diff options
author | Arno <am@disconnect.de> | 2012-03-18 03:52:00 +0100 |
---|---|---|
committer | Arno <am@disconnect.de> | 2012-03-18 03:52:00 +0100 |
commit | 6fc9473ea5b84702cc5f07bc405394bddfccf5ac (patch) | |
tree | a9154aa8dfaf9d076c24b75da39adec36c185888 | |
parent | 6c97f7d9eef744ce1da03f4d203af2307b08f6eb (diff) | |
download | SheMov-6fc9473ea5b84702cc5f07bc405394bddfccf5ac.tar.gz SheMov-6fc9473ea5b84702cc5f07bc405394bddfccf5ac.tar.bz2 SheMov-6fc9473ea5b84702cc5f07bc405394bddfccf5ac.zip |
Save settings for PicturesWidget
Remember selected node in PicturesWidget.
-rw-r--r-- | mappingtreemodel.cpp | 2 | ||||
-rw-r--r-- | mappingtreemodel.h | 2 | ||||
-rw-r--r-- | mappingtreewidget.cpp | 9 | ||||
-rw-r--r-- | mappingtreewidget.h | 1 | ||||
-rw-r--r-- | pictureswidget.cpp | 14 | ||||
-rw-r--r-- | pictureswidget.h | 2 | ||||
-rw-r--r-- | shemov.cpp | 1 |
7 files changed, 29 insertions, 2 deletions
diff --git a/mappingtreemodel.cpp b/mappingtreemodel.cpp index 9b849d9..42c1380 100644 --- a/mappingtreemodel.cpp +++ b/mappingtreemodel.cpp @@ -118,7 +118,7 @@ QList<QVariant> MappingTreeModel::childList(const QVariant &value, int column) c return QList<QVariant>() << value; } -QModelIndex MappingTreeModel::indexFromPath(QString &path, int column) const{ +QModelIndex MappingTreeModel::indexFromPath(const QString &path, int column) const{ QStringList items = path.split("/"); if(items.isEmpty() || column >= NumFields){ return QModelIndex(); diff --git a/mappingtreemodel.h b/mappingtreemodel.h index 7a3b5fe..c1b6248 100644 --- a/mappingtreemodel.h +++ b/mappingtreemodel.h @@ -35,7 +35,7 @@ class MappingTreeModel : public SmTreeModel { //data QVariant data(const QModelIndex &index, int role) const; QList<QVariant> childList(const QVariant &value, int column = 0) const; - QModelIndex indexFromPath(QString &path, int column = 0) const; + QModelIndex indexFromPath(const QString &path, int column = 0) const; bool setData(const QModelIndex &index, const QVariant &value, int role); void move(const QModelIndex &source, const QModelIndex &dest); bool addMappingType(const QString &type); diff --git a/mappingtreewidget.cpp b/mappingtreewidget.cpp index 22a9757..27d14d3 100644 --- a/mappingtreewidget.cpp +++ b/mappingtreewidget.cpp @@ -182,6 +182,15 @@ void MappingTreeWidget::deleteType(){ } } +void MappingTreeWidget::selectPath(const QString &path){ + QModelIndex pathIdx = mModel->indexFromPath(path); + if(!pathIdx.isValid()){ + return; + } + QModelIndex real = mProxy->mapFromSource(pathIdx); + mTree->setCurrentIndex(real); +} + void MappingTreeWidget::hideEvent(QHideEvent *event){ QString type = mTypeBox->currentText(); if(!type.isEmpty()){ diff --git a/mappingtreewidget.h b/mappingtreewidget.h index e110d6e..ae0f81e 100644 --- a/mappingtreewidget.h +++ b/mappingtreewidget.h @@ -35,6 +35,7 @@ class MappingTreeWidget : public QWidget { void addType(); void deleteChild(); void deleteType(); + void selectPath(const QString &path); protected: virtual void hideEvent(QHideEvent *event); diff --git a/pictureswidget.cpp b/pictureswidget.cpp index afce0e4..e26dc7f 100644 --- a/pictureswidget.cpp +++ b/pictureswidget.cpp @@ -18,6 +18,7 @@ #include <QMessageBox> #include <QMenu> #include <QFile> +#include <QSettings> #include "pictureswidget.h" #include "mappingtreewidget.h" @@ -51,12 +52,25 @@ PicturesWidget::PicturesWidget(QWidget *parent) : QWidget(parent), mWindowTitleB QHBoxLayout *mainLayout = new QHBoxLayout; mainLayout->addWidget(splitter); setLayout(mainLayout); + readSettings(); } void PicturesWidget::showPicViewer(bool toggled){ mPicViewer->setVisible(toggled); } +void PicturesWidget::writeSettings(){ + QSettings s; + MappingData selected = mMappingTree->selectedItem(); + s.setValue("ui/selectedmapping", selected.path); +} + +void PicturesWidget::readSettings(){ + QSettings s; + QStringList selPath = s.value("ui/selectedmapping").toStringList(); + mMappingTree->selectPath(selPath.join("/")); +} + void PicturesWidget::editMappings(){ QList<int> currentMappings = mPictureView->fileMappings(); mEditDialog->editWidget()->setMappings(currentMappings); diff --git a/pictureswidget.h b/pictureswidget.h index a8463a4..3d11c80 100644 --- a/pictureswidget.h +++ b/pictureswidget.h @@ -39,6 +39,8 @@ class PicturesWidget : public QWidget { public slots: void showPicViewer(bool toggled); + void writeSettings(); + void readSettings(); private slots: void editMappings(); @@ -139,6 +139,7 @@ void SheMov::closeEvent(QCloseEvent *event){ mFSWidget->pictureViewer()->close(); mATree->seriesWidget()->writeSettings(); mPicWidget->picViewer2()->writeSettings(); + mPicWidget->writeSettings(); FilesTreeModel *filesModel = static_cast<FilesTreeModel*>(SmGlobals::instance()->model("FilesModel")); filesModel->writeCache(); writeSettings(); |