##// END OF EJS Templates
Rebase fix CatalogueCatalogue
Rebase fix CatalogueCatalogue

File last commit:

r1230:964109cb8b70
r1269:66e1a8e9fbb1
Show More
CatalogueTreeModel.h
56 lines | 2.1 KiB | text/x-c | CLexer
/ gui / include / Catalogue / CatalogueTreeModel.h
Refactoring of catalogue display using a QTreeView and a custom model based on QTreeWidgetItem
r1228 #ifndef SCIQLOP_CATALOGUETREEMODEL_H
#define SCIQLOP_CATALOGUETREEMODEL_H
#include <Common/spimpl.h>
#include <QAbstractItemModel>
Refactoring of catalogue: use a custom item class
r1229
class CatalogueAbstractTreeItem;
Refactoring of catalogue display using a QTreeView and a custom model based on QTreeWidgetItem
r1228
/**
* @brief Model to display catalogue items based on QTreeWidgetItem
Refactoring of catalogue: use a custom item class
r1229 * @warning Do not use the method QTreeWidgetItem::treeWidget for an item added to this model or the
* application will crash
Refactoring of catalogue display using a QTreeView and a custom model based on QTreeWidgetItem
r1228 */
class CatalogueTreeModel : public QAbstractItemModel {
Q_OBJECT
signals:
void itemRenamed(const QModelIndex &index);
Drop of events on a catalogue
r1230 void itemDropped(const QModelIndex &parentIndex);
Refactoring of catalogue display using a QTreeView and a custom model based on QTreeWidgetItem
r1228
public:
CatalogueTreeModel(QObject *parent = nullptr);
enum class Column { Name, Validation, Count };
Refactoring of catalogue: use a custom item class
r1229 QModelIndex addTopLevelItem(CatalogueAbstractTreeItem *item);
QVector<CatalogueAbstractTreeItem *> topLevelItems() const;
Refactoring of catalogue display using a QTreeView and a custom model based on QTreeWidgetItem
r1228
Refactoring of catalogue: use a custom item class
r1229 void addChildItem(CatalogueAbstractTreeItem *child, const QModelIndex &parentIndex);
Refactoring of catalogue display using a QTreeView and a custom model based on QTreeWidgetItem
r1228
Refactoring of catalogue: use a custom item class
r1229 CatalogueAbstractTreeItem *item(const QModelIndex &index) const;
QModelIndex indexOf(CatalogueAbstractTreeItem *item, int column = 0) const;
Refactoring of catalogue display using a QTreeView and a custom model based on QTreeWidgetItem
r1228
// model
QModelIndex index(int row, int column,
const QModelIndex &parent = QModelIndex()) const override;
QModelIndex parent(const QModelIndex &index) const override;
int rowCount(const QModelIndex &parent) const override;
int columnCount(const QModelIndex &parent) const override;
Qt::ItemFlags flags(const QModelIndex &index) const override;
QVariant data(const QModelIndex &index, int role) const override;
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
Refactoring of catalogue: use a custom item class
r1229 bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column,
const QModelIndex &parent) const override;
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column,
const QModelIndex &parent) override;
Qt::DropActions supportedDropActions() const;
QStringList mimeTypes() const;
Refactoring of catalogue display using a QTreeView and a custom model based on QTreeWidgetItem
r1228 private:
class CatalogueTreeModelPrivate;
spimpl::unique_impl_ptr<CatalogueTreeModelPrivate> impl;
};
#endif // CATALOGUETREEMODEL_H