Computer Assisted Medical Intervention Tool Kit version 6.0
 
Loading...
Searching...
No Matches
VariantDataModel.h
Go to the documentation of this file.
1/*****************************************************************************
2 * $CAMITK_LICENCE_BEGIN$
3 *
4 * CamiTK - Computer Assisted Medical Intervention ToolKit
5 * (c) 2001-2025 Univ. Grenoble Alpes, CNRS, Grenoble INP - UGA, TIMC, 38000 Grenoble, France
6 *
7 * Visit http://camitk.imag.fr for more information
8 *
9 * This file is part of CamiTK.
10 *
11 * CamiTK is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
14 *
15 * CamiTK is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
22 *
23 * $CAMITK_LICENCE_END$
24 ****************************************************************************/
25
26#ifndef __VARIANT_DATA_MODEL__
27#define __VARIANT_DATA_MODEL__
28
29#include <QVariant>
30
32
125public:
132
137
142 VariantDataModel(const QVariant& variant);
143
148 VariantDataModel(const QVariantList& variant);
149
154 VariantDataModel(const QVariantMap& variant);
155
159
163 static const VariantDataModel fromJsonString(const QString& jsonString);
164
166 static const VariantDataModel fromJsonObject(const QJsonObject& jsonObject);
167
169 static VariantDataModel& invalid();
171
175 bool isModified() const;
177 bool isValid() const ;
180 QString typeString() const;
182 QString getName();
184
188 VariantDataModel& operator=(QVariant newValue);
189
191 QVariant getValue() const;
192
196 QString toString() const;
197
199 operator QString() const;
200
206 QString toJsonString() const;
207
216 void remove();
217
219 bool operator==(const VariantDataModel& other) const;
220 bool operator==(const QVariant& v) const;
221 bool operator==(const QVariantList& v) const;
222 bool operator==(const QVariantMap& v) const;
223
225 bool operator!=(const VariantDataModel& other) const;
226 bool operator!=(const QVariant& v) const;
227 bool operator!=(const QVariantList& v) const;
228 bool operator!=(const QVariantMap& v) const;
229
234 VariantDataModel& last();
235
240 int size() const;
241
246 bool isEmpty() const;
247
249 void reset();
251
255
262 VariantDataModel& value(const QString& key);
263
271 VariantDataModel& operator[](const QString& key);
272
274 const VariantDataModel operator[](const QString& key) const;
275
279 bool contains(const QString& key) const;
280
284 void insert(const QString& key, const VariantDataModel& value);
285
289 void insert(const QString& key, const QVariant& value);
290
295 int remove(const QString& key) ;
297
301
305 VariantDataModel& at(int i) ;
306
308 VariantDataModel& operator[](int i);
309
311 const VariantDataModel operator[](int i) const;
312
317 bool removeOne(const VariantDataModel& item);
318
324 bool removeAt(int i);
325
329 void append(const VariantDataModel& item);
331
334
338
341
345
348
351 QMap<QString, VariantDataModel>::iterator beginMap();
352
354 QMap<QString, VariantDataModel>::const_iterator beginMap() const;
355
358 QMap<QString, VariantDataModel>::iterator endMap();
359
361 QMap<QString, VariantDataModel>::const_iterator endMap() const;
363
364protected:
367
370
372 QString name;
373
376
378 void setName(const QString& name);
379
380private:
382 void copyMap(const QVariantMap&);
383
385 void copyList(const QVariantList&);
386
388 QVariant simpleValue;
389
392
394 QMap<QString, VariantDataModel> map;
395};
396
397#endif // __VARIANT_DATA_MODEL__
#define CAMITKEXTENSIONGENERATOR_EXPORT
Definition CamiTKExtensionGeneratorAPI.h:33
Definition PersistenceManager.h:30
VariantDataModel encapsulates QVariant and can be used as a model for any type of QVariant supported ...
Definition VariantDataModel.h:124
QString name
name (unused, equals to typeString())
Definition VariantDataModel.h:372
bool isModifiedFlag
true if there was a modification in the value, item or pair since instanciation or last reset
Definition VariantDataModel.h:366
static VariantDataModel invalidVariantDataModel
The default VariantDataModel, an Atomic VariantDataModel with invalid status.
Definition VariantDataModel.h:375
VariantNodeType
The different types that can be stored in a VariantDataModel.
Definition VariantDataModel.h:127
@ List
List of VariantDataModel.
Definition VariantDataModel.h:129
@ Atomic
Atomic type (string, numeric values, boolean)
Definition VariantDataModel.h:128
VariantNodeType type
type can be Atomic, List or Map depending on how the VariantDataModel was instantiated
Definition VariantDataModel.h:369
static Value getValue(const QMap< const QtProperty *, PrivateData > &propertyMap, const QtProperty *property, const Value &defaultValue=Value())
Definition qtpropertymanager.cpp:222