-
-
Notifications
You must be signed in to change notification settings - Fork 3k
/
qgsaction.h
106 lines (90 loc) · 3.5 KB
/
qgsaction.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/***************************************************************************
qgsaction.h - QgsAction
---------------------
begin : 18.4.2016
copyright : (C) 2016 by Matthias Kuhn
email : matthias@opengis.ch
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSACTION_H
#define QGSACTION_H
#include <QString>
#include <QIcon>
/** \ingroup core
* Utility class that encapsulates an action based on vector attributes.
*/
class CORE_EXPORT QgsAction
{
public:
enum ActionType
{
Generic,
GenericPython,
Mac,
Windows,
Unix,
OpenUrl,
};
/**
* Create a new QgsAction
*
* @param type The type of this action
* @param description A human readable description string
* @param action The action text. Its interpretation depends on the type
* @param capture If this is set to true, the output will be captured when an action is run
*/
QgsAction( ActionType type, const QString& description, const QString& action, bool capture )
: mType( type )
, mDescription( description )
, mAction( action )
, mCaptureOutput( capture )
{}
/**
* Create a new QgsAction
*
* @param type The type of this action
* @param description A human readable description string
* @param action The action text. Its interpretation depends on the type
* @param icon Path to an icon for this action
* @param capture If this is set to true, the output will be captured when an action is run
* @param shortTitle A short string used to label user interface elements like buttons
*/
QgsAction( ActionType type, const QString& description, const QString& action, const QString& icon, bool capture, const QString& shortTitle = QString() )
: mType( type )
, mDescription( description )
, mShortTitle( shortTitle )
, mIcon( icon )
, mAction( action )
, mCaptureOutput( capture )
{}
//! The name of the action. This may be a longer description.
QString name() const { return mDescription; }
//! The short title is used to label user interface elements like buttons
QString shortTitle() const { return mShortTitle; }
//! The path to the icon
QString iconPath() const { return mIcon; }
//! The icon
QIcon icon() const { return QIcon( mIcon ); }
//! The action
QString action() const { return mAction; }
//! The action type
ActionType type() const { return mType; }
//! Whether to capture output for display when this action is run
bool capture() const { return mCaptureOutput; }
//! Checks if the action is runable on the current platform
bool runable() const;
private:
ActionType mType;
QString mDescription;
QString mShortTitle;
QString mIcon;
QString mAction;
bool mCaptureOutput;
};
#endif // QGSACTION_H