diff options
Diffstat (limited to 'mappingtreemodel.cpp')
-rw-r--r-- | mappingtreemodel.cpp | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/mappingtreemodel.cpp b/mappingtreemodel.cpp index ddfd5e2..cf8bfc0 100644 --- a/mappingtreemodel.cpp +++ b/mappingtreemodel.cpp @@ -219,7 +219,7 @@ bool MappingTreeModel::setData(const QModelIndex &index, const QVariant &value, } bool MappingTreeModel::move(const QModelIndex &source, const QModelIndex &dest){ - QVariant sourceId = source.data(DescIdRole); + QVariant sourceId = source.data(MappingIdRole); QVariant destId = dest.data(MappingIdRole); mDb.transaction(); mUpdateParentQ->bindValue(":id", destId); @@ -295,7 +295,7 @@ bool MappingTreeModel::deleteChild(const QModelIndex &idx){ if(item->childCount() > 0){ return false; } - mDeleteMappingParentQ->bindValue(":id", item->data(DescId)); + mDeleteMappingParentQ->bindValue(":id", item->data(MappingId)); if(mDeleteMappingParentQ->exec()){ removeRows(idx.row(), 1, idx.parent()); return true; @@ -311,7 +311,7 @@ MappingData MappingTreeModel::mappingDataFromIndex(QModelIndex &idx) const{ } retval.mappingId = idx.data(MappingTreeModel::MappingIdRole).toInt(); retval.parentId = idx.data(MappingTreeModel::MappingParentIdRole).toInt(); - retval.myId = idx.data(MappingTreeModel::DescIdRole).toInt(); + retval.descId = idx.data(MappingTreeModel::DescIdRole).toInt(); retval.name = idx.data(MappingTreeModel::NameRole).toString(); retval.path << path(idx); return retval; @@ -336,10 +336,10 @@ void MappingTreeModel::populate(){ SmTreeItem *rootItem = new SmTreeItem(NumFields); rootItem->setData(DescId, -1); rootItem->setData(MappingId, -1); - mSeen.clear(); + rootItem->setData(MappingParentId, -1); while(rootQ.next()){ QList<QVariant> childData; - childData << rootQ.value(2) << rootQ.value(1) << rootQ.value(3) << rootQ.value(0) << rootQ.value(4); + childData << rootQ.value(2) << rootQ.value(0) << rootQ.value(3) << rootQ.value(1) << rootQ.value(4); SmTreeItem *childItem = new SmTreeItem(childData, rootItem); rootItem->appendChild(childItem); getChildrenRecursive(childItem); @@ -398,7 +398,6 @@ void MappingTreeModel::getMappingTypes(){ } void MappingTreeModel::getChildrenRecursive(SmTreeItem *item){ - //static QList<QVariant> seenIds; QSqlQuery cq(mDb); cq.prepare(mSParentsQ); cq.bindValue(":type", mType); @@ -406,11 +405,7 @@ void MappingTreeModel::getChildrenRecursive(SmTreeItem *item){ if(cq.exec()){ while(cq.next()){ QList<QVariant> childData; - childData << cq.value(2) << cq.value(1) << cq.value(3) << cq.value(0) << cq.value(4); - if(mSeen.contains(childData.at((DescId)))){ - return; - } - mSeen << childData.at(DescId); + childData << cq.value(2) << cq.value(0) << cq.value(3) << cq.value(1) << cq.value(4); SmTreeItem *child = new SmTreeItem(childData, item); item->appendChild(child); getChildrenRecursive(child); @@ -518,7 +513,7 @@ void MappingTreeResultModel::addItem(const MappingData &data){ if(i == p.count() - 1){ mappingId = data.mappingId; parentId = data.parentId; - myId = data.myId; + myId = data.descId; } QModelIndex curIdx = insertChild(p.at(i), mappingId, parentId, myId, curItem); curItem = itemAt(curIdx); @@ -580,8 +575,8 @@ QList<QVariant> MappingTreeResultModel::columnValuesRecursive(SmTreeItem *parent return retval; } -MappingData::MappingData() : mappingId(-1), parentId(-1), myId(-1) {} +MappingData::MappingData() : mappingId(-1), parentId(-1), descId(-1) {} bool MappingData::isValid(){ - return !(mappingId == -1 && parentId == -1 && myId == -1); + return !(mappingId == -1 && parentId == -1 && descId == -1); } |