MythTV  master
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions | List of all members
ImageManagerFe Class Reference

The image manager for use by Frontends. More...

#include <imagemanager.h>

Inheritance diagram for ImageManagerFe:
Inheritance graph
[legend]
Collaboration diagram for ImageManagerFe:
Collaboration graph
[legend]

Public Member Functions

void CreateThumbnails (const ImageIdList &ids, bool forFolder)
 Create thumbnails or verify that they already exist. More...
 
QString ScanImagesAction (bool start, bool local=false)
 Handle scanner start/stop commands. More...
 
QString HideFiles (bool hidden, const ImageIdList &ids)
 Hide/unhide images. More...
 
QString ChangeOrientation (ImageFileTransform transform, const ImageIdList &ids)
 Apply an orientation transform to images. More...
 
QString SetCover (int parent, int cover)
 Set image to use as a cover thumbnail(s) More...
 
void RequestMetaData (int id)
 Requests all exif/ffmpeg tags for an image, which returns by event. More...
 
QString MakeDir (int parent, const QStringList &names, bool rescan=true)
 Create directories. More...
 
QString RenameFile (const ImagePtrK &im, const QString &name)
 Rename an image. More...
 
QString CreateImages (int destId, const ImageListK &images)
 Copies database images (but not the files themselves). More...
 
QString MoveDbImages (const ImagePtrK &destDir, ImageListK &images, const QString &srcPath)
 Moves database images (but not the files themselves). More...
 
QString DeleteFiles (const ImageIdList &ids)
 Delete images. More...
 
void CloseDevices (int devId=DEVICE_INVALID, bool eject=false)
 
bool DetectLocalDevices ()
 Detect and scan local devices. More...
 
void DeviceEvent (MythMediaEvent *event)
 Manage events for local devices. More...
 
QString CreateImport ()
 
void SetDateFormat (const QString &format)
 
QString ShortDateOf (const ImagePtrK &im) const
 Return a short datestamp for thumbnail captions. More...
 
QString DeviceCaption (ImageItemK &im) const
 Return translated device name. More...
 
QString CrumbName (ImageItemK &im, bool getPath=false) const
 Return a displayable name (with optional path) for an image. More...
 
QString BuildTransferUrl (const QString &path, bool local) const
 Generate Myth URL for a local or remote path. More...
 
int DeviceCount () const
 
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 returned. More...
 
- Public Member Functions inherited from ImageDbReader
 ~ImageDbReader () override
 
int GetType () const
 
bool GetVisibility () const
 
void SetType (int showType)
 
void SetSortOrder (int order, int dirOrder)
 
void SetVisibility (bool showHidden)
 
int GetImages (const ImageIdList &ids, ImageList &files, ImageList &dirs) const
 Returns images (local or remote but not a combination) More...
 
int GetChildren (int id, ImageList &files, ImageList &dirs) const
 Return (local or remote) images that are direct children of a dir. More...
 
int GetDirectory (int id, ImagePtr &parent, ImageList &files, ImageList &dirs) const
 Return images (local and/or remote) for a dir and its direct children. More...
 
void GetDescendants (const ImageIdList &ids, ImageList &files, ImageList &dirs) const
 Return all (local or remote) images that are direct children of a dir. More...
 
void GetImageTree (int id, ImageList &files) const
 Return all files (local or remote) in the sub-trees of a dir. More...
 
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. More...
 

Static Public Member Functions

static ImageManagerFegetInstance ()
 Get Frontend Gallery. More...
 
static QStringList ScanQuery ()
 Returns storage group scanner status. More...
 
static QString IgnoreDirs (const QString &excludes)
 Set directories to ignore during scans of the storage group. More...
 
static void ClearStorageGroup ()
 Clear database & thumbnails of Storage Group images. More...
 
static QString LongDateOf (const ImagePtrK &im)
 Return a timestamp/datestamp for an image or dir. More...
 
