Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit b2456d58 authored by Scott Wheeler's avatar Scott Wheeler

A fair amount of general cleanup to the way that playlists are loaded. This

makes sure that the playlist loading settings are respected on first run and I'm
rather hoping that it fixes #87430 as well (if it doesn't in 3.4 please reopen).

BUG:87430

svn path=/trunk/kdemultimedia/juk/; revision=391547
parent 5f59813e
......@@ -133,14 +133,14 @@ void CollectionList::setupTreeViewEntries(ViewMode *viewMode) const
}
}
void CollectionList::slotNewItems(const KFileItemList &items, bool importPlaylists)
void CollectionList::slotNewItems(const KFileItemList &items)
{
QStringList files;
for(KFileItemListIterator it(items); it.current(); ++it)
files.append((*it)->url().path());
addFiles(files, importPlaylists);
addFiles(files);
update();
}
......
......@@ -102,7 +102,7 @@ public slots:
void slotRemoveItem(const QString &file);
void slotRefreshItem(const QString &file);
void slotNewItems(const KFileItemList &items, bool importPlaylists);
void slotNewItems(const KFileItemList &items);
void slotRefreshItems(const KFileItemList &items);
void slotDeleteItem(KFileItem *item);
......
......@@ -1016,7 +1016,7 @@ void Playlist::decode(QMimeSource *s, PlaylistItem *item)
for(KURL::List::Iterator it = urls.begin(); it != urls.end(); ++it)
fileList.append((*it).path());
addFiles(fileList, m_collection->importPlaylists(), item);
addFiles(fileList, item);
}
bool Playlist::eventFilter(QObject *watched, QEvent *e)
......@@ -1203,8 +1203,7 @@ void Playlist::createItems(const PlaylistItemList &siblings, PlaylistItem *after
createItems<CollectionListItem, PlaylistItem, PlaylistItem>(siblings, after);
}
void Playlist::addFiles(const QStringList &files, bool importPlaylists,
PlaylistItem *after)
void Playlist::addFiles(const QStringList &files, PlaylistItem *after)
{
if(!after)
after = static_cast<PlaylistItem *>(lastItem());
......@@ -1217,9 +1216,9 @@ void Playlist::addFiles(const QStringList &files, bool importPlaylists,
const QStringList::ConstIterator filesEnd = files.end();
for(QStringList::ConstIterator it = files.begin(); it != filesEnd; ++it)
addFile(*it, queue, importPlaylists, &after);
addFile(*it, queue, true, &after);
addFileHelper(queue, importPlaylists, &after, true);
addFileHelper(queue, &after, true);
m_blockDataChanged = false;
......@@ -1647,7 +1646,7 @@ void Playlist::addFile(const QString &file, FileHandleList &files, bool importPl
return;
processEvents();
addFileHelper(files, importPlaylists, after);
addFileHelper(files, after);
// Our biggest thing that we're fighting during startup is too many stats
// of files. Make sure that we don't do one here if it's not needed.
......@@ -1692,8 +1691,14 @@ void Playlist::addFile(const QString &file, FileHandleList &files, bool importPl
for(dirEntry = ::readdir(dir); dirEntry; dirEntry = ::readdir(dir)) {
if(strcmp(dirEntry->d_name, ".") != 0 && strcmp(dirEntry->d_name, "..") != 0) {
// We set importPlaylists to the value from the add directories
// dialog as we want to load all of the ones that the user has
// explicitly asked for, but not those that we find in lower
// directories.
addFile(fileInfo.filePath() + QDir::separator() + QFile::decodeName(dirEntry->d_name),
files, importPlaylists, after);
files, m_collection->importPlaylists(), after);
}
}
::closedir(dir);
......@@ -1706,8 +1711,7 @@ void Playlist::addFile(const QString &file, FileHandleList &files, bool importPl
}
}
void Playlist::addFileHelper(FileHandleList &files, bool loadPlaylists,
PlaylistItem **after, bool ignoreTimer)
void Playlist::addFileHelper(FileHandleList &files, PlaylistItem **after, bool ignoreTimer)
{
static QTime time = QTime::currentTime();
......@@ -1728,7 +1732,7 @@ void Playlist::addFileHelper(FileHandleList &files, bool loadPlaylists,
m_collection->raiseDistraction();
const FileHandleList::ConstIterator filesEnd = files.end();
for(FileHandleList::ConstIterator it = files.begin(); it != filesEnd; ++it)
*after = createItem(*it, *after, loadPlaylists);
*after = createItem(*it, *after, false);
files.clear();
if(visible)
......
......@@ -189,8 +189,7 @@ public:
* items since it has the overhead of checking to see if the file is a playlist
* or directory first.
*/
void addFiles(const QStringList &files, bool importPlaylists,
PlaylistItem *after = 0);
void addFiles(const QStringList &files, PlaylistItem *after = 0);
/**
* Returns the file name associated with this playlist (an m3u file) or
......@@ -536,8 +535,8 @@ private:
void addFile(const QString &file, FileHandleList &files, bool importPlaylists,
PlaylistItem **after);
void addFileHelper(FileHandleList &files, bool importPlaylists,
PlaylistItem **after, bool ignoreTimer = false);
void addFileHelper(FileHandleList &files, PlaylistItem **after,
bool ignoreTimer = false);
void redisplaySearch() { setSearch(m_search); }
......
......@@ -434,12 +434,12 @@ void PlaylistBox::decode(QMimeSource *s, Item *item)
}
if(item && item->playlist())
item->playlist()->addFiles(files, true);
item->playlist()->addFiles(files);
else {
QString name = playlistNameDialog();
if(!name.isNull()) {
Playlist *p = new Playlist(this, name);
p->addFiles(files, true);
p->addFiles(files);
}
}
}
......
......@@ -285,10 +285,10 @@ void PlaylistCollection::open(const QStringList &l)
KGuiItem(i18n("Current")),
KGuiItem(i18n("Collection"))) == KMessageBox::No)
{
CollectionList::instance()->addFiles(files, true);
CollectionList::instance()->addFiles(files);
}
else
visiblePlaylist()->addFiles(files, true);
visiblePlaylist()->addFiles(files);
dataChanged();
}
......@@ -298,16 +298,22 @@ void PlaylistCollection::open(const QString &playlist, const QStringList &files)
Playlist *p = playlistByName(playlist);
if(p)
p->addFiles(files, m_importPlaylists);
p->addFiles(files);
}
void PlaylistCollection::addFolder()
{
kdDebug(65432) << k_funcinfo << endl;
DirectoryList l(m_folderList, m_importPlaylists, widget, "directoryList");
DirectoryList::Result result = l.exec();
if(result.status == QDialog::Accepted) {
m_dirLister.blockSignals(true);
const bool reload = m_importPlaylists != result.addPlaylists;
m_importPlaylists = result.addPlaylists;
for(QStringList::Iterator it = result.addedDirs.begin();
it != result.addedDirs.end(); it++)
{
......@@ -322,14 +328,14 @@ void PlaylistCollection::addFolder()
m_folderList.remove(*it);
}
m_importPlaylists = result.addPlaylists;
if(result.addPlaylists && !m_importPlaylists)
if(reload)
open(m_folderList);
else if(!result.addedDirs.isEmpty())
open(result.addedDirs);
saveConfig();
m_dirLister.blockSignals(false);
}
}
......@@ -367,7 +373,7 @@ void PlaylistCollection::saveAs()
void PlaylistCollection::reload()
{
if(visiblePlaylist() == CollectionList::instance())
CollectionList::instance()->addFiles(m_folderList, m_importPlaylists);
CollectionList::instance()->addFiles(m_folderList);
else
visiblePlaylist()->slotReload();
......@@ -426,7 +432,7 @@ PlaylistItemList PlaylistCollection::selectedItems()
void PlaylistCollection::scanFolders()
{
CollectionList::instance()->addFiles(m_folderList, m_importPlaylists);
CollectionList::instance()->addFiles(m_folderList);
if(CollectionList::instance()->count() == 0)
addFolder();
......@@ -729,7 +735,7 @@ void PlaylistCollection::removeFileFromDict(const QString &file)
void PlaylistCollection::dirChanged(const QString &path)
{
CollectionList::instance()->addFiles(path, m_importPlaylists);
CollectionList::instance()->addFiles(path);
}
Playlist *PlaylistCollection::playlistByName(const QString &name) const
......@@ -752,7 +758,7 @@ Playlist *PlaylistCollection::playlistByName(const QString &name) const
void PlaylistCollection::newItems(const KFileItemList &list) const
{
CollectionList::instance()->slotNewItems(list, m_importPlaylists);
CollectionList::instance()->slotNewItems(list);
}
////////////////////////////////////////////////////////////////////////////////
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment