forked from mixxxdj/mixxx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include "library/tabledelegates/keydelegate.h" | ||
|
||
#include <qnamespace.h> | ||
|
||
#include <QPainter> | ||
#include <QStyle> | ||
#include <QTableView> | ||
|
||
#include "moc_keydelegate.cpp" | ||
#include "util/color/rgbcolor.h" | ||
|
||
KeyDelegate::KeyDelegate(QTableView* pTableView) | ||
: TableItemDelegate(pTableView) { | ||
} | ||
|
||
void KeyDelegate::paintItem( | ||
QPainter* painter, | ||
const QStyleOptionViewItem& option, | ||
const QModelIndex& index) const { | ||
const auto color = mixxx::RgbColor::fromQVariant(index.data()); | ||
|
||
if (color) { | ||
painter->fillRect(option.rect, mixxx::RgbColor::toQColor(color)); | ||
} else { | ||
// Filter out track color that is hidden | ||
if (option.state & QStyle::State_Selected) { | ||
painter->fillRect(option.rect, option.palette.highlight()); | ||
} | ||
} | ||
|
||
// Draw a border if the color cell has focus | ||
if (option.state & QStyle::State_HasFocus) { | ||
drawBorder(painter, m_focusBorderColor, option.rect); | ||
} | ||
|
||
// QStyledItemDelegate::paint(painter, option, index); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#pragma once | ||
|
||
#include "library/tabledelegates/tableitemdelegate.h" | ||
|
||
class QModelIndex; | ||
class QPainter; | ||
class QStyleOptionViewItem; | ||
|
||
class KeyDelegate : public TableItemDelegate { | ||
Q_OBJECT | ||
public: | ||
explicit KeyDelegate(QTableView* pTableView); | ||
|
||
void paintItem( | ||
QPainter* painter, | ||
const QStyleOptionViewItem& option, | ||
const QModelIndex& index) const override; | ||
}; |