QGIS API Documentation 3.99.0-Master (21b3aa880ba)
Loading...
Searching...
No Matches
qgsrecentstylehandler.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsrecentstylehandler.h
3 ------------------------
4 begin : September 2021
5 copyright : (C) 2021 by 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 QGSRECENTSTYLEHANDLER_H
17#define QGSRECENTSTYLEHANDLER_H
18
19#include <memory>
20#include <unordered_map>
21
22#include "qgis.h"
23#include "qgis_core.h"
24#include "qgis_sip.h"
25#include "qgssymbol.h"
26
27class QgsSymbol;
28
39class CORE_EXPORT QgsRecentStyleHandler
40{
41 public:
42
50
53
55
76 void pushRecentSymbol( const QString &identifier, QgsSymbol *symbol SIP_TRANSFER );
77
86 QgsSymbol *recentSymbol( const QString &identifier ) const SIP_FACTORY;
87
95 template <class SymbolType> std::unique_ptr< SymbolType > recentSymbol( const QString &identifier ) const SIP_SKIP
96 {
97 std::unique_ptr< QgsSymbol > tmpSymbol( recentSymbol( identifier ) );
98 if ( SymbolType *symbolCastToType = dynamic_cast<SymbolType *>( tmpSymbol.get() ) )
99 {
100 return std::unique_ptr< SymbolType >( dynamic_cast<SymbolType *>( tmpSymbol.release() ) );
101 }
102 else
103 {
104 //could not cast
105 return nullptr;
106 }
107 }
108
109 private:
110
111#ifdef SIP_RUN
113#endif
114
115 std::unordered_map< QString, std::unique_ptr< QgsSymbol > > mRecentSymbols;
116
117};
118
119#endif // QGSRECENTSTYLEHANDLER_H
Handles and tracks style items recently used in the QGIS GUI.
QgsRecentStyleHandler(const QgsRecentStyleHandler &other)=delete
void pushRecentSymbol(const QString &identifier, QgsSymbol *symbol)
Pushes a recently used symbol with the specified identifier.
QgsRecentStyleHandler()
Creates a new recent style handler.
std::unique_ptr< SymbolType > recentSymbol(const QString &identifier) const
Returns a copy of the recently used symbol with the specified identifier, or nullptr if no symbol wit...
QgsRecentStyleHandler & operator=(const QgsRecentStyleHandler &other)=delete
QgsSymbol * recentSymbol(const QString &identifier) const
Returns a copy of the recently used symbol with the specified identifier, or nullptr if no symbol wit...
Abstract base class for all rendered symbols.
Definition qgssymbol.h:231
#define SIP_SKIP
Definition qgis_sip.h:134
#define SIP_TRANSFER
Definition qgis_sip.h:36
#define SIP_FACTORY
Definition qgis_sip.h:84