summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2018-10-06 14:22:28 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2018-10-06 14:22:28 +0200
commitb37907c8269c6e96a09da830aea85c20c4209229 (patch)
treeb2dec9896ea8550f44dd0454a8c36c8e737e4f58
parentfa5b7e32e12b6310c93a9d3c1c4654f61c0f6679 (diff)
Improve look of the main channel chackbox rendering.
-rw-r--r--src/filelist.cc35
1 files changed, 24 insertions, 11 deletions
diff --git a/src/filelist.cc b/src/filelist.cc
index 9c6f591..e1467e3 100644
--- a/src/filelist.cc
+++ b/src/filelist.cc
@@ -46,6 +46,8 @@
#include <QStyledItemDelegate>
#include <QPainter>
#include <QHeaderView>
+#include <QStyleOptionButton>
+#include <QApplication>
#include <sndfile.h>
@@ -179,17 +181,28 @@ public:
}
}
-// void paint(QPainter * painter,
-// const QStyleOptionViewItem & option,
-// const QModelIndex & index ) const override
-// {
-// if(index.column() == 0)
-// {
-// painter->drawRect(option.rect);
-// return;
-// }
-// QStyledItemDelegate::paint(painter, option, index);
-// }
+ void paint(QPainter* painter, const QStyleOptionViewItem& option,
+ const QModelIndex& index) const override
+ {
+ if(index.column() == 2) // Main Channel
+ {
+ auto audiofile_ids = instrument.getAudioFileList();
+ auto audiofile_id = audiofile_ids.begin() + index.row();
+ const auto& audiofile = instrument.getAudioFile(*audiofile_id);
+
+ bool checked = audiofile.getMainChannel();
+ QStyleOptionButton butOpt;
+ butOpt.state = QStyle::State_Enabled;
+ butOpt.state |= checked ? QStyle::State_On : QStyle::State_Off;
+ butOpt.rect = option.rect;
+ QApplication::style()->drawControl( QStyle::CE_CheckBox,
+ &butOpt, painter );
+ }
+ else
+ {
+ QStyledItemDelegate::paint(painter, option, index);
+ }
+ }
private:
Instrument& instrument;