QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
gui
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 : radim.blazek@gmail.com
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 "qgis_gui.h"
20
#include "
qgis_sip.h
"
21
22
#include <QTreeView>
23
24
#ifdef SIP_RUN
25
// this is needed for the "convert to subclass" code below to compile
26
//%ModuleHeaderCode
27
#include "
qgsbrowsertreeview.h
"
28
//%End
29
#endif
30
31
class
QgsBrowserGuiModel
;
32
class
QgsDataItem
;
33
40
class
GUI_EXPORT
QgsBrowserTreeView
:
public
QTreeView
41
{
42
#ifdef SIP_RUN
43
SIP_CONVERT_TO_SUBCLASS_CODE
44
if
( qobject_cast<QgsBrowserTreeView *>( sipCpp ) !=
nullptr
)
45
sipType = sipType_QgsBrowserTreeView;
46
else
47
sipType =
nullptr
;
48
SIP_END
49
#endif
50
51
Q_OBJECT
52
public
:
54
QgsBrowserTreeView
( QWidget *parent
SIP_TRANSFERTHIS
=
nullptr
);
55
56
void
setModel
( QAbstractItemModel *model )
override
;
58
void
setBrowserModel
(
QgsBrowserGuiModel
*model );
60
QgsBrowserGuiModel
*
browserModel
() {
return
mBrowserModel; }
61
void
showEvent( QShowEvent *e )
override
;
62
void
hideEvent( QHideEvent *e )
override
;
63
64
// returns true if at least one descendat is expanded, used in refresh
65
bool
hasExpandedDescendant(
const
QModelIndex &index )
const
;
66
67
// Set section where to store settings (because we have 2 browser dock widgets)
68
void
setSettingsSection
(
const
QString §ion ) { mSettingsSection = section; }
69
77
bool
setSelectedItem(
QgsDataItem
*item );
78
88
void
expandPath(
const
QString &path,
bool
selectPath =
false
);
89
90
protected
:
91
void
keyPressEvent( QKeyEvent *event )
override
;
92
93
protected
slots:
94
void
rowsInserted(
const
QModelIndex &parentIndex,
int
start,
int
end )
override
;
95
96
private
:
97
QString mSettingsSection;
98
// initial expanded paths
99
QStringList mExpandPaths;
100
void
saveState();
101
void
restoreState();
102
103
QString expandedPathsKey()
const
;
104
105
// Get list of expanded items paths recursively
106
QStringList expandedPathsList(
const
QModelIndex &index );
107
108
// Expand path recursively to root
109
void
expandTree(
const
QModelIndex &index );
110
111
// returns true if expanded from root to item
112
bool
treeExpanded(
const
QModelIndex &index );
113
QgsBrowserGuiModel
*mBrowserModel =
nullptr
;
114
};
115
116
#endif
// QGSBROWSERTREEVIEW_H
QgsBrowserGuiModel
A model for showing available data sources and other items in a structured tree.
Definition
qgsbrowserguimodel.h:38
QgsBrowserTreeView::QgsBrowserTreeView
QgsBrowserTreeView(QWidget *parent=nullptr)
Constructor for QgsBrowserTreeView.
Definition
qgsbrowsertreeview.cpp:38
QgsBrowserTreeView::setBrowserModel
void setBrowserModel(QgsBrowserGuiModel *model)
Sets the browser model.
Definition
qgsbrowsertreeview.cpp:61
QgsBrowserTreeView::setModel
void setModel(QAbstractItemModel *model) override
Definition
qgsbrowsertreeview.cpp:54
QgsBrowserTreeView::setSettingsSection
void setSettingsSection(const QString §ion)
Definition
qgsbrowsertreeview.h:68
QgsBrowserTreeView::browserModel
QgsBrowserGuiModel * browserModel()
Returns the browser model.
Definition
qgsbrowsertreeview.h:60
QgsDataItem
Base class for all items in the model.
Definition
qgsdataitem.h:50
qgis_sip.h
SIP_CONVERT_TO_SUBCLASS_CODE
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition
qgis_sip.h:203
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition
qgis_sip.h:52
SIP_END
#define SIP_END
Definition
qgis_sip.h:220
qgsbrowsertreeview.h
Generated on
for QGIS API Documentation by
1.17.0