mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-23 13:55:36 +08:00
refs #369, prepend function for properties
This commit is contained in:
@@ -114,4 +114,11 @@ namespace BlackMisc
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CPropertyIndex::prepend(int newLeftIndex)
|
||||||
|
{
|
||||||
|
QList<int> newList = indexList();
|
||||||
|
newList.prepend(newLeftIndex);
|
||||||
|
this->setIndexStringByList(newList);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -90,6 +90,9 @@ namespace BlackMisc
|
|||||||
//! Index list
|
//! Index list
|
||||||
QList<int> indexList() const;
|
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
|
//! First element casted to given type, usually then PropertIndex enum
|
||||||
template<class CastType> CastType frontCasted() const
|
template<class CastType> CastType frontCasted() const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -138,6 +138,18 @@ namespace BlackMisc
|
|||||||
this->addValue(index, QString(str));
|
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
|
* Indexes
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -61,6 +61,9 @@ namespace BlackMisc
|
|||||||
//! Add a value as non CVariant
|
//! 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)); }
|
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?
|
//! Is empty?
|
||||||
bool isEmpty() const { return this->m_values.isEmpty(); }
|
bool isEmpty() const { return this->m_values.isEmpty(); }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user