123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583 |
- #ifndef DBTREEVIEWMANAGER_H
- #define DBTREEVIEWMANAGER_H
- #define NOMINMAX
- #include <QWidget>
- #include <QTreeView>
- #include <QJsonObject>
- #include <QStandardItemModel>
- #include <QCheckBox>
- #include <QJsonArray>
- #include <QFile>
- #include <QLineEdit>
- #include <QComboBox>
- #include <QRadioButton>
- #include <QButtonGroup>
- #include <QStyleFactory>
- #include <QEvent>
- #include <QStringList>
- #include <QSettings>
- #include <QSet>
- #include <QVariant>
- #include <QMenu>
- #include <QAction>
- #include <QTimeEdit>
- #include <QCursor>
- #include <QScrollArea>
- #include <QToolButton>
- #include <QtSql>
- #include <QSqlDatabase>
- #include <QSqlQuery>
- #include <QSqlError>
- #include <QMessageBox>
- #include <QPainter>
- #include <QTimer>
- #include <QFileInfo>
- #include <QLabel>
- #include <QHBoxLayout>
- #include <QPushButton>
- #include <QVBoxLayout>
- #include <QStandardItem>
- #include <QMap>
- #include <QJsonDocument>
- #include <array>
- #include "CViewInterface.h"
- #include "Src/Sql/SqlOperation.h"
- #include "gen_interface.h"
- struct ST_COMBINED_CONT
- {
- QString strConfigurationsName;
- QString strfieldName;
- QString strfieldDescribe;
- QLineEdit* pLineC;
- QPushButton* pGetBut;
- QPushButton* pSetBut;
- };
- struct ST_INPUT_CONT
- {
- QString strConfigurationsName;
- QString strfieldName;
- QString strfieldDescribe;
- QLineEdit* plineEdit;
- };
- struct ST_RADIO_CONT
- {
- QString strConfigurationsName;
- QString strfieldName;
- QString strfieldDescribe;
- QButtonGroup* pradioGroup;
- };
- struct ST_CHECKBOX_CONT
- {
- QString strConfigurationsName;
- QString strfieldName;
- QString strfieldDescribe;
- QCheckBox* pcheckBox;
- };
- struct ST_COMBOBOX_CONT
- {
- QString strConfigurationsName;
- QString strfieldName;
- QString strfieldDescribe;
- QComboBox* pcomboBox;
- };
- struct ST_TIME_CONT
- {
- QString strConfigurationsName;
- QString strfieldName;
- QString strfieldDescribe;
- QTimeEdit* ptimeEdit;
- };
- struct ST_SWITCH_CONT
- {
- QString strConfigurationsName;
- QString strfieldName;
- QString strfieldDescribe;
- QCheckBox* pswitchBox;
- };
- class OriginalWnd;
- class DbTreeViewManager : public QWidget
- {
- Q_OBJECT
- public:
-
- explicit DbTreeViewManager(QWidget* pOriginalWndMenuPage, QWidget* parent = nullptr);
- ~DbTreeViewManager();
-
- void Init();
-
- void initializeTree(QString name, const int &userPrivilege);
-
- void clearAllSeparators();
-
- QList<QStandardItem*> collectAllThirdLevelItems();
-
- void saveExpandedPaths();
-
- void loadExpandedPaths();
-
- void writeLogToFile(const QString& logMessage, const QString& filePath);
- void loginput(const QString& fieldTableName,const QString& fieldName,const QString& modifies);
-
- QSet<QString> expandedPaths;
- public:
- struct menuInfo {
- int menuId;
- bool isthird;
- int index;
- };
- int currentMenuId;
- std::array<menuInfo, 5> menuArray;
- void loadpage(const int& configId);
- QList<QStandardItem*> thirdLevelListtest;
- QStandardItem* deepCopyItem(const QStandardItem* item);
- void promptSaveChanges();
- signals:
- void RunFunSignals(ns_module::ST_BUTTON_FUN pra);
- void saveClicked();
- private slots:
-
- void onTreeViewClicked(const QModelIndex &index);
-
- void onTreeViewClicked_updown(const QModelIndex &index);
-
- void onButtonBackClicked();
-
- void onButtonUpClicked();
-
- void onButtonDownClicked();
-
- void onButtonLeftClicked();
-
- void onButtonRightClicked();
-
- void onItemChanged(QStandardItem *item);
- private:
-
- void Level3MenuAllSaveBut(QVBoxLayout* pVBox);
- private:
-
- OriginalWnd* m_originalWnd = nullptr;
-
- QWidget * m_pOriginalWndMenuPage = nullptr;
-
- QPointer<QTreeView> m_pTreeViewDown;
-
- QPointer<QWidget> m_pNavigationWidget;
-
- QPointer<QStandardItemModel> m_pCModel = nullptr;
-
- QWidget* m_thirdLevelFieldWnd = nullptr;
-
- QPushButton *ButtonBack = nullptr;
- QPushButton *buttonUp = nullptr;
- QPushButton *buttonDown = nullptr;
- QPushButton *buttonLeft = nullptr;
- QPushButton *buttonRight = nullptr;
-
- struct PageState {
- QStringList path;
- bool isThirdLevel;
- int directoryId;
- QString multiTableName = "";
- };
-
- QList<PageState> m_backStack;
- QList<PageState> m_forwardStack;
-
- bool m_isRestoring = false;
-
- QMap<QStandardItem*, QFrame*> m_mapFirstLevelSeparators;
-
- bool m_blockItemChanged = false;
-
- QList<QWidget*> m_fieldWidgets;
-
- QString m_currentConfigName = "";
-
-
- QPointer<QFrame> m_pLineFrame1;
-
- SqlOperation* m_sqlOper = nullptr;
-
-
- std::vector<ST_COMBINED_CONT> m_veCombinedCont;
- std::vector<ST_INPUT_CONT> m_veInputCont;
- std::vector<ST_RADIO_CONT> m_veRadioCont;
- std::vector<ST_CHECKBOX_CONT> m_veCheckBoxCont;
- std::vector<ST_COMBOBOX_CONT> m_veComboBoxCont;
- std::vector<ST_TIME_CONT> m_veTimeCont;
- std::vector<ST_SWITCH_CONT> m_veSwitchCont;
- ns_module::CViewInterface* m_pTreeCViewInterface;
-
- QString m_str2DirModuleType;
- QSet<QLabel*> modifiedLabels;
-
- const QString m_strShowName = "DisplayName";
- Gen_Interface gen_if;
- int languageValue;
- private:
-
- void clearHistory();
-
- PageState getCurrentPageState();
-
- void loadPageState(const PageState &st, bool isByHistoryNav = false);
-
-
- void loadDirectories(int configId, const int &userPrivilege);
-
- QStandardItem* findFirstThirdLevelItemDFS(QStandardItem *parentItem);
-
- void updateParentItems(QStandardItem *parentItem);
-
- void buildTreeFromDirectories(const QList<QJsonObject> &directories);
-
- void updateParentCheckState(QStandardItem *item);
-
- void updateButtonsVisibility();
-
- void clearThirdLevelMenu();
-
-
-
-
- bool eventFilter(QObject *watched, QEvent *event) override;
-
- void paintAllBranches(const QModelIndex &parentIndex, QPainter &painter);
-
- void drawParentChildLine(const QModelIndex &childIndex, QPainter &painter);
-
- void drawSiblingLine(const QModelIndex &childIndex, QPainter &painter);
-
- void applyCustomStyles();
-
- void setupButton();
-
- QFrame* createUnifiedSeparator(QWidget *parent, int height);
-
- void updateSeparatorLine();
-
- QModelIndex findLastVisibleChild(const QModelIndex &parentIndex);
-
- void updateNavigationBar(const QModelIndex &index);
-
-
-
- void displayThirdLevelButtons(const QList<CONFIG_BASE_STRUCT>& buttons);
-
- void displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DATA>& data, bool allChangeFalg, bool isHome);
-
- void saveCheckedPaths();
-
- void loadCheckedPaths();
-
- QStringList collectCheckedPaths();
-
- QStringList collectCheckedPathsRecursive(QStandardItem *item, QStringList path);
-
- void setCheckedPaths(const QStringList &checkedPathsList);
-
- QStringList buildItemPath(QStandardItem *item);
-
- QModelIndex findItemByPath(const QStringList &path);
-
- bool hasPrivilege(const int &UserGrade, const int &userPrivilege);
-
-
-
-
- };
- #endif
|