Debian Codegraph @

plugins/symbolbrowser/symbols/symboltreeview.h

raw symbols SCIP
1 /***************************************************************************
2 A SymbolBrowser plugin for JuffEd editor.
3
4 Copyright: 2010 Aleksander Sokoloff <[email protected]>
5
6
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License.
9 version 2 as published by the Free Software Foundation.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software Foundation,
18 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 ***************************************************************************/
20
21
22 #ifndef SYMBOLTREEVIEW_H
23 #define SYMBOLTREEVIEW_H
24
25 #include <QWidget>
26 #include <QHash>
27 #include <QTreeWidget>
28 #include <QTimer>
29 #include <QStringList>
30 #include "symbols/common.h"
31 #include "symbols/docsymbols.h"
32
33
34 class QAction;
35
36 class SymbolTreeView : public QTreeWidget
37 {
38 Q_OBJECT
39 public:
40 explicit SymbolTreeView(QWidget *parent = 0);
41 virtual ~SymbolTreeView();
42
43 bool settingsDetail() const { return mSettingsDetail; };
44 void setSettingsDetail(bool value) { mSettingsDetail = value; };
45
46 bool settingsSort() const { return mSettingsSort; };
47 void setSettingsSort(bool value) { mSettingsSort = value; };
48
49 bool settingsExpand() const { return mSettingsExpand; };
50 void setSettingsExpand(bool value) { mSettingsExpand = value; };
51
52 bool settingsActivateOnSingleClick() const { return mSettingsActivateOnSingleClick; };
53 void setSettingsActivateOnSingleClick(bool value) { mSettingsActivateOnSingleClick = value; };
54
55 public slots:
56 void docActivated(const QString &docName);
57 void docClosed(const QString &docName);
58 void docRenamed(const QString &oldDocName, const QString newDocName);
59
60 void refresh();
61
62 void setDetailed(bool sorted);
63 void setSorted(bool sorted);
64
65 protected:
66 void contextMenuEvent(QContextMenuEvent *event);
67 //void timerEvent(QTimerEvent * event );
68
69 virtual Language docLanguage(const QString &docName) = 0;
70 virtual void docText(const QString &docName, QString &text) = 0;
71
72 private:
73 QHash<QString, DocSymbols *> mDocuments;
74 DocSymbols * mSymbols;
75
76 QAction *mActDetailed;
77 QAction *mActSorted;
78
79 int mTimerId;
80 QTimer mRefreshTimer;
81
82 bool mSettingsDetail;
83 bool mSettingsSort;
84 bool mSettingsExpand;
85 bool mSettingsActivateOnSingleClick;
86
87 void rebuildChildren(const Symbol *parentSymbol, QTreeWidgetItem *parentTreeItem);
88 void setTreeItem(const Symbol *symbol, QTreeWidgetItem *treeItem);
89 Symbol *symbolByItem(QTreeWidgetItem *item);
90 QAction *createRelationAction(const Symbol *symbol, QObject *parent);
91
92 void getItemPath(const QTreeWidgetItem *item, QStringList &result) const;
93 QTreeWidgetItem *itemByPath(const QStringList &path) const;
94
95 signals:
96 void skipToLine(int lineNum);
97
98 private slots:
99 void doRefresh();
100 void onSymbolsChanged();
101
102 void onItemExpanded(QTreeWidgetItem *item);
103 void onItemCollapsed(QTreeWidgetItem * item);
104 void onItemClicked(QTreeWidgetItem * item, int column );
105 void onItemActivated(QTreeWidgetItem * item, int column );
106 void relatedMenuTriggered();
107
108 };
109
110 #endif // SYMBOLTREEVIEW_H