~ubuntu-branches/ubuntu/raring/qgis/raring

« back to all changes in this revision

Viewing changes to src/core/symbology-ng/qgssymbollayerv2registry.h

  • Committer: Bazaar Package Importer
  • Author(s): Johan Van de Wauw
  • Date: 2010-07-11 20:23:24 UTC
  • mfrom: (3.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100711202324-5ktghxa7hracohmr
Tags: 1.4.0+12730-3ubuntu1
* Merge from Debian unstable (LP: #540941).
* Fix compilation issues with QT 4.7
* Add build-depends on libqt4-webkit-dev 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
#ifndef QGSSYMBOLLAYERV2REGISTRY_H
 
3
#define QGSSYMBOLLAYERV2REGISTRY_H
 
4
 
 
5
#include "qgssymbolv2.h"
 
6
#include "qgssymbollayerv2.h"
 
7
 
 
8
typedef QgsSymbolLayerV2*( *QgsSymbolLayerV2CreateFunc )( const QgsStringMap& );
 
9
typedef QgsSymbolLayerV2Widget*( *QgsSymbolLayerV2WidgetFunc )();
 
10
 
 
11
/**
 
12
 Stores metadata about one symbol layer class.
 
13
 */
 
14
class CORE_EXPORT QgsSymbolLayerV2Metadata
 
15
{
 
16
  public:
 
17
    /** construct invalid metadata */
 
18
    QgsSymbolLayerV2Metadata()
 
19
        : mName(), mCreateFunc( NULL ), mWidgetFunc( NULL ) {}
 
20
 
 
21
    /** construct metadata */
 
22
    QgsSymbolLayerV2Metadata( QString name, QgsSymbolV2::SymbolType type,
 
23
                              QgsSymbolLayerV2CreateFunc pfCreate,
 
24
                              QgsSymbolLayerV2WidgetFunc pfWidget = NULL )
 
25
        : mName( name ), mType( type ), mCreateFunc( pfCreate ), mWidgetFunc( pfWidget ) {}
 
26
 
 
27
    QString name() const { return mName; }
 
28
    QgsSymbolV2::SymbolType type() const { return mType; }
 
29
    QgsSymbolLayerV2CreateFunc createFunction() const { return mCreateFunc; }
 
30
    QgsSymbolLayerV2WidgetFunc widgetFunction() const { return mWidgetFunc; }
 
31
 
 
32
    void setWidgetFunction( QgsSymbolLayerV2WidgetFunc f ) { mWidgetFunc = f; }
 
33
 
 
34
  protected:
 
35
    QString mName;
 
36
    QgsSymbolV2::SymbolType mType;
 
37
    QgsSymbolLayerV2CreateFunc mCreateFunc;
 
38
    QgsSymbolLayerV2WidgetFunc mWidgetFunc;
 
39
};
 
40
 
 
41
/**
 
42
 Registry of available symbol layer classes.
 
43
 Implemented as a singleton.
 
44
 */
 
45
class CORE_EXPORT QgsSymbolLayerV2Registry
 
46
{
 
47
  public:
 
48
 
 
49
    //! return the single instance of this class (instantiate it if not exists)
 
50
    static QgsSymbolLayerV2Registry* instance();
 
51
 
 
52
    //! return metadata for specified symbol layer
 
53
    QgsSymbolLayerV2Metadata symbolLayerMetadata( QString name ) const;
 
54
 
 
55
    //! register a new symbol layer type
 
56
    void addSymbolLayerType( const QgsSymbolLayerV2Metadata& metadata );
 
57
 
 
58
    //! set layer type's widget function
 
59
    bool setLayerTypeWidgetFunction( QString name, QgsSymbolLayerV2WidgetFunc f );
 
60
 
 
61
    //! create a new instance of symbol layer given symbol layer name and properties
 
62
    QgsSymbolLayerV2* createSymbolLayer( QString name, const QgsStringMap& properties = QgsStringMap() ) const;
 
63
 
 
64
    //! return a list of available symbol layers for a specified symbol type
 
65
    QStringList symbolLayersForType( QgsSymbolV2::SymbolType type );
 
66
 
 
67
    //! create a new instance of symbol layer for specified symbol type with default settings
 
68
    static QgsSymbolLayerV2* defaultSymbolLayer( QgsSymbolV2::SymbolType type );
 
69
 
 
70
  protected:
 
71
    QgsSymbolLayerV2Registry();
 
72
 
 
73
    static QgsSymbolLayerV2Registry* mInstance;
 
74
    QMap<QString, QgsSymbolLayerV2Metadata> mMetadata;
 
75
 
 
76
};
 
77
 
 
78
#endif