1 /*
2 	Copyright 2006-2019 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 NAMES_LIST_H
19 #define NAMES_LIST_H
20 #include <QtXml>
21 /**
22 	Cette classe represente une liste de noms, utilisee
23 	par les elements et categories pour embarquer un meme nom en plusieurs
24 	langues.
25 	Les langues sont representees par deux lettres (typiquement : les deux
26 	premieres de la locale du systeme) ; exemples : en pour l'anglais, fr
27 	pour le francais.
28 */
29 class NamesList {
30 	// constructors, destructor
31 	public:
32 	NamesList();
33 	NamesList(const NamesList &);
34 	virtual ~NamesList();
35 
36 	// attributes
37 	private:
38 	QHash<QString, QString> hash_names;
39 
40 	public:
41 	static int MetaTypeId;
42 
43 	// methods
44 	public:
45 	// methods relatives a la gestion de la liste
46 	void addName(const QString &, const QString &);
47 	void removeName(const QString &);
48 	void clearNames();
49 	QList<QString> langs() const;
50 	bool isEmpty() const;
51 	int count() const;
52 	QString &operator[](const QString &);
53 	const QString operator[](const QString &) const;
54 	bool operator!=(const NamesList &) const;
55 	bool operator==(const NamesList &) const;
56 	QString name(const QString & = QString()) const;
57 
58 	// methods relatives a XML
59 	void fromXml(const QDomElement &, const QHash<QString, QString> & = QHash<QString, QString>());
60 	QDomElement toXml(QDomDocument &, const QHash<QString, QString> & = QHash<QString, QString>()) const;
61 
62 	protected:
63 	QHash<QString, QString> getXmlOptions(const QHash<QString, QString> & = QHash<QString, QString>()) const;
64 };
65 Q_DECLARE_METATYPE(NamesList);
66 #endif
67