From a63c7340a632c634733271332a43aac82bc73799 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Mon, 26 Aug 2013 06:30:11 +0200 Subject: Nuke the old instance model, LONG LIVE THE NEW ONE --- logic/lists/InstanceList.h | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) (limited to 'logic/lists/InstanceList.h') 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 #include +#include +#include "categorizedsortfilterproxymodel.h" +#include #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; +}; + -- cgit v1.2.3