pollymc/gui/instancemodel.h

44 lines
1.1 KiB
C
Raw Normal View History

2013-03-12 02:49:17 +05:30
#pragma once
#include <QAbstractListModel>
2013-08-04 15:51:51 +05:30
#include "categorizedsortfilterproxymodel.h"
#include "lists/InstanceList.h"
2013-03-12 02:49:17 +05:30
#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;
2013-03-19 03:30:46 +05:30
public slots:
void onInstanceAdded(int index);
void onInstanceChanged(int index);
void onInvalidated();
2013-03-12 02:49:17 +05:30
private:
const InstanceList* m_instances;
2013-03-19 03:30:46 +05:30
int currentInstancesNumber;
2013-03-12 02:49:17 +05:30
};
class InstanceProxyModel : public KCategorizedSortFilterProxyModel
{
public:
explicit InstanceProxyModel ( QObject *parent = 0 );
protected:
virtual bool subSortLessThan ( const QModelIndex& left, const QModelIndex& right ) const;
};