MythTV  master
imagemanager.cpp
Go to the documentation of this file.
1 #include "imagemanager.h"
2 
3 #include <QImageReader>
4 #include <QRunnable>
5 #include <utility>
6 
7 #include "dbaccess.h" // for FileAssociations
8 #include "mthreadpool.h"
9 #include "mythdate.h"
10 #include "mythmediamonitor.h"
11 
12 
13 #define LOC QString("ImageManager: ")
14 #define DBLOC QString("ImageDb(%1): ").arg(m_table)
15 
16 // Must be empty as it's prepended to path
17 #define STORAGE_GROUP_MOUNT ""
18 
19 #define DB_TABLE "gallery_files"
20 
21 #define RESULT_ERR(ERR, MESG) \
22 { LOG(VB_GENERAL, LOG_ERR, LOC + (MESG)); \
23  return QStringList("ERROR") << (ERR); }
24 
25 #define RESULT_OK(MESG) \
26 { LOG(VB_FILE, LOG_DEBUG, LOC + (MESG)); \
27  return QStringList("OK"); }
28 
29 #define IMPORTDIR "Import"
30 
31 
33 class Device
34 {
35 public:
36  Device(QString name, QString mount,
37  MythMediaDevice *media = nullptr, QTemporaryDir *import = nullptr)
38  : m_present(true), m_name(std::move(name)), m_mount(std::move(mount)),
39  m_media(media), m_dir(import)
40  {
41  // Path relative to TEMP storage group
42  m_thumbs = QString("%1/%2").arg(THUMBNAIL_SUBDIR, m_name);
43  }
44 
45 
48  {
49  Close();
50 
51  // Remove imported images
52  delete m_dir;
53 
54  // Clean up non-SG thumbnails
56  RemoveThumbs();
57  }
58 
59 
61  void Close(bool eject = false)
62  {
63  // Imports remain present; others do not
64  m_present = isImport();
65 
66  // Release device
67  if (m_media)
68  {
69  if (eject)
70  {
71  LOG(VB_GENERAL, LOG_INFO, LOC + QString("Ejecting '%1' at '%2'")
72  .arg(m_name, m_mount));
74  }
75  else
76  LOG(VB_MEDIA, LOG_DEBUG, LOC + QString("Unlocked '%1'").arg(m_name));
77 
79  m_media = nullptr;
80  }
81  }
82 
83 
88  static void RemoveDirContents(const QString& path)
89  {
90  QDir(path).removeRecursively();
91  }
92 
93 
95  void RemoveThumbs(void) const
96  {
97  // Remove thumbnails
98  QString dir = QString("%1/" TEMP_SUBDIR "/%2").arg(GetConfDir(), m_thumbs);
99  LOG(VB_FILE, LOG_INFO, LOC + QString("Removing thumbnails in %1").arg(dir));
101  QDir::root().rmpath(dir);
102  }
103 
104 
105  bool isImport() const { return m_dir; }
106  bool isPresent() const { return m_present; }
107  void setPresent(MythMediaDevice *media) { m_present = true; m_media = media; }
108 
110  bool m_present;
111  QString m_name;
112  QString m_mount;
113  QString m_thumbs;
115  QTemporaryDir *m_dir;
116 };
117 
118 
119 static Device kNullDevice = Device("Unknown Device", "<Invalid Path>");
120 
121 
123 {
124  qDeleteAll(m_devices);
125 }
126 
127 
129 QString DeviceManager::DeviceMount(int devId) const
130 {
131  return m_devices.value(devId, &kNullDevice)->m_mount;
132 }
133 
134 
136 QString DeviceManager::DeviceName(int devId) const
137 {
138  return m_devices.value(devId, &kNullDevice)->m_name;
139 }
140 
141 
142 QString DeviceManager::ThumbDir(int fs) const
143 {
144  return m_devices.value(fs, &kNullDevice)->m_thumbs;
145 }
146 
147 
157 int DeviceManager::OpenDevice(const QString &name, const QString &mount,
158  MythMediaDevice *media, QTemporaryDir *dir)
159 {
160  // Handle devices reappearing at same mountpoint.
161  // If a USB is unplugged whilst in use (without unmounting) we get no event
162  // but we do when it's re-inserted
163  QString state("Known");
164  int id = LocateMount(mount);
165 
166  if (id == DEVICE_INVALID)
167  {
168  state = "New";
169  id = m_devices.isEmpty() ? 0 : (m_devices.constEnd() - 1).key() + 1;
170  m_devices.insert(id, new Device(name, mount, media, dir));
171  }
172  else if (m_devices.value(id))
173  m_devices.value(id)->setPresent(media);
174 
175  LOG(VB_GENERAL, LOG_INFO, LOC +
176  QString("%1 device %2 mounted at '%3' [Id %4]")
177  .arg(state, name, mount).arg(id));
178 
179  return id;
180 }
181 
182 
189 QStringList DeviceManager::CloseDevices(int devId, const QString &action)
190 {
191  QStringList clear;
192 
193  if (action == "DEVICE CLOSE ALL")
194  {
195  // Close all devices but retain their thumbnails
196  for (auto *dev : qAsConst(m_devices))
197  if (dev)
198  dev->Close();
199  }
200  else if (action == "DEVICE CLEAR ALL")
201  {
202  // Remove all thumbnails but retain devices
203  for (const auto *dev : qAsConst(m_devices)) {
204  if (dev)
205  {
206  clear << dev->m_mount;
207  dev->RemoveThumbs();
208  }
209  }
210  }
211  else
212  {
213  // Remove single device & its thumbnails, optionally ejecting it
214  Device *dev = m_devices.take(devId);
215  if (dev)
216  {
217  if (action == "DEVICE EJECT")
218  dev->Close(true);
219  clear << dev->m_mount;
220  delete dev;
221  }
222  }
223  return clear;
224 }
225 
226 
232 int DeviceManager::LocateMount(const QString &mount) const
233 {
234  DeviceMap::const_iterator it = m_devices.constBegin();
235  while (it != m_devices.constEnd())
236  {
237  if (it.value()->m_mount == mount)
238  return it.key();
239  ++it;
240  }
241  return DEVICE_INVALID;
242 }
243 
244 
247 {
249  for (int id : m_devices.keys())
250  {
251  Device *dev = m_devices.value(id);
252  if (dev)
253  paths.insert(id, dev->m_mount);
254  }
255  return paths;
256 }
257 
258 
261 {
262  QList<int> absent;
263  for (int id : m_devices.keys())
264  {
265  Device *dev = m_devices.value(id);
266  if (dev && !dev->isPresent())
267  absent << id;
268  }
269  return absent;
270 }
271 
272 
277  m_imageFileExt(SupportedImages()),
278  m_videoFileExt(SupportedVideos())
279 {
280  // Generate glob list from supported extensions
281  QStringList glob;
282  for (const auto& ext : (m_imageFileExt + m_videoFileExt))
283  glob << "*." + ext;
284 
285  // Apply filters to only detect image files
286  m_dirFilter.setNameFilters(glob);
287  m_dirFilter.setFilter(QDir::AllDirs | QDir::Files | QDir::Readable |
288  QDir::NoDotAndDotDot | QDir::NoSymLinks);
289 
290  // Sync files before dirs to improve thumb generation response
291  // Order by time (oldest first) - this determines the order thumbs appear
292  m_dirFilter.setSorting(QDir::DirsLast | QDir::Time | QDir::Reversed);
293 }
294 
300 {
301  // Determine supported picture formats from Qt
302  QStringList formats;
303  QList<QByteArray> supported = QImageReader::supportedImageFormats();
304  for (const auto& ext : qAsConst(supported))
305  formats << QString(ext);
306  return formats;
307 }
308 
309 
315 {
316  // Determine supported video formats from MythVideo
317  QStringList formats;
320  for (const auto & fa : faList)
321  {
322  if (!fa.use_default && fa.playcommand == "Internal")
323  formats << QString(fa.extension);
324  }
325  return formats;
326 }
327 
328 
337 ImageItem *ImageAdapterLocal::CreateItem(const QFileInfo &fi, int parentId,
338  int devId, const QString & /*base*/) const
339 {
340  auto *im = new ImageItem();
341 
342  im->m_parentId = parentId;
343  im->m_device = devId;
344  im->m_filePath = fi.absoluteFilePath();
345 
346  if (parentId == GALLERY_DB_ID)
347  {
348  // Import devices show time of import, other devices show 'last scan time'
349  im->m_date = im->m_filePath.contains(IMPORTDIR)
350  ? fi.lastModified().toSecsSinceEpoch()
351  : QDateTime::currentSecsSinceEpoch();
352  im->m_modTime = im->m_date;
353  im->m_type = kDevice;
354  return im;
355  }
356 
357  im->m_modTime = fi.lastModified().toSecsSinceEpoch();
358 
359  if (fi.isDir())
360  {
361  im->m_type = kDirectory;
362  return im;
363  }
364 
365  im->m_extension = fi.suffix().toLower();
366  im->m_type = GetImageType(im->m_extension);
367 
368  if (im->m_type == kUnknown)
369  {
370  delete im;
371  return nullptr;
372  }
373 
374  im->m_thumbPath = GetAbsThumbPath(ThumbDir(im->m_device), ThumbPath(*im));
375  im->m_size = fi.size();
376 
377  return im;
378 }
379 
380 
386 void ImageAdapterLocal::Notify(const QString &mesg,
387  const QStringList &extra)
388 {
389  QString host(gCoreContext->GetHostName());
390  gCoreContext->SendEvent(MythEvent(QString("%1 %2").arg(mesg, host), extra));
391 }
392 
393 
402 ImageItem *ImageAdapterSg::CreateItem(const QFileInfo &fi, int parentId,
403  int /*devId*/, const QString &base) const
404 {
405  auto *im = new ImageItem();
406 
407  im->m_device = 0;
408  im->m_parentId = parentId;
409 
410  if (parentId == GALLERY_DB_ID)
411  {
412  // All SG dirs map to a single Db dir
413  im->m_filePath = "";
414  im->m_type = kDevice;
415  im->m_date = QDateTime::currentMSecsSinceEpoch() / 1000;
416  im->m_modTime = im->m_date;
417  return im;
418  }
419 
420  // Strip SG path & leading / to leave a relative path
421  im->m_filePath = fi.absoluteFilePath().mid(base.size() + 1);
422  im->m_modTime = fi.lastModified().toSecsSinceEpoch();
423 
424  if (fi.isDir())
425  {
426  im->m_type = kDirectory;
427  return im;
428  }
429 
430  im->m_extension = fi.suffix().toLower();
431  im->m_type = GetImageType(im->m_extension);
432 
433  if (im->m_type == kUnknown)
434  {
435  delete im;
436  return nullptr;
437  }
438 
439  im->m_thumbPath = GetAbsThumbPath(ThumbDir(im->m_device), ThumbPath(*im));
440  im->m_size = fi.size();
441 
442  return im;
443 }
444 
445 
451 void ImageAdapterSg::Notify(const QString &mesg,
452  const QStringList &extra)
453 {
454  gCoreContext->SendEvent(MythEvent(mesg, extra));
455 }
456 
457 
463 {
464  StringMap map;
465  int i = 0;
466  QStringList paths = m_sg.GetDirList();
467  for (const auto& path : qAsConst(paths))
468  map.insert(i++, path);
469  return map;
470 }
471 
472 
480 {
481  if (im->IsDevice())
482  return m_sg.FindNextDirMostFree();
483  return im->m_filePath.startsWith("/") ? im->m_filePath
484  : m_sg.FindFile(im->m_filePath);
485 }
486 
487 
488 // Database fields used by several image queries
489 #define DB_COLUMNS \
490 "file_id, filename, name, dir_id, type, modtime, size, " \
491 "extension, date, hidden, orientation, angle, path, zoom"
492 // Id, filepath, basename, parentId, type, modtime, size,
493 // extension, image date, hidden, orientation, cover id, comment, device id
494 
495 
501 template <class FS>
503 {
504  auto *im = new ImageItem(FS::ImageId(query.value(0).toInt()));
505 
506  // Ordered as per DB_COLUMNS
507  im->m_filePath = query.value(1).toString();
508  im->m_baseName = query.value(2).toString();
509  im->m_parentId = FS::ImageId(query.value(3).toInt());
510  im->m_type = query.value(4).toInt();
511  im->m_modTime = query.value(5).toInt();
512  im->m_size = query.value(6).toInt();
513  im->m_extension = query.value(7).toString();
514  im->m_date = query.value(8).toUInt();
515  im->m_isHidden = query.value(9).toBool();
516  im->m_orientation = query.value(10).toInt();
517  im->m_userThumbnail = FS::ImageId(query.value(11).toInt());
518  im->m_comment = query.value(12).toString();
519  im->m_device = query.value(13).toInt();
520  im->m_url = FS::MakeFileUrl(im->m_filePath);
521 
522  if (im->IsFile())
523  {
524  // Only pics/vids have thumbs
525  QString thumbPath(FS::ThumbPath(*im));
526  QString devPath(FS::ThumbDir(im->m_device));
527  QString url(FS::MakeThumbUrl(devPath, thumbPath));
528 
529  im->m_thumbPath = FS::GetAbsThumbPath(devPath, thumbPath);
530  im->m_thumbNails.append(qMakePair(im->m_id, url));
531  }
532  return im;
533 }
534 
535 
544 template <class FS>
545 int ImageDb<FS>::GetImages(const QString &ids, ImageList &files, ImageList &dirs,
546  const QString &refine) const
547 {
548  if (ids.isEmpty())
549  return 0;
550 
551  QString select = QString("file_id IN (%1) %2").arg(FS::DbIds(ids), refine);
552  return ReadImages(dirs, files, select);
553 }
554 
555 
564 template <class FS>
565 int ImageDb<FS>::GetChildren(QString ids, ImageList &files, ImageList &dirs,
566  const QString &refine) const
567 {
568  QString select = QString("dir_id IN (%1) %2").arg(FS::DbIds(ids), refine);
569  return ReadImages(dirs, files, select);
570 }
571 
572 
582 template <class FS>
584  ImageList &files, ImageList &dirs,
585  const QString &refine) const
586 {
588  query.prepare(QString("SELECT " DB_COLUMNS " FROM %1 "
589  "WHERE (dir_id = :ID1 OR file_id = :ID2) "
590  "%2;").arg(m_table, refine));
591 
592  // Qt < 5.4 won't bind multiple occurrences
593  int dbId = FS::DbId(id);
594  query.bindValue(":ID1", dbId);
595  query.bindValue(":ID2", dbId);
596 
597  if (!query.exec())
598  {
600  return -1;
601  }
602  while (query.next())
603  {
604  ImagePtr im(CreateImage(query));
605 
606  if (im->IsFile())
607  files.append(im);
608  else if (im->m_id == id)
609  parent = im;
610  else
611  dirs.append(im);
612  }
613  return query.size();
614 }
615 
616 
624 template <class FS>
625 bool ImageDb<FS>::GetDescendants(const QString &ids,
626  ImageList &files, ImageList &dirs) const
627 {
628  if (ids.isEmpty())
629  return false;
630 
631  if (ReadImages(dirs, files, QString("file_id IN (%1)").arg(FS::DbIds(ids))) < 0)
632  return false;
633 
635  QString sql =
636  QString("SELECT " DB_COLUMNS
637  ", LENGTH(filename) - LENGTH(REPLACE(filename, '/', ''))"
638  " AS depth "
639  "FROM %1 WHERE filename LIKE :PREFIX "
640  "ORDER BY depth;").arg(m_table);
641 
642  for (const auto& im1 : qAsConst(dirs))
643  {
644  query.prepare(sql);
645  query.bindValue(":PREFIX", im1->m_filePath + "/%");
646 
647  if (!query.exec())
648  {
650  return false;
651  }
652 
653  while (query.next())
654  {
655  ImagePtr im2(CreateImage(query));
656  if (im2->IsDirectory())
657  dirs.append(im2);
658  else
659  files.append(im2);
660  }
661  }
662  return true;
663 }
664 
665 
673 template <class FS>
674 bool ImageDb<FS>::GetImageTree(int id, ImageList &files, const QString &refine) const
675 {
676  // Load starting children
677  ImageList dirs;
678  if (GetChildren(QString::number(id), files, dirs, refine) < 0)
679  return false;
680 
681  for (const auto& im : qAsConst(dirs))
682  if (!GetImageTree(im->m_id, files, refine))
683  return false;
684  return true;
685 }
686 
687 
693 template <class FS>
695 {
697  query.prepare(QString("SELECT " DB_COLUMNS " FROM %1").arg(m_table));
698 
699  if (!query.exec())
700  {
702  return false;
703  }
704 
705  while (query.next())
706  {
707  ImagePtr im(CreateImage(query));
708  if (im->IsDirectory())
709  dirs.insert(im->m_filePath, im);
710  else
711  files.insert(im->m_filePath, im);
712  }
713  return true;
714 }
715 
716 
724 template <class FS>
725 void ImageDb<FS>::ClearDb(int devId, const QString &action)
726 {
727  if (action == "DEVICE CLOSE ALL")
728  // Retain Db images when closing UI
729  return;
730 
732 
733  if (action == "DEVICE CLEAR ALL")
734  {
735  // Clear images from all devices. Reset auto-increment
736  query.prepare(QString("TRUNCATE TABLE %1;").arg(m_table));
737 
738  if (!query.exec())
740  }
741  else // Actions DEVICE REMOVE & DEVICE EJECT
742  {
743  // Delete all images of the device
744  query.prepare(QString("DELETE IGNORE FROM %1 WHERE zoom = :FS;").arg(m_table));
745  query.bindValue(":FS", devId);
746 
747  if (!query.exec())
749  }
750 }
751 
752 
760 template <class FS>
761 int ImageDb<FS>::InsertDbImage(ImageItemK &im, bool checkForDuplicate) const
762 {
764 
765  if (checkForDuplicate)
766  {
767  query.prepare(QString("SELECT file_id FROM %1 WHERE filename = :NAME;")
768  .arg(m_table));
769 
770  query.bindValue(":NAME", im.m_filePath);
771 
772  if (!query.exec())
773  {
775  return -1;
776  }
777 
778  if (query.size() > 0)
779  {
780  LOG(VB_FILE, LOG_DEBUG, QString("Image: %1 already exists in Db")
781  .arg(im.m_filePath));
782  return query.value(0).toInt();
783  }
784  }
785 
786  query.prepare(QString("INSERT INTO %1 (" DB_COLUMNS ") VALUES (0, "
787  ":FILEPATH, :NAME, :PARENT, :TYPE, :MODTIME, "
788  ":SIZE, :EXTENSION, :DATE, :HIDDEN, :ORIENT, "
789  ":COVER, :COMMENT, :FS);").arg(m_table));
790 
791  query.bindValue(":FILEPATH", im.m_filePath);
792  query.bindValue(":NAME", FS::BaseNameOf(im.m_filePath));
793  query.bindValue(":FS", im.m_device);
794  query.bindValue(":PARENT", FS::DbId(im.m_parentId));
795  query.bindValue(":TYPE", im.m_type);
796  query.bindValue(":MODTIME", im.m_modTime);
797  query.bindValue(":SIZE", im.m_size);
798  query.bindValue(":EXTENSION", im.m_extension);
799  query.bindValue(":DATE", im.m_date);
800  query.bindValue(":ORIENT", im.m_orientation);
801  query.bindValue(":COMMENT", im.m_comment.isNull() ? "" : im.m_comment);
802  query.bindValue(":HIDDEN", im.m_isHidden);
803  query.bindValue(":COVER", FS::DbId(im.m_userThumbnail));
804 
805  if (query.exec())
806  return FS::ImageId(query.lastInsertId().toInt());
807 
809  return -1;
810 }
811 
812 
818 template <class FS>
820 {
822  query.prepare(QString
823  ("UPDATE %1 SET "
824  "filename = :FILEPATH, name = :NAME, "
825  "dir_id = :PARENT, type = :TYPE, "
826  "modtime = :MODTIME, size = :SIZE, "
827  "extension = :EXTENSION, date = :DATE, zoom = :FS, "
828  "hidden = :HIDDEN, orientation = :ORIENT, "
829  "angle = :COVER, path = :COMMENT "
830  "WHERE file_id = :ID;").arg(m_table));
831 
832  query.bindValue(":ID", FS::DbId(im.m_id));
833  query.bindValue(":FILEPATH", im.m_filePath);
834  query.bindValue(":NAME", FS::BaseNameOf(im.m_filePath));
835  query.bindValue(":PARENT", FS::DbId(im.m_parentId));
836  query.bindValue(":TYPE", im.m_type);
837  query.bindValue(":MODTIME", im.m_modTime);
838  query.bindValue(":SIZE", im.m_size);
839  query.bindValue(":EXTENSION", im.m_extension);
840  query.bindValue(":DATE", im.m_date);
841  query.bindValue(":FS", im.m_device);
842  query.bindValue(":HIDDEN", im.m_isHidden);
843  query.bindValue(":ORIENT", im.m_orientation);
844  query.bindValue(":COVER", FS::DbId(im.m_userThumbnail));
845  query.bindValue(":COMMENT", im.m_comment.isNull() ? "" : im.m_comment);
846 
847  if (query.exec())
848  return true;
849 
851  return false;
852 }
853 
854 
861 template <class FS>
862 QStringList ImageDb<FS>::RemoveFromDB(const ImageList &imList) const
863 {
864  QStringList ids;
865  if (!imList.isEmpty())
866  {
867  for (const auto& im : qAsConst(imList))
868  ids << QString::number(FS::DbId(im->m_id));
869 
870  QString idents = ids.join(",");
872  query.prepare(QString("DELETE IGNORE FROM %1 WHERE file_id IN (%2);")
873  .arg(m_table, idents));
874 
875  if (!query.exec())
876  {
878  return QStringList();
879  }
880  }
881  return ids;
882 }
883 
884 
891 template <class FS>
892 bool ImageDb<FS>::SetHidden(bool hide, QString ids) const
893 {
894  if (ids.isEmpty())
895  return false;
896 
898 
899  query.prepare(QString("UPDATE %1 SET "
900  "hidden = :HIDDEN "
901  "WHERE file_id IN (%2);").arg(m_table, FS::DbIds(ids)));
902  query.bindValue(":HIDDEN", hide ? 1 : 0);
903 
904  if (query.exec())
905  return true;
906 
908  return false;
909 }
910 
911 
917 template <class FS>
918 bool ImageDb<FS>::SetCover(int dir, int id) const
919 {
921 
922  query.prepare(QString("UPDATE %1 SET "
923  "angle = :COVER "
924  "WHERE file_id = :DIR").arg(m_table));
925  query.bindValue(":COVER", FS::DbId(id));
926  query.bindValue(":DIR", FS::DbId(dir));
927  \
928  if (query.exec())
929  return true;
930 
932  return false;
933 }
934 
935 
941 template <class FS>
942 bool ImageDb<FS>::SetOrientation(int id, int orientation) const
943 {
945 
946  query.prepare(QString("UPDATE %1 SET ").arg(m_table) +
947  "orientation = :ORIENTATION "
948  "WHERE file_id = :ID");
949  query.bindValue(":ORIENTATION", orientation);
950  query.bindValue(":ID", FS::DbId(id));
951  \
952  if (query.exec())
953  return true;
954 
956  return false;
957 }
958 
959 
967 template <class FS>
969  const QString &selector) const
970 {
972  query.prepare(QString("SELECT " DB_COLUMNS " FROM %1 WHERE %2")
973  .arg(m_table, selector));
974  if (!query.exec())
975  {
977  return -1;
978  }
979 
980  while (query.next())
981  {
982  ImagePtr im(CreateImage(query));
983 
984  if (im->IsFile())
985  files.append(im);
986  else
987  dirs.append(im);
988  }
989  return query.size();
990 }
991 
992 
1002 template <class FS>
1003 void ImageDb<FS>::GetDescendantCount(int id, bool all, int &dirs,
1004  int &pics, int &videos, int &sizeKb) const
1005 {
1006  QString whereClause;
1007  if (!all)
1008  {
1009  whereClause = "WHERE filename LIKE "
1010  "( SELECT CONCAT(filename, '/%') "
1011  " FROM %2 WHERE file_id = :ID);";
1012  }
1013 
1015  query.prepare(QString("SELECT SUM(type <= :FLDR) AS Fldr, "
1016  " SUM(type = :PIC) AS Pics, "
1017  " SUM(type = :VID) AS Vids, "
1018  " SUM(size / 1024) "
1019  "FROM %2 %1;").arg(whereClause).arg(m_table));
1020 
1021  query.bindValue(":FLDR", kDirectory);
1022  query.bindValue(":PIC", kImageFile);
1023  query.bindValue(":VID", kVideoFile);
1024  if (!all)
1025  query.bindValue(":ID", FS::DbId(id));
1026 
1027  if (!query.exec())
1028  {
1030  }
1031  else if (query.next())
1032  {
1033  dirs += query.value(0).toInt();
1034  pics += query.value(1).toInt();
1035  videos += query.value(2).toInt();
1036  sizeKb += query.value(3).toInt();
1037  }
1038 }
1039 
1040 
1045 {
1046  // Be has a single SG device
1048 }
1049 
1050 
1055  : ImageDb(QString("`%1_%2`").arg(DB_TABLE, gCoreContext->GetHostName()))
1056 {
1057  // Remove any table leftover from a previous FE crash
1058  DropTable();
1059 }
1060 
1061 
1066 {
1068  query.prepare(QString("DROP TABLE IF EXISTS %1;").arg(m_table));
1069  if (query.exec())
1070  m_dbExists = false;
1071  else
1073 }
1074 
1075 
1080 {
1081  if (m_dbExists)
1082  return true;
1083 
1085 
1086  // Create temporary table
1087  query.prepare(QString("CREATE TABLE %1 LIKE " DB_TABLE ";").arg(m_table));
1088  if (query.exec())
1089  {
1090  // Store it in memory only
1091  query.prepare(QString("ALTER TABLE %1 ENGINE = MEMORY;").arg(m_table));
1092  if (query.exec())
1093  {
1094  m_dbExists = true;
1095  LOG(VB_FILE, LOG_DEBUG, QString("Created Db table %1").arg(m_table));
1096  return true;
1097  }
1098  }
1100 
1101  // Clean up after failure
1102  query.prepare(QString("DROP TABLE IF EXISTS %1;").arg(m_table));
1103  query.exec();
1104  return false;
1105 }
1106 
1107 
1111 class ReadMetaThread : public QRunnable
1112 {
1113 public:
1114  ReadMetaThread(ImagePtrK im, QString path)
1115  : m_im(std::move(im)), m_path(std::move(path)) {}
1116 
1117  void run() override // QRunnable
1118  {
1119  QStringList tags;
1120  QString orientation;
1121  QString size;
1122 
1123  // Read metadata for files only
1124  if (m_im->IsFile())
1125  {
1126  ImageMetaData *metadata = (m_im->m_type == kVideoFile)
1129  tags = metadata->GetAllTags();
1130  orientation = Orientation(m_im->m_orientation).Description();
1131  size = ImageAdapterBase::FormatSize(m_im->m_size / 1024);
1132  delete metadata;
1133  }
1134 
1135  // Add identifier at front
1136  tags.prepend(QString::number(m_im->m_id));
1137 
1138  // Include file info
1139  tags << ImageMetaData::ToString(EXIF_MYTH_HOST, "Host",
1141  tags << ImageMetaData::ToString(EXIF_MYTH_PATH, "Path",
1143  tags << ImageMetaData::ToString(EXIF_MYTH_NAME, "Name",
1145  tags << ImageMetaData::ToString(EXIF_MYTH_SIZE, "Size", size);
1146  tags << ImageMetaData::ToString(EXIF_MYTH_ORIENT, "Orientation",
1147  orientation);
1148 
1149  MythEvent me("IMAGE_METADATA", tags);
1150  gCoreContext->SendEvent(me);
1151  }
1152 
1153 private:
1155  QString m_path;
1156 };
1157 
1158 
1167 template <class DBFS>
1168 QStringList ImageHandler<DBFS>::HandleGetMetadata(const QString &id) const
1169 {
1170  // Find image in DB
1171  ImageList files;
1172  ImageList dirs;
1173  if (DBFS::GetImages(id, files, dirs) != 1)
1174  RESULT_ERR("Image not found", QString("Unknown image %1").arg(id))
1175 
1176  ImagePtr im = files.isEmpty() ? dirs[0] : files[0];
1177 
1178  QString absPath = DBFS::GetAbsFilePath(im);
1179  if (absPath.isEmpty())
1180  RESULT_ERR("Image not found",
1181  QString("File %1 not found").arg(im->m_filePath))
1182 
1183  auto *worker = new ReadMetaThread(im, absPath);
1184 
1185  MThreadPool::globalInstance()->start(worker, "ImageMetaData");
1186 
1187  RESULT_OK(QString("Fetching metadata for %1").arg(id))
1188 }
1189 
1190 
1198 template <class DBFS>
1199 QStringList ImageHandler<DBFS>::HandleRename(const QString &id,
1200  const QString &newBase) const
1201 {
1202  // Sanity check new name
1203  if (newBase.isEmpty() || newBase.contains("/") || newBase.contains("\\"))
1204  RESULT_ERR("Invalid name", QString("Invalid name %1").arg(newBase))
1205 
1206  // Find image in DB
1207  ImageList files;
1208  ImageList dirs;
1209  if (DBFS::GetImages(id, files, dirs) != 1)
1210  RESULT_ERR("Image not found", QString("Image %1 not in Db").arg(id))
1211 
1212  ImagePtr im = files.isEmpty() ? dirs[0] : files[0];
1213 
1214  // Find file
1215  QString oldPath = DBFS::GetAbsFilePath(im);
1216  if (oldPath.isEmpty())
1217  RESULT_ERR("Image not found",
1218  QString("File %1 not found").arg(im->m_filePath))
1219 
1220  // Generate new filename
1221  QFileInfo oldFi = QFileInfo(oldPath);
1222  QString newName = im->IsDirectory()
1223  ? newBase : QString("%1.%2").arg(newBase, oldFi.suffix());
1224 
1225  im->m_filePath = DBFS::ConstructPath(DBFS::PathOf(im->m_filePath), newName);
1226 
1227  // Ensure no SG duplicate files are created. (Creating clone dirs is ok)
1228  if (im->IsFile())
1229  {
1230  QString existPath = DBFS::GetAbsFilePath(im);
1231  if (!existPath.isEmpty())
1232  RESULT_ERR("Filename already used",
1233  QString("Renaming %1 to %2 will create a duplicate of %3")
1234  .arg(oldPath, im->m_filePath, existPath))
1235  }
1236 
1237  // Rename file or directory
1238  QString newPath = oldFi.dir().absoluteFilePath(newName);
1239  if (!QFile::rename(oldPath, newPath))
1240  RESULT_ERR("Rename failed",
1241  QString("Rename of %1 -> %2 failed").arg(oldPath, newPath))
1242 
1243  if (im->IsDirectory())
1244  {
1245  // Dir name change affects path of all sub-dirs & files and their thumbs
1246  HandleScanRequest("START");
1247  }
1248  else // file
1249  {
1250  // Update db
1251  DBFS::UpdateDbImage(*im);
1252 
1253  // Image is modified, not deleted
1254  QStringList mesg("");
1255  mesg << QString::number(im->m_id);
1256 
1257  // Rename thumbnail.
1258  m_thumbGen->MoveThumbnail(im);
1259 
1260  // Notify clients of changed image
1261  DBFS::Notify("IMAGE_DB_CHANGED", mesg);
1262  }
1263  RESULT_OK(QString("Renamed %1 -> %2").arg(oldPath, newPath))
1264 }
1265 
1266 
1274 template <class DBFS>
1275 QStringList ImageHandler<DBFS>::HandleDelete(const QString &ids) const
1276 {
1277  // Get subtree of all files
1278  ImageList files;
1279  ImageList dirs;
1280  // Dirs will be in depth-first order, (subdirs after parent)
1281  DBFS::GetDescendants(ids, files, dirs);
1282 
1283  // Remove files from filesystem first
1284  RemoveFiles(files);
1285  // ... then dirs, which should now be empty
1286  RemoveFiles(dirs);
1287 
1288  // Fail if nothing deleted
1289  if (files.isEmpty() && dirs.isEmpty())
1290  RESULT_ERR("Delete failed", QString("Delete of %1 failed").arg(ids))
1291 
1292  // Update Db
1293  DBFS::RemoveFromDB(files + dirs);
1294 
1295  // Clean up thumbnails
1296  QStringList mesg(m_thumbGen->DeleteThumbs(files));
1297 
1298  // Notify clients of deleted ids
1299  DBFS::Notify("IMAGE_DB_CHANGED", mesg);
1300 
1301  return QStringList("OK");
1302 }
1303 
1304 
1317 template <class DBFS>
1318 QStringList ImageHandler<DBFS>::HandleDbCreate(QStringList defs) const
1319 {
1320  if (defs.isEmpty())
1321  RESULT_ERR("Copy Failed", "Empty defs")
1322 
1323  // First item is the field seperator
1324  const QString separator = defs.takeFirst();
1325 
1326  // Convert cover ids to their new equivalent. Map<source id, new id>
1327  // Dirs follow their children so new cover ids will be defined before they
1328  // are used
1329  QHash<QString, int> idMap;
1330 
1331  // Create skeleton Db images using copied settings.
1332  // Scanner will update other attributes
1333  ImageItem im;
1334  for (const auto& def : qAsConst(defs))
1335  {
1336  QStringList aDef = def.split(separator);
1337 
1338  // Expects id, type, path, hidden, orientation, cover
1339  if (aDef.size() != 6)
1340  {
1341  // Coding error
1342  LOG(VB_GENERAL, LOG_ERR,
1343  LOC + QString("Bad definition: (%1)").arg(def));
1344  continue;
1345  }
1346 
1347  LOG(VB_FILE, LOG_DEBUG, LOC + QString("Creating %1").arg(aDef.join(",")));
1348 
1349  im.m_type = aDef[1].toInt();
1350  im.m_filePath = aDef[2];
1351  im.m_isHidden = (aDef[3].toInt() != 0);
1352  im.m_orientation = aDef[4].toInt();
1353  im.m_userThumbnail = idMap.value(aDef[5]);
1354 
1355  // Don't insert duplicate filepaths
1356  int newId = DBFS::InsertDbImage(im, true);
1357 
1358  // Record old->new id map in case it's being used as a cover
1359  idMap.insert(aDef[0], newId);
1360  }
1361  HandleScanRequest("START");
1362 
1363  RESULT_OK("Created Db images")
1364 }
1365 
1366 
1376 template <class DBFS>
1377 QStringList ImageHandler<DBFS>::HandleDbMove(const QString &ids,
1378  const QString &srcPath,
1379  QString destPath) const
1380 {
1381  // Sanity check new path
1382  if (destPath.contains(".."))
1383  RESULT_ERR("Invalid path", QString("Invalid path %1").arg(destPath))
1384 
1385  // Get subtrees of renamed files
1386  ImageList images;
1387  ImageList dirs;
1388  ImageList files;
1389  bool ok = DBFS::GetDescendants(ids, files, dirs);
1390  images << dirs << files;
1391 
1392  if (!ok || images.isEmpty())
1393  RESULT_ERR("Image not found", QString("Images %1 not in Db").arg(ids))
1394 
1395  if (!destPath.isEmpty() && !destPath.endsWith(QChar('/')))
1396  destPath.append("/");
1397 
1398  // Update path of images only. Scanner will repair parentId
1399  for (const auto& im : qAsConst(images))
1400  {
1401  QString old = im->m_filePath;
1402 
1403  if (srcPath.isEmpty())
1404  {
1405  // Image in SG root
1406  im->m_filePath.prepend(destPath);
1407  }
1408  else if (im->m_filePath.startsWith(srcPath))
1409  {
1410  // All other images
1411  im->m_filePath.replace(srcPath, destPath);
1412  }
1413  else
1414  {
1415  // Coding error
1416  LOG(VB_GENERAL, LOG_ERR,
1417  LOC + QString("Bad image: (%1 -> %2)").arg(srcPath, destPath));
1418  continue;
1419  }
1420 
1421  LOG(VB_FILE, LOG_DEBUG,
1422  LOC + QString("Db Renaming %1 -> %2").arg(old, im->m_filePath));
1423 
1424  DBFS::UpdateDbImage(*im);
1425 
1426  // Rename thumbnail
1427  if (im->IsFile())
1428  m_thumbGen->MoveThumbnail(im);
1429  }
1430  HandleScanRequest("START");
1431 
1432  RESULT_OK(QString("Moved %1 from %2 -> %3").arg(ids).arg(srcPath, destPath))
1433 }
1434 
1435 
1443 template <class DBFS>
1444 QStringList ImageHandler<DBFS>::HandleHide(bool hide, const QString &ids) const
1445 {
1446  if (!DBFS::SetHidden(hide, ids))
1447  RESULT_ERR("Hide failed", QString("Db hide failed for %1").arg(ids))
1448 
1449  // Send changed ids only (none deleted)
1450  QStringList mesg = QStringList("") << ids;
1451  DBFS::Notify("IMAGE_DB_CHANGED", mesg);
1452 
1453  RESULT_OK(QString("Images %1 now %2hidden").arg(ids, hide ? "" : "un"))
1454 }
1455 
1456 
1465 template <class DBFS>
1466 QStringList ImageHandler<DBFS>::HandleTransform(int transform,
1467  const QString &ids) const
1468 {
1469  if (transform < kResetToExif || transform > kFlipVertical)
1470  RESULT_ERR("Transform failed", QString("Bad transform %1").arg(transform))
1471 
1472  ImageList files;
1473  ImageList dirs;
1474  if (DBFS::GetImages(ids, files, dirs) < 1 || files.isEmpty())
1475  RESULT_ERR("Image not found", QString("Images %1 not in Db").arg(ids))
1476 
1477  // Update db
1478  for (const auto& im : qAsConst(files))
1479  {
1480  int old = im->m_orientation;
1481  im->m_orientation = Orientation(im->m_orientation).Transform(transform);
1482 
1483  // Update Db
1484  if (DBFS::SetOrientation(im->m_id, im->m_orientation))
1485  {
1486  LOG(VB_FILE, LOG_DEBUG, LOC + QString("Transformed %1 from %2 to %3")
1487  .arg(im->m_filePath).arg(old).arg(im->m_orientation));
1488  }
1489  }
1490 
1491  // Images are changed, not deleted
1492  QStringList mesg("");
1493 
1494  // Clean up thumbnails
1495  mesg << m_thumbGen->DeleteThumbs(files);
1496 
1497  // Notify clients of changed images
1498  DBFS::Notify("IMAGE_DB_CHANGED", mesg);
1499 
1500  return QStringList("OK");
1501 }
1502 
1503 
1512 template <class DBFS>
1513 QStringList ImageHandler<DBFS>::HandleDirs(const QString &destId,
1514  bool rescan,
1515  const QStringList &relPaths) const
1516 {
1517  // Find image in DB
1518  ImageList files;
1519  ImageList dirs;
1520  if (DBFS::GetImages(destId, files, dirs) != 1 || dirs.isEmpty())
1521  RESULT_ERR("Destination not found",
1522  QString("Image %1 not in Db").arg(destId))
1523 
1524  // Find dir. SG device (Photographs) uses most-free filesystem
1525  QString destPath = DBFS::GetAbsFilePath(dirs[0]);
1526  if (destPath.isEmpty())
1527  RESULT_ERR("Destination not found",
1528  QString("Dest dir %1 not found").arg(dirs[0]->m_filePath))
1529 
1530  QDir destDir(destPath);
1531  bool succeeded = false;
1532  for (const auto& relPath : qAsConst(relPaths))
1533  {
1534  // Validate dir name
1535  if (relPath.isEmpty() || relPath.contains("..") || relPath.startsWith(QChar('/')))
1536  continue;
1537 
1538  QString newPath = DBFS::ConstructPath(destDir.absolutePath(), relPath);
1539  if (!destDir.mkpath(relPath))
1540  {
1541  LOG(VB_GENERAL, LOG_ERR,
1542  LOC + QString("Failed to create dir %1").arg(newPath));
1543  continue;
1544  }
1545  LOG(VB_FILE, LOG_DEBUG, LOC + QString("Dir %1 created").arg(newPath));
1546  succeeded = true;
1547  }
1548 
1549  if (!succeeded)
1550  // Failures should only occur due to user input
1551  RESULT_ERR("Invalid Name", QString("Invalid name %1")
1552  .arg(relPaths.join(",")))
1553 
1554  if (rescan)
1555  // Rescan to detect new dir
1556  HandleScanRequest("START");
1557 
1558  return QStringList("OK");
1559 }
1560 
1561 
1568 template <class DBFS>
1569 QStringList ImageHandler<DBFS>::HandleCover(int dir, int cover) const
1570 {
1571  if (!DBFS::SetCover(dir, cover))
1572  RESULT_ERR("Set Cover failed",
1573  QString("Failed to set %1 to cover %2").arg(dir).arg(cover))
1574 
1575  // Image has changed, nothing deleted
1576  QStringList mesg = QStringList("") << QString::number(dir);
1577  DBFS::Notify("IMAGE_DB_CHANGED", mesg);
1578 
1579  RESULT_OK(QString("Cover of %1 is now %2").arg(dir).arg(cover));
1580 }
1581 
1582 
1591 template <class DBFS>
1592 QStringList ImageHandler<DBFS>::HandleIgnore(const QString &exclusions) const
1593 {
1594  // Save new setting. FE will have already saved it but not cleared the cache
1595  gCoreContext->SaveSettingOnHost("GalleryIgnoreFilter", exclusions, nullptr);
1596 
1597  // Rescan
1598  HandleScanRequest("START");
1599 
1600  RESULT_OK(QString("Using exclusions '%1'").arg(exclusions))
1601 }
1602 
1603 
1611 template <class DBFS>
1612 QStringList ImageHandler<DBFS>::HandleScanRequest(const QString &command,
1613  int devId) const
1614 {
1615  if (!m_scanner)
1616  RESULT_ERR("Missing Scanner", "Missing Scanner");
1617 
1618  if (command == "START")
1619  {
1620  // Must be dormant to start a scan
1621  if (m_scanner->IsScanning())
1622  RESULT_ERR("", "Scanner is busy");
1623 
1624  m_scanner->ChangeState(true);
1625  RESULT_OK("Scan requested");
1626  }
1627  else if (command == "STOP")
1628  {
1629  // Must be scanning to interrupt
1630  if (!m_scanner->IsScanning())
1631  RESULT_ERR("Scanner not running", "Scanner not running");
1632 
1633  m_scanner->ChangeState(false);
1634  RESULT_OK("Terminate scan requested");
1635  }
1636  else if (command == "QUERY")
1637  {
1638  return QStringList("OK") << m_scanner->GetProgress();
1639  }
1640  else if (command.startsWith(QString("DEVICE")))
1641  {
1642  m_scanner->EnqueueClear(devId, command);
1643  RESULT_OK(QString("Clearing device %1 %2").arg(command).arg(devId))
1644  }
1645  RESULT_ERR("Unknown command", QString("Unknown command %1").arg(command));
1646 }
1647 
1648 
1656 template <class DBFS>
1658 (const QStringList &message) const
1659 {
1660  if (message.size() != 2)
1661  RESULT_ERR("Unknown Command",
1662  QString("Bad request: %1").arg(message.join("|")))
1663 
1664  int priority = message.at(0).toInt()
1666 
1667  // get specific image details from db
1668  ImageList files;
1669  ImageList dirs;
1670  DBFS::GetImages(message.at(1), files, dirs);
1671 
1672  for (const auto& im : qAsConst(files))
1673  // notify clients when done; highest priority
1674  m_thumbGen->CreateThumbnail(im, priority, true);
1675 
1676  return QStringList("OK");
1677 }
1678 
1679 
1689 template <class DBFS>
1691 {
1692  QMutableVectorIterator<ImagePtr> it(images);
1693  it.toBack();
1694  while (it.hasPrevious())
1695  {
1696  ImagePtrK im = it.previous();
1697 
1698  // Remove file or directory
1699  QString absFilename = DBFS::GetAbsFilePath(im);
1700 
1701  bool success = !absFilename.isEmpty()
1702  && (im->IsFile() ? QFile::remove(absFilename)
1703  : QDir::root().rmdir(absFilename));
1704  if (success)
1705  LOG(VB_FILE, LOG_DEBUG, LOC + QString("Deleted %1").arg(absFilename));
1706  else
1707  {
1708  LOG(VB_GENERAL, LOG_ERR, LOC +
1709  QString("Can't delete %1").arg(absFilename));
1710  // Remove from list
1711  it.remove();
1712  }
1713  }
1714 }
1715 
1716 
1723 {
1724  switch (type)
1725  {
1726  case kPicOnly: return QString("AND type != %1").arg(kVideoFile);
1727  case kVideoOnly: return QString("AND type != %1").arg(kImageFile);
1728  case kPicAndVideo: return "";
1729  }
1730  return "";
1731 }
1732 
1733 
1740 {
1741  m_refineClause = QString("%2 %3 "
1742  "ORDER BY "
1743  "CASE WHEN type <= %1 THEN %4, "
1744  "CASE WHEN type > %1 THEN %5 ")
1745  .arg(kDirectory)
1746  .arg(m_showHidden ? "" : "AND hidden = 0",
1750 }
1751 
1752 
1759 {
1760  // prepare the sorting statement
1761  switch (order)
1762  {
1763  default:
1764  case kSortByNameAsc: return "name END ASC";
1765  case kSortByNameDesc: return "name END DESC";
1766  case kSortByModTimeAsc: return "modtime END ASC";
1767  case kSortByModTimeDesc: return "modtime END DESC";
1768  case kSortByExtAsc: return "extension END ASC, name ASC";
1769  case kSortByExtDesc: return "extension END DESC, name DESC";
1770  case kSortBySizeAsc: return "size END ASC, name ASC";
1771  case kSortBySizeDesc: return "size END DESC, name DESC";
1772  case kSortByDateAsc: return "IF(date=0, modtime, date) END ASC";
1773  case kSortByDateDesc: return "IF(date=0, modtime, date) END DESC";
1774  }
1775 }
1776 
1777 
1787  ImageList &files, ImageList &dirs) const
1788 {
1789  // Only Root node will invoke both Db queries but result set will be small
1790  // For Root the SG is always ordered before local devices
1791  // Root node has no Db entry so the 2 queries will not overwrite the parent.
1792  int count = 0;
1793  if (!ImageItem::IsLocalId(id))
1794  count = m_remote->GetDirectory(id, parent, files, dirs, m_refineClause);
1796  count += ImageHandler::GetDirectory(id, parent, files, dirs, m_refineClause);
1797 
1798  if (id == GALLERY_DB_ID)
1799  {
1800  // Add a Root node
1801  parent = ImagePtr(new ImageItem(GALLERY_DB_ID));
1802  parent->m_parentId = GALLERY_DB_ID;
1803  parent->m_type = kDevice;
1804 
1805  ++count;
1806  }
1807  return count;
1808 }
1809 
1810 
1819  ImageList &files, ImageList &dirs) const
1820 {
1821  // Ids are either all local or all remote. GALLERY_DB_ID not valid
1822  StringPair lists = ImageItem::PartitionIds(ids);
1823 
1824  if (!lists.second.isEmpty())
1825  return m_remote->GetImages(lists.second, files, dirs, m_refineClause);
1826  if (m_dbExists && !lists.first.isEmpty())
1827  return ImageHandler::GetImages(lists.first, files, dirs, m_refineClause);
1828  return 0;
1829 }
1830 
1831 
1839 int ImageDbReader::GetChildren(int id, ImageList &files, ImageList &dirs) const
1840 {
1841  int count = 0;
1842  if (!ImageItem::IsLocalId(id))
1843  count = m_remote->GetChildren(QString::number(id), files, dirs,
1844  m_refineClause);
1846  count += ImageHandler::GetChildren(QString::number(id), files, dirs,
1847  m_refineClause);
1848  return count;
1849 }
1850 
1851 
1859  ImageList &files, ImageList &dirs) const
1860 {
1861  // Ids are either all local or all remote
1862  StringPair lists = ImageItem::PartitionIds(ids);
1863 
1864  if (!lists.second.isEmpty())
1865  m_remote->GetDescendants(lists.second, files, dirs);
1866  if (m_dbExists && !lists.first.isEmpty())
1867  ImageHandler::GetDescendants(lists.first, files, dirs);
1868 }
1869 
1870 
1877 void ImageDbReader::GetImageTree(int id, ImageList &files) const
1878 {
1879  if (!ImageItem::IsLocalId(id))
1880  m_remote->GetImageTree(id, files, m_refineClause);
1882  ImageHandler::GetImageTree(id, files, m_refineClause);
1883 }
1884 
1885 
1894 void ImageDbReader::GetDescendantCount(int id, int &dirs, int &pics,
1895  int &videos, int &sizeKb) const
1896 {
1897  if (id == GALLERY_DB_ID)
1898  {
1899  // Sum both unfiltered tables
1900  m_remote->GetDescendantCount(id, true, dirs, pics, videos, sizeKb);
1901  if (m_dbExists)
1902  ImageHandler::GetDescendantCount(id, true, dirs, pics, videos, sizeKb);
1903  }
1904  else if (!ImageItem::IsLocalId(id))
1905  {
1906  // Don't filter on SG path (it's blank)
1908  dirs, pics, videos, sizeKb);
1909  }
1910  else if (m_dbExists)
1911  {
1912  // Always filter on device/dir
1913  ImageHandler::GetDescendantCount(id, false, dirs, pics, videos, sizeKb);
1914  }
1915 }
1916 
1917 
1922 
1923 
1929 {
1930  if (!s_instance)
1931  s_instance = new ImageManagerBe();
1932  return s_instance;
1933 }
1934 
1935 
1941 {
1942  if (!s_instance)
1943  {
1944  // Use saved settings
1946  (gCoreContext->GetNumSetting("GalleryImageOrder"),
1947  gCoreContext->GetNumSetting("GalleryDirOrder"),
1948  gCoreContext->GetBoolSetting("GalleryShowHidden"),
1949  gCoreContext->GetNumSetting("GalleryShowType"),
1950  gCoreContext->GetSetting("GalleryDateFormat"));
1951  }
1952  return *s_instance;
1953 }
1954 
1955 
1964 void ImageManagerFe::CreateThumbnails(const ImageIdList &ids, bool forFolder)
1965 {
1966  // Split images into <locals, remotes>
1967  StringPair lists = ImageItem::PartitionIds(ids);
1968 
1969  if (!lists.second.isEmpty())
1970  {
1971  LOG(VB_FILE, LOG_DEBUG, LOC +
1972  QString("Sending CREATE_THUMBNAILS %1 (forFolder %2)")
1973  .arg(lists.second).arg(forFolder));
1974 
1975  QStringList message;
1976  message << QString::number(static_cast<int>(forFolder)) << lists.second;
1977  gCoreContext->SendEvent(MythEvent("CREATE_THUMBNAILS", message));
1978  }
1979 
1980  if (!lists.first.isEmpty())
1981  {
1982  LOG(VB_FILE, LOG_DEBUG, LOC +
1983  QString("Creating local thumbnails %1 (forFolder %2)")
1984  .arg(lists.first).arg(forFolder));
1985 
1986  QStringList message;
1987  message << QString::number(static_cast<int>(forFolder)) << lists.first;
1988  HandleCreateThumbnails(message);
1989  }
1990 }
1991 
1992 
1999 QString ImageManagerFe::ScanImagesAction(bool start, bool local)
2000 {
2001  QStringList command;
2002  command << (start ? "START" : "STOP");
2003 
2004  if (!local)
2005  {
2006  command.push_front("IMAGE_SCAN");
2007  bool ok = gCoreContext->SendReceiveStringList(command, true);
2008  return ok ? "" : command[1];
2009  }
2010 
2011  // Create database on first scan
2012  if (!CreateTable())
2013  return "Couldn't create database";
2014 
2015  QStringList err = HandleScanRequest(command[0]);
2016  return err[0] == "OK" ? "" : err[1];
2017 }
2018 
2019 
2026 {
2027  QStringList strList;
2028  strList << "IMAGE_SCAN" << "QUERY";
2029 
2030  if (!gCoreContext->SendReceiveStringList(strList))
2031  {
2032  LOG(VB_GENERAL, LOG_ERR, LOC + QString("Scan query failed : %1")
2033  .arg(strList.join(",")));
2034  }
2035  return strList;
2036 }
2037 
2038 
2045 QString ImageManagerFe::HideFiles(bool hidden, const ImageIdList &ids)
2046 {
2047  // Split images into <locals, remotes>
2048  StringPair lists = ImageItem::PartitionIds(ids);
2049  QString result = "";
2050 
2051  if (!lists.second.isEmpty())
2052  {
2053  QStringList message;
2054  message << "IMAGE_HIDE" << QString::number(static_cast<int>(hidden)) << lists.second;
2055 
2056  if (!gCoreContext->SendReceiveStringList(message, true))
2057  result = message[1];
2058  }
2059 
2060  if (!lists.first.isEmpty())
2061  {
2062  QStringList err = HandleHide(hidden, lists.first);
2063  if (err[0] != "OK")
2064  result = err[1];
2065  }
2066  return result;
2067 }
2068 
2069 
2077  const ImageIdList &ids)
2078 {
2079  // Split images into <locals, remotes>
2080  StringPair lists = ImageItem::PartitionIds(ids);
2081  QString result = "";
2082 
2083  if (!lists.second.isEmpty())
2084  {
2085  QStringList message;
2086  message << "IMAGE_TRANSFORM" << QString::number(transform) << lists.second;
2087 
2088  if (!gCoreContext->SendReceiveStringList(message, true))
2089  result = message[1];
2090  }
2091 
2092  if (!lists.first.isEmpty())
2093  {
2094  QStringList err = HandleTransform(transform, lists.first);
2095  if (err[0] != "OK")
2096  result = err[1];
2097  }
2098  return result;
2099 }
2100 
2101 
2108 QString ImageManagerFe::SetCover(int parent, int cover)
2109 {
2110  if (!ImageItem::IsLocalId(parent))
2111  {
2112  QStringList message;
2113  message << "IMAGE_COVER" << QString::number(parent) << QString::number(cover);
2114 
2115  bool ok = gCoreContext->SendReceiveStringList(message, true);
2116  return ok ? "" : message[1];
2117  }
2118 
2119  QStringList err = HandleCover(parent, cover);
2120  return err[0] == "OK" ? "" : err[1];
2121 }
2122 
2123 
2129 {
2130  if (ImageItem::IsLocalId(id))
2131  HandleGetMetadata(QString::number(id));
2132  else
2133  gCoreContext->SendEvent(MythEvent("IMAGE_GET_METADATA", QString::number(id)));
2134 }
2135 
2136 
2139 {
2140  QStringList message("IMAGE_SCAN");
2141  message << "DEVICE CLEAR ALL";
2142  gCoreContext->SendReceiveStringList(message, true);
2143 }
2144 
2145 
2152 QString ImageManagerFe::IgnoreDirs(const QString &excludes)
2153 {
2154  QStringList message("IMAGE_IGNORE");
2155  message << excludes;
2156  bool ok = gCoreContext->SendReceiveStringList(message, true);
2157  return ok ? "" : message[1];
2158 }
2159 
2160 
2168 QString ImageManagerFe::MakeDir(int parent, const QStringList &names, bool rescan)
2169 {
2170  QString destId = QString::number(parent);
2171 
2172  if (!ImageItem::IsLocalId(parent))
2173  {
2174  QStringList message("IMAGE_CREATE_DIRS");
2175  message << destId << QString::number(static_cast<int>(rescan)) << names;
2176  bool ok = gCoreContext->SendReceiveStringList(message, true);
2177  return ok ? "" : message[1];
2178  }
2179  QStringList err = HandleDirs(destId, rescan, names);
2180  return (err[0] == "OK") ? "" : err[1];
2181 }
2182 
2183 
2190 QString ImageManagerFe::RenameFile(const ImagePtrK& im, const QString &name)
2191 {
2192  if (!im->IsLocal())
2193  {
2194  QStringList message("IMAGE_RENAME");
2195  message << QString::number(im->m_id) << name;
2196  bool ok = gCoreContext->SendReceiveStringList(message, true);
2197  return ok ? "" : message[1];
2198  }
2199  QStringList err = HandleRename(QString::number(im->m_id), name);
2200  return (err[0] == "OK") ? "" : err[1];
2201 }
2202 
2203 
2210 QString ImageManagerFe::CreateImages(int destId, const ImageListK &images)
2211 {
2212  if (images.isEmpty())
2213  return "";
2214 
2215  // Define field seperator & include it in message
2216  const QString seperator("...");
2217  QStringList imageDefs(seperator);
2218  ImageIdList ids;
2219  for (const auto& im : qAsConst(images))
2220  {
2221  ids << im->m_id;
2222 
2223  // Copies preserve hide state, orientation & cover
2224  QStringList aDef;
2225  aDef << QString::number(im->m_id)
2226  << QString::number(im->m_type)
2227  << im->m_filePath
2228  << QString::number(static_cast<int>(im->m_isHidden))
2229  << QString::number(im->m_orientation)
2230  << QString::number(im->m_userThumbnail);
2231 
2232  imageDefs << aDef.join(seperator);
2233  }
2234 
2235  // Images are either all local or all remote
2236  if (ImageItem::IsLocalId(destId))
2237  {
2238  QStringList err = HandleDbCreate(imageDefs);
2239  return (err[0] == "OK") ? "" : err[1];
2240  }
2241  imageDefs.prepend("IMAGE_COPY");
2242  bool ok = gCoreContext->SendReceiveStringList(imageDefs, true);
2243  return ok ? "" : imageDefs[1];
2244 }
2245 
2246 
2254 QString ImageManagerFe::MoveDbImages(const ImagePtrK& destDir, ImageListK &images,
2255  const QString &srcPath)
2256 {
2257  QStringList idents;
2258  for (const auto& im : qAsConst(images))
2259  idents << QString::number(im->m_id);
2260 
2261  // Images are either all local or all remote
2262  if (destDir->IsLocal())
2263  {
2264  QStringList err = HandleDbMove(idents.join(","), srcPath,
2265  destDir->m_filePath);
2266  return (err[0] == "OK") ? "" : err[1];
2267  }
2268 
2269  QStringList message("IMAGE_MOVE");
2270  message << idents.join(",") << srcPath << destDir->m_filePath;
2271  bool ok = gCoreContext->SendReceiveStringList(message, true);
2272  return ok ? "" : message[1];
2273 }
2274 
2275 
2282 {
2283  StringPair lists = ImageItem::PartitionIds(ids);
2284 
2285  QString result = "";
2286  if (!lists.second.isEmpty())
2287  {
2288  QStringList message("IMAGE_DELETE");
2289  message << lists.second;
2290 
2291  bool ok = gCoreContext->SendReceiveStringList(message, true);
2292  if (!ok)
2293  result = message[1];
2294  }
2295  if (!lists.first.isEmpty())
2296  {
2297  QStringList err = HandleDelete(lists.first);
2298  if (err[0] != "OK")
2299  result = err[1];
2300  }
2301  return result;
2302 }
2303 
2304 
2312 {
2313  if (im->m_id == GALLERY_DB_ID)
2314  return "";
2315 
2316  qint64 secs = 0;
2318 
2319  if (im->m_date > 0)
2320  {
2321  secs = im->m_date;
2322  format |= MythDate::kTime;
2323  }
2324  else
2325  secs = im->m_modTime;
2326 
2327  return MythDate::toString(QDateTime::fromSecsSinceEpoch(secs), format);
2328 }
2329 
2330 
2337 QString ImageManagerFe::ShortDateOf(const ImagePtrK& im) const
2338 {
2339  if (im->m_id == GALLERY_DB_ID)
2340  return "";
2341 
2342  qint64 secs(im->m_date > 0 ? im->m_date : im->m_modTime);
2343  return QDateTime::fromSecsSinceEpoch(secs).date().toString(m_dateFormat);
2344 }
2345 
2346 
2353 {
2354  if (im.m_id == GALLERY_DB_ID)
2355  return tr("Gallery");
2356  if (im.m_id == PHOTO_DB_ID)
2357  return tr("Photographs");
2358  return im.IsLocal() ? DeviceName(im.m_device)
2359  : m_remote->DeviceName(im.m_device);
2360 }
2361 
2362 
2370 QString ImageManagerFe::CrumbName(ImageItemK &im, bool getPath) const
2371 {
2372  if (im.IsDevice())
2373  return DeviceCaption(im);
2374 
2375  if (!getPath)
2376  return im.m_baseName;
2377 
2378  QString dev;
2379  QString path(im.m_filePath);
2380 
2381  if (im.IsLocal())
2382  {
2383  // Replace local mount path with device name
2384  path.remove(0, DeviceMount(im.m_device).size());
2385  dev = DeviceName(im.m_device);
2386  }
2387  return dev + path.replace("/", " > ");
2388 }
2389 
2390 
2391 void ImageManagerFe::CloseDevices(int devId, bool eject)
2392 {
2393  QString reason = (devId == DEVICE_INVALID)
2394  ? "DEVICE CLOSE ALL"
2395  : eject ? "DEVICE EJECT" : "DEVICE REMOVE";
2396  HandleScanRequest(reason, devId);
2397 }
2398 
2399 
2405 {
2407  if (!monitor)
2408  return false;
2409 
2410  // Detect all local media
2411  QList<MythMediaDevice*> devices
2413 
2414  for (auto *dev : qAsConst(devices))
2415  {
2416  if (monitor->ValidateAndLock(dev) && dev->isUsable())
2417  OpenDevice(dev->getDeviceModel(), dev->getMountPath(), dev);
2418  else
2419  monitor->Unlock(dev);
2420  }
2421 
2422  if (DeviceCount() > 0)
2423  {
2424  // Close devices that are no longer present
2425  QList absentees = GetAbsentees();
2426  for (int devId : qAsConst(absentees))
2427  CloseDevices(devId);
2428 
2429  // Start local scan
2430  QString err = ScanImagesAction(true, true);
2431  if (!err.isEmpty())
2432  LOG(VB_GENERAL, LOG_ERR, LOC + err);
2433  }
2434  return DeviceCount() > 0;
2435 }
2436 
2437 
2443 {
2445 
2446  if (!event || !monitor)
2447  return;
2448 
2449  MythMediaDevice *dev = event->getDevice();
2450  if (!dev)
2451  return;
2452 
2453  MythMediaType type = dev->getMediaType();
2454  MythMediaStatus status = dev->getStatus();
2455 
2456  LOG(VB_FILE, LOG_DEBUG, LOC +
2457  QString("Media event for %1 (%2) at %3, type %4, status %5 (was %6)")
2458  .arg(dev->getDeviceModel(), dev->getVolumeID(), dev->getMountPath())
2459  .arg(type).arg(status).arg(event->getOldStatus()));
2460 
2462  {
2463  LOG(VB_FILE, LOG_DEBUG, LOC +
2464  QString("Ignoring event - wrong type %1").arg(type));
2465  return;
2466  }
2467 
2468  if (status == MEDIASTAT_USEABLE || status == MEDIASTAT_MOUNTED)
2469  {
2470  // New device. Lock it & scan
2471  if (monitor->ValidateAndLock(dev))
2472  {
2473  OpenDevice(dev->getDeviceModel(), dev->getMountPath(), dev);
2474  ScanImagesAction(true, true);
2475  }
2476  else
2477  monitor->Unlock(dev);
2478  return;
2479  }
2480 
2481  // Device has disappeared
2482  int devId = LocateMount(dev->getMountPath());
2483  if (devId != DEVICE_INVALID)
2484  CloseDevices(devId);
2485 }
2486 
2487 
2489 {
2490  auto *tmp = new QTemporaryDir(QDir::tempPath() % "/" IMPORTDIR "-XXXXXX");
2491  if (!tmp->isValid())
2492  {
2493  delete tmp;
2494  return "";
2495  }
2496 
2497  QString time(QDateTime::currentDateTime().toString("mm:ss"));
2498  OpenDevice("Import " + time, tmp->path(), nullptr, tmp);
2499  return tmp->path();
2500 }
2501 
2502 
2503 // Must define the valid template implementations to generate code for the
2504 // instantiations (as they are defined in the cpp rather than header).
2505 // Otherwise the linker will fail with undefined references...
2506 template class ImageDb<ImageAdapterSg>;
2507 template class ImageDb<ImageAdapterLocal>;
2508 template class ImageHandler<ImageDbSg>;
2509 template class ImageHandler<ImageDbLocal>;
MythMediaDevice::getMountPath
const QString & getMountPath() const
Definition: mythmedia.h:58
ImageAdapterBase::ImageAdapterBase
ImageAdapterBase()
Constructor.
Definition: imagemanager.cpp:276
MythMediaEvent::getOldStatus
MythMediaStatus getOldStatus(void) const
Definition: mythmedia.h:190
ImageManagerBe::s_instance
static ImageManagerBe * s_instance
BE Gallery instance.
Definition: imagemanager.h:391
kPicAndVideo
@ kPicAndVideo
Show Pictures & Videos.
Definition: imagemanager.h:78
kSortByNameDesc
@ kSortByNameDesc
Name Z-A.
Definition: imagetypes.h:46
ImageManagerFe::m_dateFormat
QString m_dateFormat
UI format for thumbnail date captions.
Definition: imagemanager.h:514
ImageManagerFe::ImageManagerFe
ImageManagerFe(int order, int dirOrder, bool showAll, int showType, QString dateFormat)
Definition: imagemanager.h:501
MEDIATYPE_MIXED
@ MEDIATYPE_MIXED
Definition: mythmedia.h:27
MSqlQuery::next
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
Definition: mythdbcon.cpp:783
ImagePtrK
QSharedPointer< ImageItemK > ImagePtrK
Definition: imagetypes.h:164
MSqlQuery
QSqlQuery wrapper that fetches a DB connection from the connection pool.
Definition: mythdbcon.h:126
ImageDbReader::m_showType
int m_showType
Type of images to display - pic only/video only/both.
Definition: imagemanager.h:443
ImageHandler::HandleRename
QStringList HandleRename(const QString &id, const QString &newBase) const
Change name of an image/dir.
Definition: imagemanager.cpp:1199
PHOTO_DB_ID
#define PHOTO_DB_ID
Definition: imagetypes.h:28
Device::m_thumbs
QString m_thumbs
Dir sub-path of device thumbnails.
Definition: imagemanager.cpp:113
MythDate::toString
QString toString(const QDateTime &raw_dt, uint format)
Returns formatted string representing the time.
Definition: mythdate.cpp:80
MSqlQuery::size
int size(void) const
Definition: mythdbcon.h:203
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
ImageDb::SetHidden
bool SetHidden(bool hide, QString ids) const
Sets hidden status of an image/dir in database.
Definition: imagemanager.cpp:892
DeviceManager::GetDeviceDirs
StringMap GetDeviceDirs() const
Get all known devices.
Definition: imagemanager.cpp:246
root
QDomElement root
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:656
ImageManagerFe::OpenDevice
int OpenDevice(const QString &name, const QString &mount, MythMediaDevice *media=nullptr, QTemporaryDir *dir=nullptr)
Define a new device and assign it a unique id. If the device is already known, its existing id is ret...
Definition: imagemanager.cpp:157
ImageAdapterBase::BaseNameOf
static QString BaseNameOf(const QString &path)
Extracts file name (incl extension) from a filepath.
Definition: imagemanager.h:136
ImageManagerFe::CreateThumbnails
void CreateThumbnails(const ImageIdList &ids, bool forFolder)
Create thumbnails or verify that they already exist.
Definition: imagemanager.cpp:1964
ImageDbLocal::m_dbExists
bool m_dbExists
Definition: imagemanager.h:329
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
ImageItem::m_type
int m_type
Type of node: dir, video etc.
Definition: imagetypes.h:96
kVideoFile
@ kVideoFile
A video.
Definition: imagetypes.h:39
MediaMonitor::GetMedias
QList< MythMediaDevice * > GetMedias(unsigned mediatypes)
Ask for available media.
Definition: mythmediamonitor.cpp:619
ReadMetaThread
Task to read all metadata from file.
Definition: imagemanager.cpp:1112
Device::isImport
bool isImport() const
Definition: imagemanager.cpp:105
ImageItem::m_id
int m_id
Uniquely identifies an image (file/dir).
Definition: imagetypes.h:88
ImageDb::UpdateDbImage
bool UpdateDbImage(ImageItemK &im) const
Updates or creates database image or dir.
Definition: imagemanager.cpp:819
MythCoreContext::SendReceiveStringList
bool SendReceiveStringList(QStringList &strlist, bool quickTimeout=false, bool block=true)
Send a message to the backend and wait for a response.
Definition: mythcorecontext.cpp:1376
kSortByExtDesc
@ kSortByExtDesc
Extension Z-A.
Definition: imagetypes.h:50
ImageItem::m_comment
QString m_comment
User comment, from Exif metadata.
Definition: imagetypes.h:101
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
ImageManagerFe::CreateImages
QString CreateImages(int destId, const ImageListK &images)
Copies database images (but not the files themselves).
Definition: imagemanager.cpp:2210
ImageManagerFe::ScanImagesAction
QString ScanImagesAction(bool start, bool local=false)
Handle scanner start/stop commands.
Definition: imagemanager.cpp:1999
LOC
#define LOC
Definition: imagemanager.cpp:13
ImageHandler::HandleGetMetadata
QStringList HandleGetMetadata(const QString &id) const
Read meta data for an image.
Definition: imagemanager.cpp:1168
MediaMonitor::GetMediaMonitor
static MediaMonitor * GetMediaMonitor(void)
Definition: mythmediamonitor.cpp:83
ImageItem::IsLocal
bool IsLocal() const
Definition: imagetypes.h:118
ImageDbLocal::DropTable
void DropTable()
Remove local image table.
Definition: imagemanager.cpp:1065
ImageMetaData
Abstract class for image metadata.
Definition: imagemetadata.h:100
ImageManagerFe::s_instance
static ImageManagerFe * s_instance
FE Gallery instance.
Definition: imagemanager.h:511
DeviceManager::DeviceName
QString DeviceName(int devId) const
Get model name of the device.
Definition: imagemanager.cpp:136
kNullDevice
static Device kNullDevice
Definition: imagemanager.cpp:119
ImageManagerFe::MakeDir
QString MakeDir(int parent, const QStringList &names, bool rescan=true)
Create directories.
Definition: imagemanager.cpp:2168
ImageDbReader::m_showHidden
bool m_showHidden
Whether hidden images are displayed.
Definition: imagemanager.h:442
ImageItem::m_isHidden
bool m_isHidden
If true, image won't be shown.
Definition: imagetypes.h:104
Device::RemoveDirContents
static void RemoveDirContents(const QString &path)
Clears all files and sub-dirs within a directory.
Definition: imagemanager.cpp:88
StorageGroup::FindFile
QString FindFile(const QString &filename)
Definition: storagegroup.cpp:602
kDirectory
@ kDirectory
A device sub directory.
Definition: imagetypes.h:37
DB_COLUMNS
#define DB_COLUMNS
Definition: imagemanager.cpp:489
ImageManagerFe::DeviceCount
int DeviceCount() const
Definition: imagemanager.h:100
MSqlQuery::lastInsertId
QVariant lastInsertId()
Return the id of the last inserted row.
Definition: mythdbcon.cpp:888
Device::m_mount
QString m_mount
Mountpoint.
Definition: imagemanager.cpp:112
MythEvent
This class is used as a container for messages.
Definition: mythevent.h:17
ImageManagerFe::DeviceEvent
void DeviceEvent(MythMediaEvent *event)
Manage events for local devices.
Definition: imagemanager.cpp:2442
EXIF_MYTH_SIZE
#define EXIF_MYTH_SIZE
Definition: imagemetadata.h:41
Device::isPresent
bool isPresent() const
Definition: imagemanager.cpp:106
ImageManagerFe::IgnoreDirs
static QString IgnoreDirs(const QString &excludes)
Set directories to ignore during scans of the storage group.
Definition: imagemanager.cpp:2152
Device::m_media
MythMediaDevice * m_media
Set for MediaMonitor devices only.
Definition: imagemanager.cpp:114
RESULT_ERR
#define RESULT_ERR(ERR, MESG)
Definition: imagemanager.cpp:21
imagemanager.h
Manages a collection of images.
Device::Close
void Close(bool eject=false)
Releases device.
Definition: imagemanager.cpp:61
MSqlQuery::value
QVariant value(int i) const
Definition: mythdbcon.h:198
arg
arg(title).arg(filename).arg(doDelete))
mythmediamonitor.h
MEDIASTAT_USEABLE
@ MEDIASTAT_USEABLE
Definition: mythmedia.h:19
RemoveFromDB
bool RemoveFromDB(Bookmark *site)
Definition: browserdbutil.cpp:158
Device::RemoveThumbs
void RemoveThumbs(void) const
Delete thumbnails associated with device.
Definition: imagemanager.cpp:95
MSqlQuery::exec
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
Definition: mythdbcon.cpp:603
MythMediaDevice::getDevicePath
const QString & getDevicePath() const
Definition: mythmedia.h:61
kDirRequestPriority
@ kDirRequestPriority
Client request to display a directory thumbnail.
Definition: imagethumbs.h:35
MythMediaDevice::getStatus
MythMediaStatus getStatus() const
Definition: mythmedia.h:70
ImageAdapterSg::Notify
static void Notify(const QString &mesg, const QStringList &extra)
Send message to all clients about remote ids.
Definition: imagemanager.cpp:451
DEVICE_INVALID
#define DEVICE_INVALID
Definition: imagemanager.h:71
ImageManagerFe::HideFiles
QString HideFiles(bool hidden, const ImageIdList &ids)
Hide/unhide images.
Definition: imagemanager.cpp:2045
IMAGE_STORAGE_GROUP
#define IMAGE_STORAGE_GROUP
Definition: imagemanager.h:63
ImageAdapterSg::m_sg
StorageGroup m_sg
Images storage group.
Definition: imagemanager.h:266
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
FileAssociations::getList
const association_list & getList() const
Definition: dbaccess.cpp:805
STORAGE_GROUP_MOUNT
#define STORAGE_GROUP_MOUNT
Definition: imagemanager.cpp:17
ImageDb::GetImages
int GetImages(const QString &ids, ImageList &files, ImageList &dirs, const QString &refine="") const
Read database images/dirs by id.
Definition: imagemanager.cpp:545
ImageDb::InsertDbImage
int InsertDbImage(ImageItemK &im, bool checkForDuplicate=false) const
Adds new image to database, optionally checking for existing filepath.
Definition: imagemanager.cpp:761
Device
A device containing images (ie. USB stick, CD, storage group etc)
Definition: imagemanager.cpp:34
MEDIASTAT_MOUNTED
@ MEDIASTAT_MOUNTED
Definition: mythmedia.h:21
ImageDb::CreateImage
ImageItem * CreateImage(const MSqlQuery &query) const
Create image from Db query data.
Definition: imagemanager.cpp:502
ImageHandler::HandleCover
QStringList HandleCover(int dir, int cover) const
Updates/resets cover thumbnail for an image dir.
Definition: imagemanager.cpp:1569
DeviceManager::ThumbDir
QString ThumbDir(int fs) const
Definition: imagemanager.cpp:142
ImageManagerBe::ImageManagerBe
ImageManagerBe()
Definition: imagemanager.h:384
ImageDbReader::TypeSelector
static QString TypeSelector(int type)
Generate SQL type filter clause.
Definition: imagemanager.cpp:1722
MythMediaDevice::getDeviceModel
const QString & getDeviceModel() const
Definition: mythmedia.h:67
ImageMetaData::FromVideo
static ImageMetaData * FromVideo(const QString &filePath)
Factory to retrieve metadata from videos.
Definition: imagemetadata.cpp:709
ImageItem::m_device
int m_device
Id of media device. Always 0 (SG) for remotes, 1+ for local devices.
Definition: imagetypes.h:94
ImageManagerFe::CloseDevices
void CloseDevices(int devId=DEVICE_INVALID, bool eject=false)
Definition: imagemanager.cpp:2391
ImageItem::PartitionIds
static StringPair PartitionIds(const ImageIdList &ids)
Separates list of ids into a list of local ids and a list of remote ids.
Definition: imagetypes.h:139
true
VERBOSE_PREAMBLE Most true
Definition: verbosedefs.h:91
ImageDbSg::ImageDbSg
ImageDbSg()
SG database constructor.
Definition: imagemanager.cpp:1044
ImageManagerFe::ChangeOrientation
QString ChangeOrientation(ImageFileTransform transform, const ImageIdList &ids)
Apply an orientation transform to images.
Definition: imagemanager.cpp:2076
tmp
static guint32 * tmp
Definition: goom_core.cpp:31
ImageHandler::HandleTransform
QStringList HandleTransform(int transform, const QString &ids) const
Change orientation of pictures by applying a transformation.
Definition: imagemanager.cpp:1466
dbaccess.h
ImageManagerFe::getInstance
static ImageManagerFe & getInstance()
Get Frontend Gallery.
Definition: imagemanager.cpp:1940
ImageAdapterLocal::CreateItem
ImageItem * CreateItem(const QFileInfo &fi, int parentId, int devId, const QString &base) const
Construct a local image from a file.
Definition: imagemanager.cpp:337
ImageManagerFe::DeviceCaption
QString DeviceCaption(ImageItemK &im) const
Return translated device name.
Definition: imagemanager.cpp:2352
kSortByDateDesc
@ kSortByDateDesc
Exif date Latest -> Earliest.
Definition: imagetypes.h:54
Orientation::Transform
int Transform(int transform)
Adjust orientation to apply a transform to an image.
Definition: imagemetadata.cpp:28
ImageHandler::HandleDbCreate
QStringList HandleDbCreate(QStringList defs) const
Creates images for files created by a copy operation.
Definition: imagemanager.cpp:1318
ImageDbReader::m_refineClause
QString m_refineClause
SQL clause for image filtering/ordering.
Definition: imagemanager.h:444
ImageMetaData::ToString
static QString ToString(const QString &name, const QString &label, const QString &value)
Encodes metadata into a string as <tag name><tag label><tag value>
Definition: imagemetadata.h:112
ImageFileTransform
ImageFileTransform
Image transformations.
Definition: imagemetadata.h:46
EXIF_MYTH_ORIENT
#define EXIF_MYTH_ORIENT
Definition: imagemetadata.h:42
ImageDb::GetImageTree
bool GetImageTree(int id, ImageList &files, const QString &refine) const
Returns all files in the sub-tree of a dir.
Definition: imagemanager.cpp:674
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
toString
QString toString(MarkTypes type)
Definition: programtypes.cpp:26
ImageItem::m_modTime
qint64 m_modTime
Filesystem modified datestamp.
Definition: imagetypes.h:97
ImageHash
QHash< QString, ImagePtr > ImageHash
Definition: imagetypes.h:160
mythdate.h
ImageHandler::HandleDbMove
QStringList HandleDbMove(const QString &ids, const QString &srcPath, QString destPath) const
Updates images that have been renamed.
Definition: imagemanager.cpp:1377
GetConfDir
QString GetConfDir(void)
Definition: mythdirs.cpp:224
kSortByNameAsc
@ kSortByNameAsc
Name A-Z.
Definition: imagetypes.h:45
kPicOnly
@ kPicOnly
Hide videos.
Definition: imagemanager.h:79
ImageManagerFe::ClearStorageGroup
static void ClearStorageGroup()
Clear database & thumbnails of Storage Group images.
Definition: imagemanager.cpp:2138
MythCoreContext::SendEvent
void SendEvent(const MythEvent &event)
Definition: mythcorecontext.cpp:1536
DeviceManager::~DeviceManager
~DeviceManager()
Definition: imagemanager.cpp:122
MSqlQuery::InitCon
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
Definition: mythdbcon.cpp:535
FileAssociations::association_list
std::vector< file_association > association_list
Definition: dbaccess.h:154
StringMap
QMap< int, QString > StringMap
Definition: imagetypes.h:62
MythDB::DBError
static void DBError(const QString &where, const MSqlQuery &query)
Definition: mythdb.cpp:178
ImageHandler< ImageDbSg >
ImageAdapterBase::FormatSize
static QString FormatSize(int sizeKib)
Definition: imagemanager.h:143
ImageDb::SetOrientation
bool SetOrientation(int id, int orientation) const
Sets image orientation in Db.
Definition: imagemanager.cpp:942
formats
const std::array< const std::string, 8 > formats
Definition: vbilut.cpp:189
MythMediaEvent
Definition: mythmedia.h:184
ImageDbReader::GetDescendants
void GetDescendants(const ImageIdList &ids, ImageList &files, ImageList &dirs) const
Return all (local or remote) images that are direct children of a dir.
Definition: imagemanager.cpp:1858
ImageAdapterBase::SupportedImages
static QStringList SupportedImages()
Return recognised pictures.
Definition: imagemanager.cpp:299
ImageDbReader::OrderSelector
static QString OrderSelector(int order)
Generate SQL ordering clause.
Definition: imagemanager.cpp:1758
DBLOC
#define DBLOC
Definition: imagemanager.cpp:14
ImageAdapterBase::PathOf
static QString PathOf(const QString &path)
Extracts path from a filepath.
Definition: imagemanager.h:140
ImageListK
QList< ImagePtrK > ImageListK
Definition: imagetypes.h:165
clear
static void clear(SettingsMap &cache, SettingsMap &overrides, const QString &myKey)
Definition: mythdb.cpp:844
MediaMonitor::Unlock
void Unlock(MythMediaDevice *pMedia)
decrements the MythMediaDevices reference count
Definition: mythmediamonitor.cpp:525
Orientation::Description
QString Description() const
Generate text description of orientation.
Definition: imagemetadata.cpp:228
ImageManagerFe::LongDateOf
static QString LongDateOf(const ImagePtrK &im)
Return a timestamp/datestamp for an image or dir.
Definition: imagemanager.cpp:2311
RESULT_OK
#define RESULT_OK(MESG)
Definition: imagemanager.cpp:25
kSortByExtAsc
@ kSortByExtAsc
Extension A-Z.
Definition: imagetypes.h:49
EXIF_MYTH_PATH
#define EXIF_MYTH_PATH
Definition: imagemetadata.h:39
StorageGroup::GetDirList
QStringList GetDirList(void) const
Definition: storagegroup.h:23
ImageManagerFe::SetCover
QString SetCover(int parent, int cover)
Set image to use as a cover thumbnail(s)
Definition: imagemanager.cpp:2108
uint
unsigned int uint
Definition: compat.h:140
ImageMetaData::FromPicture
static ImageMetaData * FromPicture(const QString &filePath)
Factory to retrieve metadata from pictures.
Definition: imagemetadata.cpp:700
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition: mythcorecontext.cpp:56
ImageItem::IsLocalId
static bool IsLocalId(int id)
Determine image type (local/remote) from its id. Root/Gallery is remote.
Definition: imagetypes.h:121
ImageItem::m_orientation
int m_orientation
Image orientation.
Definition: imagetypes.h:100
ImageItem::m_baseName
QString m_baseName
File/Dir name with extension (no path)
Definition: imagetypes.h:91
MediaMonitor
Definition: mythmediamonitor.h:44
ImageList
QVector< ImagePtr > ImageList
Definition: imagetypes.h:159
MythCoreContext::GetNumSetting
int GetNumSetting(const QString &key, int defaultval=0)
Definition: mythcorecontext.cpp:929
DeviceManager::DeviceMount
QString DeviceMount(int devId) const
Get path at which the device is mounted.
Definition: imagemanager.cpp:129
ImageManagerFe::CreateImport
QString CreateImport()
Definition: imagemanager.cpp:2488
ImageItem::IsLocalParent
static bool IsLocalParent(int id)
Parents of locals are locals or root.
Definition: imagetypes.h:123
ImageHandler::RemoveFiles
void RemoveFiles(ImageList &images) const
Deletes images and dirs from the filesystem.
Definition: imagemanager.cpp:1690
ImageAdapterBase::GetAbsThumbPath
static QString GetAbsThumbPath(const QString &devPath, const QString &path)
Get absolute filepath for thumbnail of an image.
Definition: imagemanager.h:148
ImageMetaData::GetAllTags
virtual QStringList GetAllTags()=0
ImageDbReader::GetDescendantCount
void GetDescendantCount(int id, int &dirs, int &pics, int &videos, int &sizeKb) const
Return counts of dirs, pics and videos in the subtree of a dir. Also dir size.
Definition: imagemanager.cpp:1894
MythCoreContext::GetBoolSetting
bool GetBoolSetting(const QString &key, bool defaultval=false)
Definition: mythcorecontext.cpp:923
THUMBNAIL_SUBDIR
#define THUMBNAIL_SUBDIR
Definition: imagemanager.h:69
Device::m_present
bool m_present
True when gallery UI is running & device is useable. Always true for imports.
Definition: imagemanager.cpp:110
FileAssociations::getFileAssociation
static FileAssociations & getFileAssociation()
Definition: dbaccess.cpp:830
kSortByModTimeDesc
@ kSortByModTimeDesc
File modified time Latest -> Earliest.
Definition: imagetypes.h:48
mthreadpool.h
Device::m_dir
QTemporaryDir * m_dir
Dir path of images: import devices only.
Definition: imagemanager.cpp:115
ImageHandler::HandleScanRequest
QStringList HandleScanRequest(const QString &command, int devId=DEVICE_INVALID) const
Process scan requests.
Definition: imagemanager.cpp:1612
ImageHandler::HandleDirs
QStringList HandleDirs(const QString &destId, bool rescan, const QStringList &relPaths) const
Creates new image directories.
Definition: imagemanager.cpp:1513
kImageFile
@ kImageFile
A picture.
Definition: imagetypes.h:38
IMPORTDIR
#define IMPORTDIR
Definition: imagemanager.cpp:29
ImageManagerFe::MoveDbImages
QString MoveDbImages(const ImagePtrK &destDir, ImageListK &images, const QString &srcPath)
Moves database images (but not the files themselves).
Definition: imagemanager.cpp:2254
MythMediaType
MythMediaType
Definition: mythmedia.h:24
kFlipVertical
@ kFlipVertical
Reflect about horizontal axis.
Definition: imagemetadata.h:51
ImagePtr
QSharedPointer< ImageItem > ImagePtr
Definition: imagetypes.h:158
MythDate::kAddYear
@ kAddYear
Add year to string if not included.
Definition: mythdate.h:22
ImageManagerFe
The image manager for use by Frontends.
Definition: imagemanager.h:457
StorageGroup::FindNextDirMostFree
QString FindNextDirMostFree(void)
Definition: storagegroup.cpp:671
dir
QDir dir
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:1174
ImageDbReader::m_fileOrder
int m_fileOrder
Display ordering of pics/videos.
Definition: imagemanager.h:441
ImageDbReader::m_remote
ImageDbSg * m_remote
Remote database access.
Definition: imagemanager.h:438
ImageItem
Represents a picture, video or directory.
Definition: imagetypes.h:68
MEDIATYPE_MGALLERY
@ MEDIATYPE_MGALLERY
Definition: mythmedia.h:33
ImageDbLocal::ImageDbLocal
ImageDbLocal()
Local database constructor.
Definition: imagemanager.cpp:1054
Device::~Device
~Device()
Delete device, its thumbnails and any imported images.
Definition: imagemanager.cpp:47
MediaMonitor::EjectMedia
void EjectMedia(const QString &path)
Definition: mythmediamonitor.cpp:275
DeviceManager::LocateMount
int LocateMount(const QString &mount) const
Find the id of a device.
Definition: imagemanager.cpp:232
MSqlQuery::bindValue
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
Definition: mythdbcon.cpp:864
ImageDb::GetChildren
int GetChildren(QString ids, ImageList &files, ImageList &dirs, const QString &refine="") const
Read immediate children of a dir.
Definition: imagemanager.cpp:565
Device::Device
Device(QString name, QString mount, MythMediaDevice *media=nullptr, QTemporaryDir *import=nullptr)
Definition: imagemanager.cpp:36
EXIF_MYTH_NAME
#define EXIF_MYTH_NAME
Definition: imagemetadata.h:40
ImageHandler::HandleIgnore
QStringList HandleIgnore(const QString &exclusions) const
Updates exclusion list for images.
Definition: imagemanager.cpp:1592
kSortByDateAsc
@ kSortByDateAsc
Exif date Earliest -> Latest.
Definition: imagetypes.h:53
DeviceManager::OpenDevice
int OpenDevice(const QString &name, const QString &mount, MythMediaDevice *media=nullptr, QTemporaryDir *dir=nullptr)
Define a new device and assign it a unique id. If the device is already known, its existing id is ret...
Definition: imagemanager.cpp:157
ImageDb::SetCover
bool SetCover(int dir, int id) const
Set the thumbnail(s) to be used for a dir.
Definition: imagemanager.cpp:918
ImageIdList
QList< int > ImageIdList
Definition: imagetypes.h:59
ImageAdapterBase::ThumbPath
static QString ThumbPath(const ImageItem &im)
Thumbnails of videos are a JPEG snapshot with jpg suffix appended.
Definition: imagemanager.h:152
ImageDb::ReadImages
int ReadImages(ImageList &dirs, ImageList &files, const QString &selector) const
Read selected database images/dirs.
Definition: imagemanager.cpp:968
ImageManagerFe::CrumbName
QString CrumbName(ImageItemK &im, bool getPath=false) const
Return a displayable name (with optional path) for an image.
Definition: imagemanager.cpp:2370
ImageItem::m_parentId
int m_parentId
Id of parent dir.
Definition: imagetypes.h:95
ImageDb::ClearDb
void ClearDb(int devId, const QString &action)
Clear Db for device & remove device.
Definition: imagemanager.cpp:725
StringPair
QPair< QString, QString > StringPair
Definition: imagetypes.h:60
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
MythMediaDevice::getMediaType
MythMediaType getMediaType() const
Definition: mythmedia.h:91
ImageAdapterSg::GetAbsFilePath
QString GetAbsFilePath(const ImagePtrK &im) const
Get absolute filepath for a remote image.
Definition: imagemanager.cpp:479
EXIF_MYTH_HOST
#define EXIF_MYTH_HOST
Definition: imagemetadata.h:38
build_compdb.action
action
Definition: build_compdb.py:9
ImageDbReader::m_dirOrder
int m_dirOrder
Display ordering of dirs.
Definition: imagemanager.h:440
ImageManagerBe::getInstance
static ImageManagerBe * getInstance()
Get Backend Gallery.
Definition: imagemanager.cpp:1928
ImageDb::GetDirectory
int GetDirectory(int id, ImagePtr &parent, ImageList &files, ImageList &dirs, const QString &refine) const
Read a dir and its immediate children from Db.
Definition: imagemanager.cpp:583
DeviceManager::CloseDevices
QStringList CloseDevices(int devId, const QString &action)
Remove a device (or all devices)
Definition: imagemanager.cpp:189
DB_TABLE
#define DB_TABLE
Definition: imagemanager.cpp:19
ImageAdapterLocal::Notify
static void Notify(const QString &mesg, const QStringList &extra)
Send local message to UI about local ids.
Definition: imagemanager.cpp:386
ImageDb::RemoveFromDB
QStringList RemoveFromDB(const ImageList &imList) const
Remove images/dirs from database.
Definition: imagemanager.cpp:862
ImageDb::ReadAllImages
bool ReadAllImages(ImageHash &files, ImageHash &dirs) const
Read all database images and dirs as map. No filters or ordering applied.
Definition: imagemanager.cpp:694
ImageDbLocal::CreateTable
bool CreateTable()
Create local database table, if it doesn't exist.
Definition: imagemanager.cpp:1079
MediaMonitor::ValidateAndLock
bool ValidateAndLock(MythMediaDevice *pMedia)
Validates the MythMediaDevice and increments its reference count.
Definition: mythmediamonitor.cpp:508
MythDate::kDateFull
@ kDateFull
Default local time.
Definition: mythdate.h:16
DeviceManager::GetAbsentees
QList< int > GetAbsentees()
Get list of mountpoints for non-import devices.
Definition: imagemanager.cpp:260
ImageDbReader::SetRefinementClause
void SetRefinementClause()
Sets filter/ordering SQL clause used when reading database according to current filter/sort settings.
Definition: imagemanager.cpp:1739
MythCoreContext::GetHostName
QString GetHostName(void)
Definition: mythcorecontext.cpp:855
ImageItem::m_userThumbnail
int m_userThumbnail
Id of thumbnail to use as cover (dirs only)
Definition: imagetypes.h:105
ImageHandler::HandleDelete
QStringList HandleDelete(const QString &ids) const
Deletes images/dirs.
Definition: imagemanager.cpp:1275
ImageItem::IsDevice
bool IsDevice() const
Definition: imagetypes.h:115
ImageAdapterSg::GetScanDirs
StringMap GetScanDirs() const
Returns SG dirs.
Definition: imagemanager.cpp:462
MythMediaDevice
Definition: mythmedia.h:49
ImageManagerFe::DeleteFiles
QString DeleteFiles(const ImageIdList &ids)
Delete images.
Definition: imagemanager.cpp:2281
kSortByModTimeAsc
@ kSortByModTimeAsc
File modified time Earliest -> Latest.
Definition: imagetypes.h:47
ReadMetaThread::ReadMetaThread
ReadMetaThread(ImagePtrK im, QString path)
Definition: imagemanager.cpp:1114
ImageDb< ImageAdapterLocal >::m_table
QString m_table
Db table name.
Definition: imagemanager.h:310
Device::setPresent
void setPresent(MythMediaDevice *media)
Definition: imagemanager.cpp:107
ReadMetaThread::m_path
QString m_path
Definition: imagemanager.cpp:1155
ImageDb
Database API.
Definition: imagemanager.h:275
ImageItem::m_extension
QString m_extension
Image file extension.
Definition: imagetypes.h:93
MythDate::kTime
@ kTime
Default local time.
Definition: mythdate.h:19
kDevice
@ kDevice
Storage Group and local mounted media.
Definition: imagetypes.h:35
ImageAdapterSg::CreateItem
ImageItem * CreateItem(const QFileInfo &fi, int parentId, int devId, const QString &base) const
Construct a remote image from a file.
Definition: imagemanager.cpp:402
ImageItem::m_date
qint64 m_date
Image creation date, from Exif metadata.
Definition: imagetypes.h:99
ImageManagerBe
The image manager to be used by the Backend.
Definition: imagemanager.h:379
kSortBySizeAsc
@ kSortBySizeAsc
File size Smallest -> Largest.
Definition: imagetypes.h:51
ImageDb::GetDescendants
bool GetDescendants(const QString &ids, ImageList &files, ImageList &dirs) const
Return images and all of their descendants.
Definition: imagemanager.cpp:625
ImageManagerFe::RequestMetaData
void RequestMetaData(int id)
Requests all exif/ffmpeg tags for an image, which returns by event.
Definition: imagemanager.cpp:2128
MThreadPool::globalInstance
static MThreadPool * globalInstance(void)
Definition: mthreadpool.cpp:306
MythMediaStatus
MythMediaStatus
Definition: mythmedia.h:12
DeviceManager::m_devices
DeviceMap m_devices
Device store.
Definition: imagemanager.h:119
ImageDb::GetDescendantCount
void GetDescendantCount(int id, bool all, int &dirs, int &pics, int &videos, int &sizeKb) const
Return counts of dirs, pics, videos and size in the subtree of a dir.
Definition: imagemanager.cpp:1003
ImageAdapterBase::GetImageType
ImageNodeType GetImageType(const QString &ext) const
Determine file type from its extension.
Definition: imagemanager.h:165
query
MSqlQuery query(MSqlQuery::InitCon())
ImageManagerFe::ScanQuery
static QStringList ScanQuery()
Returns storage group scanner status.
Definition: imagemanager.cpp:2025
kUnknown
@ kUnknown
Unprocessable file type.
Definition: imagetypes.h:34
MythCoreContext::SaveSettingOnHost
bool SaveSettingOnHost(const QString &key, const QString &newValue, const QString &host)
Definition: mythcorecontext.cpp:908
ImageManagerFe::RenameFile
QString RenameFile(const ImagePtrK &im, const QString &name)
Rename an image.
Definition: imagemanager.cpp:2190
MythMediaDevice::getVolumeID
const QString & getVolumeID() const
Definition: mythmedia.h:72
Device::m_name
QString m_name
Device model/volume/id.
Definition: imagemanager.cpp:111
ImageManagerFe::ShortDateOf
QString ShortDateOf(const ImagePtrK &im) const
Return a short datestamp for thumbnail captions.
Definition: imagemanager.cpp:2337
ImageHandler::HandleCreateThumbnails
QStringList HandleCreateThumbnails(const QStringList &message) const
Creates thumbnails on-demand.
Definition: imagemanager.cpp:1658
ReadMetaThread::m_im
ImagePtrK m_im
Definition: imagemanager.cpp:1154
ImageHandler::HandleHide
QStringList HandleHide(bool hide, const QString &ids) const
Hides/unhides images/dirs.
Definition: imagemanager.cpp:1444
kSortBySizeDesc
@ kSortBySizeDesc
File size Largest -> Smallest.
Definition: imagetypes.h:52
Orientation
Encapsulates Exif orientation processing.
Definition: imagemetadata.h:63
MThreadPool::start
void start(QRunnable *runnable, const QString &debugName, int priority=0)
Definition: mthreadpool.cpp:341
ImageItem::m_size
int m_size
Filesize (files only)
Definition: imagetypes.h:98
MEDIATYPE_DATA
@ MEDIATYPE_DATA
Definition: mythmedia.h:26
GALLERY_DB_ID
#define GALLERY_DB_ID
Definition: imagetypes.h:26
kVideoOnly
@ kVideoOnly
Hide pictures.
Definition: imagemanager.h:80
TEMP_SUBDIR
#define TEMP_SUBDIR
Definition: imagemanager.h:67
MythCoreContext::GetSetting
QString GetSetting(const QString &key, const QString &defaultval="")
Definition: mythcorecontext.cpp:915
ImageAdapterBase::SupportedVideos
static QStringList SupportedVideos()
Return recognised video extensions.
Definition: imagemanager.cpp:314
ReadMetaThread::run
void run() override
Definition: imagemanager.cpp:1117
MSqlQuery::prepare
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.
Definition: mythdbcon.cpp:808
ImageItem::m_filePath
QString m_filePath
Absolute for local images. Usually SG-relative for remotes.
Definition: imagetypes.h:92
kPicRequestPriority
@ kPicRequestPriority
Client request to display an image thumbnail.
Definition: imagethumbs.h:34
build_compdb.paths
paths
Definition: build_compdb.py:13
ImageManagerFe::DetectLocalDevices
bool DetectLocalDevices()
Detect and scan local devices.
Definition: imagemanager.cpp:2404