static QString ConstructPath (const QString &path, const QString &name)
 Assembles a canonical file path without corrupting its absolute/relative nature. More...
 

Protected Member Functions

 ImageManagerFe (int order, int dirOrder, bool showAll, int showType, QString dateFormat)
 
- Protected Member Functions inherited from ImageDbReader
 ImageDbReader (int order, int dirOrder, bool showAll, int showType)
 
void SetRefinementClause ()
 Sets filter/ordering SQL clause used when reading database according to current filter/sort settings. More...
 
- Protected Member Functions inherited from ImageHandler< ImageDbLocal >
 ImageHandler ()
 
 ~ImageHandler () override
 
void RemoveFiles (ImageList &images) const
 Deletes images and dirs from the filesystem. More...
 
QStringList HandleRename (const QString &id, const QString &newBase) const
 Change name of an image/dir. More...
 
QStringList HandleDelete (const QString &ids) const
 Deletes images/dirs. More...
 
QStringList HandleDbCreate (QStringList defs) const
 Creates images for files created by a copy operation. More...
 
QStringList HandleDbMove (const QString &ids, const QString &srcPath, QString destPath) const
 Updates images that have been renamed. More...
 
QStringList HandleHide (bool hide, const QString &ids) const
 Hides/unhides images/dirs. More...
 
QStringList HandleTransform (int transform, const QString &ids) const
 Change orientation of pictures by applying a transformation. More...
 
QStringList HandleDirs (const QString &destId, bool rescan, const QStringList &relPaths) const
 Creates new image directories. More...
 
QStringList HandleCover (int dir, int cover) const
 Updates/resets cover thumbnail for an image dir. More...
 
QStringList HandleIgnore (const QString &exclusions) const
 Updates exclusion list for images. More...
 
QStringList HandleScanRequest (const QString &command, int devId=DEVICE_INVALID) const
 Process scan requests. More...
 
QStringList HandleCreateThumbnails (const QStringList &message) const
 Creates thumbnails on-demand. More...
 
QStringList HandleGetMetadata (const QString &id) const
 Read meta data for an image. More...
 
- Protected Member Functions inherited from ImageDbLocal
 ImageDbLocal ()
 Local database constructor. More...
 
 ~ImageDbLocal () override
 
bool CreateTable ()
 Create local database table, if it doesn't exist. More...
 
- Protected Member Functions inherited from ImageDb< ImageAdapterLocal >
 ImageDb (QString table)
 
ImageItemCreateImage (const MSqlQuery &query) const
 Create image from Db query data. More...
 
int ReadImages (ImageList &dirs, ImageList &files, const QString &selector) const
 Read selected database images/dirs. More...
 
int GetImages (const QString &ids, ImageList &files, ImageList &dirs, const QString &refine="") const
 Read database images/dirs by id. More...
 
bool GetDescendants (const QString &ids, ImageList &files, ImageList &dirs) const
 Return images and all of their descendants. More...
 
int InsertDbImage (ImageItemK &im, bool checkForDuplicate=false) const
 Adds new image to database, optionally checking for existing filepath. More...
 
bool UpdateDbImage (ImageItemK &im) const
 Updates or creates database image or dir. More...
 
QStringList RemoveFromDB (const ImageList &imList) const
 Remove images/dirs from database. More...
 
bool SetHidden (bool hide, QString ids) const
 Sets hidden status of an image/dir in database. More...
 
bool SetCover (int dir, int id) const
 Set the thumbnail(s) to be used for a dir. More...
 
bool SetOrientation (int id, int orientation) const
 Sets image orientation in Db. More...
 
bool ReadAllImages (ImageHash &files, ImageHash &dirs) const
 Read all database images and dirs as map. No filters or ordering applied. More...
 
void ClearDb (int devId, const QString &action)
 Clear Db for device & remove device. More...
 
int GetChildren (QString ids, ImageList &files, ImageList &dirs, const QString &refine="") const
 Read immediate children of a dir. More...
 
bool GetImageTree (int id, ImageList &files, const QString &refine) const
 Returns all files in the sub-tree of a dir. More...
 
int GetDirectory (int id, ImagePtr &parent, ImageList &files, ImageList &dirs, const QString &refine) const
 Read a dir and its immediate children from Db. More...
 
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. More...
 
- Protected Member Functions inherited from ImageAdapterLocal
 ImageAdapterLocal ()=default
 
ImageItemCreateItem (const QFileInfo &fi, int parentId, int devId, const QString &base) const
 Construct a local image from a file. More...
 
StringMap GetScanDirs () const
 Returns local device dirs to scan. More...
 
- Protected Member Functions inherited from ImageAdapterBase
 ImageAdapterBase ()
 Constructor. More...
 
virtual ~ImageAdapterBase ()=default
 
QDir GetImageFilters () const
 Get filters for detecting recognised images/videos. More...
 
ImageNodeType GetImageType (const QString &ext) const
 Determine file type from its extension. More...
 
- Protected Member Functions inherited from DeviceManager
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 returned. More...
 
int LocateMount (const QString &mount) const
 Find the id of a device. More...
 
StringMap GetDeviceDirs () const
 Get all known devices. More...
 
QList< int > GetAbsentees ()
 Get list of mountpoints for non-import devices. More...
 
 DeviceManager ()=default
 
 ~DeviceManager ()
 
QStringList CloseDevices (int devId, const QString &action)
 Remove a device (or all devices) More...
 
QString DeviceMount (int devId) const
 Get path at which the device is mounted. More...
 
QString DeviceName (int devId) const
 Get model name of the device. More...
 
int DeviceCount () const
 
QString ThumbDir (int fs) const
 

Protected Attributes

QString m_dateFormat
 UI format for thumbnail date captions. More...
 
- Protected Attributes inherited from ImageDbReader
ImageDbSgm_remote
 Remote database access. More...
 
int m_dirOrder
 Display ordering of dirs. More...
 
int m_fileOrder
 Display ordering of pics/videos. More...
 
bool m_showHidden
 Whether hidden images are displayed. More...
 
int m_showType
 Type of images to display - pic only/video only/both. More...
 
QString m_refineClause
 SQL clause for image filtering/ordering. More...
 
- Protected Attributes inherited from ImageHandler< ImageDbLocal >
ImageThumb< ImageDbLocal > * m_thumbGen
 Thumbnail generator. More...
 
ImageScanThread< ImageDbLocal > * m_scanner
 File scanner. More...
 
- Protected Attributes inherited from ImageDbLocal
bool m_dbExists { false }
 
- Protected Attributes inherited from ImageDb< ImageAdapterLocal >
QString m_table
 Db table name. More...
 

Static Protected Attributes

static ImageManagerFes_instance = nullptr
 FE Gallery instance. More...
 

Private Member Functions

 Q_DECLARE_TR_FUNCTIONS (ImageManagerFe)
 

Additional Inherited Members

- Static Protected Member Functions inherited from ImageDbReader
static QString TypeSelector (int type)
 Generate SQL type filter clause. More...
 
static QString OrderSelector (int order)
 Generate SQL ordering clause. More...
 
- Static Protected Member Functions inherited from ImageAdapterLocal
static int ImageId (int id)
 
static QString ImageId (const QString &id)
 
static int DbId (int id)
 
static QString DbIds (const QString &ids)
 
static QString GetAbsFilePath (const ImagePtrK &im)
 Get absolute filepath for a local image. More...
 
static QString MakeFileUrl (const QString &path)
 Construct URL of a local image, which is an absolute path. More...
 
static QString MakeThumbUrl (const QString &devPath, const QString &path="")
 Construct URL of the thumbnail of a local image (An absolute path) More...
 
static void Notify (const QString &mesg, const QStringList &extra)
 Send local message to UI about local ids. More...
 
- Static Protected Member Functions inherited from ImageAdapterBase
static QStringList SupportedImages ()
 Return recognised pictures. More...
 
