Changeset View
Changeset View
Standalone View
Standalone View
src/kauthaction.cpp
Show All 14 Lines | |||||
15 | * along with this program; if not, write to the | 15 | * along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., | 16 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . | 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | #include "kauthaction.h" | 20 | #include "kauthaction.h" | ||
21 | 21 | | |||
22 | #include <QtGlobal> | 22 | #include <QtGlobal> | ||
23 | #include <QRegularExpression> | 23 | #include <QRegularExpression> | ||
sitter: I think that is deprecated, or at least not recommended for use anymore. You'll want… | |||||
24 | 24 | | |||
25 | class QWidget; | 25 | class QWidget; | ||
26 | 26 | | |||
27 | #include "kauthexecutejob.h" | 27 | #include "kauthexecutejob.h" | ||
28 | 28 | | |||
29 | #include "BackendsManager.h" | 29 | #include "BackendsManager.h" | ||
30 | 30 | | |||
31 | namespace KAuth | 31 | namespace KAuth | ||
32 | { | 32 | { | ||
33 | 33 | | |||
34 | class ActionData : public QSharedData | 34 | class ActionData : public QSharedData | ||
35 | { | 35 | { | ||
36 | public: | 36 | public: | ||
37 | ActionData() : parent(nullptr), timeout(-1) {} | 37 | ActionData() : parent(nullptr), timeout(-1) {} | ||
38 | ActionData(const ActionData &other) | 38 | ActionData(const ActionData &other) | ||
39 | : QSharedData(other) | 39 | : QSharedData(other) | ||
40 | , name(other.name) | 40 | , name(other.name) | ||
41 | , details(other.details) | | |||
42 | , helperId(other.helperId) | 41 | , helperId(other.helperId) | ||
42 | , details(other.details) | ||||
43 | , args(other.args) | 43 | , args(other.args) | ||
44 | , parent(other.parent) | 44 | , parent(other.parent) | ||
45 | , timeout(other.timeout) {} | 45 | , timeout(other.timeout) {} | ||
46 | ~ActionData() {} | 46 | ~ActionData() {} | ||
47 | 47 | | |||
48 | QString name; | 48 | QString name; | ||
49 | QString details; | | |||
50 | QString helperId; | 49 | QString helperId; | ||
50 | Action::DetailsMap details; | ||||
51 | QVariantMap args; | 51 | QVariantMap args; | ||
52 | QWidget *parent = nullptr; | 52 | QWidget *parent = nullptr; | ||
Mh, minor annoyance. valid and timeout should get their defaults set here as a more modern best practice and also because parent is already set for consistency. That default ctor is kinda pointless then and should be dropped IMHO. sitter: Mh, minor annoyance. valid and timeout should get their defaults set here as a more modern best… | |||||
53 | int timeout; | 53 | int timeout; | ||
54 | }; | 54 | }; | ||
55 | 55 | | |||
56 | // Constructors | 56 | // Constructors | ||
57 | Action::Action() | 57 | Action::Action() | ||
58 | : d(new ActionData()) | 58 | : d(new ActionData()) | ||
59 | { | 59 | { | ||
60 | } | 60 | } | ||
61 | 61 | | |||
62 | Action::Action(const Action &action) | 62 | Action::Action(const Action &action) | ||
63 | : d(action.d) | 63 | : d(action.d) | ||
64 | { | 64 | { | ||
65 | } | 65 | } | ||
66 | 66 | | |||
67 | Action::Action(const QString &name) | 67 | Action::Action(const QString &name) | ||
68 | : d(new ActionData()) | 68 | : d(new ActionData()) | ||
69 | { | 69 | { | ||
70 | setName(name); | 70 | setName(name); | ||
71 | BackendsManager::authBackend()->setupAction(d->name); | 71 | BackendsManager::authBackend()->setupAction(d->name); | ||
72 | } | 72 | } | ||
73 | 73 | | |||
74 | #ifndef KAUTHCORE_NO_DEPRECATED | ||||
74 | Action::Action(const QString &name, const QString &details) | 75 | Action::Action(const QString &name, const QString &details) | ||
76 | : Action(name, DetailsMap{{DetailOther, details}}) | ||||
77 | { | ||||
78 | } | ||||
79 | #endif | ||||
80 | | ||||
81 | Action::Action(const QString &name, const DetailsMap &details) | ||||
75 | : d(new ActionData()) | 82 | : d(new ActionData()) | ||
you could just delegate to the new constructor here instead of having two code duplicated ctors. sitter: you could just delegate to the new constructor here instead of having two code duplicated ctors. | |||||
76 | { | 83 | { | ||
77 | setName(name); | 84 | setName(name); | ||
78 | setDetails(details); | 85 | setDetailsV2(details); | ||
79 | BackendsManager::authBackend()->setupAction(d->name); | 86 | BackendsManager::authBackend()->setupAction(d->name); | ||
80 | } | 87 | } | ||
81 | 88 | | |||
82 | Action::~Action() | 89 | Action::~Action() | ||
83 | { | 90 | { | ||
84 | } | 91 | } | ||
85 | 92 | | |||
86 | // Operators | 93 | // Operators | ||
Show All 35 Lines | 128 | { | |||
122 | return d->timeout; | 129 | return d->timeout; | ||
123 | } | 130 | } | ||
124 | 131 | | |||
125 | void Action::setTimeout(int timeout) | 132 | void Action::setTimeout(int timeout) | ||
126 | { | 133 | { | ||
127 | d->timeout = timeout; | 134 | d->timeout = timeout; | ||
128 | } | 135 | } | ||
129 | 136 | | |||
137 | #ifndef KAUTHCORE_NO_DEPRECATED | ||||
130 | QString Action::details() const | 138 | QString Action::details() const | ||
131 | { | 139 | { | ||
132 | return d->details; | 140 | return d->details.value(DetailOther).toString(); | ||
133 | } | 141 | } | ||
134 | 142 | | |||
135 | void Action::setDetails(const QString &details) | 143 | void Action::setDetails(const QString &details) | ||
136 | { | 144 | { | ||
145 | d->details.clear(); | ||||
146 | d->details.insert(DetailOther, details); | ||||
147 | } | ||||
148 | #endif | ||||
149 | | ||||
150 | Action::DetailsMap Action::detailsV2() const | ||||
151 | { | ||||
152 | return d->details; | ||||
153 | } | ||||
154 | | ||||
155 | void Action::setDetailsV2(const DetailsMap &details) | ||||
156 | { | ||||
137 | d->details = details; | 157 | d->details = details; | ||
138 | } | 158 | } | ||
139 | 159 | | |||
140 | bool Action::isValid() const | 160 | bool Action::isValid() const | ||
141 | { | 161 | { | ||
142 | if (d->name.isEmpty()) { | 162 | if (d->name.isEmpty()) { | ||
143 | return false; | 163 | return false; | ||
144 | } | 164 | } | ||
▲ Show 20 Lines • Show All 68 Lines • Show Last 20 Lines |
I think that is deprecated, or at least not recommended for use anymore. You'll want QRegularExpression