swift
Loading...
Searching...
No Matches
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"
14#include "misc/sequence.h"
16#include "misc/variant.h"
17
18SWIFT_DECLARE_SEQUENCE_MIXINS(swift::misc, CNameVariantPair, CNameVariantPairList)
19
20namespace 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
62Q_DECLARE_METATYPE(swift::misc::CNameVariantPairList)
64
65#endif // SWIFT_MISC_NAMEVARIANPAIRTLIST_H
Generic ordered container with value semantics.
Definition collection.h:113
Value object for icons. An icon is stored in the global icon repository and identified by its index....
Definition icon.h:39
Value object encapsulating a list of name/variant pairs.
QStringList getNames(bool sorted=true) const
Get all names.
CNameVariantPair getValue(const QString &name) const
Get value.
int getIndexForName(const QString &name) const
Get name's index, -1 if not found.
CSequence()=default
Default constructor.
CVariant getVariantValue(const QString &name) const
Get pair's variant value or default if not existing.
QString getValueAsString(const QString &name) const
Get pair's variant value as string (empty if not existing).
bool addOrReplaceValue(const QString &name, const CVariant &value, const CIcon &icon=CIcon())
Add value, if name already exists replace (true) If one is sure(!) the name does not exists,...
bool containsName(const QString &name) const
Contains name.
CNameVariantPairList()=default
Default constructor.
CSequence()=default
Default constructor.
Q_REQUIRED_RESULT CSequence sorted(Predicate p) const
Definition sequence.h:610
Wrapper around QVariant which provides transparent access to CValueObject methods of the contained ob...
Definition variant.h:69
CRTP class template from which a derived class can inherit common methods dealing with the metatype o...
#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.