QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
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  public:
111 
117  QgsBookmarkManagerProxyModel( QgsBookmarkManager *manager, QgsBookmarkManager *projectManager = nullptr, QObject *parent SIP_TRANSFERTHIS = nullptr );
118 
119  private:
120 
121  QgsBookmarkManagerModel *mModel = nullptr;
122 };
123 
124 #endif // QGSBOOKMARKMODEL_H
Implements a model for the contents of QgsBookmarkManager objects.
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
Manages storage of a set of bookmarks.
CustomRoles
Custom model roles.
Manager storing the bookmark (true if stored in project bookmark manager)
A QSortFilterProxyModel subclass for sorting the entries in a QgsBookmarkManagerModel.
Represents a spatial bookmark, with a name, CRS and extent.