QGIS API Documentation  2.8.2-Wien
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgsbrowsertreeview.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsbrowsertreeview.h
3  --------------------------------------
4  Date : January 2015
5  Copyright : (C) 2015 by Radim Blazek
6  Email : [email protected]
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSBROWSERTREEVIEW_H
17 #define QGSBROWSERTREEVIEW_H
18 
19 #include <QTreeView>
20 
21 //class QgsBrowserModel;
22 
29 class GUI_EXPORT QgsBrowserTreeView : public QTreeView
30 {
31  Q_OBJECT
32  public:
33  QgsBrowserTreeView( QWidget *parent = 0 );
35 
36  virtual void setModel( QAbstractItemModel* model ) override;
37  virtual void showEvent( QShowEvent * e ) override;
38  virtual void hideEvent( QHideEvent * e ) override;
39 
40  // returns true if at least one descendat is expanded, used in refresh
41  bool hasExpandedDescendant( const QModelIndex& index ) const;
42 
43  // Set section where to store settings (because we have 2 browser dick widgets
44  void setSettingsSection( const QString & section ) { mSettingsSection = section; }
45 
46  protected slots:
47  virtual void rowsInserted( const QModelIndex & parentIndex, int start, int end ) override;
48 
49  private:
50  QString mSettingsSection;
51  // initial expanded paths
52  QStringList mExpandPaths;
53  void saveState();
54  void restoreState();
55 
56  QString expandedPathsKey() const;
57 
58  // Get list of expanded items paths recursively
59  QStringList expandedPathsList( const QModelIndex & index );
60 
61  // Expand path recursively to root
62  void expandTree( const QModelIndex & index );
63 
64  // returns true if expanded from root to item
65  bool treeExpanded( const QModelIndex & index );
66 };
67 
68 #endif // QGSBROWSERTREEVIEW_H