QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
qgsaction.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsaction.h - QgsAction
3 
4  ---------------------
5  begin : 18.4.2016
6  copyright : (C) 2016 by Matthias Kuhn
7  email : [email protected]
8  ***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 #ifndef QGSACTION_H
17 #define QGSACTION_H
18 
19 #include <QString>
20 #include <QIcon>
21 
25 class CORE_EXPORT QgsAction
26 {
27  public:
29  {
32  Mac,
36  };
37 
46  QgsAction( ActionType type, const QString& description, const QString& action, bool capture )
47  : mType( type )
48  , mDescription( description )
49  , mAction( action )
50  , mCaptureOutput( capture )
51  , mShowInAttributeTable( true )
52  {}
53 
54 
65  QgsAction( ActionType type, const QString& description, const QString& action, const QString& icon, bool capture, const QString& shortTitle = QString() )
66  : mType( type )
67  , mDescription( description )
68  , mShortTitle( shortTitle )
69  , mIcon( icon )
70  , mAction( action )
71  , mCaptureOutput( capture )
72  , mShowInAttributeTable( true )
73  {}
74 
86  QgsAction( ActionType type, const QString& description, const QString& action, const QString& icon, bool capture, bool showInAttributeTable, const QString& shortTitle = QString() )
87  : mType( type )
88  , mDescription( description )
89  , mShortTitle( shortTitle )
90  , mIcon( icon )
91  , mAction( action )
92  , mCaptureOutput( capture )
93  , mShowInAttributeTable( showInAttributeTable )
94  {}
95 
97  QString name() const { return mDescription; }
98 
100  QString shortTitle() const { return mShortTitle; }
101 
103  QString iconPath() const { return mIcon; }
104 
106  QIcon icon() const { return QIcon( mIcon ); }
107 
109  QString action() const { return mAction; }
110 
112  ActionType type() const { return mType; }
113 
115  bool capture() const { return mCaptureOutput; }
116 
118  bool showInAttributeTable() const { return mShowInAttributeTable; }
119 
121  bool runable() const;
122 
123  private:
124  ActionType mType;
125  QString mDescription;
126  QString mShortTitle;
127  QString mIcon;
128  QString mAction;
129  bool mCaptureOutput;
130  bool mShowInAttributeTable;
131 };
132 
133 #endif // QGSACTION_H
QString iconPath() const
The path to the icon.
Definition: qgsaction.h:103
bool capture() const
Whether to capture output for display when this action is run.
Definition: qgsaction.h:115
ActionType type() const
The action type.
Definition: qgsaction.h:112
QString shortTitle() const
The short title is used to label user interface elements like buttons.
Definition: qgsaction.h:100
QgsAction(ActionType type, const QString &description, const QString &action, const QString &icon, bool capture, const QString &shortTitle=QString())
Create a new QgsAction.
Definition: qgsaction.h:65
QgsAction(ActionType type, const QString &description, const QString &action, const QString &icon, bool capture, bool showInAttributeTable, const QString &shortTitle=QString())
Create a new QgsAction.
Definition: qgsaction.h:86
Utility class that encapsulates an action based on vector attributes.
Definition: qgsaction.h:25
QIcon icon() const
The icon.
Definition: qgsaction.h:106
QString name() const
The name of the action. This may be a longer description.
Definition: qgsaction.h:97
bool showInAttributeTable() const
Whether this action should be shown on the attribute table.
Definition: qgsaction.h:118
QString action() const
The action.
Definition: qgsaction.h:109
QgsAction(ActionType type, const QString &description, const QString &action, bool capture)
Create a new QgsAction.
Definition: qgsaction.h:46