Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef FILESLISTMODEL_H
- #define FILESLISTMODEL_H
- #include <QtCore/QAbstractItemModel>
- #include <QtCore/QStringList>
- #include "core/config.h"
- /**
- * Represents a single line from «Files» config section
- * for storing in a flat list (not a map), see FLNodeGroup.
- *
- * When initializing model, it converts ConfigArchsSet to list of groups of nodes,
- * and then configArchsSet() can convert it back.
- */
- struct FLNode {
- QString target;
- bool symlinking;
- QString source;
- FLNode(QString target, bool symlinking, QString source):
- target(target), symlinking(symlinking), source(source) {}
- };
- /**
- * A group of nodes for a single architecture.
- *
- * Groups are the top level of the tree. Each group contains flat list of nodes.
- */
- struct FLNodeGroup {
- QString arch;
- QList<FLNode> nodes;
- FLNodeGroup(QString arch, QList<FLNode> nodes):
- arch(arch), nodes(nodes) {}
- };
- /**
- * Internal pointer for assigning to QModelIndex.
- *
- * Stores index of architecture node group and index of node in it.
- * To store pointer to the whole group, set \c fileIndex to \c -1.
- */
- struct FLNodePointer {
- int archIndex;
- int fileIndex;
- FLNodePointer(int archIndex, int fileIndex=-1):
- archIndex(archIndex), fileIndex(fileIndex) {}
- };
- class FilesListModel : public QAbstractItemModel
- {
- public:
- static const int COLUMN_TARGET = 0;
- static const int COLUMN_SOURCE = 1;
- static const int COLUMNS_COUNT = 2;
- private:
- QList<FLNodeGroup> _data;
- public:
- FilesListModel(ConfigArchsSet set);
- ConfigArchsSet configArchsSet();
- virtual QModelIndex index(int row, int column, const QModelIndex& parent=QModelIndex()) const;
- virtual QModelIndex parent(const QModelIndex &child) const;
- virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
- virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
- virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
- // virtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
- // virtual Qt::ItemFlags flags(const QModelIndex& index) const;
- // virtual bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex());
- };
- #endif // FILESLISTMODEL_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement