QGIS API Documentation  3.20.0-Odense (decaadbb31)
qgsbookmarkmodel.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsbookmarkmodel.h
3  ------------------
4  Date : Septemeber 2019
5  Copyright : (C) 2019 Nyall Dawson
6  Email : nyall dot dawson at gmail dot 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 QGSBOOKMARKMODEL_H
17 #define QGSBOOKMARKMODEL_H
18 
19 #include "qgis_core.h"
20 #include "qgis_sip.h"
21 #include <QAbstractTableModel>
22 #include <QSortFilterProxyModel>
23 
24 class QgsBookmarkManager;
25 class QgsBookmark;
26 
41 class CORE_EXPORT QgsBookmarkManagerModel: public QAbstractTableModel
42 {
43  Q_OBJECT
44 
45  public:
46 
49  {
50  RoleExtent = Qt::UserRole,
54  };
55 
57  enum Columns
58  {
67  };
68 
74  QgsBookmarkManagerModel( QgsBookmarkManager *manager, QgsBookmarkManager *projectManager = nullptr, QObject *parent SIP_TRANSFERTHIS = nullptr );
75 
76  int rowCount( const QModelIndex &parent = QModelIndex() ) const override;
77  int columnCount( const QModelIndex &parent = QModelIndex() ) const override;
78  QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override;
79  Qt::ItemFlags flags( const QModelIndex &index ) const override;
80  bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole ) override;
81  bool insertRows( int row, int count, const QModelIndex &parent = QModelIndex() ) override;
82  bool removeRows( int row, int count, const QModelIndex &parent = QModelIndex() ) override;
83  QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override;
84 
85  private slots:
86  void bookmarkAboutToBeAdded( const QString &id );
87  void bookmarkAdded( const QString &id );
88  void bookmarkAboutToBeRemoved( const QString &id );
89  void bookmarkRemoved( const QString &id );
90  void bookmarkChanged( const QString &id );
91 
92  private:
93  bool mBlocked = false;
94  QgsBookmarkManager *mManager = nullptr;
95  QgsBookmarkManager *mProjectManager = nullptr;
96  QgsBookmark bookmarkForIndex( const QModelIndex &index ) const;
97 
98 };
99 
108 class CORE_EXPORT QgsBookmarkManagerProxyModel : public QSortFilterProxyModel
109 {
110  Q_OBJECT
111 
112  public:
113 
119  QgsBookmarkManagerProxyModel( QgsBookmarkManager *manager, QgsBookmarkManager *projectManager = nullptr, QObject *parent SIP_TRANSFERTHIS = nullptr );
120 
121  private:
122 
123  QgsBookmarkManagerModel *mModel = nullptr;
124 };
125 
126 #endif // QGSBOOKMARKMODEL_H
Implements a model for the contents of QgsBookmarkManager objects.
@ ColumnXMin
Extent x-minimum.
@ ColumnCrs
CRS of extent.
@ ColumnGroup
Group column.
@ ColumnYMin
Extent y-minimum.
@ ColumnStore
Manager storing the bookmark (true if stored in project bookmark manager)
@ ColumnXMax
Extent x-maximum.
@ ColumnYMax
Extent y-maxnimum.
CustomRoles
Custom model roles.
@ RoleName
Bookmark name.
@ RoleGroup
Bookmark group.
A QSortFilterProxyModel subclass for sorting the entries in a QgsBookmarkManagerModel.
Manages storage of a set of bookmarks.
Represents a spatial bookmark, with a name, CRS and extent.
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53