56 lines
2.1 KiB
C++
56 lines
2.1 KiB
C++
#ifndef DBSTRUCTUREMODEL_H
|
|
#define DBSTRUCTUREMODEL_H
|
|
|
|
#include <QAbstractItemModel>
|
|
#include <QTreeWidgetItem>
|
|
#include "dbStructureNode.h"
|
|
#include "global.h"
|
|
|
|
class MainWindow;
|
|
class DBStructureModel : public QAbstractItemModel
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit DBStructureModel(QObject* parent = nullptr);
|
|
~DBStructureModel();
|
|
|
|
void setMainWindow(MainWindow*);
|
|
|
|
//QAbstractItemModel接口实现
|
|
QModelIndex index(int row, int column, const QModelIndex& parent) const override;
|
|
QModelIndex parent(const QModelIndex& index) const override;
|
|
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
|
|
int columnCount(const QModelIndex& parent = QModelIndex()) const override;
|
|
QVariant data(const QModelIndex& index, int role) const override;
|
|
bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
|
|
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
|
|
|
//业务功能接口
|
|
void addConnection(const QString& name, const QString& connID);
|
|
void removeConnection(const QString& name);
|
|
QModelIndex getConnNodeIndex(const QString& name);
|
|
void addDataModel(const QString& connection, Model& model);
|
|
void removeDataModel(DBStructureNode*);
|
|
void updateDataModelName(const QString& connection, int modelID, const QString& name);
|
|
void addDataGroup(const QString& connection, int modelID, QVector<int> groups);
|
|
void removeDataGroup(DBStructureNode*);
|
|
|
|
signals:
|
|
void errorOccurred(const QString& strConnectionName);
|
|
|
|
public slots:
|
|
void refreshStructure_Connection(const QString& connection); //刷新某个链接的数据(比如刷新、关闭或者手动刷新时)
|
|
void refreshStructure_Model(const QString& connection, int modelID);
|
|
|
|
private:
|
|
DBStructureNode* getNode(const QModelIndex& index) const;
|
|
DBStructureNode* getConnectionNode(const QString& name) const;
|
|
DBStructureNode* getModelNode(DBStructureNode* connNode, int modelID) const;
|
|
|
|
MainWindow* m_pMainWindow;
|
|
DBStructureNode* m_rootNode;
|
|
};
|
|
|
|
#endif //DBSTRUCTUREMODEL_H
|