Save playlist' id instead of tab's id in favorite widget, so we don't have to update it when tab are moved

This commit is contained in:
Arnaud Bienner 2013-05-12 23:36:32 +02:00
parent e9f14d9f8a
commit 94a70d61b9
4 changed files with 6 additions and 8 deletions

View File

@ -78,7 +78,6 @@ PlaylistBackend::PlaylistList PlaylistBackend::GetPlaylists(GetPlaylistsFlags fl
condition = " WHERE " + condition_list.join(" OR ");
}
QSqlQuery q("SELECT ROWID, name, last_played, dynamic_playlist_type,"
" dynamic_playlist_data, dynamic_playlist_backend,"
" special_type, ui_path, is_favorite"

View File

@ -194,6 +194,8 @@ void PlaylistManager::Rename(int id, const QString& new_name) {
}
void PlaylistManager::Favorite(int id, bool favorite) {
Q_ASSERT(playlists_.contains(id));
playlist_backend_->FavoritePlaylist(id, favorite);
playlists_[id].p->set_favorite(favorite);
emit PlaylistFavorited(id, favorite);

View File

@ -232,8 +232,9 @@ void PlaylistTabBar::InsertTab(int id, int index, const QString& text, bool favo
insertTab(index, text);
setTabData(index, id);
setTabToolTip(index, text);
FavoriteWidget* widget = new FavoriteWidget(index, favorite);
connect(widget, SIGNAL(FavoriteStateChanged(int, bool)), SLOT(TabFavorited(int, bool)));
FavoriteWidget* widget = new FavoriteWidget(id, favorite);
connect(widget, SIGNAL(FavoriteStateChanged(int, bool)),
SIGNAL(PlaylistFavorited(int, bool)));
setTabButton(index, QTabBar::LeftSide, widget);
suppress_current_changed_ = false;
@ -252,10 +253,6 @@ void PlaylistTabBar::TabMoved() {
emit PlaylistOrderChanged(ids);
}
void PlaylistTabBar::TabFavorited(int index, bool favorite) {
emit PlaylistFavorited(tabData(index).toInt(), favorite);
}
void PlaylistTabBar::dragEnterEvent(QDragEnterEvent* e) {
if (e->mimeData()->hasUrls() ||
e->mimeData()->hasFormat(Playlist::kRowsMimetype) ||

View File

@ -42,7 +42,7 @@ class FavoriteWidget : public QWidget {
private:
static const int kStarSize;
// The tab's id this widget belongs to
// The playlist's id this widget belongs to
int tab_index_;
bool favorite_;
QPixmap on_;