Line data Source code
1 : /**
2 : * @file
3 : *
4 : * @brief
5 : *
6 : * @copyright BSD License (see LICENSE.md or https://www.libelektra.org)
7 : */
8 :
9 : #ifndef DATACONTAINER_HPP
10 : #define DATACONTAINER_HPP
11 :
12 : #include "treeviewmodel.hpp"
13 : #include <QObject>
14 :
15 : /**
16 : * @brief The DataContainer class. It encapsulates various properties to avoid long method signatures.
17 : */
18 :
19 0 : class DataContainer : public QObject
20 : {
21 : Q_OBJECT
22 :
23 : public:
24 : /**
25 : * @brief The default constructor.
26 : * @param parentContainer An optional parent object.
27 : */
28 0 : explicit DataContainer (QObject * parentContainer = nullptr) : QObject (parentContainer)
29 : {
30 : }
31 :
32 : /**
33 : * @brief The mandatory copy construcor-
34 : */
35 : DataContainer (const DataContainer & otherContainer)
36 : : QObject (){ Q_UNUSED (otherContainer) }
37 :
38 : /**
39 : * @brief The old name of a ConfigNode. Used when creating EditKeyCommands.
40 : * @return The old name of a ConfigNode.
41 : */
42 : Q_INVOKABLE QString oldName () const;
43 :
44 : /**
45 : * @brief Sets the old name of a ConfigNode. Used when creating EditKeyCommands.
46 : * @param name The old name of a ConfigNode.
47 : */
48 : Q_INVOKABLE void setOldName (const QString & name);
49 :
50 : /**
51 : * @brief The old value of a ConfigNode. Used when creating EditKeyCommands.
52 : * @return The old value of a ConfigNode.
53 : */
54 : Q_INVOKABLE QString oldValue () const;
55 :
56 : /**
57 : * @brief Sets the old value of a ConfigNode. Used when creating EditKeyCommands.
58 : * @param value The old value of a ConfigNode.
59 : */
60 : Q_INVOKABLE void setOldValue (const QString & value);
61 :
62 : /**
63 : * @brief The old metadata of a ConfigNode. Used when creating EditKeyCommands.
64 : * @return The old metadata of a ConfigNode.
65 : */
66 : Q_INVOKABLE QVariantMap oldMetadata () const;
67 :
68 : /**
69 : * @brief Sets the old metadata of a ConfigNode. Used when creating EditKeyCommands.
70 : * @param metadata The old metadata of a ConfigNode.
71 : */
72 : Q_INVOKABLE void setOldMetadata (TreeViewModel * metadata);
73 :
74 : /**
75 : * @brief The new name of a ConfigNode. Used when creating EditKeyCommands and NewKeyCommands.
76 : * @return The new name of a ConfigNode.
77 : */
78 : Q_INVOKABLE QString newName () const;
79 :
80 : /**
81 : * @brief Sets the new name of a ConfigNode. Used when creating EditKeyCommands and NewKeyCommands.
82 : * @param name The new name of a ConfigNode.
83 : */
84 : Q_INVOKABLE void setNewName (const QString & name);
85 :
86 : /**
87 : * @brief The new value of a ConfigNode. Used when creating EditKeyCommands and NewKeyCommands.
88 : * @param name The new value of a ConfigNode.
89 : */
90 : Q_INVOKABLE QString newValue () const;
91 :
92 : /**
93 : * @brief Sets the new value of a ConfigNode. Used when creating EditKeyCommands and NewKeyCommands.
94 : * @param name The new value of a ConfigNode.
95 : */
96 : Q_INVOKABLE void setNewValue (const QString & value);
97 :
98 : /**
99 : * @brief The new metadata of a ConfigNode. Used when creating EditKeyCommands and NewKeyCommands.
100 : * @param name The new metadata of a ConfigNode.
101 : */
102 : Q_INVOKABLE QVariantMap newMetadata () const;
103 :
104 : /**
105 : * @brief Sets the new metadata of a ConfigNode. Used when creating EditKeyCommands and NewKeyCommands.
106 : * @param name The new metadata of a ConfigNode.
107 : */
108 : Q_INVOKABLE void setNewMetadata (const QVariantMap & metadata);
109 :
110 : /**
111 : * @brief The name of the ConfigNode that will be the root ConfigNode when importing a configuration from file. Used when creating
112 : * ImportConfigurationCommands.
113 : * @return The name of the ConfigNode that will be the root ConfigNode when importing a configuration from file.
114 : */
115 : Q_INVOKABLE QString importName () const;
116 :
117 : /**
118 : * @brief Sets the name of the ConfigNode that will be the root ConfigNode when importing a configuration from file. Used when
119 : * creating ImportConfigurationCommands.
120 : * @param name The name of the ConfigNode that will be the root ConfigNode when importing a configuration from file.
121 : */
122 : Q_INVOKABLE void setImportName (const QString & name);
123 :
124 : /**
125 : * @brief The format of the file that contains the configuration to import. Used when creating ImportConfigurationCommands.
126 : * @return The format of the file that contains the configuration to import.
127 : */
128 : Q_INVOKABLE QString format () const;
129 :
130 : /**
131 : * @brief Sets the format of the file that contains the configuration to import. Used when creating ImportConfigurationCommands.
132 : * @param form The format of the file that contains the configuration to import.
133 : */
134 : Q_INVOKABLE void setFormat (const QString & form);
135 :
136 : /**
137 : * @brief The system path of the file that contains the configuration to import. Used when creating ImportConfigurationCommands.
138 : * @return The system path of the file that contains the configuration to import.
139 : */
140 : Q_INVOKABLE QString file () const;
141 :
142 : /**
143 : * @brief Sets the system path of the file that contains the configuration to import. Used when creating
144 : * ImportConfigurationCommands.
145 : * @param fil The system path of the file that contains the configuration to import.
146 : */
147 : Q_INVOKABLE void setFile (const QString & fil);
148 :
149 : /**
150 : * @brief The merge strategies used when importing a configuration from file. Used when creating ImportConfigurationCommands.
151 : * @return The merge strategies used when importing a configuration from file.
152 : */
153 : Q_INVOKABLE QVariantList mergeStrategies () const;
154 :
155 : /**
156 : * @brief Sets the merge strategies used when importing a configuration from file. Used when creating ImportConfigurationCommands.
157 : * @param strategies The merge strategies used when importing a configuration from file.
158 : */
159 : Q_INVOKABLE void setMergeStrategies (const QVariantList & strategies);
160 :
161 : /**
162 : * @brief Sets all properties to empty values.
163 : */
164 : Q_INVOKABLE void clearData ();
165 :
166 : private:
167 : QString m_oldName;
168 : QString m_oldValue;
169 : QVariantMap m_oldMetadata;
170 :
171 : QString m_newName;
172 : QString m_newValue;
173 : QVariantMap m_newMetadata;
174 :
175 : QString m_importName;
176 : QString m_format;
177 : QString m_file;
178 : QVariantList m_mergeStrategies;
179 : };
180 :
181 : #endif // DATACONTAINER_HPP
|