diff options
author | Arno <am@disconnect.de> | 2012-10-19 16:03:17 +0200 |
---|---|---|
committer | Arno <am@disconnect.de> | 2012-10-19 16:03:17 +0200 |
commit | c37164306b1cf713e63d607fa1d1e866a5bbaa12 (patch) | |
tree | 0b34ae8337a5d36f0a0cf0e79fffaefc39ebbae0 /pictureviewer2.cpp | |
parent | b185254de61a7b6497d480339a9a38ff94a2cd87 (diff) | |
download | SheMov-c37164306b1cf713e63d607fa1d1e866a5bbaa12.tar.gz SheMov-c37164306b1cf713e63d607fa1d1e866a5bbaa12.tar.bz2 SheMov-c37164306b1cf713e63d607fa1d1e866a5bbaa12.zip |
Keep current Pic when adding files to PicViewer2
Try to get the position of the current picture after adding and clearing
the file list of PictureViewer2. While thinking of using std::find for
this I realized that the operator()-functions in Helper:: weren't used
any more, so remove them and the <algorithm> includes.
Diffstat (limited to 'pictureviewer2.cpp')
-rw-r--r-- | pictureviewer2.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/pictureviewer2.cpp b/pictureviewer2.cpp index ae18a0c..eee61ab 100644 --- a/pictureviewer2.cpp +++ b/pictureviewer2.cpp @@ -73,10 +73,13 @@ PictureViewer2::PictureViewer2(QWidget *parent) : QGraphicsView(parent), mCur(0) } void PictureViewer2::addFiles(const PicDataList &files, bool clear){ + if(files.isEmpty()){ + return; + } + QVariant curMd5 = mFiles.at(mCurPos).at(PicFilesModel::Md5Sum); if(clear){ - mFiles.clear(); mFiles = files; - mCurPos = 0; + }else{ foreach(const PicData &f, files){ if(!mFiles.contains(f)){ @@ -84,7 +87,14 @@ void PictureViewer2::addFiles(const PicDataList &files, bool clear){ } } } - if(!mCurPos >= mFiles.size()){ + mCurPos = 0; + for(int i = 0; i < mFiles.size(); ++i){ + if(mFiles.at(i).at(PicFilesModel::Md5Sum) == curMd5){ + mCurPos = i; + break; + } + } + if(mCurPos < mFiles.size()){ showFile(mFiles.at(mCurPos)); }else{ showFile(mFiles.at(0)); |