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 22
#include <kdebug.h>

23
#include <qpopupmenu.h>
24

25
#include "playlistsplitter.h"
26
#include "directorylist.h"
27
#include "playlistsearch.h"
28

29 30
QStringList *PlaylistSplitter::m_mediaExtensions = 0;
QStringList *PlaylistSplitter::m_listExtensions = 0;
31 32

////////////////////////////////////////////////////////////////////////////////
33
// helper functions
34 35
////////////////////////////////////////////////////////////////////////////////

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

44
////////////////////////////////////////////////////////////////////////////////
45
// public methods
46 47
////////////////////////////////////////////////////////////////////////////////

48 49 50 51
PlaylistSplitter::PlaylistSplitter(QWidget *parent, bool restore, const char *name) : 
    QSplitter(Qt::Horizontal, parent, name),
    m_playingItem(0), m_searchWidget(0), m_dynamicList(0), m_restore(restore), 
    m_nextPlaylistItem(0)
52
{
53 54 55 56 57 58 59 60
    if(!m_mediaExtensions && !m_listExtensions) {
	m_mediaExtensions = new QStringList();
	m_listExtensions = new QStringList();

	m_mediaExtensions->append("mp3");
	m_mediaExtensions->append("ogg");
	m_listExtensions->append("m3u");
    }
61 62 63

    setupLayout();
    readConfig();
64 65

    m_editor->slotUpdateCollection();
66
}
67

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

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

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

    int playlistNumber = 1;

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

86 87 88 89
    if(useParenthesis) {
	while(names.contains(startingWith + " (" + QString::number(playlistNumber) + ")") != 0)
	    playlistNumber++;
	
90
	return startingWith + " (" + QString::number(playlistNumber) + ")";	
91 92 93 94 95 96
    }
    else
    {
	while(names.contains(startingWith + ' ' + QString::number(playlistNumber)) != 0)
	    playlistNumber++;
	
97
	return startingWith + " " + QString::number(playlistNumber);
98
    }
99 100
}

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

105 106 107
    // Four basic cases here:  (1) We've asked for a specific next item, (2) play
    // the item that's after the currently playing item, (3) play the selected 
    // 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 151 152 153 154 155 156
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;
    for (PlaylistItemList::iterator it = list.begin(); it != list.end(); ++it)
    {
        menu->insertItem((*it)->tag()->track(), ++i);
    }
}

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

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

170
    return play(i);
171 172
}

173 174 175 176 177 178 179 180 181
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));
}

182 183
void PlaylistSplitter::stop()
{
184 185
    m_nextPlaylistItem = 0;

186 187 188 189 190
    if(!m_playingItem)
	return;

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

191 192 193
    if(p)
	p->setPlaying(m_playingItem, false);

194
    m_playingItem = 0;
195 196 197 198
}

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

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

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

221
QString PlaylistSplitter::extensionsString(const QStringList &extensions, const QString &type) // static
222
{
223 224 225 226 227 228 229 230 231 232 233 234
    QStringList l;

    for(QStringList::ConstIterator it = extensions.begin(); it != extensions.end(); ++it)
	l.append(QString("*." + (*it)));

    // i.e. "*.m3u, *.mp3|Media Files"

    QString s = l.join(" ");

    if(type != QString::null)
	s += "|" + type + " (" + l.join(", ") + ")";

235
    return s;
236 237
}

238 239
void PlaylistSplitter::open(const QString &file) 
{
240 241 242
    if(file.isEmpty())
	return;

243
    if(visiblePlaylist() == m_collection || 
244 245 246 247 248 249
       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")), 
				  KGuiItem(i18n("Collection"))) == KMessageBox::No)
    {
250
	slotAddToPlaylist(file, m_collection);
251
    }
252
    else
253
	slotAddToPlaylist(file, visiblePlaylist());
254 255 256 257
}

void PlaylistSplitter::open(const QStringList &files) 
{
258 259 260
    if(files.isEmpty())
	return;
    
261
    if(visiblePlaylist() == m_collection || 
262 263 264 265 266 267
       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) 
    {
268
	slotAddToPlaylist(files, m_collection);
269
    }
270
    else
271
	slotAddToPlaylist(files, visiblePlaylist());
272 273 274 275
}

Playlist *PlaylistSplitter::createPlaylist(const QString &name)
{
276
    Playlist *p = new Playlist(m_playlistStack, name.latin1());
277 278
    setupPlaylist(p, true);
    return p;
279 280
}

