1 /************************************************************************** 2 ** This file is part of LiteIDE 3 ** 4 ** Copyright (c) 2011-2019 LiteIDE. All rights reserved. 5 ** 6 ** This library is free software; you can redistribute it and/or 7 ** modify it under the terms of the GNU Lesser General Public 8 ** License as published by the Free Software Foundation; either 9 ** version 2.1 of the License, or (at your option) any later version. 10 ** 11 ** This library 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 GNU 14 ** Lesser General Public License for more details. 15 ** 16 ** In addition, as a special exception, that plugins developed for LiteIDE, 17 ** are allowed to remain closed sourced and can be distributed under any license . 18 ** These rights are included in the file LGPL_EXCEPTION.txt in this package. 19 ** 20 **************************************************************************/ 21 // Module: symboltreeview.h 22 // Creator: visualfc <visualfc@gmail.com> 23 24 #ifndef SYMBOLTREEVIEW_H 25 #define SYMBOLTREEVIEW_H 26 27 #include <QTreeView> 28 29 struct SymbolTreeState 30 { SymbolTreeStateSymbolTreeState31 SymbolTreeState() : vbar(-1),hbar(-1) 32 { 33 } 34 QList<QStringList> expands; 35 QStringList cur; 36 int vbar; 37 int hbar; 38 }; 39 40 class SymbolTreeView : public QTreeView 41 { 42 Q_OBJECT 43 public: 44 SymbolTreeView(QWidget *parent = 0); 45 SymbolTreeView(bool bResizeToContents, QWidget *parent = 0); 46 protected: 47 void init(bool bResizeToContents); 48 public: 49 QModelIndex topViewIndex(); 50 QList<QModelIndex> expandIndexs() const; 51 virtual void reset(); 52 void saveState(SymbolTreeState *state); 53 void loadState(QAbstractItemModel *model,SymbolTreeState *state); 54 signals: 55 void currentIndexChanged(const QModelIndex ¤t, const QModelIndex &previous); 56 void enterKeyPressed(QModelIndex); 57 protected: 58 void focusInEvent(QFocusEvent *event); 59 void focusOutEvent(QFocusEvent *event); 60 void keyPressEvent(QKeyEvent *event); 61 void currentChanged(const QModelIndex ¤t, const QModelIndex &previous); 62 void getTreeExpands(const QModelIndex &parent, QList<QModelIndex> &list) const; 63 protected slots: 64 void clickedItem(QModelIndex); 65 void hsbValueChanged(int); 66 protected: 67 bool m_bClickedItem; 68 int m_hsbPos; 69 }; 70 71 #endif //SYMBOLTREEVIEW_H 72