diff options
author | Arno <arno@disconnect.de> | 2015-08-29 11:41:40 +0200 |
---|---|---|
committer | Arno <arno@disconnect.de> | 2015-08-29 11:41:40 +0200 |
commit | b8c44e336b596aa45f4fd4054353912b73b71e66 (patch) | |
tree | 4cf75ee2e5fc3df266b0f0c3c60ff32874189b62 /picfilesmodel.cpp | |
parent | 8044844879f3bdb57f216c5be1499b0af5b5bbb7 (diff) | |
download | SheMov-b8c44e336b596aa45f4fd4054353912b73b71e66.tar.gz SheMov-b8c44e336b596aa45f4fd4054353912b73b71e66.tar.bz2 SheMov-b8c44e336b596aa45f4fd4054353912b73b71e66.zip |
Slide through recent in PictureViewer2
For now, recent is hardcoded to pictures added in the last 6 months.
Maybe it should be configurable...
Diffstat (limited to 'picfilesmodel.cpp')
-rw-r--r-- | picfilesmodel.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/picfilesmodel.cpp b/picfilesmodel.cpp index 3eff4cb..ec1b82d 100644 --- a/picfilesmodel.cpp +++ b/picfilesmodel.cpp @@ -305,6 +305,19 @@ void PicFilesModel::allPicIds(){ cur << q.value(0) << q.value(1) << q.value(2); mAllPics << cur; } + mCurrentPics = &mAllPics; +} + +void PicFilesModel::recentPicIds(){ + mRecentPics.clear(); + mCurrentBatch = 0; + QSqlQuery q("SELECT tfilename, cmd5sum, ipicsid FROM pics WHERE dtadded > now() - interval '6 months' ORDER BY random()", mDb); + while(q.next()){ + QList<QVariant> cur; + cur << q.value(0) << q.value(1) << q.value(2); + mRecentPics << cur; + } + mCurrentPics = &mRecentPics; } QList<QList<QVariant> > PicFilesModel::getNextBatch(){ @@ -312,7 +325,7 @@ QList<QList<QVariant> > PicFilesModel::getNextBatch(){ mCurrentBatch = 0; } int start = mCurrentBatch * 100; - QList<QList<QVariant> > res = mAllPics.mid(start, 100); + QList<QList<QVariant> > res = mCurrentPics->mid(start, 100); QList<QList<QVariant> > retval; for(QList<QList<QVariant> >::const_iterator it = res.constBegin(); it != res.constEnd(); ++it){ QList<QVariant> c = *it; |