summaryrefslogtreecommitdiffstats
path: root/gui/instancemodel.h
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2013-03-11 22:19:17 +0100
committerPetr Mrázek <peterix@gmail.com>2013-03-11 22:19:17 +0100
commit46f93311afc9f1e2afc306f63cee0e4f462758e2 (patch)
treecc945d66e6ca5e68c43b354d3f8f6d6e70cf5326 /gui/instancemodel.h
parent36396f7c6aca9fcc61c8620e10c31ed2c8999ebd (diff)
downloadMultiMC-46f93311afc9f1e2afc306f63cee0e4f462758e2.tar
MultiMC-46f93311afc9f1e2afc306f63cee0e4f462758e2.tar.gz
MultiMC-46f93311afc9f1e2afc306f63cee0e4f462758e2.tar.lz
MultiMC-46f93311afc9f1e2afc306f63cee0e4f462758e2.tar.xz
MultiMC-46f93311afc9f1e2afc306f63cee0e4f462758e2.zip
Instance view, model, delegate.
Diffstat (limited to 'gui/instancemodel.h')
-rw-r--r--gui/instancemodel.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/gui/instancemodel.h b/gui/instancemodel.h
new file mode 100644
index 00000000..995c51ec
--- /dev/null
+++ b/gui/instancemodel.h
@@ -0,0 +1,38 @@
+#pragma once
+
+#include <QAbstractListModel>
+#include "kcategorizedsortfilterproxymodel.h"
+#include "instancelist.h"
+#include <QIcon>
+
+class InstanceModel : public QAbstractListModel
+{
+ Q_OBJECT
+public:
+ enum AdditionalRoles
+ {
+ InstancePointerRole = 0x34B1CB48 ///< Return pointer to real instance
+ };
+ explicit InstanceModel ( const InstanceList& instances,
+ QObject *parent = 0 );
+
+ QModelIndex index ( int row, int column = 0,
+ const QModelIndex& parent = QModelIndex() ) const;
+ int rowCount ( const QModelIndex& parent = QModelIndex() ) const;
+ QVariant data ( const QModelIndex& index, int role ) const;
+ Qt::ItemFlags flags ( const QModelIndex& index ) const;
+
+private:
+ const InstanceList* m_instances;
+ QIcon cachedIcon;
+};
+
+class InstanceProxyModel : public KCategorizedSortFilterProxyModel
+{
+public:
+ explicit InstanceProxyModel ( QObject *parent = 0 );
+
+protected:
+ virtual bool subSortLessThan ( const QModelIndex& left, const QModelIndex& right ) const;
+};
+