281 282 283 284
////////////////////////////////////////////////////////////////////////////////
// public slots
////////////////////////////////////////////////////////////////////////////////

285
void PlaylistSplitter::slotOpen()
286
{
287 288
    QStringList files = KFileDialog::getOpenFileNames(
	QString::null, extensionsString((*m_mediaExtensions + *m_listExtensions), i18n("Media Files")));
289 290 291
    open(files);
}

292
void PlaylistSplitter::slotOpenDirectory()
293
{ 
294
    DirectoryList *l = new DirectoryList(m_directoryList, this, "directoryList");
295

296
    m_directoryQueue.clear();
297
    m_directoryQueueRemove.clear();
298

299 300 301 302
    connect(l, SIGNAL(signalDirectoryAdded(const QString &)), 
	    this, SLOT(slotQueueDirectory(const QString &)));
    connect(l, SIGNAL(signalDirectoryRemoved(const QString &)), 
	    this, SLOT(slotQueueDirectoryRemove(const QString &)));
303 304

    if(l->exec() == QDialog::Accepted) {
305
	open(m_directoryQueue);
306 307 308
	for(QStringList::Iterator it = m_directoryQueue.begin(); it !=  m_directoryQueue.end(); it++)
	    m_dirWatch->addDir(*it, false, true);
	    
309
	m_directoryList += m_directoryQueue;
310 311 312

	QStringList::Iterator it = m_directoryQueueRemove.begin();
	for(; it !=  m_directoryQueueRemove.end(); it++) {
313
	    m_dirWatch->removeDir(*it);
314
	    m_directoryList.remove(*it);
315
	}
316 317
    }
}
318

319
Playlist *PlaylistSplitter::slotCreatePlaylist()
320 321 322
{
    bool ok;

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

Nadeem Hasan's avatar
Nadeem Hasan committed
325 326 327
    QString name = KLineEditDlg::getText(i18n("Create New Playlist"), 
	i18n("Please enter a name for the new playlist:"),
	uniquePlaylistName(), &ok);
328
    if(ok)
329
	return createPlaylist(name);
330
    else
331
	return 0;
332 333
}

334
void PlaylistSplitter::slotSelectPlaying()
335
{
336
    if(!m_playingItem)
337 338
	return;

339
    Playlist *l = static_cast<Playlist *>(m_playingItem->listView());
340
	
341 342
    if(!l)
	return;
343

344
    l->clearSelection();
345 346
    l->setSelected(m_playingItem, true);
    l->ensureItemVisible(m_playingItem);
Nadeem Hasan's avatar
Nadeem Hasan committed
347

348 349
    if(l != visiblePlaylist())
	m_playlistBox->raise(l);
350 351
}

352
void PlaylistSplitter::slotDeleteSelectedItems()
353 354 355
{
    Playlist *p = visiblePlaylist();
    if(p)
356
	p->slotDeleteSelectedItems();
357 358
}

359 360 361 362 363
void PlaylistSplitter::slotAddToPlaylist(const QString &file, Playlist *list)
{
    KApplication::setOverrideCursor(Qt::waitCursor);
    addImpl(file, list);
    KApplication::restoreOverrideCursor();
Nadeem Hasan's avatar
Nadeem Hasan committed
364

365 366 367 368 369 370 371 372 373 374 375 376 377 378 379
    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);
    KApplication::restoreOverrideCursor();

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

380 381 382 383 384 385 386
void PlaylistSplitter::slotGuessTagInfo()
{
    visiblePlaylist()->slotGuessTagInfo();
    if(m_editor)
        m_editor->slotRefresh();
}

387 388 389 390 391 392 393
void PlaylistSplitter::slotRenameFile()
{
    visiblePlaylist()->slotRenameFile();
    if(m_editor)
        m_editor->slotRefresh();
}

394 395 396 397 398 399
////////////////////////////////////////////////////////////////////////////////
// private members
////////////////////////////////////////////////////////////////////////////////

