diff options
author | Arno <am@disconnect.de> | 2012-10-27 13:39:25 +0200 |
---|---|---|
committer | Arno <am@disconnect.de> | 2012-10-27 13:39:25 +0200 |
commit | 97e8c68d7a92d6ccdb5f6ead8bba0d0af58efb3b (patch) | |
tree | 9cf27100410fe74b4794927ef1171301b7a1ceb5 | |
parent | dc7cc269a4fffe43bdac2ae2dc6548fbd1e3bb5e (diff) | |
download | SheMov-97e8c68d7a92d6ccdb5f6ead8bba0d0af58efb3b.tar.gz SheMov-97e8c68d7a92d6ccdb5f6ead8bba0d0af58efb3b.tar.bz2 SheMov-97e8c68d7a92d6ccdb5f6ead8bba0d0af58efb3b.zip |
Bugfixes: don't select dirs and don't crash on write settings
Only select files when archiving pics from filemanager. While at it, I
noticed a crash on close when no item is selected in PicturesWidget. So
check if MappingData is valid on writing settings. Best way is
MappingData::isValid(), and for that I needed a explicit constructor.
-rw-r--r-- | mappingtreemodel.cpp | 8 | ||||
-rw-r--r-- | mappingtreemodel.h | 2 | ||||
-rw-r--r-- | mappingtreewidget.cpp | 5 | ||||
-rw-r--r-- | newpicsdialog.cpp | 2 | ||||
-rw-r--r-- | pictureswidget.cpp | 4 |
5 files changed, 15 insertions, 6 deletions
diff --git a/mappingtreemodel.cpp b/mappingtreemodel.cpp index 2c636e6..80085c3 100644 --- a/mappingtreemodel.cpp +++ b/mappingtreemodel.cpp @@ -305,7 +305,7 @@ bool MappingTreeModel::deleteChild(const QModelIndex &idx){ } MappingData MappingTreeModel::mappingDataFromIndex(QModelIndex &idx) const{ - MappingData retval = { -1, -1, -1, QString(), QList<QStringList>() }; + MappingData retval; if(!idx.isValid()){ return retval; } @@ -579,3 +579,9 @@ QList<QVariant> MappingTreeResultModel::columnValuesRecursive(SmTreeItem *parent } return retval; } + +MappingData::MappingData() : mappingId(-1), parentId(-1), myId(-1) {} + +bool MappingData::isValid(){ + return !(mappingId == -1 && parentId == -1 && myId == -1); +} diff --git a/mappingtreemodel.h b/mappingtreemodel.h index a4a1ae8..fa91a78 100644 --- a/mappingtreemodel.h +++ b/mappingtreemodel.h @@ -117,6 +117,8 @@ class MappingTreeResultModel : public SmTreeModel { }; struct MappingData { + MappingData(); + bool isValid(); int mappingId; int parentId; int myId; diff --git a/mappingtreewidget.cpp b/mappingtreewidget.cpp index e9d0c93..fd3ebe6 100644 --- a/mappingtreewidget.cpp +++ b/mappingtreewidget.cpp @@ -94,13 +94,12 @@ MappingTreeWidget::MappingTreeWidget(QWidget *parent) : QWidget(parent){ } MappingData MappingTreeWidget::selectedItem() const { - MappingData retval = { -1, -1, -1, QString(), QList<QStringList>() }; QModelIndex sel = selected(); if(!sel.isValid()){ - return retval; + return MappingData(); } QModelIndex real = mProxy->mapToSource(sel); - return mModel->mappingDataFromIndex(real); + return mModel->mappingDataFromIndex(real); } void MappingTreeWidget::addChild(){ diff --git a/newpicsdialog.cpp b/newpicsdialog.cpp index 0ededef..272bf2d 100644 --- a/newpicsdialog.cpp +++ b/newpicsdialog.cpp @@ -272,7 +272,7 @@ void NewPicFilesModel::setFiles(const QStringList &paths) { void NewPicFilesModel::addFile(const QString &path){ QFileInfo fi(path); - if(!fi.exists()){ + if(!fi.exists() || !fi.isFile()){ return; } QString md5 = Helper::md5Sum(fi.absoluteFilePath()); diff --git a/pictureswidget.cpp b/pictureswidget.cpp index 92b0490..54d86e2 100644 --- a/pictureswidget.cpp +++ b/pictureswidget.cpp @@ -64,7 +64,9 @@ void PicturesWidget::showPicViewer(bool toggled){ void PicturesWidget::writeSettings(){ QSettings s; MappingData selected = mMappingTree->selectedItem(); - s.setValue("ui/selectedmapping", selected.path.first()); + if(selected.isValid()){ + s.setValue("ui/selectedmapping", selected.path.first()); + } mPictureView->writeHeaderConfig(); } |