QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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
QgsBookmarkManagerModel::ColumnXMin
@ ColumnXMin
Extent x-minimum.
Definition: qgsbookmarkmodel.h:61
QgsBookmarkManagerModel::ColumnXMax
@ ColumnXMax
Extent x-maximum.
Definition: qgsbookmarkmodel.h:63
QgsBookmarkManager
Manages storage of a set of bookmarks.
Definition: qgsbookmarkmanager.h:145
QgsBookmarkManagerModel::CustomRoles
CustomRoles
Custom model roles.
Definition: qgsbookmarkmodel.h:48
QgsBookmarkManagerModel::ColumnYMax
@ ColumnYMax
Extent y-maxnimum.
Definition: qgsbookmarkmodel.h:64
QgsBookmarkManagerModel::ColumnGroup
@ ColumnGroup
Group column.
Definition: qgsbookmarkmodel.h:60
QgsBookmarkManagerModel::Columns
Columns
Model columns.
Definition: qgsbookmarkmodel.h:57
QgsBookmark
Represents a spatial bookmark, with a name, CRS and extent.
Definition: qgsbookmarkmanager.h:37
qgis_sip.h
QgsBookmarkManagerModel::RoleGroup
@ RoleGroup
Bookmark group.
Definition: qgsbookmarkmodel.h:53
QgsBookmarkManagerModel::ColumnName
@ ColumnName
Name column.
Definition: qgsbookmarkmodel.h:59
QgsBookmarkManagerModel::ColumnStore
@ ColumnStore
Manager storing the bookmark (true if stored in project bookmark manager)
Definition: qgsbookmarkmodel.h:66
QgsBookmarkManagerModel::ColumnYMin
@ ColumnYMin
Extent y-minimum.
Definition: qgsbookmarkmodel.h:62
QgsBookmarkManagerModel::ColumnCrs
@ ColumnCrs
CRS of extent.
Definition: qgsbookmarkmodel.h:65
QgsBookmarkManagerModel::RoleId
@ RoleId
Bookmark ID.
Definition: qgsbookmarkmodel.h:52
QgsBookmarkManagerProxyModel
A QSortFilterProxyModel subclass for sorting the entries in a QgsBookmarkManagerModel.
Definition: qgsbookmarkmodel.h:108
QgsBookmarkManagerModel
Implements a model for the contents of QgsBookmarkManager objects.
Definition: qgsbookmarkmodel.h:41
QgsBookmarkManagerModel::RoleName
@ RoleName
Bookmark name.
Definition: qgsbookmarkmodel.h:51
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53