summaryrefslogtreecommitdiffstats
path: root/libmultimc/src
diff options
context:
space:
mode:
authorAndrew <forkk@forkk.net>2013-03-28 11:33:31 -0500
committerAndrew <forkk@forkk.net>2013-03-28 11:33:31 -0500
commit168ed3e8e58a8e5065ffa720f8d45f4cee0f2069 (patch)
treeb673669632797eab3fdf5bbf4e9fa471bcf20290 /libmultimc/src
parentad70e3fd4cda26508f00e9b549c04a5fe8831dac (diff)
downloadMultiMC-168ed3e8e58a8e5065ffa720f8d45f4cee0f2069.tar
MultiMC-168ed3e8e58a8e5065ffa720f8d45f4cee0f2069.tar.gz
MultiMC-168ed3e8e58a8e5065ffa720f8d45f4cee0f2069.tar.lz
MultiMC-168ed3e8e58a8e5065ffa720f8d45f4cee0f2069.tar.xz
MultiMC-168ed3e8e58a8e5065ffa720f8d45f4cee0f2069.zip
Implemented version lists.
Further work on this is still needed. Currently there is no sorting or filtering of any kind. In addition, changes need to be made to fix issues with bad ETags since the current system here is based on MultiMC 4's version list system before it was fixed.
Diffstat (limited to 'libmultimc/src')
-rw-r--r--libmultimc/src/instversionlist.cpp95
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;
+}