QtHPConnect/treemodel.h

46 lines
1.2 KiB
C
Raw Normal View History

2019-02-10 14:32:15 +01:00
#ifndef TREEMODEL_H
#define TREEMODEL_H
2019-02-10 14:43:00 +01:00
#include <QStandardItemModel>
2019-02-10 14:32:15 +01:00
#include <QObject>
2019-02-10 14:43:00 +01:00
#include <QMap>
2019-02-10 14:32:15 +01:00
2019-02-10 14:43:00 +01:00
#include "hpdata.h"
class hpTreeItem;
struct hpDataLink {
hpTreeItem * treeItem;
hpCalcData * dataItem;
};
class treeModel: public QStandardItemModel
2019-02-10 14:32:15 +01:00
{
2019-02-10 14:43:00 +01:00
Q_OBJECT
private:
int createRoot();
2019-09-15 17:23:44 +02:00
QStandardItem *rootNode=nullptr;
2019-02-10 14:43:00 +01:00
QMap<QString,hpDataLink> hpCalcList;
2019-09-15 17:23:44 +02:00
hpCalcData * hpdata=nullptr;
2019-02-10 14:43:00 +01:00
2019-02-10 14:32:15 +01:00
public:
2019-02-10 14:43:00 +01:00
treeModel(QObject *parent);
2019-09-15 17:23:44 +02:00
virtual ~treeModel() override;
2019-02-10 14:43:00 +01:00
int addCalculator(QString name, hpusb * handle);
hpCalcData * getCalculator(QString name);
hpCalcData * getHpCalcData(QString name);
void setHpCalcData(QString name, hpCalcData * , hpTreeItem *);
QString getLastDataKey();
2019-09-15 17:23:44 +02:00
bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override;
Qt::DropActions supportedDropActions() const override;
QMimeData* mimeData(const QModelIndexList &) const override;
Qt::ItemFlags flags(const QModelIndex&) const override;
2019-02-10 14:43:00 +01:00
2019-02-10 14:32:15 +01:00
};
2019-02-10 14:43:00 +01:00
#endif // TREEMODEL_H