swift
namevariantpairlist.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 2013 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
5 
6 #ifndef SWIFT_MISC_NAMEVARIANPAIRTLIST_H
7 #define SWIFT_MISC_NAMEVARIANPAIRTLIST_H
8 
9 #include <QMetaType>
10 #include <QString>
11 
12 #include "misc/collection.h"
13 #include "misc/namevariantpair.h"
14 #include "misc/sequence.h"
15 #include "misc/swiftmiscexport.h"
16 #include "misc/variant.h"
17 
18 SWIFT_DECLARE_SEQUENCE_MIXINS(swift::misc, CNameVariantPair, CNameVariantPairList)
19 
20 namespace swift::misc
21 {
25  public CSequence<CNameVariantPair>,
26  public mixin::MetaType<CNameVariantPairList>
27  {
28  public:
31 
34 
37 
39  int getIndexForName(const QString &name) const;
40 
42  bool containsName(const QString &name) const;
43 
45  QStringList getNames(bool sorted = true) const;
46 
48  CNameVariantPair getValue(const QString &name) const;
49 
51  CVariant getVariantValue(const QString &name) const;
52 
54  QString getValueAsString(const QString &name) const;
55 
58  bool addOrReplaceValue(const QString &name, const CVariant &value, const CIcon &icon = CIcon());
59  };
60 } // namespace swift::misc
61 
62 Q_DECLARE_METATYPE(swift::misc::CNameVariantPairList)
64 
65 #endif // SWIFT_MISC_NAMEVARIANPAIRTLIST_H
Generic ordered container with value semantics.
Definition: collection.h:107
Value object for icons. An icon is stored in the global icon repository and identified by its index....
Definition: icon.h:39
Value / variant pair.
Value object encapsulating a list of name/variant pairs.
Generic sequential container with value semantics.
Definition: sequence.h:86
CSequence()=default
Default constructor.
Wrapper around QVariant which provides transparent access to CValueObject methods of the contained ob...
Definition: variant.h:66
CRTP class template from which a derived class can inherit common methods dealing with the metatype o...
Definition: mixinmetatype.h:29
#define SWIFT_MISC_DECLARE_USING_MIXIN_METATYPE(DERIVED)
When a derived class and a base class both inherit from mixin::MetaType, the derived class uses this ...
Free functions in swift::misc.
#define SWIFT_DECLARE_SEQUENCE_MIXINS(Namespace, T, List)
Explicit template declaration of mixins for a CSequence subclass to be placed near the top of the hea...
Definition: sequence.h:62
#define SWIFT_MISC_EXPORT
Export a class or function from the library.