summaryrefslogtreecommitdiffstats
path: root/smtreemodel.cpp
diff options
context:
space:
mode:
authorArno <am@disconnect.de>2010-07-04 10:13:17 +0200
committerArno <am@disconnect.de>2010-07-04 10:13:17 +0200
commit5dd4fe05df7619fb68356613b698fb373f4fccee (patch)
treed74adce3b2a1c56448e9dea08a23c51f83decedb /smtreemodel.cpp
parent8c6051a16b12f265d7a30b4b24da10b3ba63edae (diff)
downloadSheMov-5dd4fe05df7619fb68356613b698fb373f4fccee.tar.gz
SheMov-5dd4fe05df7619fb68356613b698fb373f4fccee.tar.bz2
SheMov-5dd4fe05df7619fb68356613b698fb373f4fccee.zip
Fix MovieInfoPage
The first page of NewMovieWizard gave me quite a headache. It crashed with a segmentation fault because of exposing mDvdNo via registerField() without actually assigning a QCheckBox to it. The backtrace isn't very helpful in such a case. I also fixed some bugs on the way: 1. use SmTreeItem::setData in SmTreeModel::addRow instead of deleting the old item and creating a new one. This way I don't need to take care of the parent. 2. get data of old item in SmTreeModel::reparent before calling removeRows. This call deletes the item. 3. Fix column alignments in WizardTreeModel for size column
Diffstat (limited to 'smtreemodel.cpp')
-rw-r--r--smtreemodel.cpp10
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);