mirror of
https://github.com/dguglielmi/sunny-overlay.git
synced 2025-12-06 09:32:37 +01:00
1060 lines
39 KiB
Diff
1060 lines
39 KiB
Diff
From 1a3ea722783f0cf55bbf090a831993ff0d8950b6 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= <daschuer@mixxx.org>
|
|
Date: Mon, 28 May 2018 00:17:16 +0200
|
|
Subject: [PATCH 1/4] Draw background for library cover art and peview coloumn,
|
|
fixing LP1773709
|
|
|
|
---
|
|
src/library/coverartdelegate.cpp | 28 +++++++++++++++++++++++++++-
|
|
src/library/coverartdelegate.h | 2 ++
|
|
src/library/previewbuttondelegate.cpp | 27 ++++++++++++++++++++++++---
|
|
3 files changed, 53 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/src/library/coverartdelegate.cpp b/src/library/coverartdelegate.cpp
|
|
index 548e9d5a8f..c500217421 100644
|
|
--- a/src/library/coverartdelegate.cpp
|
|
+++ b/src/library/coverartdelegate.cpp
|
|
@@ -7,6 +7,7 @@
|
|
|
|
CoverArtDelegate::CoverArtDelegate(QObject *parent)
|
|
: QStyledItemDelegate(parent),
|
|
+ m_pTableView(qobject_cast<QTableView*>(parent)),
|
|
m_bOnlyCachedCover(false),
|
|
m_iCoverColumn(-1),
|
|
m_iCoverSourceColumn(-1),
|
|
@@ -84,14 +85,37 @@ void CoverArtDelegate::slotCoverFound(const QObject* pRequestor,
|
|
void CoverArtDelegate::paint(QPainter *painter,
|
|
const QStyleOptionViewItem &option,
|
|
const QModelIndex &index) const {
|
|
+
|
|
+ painter->save();
|
|
+ painter->setClipRect(option.rect);
|
|
+
|
|
+ if (m_pTableView != NULL) {
|
|
+ QStyle* style = m_pTableView->style();
|
|
+ if (style != NULL) {
|
|
+ style->drawControl(QStyle::CE_ItemViewItem, &option, painter,
|
|
+ m_pTableView);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ // Set the palette appropriately based on whether the row is selected or
|
|
+ // not. We also have to check if it is inactive or not and use the
|
|
+ // appropriate ColorGroup.
|
|
+ QPalette::ColorGroup cg = option.state & QStyle::State_Enabled
|
|
+ ? QPalette::Normal : QPalette::Disabled;
|
|
+ if (cg == QPalette::Normal && !(option.state & QStyle::State_Active))
|
|
+ cg = QPalette::Inactive;
|
|
+
|
|
if (option.state & QStyle::State_Selected) {
|
|
- painter->fillRect(option.rect, option.palette.highlight());
|
|
+ painter->setBrush(option.palette.color(cg, QPalette::HighlightedText));
|
|
+ } else {
|
|
+ painter->setBrush(option.palette.color(cg, QPalette::Text));
|
|
}
|
|
|
|
CoverArtCache* pCache = CoverArtCache::instance();
|
|
if (pCache == NULL || m_iIdColumn == -1 || m_iCoverSourceColumn == -1 ||
|
|
m_iCoverTypeColumn == -1 || m_iCoverLocationColumn == -1 ||
|
|
m_iCoverHashColumn == -1) {
|
|
+ painter->restore();
|
|
return;
|
|
}
|
|
|
|
@@ -101,6 +125,7 @@ void CoverArtDelegate::paint(QPainter *painter,
|
|
|
|
// We don't support types other than METADATA or FILE currently.
|
|
if (info.type != CoverInfo::METADATA && info.type != CoverInfo::FILE) {
|
|
+ painter->restore();
|
|
return;
|
|
}
|
|
|
|
@@ -131,4 +156,5 @@ void CoverArtDelegate::paint(QPainter *painter,
|
|
// we can request an update.
|
|
m_cacheMissRows.append(index.row());
|
|
}
|
|
+ painter->restore();
|
|
}
|
|
diff --git a/src/library/coverartdelegate.h b/src/library/coverartdelegate.h
|
|
index d510c1d006..7908121b84 100644
|
|
--- a/src/library/coverartdelegate.h
|
|
+++ b/src/library/coverartdelegate.h
|
|
@@ -6,6 +6,7 @@
|
|
#include <QStyledItemDelegate>
|
|
#include <QHash>
|
|
#include <QLinkedList>
|
|
+#include <QTableView>
|
|
|
|
#include "library/trackmodel.h"
|
|
|
|
@@ -40,6 +41,7 @@ class CoverArtDelegate : public QStyledItemDelegate {
|
|
QPixmap pixmap, bool fromCache);
|
|
|
|
private:
|
|
+ QTableView* m_pTableView;
|
|
bool m_bOnlyCachedCover;
|
|
int m_iCoverColumn;
|
|
int m_iCoverSourceColumn;
|
|
diff --git a/src/library/previewbuttondelegate.cpp b/src/library/previewbuttondelegate.cpp
|
|
index 6c09f59429..77d9068872 100644
|
|
--- a/src/library/previewbuttondelegate.cpp
|
|
+++ b/src/library/previewbuttondelegate.cpp
|
|
@@ -90,11 +90,32 @@ void PreviewButtonDelegate::paint(QPainter *painter,
|
|
// it's playing.
|
|
m_pButton->setChecked(index.data().toBool() && playing);
|
|
|
|
- if (option.state == QStyle::State_Selected) {
|
|
- painter->fillRect(option.rect, option.palette.base());
|
|
+ painter->save();
|
|
+
|
|
+ painter->setClipRect(option.rect);
|
|
+
|
|
+ if (m_pTableView != NULL) {
|
|
+ QStyle* style = m_pTableView->style();
|
|
+ if (style != NULL) {
|
|
+ style->drawControl(QStyle::CE_ItemViewItem, &option, painter,
|
|
+ m_pTableView);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ // Set the palette appropriately based on whether the row is selected or
|
|
+ // not. We also have to check if it is inactive or not and use the
|
|
+ // appropriate ColorGroup.
|
|
+ QPalette::ColorGroup cg = option.state & QStyle::State_Enabled
|
|
+ ? QPalette::Normal : QPalette::Disabled;
|
|
+ if (cg == QPalette::Normal && !(option.state & QStyle::State_Active))
|
|
+ cg = QPalette::Inactive;
|
|
+
|
|
+ if (option.state & QStyle::State_Selected) {
|
|
+ painter->setBrush(option.palette.color(cg, QPalette::HighlightedText));
|
|
+ } else {
|
|
+ painter->setBrush(option.palette.color(cg, QPalette::Text));
|
|
}
|
|
|
|
- painter->save();
|
|
// Render button at the desired position
|
|
painter->translate(option.rect.topLeft());
|
|
m_pButton->render(painter);
|
|
|
|
From 67353bf2b195b38cb8ca083f08970003e5b6dfac Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= <daschuer@mixxx.org>
|
|
Date: Tue, 29 May 2018 22:34:41 +0200
|
|
Subject: [PATCH 2/4] Added a TableItemDelegate base class to hold the
|
|
background painting
|
|
|
|
---
|
|
build/depends.py | 1 +
|
|
src/library/basesqltablemodel.cpp | 12 ++++---
|
|
src/library/bpmdelegate.cpp | 57 +++++++++++++++++++++++++++++---
|
|
src/library/bpmdelegate.h | 15 ++++-----
|
|
src/library/browse/browsetablemodel.cpp | 5 ++-
|
|
src/library/coverartdelegate.cpp | 9 ++---
|
|
src/library/coverartdelegate.h | 15 ++++-----
|
|
src/library/previewbuttondelegate.cpp | 58 ++++++++++++++++-----------------
|
|
src/library/previewbuttondelegate.h | 29 ++++++++---------
|
|
src/library/stardelegate.cpp | 11 ++++---
|
|
src/library/stardelegate.h | 9 +++--
|
|
src/library/starrating.cpp | 2 ++
|
|
src/library/starrating.h | 6 ++--
|
|
src/library/tableitemdelegate.cpp | 18 ++++++++++
|
|
src/library/tableitemdelegate.h | 25 ++++++++++++++
|
|
15 files changed, 184 insertions(+), 88 deletions(-)
|
|
create mode 100644 src/library/tableitemdelegate.cpp
|
|
create mode 100644 src/library/tableitemdelegate.h
|
|
|
|
diff --git a/build/depends.py b/build/depends.py
|
|
index fc4196099f..f548b89062 100644
|
|
--- a/build/depends.py
|
|
+++ b/build/depends.py
|
|
@@ -1059,6 +1059,7 @@ def sources(self, build):
|
|
"library/bpmdelegate.cpp",
|
|
"library/previewbuttondelegate.cpp",
|
|
"library/coverartdelegate.cpp",
|
|
+ "library/tableitemdelegate.cpp",
|
|
|
|
"library/treeitemmodel.cpp",
|
|
"library/treeitem.cpp",
|
|
diff --git a/src/library/basesqltablemodel.cpp b/src/library/basesqltablemodel.cpp
|
|
index 3b79392348..6502d82180 100644
|
|
--- a/src/library/basesqltablemodel.cpp
|
|
+++ b/src/library/basesqltablemodel.cpp
|
|
@@ -3,6 +3,7 @@
|
|
#include <QtAlgorithms>
|
|
#include <QtDebug>
|
|
#include <QUrl>
|
|
+#include <QTableView>
|
|
|
|
#include "library/basesqltablemodel.h"
|
|
|
|
@@ -1049,14 +1050,17 @@ QMimeData* BaseSqlTableModel::mimeData(const QModelIndexList &indexes) const {
|
|
}
|
|
|
|
QAbstractItemDelegate* BaseSqlTableModel::delegateForColumn(const int i, QObject* pParent) {
|
|
+ QTableView* pTableView = qobject_cast<QTableView*>(pParent);
|
|
+ DEBUG_ASSERT(pTableView);
|
|
+
|
|
if (i == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_RATING)) {
|
|
- return new StarDelegate(pParent);
|
|
+ return new StarDelegate(pTableView);
|
|
} else if (i == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_BPM)) {
|
|
- return new BPMDelegate(pParent);
|
|
+ return new BPMDelegate(pTableView);
|
|
} else if (PlayerManager::numPreviewDecks() > 0 && i == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_PREVIEW)) {
|
|
- return new PreviewButtonDelegate(pParent, i);
|
|
+ return new PreviewButtonDelegate(pTableView, i);
|
|
} else if (i == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_COVERART)) {
|
|
- CoverArtDelegate* pCoverDelegate = new CoverArtDelegate(pParent);
|
|
+ CoverArtDelegate* pCoverDelegate = new CoverArtDelegate(pTableView);
|
|
connect(pCoverDelegate, SIGNAL(coverReadyForCell(int, int)),
|
|
this, SLOT(refreshCell(int, int)));
|
|
return pCoverDelegate;
|
|
diff --git a/src/library/bpmdelegate.cpp b/src/library/bpmdelegate.cpp
|
|
index 53dd545da8..793c0f9c2f 100644
|
|
--- a/src/library/bpmdelegate.cpp
|
|
+++ b/src/library/bpmdelegate.cpp
|
|
@@ -3,6 +3,8 @@
|
|
#include <QDoubleSpinBox>
|
|
#include <QRect>
|
|
#include <QPalette>
|
|
+#include <QTableView>
|
|
+#include <QPainter>
|
|
|
|
#include "library/bpmdelegate.h"
|
|
#include "library/trackmodel.h"
|
|
@@ -30,9 +32,9 @@ class BpmEditorCreator : public QItemEditorCreatorBase {
|
|
}
|
|
};
|
|
|
|
-BPMDelegate::BPMDelegate(QObject* parent)
|
|
- : QStyledItemDelegate(parent),
|
|
- m_pTableView(qobject_cast<QTableView*>(parent)),
|
|
+BPMDelegate::BPMDelegate(QTableView* pTableView)
|
|
+ : TableItemDelegate(pTableView),
|
|
+ m_pTableView(pTableView),
|
|
m_pCheckBox(new QCheckBox(m_pTableView)) {
|
|
m_pCheckBox->setObjectName("LibraryBPMButton");
|
|
// NOTE(rryan): Without ensurePolished the first render of the QTableView
|
|
@@ -51,8 +53,8 @@ BPMDelegate::~BPMDelegate() {
|
|
delete m_pFactory;
|
|
}
|
|
|
|
-void BPMDelegate::paint(QPainter* painter,const QStyleOptionViewItem &option,
|
|
- const QModelIndex &index) const {
|
|
+void BPMDelegate::paintItem(QPainter* painter,const QStyleOptionViewItem &option,
|
|
+ const QModelIndex& index) const {
|
|
// NOTE(rryan): Qt has a built-in limitation that we cannot style multiple
|
|
// CheckState indicators in the same QAbstractItemView. The CSS rule
|
|
// QTableView::indicator:checked applies to all columns with a
|
|
@@ -75,6 +77,21 @@ void BPMDelegate::paint(QPainter* painter,const QStyleOptionViewItem &option,
|
|
QStyleOptionViewItemV4 opt = option;
|
|
initStyleOption(&opt, index);
|
|
|
|
+ // Set the palette appropriately based on whether the row is selected or
|
|
+ // not. We also have to check if it is inactive or not and use the
|
|
+ // appropriate ColorGroup.
|
|
+ QPalette::ColorGroup cg = option.state & QStyle::State_Enabled
|
|
+ ? QPalette::Normal : QPalette::Disabled;
|
|
+ if (cg == QPalette::Normal && !(option.state & QStyle::State_Active))
|
|
+ cg = QPalette::Inactive;
|
|
+
|
|
+ if (option.state & QStyle::State_Selected) {
|
|
+ painter->setBrush(option.palette.color(cg, QPalette::HighlightedText));
|
|
+ } else {
|
|
+ painter->setBrush(option.palette.color(cg, QPalette::Text));
|
|
+ }
|
|
+
|
|
+
|
|
if (m_pTableView != NULL) {
|
|
QStyle* style = m_pTableView->style();
|
|
if (style != NULL) {
|
|
@@ -82,4 +99,34 @@ void BPMDelegate::paint(QPainter* painter,const QStyleOptionViewItem &option,
|
|
m_pCheckBox);
|
|
}
|
|
}
|
|
+
|
|
+
|
|
+ /*
|
|
+
|
|
+ painter->save();
|
|
+ painter->setClipRect(option.rect);
|
|
+
|
|
+ if (m_pTableView != NULL) {
|
|
+ QStyle* style = m_pTableView->style();
|
|
+ if (style != NULL) {
|
|
+ style->drawControl(QStyle::CE_ItemViewItem, &option, painter,
|
|
+ m_pTableView);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ // Set the palette appropriately based on whether the row is selected or
|
|
+ // not. We also have to check if it is inactive or not and use the
|
|
+ // appropriate ColorGroup.
|
|
+ QPalette::ColorGroup cg = option.state & QStyle::State_Enabled
|
|
+ ? QPalette::Normal : QPalette::Disabled;
|
|
+ if (cg == QPalette::Normal && !(option.state & QStyle::State_Active))
|
|
+ cg = QPalette::Inactive;
|
|
+
|
|
+ if (option.state & QStyle::State_Selected) {
|
|
+ painter->setBrush(option.palette.color(cg, QPalette::HighlightedText));
|
|
+ } else {
|
|
+ painter->setBrush(option.palette.color(cg, QPalette::Text));
|
|
+ }
|
|
+ */
|
|
+
|
|
}
|
|
diff --git a/src/library/bpmdelegate.h b/src/library/bpmdelegate.h
|
|
index a2fc678bd6..58f8adef27 100644
|
|
--- a/src/library/bpmdelegate.h
|
|
+++ b/src/library/bpmdelegate.h
|
|
@@ -3,20 +3,19 @@
|
|
|
|
#include <QCheckBox>
|
|
#include <QModelIndex>
|
|
-#include <QObject>
|
|
-#include <QPainter>
|
|
#include <QStyleOptionViewItem>
|
|
-#include <QStyledItemDelegate>
|
|
-#include <QTableView>
|
|
|
|
-class BPMDelegate : public QStyledItemDelegate {
|
|
+#include "library/tableitemdelegate.h"
|
|
+
|
|
+
|
|
+class BPMDelegate : public TableItemDelegate {
|
|
Q_OBJECT
|
|
public:
|
|
- explicit BPMDelegate(QObject* parent);
|
|
+ explicit BPMDelegate(QTableView* pTableView);
|
|
virtual ~BPMDelegate();
|
|
|
|
- void paint(QPainter *painter, const QStyleOptionViewItem &option,
|
|
- const QModelIndex &index) const;
|
|
+ void paintItem(QPainter* painter, const QStyleOptionViewItem& option,
|
|
+ const QModelIndex& index) const;
|
|
|
|
private:
|
|
QTableView* m_pTableView;
|
|
diff --git a/src/library/browse/browsetablemodel.cpp b/src/library/browse/browsetablemodel.cpp
|
|
index e1a590edc5..5279a3fcb9 100644
|
|
--- a/src/library/browse/browsetablemodel.cpp
|
|
+++ b/src/library/browse/browsetablemodel.cpp
|
|
@@ -4,6 +4,7 @@
|
|
#include <QMetaType>
|
|
#include <QMessageBox>
|
|
#include <QUrl>
|
|
+#include <QTableView>
|
|
|
|
#include "library/browse/browsetablemodel.h"
|
|
#include "library/browse/browsethread.h"
|
|
@@ -364,8 +365,10 @@ bool BrowseTableModel::isColumnSortable(int column) {
|
|
}
|
|
|
|
QAbstractItemDelegate* BrowseTableModel::delegateForColumn(const int i, QObject* pParent) {
|
|
+ QTableView* pTableView = qobject_cast<QTableView*>(pParent);
|
|
+ DEBUG_ASSERT(pTableView);
|
|
if (PlayerManager::numPreviewDecks() > 0 && i == COLUMN_PREVIEW) {
|
|
- return new PreviewButtonDelegate(pParent, i);
|
|
+ return new PreviewButtonDelegate(pTableView, i);
|
|
}
|
|
return NULL;
|
|
}
|
|
diff --git a/src/library/coverartdelegate.cpp b/src/library/coverartdelegate.cpp
|
|
index c500217421..fea6276eb1 100644
|
|
--- a/src/library/coverartdelegate.cpp
|
|
+++ b/src/library/coverartdelegate.cpp
|
|
@@ -1,13 +1,14 @@
|
|
#include <QTableView>
|
|
+#include <QPainter>
|
|
|
|
#include "library/coverartdelegate.h"
|
|
#include "library/coverartcache.h"
|
|
#include "library/dao/trackschema.h"
|
|
#include "util/math.h"
|
|
|
|
-CoverArtDelegate::CoverArtDelegate(QObject *parent)
|
|
- : QStyledItemDelegate(parent),
|
|
- m_pTableView(qobject_cast<QTableView*>(parent)),
|
|
+CoverArtDelegate::CoverArtDelegate(QTableView* parent)
|
|
+ : TableItemDelegate(parent),
|
|
+ m_pTableView(parent),
|
|
m_bOnlyCachedCover(false),
|
|
m_iCoverColumn(-1),
|
|
m_iCoverSourceColumn(-1),
|
|
@@ -82,7 +83,7 @@ void CoverArtDelegate::slotCoverFound(const QObject* pRequestor,
|
|
}
|
|
}
|
|
|
|
-void CoverArtDelegate::paint(QPainter *painter,
|
|
+void CoverArtDelegate::paintItem(QPainter *painter,
|
|
const QStyleOptionViewItem &option,
|
|
const QModelIndex &index) const {
|
|
|
|
diff --git a/src/library/coverartdelegate.h b/src/library/coverartdelegate.h
|
|
index 7908121b84..ff8fef5412 100644
|
|
--- a/src/library/coverartdelegate.h
|
|
+++ b/src/library/coverartdelegate.h
|
|
@@ -1,24 +1,21 @@
|
|
#ifndef COVERARTDELEGATE_H
|
|
#define COVERARTDELEGATE_H
|
|
|
|
-#include <QObject>
|
|
-#include <QPainter>
|
|
-#include <QStyledItemDelegate>
|
|
#include <QHash>
|
|
#include <QLinkedList>
|
|
-#include <QTableView>
|
|
|
|
+#include "library/tableitemdelegate.h"
|
|
#include "library/trackmodel.h"
|
|
|
|
-class CoverArtDelegate : public QStyledItemDelegate {
|
|
+class CoverArtDelegate : public TableItemDelegate {
|
|
Q_OBJECT
|
|
public:
|
|
- explicit CoverArtDelegate(QObject* parent = NULL);
|
|
+ explicit CoverArtDelegate(QTableView* pTableView);
|
|
virtual ~CoverArtDelegate();
|
|
|
|
- void paint(QPainter *painter,
|
|
- const QStyleOptionViewItem &option,
|
|
- const QModelIndex &index) const;
|
|
+ void paintItem(QPainter* painter,
|
|
+ const QStyleOptionViewItem& option,
|
|
+ const QModelIndex& index) const;
|
|
|
|
signals:
|
|
void coverReadyForCell(int row, int column);
|
|
diff --git a/src/library/previewbuttondelegate.cpp b/src/library/previewbuttondelegate.cpp
|
|
index 77d9068872..be63482b71 100644
|
|
--- a/src/library/previewbuttondelegate.cpp
|
|
+++ b/src/library/previewbuttondelegate.cpp
|
|
@@ -1,5 +1,6 @@
|
|
#include <QPainter>
|
|
#include <QPushButton>
|
|
+#include <QTableView>
|
|
|
|
#include "library/previewbuttondelegate.h"
|
|
#include "library/trackmodel.h"
|
|
@@ -8,9 +9,9 @@
|
|
#include "track/track.h"
|
|
#include "control/controlproxy.h"
|
|
|
|
-PreviewButtonDelegate::PreviewButtonDelegate(QObject *parent, int column)
|
|
- : QStyledItemDelegate(parent),
|
|
- m_pTableView(NULL),
|
|
+PreviewButtonDelegate::PreviewButtonDelegate(QTableView* parent, int column)
|
|
+ : TableItemDelegate(parent),
|
|
+ m_pTableView(parent),
|
|
m_pButton(NULL),
|
|
m_isOneCellInEditMode(false),
|
|
m_column(column) {
|
|
@@ -25,24 +26,21 @@ PreviewButtonDelegate::PreviewButtonDelegate(QObject *parent, int column)
|
|
connect(this, SIGNAL(loadTrackToPlayer(TrackPointer, QString, bool)),
|
|
parent, SIGNAL(loadTrackToPlayer(TrackPointer, QString, bool)));
|
|
|
|
- if (QTableView *tableView = qobject_cast<QTableView*>(parent)) {
|
|
- m_pTableView = tableView;
|
|
- m_pButton = new QPushButton("", m_pTableView);
|
|
- m_pButton->setObjectName("LibraryPreviewButton");
|
|
- m_pButton->setCheckable(true);
|
|
- m_pButton->setChecked(false);
|
|
- m_pButton->hide();
|
|
- connect(m_pTableView, SIGNAL(entered(QModelIndex)),
|
|
- this, SLOT(cellEntered(QModelIndex)));
|
|
- }
|
|
+ m_pButton = new QPushButton("", m_pTableView);
|
|
+ m_pButton->setObjectName("LibraryPreviewButton");
|
|
+ m_pButton->setCheckable(true);
|
|
+ m_pButton->setChecked(false);
|
|
+ m_pButton->hide();
|
|
+ connect(m_pTableView, SIGNAL(entered(QModelIndex)),
|
|
+ this, SLOT(cellEntered(QModelIndex)));
|
|
}
|
|
|
|
PreviewButtonDelegate::~PreviewButtonDelegate() {
|
|
}
|
|
|
|
-QWidget* PreviewButtonDelegate::createEditor(QWidget *parent,
|
|
- const QStyleOptionViewItem &option,
|
|
- const QModelIndex &index) const {
|
|
+QWidget* PreviewButtonDelegate::createEditor(QWidget* parent,
|
|
+ const QStyleOptionViewItem& option,
|
|
+ const QModelIndex& index) const {
|
|
Q_UNUSED(option);
|
|
QPushButton* btn = new QPushButton(parent);
|
|
btn->setObjectName("LibraryPreviewButton");
|
|
@@ -58,23 +56,23 @@ QWidget* PreviewButtonDelegate::createEditor(QWidget *parent,
|
|
return btn;
|
|
}
|
|
|
|
-void PreviewButtonDelegate::setEditorData(QWidget *editor,
|
|
- const QModelIndex &index) const {
|
|
+void PreviewButtonDelegate::setEditorData(QWidget* editor,
|
|
+ const QModelIndex& index) const {
|
|
Q_UNUSED(editor);
|
|
Q_UNUSED(index);
|
|
}
|
|
|
|
-void PreviewButtonDelegate::setModelData(QWidget *editor,
|
|
- QAbstractItemModel *model,
|
|
- const QModelIndex &index) const {
|
|
+void PreviewButtonDelegate::setModelData(QWidget* editor,
|
|
+ QAbstractItemModel* model,
|
|
+ const QModelIndex& index) const {
|
|
Q_UNUSED(editor);
|
|
Q_UNUSED(model);
|
|
Q_UNUSED(index);
|
|
}
|
|
|
|
-void PreviewButtonDelegate::paint(QPainter *painter,
|
|
- const QStyleOptionViewItem &option,
|
|
- const QModelIndex &index) const {
|
|
+void PreviewButtonDelegate::paintItem(QPainter* painter,
|
|
+ const QStyleOptionViewItem& option,
|
|
+ const QModelIndex& index) const {
|
|
// Let the editor paint in this case
|
|
if (index == m_currentEditedCellIndex) {
|
|
return;
|
|
@@ -122,15 +120,15 @@ void PreviewButtonDelegate::paint(QPainter *painter,
|
|
painter->restore();
|
|
}
|
|
|
|
-void PreviewButtonDelegate::updateEditorGeometry(QWidget *editor,
|
|
- const QStyleOptionViewItem &option,
|
|
- const QModelIndex &index) const {
|
|
+void PreviewButtonDelegate::updateEditorGeometry(QWidget* editor,
|
|
+ const QStyleOptionViewItem& option,
|
|
+ const QModelIndex& index) const {
|
|
Q_UNUSED(index);
|
|
editor->setGeometry(option.rect);
|
|
}
|
|
|
|
-QSize PreviewButtonDelegate::sizeHint(const QStyleOptionViewItem &option,
|
|
- const QModelIndex &index) const {
|
|
+QSize PreviewButtonDelegate::sizeHint(const QStyleOptionViewItem& option,
|
|
+ const QModelIndex& index) const {
|
|
Q_UNUSED(option);
|
|
Q_UNUSED(index);
|
|
if (!m_pButton) {
|
|
@@ -139,7 +137,7 @@ QSize PreviewButtonDelegate::sizeHint(const QStyleOptionViewItem &option,
|
|
return m_pButton->sizeHint();
|
|
}
|
|
|
|
-void PreviewButtonDelegate::cellEntered(const QModelIndex &index) {
|
|
+void PreviewButtonDelegate::cellEntered(const QModelIndex& index) {
|
|
if (!m_pTableView) {
|
|
return;
|
|
}
|
|
diff --git a/src/library/previewbuttondelegate.h b/src/library/previewbuttondelegate.h
|
|
index d9d5f8bfa1..27bcaf87eb 100644
|
|
--- a/src/library/previewbuttondelegate.h
|
|
+++ b/src/library/previewbuttondelegate.h
|
|
@@ -1,41 +1,40 @@
|
|
#ifndef PREVIEWBUTTONDELEGATE_H
|
|
#define PREVIEWBUTTONDELEGATE_H
|
|
|
|
-#include <QStyledItemDelegate>
|
|
#include <QPushButton>
|
|
-#include <QTableView>
|
|
|
|
+#include "library/tableitemdelegate.h"
|
|
#include "track/track.h"
|
|
|
|
class ControlProxy;
|
|
|
|
-class PreviewButtonDelegate : public QStyledItemDelegate {
|
|
+class PreviewButtonDelegate : public TableItemDelegate {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
- explicit PreviewButtonDelegate(QObject* parent = NULL, int column = 0);
|
|
+ explicit PreviewButtonDelegate(QTableView* parent, int column);
|
|
virtual ~PreviewButtonDelegate();
|
|
|
|
- QWidget* createEditor(QWidget *parent,
|
|
- const QStyleOptionViewItem &option,
|
|
- const QModelIndex &index) const;
|
|
+ QWidget* createEditor(QWidget* parent,
|
|
+ const QStyleOptionViewItem& option,
|
|
+ const QModelIndex& index) const;
|
|
|
|
- void setEditorData(QWidget *editor, const QModelIndex &index) const;
|
|
- void setModelData(QWidget *editor, QAbstractItemModel *model,
|
|
+ void setEditorData(QWidget* editor, const QModelIndex& index) const;
|
|
+ void setModelData(QWidget* editor, QAbstractItemModel* model,
|
|
const QModelIndex &index) const;
|
|
- void paint(QPainter *painter, const QStyleOptionViewItem &option,
|
|
- const QModelIndex &index) const;
|
|
+ void paintItem(QPainter* painter, const QStyleOptionViewItem& option,
|
|
+ const QModelIndex& index) const;
|
|
QSize sizeHint(const QStyleOptionViewItem &option,
|
|
- const QModelIndex &index) const;
|
|
- void updateEditorGeometry(QWidget *editor,const QStyleOptionViewItem &option,
|
|
- const QModelIndex &index) const;
|
|
+ const QModelIndex& index) const;
|
|
+ void updateEditorGeometry(QWidget* editor,const QStyleOptionViewItem& option,
|
|
+ const QModelIndex& index) const;
|
|
|
|
signals:
|
|
void loadTrackToPlayer(TrackPointer Track, QString group, bool play);
|
|
void buttonSetChecked(bool);
|
|
|
|
public slots:
|
|
- void cellEntered(const QModelIndex &index);
|
|
+ void cellEntered(const QModelIndex& index);
|
|
void buttonClicked();
|
|
void previewDeckPlayChanged(double v);
|
|
|
|
diff --git a/src/library/stardelegate.cpp b/src/library/stardelegate.cpp
|
|
index 374ea82531..90daa60f5b 100644
|
|
--- a/src/library/stardelegate.cpp
|
|
+++ b/src/library/stardelegate.cpp
|
|
@@ -18,19 +18,20 @@
|
|
|
|
#include <QtDebug>
|
|
|
|
+#include "library/tableitemdelegate.h"
|
|
#include "library/stardelegate.h"
|
|
#include "library/stareditor.h"
|
|
#include "library/starrating.h"
|
|
|
|
-StarDelegate::StarDelegate(QObject* pParent)
|
|
- : QStyledItemDelegate(pParent),
|
|
- m_pTableView(qobject_cast<QTableView*>(pParent)),
|
|
+StarDelegate::StarDelegate(QTableView* pTableView)
|
|
+ : TableItemDelegate(pTableView),
|
|
+ m_pTableView(pTableView),
|
|
m_isOneCellInEditMode(false) {
|
|
- connect(pParent, SIGNAL(entered(QModelIndex)),
|
|
+ connect(pTableView, SIGNAL(entered(QModelIndex)),
|
|
this, SLOT(cellEntered(QModelIndex)));
|
|
}
|
|
|
|
-void StarDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option,
|
|
+void StarDelegate::paintItem(QPainter* painter, const QStyleOptionViewItem& option,
|
|
const QModelIndex& index) const {
|
|
// let the editor do the painting if this cell is currently being edited
|
|
if (index == m_currentEditedCellIndex) {
|
|
diff --git a/src/library/stardelegate.h b/src/library/stardelegate.h
|
|
index a223cc4c97..999c65e2ff 100644
|
|
--- a/src/library/stardelegate.h
|
|
+++ b/src/library/stardelegate.h
|
|
@@ -19,17 +19,16 @@
|
|
#ifndef STARDELEGATE_H
|
|
#define STARDELEGATE_H
|
|
|
|
-#include <QStyledItemDelegate>
|
|
-#include <QTableView>
|
|
+#include "library/tableitemdelegate.h"
|
|
|
|
-class StarDelegate : public QStyledItemDelegate {
|
|
+class StarDelegate : public TableItemDelegate {
|
|
Q_OBJECT
|
|
public:
|
|
- StarDelegate(QObject* pParent = 0);
|
|
+ StarDelegate(QTableView* pTrackTable);
|
|
|
|
// reimplemented from QItemDelegate and is called whenever the view needs to
|
|
// repaint an item
|
|
- void paint(QPainter* painter, const QStyleOptionViewItem& option,
|
|
+ void paintItem(QPainter* painter, const QStyleOptionViewItem& option,
|
|
const QModelIndex& index) const;
|
|
|
|
// returns an item's preferred size
|
|
diff --git a/src/library/starrating.cpp b/src/library/starrating.cpp
|
|
index c514e7b3f8..04f9c9023f 100644
|
|
--- a/src/library/starrating.cpp
|
|
+++ b/src/library/starrating.cpp
|
|
@@ -15,6 +15,8 @@
|
|
* *
|
|
***************************************************************************/
|
|
|
|
+#include <QPainter>
|
|
+
|
|
#include "library/starrating.h"
|
|
#include "util/math.h"
|
|
|
|
diff --git a/src/library/starrating.h b/src/library/starrating.h
|
|
index e8cd31aaa0..3ee79f46b1 100644
|
|
--- a/src/library/starrating.h
|
|
+++ b/src/library/starrating.h
|
|
@@ -22,8 +22,10 @@
|
|
#include <QMetaType>
|
|
#include <QPointF>
|
|
#include <QVector>
|
|
-#include <QPainter>
|
|
-#include <QStyledItemDelegate>
|
|
+#include <QPolygonF>
|
|
+
|
|
+class QPainter;
|
|
+
|
|
|
|
/*
|
|
* The StarRating class represents a rating as a number of stars.
|
|
diff --git a/src/library/tableitemdelegate.cpp b/src/library/tableitemdelegate.cpp
|
|
new file mode 100644
|
|
index 0000000000..c1097e6f99
|
|
--- /dev/null
|
|
+++ b/src/library/tableitemdelegate.cpp
|
|
@@ -0,0 +1,18 @@
|
|
+
|
|
+#include <QTableView>
|
|
+
|
|
+#include "library/tableitemdelegate.h"
|
|
+
|
|
+
|
|
+TableItemDelegate::TableItemDelegate(QTableView* pTableView)
|
|
+ : QStyledItemDelegate(pTableView),
|
|
+ m_pTableView(pTableView) {
|
|
+}
|
|
+
|
|
+TableItemDelegate::~TableItemDelegate() {
|
|
+}
|
|
+
|
|
+void TableItemDelegate::paint(QPainter* painter,const QStyleOptionViewItem& option,
|
|
+ const QModelIndex& index) const {
|
|
+ paintItem(painter, option, index);
|
|
+}
|
|
diff --git a/src/library/tableitemdelegate.h b/src/library/tableitemdelegate.h
|
|
new file mode 100644
|
|
index 0000000000..a39071aac3
|
|
--- /dev/null
|
|
+++ b/src/library/tableitemdelegate.h
|
|
@@ -0,0 +1,25 @@
|
|
+#ifndef TABLEITEMDELEGATE_H
|
|
+#define TABLEITEMDELEGATE_H
|
|
+
|
|
+#include <QStyledItemDelegate>
|
|
+
|
|
+class QTableView;
|
|
+class QStyleOptionViewItem;
|
|
+
|
|
+class TableItemDelegate : public QStyledItemDelegate {
|
|
+ Q_OBJECT
|
|
+ public:
|
|
+ explicit TableItemDelegate(QTableView* pTableView);
|
|
+ virtual ~TableItemDelegate();
|
|
+
|
|
+ void paint(QPainter *painter, const QStyleOptionViewItem &option,
|
|
+ const QModelIndex &index) const;
|
|
+
|
|
+ virtual void paintItem(QPainter *painter, const QStyleOptionViewItem &option,
|
|
+ const QModelIndex &index) const = 0;
|
|
+
|
|
+ private:
|
|
+ QTableView* m_pTableView;
|
|
+};
|
|
+
|
|
+#endif // TABLEITEMDELEGATE_H
|
|
|
|
From f9bdf3e4897fc1670e8ac7a6309ad784d5f52f16 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= <daschuer@mixxx.org>
|
|
Date: Wed, 30 May 2018 23:59:35 +0200
|
|
Subject: [PATCH 3/4] de-duplicated Code
|
|
|
|
---
|
|
src/library/bpmdelegate.cpp | 30 ------------------------------
|
|
src/library/coverartdelegate.cpp | 29 -----------------------------
|
|
src/library/previewbuttondelegate.cpp | 27 ---------------------------
|
|
src/library/stardelegate.cpp | 11 ++++++++++-
|
|
src/library/stardelegate.h | 3 +++
|
|
src/library/starrating.cpp | 2 --
|
|
src/library/tableitemdelegate.cpp | 30 ++++++++++++++++++++++++++++++
|
|
7 files changed, 43 insertions(+), 89 deletions(-)
|
|
|
|
diff --git a/src/library/bpmdelegate.cpp b/src/library/bpmdelegate.cpp
|
|
index 793c0f9c2f..a8295b358d 100644
|
|
--- a/src/library/bpmdelegate.cpp
|
|
+++ b/src/library/bpmdelegate.cpp
|
|
@@ -99,34 +99,4 @@ void BPMDelegate::paintItem(QPainter* painter,const QStyleOptionViewItem &option
|
|
m_pCheckBox);
|
|
}
|
|
}
|
|
-
|
|
-
|
|
- /*
|
|
-
|
|
- painter->save();
|
|
- painter->setClipRect(option.rect);
|
|
-
|
|
- if (m_pTableView != NULL) {
|
|
- QStyle* style = m_pTableView->style();
|
|
- if (style != NULL) {
|
|
- style->drawControl(QStyle::CE_ItemViewItem, &option, painter,
|
|
- m_pTableView);
|
|
- }
|
|
- }
|
|
-
|
|
- // Set the palette appropriately based on whether the row is selected or
|
|
- // not. We also have to check if it is inactive or not and use the
|
|
- // appropriate ColorGroup.
|
|
- QPalette::ColorGroup cg = option.state & QStyle::State_Enabled
|
|
- ? QPalette::Normal : QPalette::Disabled;
|
|
- if (cg == QPalette::Normal && !(option.state & QStyle::State_Active))
|
|
- cg = QPalette::Inactive;
|
|
-
|
|
- if (option.state & QStyle::State_Selected) {
|
|
- painter->setBrush(option.palette.color(cg, QPalette::HighlightedText));
|
|
- } else {
|
|
- painter->setBrush(option.palette.color(cg, QPalette::Text));
|
|
- }
|
|
- */
|
|
-
|
|
}
|
|
diff --git a/src/library/coverartdelegate.cpp b/src/library/coverartdelegate.cpp
|
|
index fea6276eb1..871807d2e8 100644
|
|
--- a/src/library/coverartdelegate.cpp
|
|
+++ b/src/library/coverartdelegate.cpp
|
|
@@ -86,37 +86,10 @@ void CoverArtDelegate::slotCoverFound(const QObject* pRequestor,
|
|
void CoverArtDelegate::paintItem(QPainter *painter,
|
|
const QStyleOptionViewItem &option,
|
|
const QModelIndex &index) const {
|
|
-
|
|
- painter->save();
|
|
- painter->setClipRect(option.rect);
|
|
-
|
|
- if (m_pTableView != NULL) {
|
|
- QStyle* style = m_pTableView->style();
|
|
- if (style != NULL) {
|
|
- style->drawControl(QStyle::CE_ItemViewItem, &option, painter,
|
|
- m_pTableView);
|
|
- }
|
|
- }
|
|
-
|
|
- // Set the palette appropriately based on whether the row is selected or
|
|
- // not. We also have to check if it is inactive or not and use the
|
|
- // appropriate ColorGroup.
|
|
- QPalette::ColorGroup cg = option.state & QStyle::State_Enabled
|
|
- ? QPalette::Normal : QPalette::Disabled;
|
|
- if (cg == QPalette::Normal && !(option.state & QStyle::State_Active))
|
|
- cg = QPalette::Inactive;
|
|
-
|
|
- if (option.state & QStyle::State_Selected) {
|
|
- painter->setBrush(option.palette.color(cg, QPalette::HighlightedText));
|
|
- } else {
|
|
- painter->setBrush(option.palette.color(cg, QPalette::Text));
|
|
- }
|
|
-
|
|
CoverArtCache* pCache = CoverArtCache::instance();
|
|
if (pCache == NULL || m_iIdColumn == -1 || m_iCoverSourceColumn == -1 ||
|
|
m_iCoverTypeColumn == -1 || m_iCoverLocationColumn == -1 ||
|
|
m_iCoverHashColumn == -1) {
|
|
- painter->restore();
|
|
return;
|
|
}
|
|
|
|
@@ -126,7 +99,6 @@ void CoverArtDelegate::paintItem(QPainter *painter,
|
|
|
|
// We don't support types other than METADATA or FILE currently.
|
|
if (info.type != CoverInfo::METADATA && info.type != CoverInfo::FILE) {
|
|
- painter->restore();
|
|
return;
|
|
}
|
|
|
|
@@ -157,5 +129,4 @@ void CoverArtDelegate::paintItem(QPainter *painter,
|
|
// we can request an update.
|
|
m_cacheMissRows.append(index.row());
|
|
}
|
|
- painter->restore();
|
|
}
|
|
diff --git a/src/library/previewbuttondelegate.cpp b/src/library/previewbuttondelegate.cpp
|
|
index be63482b71..5c916bd841 100644
|
|
--- a/src/library/previewbuttondelegate.cpp
|
|
+++ b/src/library/previewbuttondelegate.cpp
|
|
@@ -88,36 +88,9 @@ void PreviewButtonDelegate::paintItem(QPainter* painter,
|
|
// it's playing.
|
|
m_pButton->setChecked(index.data().toBool() && playing);
|
|
|
|
- painter->save();
|
|
-
|
|
- painter->setClipRect(option.rect);
|
|
-
|
|
- if (m_pTableView != NULL) {
|
|
- QStyle* style = m_pTableView->style();
|
|
- if (style != NULL) {
|
|
- style->drawControl(QStyle::CE_ItemViewItem, &option, painter,
|
|
- m_pTableView);
|
|
- }
|
|
- }
|
|
-
|
|
- // Set the palette appropriately based on whether the row is selected or
|
|
- // not. We also have to check if it is inactive or not and use the
|
|
- // appropriate ColorGroup.
|
|
- QPalette::ColorGroup cg = option.state & QStyle::State_Enabled
|
|
- ? QPalette::Normal : QPalette::Disabled;
|
|
- if (cg == QPalette::Normal && !(option.state & QStyle::State_Active))
|
|
- cg = QPalette::Inactive;
|
|
-
|
|
- if (option.state & QStyle::State_Selected) {
|
|
- painter->setBrush(option.palette.color(cg, QPalette::HighlightedText));
|
|
- } else {
|
|
- painter->setBrush(option.palette.color(cg, QPalette::Text));
|
|
- }
|
|
-
|
|
// Render button at the desired position
|
|
painter->translate(option.rect.topLeft());
|
|
m_pButton->render(painter);
|
|
- painter->restore();
|
|
}
|
|
|
|
void PreviewButtonDelegate::updateEditorGeometry(QWidget* editor,
|
|
diff --git a/src/library/stardelegate.cpp b/src/library/stardelegate.cpp
|
|
index 90daa60f5b..c861d93d8c 100644
|
|
--- a/src/library/stardelegate.cpp
|
|
+++ b/src/library/stardelegate.cpp
|
|
@@ -31,6 +31,15 @@ StarDelegate::StarDelegate(QTableView* pTableView)
|
|
this, SLOT(cellEntered(QModelIndex)));
|
|
}
|
|
|
|
+void StarDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option,
|
|
+ const QModelIndex& index) const {
|
|
+ // let the editor do the painting if this cell is currently being edited
|
|
+ if (index == m_currentEditedCellIndex) {
|
|
+ return;
|
|
+ }
|
|
+ TableItemDelegate::paint(painter, option, index);
|
|
+}
|
|
+
|
|
void StarDelegate::paintItem(QPainter* painter, const QStyleOptionViewItem& option,
|
|
const QModelIndex& index) const {
|
|
// let the editor do the painting if this cell is currently being edited
|
|
@@ -43,7 +52,7 @@ void StarDelegate::paintItem(QPainter* painter, const QStyleOptionViewItem& opti
|
|
initStyleOption(&newOption, index);
|
|
|
|
StarRating starRating = qVariantValue<StarRating>(index.data());
|
|
- StarEditor::renderHelper(painter, m_pTableView, option, &starRating);
|
|
+ starRating.paint(painter, option.rect);
|
|
}
|
|
|
|
QSize StarDelegate::sizeHint(const QStyleOptionViewItem& option,
|
|
diff --git a/src/library/stardelegate.h b/src/library/stardelegate.h
|
|
index 999c65e2ff..2b35fc61bb 100644
|
|
--- a/src/library/stardelegate.h
|
|
+++ b/src/library/stardelegate.h
|
|
@@ -28,6 +28,9 @@ class StarDelegate : public TableItemDelegate {
|
|
|
|
// reimplemented from QItemDelegate and is called whenever the view needs to
|
|
// repaint an item
|
|
+ void paint(QPainter* painter, const QStyleOptionViewItem& option,
|
|
+ const QModelIndex& index) const;
|
|
+
|
|
void paintItem(QPainter* painter, const QStyleOptionViewItem& option,
|
|
const QModelIndex& index) const;
|
|
|
|
diff --git a/src/library/starrating.cpp b/src/library/starrating.cpp
|
|
index 04f9c9023f..8e7bb37e7e 100644
|
|
--- a/src/library/starrating.cpp
|
|
+++ b/src/library/starrating.cpp
|
|
@@ -37,7 +37,6 @@ QSize StarRating::sizeHint() const {
|
|
|
|
void StarRating::paint(QPainter *painter, const QRect &rect) const {
|
|
// Assume the painter is configured with the right brush.
|
|
- painter->save();
|
|
painter->setRenderHint(QPainter::Antialiasing, true);
|
|
painter->setPen(Qt::NoPen);
|
|
|
|
@@ -56,5 +55,4 @@ void StarRating::paint(QPainter *painter, const QRect &rect) const {
|
|
}
|
|
painter->translate(1.0, 0.0);
|
|
}
|
|
- painter->restore();
|
|
}
|
|
diff --git a/src/library/tableitemdelegate.cpp b/src/library/tableitemdelegate.cpp
|
|
index c1097e6f99..8f0575e105 100644
|
|
--- a/src/library/tableitemdelegate.cpp
|
|
+++ b/src/library/tableitemdelegate.cpp
|
|
@@ -1,5 +1,6 @@
|
|
|
|
#include <QTableView>
|
|
+#include <QPainter>
|
|
|
|
#include "library/tableitemdelegate.h"
|
|
|
|
@@ -14,5 +15,34 @@ TableItemDelegate::~TableItemDelegate() {
|
|
|
|
void TableItemDelegate::paint(QPainter* painter,const QStyleOptionViewItem& option,
|
|
const QModelIndex& index) const {
|
|
+
|
|
+ painter->save();
|
|
+
|
|
+ painter->setClipRect(option.rect);
|
|
+
|
|
+ // Set the palette appropriately based on whether the row is selected or
|
|
+ // not. We also have to check if it is inactive or not and use the
|
|
+ // appropriate ColorGroup.
|
|
+ QPalette::ColorGroup cg = option.state & QStyle::State_Enabled
|
|
+ ? QPalette::Normal : QPalette::Disabled;
|
|
+ if (cg == QPalette::Normal && !(option.state & QStyle::State_Active))
|
|
+ cg = QPalette::Inactive;
|
|
+
|
|
+ if (option.state & QStyle::State_Selected) {
|
|
+ painter->setBrush(option.palette.color(cg, QPalette::HighlightedText));
|
|
+ } else {
|
|
+ painter->setBrush(option.palette.color(cg, QPalette::Text));
|
|
+ }
|
|
+
|
|
+ if (m_pTableView) {
|
|
+ QStyle* style = m_pTableView->style();
|
|
+ if (style) {
|
|
+ style->drawControl(QStyle::CE_ItemViewItem, &option, painter,
|
|
+ m_pTableView);
|
|
+ }
|
|
+ }
|
|
+
|
|
paintItem(painter, option, index);
|
|
+
|
|
+ painter->restore();
|
|
}
|
|
|
|
From 196994ea61ac415203b4356761eed7d023578249 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= <daschuer@mixxx.org>
|
|
Date: Wed, 6 Jun 2018 00:51:59 +0200
|
|
Subject: [PATCH 4/4] Remove redundant code
|
|
|
|
---
|
|
src/library/bpmdelegate.cpp | 15 ---------------
|
|
src/library/stardelegate.cpp | 4 ----
|
|
2 files changed, 19 deletions(-)
|
|
|
|
diff --git a/src/library/bpmdelegate.cpp b/src/library/bpmdelegate.cpp
|
|
index a8295b358d..dae91d45dc 100644
|
|
--- a/src/library/bpmdelegate.cpp
|
|
+++ b/src/library/bpmdelegate.cpp
|
|
@@ -77,21 +77,6 @@ void BPMDelegate::paintItem(QPainter* painter,const QStyleOptionViewItem &option
|
|
QStyleOptionViewItemV4 opt = option;
|
|
initStyleOption(&opt, index);
|
|
|
|
- // Set the palette appropriately based on whether the row is selected or
|
|
- // not. We also have to check if it is inactive or not and use the
|
|
- // appropriate ColorGroup.
|
|
- QPalette::ColorGroup cg = option.state & QStyle::State_Enabled
|
|
- ? QPalette::Normal : QPalette::Disabled;
|
|
- if (cg == QPalette::Normal && !(option.state & QStyle::State_Active))
|
|
- cg = QPalette::Inactive;
|
|
-
|
|
- if (option.state & QStyle::State_Selected) {
|
|
- painter->setBrush(option.palette.color(cg, QPalette::HighlightedText));
|
|
- } else {
|
|
- painter->setBrush(option.palette.color(cg, QPalette::Text));
|
|
- }
|
|
-
|
|
-
|
|
if (m_pTableView != NULL) {
|
|
QStyle* style = m_pTableView->style();
|
|
if (style != NULL) {
|
|
diff --git a/src/library/stardelegate.cpp b/src/library/stardelegate.cpp
|
|
index c861d93d8c..5b82ff6236 100644
|
|
--- a/src/library/stardelegate.cpp
|
|
+++ b/src/library/stardelegate.cpp
|
|
@@ -47,10 +47,6 @@ void StarDelegate::paintItem(QPainter* painter, const QStyleOptionViewItem& opti
|
|
return;
|
|
}
|
|
|
|
- // Populate the correct colors based on the styling
|
|
- QStyleOptionViewItemV4 newOption = option;
|
|
- initStyleOption(&newOption, index);
|
|
-
|
|
StarRating starRating = qVariantValue<StarRating>(index.data());
|
|
starRating.paint(painter, option.rect);
|
|
}
|