git-svn-id: svn://db.shs.com.ru/libs@114 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
57
cd_utils/pult/cd_kmodel.h
Normal file
57
cd_utils/pult/cd_kmodel.h
Normal file
@@ -0,0 +1,57 @@
|
||||
#ifndef CD_KMODEL_H
|
||||
#define CD_KMODEL_H
|
||||
|
||||
#include "cdutils_k.h"
|
||||
#include <QAbstractItemModel>
|
||||
|
||||
class CDKItemModel;
|
||||
|
||||
class CDKItem {
|
||||
friend class CDKItemModel;
|
||||
public:
|
||||
enum CDKItemType{ItemCDType, ItemCDSection};
|
||||
CDKItem(int index, CDKItemType type, CDKItem * parent);
|
||||
~CDKItem();
|
||||
QVariant data(int column) const;
|
||||
bool setData(int column, const QVariant & value);
|
||||
|
||||
private:
|
||||
PIDeque<int> buildPath() const;
|
||||
|
||||
CDKItem * parent_;
|
||||
int index_;
|
||||
CDKItemType type_;
|
||||
QList<CDKItem *> childs;
|
||||
};
|
||||
|
||||
class CDKItemModel : public QAbstractItemModel {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CDKItemModel(QObject *parent = 0);
|
||||
~CDKItemModel();
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
||||
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
|
||||
QModelIndex parent(const QModelIndex &index) const;
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
|
||||
|
||||
void rebuildModel();
|
||||
void buildItem(CDKItem * it, CDUtils::CDSection r);
|
||||
|
||||
public slots:
|
||||
|
||||
private:
|
||||
void internalRebuild();
|
||||
CDKItem * getItem(const QModelIndex & index) const;
|
||||
|
||||
CDKItem * root;
|
||||
|
||||
signals:
|
||||
|
||||
};
|
||||
|
||||
#endif // CD_KMODEL_H
|
||||
Reference in New Issue
Block a user