Commit ec5180e7 authored by Scott Wheeler's avatar Scott Wheeler

Create playlists (and as such load) faster by delaying much of the

initialization until the polish() method is called.

svn path=/trunk/kdemultimedia/juk/; revision=231696
parent 35bc462a
......@@ -114,9 +114,6 @@ CollectionList::CollectionList(QWidget *parent) : Playlist(parent, i18n("Collect
connect(m_dirWatch, SIGNAL(deleted(const QString &)), this, SLOT(slotRemoveItem(const QString &)));
connect(m_dirWatch, SIGNAL(dirty(const QString &)), this, SLOT(slotRefreshItem(const QString &)));
m_dirWatch->startScan();
rmbMenu()->insertSeparator();
rmbMenu()->insertItem(SmallIcon("new"), i18n("Create Group From Selected Items"), this, SLOT(slotCreateGroup()));
}
CollectionList::~CollectionList()
......@@ -173,6 +170,14 @@ void CollectionList::addAlbum(const QString &album)
previousAlbum = album;
}
void CollectionList::polish()
{
Playlist::polish();
rmbMenu()->insertSeparator();
rmbMenu()->insertItem(SmallIcon("new"), i18n("Create Group From Selected Items"), this, SLOT(slotCreateGroup()));
}
////////////////////////////////////////////////////////////////////////////////
// private slots
////////////////////////////////////////////////////////////////////////////////
......
......@@ -94,6 +94,8 @@ protected:
void addWatched(const QString &file) { m_dirWatch->addFile(file); }
void removeWatched(const QString &file) { m_dirWatch->removeFile(file); }
virtual void polish();
signals:
void signalCollectionChanged();
void signalRequestPlaylistCreation(const PlaylistItemList &items);
......
......@@ -386,8 +386,6 @@ void JuK::setupSplitterConnections()
for(; it != m_splitterConnections.end(); ++it)
connect((*it).first, SIGNAL(activated()), m_splitter, (*it).second);
actionCollection()->insert(m_splitter->columnVisibleAction());
connect(m_showSearchAction, SIGNAL(toggled(bool)), m_splitter, SLOT(slotSetSearchVisible(bool)));
connect(m_showEditorAction, SIGNAL(toggled(bool)), m_splitter, SLOT(slotSetEditorVisible(bool)));
connect(this, SIGNAL(dockWindowPositionChanged(QDockWindow *)), m_sliderAction, SLOT(slotUpdateOrientation(QDockWindow *)));
......@@ -467,6 +465,11 @@ void JuK::setupGlobalAccels()
m_accel->updateConnections();
}
void JuK::polish()
{
actionCollection()->insert(m_splitter->columnVisibleAction());
}
void JuK::processArgs()
{
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
......
......@@ -86,6 +86,8 @@ private:
void setupSystemTray();
void setupGlobalAccels();
virtual void polish();
void processArgs();
void keyPressEvent(QKeyEvent *);
......
......@@ -734,12 +734,13 @@ QString Playlist::resolveSymLinks(const QFileInfo &file) // static
}
////////////////////////////////////////////////////////////////////////////////
// private members
////////////////////////////////////////////////////////////////////////////////
void Playlist::setup()
void Playlist::polish()
{
if(m_polished)
return;
m_polished = true;
addColumn(i18n("Track Name"));
addColumn(i18n("Artist"));
addColumn(i18n("Album"));
......@@ -750,6 +751,8 @@ void Playlist::setup()
addColumn(i18n("Comment"));
addColumn(i18n("File Name"));
setSorting(1);
// These settings aren't really respected in KDE < 3.1.1, fixed in CVS
setRenameable(PlaylistItem::TrackColumn, true);
......@@ -765,14 +768,12 @@ void Playlist::setup()
setDropVisualizer(true);
setItemMargin(3);
setSorting(1);
//////////////////////////////////////////////////
// setup header RMB menu
//////////////////////////////////////////////////
m_columnVisibleAction = new KActionMenu(i18n("&Show Columns"), this, "showColumns");
m_headerMenu = m_columnVisibleAction->popupMenu();
m_headerMenu->insertTitle(i18n("Show"));
m_headerMenu->setCheckable(true);
......@@ -790,7 +791,6 @@ void Playlist::setup()
// hide some columns by default
//////////////////////////////////////////////////
hideColumn(PlaylistItem::CommentColumn);
hideColumn(PlaylistItem::FileNameColumn);
......@@ -820,16 +820,22 @@ void Playlist::setup()
connect(this, SIGNAL(itemRenamed(QListViewItem *, const QString &, int)),
this, SLOT(slotApplyModification(QListViewItem *, const QString &, int)));
//////////////////////////////////////////////////
addColumn(QString::null);
setResizeMode(QListView::LastColumn);
setAcceptDrops(true);
}
////////////////////////////////////////////////////////////////////////////////
// private members
////////////////////////////////////////////////////////////////////////////////
void Playlist::setup()
{
m_polished = false;
m_allowDuplicates = false;
connect(header(), SIGNAL(indexChange(int, int, int)), this, SLOT(slotColumnOrderChanged(int, int, int)));
connect(this, SIGNAL(signalDataChanged()), this, SIGNAL(signalChanged()));
connect(this, SIGNAL(signalNumberOfItemsChanged(Playlist *)), this, SIGNAL(signalChanged()));
}
......
......@@ -215,6 +215,8 @@ protected:
KPopupMenu *rmbMenu() { return m_rmbMenu; }
const KPopupMenu *rmbMenu() const { return m_rmbMenu; }
virtual void polish();
signals:
/**
* This signal is connected to PlaylistItem::refreshed() in the
......@@ -315,6 +317,8 @@ private:
PlaylistItemList m_randomList;
PlaylistSearch m_search;
bool m_polished;
};
QDataStream &operator<<(QDataStream &s, const Playlist &p);
......
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