1
0
mirror of https://github.com/clementine-player/Clementine synced 2024-12-25 01:02:37 +01:00

Merge pull request #5083 from clementine-player/revert-5077-master

Revert "Lock/Unlock Ratings edit status"
This commit is contained in:
John Maguire 2015-10-20 18:39:47 +01:00
commit 888134cc48
4 changed files with 24 additions and 70 deletions

View File

@ -21,7 +21,6 @@
#include <QtDebug>
#include <QContextMenuEvent>
#include <QMenu>
#include <QSettings>
#include <QSignalMapper>
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());
}

View File

@ -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_;

View File

@ -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);
}

View File

@ -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_;