mirror of
https://github.com/clementine-player/Clementine
synced 2024-12-17 20:09:50 +01:00
Avoid db commits during startup
When starting clementine, each playlist is loaded in turn. When loading a playlist, the new tab order is committed to the db, but we don't need to do that here because we know that once all the playlists are loaded the tab order will be the same as it was initially. This speeds startup substantially. kstartperf: Before: 3.5s After: 1.5s
This commit is contained in:
parent
09e839353e
commit
401f07c7cb
@ -44,6 +44,7 @@ PlaylistTabBar::PlaylistTabBar(QWidget* parent)
|
|||||||
menu_(new QMenu(this)),
|
menu_(new QMenu(this)),
|
||||||
menu_index_(-1),
|
menu_index_(-1),
|
||||||
suppress_current_changed_(false),
|
suppress_current_changed_(false),
|
||||||
|
initialized_(false),
|
||||||
rename_editor_(new RenameTabLineEdit(this)) {
|
rename_editor_(new RenameTabLineEdit(this)) {
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
setElideMode(Qt::ElideRight);
|
setElideMode(Qt::ElideRight);
|
||||||
@ -79,6 +80,16 @@ void PlaylistTabBar::SetManager(PlaylistManager* manager) {
|
|||||||
manager_ = manager;
|
manager_ = manager;
|
||||||
connect(manager_, SIGNAL(PlaylistFavorited(int, bool)),
|
connect(manager_, SIGNAL(PlaylistFavorited(int, bool)),
|
||||||
SLOT(PlaylistFavoritedSlot(int, bool)));
|
SLOT(PlaylistFavoritedSlot(int, bool)));
|
||||||
|
connect(manager_, SIGNAL(PlaylistManagerInitialized()), this,
|
||||||
|
SLOT(PlaylistManagerInitialized()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void PlaylistTabBar::PlaylistManagerInitialized() {
|
||||||
|
// Signal that we are done loading and thus further changes should be
|
||||||
|
// committed to the db.
|
||||||
|
initialized_ = true;
|
||||||
|
disconnect(manager_, SIGNAL(PlaylistManagerInitialized()), this,
|
||||||
|
SLOT(PlaylistManagerInitialized()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlaylistTabBar::contextMenuEvent(QContextMenuEvent* e) {
|
void PlaylistTabBar::contextMenuEvent(QContextMenuEvent* e) {
|
||||||
@ -281,6 +292,7 @@ void PlaylistTabBar::InsertTab(int id, int index, const QString& text,
|
|||||||
insertTab(index, text);
|
insertTab(index, text);
|
||||||
setTabData(index, id);
|
setTabData(index, id);
|
||||||
setTabToolTip(index, text);
|
setTabToolTip(index, text);
|
||||||
|
|
||||||
FavoriteWidget* widget = new FavoriteWidget(id, favorite);
|
FavoriteWidget* widget = new FavoriteWidget(id, favorite);
|
||||||
widget->setToolTip(
|
widget->setToolTip(
|
||||||
tr("Click here to favorite this playlist so it will be saved and remain "
|
tr("Click here to favorite this playlist so it will be saved and remain "
|
||||||
@ -291,14 +303,19 @@ void PlaylistTabBar::InsertTab(int id, int index, const QString& text,
|
|||||||
setTabButton(index, QTabBar::LeftSide, widget);
|
setTabButton(index, QTabBar::LeftSide, widget);
|
||||||
suppress_current_changed_ = false;
|
suppress_current_changed_ = false;
|
||||||
|
|
||||||
|
// If we are still starting up, we don't need to do this, as the
|
||||||
|
// tab ordering after startup will be the same as was already in the db.
|
||||||
|
if (initialized_) {
|
||||||
if (currentIndex() == index) emit CurrentIdChanged(id);
|
if (currentIndex() == index) emit CurrentIdChanged(id);
|
||||||
|
|
||||||
// Update playlist tab order/visibility
|
// Update playlist tab order/visibility
|
||||||
TabMoved();
|
TabMoved();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlaylistTabBar::TabMoved() {
|
void PlaylistTabBar::TabMoved() {
|
||||||
QList<int> ids;
|
QList<int> ids;
|
||||||
|
|
||||||
for (int i = 0; i < count(); ++i) {
|
for (int i = 0; i < count(); ++i) {
|
||||||
ids << tabData(i).toInt();
|
ids << tabData(i).toInt();
|
||||||
}
|
}
|
||||||
|
@ -82,6 +82,8 @@ signals:
|
|||||||
// Used when playlist's favorite flag isn't changed from the favorite widget
|
// Used when playlist's favorite flag isn't changed from the favorite widget
|
||||||
// (e.g. from the playlistlistcontainer): will update the favorite widget
|
// (e.g. from the playlistlistcontainer): will update the favorite widget
|
||||||
void PlaylistFavoritedSlot(int id, bool favorite);
|
void PlaylistFavoritedSlot(int id, bool favorite);
|
||||||
|
// Used to signal that the playlist manager is done starting up
|
||||||
|
void PlaylistManagerInitialized();
|
||||||
void TabMoved();
|
void TabMoved();
|
||||||
void Save();
|
void Save();
|
||||||
|
|
||||||
@ -99,6 +101,7 @@ signals:
|
|||||||
int drag_hover_tab_;
|
int drag_hover_tab_;
|
||||||
|
|
||||||
bool suppress_current_changed_;
|
bool suppress_current_changed_;
|
||||||
|
bool initialized_;
|
||||||
|
|
||||||
// Editor for inline renaming
|
// Editor for inline renaming
|
||||||
RenameTabLineEdit* rename_editor_;
|
RenameTabLineEdit* rename_editor_;
|
||||||
|
Loading…
Reference in New Issue
Block a user