Display icons in the SourceFileModel

This commit is contained in:
Moritz Bunkus 2012-04-11 12:54:31 +02:00
parent 5cdf704821
commit 64c7825f95
2 changed files with 12 additions and 1 deletions

View File

@ -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{};

View File

@ -6,6 +6,7 @@
#include "mkvtoolnix-gui/source_file.h"
#include <QAbstractItemModel>
#include <QIcon>
#include <QList>
class SourceFileModel;
@ -16,6 +17,7 @@ class SourceFileModel : public QAbstractItemModel {
protected:
QList<SourceFilePtr> *m_sourceFiles;
QIcon m_additionalPartIcon, m_addedIcon, m_normalIcon;
public:
SourceFileModel(QObject *parent);