MythTV  master
galleryviews.cpp
Go to the documentation of this file.
1 #include "galleryviews.h"
2 
3 #include <cmath> // for qsrand
4 #include <random>
5 #if QT_VERSION >= QT_VERSION_CHECK(5,10,0)
6 #include <QRandomGenerator>
7 #endif
8 
9 #define LOC QString("Galleryviews: ")
10 
12 const static int kMaxFolderThumbnails = 4;
13 
20 const double LEADING_BETA_SHAPE = 0.175;
22 const double TRAILING_BETA_SHAPE = 0.31;
23 
25 const double DEFAULT_WEIGHT = std::pow(0.5, TRAILING_BETA_SHAPE - 1) *
26  std::pow(0.5, LEADING_BETA_SHAPE - 1);
28 const qint64 BETA_CLIP = 60 * 60 * 24;
29 
30 void MarkedFiles::Add(const ImageIdList& newIds)
31 {
32  for (int newid : newIds)
33  insert(newid);
34 }
35 
37 {
38  QSet tmp;
39  for (int tmpint : all)
40  tmp.insert(tmpint);
41  for (int tmpint : qAsConst(*this))
42  tmp.remove(tmpint);
43  swap(tmp);
44 }
45 
51 {
52  ImageListK files;
53  for (int id : qAsConst(m_sequence))
54  files.append(m_images.value(id));
55  return files;
56 }
57 
58 
64 {
65  return m_active < 0 || m_active >= m_sequence.size()
66  ? ImagePtrK() : m_images.value(m_sequence.at(m_active));
67 }
68 
69 
74 QString FlatView::GetPosition() const
75 {
76  return QString("%1/%2").arg(m_active + 1).arg(m_sequence.size());
77 }
78 
79 
85 bool FlatView::Update(int id)
86 {
87  ImagePtrK im = m_images.value(id);
88  if (!im)
89  return false;
90 
91  // Get updated image
92  ImageList files;
93  ImageList dirs;
94  ImageIdList ids = ImageIdList() << id;
95  if (m_mgr.GetImages(ids, files, dirs) != 1 || files.size() != 1)
96  return false;
97 
98  bool active = (im == GetSelected());
99 
100  // Replace image
101  m_images.insert(id, files.at(0));
102 
103  LOG(VB_FILE, LOG_DEBUG, LOC + QString("Modified id %1").arg(id));
104 
105  return active;
106 }
107 
108 
116 bool FlatView::Select(int id, int fallback)
117 {
118  // Select first appearance of image
119  int index = m_sequence.indexOf(id);
120  if (index >= 0)
121  {
122  m_active = index;
123  return true;
124  }
125 
126  if (fallback >= 0)
127  m_active = fallback;
128 
129  return false;
130 }
131 
132 
137 void FlatView::Clear(bool resetParent)
138 {
139  m_images.clear();
140  m_sequence.clear();
141  m_active = -1;
142  if (resetParent)
144 }
145 
146 
152 {
153  return m_sequence.isEmpty() || m_active + inc >= m_sequence.size()
154  ? ImagePtrK() : m_images.value(m_sequence.at(m_active + inc));
155 }
156 
157 
164 {
165  if (m_sequence.isEmpty())
166  return ImagePtrK();
167 
168  // Preserve index as it may be reset when wrapping
169  int next = m_active + inc;
170 
171  // Regenerate unordered views when wrapping
172  if (next >= m_sequence.size() && m_order != kOrdered && !LoadFromDb(m_parentId))
173  // Images have disappeared
174  return ImagePtrK();
175 
176  m_active = next % m_sequence.size();
177  return m_images.value(m_sequence.at(m_active));
178 }
179 
180 
186 {
187  return m_sequence.isEmpty() || m_active < inc
188  ? ImagePtrK() : m_images.value(m_sequence.at(m_active - inc));
189 }
190 
191 
197 {
198  if (m_sequence.isEmpty())
199  return ImagePtrK();
200 
201  // Wrap avoiding modulo of negative uncertainty
202  m_active -= inc % m_sequence.size();
203  if (m_active < 0)
204  m_active += m_sequence.size();
205 
206  return m_images.value(m_sequence.at(m_active));
207 }
208 
209 
215 {
216  // Do not reset parent
217  Clear(false);
218 
219  if (files.isEmpty())
220  return;
221 
222  for (const QSharedPointer<ImageItem> & im : qAsConst(files))
223  {
224  // Add image to view
225  m_images.insert(im->m_id, im);
226 
227  // Cache all displayed images
228  if (im->IsFile())
229  Cache(im->m_id, im->m_parentId, im->m_url, im->m_thumbNails.at(0).second);
230  }
231 
232  if (files.size() == 1 || m_order == kOrdered || m_order == kShuffle)
233  {
234  // Default sequence is ordered
235  for (const QSharedPointer<ImageItem> & im : qAsConst(files))
236  m_sequence.append(im->m_id);
237  }
238 
239  if (files.size() > 1)
240  {
241  // Modify viewing sequence
242  if (m_order == kShuffle)
243  {
244  std::shuffle(m_sequence.begin(), m_sequence.end(),
245  std::mt19937(std::random_device()()));
246  }
247  else if (m_order == kRandom)
248  {
249 #if QT_VERSION >= QT_VERSION_CHECK(5,10,0)
250  QVector<quint32> rands;
251  rands.resize(files.size());
252  QRandomGenerator::global()->fillRange(rands.data(), rands.size());
253 #else
254  qsrand(QTime::currentTime().msec());
255 #endif
256  // An image is not a valid candidate for its successor
257  int range = files.size() - 1;
258  int index = range;
259  for (int count = 0; count < files.size(); ++count)
260  {
261 #if QT_VERSION >= QT_VERSION_CHECK(5,10,0)
262  int rand = rands[count] % range;
263 #else
264  int rand = qrand() % range;
265 #endif
266  // Avoid consecutive repeats
267  index = (rand < index) ? rand : rand + 1;
268  m_sequence.append(files.at(index)->m_id);
269  }
270  }
271  else if (m_order == kSeasonal)
272  {
273  WeightList weights = CalculateSeasonalWeights(files);
274  double maxWeight = weights.last();
275 
276 #if QT_VERSION >= QT_VERSION_CHECK(5,10,0)
277  auto *randgen = QRandomGenerator::global();
278 #else
279  qsrand(QTime::currentTime().msec());
280 #endif
281  for (int count = 0; count < files.size(); ++count)
282  {
283 #if QT_VERSION >= QT_VERSION_CHECK(5,10,0)
284  // generateDouble() returns in the range [0, 1)
285  double randWeight = randgen->generateDouble() * maxWeight;
286 #else
287  double randWeight = qrand() * maxWeight / RAND_MAX;
288 #endif
289  WeightList::iterator it =
290  std::upper_bound(weights.begin(), weights.end(), randWeight);
291  int index = std::distance(weights.begin(), it);
292  m_sequence.append(files.at(index)->m_id);
293  }
294  }
295  }
296 }
297 
298 
310 {
311  WeightList weights(files.size());
312  double totalWeight = 0;
313  QDateTime now = QDateTime::currentDateTime();
314 
315  for (int i = 0; i < files.size(); ++i)
316  {
317  ImagePtrK im = files.at(i);
318  double weight = 0;
319 
320  if (im->m_date == 0)
321  weight = DEFAULT_WEIGHT;
322  else
323  {
324  QDateTime timestamp = QDateTime::fromSecsSinceEpoch(im->m_date);
325  QDateTime curYearAnniversary =
326  QDateTime(QDate(now.date().year(),
327  timestamp.date().month(),
328  timestamp.date().day()),
329  timestamp.time());
330 
331  bool isAnniversaryPast = curYearAnniversary < now;
332 
333  QDateTime adjacentYearAnniversary =
334  QDateTime(QDate(now.date().year() +
335  (isAnniversaryPast ? 1 : -1),
336  timestamp.date().month(),
337  timestamp.date().day()),
338  timestamp.time());
339 
340  double range = llabs(curYearAnniversary.secsTo(
341  adjacentYearAnniversary)) + BETA_CLIP;
342 
343  // This calculation is not normalized, because that would require the
344  // beta function, which isn't part of the C++98 libraries. Weights
345  // that aren't normalized work just as well relative to each other.
346  QDateTime d1(isAnniversaryPast ? curYearAnniversary
347  : adjacentYearAnniversary);
348  QDateTime d2(isAnniversaryPast ? adjacentYearAnniversary
349  : curYearAnniversary);
350  weight = std::pow(llabs(now.secsTo(d1) + BETA_CLIP) / range,
352  * std::pow(llabs(now.secsTo(d2) + BETA_CLIP) / range,
353  LEADING_BETA_SHAPE - 1);
354  }
355  totalWeight += weight;
356  weights[i] = totalWeight;
357  }
358  return weights;
359 }
360 
361 
368 bool FlatView::LoadFromDb(int parentId)
369 {
370  m_parentId = parentId;
371 
372  // Load child images of the parent
373  ImageList files;
374  ImageList dirs;
375  m_mgr.GetChildren(m_parentId, files, dirs);
376 
377  // Load gallery datastore with current dir
378  Populate(files);
379 
380  return !files.isEmpty();
381 }
382 
383 
388 {
389  LOG(VB_FILE, LOG_DEBUG, LOC + "Cleared File cache");
390  m_fileCache.clear();
391 }
392 
393 
400 QStringList FlatView::ClearImage(int id, bool remove)
401 {
402  if (remove)
403  {
404  m_sequence.removeAll(id);
405  m_images.remove(id);
406  }
407 
408  QStringList urls;
409  FileCacheEntry file = m_fileCache.take(id);
410 
411  if (!file.m_url.isEmpty())
412  urls << file.m_url;
413 
414  if (!file.m_thumbUrl.isEmpty())
415  urls << file.m_thumbUrl;
416 
417  LOG(VB_FILE, LOG_DEBUG, LOC + QString("Cleared %1 from file cache (%2)")
418  .arg(id).arg(urls.join(",")));
419  return urls;
420 }
421 
422 
427 void FlatView::Rotate(int id)
428 {
429  // Rotate sequence so that (first appearance of) specified image is
430  // at offset from front
431  int index = m_sequence.indexOf(id);
432  if (index >= 0)
433  {
434  int first = index % m_sequence.size();
435  if (first > 0)
436  m_sequence = m_sequence.mid(first) + m_sequence.mid(0, first);
437  }
438 }
439 
440 
448 void FlatView::Cache(int id, int parent, const QString &url, const QString &thumb)
449 {
450  // Cache parent dir so that dir thumbs are updated when a child changes.
451  // Also store urls for image cache cleanup
452  FileCacheEntry cached(parent, url, thumb);
453  m_fileCache.insert(id, cached);
454  LOG(VB_FILE, LOG_DEBUG, LOC + "Caching " + cached.ToString(id));
455 }
456 
457 
458 QString DirCacheEntry::ToString(int id) const
459 {
460  QStringList ids;
461  for (const auto & thumb : qAsConst(m_thumbs))
462  ids << QString::number(thumb.first);
463  return QString("Dir %1 (%2, %3) Thumbs %4 (%5) Parent %6")
464  .arg(id).arg(m_fileCount).arg(m_dirCount).arg(ids.join(","))
465  .arg(m_thumbCount).arg(m_parent);
466 }
467 
468 
474  : FlatView(order)
475 {
476  m_marked.Clear();
478 }
479 
480 
486 {
487  return QString("%1/%2").arg(m_active).arg(m_sequence.size() - 1);
488 }
489 
490 
499 bool DirectoryView::LoadFromDb(int parentId)
500 {
501  // Determine parent (defaulting to ancestor) & get initial children
502  ImageList files;
503  ImageList dirs;
504  ImagePtr parent;
505  int count = 0;
506  // Root is guaranteed to return at least 1 item
507  while ((count = m_mgr.GetDirectory(parentId, parent, files, dirs)) == 0)
508  {
509  // Fallback if dir no longer exists
510  // Ascend to Gallery for gallery subdirs, Root for device dirs & Gallery
511  parentId = parentId > PHOTO_DB_ID ? PHOTO_DB_ID : GALLERY_DB_ID;
512  }
513 
514  SetDirectory(parentId);
515  m_parentId = parentId;
516 
517  // No SG & no devices uses special 'empty' screen
518  if (!parent || (parentId == GALLERY_DB_ID && count == 1))
519  {
520  parent.clear();
521  return false;
522  }
523 
524  // Populate all subdirs
525  for (const ImagePtr & im : qAsConst(dirs))
526  {
527  if (im)
528  // Load sufficient thumbs from each dir as subsequent dirs may be empty
530  }
531 
532  // Populate parent
534  PopulateThumbs(*parent, kMaxFolderThumbnails, files, dirs);
535 
536  // Dirs shown before images
537  ImageList images = dirs + files;
538 
539  // Validate marked images
540  if (!m_marked.isEmpty())
541  {
542  QSet<int> ids;
543  for (const QSharedPointer<ImageItem> & im : qAsConst(images))
544  ids.insert(im->m_id);
545  m_marked.intersect(ids);
546  }
547 
548  // Parent is always first (for navigating up).
549  images.prepend(parent);
550 
551  // Preserve current selection before view is destroyed
552  ImagePtrK selected = GetSelected();
553  int activeId = selected ? selected->m_id : 0;
554 
555  // Construct view
556  Populate(images);
557 
558  // Reinstate selection, falling back to parent
559  Select(activeId);
560 
561  return true;
562 }
563 
564 
571 void DirectoryView::LoadDirThumbs(ImageItem &parent, int thumbsNeeded, int level)
572 {
573  // Use cached data, if available
574  if (PopulateFromCache(parent, thumbsNeeded))
575  return;
576 
577  // Load child images & dirs
578  ImageList files;
579  ImageList dirs;
580  m_mgr.GetChildren(parent.m_id, files, dirs);
581 
582  PopulateThumbs(parent, thumbsNeeded, files, dirs, level);
583 }
584 
585 
596 void DirectoryView::PopulateThumbs(ImageItem &parent, int thumbsNeeded,
597  const ImageList &files, const ImageList &dirs,
598  int level)
599 {
600  // Set parent stats
601  parent.m_fileCount = files.size();
602  parent.m_dirCount = dirs.size();
603 
604  // Locate user assigned thumb amongst children, if defined
605  ImagePtr userIm;
606  if (parent.m_userThumbnail != 0)
607  {
608  ImageList images = files + dirs;
609  for (const ImagePtr & im : qAsConst(images))
610  {
611  if (im && im->m_id == parent.m_userThumbnail)
612  {
613  userIm = im;
614  break;
615  }
616  }
617  }
618 
619  // Children to use as thumbnails
620  ImageList thumbFiles;
621  ImageList thumbDirs;
622 
623  if (!userIm)
624  {
625  // Construct multi-thumbnail from all children
626  thumbFiles = files;
627  thumbDirs = dirs;
628  }
629  else if (userIm->IsFile())
630  {
631  thumbFiles.append(userIm);
632  thumbsNeeded = 1;
633  }
634  else
635  thumbDirs.append(userIm);
636 
637  // Fill parent thumbs from child files first
638  // Whilst they're available fill as many as possible for cache
639  for (int i = 0; i < qMin(kMaxFolderThumbnails, thumbFiles.size()); ++i)
640  {
641  parent.m_thumbNails.append(thumbFiles.at(i)->m_thumbNails.at(0));
642  --thumbsNeeded;
643  }
644 
645  // Only recurse if necessary
646  if (thumbsNeeded > 0)
647  {
648  // Prevent lengthy/infinite recursion due to deep/cyclic folder
649  // structures
650  if (++level > 10)
651  {
652  LOG(VB_GENERAL, LOG_NOTICE, LOC +
653  "Directory thumbnails are more than 10 levels deep");
654  }
655  else
656  {
657  // Recursively load subdir thumbs to try to get 1 thumb from each
658  for (const ImagePtr & im : qAsConst(thumbDirs))
659  {
660  if (!im)
661  continue;
662 
663  // Load sufficient thumbs from each dir as subsequent dirs may
664  // be empty
665  LoadDirThumbs(*im, thumbsNeeded, level);
666 
667  if (!im->m_thumbNails.empty())
668  {
669  // Add first thumbnail to parent thumb
670  parent.m_thumbNails.append(im->m_thumbNails.at(0));
671 
672  // Quit when we have sufficient thumbs
673  if (--thumbsNeeded == 0)
674  break;
675  }
676  }
677 
678  // If insufficient dirs to supply 1 thumb per dir, use other dir
679  // thumbs (indices 1-3) as well
680  int i = 0;
681  while (thumbsNeeded > 0 && ++i < kMaxFolderThumbnails)
682  {
683  for (const QSharedPointer<ImageItem> & im : qAsConst(thumbDirs))
684  {
685  if (i < im->m_thumbNails.size())
686  {
687  parent.m_thumbNails.append(im->m_thumbNails.at(i));
688  if (--thumbsNeeded == 0)
689  break;
690  }
691  }
692  }
693  }
694  }
695 
696  // Flag the cached entry with number of thumbs loaded. If future uses require
697  // more, then the dir must be reloaded.
698  // For user thumbs and dirs with insufficient child images, the cache is always valid
699  int scanned = (userIm || thumbsNeeded > 0)
701  : parent.m_thumbNails.size();
702 
703  // Cache result to optimize navigation
704  Cache(parent, scanned);
705 }
706 
707 
712 void DirectoryView::Clear(bool /*resetParent*/)
713 {
714  ClearMarked();
715  ClearCache();
716  FlatView::Clear();
717 }
718 
719 
724 {
725  // Any marking clears previous marks
728 }
729 
730 
736 void DirectoryView::Mark(int id, bool mark)
737 {
738  if (mark)
739  {
740  // Any marking clears previous marks
742  m_marked.Add(id);
743  }
744  else
745  {
746  m_prevMarked.remove(id);
747  m_marked.remove(id);
748  }
749 }
750 
751 
756 {
757  // Any marking clears previous marks
760 }
761 
762 
767 {
768  m_marked.Clear();
770 }
771 
772 
777 void DirectoryView::SetDirectory(int newParent)
778 {
779  if (m_marked.IsFor(newParent))
780  // Directory hasn't changed
781  return;
782 
783  // Markings are cleared on every dir change
784  // Any current markings become previous markings
785  // Only 1 set of previous markings are preserved
786  if (m_prevMarked.IsFor(newParent))
787  {
788  // Returned to dir of previous markings: reinstate them
791  return;
792  }
793 
794  if (!m_marked.isEmpty())
795  // Preserve current markings
797 
798  // Initialise current markings for new dir
799  m_marked.Initialise(newParent);
800 }
801 
802 
808 {
809  // hiddenMarked is true if 1 or more marked items are hidden
810  // unhiddenMarked is true if 1 or more marked items are not hidden
811  bool hiddenMarked = false;
812  bool unhiddenMarked = false;
813  for (int id : qAsConst(m_marked))
814  {
815  ImagePtrK im = m_images.value(id);
816  if (!im)
817  continue;
818 
819  if (im->m_isHidden)
820  hiddenMarked = true;
821  else
822  unhiddenMarked = true;
823 
824  if (hiddenMarked && unhiddenMarked)
825  break;
826  }
827 
828  return MenuSubjects(GetSelected(), m_sequence.size() - 1,
830  hiddenMarked, unhiddenMarked);
831 }
832 
833 
841 {
842  DirCacheEntry cached(m_dirCache.value(dir.m_id));
843  if (cached.m_dirCount == -1 || cached.m_thumbCount < required)
844  return false;
845 
846  dir.m_fileCount = cached.m_fileCount;
847  dir.m_dirCount = cached.m_dirCount;
848  dir.m_thumbNails = cached.m_thumbs;
849 
850  LOG(VB_FILE, LOG_DEBUG, LOC + "Using cached " + cached.ToString(dir.m_id));
851  return true;
852 }
853 
854 
860 void DirectoryView::Cache(ImageItemK &dir, int thumbCount)
861 {
862  // Cache counts & thumbnails for each dir so that we don't need to reload its
863  // children from Db each time it's displayed
864  DirCacheEntry cacheEntry(dir.m_parentId, dir.m_dirCount, dir.m_fileCount,
865  dir.m_thumbNails, thumbCount);
866 
867  m_dirCache.insert(dir.m_id, cacheEntry);
868 
869  // Cache images used by dir thumbnails
870  for (const ThumbPair & thumb : qAsConst(dir.m_thumbNails))
871  {
872  // Do not overwrite any existing image url nor parent.
873  // Image url is cached when image is displayed as a child, but not as a
874  // ancestor dir thumbnail
875  // First cache attempt will be by parent. Subsequent attempts may be
876  // by ancestor dirs.
877  if (!m_fileCache.contains(thumb.first))
878  FlatView::Cache(thumb.first, dir.m_id, "", thumb.second);
879  }
880  LOG(VB_FILE, LOG_DEBUG, LOC + "Caching " + cacheEntry.ToString(dir.m_id));
881 }
882 
883 
888 {
889  LOG(VB_FILE, LOG_DEBUG, LOC + "Cleared Dir cache");
890  m_dirCache.clear();
892 }
893 
894 
902 QStringList DirectoryView::RemoveImage(int id, bool deleted)
903 {
904  QStringList urls;
905  int dirId = id;
906 
907  if (deleted)
908  {
909  m_marked.remove(id);
910  m_prevMarked.remove(id);
911  }
912 
913  // If id is a file then start with its parent
914  if (m_fileCache.contains(id))
915  {
916  // Clear file cache & start from its parent dir
917  dirId = m_fileCache.value(id).m_parent;
918  urls = FlatView::ClearImage(id, deleted);
919  }
920 
921  // Clear ancestor dirs
922  while (m_dirCache.contains(dirId))
923  {
924  LOG(VB_FILE, LOG_DEBUG, LOC + QString("Cleared %1 from dir cache").arg(dirId));
925  DirCacheEntry dir = m_dirCache.take(dirId);
926  dirId = dir.m_parent;
927  }
928  return urls;
929 }
930 
931 
939 bool TreeView::LoadFromDb(int parentId)
940 {
941  m_parentId = parentId;
942 
943  // Load visible subtree of the parent
944  // Ordered images of parent first, then breadth-first recursion of ordered dirs
945  ImageList files;
946  m_mgr.GetImageTree(m_parentId, files);
947 
948  // Load view
949  Populate(files);
950 
951  return !files.isEmpty();
952 }
ImagePtrK
QSharedPointer< ImageItemK > ImagePtrK
Definition: imagetypes.h:164
MarkedFiles::Add
void Add(const ImageIdList &newIds)
Definition: galleryviews.cpp:30
PHOTO_DB_ID
#define PHOTO_DB_ID
Definition: imagetypes.h:28
FlatView::CalculateSeasonalWeights
static WeightList CalculateSeasonalWeights(ImageList &files)
This method calculates a weight for the item based on how closely it was taken to the current time of...
Definition: galleryviews.cpp:309
ImageDbReader::GetImages
int GetImages(const ImageIdList &ids, ImageList &files, ImageList &dirs) const
Returns images (local or remote but not a combination)
Definition: imagemanager.cpp:1818
FlatView::HasNext
ImagePtrK HasNext(int inc) const
Peeks at next image in view but does not advance iterator.
Definition: galleryviews.cpp:151
LEADING_BETA_SHAPE
const double LEADING_BETA_SHAPE
Tuning parameter for seasonal weights, between 0 and 1, where lower numbers give greater weight to se...
Definition: galleryviews.cpp:20
DirectoryView::GetPosition
QString GetPosition() const
Get positional status.
Definition: galleryviews.cpp:485
ImageDbReader::GetImageTree
void GetImageTree(int id, ImageList &files) const
Return all files (local or remote) in the sub-trees of a dir.
Definition: imagemanager.cpp:1877
TreeView::LoadFromDb
bool LoadFromDb(int parentId) override
Populate view from database as images of a directory sub-tree. Default order of a tree is depth-first...
Definition: galleryviews.cpp:939
MarkedFiles::Initialise
void Initialise(int id)
Definition: galleryviews.h:38
FlatView::m_images
QHash< int, ImagePtrK > m_images
Image objects currently displayed.
Definition: galleryviews.h:133
ImageItem::m_id
int m_id
Uniquely identifies an image (file/dir).
Definition: imagetypes.h:88
FlatView::ClearImage
QStringList ClearImage(int id, bool remove=false)
Clear file from UI cache and optionally from view.
Definition: galleryviews.cpp:400
FileCacheEntry
Records info of displayed image files to enable clean-up of the UI image cache.
Definition: galleryviews.h:77
ImageDbReader::GetDirectory
int GetDirectory(int id, ImagePtr &parent, ImageList &files, ImageList &dirs) const
Return images (local and/or remote) for a dir and its direct children.
Definition: imagemanager.cpp:1786
DEFAULT_WEIGHT
const double DEFAULT_WEIGHT
Photos without an exif timestamp will default to the mode of the beta distribution.
Definition: galleryviews.cpp:25
FlatView::m_order
SlideOrderType m_order
Definition: galleryviews.h:131
DirectoryView::Mark
void Mark(int id, bool mark)
Mark/unmark an image/dir.
Definition: galleryviews.cpp:736
DirCacheEntry::m_thumbs
QList< ThumbPair > m_thumbs
Definition: galleryviews.h:160
FlatView::Rotate
void Rotate(int id)
Rotate view so that starting image is at front.
Definition: galleryviews.cpp:427
FlatView::LoadFromDb
virtual bool LoadFromDb(int parentId)
Populate view with database images from a directory.
Definition: galleryviews.cpp:368
DirectoryView::PopulateFromCache
bool PopulateFromCache(ImageItem &dir, int required)
Retrieve cached dir, if available.
Definition: galleryviews.cpp:840
arg
arg(title).arg(filename).arg(doDelete))
FlatView::m_mgr
ImageManagerFe & m_mgr
Definition: galleryviews.h:132
FileCacheEntry::ToString
QString ToString(int id) const
Definition: galleryviews.h:84
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
FlatView
A datastore of images for display by a screen.
Definition: galleryviews.h:99
kSeasonal
@ kSeasonal
Biased random selection so that images are more likely to appear on anniversaries.
Definition: galleryviews.h:25
TRAILING_BETA_SHAPE
const double TRAILING_BETA_SHAPE
See LEADING_BETA_SHAPE.
Definition: galleryviews.cpp:22
kMaxFolderThumbnails
static const int kMaxFolderThumbnails
Number of thumbnails to use for folders.
Definition: galleryviews.cpp:12
build_compdb.file
file
Definition: build_compdb.py:55
FlatView::Populate
void Populate(ImageList &files)
Fills view with Db images, re-ordering them as required.
Definition: galleryviews.cpp:214
FlatView::GetPosition
QString GetPosition() const
Get positional status.
Definition: galleryviews.cpp:74
DirectoryView::Cache
void Cache(ImageItemK &dir, int thumbCount)
Cache displayed dir.
Definition: galleryviews.cpp:860
FlatView::ClearCache
void ClearCache()
Clears UI cache.
Definition: galleryviews.cpp:387
DirectoryView::m_dirCache
QHash< int, DirCacheEntry > m_dirCache
Caches displayed image dirs.
Definition: galleryviews.h:205
MarkedFiles::Clear
void Clear()
Definition: galleryviews.h:39
FlatView::Select
bool Select(int id, int fallback=0)
Selects first occurrence of an image.
Definition: galleryviews.cpp:116
FlatView::Prev
ImagePtrK Prev(int inc)
Decrements iterator and returns previous image. Wraps at start.
Definition: galleryviews.cpp:196
tmp
static guint32 * tmp
Definition: goom_core.cpp:31
FlatView::Update
bool Update(int id)
Updates view with images that have been updated.
Definition: galleryviews.cpp:85
DirectoryView::MarkAll
void MarkAll()
Mark all images/dirs.
Definition: galleryviews.cpp:723
MythDate::fromSecsSinceEpoch
MBASE_PUBLIC QDateTime fromSecsSinceEpoch(uint seconds)
This function takes the number of seconds since the start of the epoch and returns a QDateTime with t...
Definition: mythdate.cpp:68
DirCacheEntry
Records dir info for every displayed dir.
Definition: galleryviews.h:146
FlatView::m_fileCache
QHash< int, FileCacheEntry > m_fileCache
Caches displayed image files.
Definition: galleryviews.h:138
DirectoryView::DirectoryView
DirectoryView(SlideOrderType order)
Constructs a view of images & directories that can be marked.
Definition: galleryviews.cpp:473
mark
Definition: lang.cpp:21
FlatView::HasPrev
ImagePtrK HasPrev(int inc) const
Peeks at previous image in view but does not decrement iterator.
Definition: galleryviews.cpp:185
LOC
#define LOC
Definition: galleryviews.cpp:9
kShuffle
@ kShuffle
Each image appears exactly once, but in random order.
Definition: galleryviews.h:23
FlatView::GetAllNodes
ImageListK GetAllNodes() const
Get all images/dirs in view.
Definition: galleryviews.cpp:50
FlatView::m_parentId
int m_parentId
Definition: galleryviews.h:130
MenuSubjects
A snapshot of current selection, markings & dir info when menu is invoked.
Definition: galleryviews.h:53
DirectoryView::InvertMarked
void InvertMarked()
Mark all unmarked items, unmark all marked items.
Definition: galleryviews.cpp:755
ImageListK
QList< ImagePtrK > ImageListK
Definition: imagetypes.h:165
FlatView::GetSelected
ImagePtrK GetSelected() const
Get current selection.
Definition: galleryviews.cpp:63
DirectoryView::SetDirectory
void SetDirectory(int newParent)
Manage markings on tree navigation.
Definition: galleryviews.cpp:777
DirCacheEntry::m_fileCount
int m_fileCount
Definition: galleryviews.h:159
FlatView::Clear
void Clear(bool resetParent=true)
Reset view.
Definition: galleryviews.cpp:137
ImageList
QVector< ImagePtr > ImageList
Definition: imagetypes.h:159
DirectoryView::m_prevMarked
MarkedFiles m_prevMarked
Marked items in previous dir.
Definition: galleryviews.h:202
ImageItem::m_thumbNails
QList< ThumbPair > m_thumbNails
Definition: imagetypes.h:110
DirCacheEntry::ToString
QString ToString(int id) const
Definition: galleryviews.cpp:458
ImageItem::m_dirCount
int m_dirCount
Id & URLs of thumbnail(s). 1 for a file, 4 for dirs.
Definition: imagetypes.h:111
FlatView::Next
ImagePtrK Next(int inc)
Advance iterator and return next image, wrapping if necessary. Regenerates unordered views on wrap.
Definition: galleryviews.cpp:163
DirectoryView::LoadFromDb
bool LoadFromDb(int parentId) override
Populate view from database as images/subdirs of a directory. View is ordered: Parent dir,...
Definition: galleryviews.cpp:499
DirectoryView::m_marked
MarkedFiles m_marked
Marked items in current dir/view.
Definition: galleryviews.h:201
next
PictureAttribute next(PictureAttributeSupported Supported, PictureAttribute Attribute)
Definition: videoouttypes.h:360
galleryviews.h
Provides view datastores for Gallery screens.
DirectoryView::LoadDirThumbs
void LoadDirThumbs(ImageItem &parent, int thumbsNeeded, int level=0)
Populate thumbs for a dir.
Definition: galleryviews.cpp:571
ImagePtr
QSharedPointer< ImageItem > ImagePtr
Definition: imagetypes.h:158
DirCacheEntry::m_thumbCount
int m_thumbCount
Definition: galleryviews.h:157
dir
QDir dir
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:1177
ImageItem
Represents a picture, video or directory.
Definition: imagetypes.h:68
DirCacheEntry::m_parent
int m_parent
Definition: galleryviews.h:156
FlatView::m_sequence
ImageIdList m_sequence
The sequence in which to display images.
Definition: galleryviews.h:134
ImageIdList
QList< int > ImageIdList
Definition: imagetypes.h:59
DirectoryView::GetMenuSubjects
MenuSubjects GetMenuSubjects()
Determine current selection, markings & various info to support menu display.
Definition: galleryviews.cpp:807
MarkedFiles::Invert
void Invert(const ImageIdList &all)
Definition: galleryviews.cpp:36
ImageDbReader::GetChildren
int GetChildren(int id, ImageList &files, ImageList &dirs) const
Return (local or remote) images that are direct children of a dir.
Definition: imagemanager.cpp:1839
DirectoryView::PopulateThumbs
void PopulateThumbs(ImageItem &parent, int thumbsNeeded, const ImageList &files, const ImageList &dirs, int level=0)
Populate directory stats & thumbnails recursively from database as follows: Use user cover,...
Definition: galleryviews.cpp:596
SlideOrderType
SlideOrderType
Order of images in slideshow.
Definition: galleryviews.h:21
DirectoryView::ClearCache
void ClearCache()
Clears UI cache.
Definition: galleryviews.cpp:887
DirectoryView::Clear
void Clear(bool resetParent=true)
Resets view.
Definition: galleryviews.cpp:712
DirectoryView::RemoveImage
QStringList RemoveImage(int id, bool deleted=false)
Clear file/dir and all its ancestors from UI cache so that ancestor thumbnails are recalculated....
Definition: galleryviews.cpp:902
WeightList
QVector< double > WeightList
Seasonal weightings for images in a view.
Definition: galleryviews.h:30
ThumbPair
QPair< int, QString > ThumbPair
Definition: imagetypes.h:63
ImageItem::m_userThumbnail
int m_userThumbnail
Id of thumbnail to use as cover (dirs only)
Definition: imagetypes.h:105
kOrdered
@ kOrdered
Ordered as per user setting GallerySortOrder.
Definition: galleryviews.h:22
BETA_CLIP
const qint64 BETA_CLIP
The edges of the distribution get clipped to avoid a singularity.
Definition: galleryviews.cpp:28
FlatView::Cache
void Cache(int id, int parent, const QString &url, const QString &thumb)
Cache image properties to optimize UI.
Definition: galleryviews.cpp:448
MarkedFiles::IsFor
bool IsFor(int id) const
Definition: galleryviews.h:40
DirectoryView::GetChildren
ImageIdList GetChildren() const
Definition: galleryviews.h:197
DirectoryView::ClearMarked
void ClearMarked()
Unmark all items.
Definition: galleryviews.cpp:766
kRandom
@ kRandom
Random selection from view. An image may be absent or appear multiple times.
Definition: galleryviews.h:24
DirCacheEntry::m_dirCount
int m_dirCount
Definition: galleryviews.h:158
GALLERY_DB_ID
#define GALLERY_DB_ID
Definition: imagetypes.h:26
ImageItem::m_fileCount
int m_fileCount
Number of child images (dirs only)
Definition: imagetypes.h:112
FlatView::m_active
int m_active
Sequence index of current selected image.
Definition: galleryviews.h:135