diff options
author | Petr Mrázek <peterix@gmail.com> | 2013-08-26 06:30:11 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2013-08-26 06:30:11 +0200 |
commit | a63c7340a632c634733271332a43aac82bc73799 (patch) | |
tree | 6ee5760f8a61ed40b657701a523cd69996a64688 /logic/lists/InstanceList.h | |
parent | 392c58c4b0db7ac5a826a16557712dc005f3705e (diff) | |
download | MultiMC-a63c7340a632c634733271332a43aac82bc73799.tar MultiMC-a63c7340a632c634733271332a43aac82bc73799.tar.gz MultiMC-a63c7340a632c634733271332a43aac82bc73799.tar.lz MultiMC-a63c7340a632c634733271332a43aac82bc73799.tar.xz MultiMC-a63c7340a632c634733271332a43aac82bc73799.zip |
Nuke the old instance model, LONG LIVE THE NEW ONE
Diffstat (limited to 'logic/lists/InstanceList.h')
-rw-r--r-- | logic/lists/InstanceList.h | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/logic/lists/InstanceList.h b/logic/lists/InstanceList.h index 50ba56f3..501edeb1 100644 --- a/logic/lists/InstanceList.h +++ b/logic/lists/InstanceList.h @@ -17,12 +17,15 @@ #include <QObject> #include <QSharedPointer> +#include <QAbstractListModel> +#include "categorizedsortfilterproxymodel.h" +#include <QIcon> #include "logic/BaseInstance.h" class BaseInstance; -class InstanceList : public QObject +class InstanceList : public QAbstractListModel { Q_OBJECT private: @@ -33,6 +36,16 @@ public: explicit InstanceList(const QString &instDir, QObject *parent = 0); virtual ~InstanceList(); +public: + 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; + + enum AdditionalRoles + { + InstancePointerRole = 0x34B1CB48 ///< Return pointer to real instance + }; /*! * \brief Error codes returned by functions in the InstanceList class. * NoError Indicates that no error occurred. @@ -75,16 +88,26 @@ public: /// Get an instance by ID InstancePtr getInstanceById (QString id); - signals: - void instanceAdded(int index); - void instanceChanged(int index); - void invalidated(); + void dataIsInvalid(); private slots: void propertiesChanged(BaseInstance * inst); + void instanceNuked(BaseInstance * inst); void groupChanged(); +private: + int getInstIndex(BaseInstance * inst); protected: QString m_instDir; QList< InstancePtr > m_instances; }; + +class InstanceProxyModel : public KCategorizedSortFilterProxyModel +{ +public: + explicit InstanceProxyModel ( QObject *parent = 0 ); + +protected: + virtual bool subSortLessThan ( const QModelIndex& left, const QModelIndex& right ) const; +}; + |