| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 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 |
|
| 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 |