MythTV
master
|
The image manager for use by Frontends. More...
#include <libmythmetadata/imagemanager.h>
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 ImageManagerFe & | getInstance () |
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) | |
ImageItem * | CreateImage (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, const 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 (const 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 | |
ImageItem * | CreateItem (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 | |
ImageDbSg * | m_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 ImageManagerFe * | s_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... | |
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 463 of file imagemanager.h.
|
inlineprotected |
Definition at line 508 of file imagemanager.h.
Referenced by getInstance().
|
private |
|
static |
Get Frontend Gallery.
Definition at line 1956 of file imagemanager.cpp.
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.
ids | Images requiring thumbnails |
forFolder | True if thumbnail is required for a directory image. UI aesthetics consider this to be lower priority than picture/video thumbnails. |
Definition at line 1980 of file imagemanager.cpp.
Referenced by GalleryThumbView::UpdateImageItem().
Handle scanner start/stop commands.
start | True to start a scan, False to stop a scan |
local | True to start scan of local devices, False to scan storage group |
Definition at line 2015 of file imagemanager.cpp.
Referenced by DetectLocalDevices(), DeviceEvent(), GalleryThumbView::DoScanAction(), and GalleryThumbView::Import().
|
static |
Returns storage group scanner status.
Definition at line 2041 of file imagemanager.cpp.
Referenced by GalleryThumbView::Start().
QString ImageManagerFe::HideFiles | ( | bool | hidden, |
const ImageIdList & | ids | ||
) |
Hide/unhide images.
hidden | True to hide, False to show images |
ids | List of image ids |
Definition at line 2061 of file imagemanager.cpp.
Referenced by GalleryThumbView::DoHideItem(), and GalleryThumbView::DoHideMarked().
QString ImageManagerFe::ChangeOrientation | ( | ImageFileTransform | transform, |
const ImageIdList & | ids | ||
) |
Apply an orientation transform to images.
transform | Transformation to apply |
ids | List of image ids |
Definition at line 2092 of file imagemanager.cpp.
Referenced by GallerySlideView::Transform(), GalleryThumbView::TransformItem(), and GalleryThumbView::TransformMarked().
QString ImageManagerFe::SetCover | ( | int | parent, |
int | cover | ||
) |
Set image to use as a cover thumbnail(s)
parent | Id of directory to change |
cover | Image id to use as cover |
Definition at line 2124 of file imagemanager.cpp.
Referenced by GalleryThumbView::DoSetCover(), and GalleryThumbView::keyPressEvent().
void ImageManagerFe::RequestMetaData | ( | int | id | ) |
Requests all exif/ffmpeg tags for an image, which returns by event.
id | An image id |
Definition at line 2144 of file imagemanager.cpp.
Referenced by InfoList::Update().
|
static |
Set directories to ignore during scans of the storage group.
excludes | Comma separated list of dir names/patterns to exclude. Glob characters * and ? permitted. |
Definition at line 2168 of file imagemanager.cpp.
Referenced by GalleryThumbView::ShowSettings().
Create directories.
parent | Dir in which to create new dirs |
names | List of dir names |
rescan | Whether to scan after creating dirs |
Definition at line 2184 of file imagemanager.cpp.
Referenced by GalleryThumbView::Copy(), and GalleryThumbView::customEvent().
QString ImageManagerFe::RenameFile | ( | const ImagePtrK & | im, |
const QString & | name | ||
) |
Rename an image.
im | An image |
name | New name of the file/dir (basename only, no path or extension) |
Definition at line 2206 of file imagemanager.cpp.
Referenced by GalleryThumbView::customEvent().
QString ImageManagerFe::CreateImages | ( | int | destId, |
const ImageListK & | images | ||
) |
Copies database images (but not the files themselves).
destId | Id of an image directory |
images | List of images to copy |
Definition at line 2226 of file imagemanager.cpp.
Referenced by GalleryThumbView::Copy().
QString ImageManagerFe::MoveDbImages | ( | const ImagePtrK & | destDir, |
ImageListK & | images, | ||
const QString & | srcPath | ||
) |
Moves database images (but not the files themselves).
destDir | Destination image directory |
images | List of images to copy |
srcPath | Original parent path |
Definition at line 2270 of file imagemanager.cpp.
Referenced by GalleryThumbView::Move().
QString ImageManagerFe::DeleteFiles | ( | const ImageIdList & | ids | ) |
Delete images.
ids | List of image ids |
Definition at line 2297 of file imagemanager.cpp.
Referenced by GalleryThumbView::Copy(), and GalleryThumbView::customEvent().
|
static |
Clear database & thumbnails of Storage Group images.
Definition at line 2154 of file imagemanager.cpp.
Referenced by GalleryThumbView::ClearSgDb().
void ImageManagerFe::CloseDevices | ( | int | devId = DEVICE_INVALID , |
bool | eject = false |
||
) |
Definition at line 2409 of file imagemanager.cpp.
Referenced by GalleryThumbView::Close(), DetectLocalDevices(), DeviceEvent(), and GalleryThumbView::Eject().
bool ImageManagerFe::DetectLocalDevices | ( | ) |
Detect and scan local devices.
Definition at line 2424 of file imagemanager.cpp.
Referenced by GalleryThumbView::Start().
void ImageManagerFe::DeviceEvent | ( | MythMediaEvent * | event | ) |
Manage events for local devices.
event | Appeared/disappeared events |
Definition at line 2462 of file imagemanager.cpp.
Referenced by GalleryThumbView::mediaEvent().
QString ImageManagerFe::CreateImport | ( | ) |
Definition at line 2510 of file imagemanager.cpp.
Referenced by GalleryThumbView::Import().
|
inline |
Definition at line 496 of file imagemanager.h.
Referenced by GalleryThumbView::ShowSettings().
|
static |
Return a timestamp/datestamp for an image or dir.
Uses exif timestamp if defined, otherwise file modified date
im | Image or dir |
Definition at line 2327 of file imagemanager.cpp.
Referenced by GalleryThumbView::SetUiSelection(), and GallerySlideView::TransitionComplete().
QString ImageManagerFe::ShortDateOf | ( | const ImagePtrK & | im | ) | const |
Return a short datestamp for thumbnail captions.
Uses exif date if defined, otherwise file modified date
im | Image or dir |
Definition at line 2355 of file imagemanager.cpp.
Referenced by GalleryThumbView::UpdateImageItem().
QString ImageManagerFe::DeviceCaption | ( | ImageItemK & | im | ) | const |
Return translated device name.
im | Image |
Definition at line 2370 of file imagemanager.cpp.
Referenced by CrumbName(), InfoList::Display(), and InfoList::Update().
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
im | Image |
getPath | If true, name will include path. Otherwise only the basename |
Definition at line 2388 of file imagemanager.cpp.
Referenced by GalleryThumbView::SetUiSelection(), and GalleryThumbView::UpdateImageItem().
|
inline |
Generate Myth URL for a local or remote path.
Definition at line 503 of file imagemanager.h.
Referenced by GalleryThumbView::Copy(), and GalleryThumbView::Move().
|
inlinestatic |
Assembles a canonical file path without corrupting its absolute/relative nature.
Definition at line 132 of file imagemanager.h.
|
inline |
Definition at line 100 of file imagemanager.h.
Referenced by GalleryThumbView::keyPressEvent().
int DeviceManager::OpenDevice |
Define a new device and assign it a unique id. If the device is already known, its existing id is returned.
name | Device model/volume/id |
mount | Device mountpoint |
media | Set for MediaMonitor devices only |
dir | Dir path of images: import devices only |
Definition at line 162 of file imagemanager.cpp.
|
staticprotected |
FE Gallery instance.
Frontend Gallery instance.
Definition at line 518 of file imagemanager.h.
Referenced by getInstance().
|
protected |
UI format for thumbnail date captions.
Definition at line 521 of file imagemanager.h.
Referenced by ShortDateOf().