diff options
Diffstat (limited to 'smtreemodel.cpp')
-rw-r--r-- | smtreemodel.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/smtreemodel.cpp b/smtreemodel.cpp index 2026902..bc7b010 100644 --- a/smtreemodel.cpp +++ b/smtreemodel.cpp @@ -153,11 +153,11 @@ void SmTreeModel::reparent(const QModelIndex &idx, const QModelIndex &newParent) }else{ parentItem = static_cast<SmTreeItem*>(newParent.internalPointer()); } - removeRows(idx.row(), 1, idx.parent()); QList<QVariant> data; for(int i = 0; i < item->columnCount(); ++i){ data << item->data(i); } + removeRows(idx.row(), 1, idx.parent()); addRow(data, newParent); } @@ -171,7 +171,7 @@ bool SmTreeModel::insertRows(int row, int count, const QModelIndex &parent){ beginInsertRows(parent, row, row + count - 1); for(int i = row; i < row + count; ++i){ - SmTreeItem *newItem = new SmTreeItem(mRootItem->columnCount()); + SmTreeItem *newItem = new SmTreeItem(mRootItem->columnCount(), parentItem); retval = parentItem->insertChild(i, newItem); } endInsertRows(); @@ -204,9 +204,9 @@ bool SmTreeModel::addRow(const QList<QVariant> &data, const QModelIndex &parent) if(insertRows(parentItem->childCount(), 1, parent)){ SmTreeItem *child = parentItem->child(parentItem->childCount() - 1); - delete child; - SmTreeItem *newChild = new SmTreeItem(data, parentItem); - child = newChild; + 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); emit dataChanged(start, end); |