mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-20 20:40:29 +08:00
Ref T472, allow to pass already existing values for model parsing
* list to map: toDbKeyValueMap * categories can also be passed, hence the categories can be seen in model views
This commit is contained in:
committed by
Mat Sutcliffe
parent
7a2ed1433d
commit
9cee34f4cc
@@ -119,6 +119,18 @@ namespace BlackMisc
|
||||
return keys;
|
||||
}
|
||||
|
||||
template <class OBJ, class CONTAINER, typename KEYTYPE>
|
||||
QMap<KEYTYPE, OBJ> IDatastoreObjectList<OBJ, CONTAINER, KEYTYPE>::toDbKeyValueMap() const
|
||||
{
|
||||
QMap<KEYTYPE, OBJ> map;
|
||||
for (const OBJ &obj : ITimestampObjectList<OBJ, CONTAINER>::container())
|
||||
{
|
||||
if (!obj.hasValidDbKey()) { continue; }
|
||||
map.insert(obj.getDbKey(), obj);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
template<class OBJ, class CONTAINER, typename KEYTYPE>
|
||||
QSet<QString> IDatastoreObjectList<OBJ, CONTAINER, KEYTYPE>::toDbKeyStringSet() const
|
||||
{
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "blackmisc/jsonexception.h"
|
||||
#include <QJsonArray>
|
||||
#include <QSet>
|
||||
#include <QMap>
|
||||
#include <QString>
|
||||
|
||||
namespace BlackMisc
|
||||
@@ -48,6 +49,9 @@ namespace BlackMisc
|
||||
//! All keys as set
|
||||
QSet<KEYTYPE> toDbKeySet() const;
|
||||
|
||||
//! As map with DB key/object
|
||||
QMap<KEYTYPE, OBJ> toDbKeyValueMap() const;
|
||||
|
||||
//! All keys as string set (also integer keys will be converted to string)
|
||||
QSet<QString> toDbKeyStringSet() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user