static QStringList SupportedVideos ()
 Return recognised video extensions. More...
 
static QString ConstructPath (const QString &path, const QString &name)
 Assembles a canonical file path without corrupting its absolute/relative nature. More...
 
static QString BaseNameOf (const QString &path)
 Extracts file name (incl extension) from a filepath. More...
 
static QString PathOf (const QString &path)
 Extracts path from a filepath. More...
 
static QString FormatSize (int sizeKib)
 
static QString GetAbsThumbPath (const QString &devPath, const QString &path)
 Get absolute filepath for thumbnail of an image. More...
 
static QString ThumbPath (const ImageItem &im)
 Thumbnails of videos are a JPEG snapshot with jpg suffix appended. More...
 

Detailed Description

The image manager for use by Frontends.

A singleton created on first use and deleted when FE exits. As sole API for UI, it handles local & remote images. Actions for local images are processed internally; actions for remote images are delegated to the Backend. Incorporates a remote Db adapter for read-only access to remote images. Manages all local images (on removeable media) locally.

Definition at line 456 of file imagemanager.h.

Constructor & Destructor Documentation

◆ ImageManagerFe()

ImageManagerFe::ImageManagerFe ( int  order,
int  dirOrder,
bool  showAll,
int  showType,
QString  dateFormat 
)
inlineprotected

Definition at line 501 of file imagemanager.h.

Referenced by getInstance().

Member Function Documentation

◆ Q_DECLARE_TR_FUNCTIONS()

ImageManagerFe::Q_DECLARE_TR_FUNCTIONS ( ImageManagerFe  )
private

◆ getInstance()

ImageManagerFe & ImageManagerFe::getInstance ( )
static

Get Frontend Gallery.

Returns
Frontend Gallery singleton

Definition at line 1938 of file imagemanager.cpp.

◆ CreateThumbnails()

void ImageManagerFe::CreateThumbnails ( const ImageIdList ids,
bool  forFolder 
)

Create thumbnails or verify that they already exist.

A THUMB_AVAILABLE event will be generated for each thumbnail as soon as it exists.

Parameters
idsImages requiring thumbnails
forFolderTrue if thumbnail is required for a directory image. UI aesthetics consider this to be lower priority than picture/video thumbnails.

Definition at line 1962 of file imagemanager.cpp.

Referenced by GalleryThumbView::UpdateImageItem().

◆ ScanImagesAction()

QString ImageManagerFe::ScanImagesAction ( bool  start,
bool  local = false 
)

Handle scanner start/stop commands.

Parameters
startTrue to start a scan, False to stop a scan
localTrue to start scan of local devices, False to scan storage group
Returns
QString Error message or empty

Definition at line 1997 of file imagemanager.cpp.

Referenced by DetectLocalDevices(), DeviceEvent(), GalleryThumbView::Import(), and GalleryThumbView::StartScan().

◆ ScanQuery()

QStringList ImageManagerFe::ScanQuery ( )
static

Returns storage group scanner status.

Returns
QStringList State ("ERROR" | "OK"), SG scanner id "1", Progress count, Total

Definition at line 2023 of file imagemanager.cpp.

Referenced by GalleryThumbView::Start().

◆ HideFiles()

QString ImageManagerFe::HideFiles ( bool  hidden,
const ImageIdList ids 
)

Hide/unhide images.

Parameters
hiddenTrue to hide, False to show images
idsList of image ids
Returns
QString Error message, if not empty

Definition at line 2043 of file imagemanager.cpp.

Referenced by GalleryThumbView::HideItem(), and GalleryThumbView::HideMarked().

◆ ChangeOrientation()

QString ImageManagerFe::ChangeOrientation ( ImageFileTransform  transform,
const ImageIdList ids 
)

Apply an orientation transform to images.

Parameters
transformTransformation to apply
idsList of image ids
Returns
QString Error message, if not empty

Definition at line 2074 of file imagemanager.cpp.

