From fad1767f6ccd8c99292382e08687ef85b949945c Mon Sep 17 00:00:00 2001 From: John Maguire Date: Tue, 20 Oct 2015 18:39:42 +0100 Subject: [PATCH] Revert "Lock/Unlock Ratings edit status" --- src/playlist/playlistheader.cpp | 15 ------- src/playlist/playlistheader.h | 3 -- src/playlist/playlistview.cpp | 72 +++++++++++---------------------- src/playlist/playlistview.h | 4 -- 4 files changed, 24 insertions(+), 70 deletions(-) diff --git a/src/playlist/playlistheader.cpp b/src/playlist/playlistheader.cpp index 90f256fed..51a79c2dc 100644 --- a/src/playlist/playlistheader.cpp +++ b/src/playlist/playlistheader.cpp @@ -21,7 +21,6 @@ #include #include #include -#include #include PlaylistHeader::PlaylistHeader(Qt::Orientation orientation, PlaylistView* view, @@ -33,13 +32,6 @@ PlaylistHeader::PlaylistHeader(Qt::Orientation orientation, PlaylistView* view, hide_action_ = menu_->addAction(tr("&Hide..."), this, SLOT(HideCurrent())); stretch_action_ = menu_->addAction(tr("&Stretch columns to fit window"), this, SLOT(ToggleStretchEnabled())); - rating_lock_ = menu_->addAction(tr("&Lock Rating"), this, - SLOT(ToggleRatingEditStatus())); - rating_lock_->setCheckable(true); - QSettings s; - s.beginGroup("Playlist"); - rating_lock_->setChecked(s.value("RatingLocked", false).toBool()); - s.endGroup(); menu_->addSeparator(); QMenu* align_menu = new QMenu(tr("&Align text"), this); @@ -79,9 +71,6 @@ void PlaylistHeader::contextMenuEvent(QContextMenuEvent* e) { QString title( model()->headerData(menu_section_, Qt::Horizontal).toString()); hide_action_->setText(tr("&Hide %1").arg(title)); - - // show rating_lock action only for ratings section - rating_lock_->setVisible(menu_section_ == Playlist::Column_Rating); Qt::Alignment alignment = view_->column_alignment(menu_section_); if (alignment & Qt::AlignLeft) @@ -140,7 +129,3 @@ void PlaylistHeader::ToggleVisible(int section) { } void PlaylistHeader::enterEvent(QEvent*) { emit MouseEntered(); } - -void PlaylistHeader::ToggleRatingEditStatus() { - emit SectionRatingLockStatusChanged(rating_lock_->isChecked()); -} diff --git a/src/playlist/playlistheader.h b/src/playlist/playlistheader.h index 613813bf9..a2e2e3d2f 100644 --- a/src/playlist/playlistheader.h +++ b/src/playlist/playlistheader.h @@ -38,13 +38,11 @@ class PlaylistHeader : public StretchHeaderView { signals: void SectionVisibilityChanged(int logical, bool visible); - void SectionRatingLockStatusChanged(bool state); void MouseEntered(); private slots: void HideCurrent(); void ToggleVisible(int section); - void ToggleRatingEditStatus(); void SetColumnAlignment(QAction* action); private: @@ -56,7 +54,6 @@ signals: int menu_section_; QMenu* menu_; QAction* hide_action_; - QAction* rating_lock_; QAction* stretch_action_; QAction* align_left_action_; QAction* align_center_action_; diff --git a/src/playlist/playlistview.cpp b/src/playlist/playlistview.cpp index f6b4203d8..1b0abfb62 100644 --- a/src/playlist/playlistview.cpp +++ b/src/playlist/playlistview.cpp @@ -144,8 +144,6 @@ PlaylistView::PlaylistView(QWidget* parent) SLOT(SaveGeometry())); connect(header_, SIGNAL(SectionVisibilityChanged(int, bool)), SLOT(SaveGeometry())); - connect(header_, SIGNAL(SectionRatingLockStatusChanged(bool)), - SLOT(SetRatingLockStatus(bool))); connect(header_, SIGNAL(sectionResized(int, int, int)), SLOT(InvalidateCachedCurrentPixmap())); connect(header_, SIGNAL(sectionMoved(int, int, int)), @@ -272,7 +270,6 @@ void PlaylistView::SetPlaylist(Playlist* playlist) { playlist_ = playlist; LoadGeometry(); - LoadRatingLockStatus(); ReloadSettings(); DynamicModeChanged(playlist->is_dynamic()); setFocus(); @@ -389,12 +386,6 @@ void PlaylistView::LoadGeometry() { } } -void PlaylistView::LoadRatingLockStatus() { - QSettings s; - s.beginGroup(Playlist::kSettingsGroup); - ratings_locked_ = s.value("RatingLocked", false).toBool(); -} - void PlaylistView::SaveGeometry() { if (read_only_settings_) return; @@ -404,15 +395,6 @@ void PlaylistView::SaveGeometry() { settings.setValue("state_version", kStateVersion); } -void PlaylistView::SetRatingLockStatus(bool state) { - if (read_only_settings_) return; - - ratings_locked_ = state; - QSettings s; - s.beginGroup(Playlist::kSettingsGroup); - s.setValue("RatingLocked", state); -} - void PlaylistView::ReloadBarPixmaps() { currenttrack_bar_left_ = LoadBarPixmap(":currenttrack_bar_left.png"); currenttrack_bar_mid_ = LoadBarPixmap(":currenttrack_bar_mid.png"); @@ -732,14 +714,11 @@ void PlaylistView::closeEditor(QWidget* editor, } void PlaylistView::mouseMoveEvent(QMouseEvent* event) { - // Check wheather rating section is locked by user or not - if (!ratings_locked_) { - QModelIndex index = indexAt(event->pos()); - if (index.isValid() && index.data(Playlist::Role_CanSetRating).toBool()) { - RatingHoverIn(index, event->pos()); - } else if (rating_delegate_->is_mouse_over()) { - RatingHoverOut(); - } + QModelIndex index = indexAt(event->pos()); + if (index.isValid() && index.data(Playlist::Role_CanSetRating).toBool()) { + RatingHoverIn(index, event->pos()); + } else if (rating_delegate_->is_mouse_over()) { + RatingHoverOut(); } if (!drag_over_) { QTreeView::mouseMoveEvent(event); @@ -747,7 +726,7 @@ void PlaylistView::mouseMoveEvent(QMouseEvent* event) { } void PlaylistView::leaveEvent(QEvent* e) { - if (rating_delegate_->is_mouse_over() && !ratings_locked_) { + if (rating_delegate_->is_mouse_over()) { RatingHoverOut(); } QTreeView::leaveEvent(e); @@ -803,30 +782,27 @@ void PlaylistView::mousePressEvent(QMouseEvent* event) { return; } - // Check wheather rating section is locked by user or not - if (!ratings_locked_) { - QModelIndex index = indexAt(event->pos()); - if (event->button() == Qt::LeftButton && index.isValid() && - index.data(Playlist::Role_CanSetRating).toBool()) { - // Calculate which star was clicked - double new_rating = - RatingPainter::RatingForPos(event->pos(), visualRect(index)); + QModelIndex index = indexAt(event->pos()); + if (event->button() == Qt::LeftButton && index.isValid() && + index.data(Playlist::Role_CanSetRating).toBool()) { + // Calculate which star was clicked + double new_rating = + RatingPainter::RatingForPos(event->pos(), visualRect(index)); - if (selectedIndexes().contains(index)) { - // Update all the selected items - QModelIndexList src_index_list; - for (const QModelIndex& index : selectedIndexes()) { - if (index.data(Playlist::Role_CanSetRating).toBool()) { - QModelIndex src_index = playlist_->proxy()->mapToSource(index); - src_index_list << src_index; - } + if (selectedIndexes().contains(index)) { + // Update all the selected items + QModelIndexList src_index_list; + for (const QModelIndex& index : selectedIndexes()) { + if (index.data(Playlist::Role_CanSetRating).toBool()) { + QModelIndex src_index = playlist_->proxy()->mapToSource(index); + src_index_list << src_index; } - playlist_->RateSongs(src_index_list, new_rating); - } else { - // Update only this item - playlist_->RateSong(playlist_->proxy()->mapToSource(index), new_rating); } - } + playlist_->RateSongs(src_index_list, new_rating); + } else { + // Update only this item + playlist_->RateSong(playlist_->proxy()->mapToSource(index), new_rating); + } } else { QTreeView::mousePressEvent(event); } diff --git a/src/playlist/playlistview.h b/src/playlist/playlistview.h index 656ab3523..184c8810d 100644 --- a/src/playlist/playlistview.h +++ b/src/playlist/playlistview.h @@ -142,9 +142,7 @@ signals: private slots: void LoadGeometry(); - void LoadRatingLockStatus(); void SaveGeometry(); - void SetRatingLockStatus(bool state); void GlowIntensityChanged(); void InhibitAutoscrollTimeout(); void MaybeAutoscroll(); @@ -246,8 +244,6 @@ signals: int drop_indicator_row_; bool drag_over_; - bool ratings_locked_; // To store Ratings section lock status - DynamicPlaylistControls* dynamic_controls_; ColumnAlignmentMap column_alignment_;