FOSSredder 0.5.0
Loading...
Searching...
No Matches
ActorViewModel.h
Go to the documentation of this file.
1
5
6#pragma once
7
8#include <QObject>
9#include <QString>
10#include <QStringList>
11#include <QVariantList>
12#include <QVariantMap>
13
14namespace ui {
15
19class WorkspaceStore;
20
24class ActorViewModel : public QObject {
25 Q_OBJECT
26 Q_PROPERTY(QString currentId READ currentId NOTIFY changed)
27 Q_PROPERTY(QString name READ name WRITE setName NOTIFY changed)
28 Q_PROPERTY(QVariantList aliases READ aliases WRITE setAliases NOTIFY changed)
29 Q_PROPERTY(QString aliasInputText READ aliasInputText WRITE setAliasInputText
30 NOTIFY changed)
31 Q_PROPERTY(int aliasIndex READ aliasIndex WRITE setAliasIndex NOTIFY changed)
32 Q_PROPERTY(QVariantList selectedContractIds READ selectedContractIds WRITE
34 Q_PROPERTY(QVariantList actorRows READ actorRows NOTIFY changed)
35 Q_PROPERTY(QVariantList contractRows READ contractRows NOTIFY changed)
36 Q_PROPERTY(bool isEdit READ isEdit NOTIFY changed)
37 Q_PROPERTY(bool hasChanges READ hasChanges NOTIFY changed)
38 Q_PROPERTY(bool canSubmit READ canSubmit NOTIFY changed)
39
40public:
45 explicit ActorViewModel(WorkspaceStore* store, WorkspaceCommands* commands,
46 WorkspaceSelection* selection,
47 WorkspaceSelectors* selectors,
48 QObject* parent = nullptr);
49
54 QString currentId() const;
59 QString name() const {
60 return name_;
61 }
62
66 void setName(const QString& value);
71 QVariantList aliases() const {
72 return aliases_;
73 }
74
78 void setAliases(const QVariantList& value);
83 QString aliasInputText() const {
84 return aliasInputText_;
85 }
86
90 void setAliasInputText(const QString& value);
95 int aliasIndex() const {
96 return aliasIndex_;
97 }
98
102 void setAliasIndex(int value);
107 QVariantList selectedContractIds() const {
108 return selectedContractIds_;
109 }
110
114 void setSelectedContractIds(const QVariantList& value);
119 bool isEdit() const;
124 bool hasChanges() const;
129 bool canSubmit() const;
130
135 QVariantList actorRows() const;
136
141 QVariantList contractRows() const;
142
147 Q_INVOKABLE void selectActor(const QString& id);
153 Q_INVOKABLE bool canAddAlias(const QString& value) const;
158 Q_INVOKABLE void addAlias(const QString& value);
162 Q_INVOKABLE void requestRemoveSelectedAlias();
166 Q_INVOKABLE void enterCreateMode();
170 Q_INVOKABLE void previous();
174 Q_INVOKABLE void next();
179 Q_INVOKABLE QString submit();
183 Q_INVOKABLE void deleteCurrent();
187 Q_INVOKABLE void clear();
193 Q_INVOKABLE void setContractSelected(const QString& contractId,
194 bool selected);
195
196signals:
198 void changed();
199
200private:
205 void setCurrentId(const QString& id);
206
210 void bindSignals();
211
216 void reloadFromSelection(bool forceReload);
220 void clearFormState();
225 bool hasValidAliasSelection() const;
229 void captureSavedState();
234 void applyFormState(const QVariantMap& state);
241 void reloadFormState(bool forceReload, const QVariantMap& state);
242
243 WorkspaceStore* store_ = nullptr;
244 WorkspaceCommands* commands_ = nullptr;
245 WorkspaceSelection* selection_ = nullptr;
246 WorkspaceSelectors* selectors_ = nullptr;
247 QString currentOwnerId_;
248 QString name_;
249 QVariantList aliases_;
250 QString aliasInputText_;
251 int aliasIndex_ = -1;
252 QString savedName_;
253 QVariantList savedAliases_;
254 QVariantList selectedContractIds_;
255 QVariantList savedSelectedContractIds_;
256};
257
258} // namespace ui
QVariantList contractRows
Q_INVOKABLE void deleteCurrent()
Deletes the selected actor through workspace commands.
QVariantList aliases
Q_INVOKABLE void next()
Selects the next actor row.
void setAliasInputText(const QString &value)
Updates the current alias input text.
Q_INVOKABLE void setContractSelected(const QString &contractId, bool selected)
Adds or removes a contract id from the actor form selection.
Q_INVOKABLE void clear()
Clears the editable actor form.
QVariantList selectedContractIds
QString aliasInputText() const
Returns the current alias input text.
Q_INVOKABLE void previous()
Selects the previous actor row.
int aliasIndex() const
Returns the selected alias index.
void changed()
Emitted when actor view model state changed.
Q_INVOKABLE void selectActor(const QString &id)
Selects an actor for editing.
Q_INVOKABLE bool canAddAlias(const QString &value) const
Checks whether an alias value can be added to the form.
Q_INVOKABLE void addAlias(const QString &value)
Adds an alias to the actor form.
QVariantList aliases() const
Returns editable actor aliases.
ActorViewModel(WorkspaceStore *store, WorkspaceCommands *commands, WorkspaceSelection *selection, WorkspaceSelectors *selectors, QObject *parent=nullptr)
Creates the actor view model bound to workspace roles.
void setAliasIndex(int value)
Updates the selected alias index.
QVariantList selectedContractIds() const
Returns selected contract ids in the actor form.
void setName(const QString &value)
Updates the editable actor name.
Q_INVOKABLE void requestRemoveSelectedAlias()
Removes the currently selected alias when possible.
void setAliases(const QVariantList &value)
Replaces editable actor aliases.
QVariantList actorRows
Q_INVOKABLE QString submit()
Creates or updates the actor through workspace commands.
Q_INVOKABLE void enterCreateMode()
Clears selection and opens an empty create form.
void setSelectedContractIds(const QVariantList &value)
Replaces selected contract ids in the actor form.
Maps UI intent to core workspace writer commands.
Tracks the currently selected workspace entities.
Projects workspace store data into QML-facing read models.
Owns the current UI-side workspace snapshot and revision lifecycle.