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