diff options
Diffstat (limited to 'libmultimc/src')
-rw-r--r-- | libmultimc/src/instversionlist.cpp | 95 |
1 files changed, 94 insertions, 1 deletions
diff --git a/libmultimc/src/instversionlist.cpp b/libmultimc/src/instversionlist.cpp index 301b9969..6c7b44bb 100644 --- a/libmultimc/src/instversionlist.cpp +++ b/libmultimc/src/instversionlist.cpp @@ -17,7 +17,7 @@ #include "instversion.h" InstVersionList::InstVersionList(QObject *parent) : - QObject(parent) + QAbstractListModel(parent) { } @@ -30,3 +30,96 @@ const InstVersion *InstVersionList::findVersion(const QString &descriptor) } return NULL; } + +// Column Enum +enum VListColumns +{ + // First column - Name + NameColumn = 0, + + // Second column - Type + TypeColumn, + + // Column count + ColCount +}; + +QVariant InstVersionList::data(const QModelIndex &index, int role) const +{ + if (!index.isValid()) + return QVariant(); + + if (index.row() > count()) + return QVariant(); + + + const InstVersion *version = at(index.row()); + + switch (role) + { + case Qt::DisplayRole: + switch (index.column()) + { + case NameColumn: + return version->name(); + + case TypeColumn: + return version->typeName(); + + default: + return QVariant(); + } + + case Qt::ToolTipRole: + return version->descriptor(); + + default: + return QVariant(); + } +} + +QVariant InstVersionList::headerData(int section, Qt::Orientation orientation, int role) const +{ + switch (role) + { + case Qt::DisplayRole: + switch (section) + { + case NameColumn: + return "Name"; + + case TypeColumn: + return "Type"; + + default: + return QVariant(); + } + + case Qt::ToolTipRole: + switch (section) + { + case NameColumn: + return "The name of the version."; + + case TypeColumn: + return "The version's type."; + + default: + return QVariant(); + } + + default: + return QVariant(); + } +} + +int InstVersionList::rowCount(const QModelIndex &parent) const +{ + // Return count + return count(); +} + +int InstVersionList::columnCount(const QModelIndex &parent) const +{ + return ColCount; +} |