From 47d30d5f4838a1980545c36308858efc7d5bde0d Mon Sep 17 00:00:00 2001 From: Arno Date: Sun, 22 May 2011 05:54:07 +0200 Subject: Update IsLocal when setting DVD no. The field IsLocal in the SeriesTreeModel is now properly updated when the DVD no. changes. It still doesn't propagate to the file view, though. --- smtreemodel.cpp | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'smtreemodel.cpp') diff --git a/smtreemodel.cpp b/smtreemodel.cpp index 8b51bab..bcd1a8a 100644 --- a/smtreemodel.cpp +++ b/smtreemodel.cpp @@ -136,6 +136,26 @@ QModelIndex SmTreeModel::find(const QVariant &value, int column, const QModelInd return QModelIndex(); } +QModelIndex SmTreeModel::findRecursive(const QVariant &value, int column, const QModelIndex &parent) const{ + SmTreeItem *parentItem = 0; + if(!parent.isValid()){ + return QModelIndex(); + }else{ + parentItem = static_cast(parent.internalPointer()); + } + for(int i = 0; i < parentItem->childCount(); ++i){ + SmTreeItem *child = parentItem->child(i); + if(child->childCount()){ + return findRecursive(value, column, createIndex(i, column, child)); + } + if(child->data(column) == value){ + return createIndex(i, column, child); + } + } + QModelIndex next = index(parent.row() + 1, column, parent.parent()); + return findRecursive(value, column, next); +} + bool SmTreeModel::setRoot(SmTreeItem *rootItem){ if(mRootItem){ beginResetModel(); @@ -159,13 +179,7 @@ void SmTreeModel::reparent(const QModelIndex &idx, const QModelIndex &newParent) if(!idx.isValid()){ return; } - SmTreeItem *parentItem = 0; SmTreeItem *item = static_cast(idx.internalPointer()); - if(newParent == QModelIndex()){ - parentItem = root(); - }else{ - parentItem = static_cast(newParent.internalPointer()); - } QList data; for(int i = 0; i < item->columnCount(); ++i){ data << item->data(i); -- cgit v1.2.3-70-g09d2