Referenced by GallerySlideView::Transform(), GalleryThumbView::TransformItem(), and GalleryThumbView::TransformMarked().

◆ SetCover()

QString ImageManagerFe::SetCover ( int  parent,
int  cover 
)

Set image to use as a cover thumbnail(s)

Parameters
parentId of directory to change
coverImage id to use as cover
Returns
QString Error message, if not empty

Definition at line 2106 of file imagemanager.cpp.

Referenced by GalleryThumbView::keyPressEvent(), and GalleryThumbView::SetCover().

◆ RequestMetaData()

void ImageManagerFe::RequestMetaData ( int  id)

Requests all exif/ffmpeg tags for an image, which returns by event.

Parameters
idAn image id

Definition at line 2126 of file imagemanager.cpp.

Referenced by InfoList::Update().

◆ IgnoreDirs()

QString ImageManagerFe::IgnoreDirs ( const QString &  excludes)
static

Set directories to ignore during scans of the storage group.

Parameters
excludesComma separated list of dir names/patterns to exclude. Glob characters * and ? permitted.
Returns
QString Error message, if not empty

Definition at line 2150 of file imagemanager.cpp.

Referenced by GalleryThumbView::ShowSettings().

◆ MakeDir()

QString ImageManagerFe::MakeDir ( int  parent,
const QStringList &  names,
bool  rescan = true 
)

Create directories.

Parameters
parentDir in which to create new dirs
namesList of dir names
rescanWhether to scan after creating dirs
Returns
QString Error message, if not empty

Definition at line 2166 of file imagemanager.cpp.

Referenced by GalleryThumbView::Copy(), and GalleryThumbView::customEvent().

◆ RenameFile()

QString ImageManagerFe::RenameFile ( const ImagePtrK im,
const QString &  name 
)

Rename an image.

Parameters
imAn image
nameNew name of the file/dir (basename only, no path or extension)
Returns
QString Error message, if not empty

Definition at line 2188 of file imagemanager.cpp.

Referenced by GalleryThumbView::customEvent().

◆ CreateImages()

QString ImageManagerFe::CreateImages ( int  destId,
const ImageListK images 
)

Copies database images (but not the files themselves).

Parameters
destIdId of an image directory
imagesList of images to copy
Returns
QString Error message

Definition at line 2208 of file imagemanager.cpp.

Referenced by GalleryThumbView::Copy().

◆ MoveDbImages()

QString ImageManagerFe::MoveDbImages ( const ImagePtrK destDir,
ImageListK images,
const QString &  srcPath 
)

Moves database images (but not the files themselves).

Parameters
destDirDestination image directory
imagesList of images to copy
srcPathOriginal parent path
Returns
QString Error message

Definition at line 2252 of file imagemanager.cpp.

Referenced by GalleryThumbView::Move().

◆ DeleteFiles()

QString ImageManagerFe::DeleteFiles ( const ImageIdList ids)

Delete images.

Parameters
idsList of image ids
Returns
QString Error message, if not empty

Definition at line 2279 of file imagemanager.cpp.

Referenced by GalleryThumbView::Copy(), and GalleryThumbView::customEvent().

◆ ClearStorageGroup()

void ImageManagerFe::ClearStorageGroup ( )
static

Clear database & thumbnails of Storage Group images.

Definition at line 2136 of file imagemanager.cpp.

Referenced by GalleryThumbView::ClearSgDb().

◆ CloseDevices()

void ImageManagerFe::CloseDevices ( int  devId = DEVICE_INVALID,
bool  eject = false 
)

◆ DetectLocalDevices()

bool ImageManagerFe::DetectLocalDevices ( )

Detect and scan local devices.

Returns
True if local devices exist

Definition at line 2402 of file imagemanager.cpp.

Referenced by GalleryThumbView::Start().

◆ DeviceEvent()

void ImageManagerFe::DeviceEvent ( MythMediaEvent event)

Manage events for local devices.

Parameters
eventAppeared/disappeared events

