playlistsplitter.cpp 20.1 KB
Newer Older
1 2 3 4 5
/***************************************************************************
                          playlistsplitter.cpp  -  description
                             -------------------
    begin                : Fri Sep 13 2002
    copyright            : (C) 2002 by Scott Wheeler
6
    email                : wheeler@kde.org
7 8 9 10 11 12 13 14 15 16 17
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

18
#include <kstandarddirs.h>
19
#include <kmessagebox.h>
Nadeem Hasan's avatar
Nadeem Hasan committed
20
#include <klineeditdlg.h>
21
#include <kcmdlineargs.h>
22 23
#include <kdebug.h>

24
#include <qpopupmenu.h>
25

26
#include "playlistsplitter.h"
27
#include "searchwidget.h"
28
#include "directorylist.h"
29
#include "playlistsearch.h"
30
#include "dynamicplaylist.h"
31
#include "searchplaylist.h"
32
#include "mediafiles.h"
33 34

////////////////////////////////////////////////////////////////////////////////
35
// helper functions
36 37
////////////////////////////////////////////////////////////////////////////////

38
void processEvents()
39
{
40 41 42
    static int processed = 0;
    if(processed == 0)
        kapp->processEvents();
43
    processed = (processed + 1) % 5;
44 45
}

46
////////////////////////////////////////////////////////////////////////////////
47
// public methods
48 49
////////////////////////////////////////////////////////////////////////////////

50
PlaylistSplitter::PlaylistSplitter(QWidget *parent, const char *name) :
51
    QSplitter(Qt::Horizontal, parent, name),
52
    m_playingItem(0), m_searchWidget(0), m_dynamicList(0),
53
    m_nextPlaylistItem(0)
54
{
55 56 57 58 59 60 61 62
#ifndef NO_DEBUG
    m_restore = KCmdLineArgs::parsedArgs()->isSet("restore");
#else
    m_restore = true;
#endif

    m_dirWatch = new KDirWatch();

63 64
    setupLayout();
    readConfig();
65 66

    m_editor->slotUpdateCollection();
67
}
68

69
PlaylistSplitter::~PlaylistSplitter()
70
{
Scott Wheeler's avatar
Scott Wheeler committed
71
    delete m_dirWatch;
72
    saveConfig();
73 74
}

75
QString PlaylistSplitter::uniquePlaylistName(const QString &startingWith, bool useParenthesis)
76
{
77
    if(!m_playlistBox)
78
	return QString::null;
79

80
    QStringList names = m_playlistBox->names();
81 82 83

    int playlistNumber = 1;

84
    // while the list contains more than zero instances of the generated
85 86
    // string...

87 88 89
    if(useParenthesis) {
	while(names.contains(startingWith + " (" + QString::number(playlistNumber) + ")") != 0)
	    playlistNumber++;
90 91

	return startingWith + " (" + QString::number(playlistNumber) + ")";
92
    }
93
    else {
94 95
	while(names.contains(startingWith + ' ' + QString::number(playlistNumber)) != 0)
	    playlistNumber++;
96

97
	return startingWith + " " + QString::number(playlistNumber);
98
    }
99 100
}

101
QString PlaylistSplitter::playNextFile(bool random, bool loopPlaylist)
102
{
103 104
    PlaylistItem *i;

105
    // Four basic cases here:  (1) We've asked for a specific next item, (2) play
106
    // the item that's after the currently playing item, (3) play the selected
107
    // item or (4) play the first item in the list.
108

109
    // (1) we've asked for a specific next item
110
    if(m_nextPlaylistItem && m_nextPlaylistItem != m_playingItem) {
111 112 113
        i = m_nextPlaylistItem;
        m_nextPlaylistItem = 0;
    }
114
    // (2) play the item after the currently selected item
115
    else if(m_playingItem) {
116 117
        Playlist *p = static_cast<Playlist *>(m_playingItem->listView());
        i = p->nextItem(m_playingItem, random);
118
        if(!i && loopPlaylist)
119
            i = static_cast<PlaylistItem *>(p->firstChild());
120
    }
121 122
    // (3) play the selected item
    else if(playlistSelection().size() > 0) {
123
        i = playlistSelection().first();
124 125
        if(!i)
            i = static_cast<PlaylistItem *>(visiblePlaylist()->firstChild());
126
    }
127 128 129
    // (4) play the first item in the list
    else
        i = static_cast<PlaylistItem *>(visiblePlaylist()->firstChild());
130

131
    return play(i);
132 133
}

134
QString PlaylistSplitter::playPreviousFile(bool random)
135
{
136
    if(!m_playingItem)
137
	return QString::null;
138

139 140
    Playlist *p = static_cast<Playlist *>(m_playingItem->listView());
    PlaylistItem *i = p->previousItem(m_playingItem, random);
141

142
    return play(i);
143 144
}

145 146 147 148 149 150
void PlaylistSplitter::populatePlayHistoryMenu(QPopupMenu* menu, bool random)
{
    Playlist *p = static_cast<Playlist *>(m_playingItem->listView());
    PlaylistItemList list = p->historyItems(m_playingItem, random);
    menu->clear();
    int i = 0;
151
    for(PlaylistItemList::Iterator it = list.begin(); it != list.end(); ++it)
152 153 154
        menu->insertItem((*it)->tag()->track(), ++i);
}

155 156 157 158 159 160 161 162
QString PlaylistSplitter::playSelectedFile()
{
    if(playlistSelection().isEmpty())
	return QString::null;
    else
	return play(playlistSelection().first());
}

163 164 165 166
QString PlaylistSplitter::playFirstFile()
{
    Playlist *p = visiblePlaylist();
    PlaylistItem *i = static_cast<PlaylistItem *>(p->firstChild());
167

168
    return play(i);
169 170
}

171 172 173 174 175 176 177 178 179
QString PlaylistSplitter::playRandomFile()
{
    Playlist *p = visiblePlaylist();
    PlaylistItem *i = static_cast<PlaylistItem *>(p->firstChild());

    // Not exactly random (the first item won't be taken into account)
    return play(p->nextItem(i, true));
}

180 181
void PlaylistSplitter::stop()
{
182 183
    m_nextPlaylistItem = 0;

184 185 186 187 188
    if(!m_playingItem)
	return;

    Playlist *p = static_cast<Playlist *>(m_playingItem->listView());

189 190 191
    if(p)
	p->setPlaying(m_playingItem, false);

192
    m_playingItem = 0;
193 194 195 196
}

QString PlaylistSplitter::playingArtist() const
{
197 198
    if(m_playingItem)
	return m_playingItem->text(PlaylistItem::ArtistColumn);
199
    else
200
	return QString::null;
201 202 203 204
}

QString PlaylistSplitter::playingTrack() const
{
205 206
    if(m_playingItem)
	return m_playingItem->text(PlaylistItem::TrackColumn);
207
    else
208
	return QString::null;
209 210 211 212
}

QString PlaylistSplitter::playingList() const
{
213 214
    if(m_playingItem)
	return static_cast<Playlist *>(m_playingItem->listView())->name();
215
    else
216
	return QString::null;
217 218
}

219
void PlaylistSplitter::open(const QString &file)
220
{
221 222 223
    if(file.isEmpty())
	return;

224 225 226 227 228
    if(visiblePlaylist() == m_collection ||
       KMessageBox::questionYesNo(this,
				  i18n("Do you want to add this item to the current list or to the collection list?"),
				  QString::null,
				  KGuiItem(i18n("Current")),
229 230
				  KGuiItem(i18n("Collection"))) == KMessageBox::No)
    {
231
	slotAddToPlaylist(file, m_collection);
232
    }
233
    else
234
	slotAddToPlaylist(file, visiblePlaylist());
235 236
}

237
void PlaylistSplitter::open(const QStringList &files)
238
{
239 240
    if(files.isEmpty())
	return;
241 242 243 244 245 246 247

    if(visiblePlaylist() == m_collection ||
       KMessageBox::questionYesNo(this,
				  i18n("Do you want to add these items to the current list or to the collection list?"),
				  QString::null,
				  KGuiItem(i18n("Current")),
				  KGuiItem(i18n("Collection"))) == KMessageBox::No)
248
    {
249
	slotAddToPlaylist(files, m_collection);
250
    }
251
    else
252
	slotAddToPlaylist(files, visiblePlaylist());
253 254 255 256
}

Playlist *PlaylistSplitter::createPlaylist(const QString &name)
{
257
    Playlist *p = new Playlist(m_playlistStack, name);
258 259
    setupPlaylist(p, true);
    return p;
260 261
}

262 263 264 265
////////////////////////////////////////////////////////////////////////////////
// public slots
////////////////////////////////////////////////////////////////////////////////

266
void PlaylistSplitter::slotOpen()
267
{
268
    open(MediaFiles::openDialog(this));
269 270
}

271
void PlaylistSplitter::slotOpenDirectory()
272
{
273
    DirectoryList *l = new DirectoryList(m_directoryList, this, "directoryList");
274

275
    m_directoryQueue.clear();
276
    m_directoryQueueRemove.clear();
277

278
    connect(l, SIGNAL(signalDirectoryAdded(const QString &)),
279
	    this, SLOT(slotQueueDirectory(const QString &)));
280
    connect(l, SIGNAL(signalDirectoryRemoved(const QString &)),
281
	    this, SLOT(slotQueueDirectoryRemove(const QString &)));
282 283

    if(l->exec() == QDialog::Accepted) {
284
	open(m_directoryQueue);
285 286
	for(QStringList::Iterator it = m_directoryQueue.begin(); it !=  m_directoryQueue.end(); it++)
	    m_dirWatch->addDir(*it, false, true);
287

288
	m_directoryList += m_directoryQueue;
289 290 291

	QStringList::Iterator it = m_directoryQueueRemove.begin();
	for(; it !=  m_directoryQueueRemove.end(); it++) {
292
	    m_dirWatch->removeDir(*it);
293
	    m_directoryList.remove(*it);
294
	}
295 296
    }
}
297

298
Playlist *PlaylistSplitter::slotCreatePlaylist()
299 300 301
{
    bool ok;

302
    // If this text is changed, please also change it in PlaylistBox::duplicate().
303

304
    QString name = KLineEditDlg::getText(i18n("Create New Playlist"),
Nadeem Hasan's avatar
Nadeem Hasan committed
305 306
	i18n("Please enter a name for the new playlist:"),
	uniquePlaylistName(), &ok);
307
    if(ok)
308
	return createPlaylist(name);
309
    else
310
	return 0;
311 312
}

313
void PlaylistSplitter::slotSelectPlaying()
314
{
315
    if(!m_playingItem)
316 317
	return;

318
    Playlist *l = static_cast<Playlist *>(m_playingItem->listView());
319

320 321
    if(!l)
	return;
322

323
    l->clearSelection();
324 325
    l->setSelected(m_playingItem, true);
    l->ensureItemVisible(m_playingItem);
Nadeem Hasan's avatar
Nadeem Hasan committed
326

327 328
    if(l != visiblePlaylist())
	m_playlistBox->raise(l);
329 330
}

331
void PlaylistSplitter::slotDeleteSelectedItems()
332 333 334
{
    Playlist *p = visiblePlaylist();
    if(p)
335
	p->slotDeleteSelectedItems();
336 337
}

338 339 340 341
void PlaylistSplitter::slotAddToPlaylist(const QString &file, Playlist *list)
{
    KApplication::setOverrideCursor(Qt::waitCursor);
    addImpl(file, list);
342
    list->emitNumberOfItemsChanged();
343
    KApplication::restoreOverrideCursor();
Nadeem Hasan's avatar
Nadeem Hasan committed
344

345 346 347 348 349 350 351 352 353
    if(m_editor)
	m_editor->slotUpdateCollection();
}

void PlaylistSplitter::slotAddToPlaylist(const QStringList &files, Playlist *list)
{
    KApplication::setOverrideCursor(Qt::waitCursor);
    for(QStringList::ConstIterator it = files.begin(); it != files.end(); ++it)
        addImpl(*it, list);
354
    list->emitNumberOfItemsChanged();
355 356 357 358 359 360
    KApplication::restoreOverrideCursor();

    if(m_editor)
	m_editor->slotUpdateCollection();
}

361 362 363 364 365 366 367
void PlaylistSplitter::slotSetSearchVisible(bool visible)
{
    m_searchWidget->setShown(visible);
    redisplaySearch();
}


368
void PlaylistSplitter::slotGuessTagInfoFile()
369
{
370 371 372 373 374 375 376 377
    visiblePlaylist()->slotGuessTagInfoFile();
    if(m_editor)
        m_editor->slotRefresh();
}

void PlaylistSplitter::slotGuessTagInfoInternet()
{
    visiblePlaylist()->slotGuessTagInfoInternet();
378 379 380 381
    if(m_editor)
        m_editor->slotRefresh();
}

382 383 384 385 386 387 388
void PlaylistSplitter::slotRenameFile()
{
    visiblePlaylist()->slotRenameFile();
    if(m_editor)
        m_editor->slotRefresh();
}

389 390 391 392 393 394
////////////////////////////////////////////////////////////////////////////////
// private members
////////////////////////////////////////////////////////////////////////////////

void PlaylistSplitter::setupLayout()
{
395 396
    setOpaqueResize(true);

397
    m_playlistBox = new PlaylistBox(this, "playlistBox");
398

399 400 401
    connect(m_playlistBox, SIGNAL(signalCreateSearchList(const PlaylistSearch &, const QString &, const QString &)),
            this, SLOT(slotCreateSearchList(const PlaylistSearch &, const QString &, const QString &)));

402 403 404 405 406
    // Create a splitter to go between the playlists and the editor.

    QSplitter *editorSplitter = new QSplitter(Qt::Vertical, this, "editorSplitter");

    // Create the playlist and the editor.
407

408 409
    m_playlistStack = new QWidgetStack(editorSplitter, "playlistStack");
    m_editor = new TagEditor(editorSplitter, "tagEditor");
410 411 412

    // Make the editor as small as possible (or at least as small as recommended)

413
    editorSplitter->setResizeMode(m_editor, QSplitter::FollowSizeHint);
414

415
    // Make the connection that will update the selected playlist when a
416 417
    // selection is made in the playlist box.

418
    connect(m_playlistBox, SIGNAL(signalCurrentChanged(const PlaylistList &)),
419
	    this, SLOT(slotChangePlaylist(const PlaylistList &)));
420

421
    connect(m_playlistBox, SIGNAL(signalDoubleClicked()), this, SIGNAL(signalListBoxDoubleClicked()));
422

423
    // Create the collection list; this should always exist.  This has a
424
    // slightly different creation process than normal playlists (since it in
425
    // fact is a subclass) so it is created here rather than by using
426
    // slotCreatePlaylist().
427

428
    CollectionList::initialize(m_playlistStack, m_restore);
429
    m_collection = CollectionList::instance();
430
    setupPlaylist(m_collection, true, "folder_sound", true);
431
    connect(m_collection, SIGNAL(signalCollectionChanged()), m_editor, SLOT(slotUpdateCollection()));
432
    connect(m_collection, SIGNAL(signalRequestPlaylistCreation(const PlaylistItemList &)),
433
	    this, SLOT(slotCreatePlaylist(const PlaylistItemList &)));
434

435 436 437 438

    // Create the search widget -- this must be done after the CollectionList is created.
    m_searchWidget = new SearchWidget(editorSplitter, CollectionList::instance(), "searchWidget");
    editorSplitter->moveToFirst(m_searchWidget);
439
    connect(m_searchWidget, SIGNAL(signalQueryChanged()), this, SLOT(slotShowSearchResults()));
440 441 442
    connect(CollectionList::instance(), SIGNAL(signalVisibleColumnsChanged()),
	    this, SLOT(slotVisibleColumnsChanged()));

443
    // Show the collection on startup.
444
    m_playlistBox->setSelected(0, true);
445 446 447 448
}

void PlaylistSplitter::readConfig()
{
449 450 451 452
    KConfig *config = KGlobal::config();
    { // block for Playlists group
	KConfigGroupSaver saver(config, "Playlists");

453 454 455 456 457 458
	QValueList<int> splitterSizes = config->readIntListEntry("PlaylistSplitterSizes");
	if(splitterSizes.isEmpty()) {
	    splitterSizes.append(100);
	    splitterSizes.append(640);
	}
	setSizes(splitterSizes);
459

460
	if(m_restore) {
461 462 463 464

	    QString playlistsFile = KGlobal::dirs()->saveLocation("appdata") + "playlists";

	    QFile f(playlistsFile);
Nadeem Hasan's avatar
Nadeem Hasan committed
465

466 467 468
	    if(f.open(IO_ReadOnly)) {
		QDataStream s(&f);
		while(!s.atEnd()) {
469
		    Playlist *p = new Playlist(m_playlistStack);
470 471 472 473
		    s >> *p;

		    // check to see if we've alredy loaded this item before continuing

474
		    if(p->fileName().isEmpty() || !m_playlistFiles.insert(p->fileName()))
475 476 477 478
			setupPlaylist(p);
		    else
			delete p;
		}
479
	    }
480

481
	    m_directoryList = config->readListEntry("DirectoryList");
482
	    QTimer::singleShot(0, this, SLOT(slotScanDirectories()));
483

484
	    connect(m_dirWatch, SIGNAL(dirty(const QString &)),
485
		    this, SLOT(slotDirChanged(const QString &)));
486

487 488
	    QStringList::Iterator it = m_directoryList.begin();
            for(; it != m_directoryList.end(); ++it)
489 490 491
		m_dirWatch->addDir(*it, false, true);

	    m_dirWatch->startScan();
492
	}
493 494 495

	// restore the list of hidden and shown columns

496
	if(m_collection) {
497
	    for(int i = 0; i < m_collection->columns(); i++)
498
		m_columnNames.append(m_collection->columnText(i));
499
	}
500

501
    }
502
}
503 504 505 506

void PlaylistSplitter::saveConfig()
{
    KConfig *config = KGlobal::config();
507

508
    // Save the list of open playlists.
Nadeem Hasan's avatar
Nadeem Hasan committed
509

510
    if(m_restore && m_playlistBox) {
511 512 513

	// Start at item 1.  We want to skip the collection list.

514 515
	QString playlistsFile = KGlobal::dirs()->saveLocation("appdata") + "playlists";
	QFile f(playlistsFile);
516

517 518 519 520
	if(f.open(IO_WriteOnly)) {

	    QDataStream s(&f);

521
	    PlaylistList l = m_playlistBox->playlists();
522

523 524
	    for(PlaylistList::Iterator it = l.begin(); it != l.end(); it++)
		s << *(*it);
525

526
	    f.close();
527 528 529
	}
	{ // block for Playlists group
	    KConfigGroupSaver saver(config, "Playlists");
530
	    config->writeEntry("DirectoryList", m_directoryList);
531
	    config->writeEntry("SortColumn", m_collection->sortColumn());
532
	    config->writeEntry("PlaylistSplitterSizes", sizes());
533 534
	}
    }
535 536
}

537 538 539 540 541 542 543
void PlaylistSplitter::addImpl(const QString &file, Playlist *list)
{
    processEvents();
    QFileInfo fileInfo(QDir::cleanDirPath(file));
    if(fileInfo.exists()) {
        if(fileInfo.isDir()) {
            QDir dir(fileInfo.filePath());
544
            QStringList dirContents = dir.entryList();
545 546 547 548 549
            for(QStringList::Iterator it = dirContents.begin(); it != dirContents.end(); ++it)
                if(*it != "." && *it != "..")
                    addImpl(fileInfo.filePath() + QDir::separator() + *it, list);
        }
        else {
550
            if(MediaFiles::isMediaFile(file))
551
		list->createItem(fileInfo, QString::null, 0, false);
552
	    else if(MediaFiles::isPlaylistFile(file))
553 554
		openPlaylist(fileInfo.absFilePath());
        }
Nadeem Hasan's avatar
Nadeem Hasan committed
555
    }
556 557
}

558
void PlaylistSplitter::setupPlaylist(Playlist *p, bool raise, const char *icon, bool sortedFirst)
559
{
560 561
    connect(p, SIGNAL(signalSelectionChanged(const PlaylistItemList &)),
	    m_editor, SLOT(slotSetItems(const PlaylistItemList &)));
562 563 564 565 566 567 568

    connect(p, SIGNAL(doubleClicked(QListViewItem *)),
	    this, SIGNAL(signalActivated()));

    connect(p, SIGNAL(returnPressed(QListViewItem *)), 
	    this, SIGNAL(signalActivated()));

569 570
    connect(p, SIGNAL(signalNumberOfItemsChanged(Playlist *)),
	    this, SLOT(slotPlaylistCountChanged(Playlist *)));
571

572
    connect(p, SIGNAL(signalAboutToRemove(PlaylistItem *)),
573
	    this, SLOT(slotPlaylistItemRemoved(PlaylistItem *)));
574

575
    connect(p, SIGNAL(signalFilesDropped(const QStringList &, Playlist *)),
576
	    this, SLOT(slotAddToPlaylist(const QStringList &, Playlist *)));
577

578 579
    connect(p, SIGNAL(signalSetNext(PlaylistItem *)),
	    this, SLOT(slotSetNextItem(PlaylistItem *)));
580

581
    if(icon)
582
	m_playlistBox->createItem(p, icon, raise, sortedFirst);
583

584 585 586 587 588
    if(raise) {
	PlaylistList l;
	l.append(p);
	slotChangePlaylist(l);
    }
589 590
}

591 592 593
Playlist *PlaylistSplitter::openPlaylist(const QString &file)
{
    QFileInfo fileInfo(file);
594 595 596
    if(!fileInfo.exists() ||
       !fileInfo.isFile() ||
       !fileInfo.isReadable() ||
597 598
       m_playlistFiles.insert(fileInfo.absFilePath()))
    {
599
	return 0;
600
    }
601

602
    Playlist *p = new Playlist(file, m_playlistStack, fileInfo.baseName(true));
603
    setupPlaylist(p);
604
    return p;
605 606
}

607 608 609 610 611 612 613
QString PlaylistSplitter::play(PlaylistItem *item)
{
    stop();

    if(!item)
	return QString::null;

614 615 616 617
    Playlist *p = static_cast<Playlist *>(item->listView());

    p->setPlaying(item, true);

618 619 620 621 622
    m_playingItem = item;

    return item->absFilePath();
}

623 624 625 626 627 628 629 630 631 632
void PlaylistSplitter::redisplaySearch()
{
    if(!m_searchWidget->isVisible() || visiblePlaylist()->search().isEmpty())
	visiblePlaylist()->setItemsVisible(visiblePlaylist()->items(), true);
    else {
	Playlist::setItemsVisible(visiblePlaylist()->search().matchedItems(), true);
	Playlist::setItemsVisible(visiblePlaylist()->search().unmatchedItems(), false);
    }
}

633 634 635 636
////////////////////////////////////////////////////////////////////////////////
// private slots
////////////////////////////////////////////////////////////////////////////////

637
void PlaylistSplitter::slotChangePlaylist(const PlaylistList &l)
638
{
639 640
    if(l.isEmpty()) {
	emit signalPlaylistChanged();
641
	return;
642
    }
643

644 645
    Playlist *current = m_dynamicList;

646
    m_nextPlaylistItem = 0;
647 648 649 650
    if(l.count() == 1) {
	m_playlistStack->raiseWidget(l.first());
	m_editor->slotSetItems(playlistSelection());
	m_dynamicList = 0;
651 652 653 654 655

	if(m_searchWidget) {
	    m_searchWidget->setSearch(l.first()->search());
	    redisplaySearch();
	}
656 657
    }
    else {
658
	m_dynamicList = new DynamicPlaylist(l, m_playlistStack, i18n("Dynamic List"));
659 660 661 662 663
	setupPlaylist(m_dynamicList, true, 0);
    }

    if(current)
	delete current;
664 665

    emit signalPlaylistChanged();
666 667
}

668
void PlaylistSplitter::slotPlaylistCountChanged(Playlist *p)
669
{
670 671
    if(p && p == m_playlistStack->visibleWidget())
	emit signalSelectedPlaylistCountChanged(p->childCount());
672 673
}

674
void PlaylistSplitter::slotPlaylistItemRemoved(PlaylistItem *item)
675
{
676 677
    if(item == m_playingItem)
	m_playingItem = 0;
678 679 680

    if(item == m_nextPlaylistItem)
	m_nextPlaylistItem = 0;
681 682
}

683
void PlaylistSplitter::slotCreatePlaylist(const PlaylistItemList &items)
684
{
685 686 687
    if(items.isEmpty())
	return;

688
    Playlist *playlist = slotCreatePlaylist();
689

690
    if(!playlist)
691
        return;
692

693
    playlist->createItems(items);
694 695
}

696
void PlaylistSplitter::slotShowSearchResults()
697 698 699 700
{
    PlaylistList playlists;
    playlists.append(visiblePlaylist());

701
    PlaylistSearch search = m_searchWidget->search(playlists);
702

703 704
    visiblePlaylist()->setSearch(search);
    redisplaySearch();
705 706
}

707 708 709 710 711
void PlaylistSplitter::slotVisibleColumnsChanged()
{
    m_searchWidget->slotUpdateColumns();
    m_searchWidget->slotQueryChanged();
    if(m_searchWidget->searchedColumns(0).count() > 1)
712
        slotShowSearchResults();
713 714
}

715 716 717 718 719 720 721 722 723
void PlaylistSplitter::slotCreateSearchList(const PlaylistSearch &search, 
					    const QString &searchCategory,
					    const QString &name)
{
    SearchPlaylist *p = new SearchPlaylist(search, m_playlistStack, name);
    m_playlistBox->createSearchItem(p, searchCategory);
    setupPlaylist(p, false, 0);
}

724
#include "playlistsplitter.moc"
Nadeem Hasan's avatar
Nadeem Hasan committed
725 726

// vim:ts=8