@@ -51,13 +51,32 @@ class CORE_EXPORT QgsBrowserWatcher : public QFutureWatcher<QVector <QgsDataItem
51
51
/* *
52
52
* \ingroup core
53
53
* \class QgsBrowserModel
54
+ *
55
+ * A model for showing available data sources and other items in a structured
56
+ * tree.
57
+ *
58
+ * QgsBrowserModel is the foundation for the QGIS browser panel, and includes
59
+ * items for the different data providers and folders accessible to users.
60
+ *
61
+ * QgsBrowserModel models are not initially populated and use a deferred initialization
62
+ * approach. After constructing a QgsBrowserModel, a call must be made
63
+ * to initialize() in order to populate the model.
54
64
*/
55
65
class CORE_EXPORT QgsBrowserModel : public QAbstractItemModel
56
66
{
57
67
Q_OBJECT
58
68
59
69
public:
70
+
71
+ /* *
72
+ * Constructor for QgsBrowserModel, with the specified \a parent object.
73
+ *
74
+ * \note QgsBrowserModel models are not initially populated and use a deferred initialization
75
+ * approach. After constructing a QgsBrowserModel, a call must be made
76
+ * to initialize() in order to populate the model.
77
+ */
60
78
explicit QgsBrowserModel ( QObject *parent = nullptr );
79
+
61
80
~QgsBrowserModel () override ;
62
81
63
82
enum ItemDataRole
@@ -68,54 +87,23 @@ class CORE_EXPORT QgsBrowserModel : public QAbstractItemModel
68
87
};
69
88
// implemented methods from QAbstractItemModel for read-only access
70
89
71
- /* *
72
- * Used by other components to obtain information about each item provided by the model.
73
- In many models, the combination of flags should include Qt::ItemIsEnabled and Qt::ItemIsSelectable. */
74
90
Qt::ItemFlags flags ( const QModelIndex &index ) const override ;
75
-
76
- /* *
77
- * Used to supply item data to views and delegates. Generally, models only need to supply data
78
- for Qt::DisplayRole and any application-specific user roles, but it is also good practice
79
- to provide data for Qt::ToolTipRole, Qt::AccessibleTextRole, and Qt::AccessibleDescriptionRole.
80
- See the Qt::ItemDataRole enum documentation for information about the types associated with each role. */
81
91
QVariant data ( const QModelIndex &index, int role = Qt::DisplayRole ) const override ;
82
-
83
- /* *
84
- * Provides views with information to show in their headers. The information is only retrieved
85
- by views that can display header information. */
86
92
QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override ;
87
-
88
- // ! Provides the number of rows of data exposed by the model.
89
93
int rowCount ( const QModelIndex &parent = QModelIndex() ) const override ;
90
-
91
- /* *
92
- * Provides the number of columns of data exposed by the model. List models do not provide this function
93
- because it is already implemented in QAbstractListModel. */
94
94
int columnCount ( const QModelIndex &parent = QModelIndex() ) const override ;
95
-
96
- // ! Returns the index of the item in the model specified by the given row, column and parent index.
97
95
QModelIndex index ( int row, int column, const QModelIndex &parent = QModelIndex() ) const override ;
98
-
99
- QModelIndex findItem ( QgsDataItem *item, QgsDataItem *parent = nullptr ) const ;
100
-
101
- /* *
102
- * Returns the parent of the model item with the given index.
103
- * If the item has no parent, an invalid QModelIndex is returned.
104
- */
105
96
QModelIndex parent ( const QModelIndex &index ) const override ;
106
-
107
- // ! Returns a list of mime that can describe model indexes
108
97
QStringList mimeTypes () const override ;
109
-
110
- // ! Returns an object that contains serialized items of data corresponding to the list of indexes specified
111
98
QMimeData *mimeData ( const QModelIndexList &indexes ) const override ;
112
-
113
- // ! Handles the data supplied by a drag and drop operation that ended with the given action
114
99
bool dropMimeData ( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent ) override ;
100
+ bool hasChildren ( const QModelIndex &parent = QModelIndex() ) const override ;
101
+ bool canFetchMore ( const QModelIndex &parent ) const override ;
102
+ void fetchMore ( const QModelIndex &parent ) override ;
115
103
116
- QgsDataItem *dataItem ( const QModelIndex &idx ) const ;
104
+ QModelIndex findItem ( QgsDataItem *item, QgsDataItem *parent = nullptr ) const ;
117
105
118
- bool hasChildren ( const QModelIndex &parent = QModelIndex() ) const override ;
106
+ QgsDataItem * dataItem ( const QModelIndex &idx ) const ;
119
107
120
108
// ! Refresh item specified by path
121
109
void refresh ( const QString &path );
@@ -137,11 +125,12 @@ class CORE_EXPORT QgsBrowserModel : public QAbstractItemModel
137
125
138
126
void connectItem ( QgsDataItem *item );
139
127
140
- bool canFetchMore ( const QModelIndex &parent ) const override ;
141
- void fetchMore ( const QModelIndex &parent ) override ;
142
-
143
- // ! Returns true if the model has been initialized
144
- bool initialized ( ) const { return mInitialized ; }
128
+ /* *
129
+ * Returns true if the model has been initialized.
130
+ *
131
+ * \see initialize()
132
+ */
133
+ bool initialized () const { return mInitialized ; }
145
134
146
135
signals:
147
136
// ! Emitted when item children fetch was finished
@@ -186,7 +175,10 @@ class CORE_EXPORT QgsBrowserModel : public QAbstractItemModel
186
175
// ! Hide the given path in the browser model
187
176
void hidePath ( QgsDataItem *item );
188
177
189
- // ! Delayed initialization, needed because the provider registry must be already populated
178
+ /* *
179
+ * Delayed initialization, needed because the provider registry must be already populated.
180
+ * \see initialized()
181
+ */
190
182
void initialize ();
191
183
192
184
protected:
0 commit comments