Definition at line 2439 of file imagemanager.cpp.

Referenced by GalleryThumbView::mediaEvent().

◆ CreateImport()

QString ImageManagerFe::CreateImport ( )

Definition at line 2485 of file imagemanager.cpp.

Referenced by GalleryThumbView::Import().

◆ SetDateFormat()

void ImageManagerFe::SetDateFormat ( const QString &  format)
inline

Definition at line 489 of file imagemanager.h.

Referenced by GalleryThumbView::ShowSettings().

◆ LongDateOf()

QString ImageManagerFe::LongDateOf ( const ImagePtrK im)
static

Return a timestamp/datestamp for an image or dir.

Uses exif timestamp if defined, otherwise file modified date

Parameters
imImage or dir
Returns
QString Time or date string formatted as per Myth general settings

Definition at line 2309 of file imagemanager.cpp.

Referenced by GalleryThumbView::SetUiSelection(), and GallerySlideView::TransitionComplete().

◆ ShortDateOf()

QString ImageManagerFe::ShortDateOf ( const ImagePtrK im) const

Return a short datestamp for thumbnail captions.

Uses exif date if defined, otherwise file modified date

Parameters
imImage or dir
Returns
QString Date formatted as per Gallery caption date format.

Definition at line 2335 of file imagemanager.cpp.

Referenced by GalleryThumbView::UpdateImageItem().

◆ DeviceCaption()

QString ImageManagerFe::DeviceCaption ( ImageItemK im) const

Return translated device name.

Parameters
imImage
Returns
Translated name of the device

Definition at line 2350 of file imagemanager.cpp.

Referenced by CrumbName(), InfoList::Display(), and InfoList::Update().

◆ CrumbName()

QString ImageManagerFe::CrumbName ( ImageItemK im,
bool  getPath = false 
) const

Return a displayable name (with optional path) for an image.

Uses device name rather than mount path for local devices

Parameters
imImage
getPathIf true, name will include path. Otherwise only the basename
Returns
QString Filepath for display

Definition at line 2368 of file imagemanager.cpp.

Referenced by GalleryThumbView::SetUiSelection(), and GalleryThumbView::UpdateImageItem().

◆ BuildTransferUrl()

QString ImageManagerFe::BuildTransferUrl ( const QString &  path,
bool  local 
) const
inline

Generate Myth URL for a local or remote path.

Definition at line 496 of file imagemanager.h.

Referenced by GalleryThumbView::Copy(), and GalleryThumbView::Move().

◆ ConstructPath()

static QString ImageAdapterBase::ConstructPath
inlinestatic

Assembles a canonical file path without corrupting its absolute/relative nature.

Definition at line 132 of file imagemanager.h.

Referenced by GalleryThumbView::Copy(), and GalleryThumbView::Move().

◆ DeviceCount()

int DeviceManager::DeviceCount
inline

Definition at line 100 of file imagemanager.h.

Referenced by DetectLocalDevices(), and GalleryThumbView::keyPressEvent().

◆ OpenDevice()

int DeviceManager::OpenDevice

Define a new device and assign it a unique id. If the device is already known, its existing id is returned.

Parameters
nameDevice model/volume/id
mountDevice mountpoint
mediaSet for MediaMonitor devices only
dirDir path of images: import devices only
Returns
int A unique id for this device.

Definition at line 104 of file imagemanager.cpp.

Referenced by CreateImport(), DetectLocalDevices(), and DeviceEvent().

Member Data Documentation

◆ s_instance

ImageManagerFe * ImageManagerFe::s_instance = nullptr
staticprotected

FE Gallery instance.

Frontend Gallery instance.

Definition at line 511 of file imagemanager.h.

Referenced by getInstance().

◆ m_dateFormat

QString ImageManagerFe::m_dateFormat
protected

UI format for thumbnail date captions.

Definition at line 514 of file imagemanager.h.

Referenced by ShortDateOf().


The documentation for this class was generated from the following files: