111 lines
4.6 KiB
C++
111 lines
4.6 KiB
C++
#ifndef STRUCTDATAPREVIEWDLG_H
|
|
#define STRUCTDATAPREVIEWDLG_H
|
|
/**
|
|
* *******结构化数据展示界面*******
|
|
**/
|
|
|
|
#include <QDialog>
|
|
#include "dataManager.h"
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
namespace Ui { class structDataPreviewDlg; }
|
|
QT_END_NAMESPACE
|
|
|
|
class QStandardItemModel;
|
|
class TitleBar;
|
|
class ExtraPropertyManager;
|
|
struct ExtraProperty;
|
|
class QStandardItem;
|
|
class QTreeView;
|
|
class QAbstractItemModel;
|
|
class StructDataSource;
|
|
class StructDataMeasurementModel;
|
|
class StructDataPropertyModel;
|
|
class StructDataPropertyDelegate;
|
|
class StructDataMeasurementDelegate;
|
|
class QStatusBar;
|
|
class QCompleter;
|
|
class QStringListModel;
|
|
|
|
class StructDataPreviewDlg : public QDialog
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
StructDataPreviewDlg(QWidget *parent = nullptr);
|
|
~StructDataPreviewDlg();
|
|
|
|
void initial();
|
|
void loadData();
|
|
|
|
void showMaximized();
|
|
void showNormal();
|
|
void setExtraPropertyManager(ExtraPropertyManager* p) {_pExtraProManager = p;}
|
|
void showDlg();
|
|
QVector<ExtraProperty> getGroupProperties(QStandardItem* groupItem); //获取属性组的所有属性
|
|
QString getGroupSourceType(QStandardItem* groupItem);
|
|
void addItemToView(const ExtraProperty& property,
|
|
const QString& displayMode, // "name" 或 "tag"
|
|
QStandardItem* root,
|
|
QStandardItem* pItem);
|
|
void updateRecommandLst(QStringList); //更新当前推荐列表
|
|
|
|
void addLog(const QString &message);
|
|
public slots:
|
|
void onExitClicked();
|
|
void onSaveClicked();
|
|
|
|
void onLevelButtonClicked(int nLevel);
|
|
void onTreeSelectionChanged(const QModelIndex& current, const QModelIndex& previous);
|
|
void onPropertyModified(int row, const ExtraProperty& prop);
|
|
protected:
|
|
void showEvent(QShowEvent *event) override;
|
|
void resizeEvent(QResizeEvent *event) override;
|
|
private slots:
|
|
void toggleMaximize();
|
|
private:
|
|
void clearItems();
|
|
QString getLevelType(int index);
|
|
void expandToLevel(QTreeView* treeView, int targetLevel); // 展开到指定层级
|
|
void expandToLevelRecursive(QTreeView* treeView,
|
|
QAbstractItemModel* model,
|
|
const QModelIndex& parent,
|
|
int currentDepth,
|
|
int targetLevel);
|
|
int getNodeLevel(QAbstractItemModel* model, const QModelIndex& index); // 获取节点的层级(从存储的数据中读取)
|
|
int getDepthFromRoot(QAbstractItemModel* model, const QModelIndex& index); // 获取节点从根开始的深度
|
|
QStandardItem* processGroupLevel(QStandardItem* componentItem,const ExtraProperty& property); // 处理group层级
|
|
void processCategoryLevel(QStandardItem* groupItem,const ExtraProperty& property); // 处理category层级
|
|
void updateCategoryProperties(QStandardItem* categoryItem,const ExtraProperty& property); // 更新category节点的属性列表
|
|
void loadCategoryProperties(QStandardItem* categoryItem);
|
|
QVector<ExtraProperty> getCategoryPropertiesFromDataManager(const QVariantMap& categoryData);
|
|
void setupPropertyTable(const QVector<ExtraProperty>& properties,const QString& categoryName,const QString& groupName); //设置参量的model
|
|
void setupMeasurementTable(const QVector<ExtraProperty>& properties,const QString& categoryName,const QString& groupName); //设置量测的model
|
|
void updateCategoryAfterPropertyModified(QStandardItem* categoryItem, const ExtraProperty& updatedProp); //回调更新节点
|
|
void saveCurrentIfModified();
|
|
void saveAll();
|
|
void clearTableView();
|
|
void setupPropertyColumns();
|
|
void setupMeasurementColumns();
|
|
void updateTableTitle(const QString& dataType, const QString& categoryName,const QString& groupName, int count);
|
|
private:
|
|
Ui::structDataPreviewDlg *ui;
|
|
QStandardItemModel* _treeModel;
|
|
TitleBar* m_titleBar;
|
|
QRect m_normalGeometry; // 记录正常状态的位置和大小
|
|
ExtraPropertyManager* _pExtraProManager; //使用外部的manager
|
|
StructDataSource* m_dataSource;
|
|
bool m_currentModified = false;
|
|
QStandardItem* m_currentCategoryItem; //当前操作对象
|
|
StructDataMeasurementModel* m_measurementTableModel;
|
|
StructDataPropertyModel* m_propertyTableModel;
|
|
StructDataPropertyDelegate* m_propertyDelegate;
|
|
StructDataMeasurementDelegate* m_measurementDelegate;
|
|
QStatusBar* m_statusBar;
|
|
|
|
QStringList _curRecommandLst; //当前推荐列表
|
|
QCompleter* _recommandCompleter; //自动填充器
|
|
QStringListModel* _strLstModel; //自动填充模型
|
|
};
|
|
|
|
#endif
|