From 64c7825f95ac398cfaeaf3c059d9504acd481432 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 11 Apr 2012 12:54:31 +0200 Subject: [PATCH] Display icons in the SourceFileModel --- src/mkvtoolnix-gui/source_file_model.cpp | 11 ++++++++++- src/mkvtoolnix-gui/source_file_model.h | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/mkvtoolnix-gui/source_file_model.cpp b/src/mkvtoolnix-gui/source_file_model.cpp index 8ad67a9a6..41fcc9fd2 100644 --- a/src/mkvtoolnix-gui/source_file_model.cpp +++ b/src/mkvtoolnix-gui/source_file_model.cpp @@ -8,6 +8,9 @@ SourceFileModel::SourceFileModel(QObject *parent) : QAbstractItemModel{parent} , m_sourceFiles{nullptr} { + m_additionalPartIcon.addFile(":/icons/16x16/distribute-horizontal-margin.png"); + m_addedIcon.addFile(":/icons/16x16/distribute-horizontal-x.png"); + m_normalIcon.addFile(":/icons/16x16/distribute-vertical-page.png"); } SourceFileModel::~SourceFileModel() { @@ -95,10 +98,16 @@ SourceFileModel::data(QModelIndex const &index, if (role == Qt::TextAlignmentRole) return 2 == index.column() ? Qt::AlignRight : Qt::AlignLeft; + auto sourceFile = sourceFileFromIndex(index); + if (role == Qt::DecorationRole) + return 0 != index.column() ? QVariant{} + : sourceFile->m_additionalPart ? m_additionalPartIcon + : sourceFile->m_appended ? m_addedIcon + : m_normalIcon; + if (role != Qt::DisplayRole) return QVariant{}; - auto sourceFile = sourceFileFromIndex(index); if (!sourceFile) return QVariant{}; diff --git a/src/mkvtoolnix-gui/source_file_model.h b/src/mkvtoolnix-gui/source_file_model.h index d9509deae..961f5677a 100644 --- a/src/mkvtoolnix-gui/source_file_model.h +++ b/src/mkvtoolnix-gui/source_file_model.h @@ -6,6 +6,7 @@ #include "mkvtoolnix-gui/source_file.h" #include +#include #include class SourceFileModel; @@ -16,6 +17,7 @@ class SourceFileModel : public QAbstractItemModel { protected: QList *m_sourceFiles; + QIcon m_additionalPartIcon, m_addedIcon, m_normalIcon; public: SourceFileModel(QObject *parent);