summaryrefslogtreecommitdiffstats
path: root/smtreemodel.cpp
diff options
context:
space:
mode:
authorArno <am@disconnect.de>2011-05-22 05:54:07 +0200
committerArno <am@disconnect.de>2011-05-22 05:54:07 +0200
commit47d30d5f4838a1980545c36308858efc7d5bde0d (patch)
treeb1137fa0db924409df7eda40f8ed08e5fa30ae1e /smtreemodel.cpp
parent9b2f7da813faea42587c0a78435a41aa338471fe (diff)
downloadSheMov-47d30d5f4838a1980545c36308858efc7d5bde0d.tar.gz
SheMov-47d30d5f4838a1980545c36308858efc7d5bde0d.tar.bz2
SheMov-47d30d5f4838a1980545c36308858efc7d5bde0d.zip
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.
Diffstat (limited to 'smtreemodel.cpp')
-rw-r--r--smtreemodel.cpp26
1 files changed, 20 insertions, 6 deletions
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<SmTreeItem*>(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<SmTreeItem*>(idx.internalPointer());
- if(newParent == QModelIndex()){
- parentItem = root();
- }else{
- parentItem = static_cast<SmTreeItem*>(newParent.internalPointer());
- }
QList<QVariant> data;
for(int i = 0; i < item->columnCount(); ++i){
data << item->data(i);