Commit 4c6bac11 authored by Scott Wheeler's avatar Scott Wheeler

Initialize the tree view after the collection list has been initialized

by emiting a signal when the collection item is inserted.

CCMAIL:60386-done@bugs.kde.org

svn path=/trunk/kdemultimedia/juk/; revision=238454
parent 536010b2
......@@ -92,6 +92,7 @@ PlaylistBox::PlaylistBox(PlaylistSplitter *parent, const QString &name) :
m_viewModeAction->setItems(modeNames);
m_viewModeAction->setCurrentItem(m_viewModeIndex);
m_viewModes[m_viewModeIndex]->setShown(true);
m_viewModeAction->plug(m_contextMenu);
connect(m_viewModeAction, SIGNAL(activated(int)), this, SLOT(slotSetViewMode(int)));
......@@ -125,6 +126,9 @@ void PlaylistBox::createItem(Playlist *playlist, const char *icon, bool raise, b
ensureCurrentVisible();
}
i->setSortedFirst(sortedFirst);
if(playlist == CollectionList::instance())
emit signalCollectionInitialized();
}
void PlaylistBox::createSearchItem(SearchPlaylist *playlist, const QString &searchCategory)
......
......@@ -88,6 +88,7 @@ signals:
void signalCreateSearchList(const PlaylistSearch &search,
const QString &searchCategory,
const QString &name);
void signalCollectionInitialized();
private:
void readConfig();
......
......@@ -197,24 +197,14 @@ void TreeViewMode::setShown(bool show)
PlaylistBox::Item *collectionItem = PlaylistBox::Item::collectionItem();
if(!collectionItem)
kdDebug(65432) << "TreeViewMode::setShown() - the CollectionList isn't initialized yet." << endl;
if(collectionItem && m_searchCategories.isEmpty()) {
PlaylistBox::Item *i;
i = new PlaylistBox::Item(collectionItem, "cdimage", i18n("Artists"));
m_searchCategories.insert("artists", i);
setupCategory("artists", CollectionList::instance()->viewModeItems()["artists"].values(), 1);
i = new PlaylistBox::Item(collectionItem, "cdimage", i18n("Albums"));
m_searchCategories.insert("albums", i);
setupCategory("albums", CollectionList::instance()->viewModeItems()["albums"].values(), 2);
for(QDictIterator<PlaylistBox::Item> it(m_searchCategories); it.current(); ++it)
it.current()->setSortedFirst(true);
if(!collectionItem) {
connect(playlistBox(), SIGNAL(signalCollectionInitialized()),
this, SLOT(slotSetupCategories()));
return;
}
if(collectionItem && m_searchCategories.isEmpty())
slotSetupCategories();
else {
for(QDictIterator<PlaylistBox::Item> it(m_searchCategories); it.current(); ++it)
it.current()->setVisible(true);
......@@ -260,4 +250,23 @@ void TreeViewMode::setupCategory(const QString &searchCategory, const QStringLis
KApplication::restoreOverrideCursor();
}
void TreeViewMode::slotSetupCategories()
{
PlaylistBox::Item *i;
PlaylistBox::Item *collectionItem = PlaylistBox::Item::collectionItem();
i = new PlaylistBox::Item(collectionItem, "cdimage", i18n("Artists"));
m_searchCategories.insert("artists", i);
setupCategory("artists", CollectionList::instance()->viewModeItems()["artists"].values(), 1);
i = new PlaylistBox::Item(collectionItem, "cdimage", i18n("Albums"));
m_searchCategories.insert("albums", i);
setupCategory("albums", CollectionList::instance()->viewModeItems()["albums"].values(), 2);
for(QDictIterator<PlaylistBox::Item> it(m_searchCategories); it.current(); ++it)
it.current()->setSortedFirst(true);
}
#include "viewmode.moc"
......@@ -87,6 +87,8 @@ public:
class TreeViewMode : public CompactViewMode
{
Q_OBJECT
public:
TreeViewMode(PlaylistBox *l);
virtual ~TreeViewMode();
......@@ -101,6 +103,12 @@ public:
private:
void setupCategory(const QString &searchCategory, const QStringList &members, int column);
private slots:
/**
* Setup all of the categories.
*/
void slotSetupCategories();
QDict<PlaylistBox::Item> m_searchCategories;
};
......
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