Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit 4aeef181 authored by EXT Arnaud Clère's avatar EXT Arnaud Clère
Browse files

minor fixes

parent d8ae863d
......@@ -67,24 +67,30 @@ public:
Val<Cursor> meta(QMetaData&& m) { return Cursor(this).value().meta(m); }
protected:
void _meta(QMetaData& meta) {
if (meta.find(qmChildren)!=meta.end()) {
childrenName = meta[qmChildren].toUtf8();
}
if (meta.find(qmColumns)!=meta.end()) {
int i=0;
Q_FOREACH(auto k,meta[qmColumns].split(',')) {
columnNames.append(k.toUtf8());
m->insertColumn(i);
m->setHeaderData(i,Qt::Horizontal,k);
i++;
if (T==d) {
if (meta.find(qmChildren)!=meta.end()) {
childrenName = meta[qmChildren].toUtf8();
}
}
if (meta.find(qmSizes)!=meta.end()) {
Q_FOREACH(auto k,meta[qmSizes].split(',')) {
int i = k.toUtf8().toInt();
if (0<i) sizes.append(i);
if (meta.find(qmColumns)!=meta.end()) {
metaColumnNames=true;
int i=0;
Q_FOREACH(auto k,meta[qmColumns].split(',')) {
m->insertColumn(i);
m->setHeaderData(i,Qt::Horizontal,k);
columnNames.insert(i,k.toUtf8());
i++;
}
}
if (meta.find(qmSizes)!=meta.end()) {
Q_FOREACH(auto k,meta[qmSizes].split(',')) {
int i = k.toUtf8().toInt();
if (0<i) sizes.append(i);
}
}
}
else if (I<=d) {
w._meta(meta);
}
}
bool _null( ) { return hidden() ? true : I<=d ? w._null() : m->setData(current(), QVariant()); }
......@@ -177,9 +183,9 @@ protected:
return true;
}
if (n!=childrenName) {
// TODO if (rowNames...
_reportError(qBindIgnoredItemName);
return true;
// TODO if (rowNames...
_reportError(qBindIgnoredItemName);
return true;
}
}
if (is(C)) { col++; // mandatory after _record()
......@@ -187,20 +193,21 @@ protected:
return true;
}
if (n!=childrenName) {
if (columnNames.isEmpty()) {
if (!metaColumnNames) {
if (!parent.isValid() && row==0) {
int i = m->columnCount(parent); m->insertColumn(i); m->setHeaderData(i,Qt::Horizontal,n);
int i = m->columnCount();
m->insertColumn(i);
m->setHeaderData(i,Qt::Horizontal,n);
columnNames.insert(i,n);
}
}
else {
col=columnNames.indexOf(n);
// TODO if (max(dimension())<=col) col=-1;
if (col<0) {
_reportError(qBindIgnoredItem);
}
return true;
}
// TODO if (max(dimension())<=col) ...
_reportError(qBindIgnoredItemName);
return true;
}
}
......@@ -261,9 +268,8 @@ private:
// Supported QMetaData
QUtf8String childrenName;
QList<QUtf8String> columnNames;
bool metaColumnNames=false;
QVector<int> sizes;
// TODO setHeaderData on 1st item
};
// --------------------------------------------------------------------------
......@@ -63,9 +63,9 @@ protected:
// TODO Support _meta to be able to cache and restitute all metadata as well as data+datatype
template<typename T>
bool _bind ( T&& t) { set(QVariant::fromValue(t)); return true; }
bool _bind ( const char* u) { set(QVariant (u)); return true; }
bool _null ( ) { set(QVariant ( )); return true; }
bool _bind ( T&& t) { set(QVariant::fromValue(t)); return true; }
bool _bind (const char* u) { set(QVariant (u)); return true; }
bool _null ( ) { set(QVariant ( )); return true; }
bool _sequence(quint32* =nullptr) { levels.push(Level(nullptr)); return true; }
bool _record (quint32* =nullptr) { levels.push(Level("" )); return true; }
......@@ -147,9 +147,9 @@ protected:
bool _bind( double& t) { if (current()->type()==qMetaTypeId< float>()||
current()->type()==qMetaTypeId< double>()) { t = current()->value< double>(); return true; } _reportError(qBindExpectedDecimal ); return false; }
bool _sequence(quint32* =nullptr) { if (current()->type()==QVariant::List ) { levels.push(Level()); return true; } _reportError(qBindExpectedSequence); return false; }
bool _record (quint32* =nullptr) { if (current()->type()==QVariant::Map ) { levels.push(Level()); return true; } _reportError(qBindExpectedRecord ); return false; }
bool _null ( ) { if (current()->isNull() ) { return true; } _reportError(qBindExpectedNull ); return false; }
bool _sequence(quint32* =nullptr) { if (current()->type()==QVariant::List ) { levels.push(Level()); return true; } _reportError(qBindExpectedSequence); return false; }
bool _record (quint32* =nullptr) { if (current()->type()==QVariant::Map ) { levels.push(Level()); return true; } _reportError(qBindExpectedRecord ); return false; }
bool _null ( ) { if (current()->isNull() ) { return true; } _reportError(qBindExpectedNull ); return false; }
bool _item(QUtf8String& k) { levels.last().key=k; return (levels.last().item = current(1)->toMap ().value(QString::fromUtf8(levels.last().key), QVariant())).isValid(); }
bool _item( ) { levels.last().idx++; return (levels.last().item = current(1)->toList().value( levels.last().idx , QVariant())).isValid(); }
......
......@@ -690,10 +690,17 @@ int main(int argc, char *argv[])
GROUP_STOP
{
QVector<Person> persons; persons << person << person; persons[0].children.append(person); persons[0].age=42; persons[1].age=41;
// Adapt dataset to different views
person.firstName="";
person.comments="";
person.phones.takeLast();
QVector<Person> persons; persons << person << person;
persons[0].age=42;
persons[0].children.append(person);
persons[1].age=41;
QStandardItemModel treeModel; QModelWriter<>(& treeModel ).meta({{qmChildren,"children"}/*,{qmColumns ,"names,age"}*/}).bind(persons);
QStandardItemModel tableModel; QModelWriter<>(& tableModel ).meta({{qmColumns ,"names,phones,age"}}).bind(persons); // FIXME children mixed with comments when no qmColumns
QStandardItemModel tableModel; QModelWriter<>(& tableModel ).meta({{qmColumns ,"names,age,children"}}).bind(persons);
QStandardItemModel matrixModel; QModelWriter<>(&matrixModel,false).meta({{qmSizes,"4,3"}}).bind(transform);
QDialog dlg;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment