void BaseTable::adjustRange(int index) { ColumnDefinition& coldef = columndefinitionRef(index); if (!coldef.isValid()) return; if( hasType(coldef.datadef().domain<>()->ilwisType(), itNUMERICDOMAIN)) { SPNumericRange rng = coldef.datadef().range<NumericRange>(); std::vector<QVariant> values = column(coldef.id()); if ( values.size() > 0 && !rng.isNull()) { double vmin=1e208, vmax=-1e208; bool hasfraction = true; for(const QVariant& var : values ){ double v = var.toDouble(); if ( !isNumericalUndef2(v, this)) vmin = std::min(vmin, v) ; v = var.toDouble(); if (!isNumericalUndef2(v, this)) { vmax = std::max(vmax, v) ; } hasfraction |= (v - (qint64)v != 0); } if ( vmin != 1e208 && vmax != -1e208) { //something has changed rng->min(vmin); rng->max(vmax); if (!hasfraction) rng->resolution(1); } } } else if ( hasType(coldef.datadef().domain<>()->ilwisType(), itITEMDOMAIN)) { SPItemRange rng = coldef.datadef().range<ItemRange>(); SPItemRange rngDomain = coldef.datadef().domain<>()->range<ItemRange>(); std::vector<QVariant> values = column(coldef.id()); if ( values.size() > 0 && !rng.isNull()) { rng->clear(); for(auto qval : values) { quint32 id = qval.toUInt(); SPDomainItem item = rngDomain->item(id); if ( !item.isNull()) { rng->add(item->clone()); } } } } coldef.changed(false); }
QQmlListProperty<DomainItemModel> IlwisObjectModel::domainitems() { IlwisTypes objectype = _ilwisobject->ilwisType(); if ( hasType( objectype, itDOMAIN)){ IDomain domain = _ilwisobject.as<Domain>(); if ( hasType(domain->ilwisType(), itITEMDOMAIN)){ SPItemRange itemrange =domain->range<ItemRange>(); if ( !itemrange.isNull()){ for(auto item : *(itemrange.data())) { if ( item){ DomainItemModel *domainitem = new DomainItemModel(itemrange,item->name(), this); _domainItems.push_back(domainitem); } } if ( _domainItems.size() > 0) return QQmlListProperty<DomainItemModel>(this, _domainItems) ; } } } return QQmlListProperty<DomainItemModel>(); }