void PlaylistSplitter::setupLayout()
{
400 401
    setOpaqueResize(true);

402
    m_playlistBox = new PlaylistBox(this, "playlistBox");
403 404 405 406 407 408

    // 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.
409
    
410 411
    m_playlistStack = new QWidgetStack(editorSplitter, "playlistStack");
    m_editor = new TagEditor(editorSplitter, "tagEditor");
412 413 414

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

415
    editorSplitter->setResizeMode(m_editor, QSplitter::FollowSizeHint);
416 417 418 419

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

420 421
    connect(m_playlistBox, SIGNAL(signalCurrentChanged(const PlaylistList &)), 
	    this, SLOT(slotChangePlaylist(const PlaylistList &)));
422

423
    connect(m_playlistBox, SIGNAL(signalDoubleClicked()), this, SIGNAL(signalListBoxDoubleClicked()));
424 425 426 427

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

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

437 438 439 440 441 442 443 444 445

    // 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);
    connect(m_searchWidget, SIGNAL(signalQueryChanged(const QString &, bool)),
	    this, SLOT(slotShowSearchResults(const QString &, bool)));
    connect(CollectionList::instance(), SIGNAL(signalVisibleColumnsChanged()),
	    this, SLOT(slotVisibleColumnsChanged()));

446
    // Show the collection on startup.
447
    m_playlistBox->setSelected(0, true);
448 449 450 451
}

void PlaylistSplitter::readConfig()
{
452 453 454 455
    KConfig *config = KGlobal::config();
    { // block for Playlists group
	KConfigGroupSaver saver(config, "Playlists");

456 457 458 459 460 461 462
	QValueList<int> splitterSizes = config->readIntListEntry("PlaylistSplitterSizes");
	if(splitterSizes.isEmpty()) {
	    splitterSizes.append(100);
	    splitterSizes.append(640);
	}
	setSizes(splitterSizes);
	
463
	if(m_restore) {
464 465 466 467

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

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

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

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

477
		    if(p->fileName().isEmpty() || !m_playlistFiles.insert(p->fileName()))
478 479 480 481
			setupPlaylist(p);
		    else
			delete p;
		}
482
	    }
483

484
	    m_directoryList = config->readListEntry("DirectoryList");
485
	    QTimer::singleShot(0, this, SLOT(slotScanDirectories()));
486 487

	    m_dirWatch = new KDirWatch();
488 489
	    connect(m_dirWatch, SIGNAL(dirty(const QString &)), 
		    this, SLOT(slotDirChanged(const QString &)));
490

491 492
	    QStringList::Iterator it = m_directoryList.begin();
            for(; it != m_directoryList.end(); ++it)
493 494 495
		m_dirWatch->addDir(*it, false, true);

	    m_dirWatch->startScan();
496
	}
497 498 499

	// restore the list of hidden and shown columns

500
	if(m_collection) {
501
	    for(int i = 0; i < m_collection->columns(); i++)
502
		m_columnNames.append(m_collection->columnText(i));
503
	}
504

505
    }
506
}
507 508 509 510

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

512
    // Save the list of open playlists.
Nadeem Hasan's avatar
Nadeem Hasan committed
513

