Revert "Lock/Unlock Ratings edit status"
This commit is contained in:
parent
8208de9b53
commit
fad1767f6c
@ -21,7 +21,6 @@
|
|||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
#include <QContextMenuEvent>
|
#include <QContextMenuEvent>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QSettings>
|
|
||||||
#include <QSignalMapper>
|
#include <QSignalMapper>
|
||||||
|
|
||||||
PlaylistHeader::PlaylistHeader(Qt::Orientation orientation, PlaylistView* view,
|
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()));
|
hide_action_ = menu_->addAction(tr("&Hide..."), this, SLOT(HideCurrent()));
|
||||||
stretch_action_ = menu_->addAction(tr("&Stretch columns to fit window"), this,
|
stretch_action_ = menu_->addAction(tr("&Stretch columns to fit window"), this,
|
||||||
SLOT(ToggleStretchEnabled()));
|
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();
|
menu_->addSeparator();
|
||||||
|
|
||||||
QMenu* align_menu = new QMenu(tr("&Align text"), this);
|
QMenu* align_menu = new QMenu(tr("&Align text"), this);
|
||||||
@ -79,9 +71,6 @@ void PlaylistHeader::contextMenuEvent(QContextMenuEvent* e) {
|
|||||||
QString title(
|
QString title(
|
||||||
model()->headerData(menu_section_, Qt::Horizontal).toString());
|
model()->headerData(menu_section_, Qt::Horizontal).toString());
|
||||||
hide_action_->setText(tr("&Hide %1").arg(title));
|
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_);
|
Qt::Alignment alignment = view_->column_alignment(menu_section_);
|
||||||
if (alignment & Qt::AlignLeft)
|
if (alignment & Qt::AlignLeft)
|
||||||
@ -140,7 +129,3 @@ void PlaylistHeader::ToggleVisible(int section) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PlaylistHeader::enterEvent(QEvent*) { emit MouseEntered(); }
|
void PlaylistHeader::enterEvent(QEvent*) { emit MouseEntered(); }
|
||||||
|
|
||||||
void PlaylistHeader::ToggleRatingEditStatus() {
|
|
||||||
emit SectionRatingLockStatusChanged(rating_lock_->isChecked());
|
|
||||||
}
|
|
||||||
|
@ -38,13 +38,11 @@ class PlaylistHeader : public StretchHeaderView {
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void SectionVisibilityChanged(int logical, bool visible);
|
void SectionVisibilityChanged(int logical, bool visible);
|
||||||
void SectionRatingLockStatusChanged(bool state);
|
|
||||||
void MouseEntered();
|
void MouseEntered();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void HideCurrent();
|
void HideCurrent();
|
||||||
void ToggleVisible(int section);
|
void ToggleVisible(int section);
|
||||||
void ToggleRatingEditStatus();
|
|
||||||
void SetColumnAlignment(QAction* action);
|
void SetColumnAlignment(QAction* action);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -56,7 +54,6 @@ signals:
|
|||||||
int menu_section_;
|
int menu_section_;
|
||||||
QMenu* menu_;
|
QMenu* menu_;
|
||||||
QAction* hide_action_;
|
QAction* hide_action_;
|
||||||
QAction* rating_lock_;
|
|
||||||
QAction* stretch_action_;
|
QAction* stretch_action_;
|
||||||
QAction* align_left_action_;
|
QAction* align_left_action_;
|
||||||
QAction* align_center_action_;
|
QAction* align_center_action_;
|
||||||
|
@ -144,8 +144,6 @@ PlaylistView::PlaylistView(QWidget* parent)
|
|||||||
SLOT(SaveGeometry()));
|
SLOT(SaveGeometry()));
|
||||||
connect(header_, SIGNAL(SectionVisibilityChanged(int, bool)),
|
connect(header_, SIGNAL(SectionVisibilityChanged(int, bool)),
|
||||||
SLOT(SaveGeometry()));
|
SLOT(SaveGeometry()));
|
||||||
connect(header_, SIGNAL(SectionRatingLockStatusChanged(bool)),
|
|
||||||
SLOT(SetRatingLockStatus(bool)));
|
|
||||||
connect(header_, SIGNAL(sectionResized(int, int, int)),
|
connect(header_, SIGNAL(sectionResized(int, int, int)),
|
||||||
SLOT(InvalidateCachedCurrentPixmap()));
|
SLOT(InvalidateCachedCurrentPixmap()));
|
||||||
connect(header_, SIGNAL(sectionMoved(int, int, int)),
|
connect(header_, SIGNAL(sectionMoved(int, int, int)),
|
||||||
@ -272,7 +270,6 @@ void PlaylistView::SetPlaylist(Playlist* playlist) {
|
|||||||
|
|
||||||
playlist_ = playlist;
|
playlist_ = playlist;
|
||||||
LoadGeometry();
|
LoadGeometry();
|
||||||
LoadRatingLockStatus();
|
|
||||||
ReloadSettings();
|
ReloadSettings();
|
||||||
DynamicModeChanged(playlist->is_dynamic());
|
DynamicModeChanged(playlist->is_dynamic());
|
||||||
setFocus();
|
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() {
|
void PlaylistView::SaveGeometry() {
|
||||||
if (read_only_settings_) return;
|
if (read_only_settings_) return;
|
||||||
|
|
||||||
@ -404,15 +395,6 @@ void PlaylistView::SaveGeometry() {
|
|||||||
settings.setValue("state_version", kStateVersion);
|
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() {
|
void PlaylistView::ReloadBarPixmaps() {
|
||||||
currenttrack_bar_left_ = LoadBarPixmap(":currenttrack_bar_left.png");
|
currenttrack_bar_left_ = LoadBarPixmap(":currenttrack_bar_left.png");
|
||||||
currenttrack_bar_mid_ = LoadBarPixmap(":currenttrack_bar_mid.png");
|
currenttrack_bar_mid_ = LoadBarPixmap(":currenttrack_bar_mid.png");
|
||||||
@ -732,14 +714,11 @@ void PlaylistView::closeEditor(QWidget* editor,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PlaylistView::mouseMoveEvent(QMouseEvent* event) {
|
void PlaylistView::mouseMoveEvent(QMouseEvent* event) {
|
||||||
// Check wheather rating section is locked by user or not
|
QModelIndex index = indexAt(event->pos());
|
||||||
if (!ratings_locked_) {
|
if (index.isValid() && index.data(Playlist::Role_CanSetRating).toBool()) {
|
||||||
QModelIndex index = indexAt(event->pos());
|
RatingHoverIn(index, event->pos());
|
||||||
if (index.isValid() && index.data(Playlist::Role_CanSetRating).toBool()) {
|
} else if (rating_delegate_->is_mouse_over()) {
|
||||||
RatingHoverIn(index, event->pos());
|
RatingHoverOut();
|
||||||
} else if (rating_delegate_->is_mouse_over()) {
|
|
||||||
RatingHoverOut();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!drag_over_) {
|
if (!drag_over_) {
|
||||||
QTreeView::mouseMoveEvent(event);
|
QTreeView::mouseMoveEvent(event);
|
||||||
@ -747,7 +726,7 @@ void PlaylistView::mouseMoveEvent(QMouseEvent* event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PlaylistView::leaveEvent(QEvent* e) {
|
void PlaylistView::leaveEvent(QEvent* e) {
|
||||||
if (rating_delegate_->is_mouse_over() && !ratings_locked_) {
|
if (rating_delegate_->is_mouse_over()) {
|
||||||
RatingHoverOut();
|
RatingHoverOut();
|
||||||
}
|
}
|
||||||
QTreeView::leaveEvent(e);
|
QTreeView::leaveEvent(e);
|
||||||
@ -803,30 +782,27 @@ void PlaylistView::mousePressEvent(QMouseEvent* event) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check wheather rating section is locked by user or not
|
QModelIndex index = indexAt(event->pos());
|
||||||
if (!ratings_locked_) {
|
if (event->button() == Qt::LeftButton && index.isValid() &&
|
||||||
QModelIndex index = indexAt(event->pos());
|
index.data(Playlist::Role_CanSetRating).toBool()) {
|
||||||
if (event->button() == Qt::LeftButton && index.isValid() &&
|
// Calculate which star was clicked
|
||||||
index.data(Playlist::Role_CanSetRating).toBool()) {
|
double new_rating =
|
||||||
// Calculate which star was clicked
|
RatingPainter::RatingForPos(event->pos(), visualRect(index));
|
||||||
double new_rating =
|
|
||||||
RatingPainter::RatingForPos(event->pos(), visualRect(index));
|
|
||||||
|
|
||||||
if (selectedIndexes().contains(index)) {
|
if (selectedIndexes().contains(index)) {
|
||||||
// Update all the selected items
|
// Update all the selected items
|
||||||
QModelIndexList src_index_list;
|
QModelIndexList src_index_list;
|
||||||
for (const QModelIndex& index : selectedIndexes()) {
|
for (const QModelIndex& index : selectedIndexes()) {
|
||||||
if (index.data(Playlist::Role_CanSetRating).toBool()) {
|
if (index.data(Playlist::Role_CanSetRating).toBool()) {
|
||||||
QModelIndex src_index = playlist_->proxy()->mapToSource(index);
|
QModelIndex src_index = playlist_->proxy()->mapToSource(index);
|
||||||
src_index_list << src_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 {
|
} else {
|
||||||
QTreeView::mousePressEvent(event);
|
QTreeView::mousePressEvent(event);
|
||||||
}
|
}
|
||||||
|
@ -142,9 +142,7 @@ signals:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void LoadGeometry();
|
void LoadGeometry();
|
||||||
void LoadRatingLockStatus();
|
|
||||||
void SaveGeometry();
|
void SaveGeometry();
|
||||||
void SetRatingLockStatus(bool state);
|
|
||||||
void GlowIntensityChanged();
|
void GlowIntensityChanged();
|
||||||
void InhibitAutoscrollTimeout();
|
void InhibitAutoscrollTimeout();
|
||||||
void MaybeAutoscroll();
|
void MaybeAutoscroll();
|
||||||
@ -246,8 +244,6 @@ signals:
|
|||||||
int drop_indicator_row_;
|
int drop_indicator_row_;
|
||||||
bool drag_over_;
|
bool drag_over_;
|
||||||
|
|
||||||
bool ratings_locked_; // To store Ratings section lock status
|
|
||||||
|
|
||||||
DynamicPlaylistControls* dynamic_controls_;
|
DynamicPlaylistControls* dynamic_controls_;
|
||||||
|
|
||||||
ColumnAlignmentMap column_alignment_;
|
ColumnAlignmentMap column_alignment_;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user