mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +08:00
refs #369, prepend function for properties
This commit is contained in:
@@ -114,4 +114,11 @@ namespace BlackMisc
|
||||
return list;
|
||||
}
|
||||
|
||||
void CPropertyIndex::prepend(int newLeftIndex)
|
||||
{
|
||||
QList<int> newList = indexList();
|
||||
newList.prepend(newLeftIndex);
|
||||
this->setIndexStringByList(newList);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -90,6 +90,9 @@ namespace BlackMisc
|
||||
//! Index list
|
||||
QList<int> indexList() const;
|
||||
|
||||
//! Shif existing indexes to right and insert given index at front
|
||||
void prepend(int newLeftIndex);
|
||||
|
||||
//! First element casted to given type, usually then PropertIndex enum
|
||||
template<class CastType> CastType frontCasted() const
|
||||
{
|
||||
|
||||
@@ -138,6 +138,18 @@ namespace BlackMisc
|
||||
this->addValue(index, QString(str));
|
||||
}
|
||||
|
||||
void CPropertyIndexVariantMap::prependIndex(int index)
|
||||
{
|
||||
QMap<CPropertyIndex, CVariant> newMap;
|
||||
for (const CPropertyIndex &pi : this->indexes())
|
||||
{
|
||||
CPropertyIndex newPi(pi);
|
||||
newPi.prepend(index);
|
||||
newMap.insert(newPi, this->m_values[pi]);
|
||||
}
|
||||
this->m_values = newMap;
|
||||
}
|
||||
|
||||
/*
|
||||
* Indexes
|
||||
*/
|
||||
|
||||
@@ -61,6 +61,9 @@ namespace BlackMisc
|
||||
//! Add a value as non CVariant
|
||||
template<class T> void addValue(const CPropertyIndex &index, const T &value) { this->m_values.insert(index, CVariant::fromValue(value)); }
|
||||
|
||||
//! Prepend index to all property indexes
|
||||
void prependIndex(int index);
|
||||
|
||||
//! Is empty?
|
||||
bool isEmpty() const { return this->m_values.isEmpty(); }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user