File indexing completed on 2024-04-14 03:43:56
0001 /* 0002 SPDX-FileCopyrightText: 2003-2008 Cies Breijs <cies AT kde DOT nl> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef _INSPECTOR_H_ 0008 #define _INSPECTOR_H_ 0009 0010 #include <QWidget> 0011 #include <QHash> 0012 0013 #include "editor.h" 0014 #include "highlighter.h" 0015 #include "interpreter/value.h" 0016 #include "interpreter/treenode.h" 0017 0018 class QHBoxLayout; 0019 class QTableWidget; 0020 class QTableWidgetItem; 0021 class QTabWidget; 0022 class QTreeWidget; 0023 class QTreeWidgetItem; 0024 0025 0026 class Inspector : public QWidget 0027 { 0028 Q_OBJECT 0029 0030 public: 0031 explicit Inspector(QWidget *parent = nullptr); 0032 ~Inspector() override; 0033 0034 void clear(); 0035 0036 0037 public Q_SLOTS: 0038 void updateVariable(const QString& name, const Value& value); 0039 void updateFunction(const QString& name, const QStringList& parameters); 0040 void updateTree(TreeNode* rootNode); 0041 0042 void markVariable(const QString&); 0043 void markFunction(const QString&); 0044 void markTreeNode(TreeNode*); 0045 0046 void clearAllMarks(); 0047 0048 void disable(); 0049 0050 0051 private: 0052 int findVariable(const QString& name); 0053 QTreeWidgetItem* walkTree(TreeNode* node); 0054 0055 void clearTreeMark(); 0056 0057 Highlighter *highlighter; 0058 0059 // map the names of the variables/functions to their respective items in the tabelwidget 0060 QHash<QString, QTableWidgetItem*> variableMap; 0061 QHash<QString, QTableWidgetItem*> functionMap; 0062 // map the treenodes to their respective items in the treewidget 0063 QHash<TreeNode*, QTreeWidgetItem*> treeMap; 0064 0065 QHBoxLayout *mainLayout; 0066 QTabWidget *tabWidget; 0067 0068 QWidget *variableTab; 0069 QHBoxLayout *variableLayout; 0070 QTableWidget *variableTable; 0071 0072 QWidget *functionTab; 0073 QHBoxLayout *functionLayout; 0074 QTableWidget *functionTable; 0075 0076 QWidget *treeTab; 0077 QHBoxLayout *treeLayout; 0078 QTreeWidget *treeView; 0079 0080 QBrush previousTreeBackground; 0081 QTreeWidgetItem *currentlyMarkedTreeItem; 0082 0083 bool variableTableEmpty; 0084 bool functionTableEmpty; 0085 }; 0086 0087 0088 #endif // _INSPECTOR_H_