QElectroTech 0.100.0-dev
Loading...
Searching...
No Matches
userproperties.h
Go to the documentation of this file.
1/*
2 Copyright 2006-2024 The QElectroTech Team
3 This file is part of QElectroTech.
4
5 QElectroTech is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 2 of the License, or
8 (at your option) any later version.
9
10 QElectroTech is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
17*/
18#ifndef USERPROPERTIES_H
19#define USERPROPERTIES_H
20
21#include "propertiesinterface.h"
22
32{
33 public:
34 UserProperties(const QString tag_name = "userProperties");
35
36 virtual void toSettings (QSettings &,
37 const QString = QString()) const override {}
38
39 virtual void fromSettings (const QSettings &,
40 const QString = QString()) override {}
41
42 virtual QDomElement toXml (QDomDocument &xml_document) const override;
43 virtual bool fromXml (const QDomElement &xml_element) override;
44
46 int userPropertiesCount() const;
47 void setUserProperty(const QString& key, const QVariant& value);
48 bool existUserProperty(const QString& key) const;
49 QVariant userPropertyValue(const QString& key);
50
51 void setTagName(const QString& tag_name);
52 QString tagName() const;
53
54 private:
55 QHash<QString, QVariant> m_properties;
56 QString m_tag_name;
57};
58
59#endif // USERPROPERTIES_H
The PropertiesInterface class This class is an interface for have common way to use properties in QEl...
Definition propertiesinterface.h:31
The UserProperties class This class store user properties. User properties are properties set by user...
Definition userproperties.h:32
void deleteUserProperties()
UserProperties::deleteUserProperties Delete all userproperties.
Definition userproperties.cpp:150
QHash< QString, QVariant > m_properties
Definition userproperties.h:55
void setUserProperty(const QString &key, const QVariant &value)
UserProperties::setUserProperty Adds a new property if key does not exist in the properties member,...
Definition userproperties.cpp:169
virtual void fromSettings(const QSettings &, const QString=QString()) override
fromSettings load properties to setting file.
Definition userproperties.h:39
QString tagName() const
Definition userproperties.cpp:208
virtual QDomElement toXml(QDomDocument &xml_document) const override
UserProperties::toXml.
Definition userproperties.cpp:39
virtual bool fromXml(const QDomElement &xml_element) override
UserProperties::fromXml.
Definition userproperties.cpp:74
QString m_tag_name
Definition userproperties.h:56
void setTagName(const QString &tag_name)
UserProperties::setTagName Set the tag name use to store in xml.
Definition userproperties.cpp:204
virtual void toSettings(QSettings &, const QString=QString()) const override
toSettings Save properties to setting file.
Definition userproperties.h:36
bool existUserProperty(const QString &key) const
UserProperties::existUserProperty Checks if a user property with key key is available or not.
Definition userproperties.cpp:179
QVariant userPropertyValue(const QString &key)
UserProperties::userPropertyValue Returns the value of a user property with key key If key is not fou...
Definition userproperties.cpp:191
int userPropertiesCount() const
UserProperties::userPropertiesCount.
Definition userproperties.cpp:158