diff options
author | Arno <am@disconnect.de> | 2012-10-06 11:02:42 +0200 |
---|---|---|
committer | Arno <am@disconnect.de> | 2012-10-06 11:02:42 +0200 |
commit | e2d4843586d84da62e325d1cb0025a795b162c1c (patch) | |
tree | 9dd94bf487c4f1d55845854706387512d7279ea2 /smtreemodel.cpp | |
parent | c7caac3459461f93fbae544a501fa491f84e5ce4 (diff) | |
download | SheMov-e2d4843586d84da62e325d1cb0025a795b162c1c.tar.gz SheMov-e2d4843586d84da62e325d1cb0025a795b162c1c.tar.bz2 SheMov-e2d4843586d84da62e325d1cb0025a795b162c1c.zip |
More fixes to MappingTreeModel
Fix move, addChild and such. Rename Fields and Roles to more speaking
names, but that revealed a much deeper bug: the ParentID isn't really
the parent_id, but the mapping_id. That could explain a lot.
Nevertheless, it's still faster to repopulate the model after moving
oder adding children instead of calling removeRows and insertRows.
Another non-working commit... :(
Diffstat (limited to 'smtreemodel.cpp')
-rw-r--r-- | smtreemodel.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/smtreemodel.cpp b/smtreemodel.cpp index 4596a5b..71c815e 100644 --- a/smtreemodel.cpp +++ b/smtreemodel.cpp @@ -143,7 +143,7 @@ QModelIndex SmTreeModel::find(const QVariant &value, int column, const QModelInd for(int i = 0; i < parentItem->childCount(); ++i){ SmTreeItem *child = parentItem->child(i); if(child->data(column) == value){ - return index(i, column, parent); + return index(i, column, parent); } } return QModelIndex(); @@ -200,11 +200,11 @@ void SmTreeModel::reparent(const QModelIndex &idx, const QModelIndex &newParent, if(!idx.isValid()){ return; } - SmTreeItem *item = static_cast<SmTreeItem*>(idx.internalPointer()); - QList<QVariant> data; - for(int i = 0; i < item->columnCount(); ++i){ - data << item->data(i); - } + SmTreeItem *item = static_cast<SmTreeItem*>(idx.internalPointer()); + QList<QVariant> data; + for(int i = 0; i < item->columnCount(); ++i){ + data << item->data(i); + } QPersistentModelIndex pNewParent = newParent; removeRows(idx.row(), 1, idx.parent()); addRow(data, pNewParent, sorted); @@ -218,7 +218,7 @@ bool SmTreeModel::insertRows(int row, int count, const QModelIndex &parent){ return false; } - beginInsertRows(parent, row, row + count - 1); + beginInsertRows(parent, row, row + count - 1); for(int i = row; i < row + count; ++i){ SmTreeItem *newItem = new SmTreeItem(mRootItem->columnCount(), parentItem); retval = parentItem->insertChild(i, newItem); @@ -264,8 +264,8 @@ bool SmTreeModel::addRow(const QList<QVariant> &data, const QModelIndex &parent, for(int i = 0; i < data.count(); ++i){ child->setData(i, data.at(i)); } - QModelIndex start = index(parentItem->childCount() - 1, 0, parent); - QModelIndex end = index(parentItem->childCount() - 1, parentItem->columnCount() - 1, parent); + QModelIndex start = index(parentItem->childCount() - 1, 0, parent); + QModelIndex end = index(parentItem->childCount() - 1, parentItem->columnCount() - 1, parent); emit dataChanged(start, end); return true; } |