propertyselectormodel.h

来自「压缩包里有教材<<C++模式设计-基于QT4开源跨平台开发框架&gt」· C头文件 代码 · 共 61 行

H
61
字号
#ifndef _PROPERTY_SELECTOR_MODEL_H_#define _PROPERTY_SELECTOR_MODEL_H_#include <QObject>#include <QStringList>#include <QAbstractListModel>#include <QVariant>#include <QItemSelection>using namespace Qt;class DataObject;class QAction;/** This class facilitates the use of the properties of another class ascolumn headers in a view. It has methods that allow the user to selectproperties in the associated list view and it has accessors forgetting either the full list of properties or the list of selected properties.*///start id=overridesclass PropertySelectorModel : public QAbstractListModel {    Q_OBJECTpublic:    PropertySelectorModel(DataObject* propnamesrc, QObject* parent = 0);    int rowCount(const QModelIndex& parent = QModelIndex()) const;    QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;    QVariant headerData(int section, Qt::Orientation orientation,                        int role = DisplayRole) const;    ItemFlags flags(const QModelIndex &index) const;    bool setData(const QModelIndex &index, const QVariant &value,                 int role = EditRole);    bool insertRows(int position, int rows, const QModelIndex &index = QModelIndex());    bool removeRows(int position, int rows, const QModelIndex &index = QModelIndex());//end//start id=additional-methods    void initializePropertyNames();    QStringList getAllPropertyNames() const;    QStringList getSelectedPropertyNames() const;//end    //start id=signals-slotssignals:    void readyQuit();    void readyCloseWindow(bool);    void readyRestore(QList<QPersistentModelIndex>);public slots:    void updateSelects(QModelIndexList selects);    void prepareShow();//end//start id=overridesprivate:    QStringList m_PropertyNames;    DataObject* m_PropNameSource;//stop//start id=signals-slots    QList<QPersistentModelIndex> m_SelectedIndexes;//stop//start id=overrides};//stop#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?