514
    if(m_restore && m_playlistBox) {
515 516 517

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

518 519 520 521 522 523 524
	QString playlistsFile = KGlobal::dirs()->saveLocation("appdata") + "playlists";
	QFile f(playlistsFile);
	
	if(f.open(IO_WriteOnly)) {

	    QDataStream s(&f);

525
	    PlaylistList l = m_playlistBox->playlists();
526

527 528
	    for(PlaylistList::Iterator it = l.begin(); it != l.end(); it++)
		s << *(*it);
529

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

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

563
void PlaylistSplitter::setupPlaylist(Playlist *p, bool raise, const char *icon)
564
{
565 566 567 568 569 570 571 572 573 574 575 576
    connect(p, SIGNAL(signalSelectionChanged(const PlaylistItemList &)),
	    m_editor, SLOT(slotSetItems(const PlaylistItemList &)));
    connect(p, SIGNAL(signalDoubleClicked()),
	    this, SIGNAL(signalDoubleClicked()));
    connect(p, SIGNAL(signalNumberOfItemsChanged(Playlist *)),
	    this, SLOT(slotPlaylistCountChanged(Playlist *)));
    connect(p, SIGNAL(signalAboutToRemove(PlaylistItem *)), 
	    this, SLOT(slotPlaylistItemRemoved(PlaylistItem *)));
    connect(p, SIGNAL(signalFilesDropped(const QStringList &, Playlist *)), 
	    this, SLOT(slotAddToPlaylist(const QStringList &, Playlist *)));
    connect(p, SIGNAL(signalSetNext(PlaylistItem *)),
	    this, SLOT(slotSetNextItem(PlaylistItem *)));
577

578 579
    if(icon)
	m_playlistBox->createItem(p, icon, raise);
580

581
    if(raise)
582
	m_playlistStack->raiseWidget(p);
583 584
}

585 586 587
Playlist *PlaylistSplitter::openPlaylist(const QString &file)
{
    QFileInfo fileInfo(file);
588 589 590 591 592
    if(!fileInfo.exists() || 
       !fileInfo.isFile() || 
       !fileInfo.isReadable() || 
       m_playlistFiles.insert(fileInfo.absFilePath()))
    {
593
	return 0;
594
    }
595

596
    Playlist *p = new Playlist(file, m_playlistStack, fileInfo.baseName(true).latin1());
597
    setupPlaylist(p);
598
    return p;
599 600
}

601 602 603 604 605 606 607
QString PlaylistSplitter::play(PlaylistItem *item)
{
    stop();

    if(!item)
	return QString::null;

608 609 610 611
    Playlist *p = static_cast<Playlist *>(item->listView());

    p->setPlaying(item, true);

612 613 614 615 616
    m_playingItem = item;

    return item->absFilePath();
}

617 618 619 620
////////////////////////////////////////////////////////////////////////////////
// private slots
////////////////////////////////////////////////////////////////////////////////

621
void PlaylistSplitter::slotChangePlaylist(const PlaylistList &l)
622
{
623
    if(l.isEmpty())
624
	return;
625

626 627
    Playlist *current = m_dynamicList;

628 629
    if(m_searchWidget)
	m_searchWidget->clear();
630 631

    m_nextPlaylistItem = 0;
632 633 634 635 636 637 638 639 640 641 642 643 644
    if(l.count() == 1) {
	m_playlistStack->raiseWidget(l.first());
	m_editor->slotSetItems(playlistSelection());
	m_dynamicList = 0;
	emit signalPlaylistChanged();
    }
    else {
	m_dynamicList = new Playlist(m_playlistStack, i18n("Dynamic List"));
	setupPlaylist(m_dynamicList, true, 0);
	// unsorted...
	m_dynamicList->setSorting(m_dynamicList->columns() + 1);

	for(PlaylistList::ConstIterator it = l.begin(); it != l.end(); ++it) {
645 646
	    if(*it)
		m_dynamicList->createItems((*it)->items());
647 648 649 650 651
	}
    }

    if(current)
	delete current;
652 653
}

654
void PlaylistSplitter::slotPlaylistCountChanged(Playlist *p)
655
{
656 657
    if(p && p == m_playlistStack->visibleWidget())
	emit signalSelectedPlaylistCountChanged(p->childCount());
658 659
}

660
void PlaylistSplitter::slotPlaylistItemRemoved(PlaylistItem *item)
661
{
662 663
    if(item == m_playingItem)
	m_playingItem = 0;
664 665 666

    if(item == m_nextPlaylistItem)
	m_nextPlaylistItem = 0;
667 668
}

669
void PlaylistSplitter::slotCreatePlaylist(const PlaylistItemList &items)
670
{
671 672 673
    if(items.isEmpty())
	return;

674
    Playlist *playlist = slotCreatePlaylist();
675

676
    if(!playlist)
677
        return;
678

679
    playlist->createItems(items);
680 681
}

682 683 684 685 686 687 688 689 690 691
void PlaylistSplitter::slotShowSearchResults(const QString &query, bool caseSensitive)
{
    if(query.isEmpty()) {
	visiblePlaylist()->setItemsVisible(visiblePlaylist()->items(), true);
	return;
    }

    PlaylistList playlists;
    playlists.append(visiblePlaylist());

692
    PlaylistSearch::Component component(query, caseSensitive, m_searchWidget->searchedColumns(0));
693
    PlaylistSearch::ComponentList components;
Scott Wheeler's avatar
Scott Wheeler committed
694
    components.append(component);
695 696 697 698 699 700 701

    PlaylistSearch search(playlists, components);

    Playlist::setItemsVisible(search.matchedItems(), true);    
    Playlist::setItemsVisible(search.unmatchedItems(), false);
}

702 703 704 705 706 707 708 709
void PlaylistSplitter::slotVisibleColumnsChanged()
{
    m_searchWidget->slotUpdateColumns();
    m_searchWidget->slotQueryChanged();
    if(m_searchWidget->searchedColumns(0).count() > 1)
	slotShowSearchResults(m_searchWidget->query(), m_searchWidget->caseSensitive());
}

710
#include "playlistsplitter.moc"
Nadeem Hasan's avatar
Nadeem Hasan committed
711 712

// vim:ts=8