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 : *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  for (const ImagePtr & im : files + dirs)
609  {
610  if (im && im->m_id == parent.m_userThumbnail)
611  {
612  userIm = im;
613  break;
614  }
615  }
616  }
617 
618  // Children to use as thumbnails
619  ImageList thumbFiles;
620  ImageList thumbDirs;
621 
622  if (!userIm)
623  {
624  // Construct multi-thumbnail from all children
625  thumbFiles = files;
626  thumbDirs = dirs;
627  }
628  else if (userIm->IsFile())
629  {
630  thumbFiles.append(userIm);
631  thumbsNeeded = 1;
632  }
633  else
634  thumbDirs.append(userIm);
635 
636  // Fill parent thumbs from child files first
637  // Whilst they're available fill as many as possible for cache
638  for (int i = 0; i < qMin(kMaxFolderThumbnails, thumbFiles.size()); ++i)
639  {
640  parent.m_thumbNails.append(thumbFiles.at(i)->m_thumbNails.at(0));
641  --thumbsNeeded;
642  }
643 
644  // Only recurse if necessary
645  if (thumbsNeeded > 0)
646  {
647  // Prevent lengthy/infinite recursion due to deep/cyclic folder
648  // structures
649  if (++level > 10)
650  {
651  LOG(VB_GENERAL, LOG_NOTICE, LOC +
652  "Directory thumbnails are more than 10 levels deep");
653  }
654  else
655  {
656  // Recursively load subdir thumbs to try to get 1 thumb from each
657  for (const ImagePtr & im : qAsConst(thumbDirs))
658  {
659  if (!im)
660  continue;
661 
662  // Load sufficient thumbs from each dir as subsequent dirs may
663  // be empty
664  LoadDirThumbs(*im, thumbsNeeded, level);
665 
666  if (!im->m_thumbNails.empty())
667  {
668  // Add first thumbnail to parent thumb
669  parent.m_thumbNails.append(im->m_thumbNails.at(0));
670 
671  // Quit when we have sufficient thumbs
672  if (--thumbsNeeded == 0)
673  break;
674  }
675  }
676 
677  // If insufficient dirs to supply 1 thumb per dir, use other dir
678  // thumbs (indices 1-3) as well
679  int i = 0;
680  while (thumbsNeeded > 0 && ++i < kMaxFolderThumbnails)
681  {
682  for (const QSharedPointer<ImageItem> & im : qAsConst(thumbDirs))
683  {
684  if (i < im->m_thumbNails.size())
685  {
686  parent.m_thumbNails.append(im->m_thumbNails.at(i));
687  if (--thumbsNeeded == 0)
688  break;
689  }
690  }
691  }
692  }
693  }
694 
695  // Flag the cached entry with number of thumbs loaded. If future uses require
696  // more, then the dir must be reloaded.
697  // For user thumbs and dirs with insufficient child images, the cache is always valid
698  int scanned = (userIm || thumbsNeeded > 0)
700  : parent.m_thumbNails.size();
701 
702  // Cache result to optimize navigation
703  Cache(parent, scanned);
704 }
705 
706 
711 void DirectoryView::Clear(bool /*resetParent*/)
712 {
713  ClearMarked();
714  ClearCache();
715  FlatView::Clear();
716 }
717 
718 
723 {
724  // Any marking clears previous marks
727 }
728 
729 
735 void DirectoryView::Mark(int id, bool mark)
736 {
737  if (mark)
738  {
739  // Any marking clears previous marks
741  m_marked.Add(id);
742  }
743  else
744  {
745  m_prevMarked.remove(id);
746  m_marked.remove(id);
747  }
748 }
749 
750 
755 {
756  // Any marking clears previous marks
759 }
760 
761 
766 {
767  m_marked.Clear();
769 }
770 
771 
776 void DirectoryView::SetDirectory(int newParent)
777 {
778  if (m_marked.IsFor(newParent))
779  // Directory hasn't changed
780  return;
781 
782  // Markings are cleared on every dir change
783  // Any current markings become previous markings
784  // Only 1 set of previous markings are preserved
785  if (m_prevMarked.IsFor(newParent))
786  {
787  // Returned to dir of previous markings: reinstate them
790  return;
791  }
792 
793  if (!m_marked.isEmpty())
794  // Preserve current markings
796 
797  // Initialise current markings for new dir
798  m_marked.Initialise(newParent);
799 }
800 
801 
807 {
808  // hiddenMarked is true if 1 or more marked items are hidden
809  // unhiddenMarked is true if 1 or more marked items are not hidden
810  bool hiddenMarked = false;
811  bool unhiddenMarked = false;
812  for (int id : qAsConst(m_marked))
813  {
814  ImagePtrK im = m_images.value(id);
815  if (!im)
816  continue;
817 
818  if (im->m_isHidden)
819  hiddenMarked = true;
820  else
821  unhiddenMarked = true;
822 
823  if (hiddenMarked && unhiddenMarked)
824  break;
825  }
826 
827  return MenuSubjects(GetSelected(), m_sequence.size() - 1,
829  hiddenMarked, unhiddenMarked);
830 }
831 
832 
840 {
841  DirCacheEntry cached(m_dirCache.value(dir.m_id));
842  if (cached.m_dirCount == -1 || cached.m_thumbCount < required)
843  return false;
844 
845  dir.m_fileCount = cached.m_fileCount;
846  dir.m_dirCount = cached.m_dirCount;
847  dir.m_thumbNails = cached.m_thumbs;
848 
849  LOG(VB_FILE, LOG_DEBUG, LOC + "Using cached " + cached.ToString(dir.m_id));
850  return true;
851 }
852 
853 
859 void DirectoryView::Cache(ImageItemK &dir, int thumbCount)
860 {
861  // Cache counts & thumbnails for each dir so that we don't need to reload its
862  // children from Db each time it's displayed
863  DirCacheEntry cacheEntry(dir.m_parentId, dir.m_dirCount, dir.m_fileCount,
864  dir.m_thumbNails, thumbCount);
865 
866  m_dirCache.insert(dir.m_id, cacheEntry);
867 
868  // Cache images used by dir thumbnails
869  for (const ThumbPair & thumb : qAsConst(dir.m_thumbNails))
870  {
871  // Do not overwrite any existing image url nor parent.
872  // Image url is cached when image is displayed as a child, but not as a
873  // ancestor dir thumbnail
874  // First cache attempt will be by parent. Subsequent attempts may be
875  // by ancestor dirs.
876  if (!m_fileCache.contains(thumb.first))
877  FlatView::Cache(thumb.first, dir.m_id, "", thumb.second);
878  }
879  LOG(VB_FILE, LOG_DEBUG, LOC + "Caching " + cacheEntry.ToString(dir.m_id));
880 }
881 
882 
887 {
888  LOG(VB_FILE, LOG_DEBUG, LOC + "Cleared Dir cache");
889  m_dirCache.clear();
891 }
892 
893 
901 QStringList DirectoryView::RemoveImage(int id, bool deleted)
902 {
903  QStringList urls;
904  int dirId = id;
905 
906  if (deleted)
907  {
908  m_marked.remove(id);
909  m_prevMarked.remove(id);
910  }
911 
912  // If id is a file then start with its parent
913  if (m_fileCache.contains(id))
914  {
915  // Clear file cache & start from its parent dir
916  dirId = m_fileCache.value(id).m_parent;
917  urls = FlatView::ClearImage(id, deleted);
918  }
919 
920  // Clear ancestor dirs
921  while (m_dirCache.contains(dirId))
922  {
923  LOG(VB_FILE, LOG_DEBUG, LOC + QString("Cleared %1 from dir cache").arg(dirId));
924  DirCacheEntry dir = m_dirCache.take(dirId);
925  dirId = dir.m_parent;
926  }
927  return urls;
928 }
929 
930 
938 bool TreeView::LoadFromDb(int parentId)
939 {
940  m_parentId = parentId;
941 
942  // Load visible subtree of the parent
943  // Ordered images of parent first, then breadth-first recursion of ordered dirs
944  ImageList files;
945  m_mgr.GetImageTree(m_parentId, files);
946 
947  // Load view
948  Populate(files);
949 
950  return !files.isEmpty();
951 }
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:1816
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:1875
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:938
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:76
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:1784
DEFAULT_WEIGHT
const double DEFAULT_WEIGHT
Photos without an exif timestamp will default to the mode of the beta distribution.
Definition: galleryviews.cpp:25
kMaxFolderThumbnails
const static int kMaxFolderThumbnails
Number of thumbnails to use for folders.
Definition: galleryviews.cpp:12
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:735
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:839
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:98
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
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:859
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:30
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:722
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:145
FlatView::m_fileCache
QHash< int, FileCacheEntry > m_fileCache
Caches displayed image files.
Definition: galleryviews.h:138
ImageList
QList< ImagePtr > ImageList
Definition: imagetypes.h:159
DirectoryView::DirectoryView
DirectoryView(SlideOrderType order)
Constructs a view of images & directories that can be marked.
Definition: galleryviews.cpp:473
mark
Definition: lang.cpp:20
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:52
DirectoryView::InvertMarked
void InvertMarked()
Mark all unmarked items, unmark all marked items.
Definition: galleryviews.cpp:754
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:776
DirCacheEntry::m_fileCount
int m_fileCount
Definition: galleryviews.h:159
FlatView::Clear
void Clear(bool resetParent=true)
Reset view.
Definition: galleryviews.cpp:137
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:350
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:1171
ImageItem
Represents a picture, video or directory.
Definition: imagetypes.h:67
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:806
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:1837
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:886
DirectoryView::Clear
void Clear(bool resetParent=true)
Resets view.
Definition: galleryviews.cpp:711
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:901
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:765
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