summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArno <am@disconnect.de>2014-07-09 14:05:15 +0200
committerArno <am@disconnect.de>2014-07-09 14:05:15 +0200
commit1e84e246d1a4e0b24657e9c416c6ce4a0eb002d5 (patch)
tree1aaad4e6ffacaa13c4fbe0193c892c7e8d7add49
parent7a2c2c37d4324935ea55221b57d1c878fff4860e (diff)
downloadSheMov-1e84e246d1a4e0b24657e9c416c6ce4a0eb002d5.tar.gz
SheMov-1e84e246d1a4e0b24657e9c416c6ce4a0eb002d5.tar.bz2
SheMov-1e84e246d1a4e0b24657e9c416c6ce4a0eb002d5.zip
Fix commit dc7cc269a4fffe43bdac2ae2dc6548fbd1e3bb5e
Since that commit we not only recorded leaves for Mappings, but also the nodes. This is plain wrong, since we build the path/tree ourselves where it matters (e.g. MappingTreeItem). Fix it by checking recursively if the MappingItem has children.
-rw-r--r--mappingtreemodel.cpp13
-rw-r--r--mappingtreemodel.h1
-rw-r--r--newpicsdialog.cpp2
3 files changed, 15 insertions, 1 deletions
diff --git a/mappingtreemodel.cpp b/mappingtreemodel.cpp
index 64de32f..a56f543 100644
--- a/mappingtreemodel.cpp
+++ b/mappingtreemodel.cpp
@@ -473,6 +473,19 @@ void MappingTreeResultModel::removeItem(const QModelIndex &idx){
endResetModel();
}
+QList<QVariant> MappingTreeResultModel::getMappings(SmTreeItem *start) const{
+ QList<QVariant> retval;
+ for(int i = 0; i < start->childCount(); ++i){
+ SmTreeItem *childItem = start->child(i);
+ if(childItem->childCount()){
+ retval.append(getMappings(childItem));
+ }else{
+ retval << childItem->data(MappingId);
+ }
+ }
+ return retval;
+}
+
QList<QVariant> MappingTreeResultModel::columnValues(int column) const {
return columnValuesRecursive(root(), column);
}
diff --git a/mappingtreemodel.h b/mappingtreemodel.h
index 1b5f3ea..6b20dbc 100644
--- a/mappingtreemodel.h
+++ b/mappingtreemodel.h
@@ -85,6 +85,7 @@ class MappingTreeResultModel : public SmTreeModel {
Qt::ItemFlags flags(const QModelIndex &index) const;
virtual QVariant data(const QModelIndex &index, int role) const;
virtual bool setData(const QModelIndex &index, const QVariant &value, int role);
+ QList<QVariant> getMappings(SmTreeItem *start) const;
QList<QVariant> columnValues(int column) const;
void clearData();
diff --git a/newpicsdialog.cpp b/newpicsdialog.cpp
index 2b14c6d..e665f3b 100644
--- a/newpicsdialog.cpp
+++ b/newpicsdialog.cpp
@@ -147,7 +147,7 @@ void NewPicsDialog::accept(){
if(files.isEmpty()){
return QDialog::accept();
}
- QList<QVariant> mappingParentsIds = mMappingEditWidget->model()->columnValues(MappingTreeResultModel::MappingId);
+ QList<QVariant> mappingParentsIds = mMappingEditWidget->model()->getMappings(mMappingEditWidget->model()->root());
QSqlQuery addFileQ(mDb);
addFileQ.prepare("INSERT INTO pics (tfilename, cmd5sum, isize, tformat, cpicsize) VALUES(:fn, :md5, :size, :format, :picsize)");
QSqlQuery addMappingQ(mDb);