From b37907c8269c6e96a09da830aea85c20c4209229 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sat, 6 Oct 2018 14:22:28 +0200 Subject: Improve look of the main channel chackbox rendering. --- src/filelist.cc | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) (limited to 'src/filelist.cc') 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 #include #include +#include +#include #include @@ -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; -- cgit v1.2.3