16 CPropertyIndexVariantMap::CPropertyIndexVariantMap(
const CPropertyIndex &index,
const CVariant &value)
19 this->addValue(index, value);
22 bool operator==(
const CPropertyIndexVariantMap &a,
const CPropertyIndexVariantMap &b)
24 return a.m_wildcard == b.m_wildcard && a.m_values == b.m_values;
27 bool operator!=(
const CPropertyIndexVariantMap &a,
const CPropertyIndexVariantMap &b) {
return !(b == a); }
29 bool CPropertyIndexVariantMap::matchesVariant(
const CVariant &variant)
const
33 return this->isWildcard();
35 const auto &
map = this->
map();
36 for (
auto it =
map.begin(); it !=
map.end(); ++it)
39 const CVariant p = variant.propertyByIndex(it.key());
40 const CVariant v = it.value();
41 if (p != v)
return false;
46 QString CPropertyIndexVariantMap::convertToQString(
bool i18n)
const
48 if (this->isEmpty())
return QStringLiteral(
"{wildcard: %1}").
arg(m_wildcard ?
"true" :
"false");
52 CVariant v = m_values.value(index);
66 void CPropertyIndexVariantMap::marshallToDbus(
QDBusArgument &argument)
const
68 argument << m_values.keys();
69 argument << m_values.values();
72 void CPropertyIndexVariantMap::unmarshallFromDbus(
const QDBusArgument &argument)
78 Q_ASSERT(indexes.
size() == values.
size());
80 for (
int i = 0; i < indexes.
size(); i++)
82 newMap.
insert(indexes[i], values[i]);
85 m_values.
swap(newMap);
88 void CPropertyIndexVariantMap::marshalToDataStream(
QDataStream &stream)
const
90 stream << m_values.keys();
91 stream << m_values.values();
94 void CPropertyIndexVariantMap::unmarshalFromDataStream(
QDataStream &stream)
100 Q_ASSERT(indexes.
size() == values.
size());
102 for (
int i = 0; i < indexes.
size(); i++)
104 newMap.
insert(indexes[i], values[i]);
107 m_values.
swap(newMap);
110 void CPropertyIndexVariantMap::addValue(
const CPropertyIndex &index,
const CVariant &value)
112 m_values.insert(index, value);
115 void CPropertyIndexVariantMap::addValue(
const CPropertyIndex &index,
const char *str)
117 this->addValue(index,
QString(str));
120 void CPropertyIndexVariantMap::prependIndex(
int index)
123 for (
const CPropertyIndex &pi : this->indexes())
125 CPropertyIndex newPi(pi);
126 newPi.prepend(index);
127 newMap.
insert(newPi, m_values[pi]);
132 CPropertyIndexList CPropertyIndexVariantMap::indexes()
const {
return m_values.
keys(); }
134 int CPropertyIndexVariantMap::size()
const {
return m_values.size(); }
136 size_t CPropertyIndexVariantMap::getValueHash()
const
139 return qHash(this->toQString(
false));
bool operator!=(const AddAtc &lhs, const AddAtc &rhs)
Not equal operator.
CPropertyIndexVariantMap(bool wildcard=false)
Constructor.
Free functions in swift::misc.
auto makeKeysRange(const T &container)
Returns a const CRange for iterating over the keys of a Qt associative container.
qsizetype size() const const
QMap< Key, T >::iterator insert(QMap< Key, T >::const_iterator pos, const Key &key, const T &value)
QList< Key > keys() const const
void swap(QMap< Key, T > &other)
QString & append(QChar ch)
QString arg(Args &&... args) const const
bool isEmpty() const const
QString number(double n, char format, int precision)
QFuture< void > map(Iterator begin, Iterator end, MapFunctor &&function)