summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;