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

Provides read access to local & remote images. More...

#include <imagemanager.h>

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

Public Member Functions

 ~ImageDbReader () override
 
int GetType ()
 
bool GetVisibility ()
 
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...
 

Protected Member Functions

 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
 

Static Protected Member Functions

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...
 

Protected Attributes

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...
 

Detailed Description

Provides read access to local & remote images.

Also manages UI filters (show hidden, show pics/vids) and UI ordering. All filtering and sorting is performed by SQL as images are retrieved.

Definition at line 400 of file imagemanager.h.

Constructor & Destructor Documentation

◆ ~ImageDbReader()

ImageDbReader::~ImageDbReader ( )
inlineoverride

Definition at line 403 of file imagemanager.h.

◆ ImageDbReader()

ImageDbReader::ImageDbReader ( int  order,
int  dirOrder,
bool  showAll,
int  showType 
)
inlineprotected

Definition at line 427 of file imagemanager.h.

Member Function Documentation

◆ GetType()

int ImageDbReader::GetType ( )
inline

Definition at line 405 of file imagemanager.h.

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

◆ GetVisibility()

bool ImageDbReader::GetVisibility ( )
inline

◆ SetType()

void ImageDbReader::SetType ( int  showType)
inline

Definition at line 408 of file imagemanager.h.

Referenced by GalleryThumbView::ShowType().

◆ SetSortOrder()

void ImageDbReader::SetSortOrder ( int  order,
int  dirOrder 
)
inline

Definition at line 411 of file imagemanager.h.

Referenced by GalleryThumbView::ShowSettings().

◆ SetVisibility()

void ImageDbReader::SetVisibility ( bool  showHidden)
inline

◆ GetImages()

int ImageDbReader::GetImages ( const ImageIdList ids,
ImageList files,
ImageList dirs 
) const

Returns images (local or remote but not a combination)

Parameters
[in]idsImage ids
[in,out]filesList of files, filtered & ordered iaw current settings.
[in,out]dirsList of dirs, filtered & ordered iaw current settings.
Returns
int Number of images

Definition at line 1829 of file imagemanager.cpp.

Referenced by GalleryThumbView::Move(), and FlatView::Update().

◆ GetChildren()

int ImageDbReader::GetChildren ( int  id,
ImageList files,
ImageList dirs 
) const

Return (local or remote) images that are direct children of a dir.

Parameters
[in]idDirectory id
[in,out]filesList of files, filtered & ordered iaw current settings.
[in,out]dirsList of dirs, filtered & ordered iaw current settings.
Returns
int Number of Images

Definition at line 1850 of file imagemanager.cpp.

Referenced by DirectoryView::LoadDirThumbs(), and FlatView::LoadFromDb().

◆ GetDirectory()

int ImageDbReader::GetDirectory ( int  id,
ImagePtr parent,
ImageList files,
ImageList dirs 
) const

Return images (local and/or remote) for a dir and its direct children.

Parameters
[in]idDir id
[out]parentParent image
[in,out]filesChild files, filtered & ordered iaw current settings.
[in,out]dirsChild dirs, filtered & ordered iaw current settings.
Returns
int Number of images, including parent

Definition at line 1797 of file imagemanager.cpp.

Referenced by DirectoryView::LoadFromDb().

◆ GetDescendants()

void ImageDbReader::GetDescendants ( const ImageIdList ids,
ImageList files,
ImageList dirs 
) const

Return all (local or remote) images that are direct children of a dir.

Parameters
[in]idsDirectory ids, GALLERY_DB_ID not valid
[in,out]filesList of files, unfiltered & unordered
[in,out]dirsList of dirs, unfiltered & unordered

Definition at line 1869 of file imagemanager.cpp.

Referenced by GalleryThumbView::Copy().

◆ GetImageTree()

void ImageDbReader::GetImageTree ( int  id,
ImageList files 
) const

Return all files (local or remote) in the sub-trees of a dir.

Parameters
[in]idDir id
[in,out]filesList of images within sub-tree. Ordered & filtered iaw current settings

Definition at line 1888 of file imagemanager.cpp.

Referenced by TreeView::LoadFromDb().

◆ GetDescendantCount()

void ImageDbReader::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.

Parameters
[in]idDir id
[in,out]dirsNumber of dirs in parent sub-tree
[in,out]picsNumber of pictures in parent sub-tree
[in,out]videosNumber of videos in parent sub-tree
[in,out]sizeKbSize in KiB of parent sub-tree

Definition at line 1905 of file imagemanager.cpp.

Referenced by InfoList::CreateCount().

◆ SetRefinementClause()

void ImageDbReader::SetRefinementClause ( )
protected

Sets filter/ordering SQL clause used when reading database according to current filter/sort settings.

Filters by 'show hidden' & 'show pics/vids/all'. Orders files & dirs

Definition at line 1750 of file imagemanager.cpp.

◆ TypeSelector()

QString ImageDbReader::TypeSelector ( int  type)
staticprotected

Generate SQL type filter clause.

Parameters
typeFilter pic/video/both
Returns
QString SQL filter clause

Definition at line 1733 of file imagemanager.cpp.

Referenced by SetRefinementClause().

◆ OrderSelector()

QString ImageDbReader::OrderSelector ( int  order)
staticprotected

Generate SQL ordering clause.

Parameters
orderOrder criteria
Returns
QString SQL order caluse

Definition at line 1769 of file imagemanager.cpp.

Referenced by SetRefinementClause().

Member Data Documentation

◆ m_remote

ImageDbSg* ImageDbReader::m_remote
protected

◆ m_dirOrder

int ImageDbReader::m_dirOrder
protected

Display ordering of dirs.

Definition at line 440 of file imagemanager.h.

Referenced by SetRefinementClause().

◆ m_fileOrder

int ImageDbReader::m_fileOrder
protected

Display ordering of pics/videos.

Definition at line 441 of file imagemanager.h.

Referenced by SetRefinementClause().

◆ m_showHidden

bool ImageDbReader::m_showHidden
protected

Whether hidden images are displayed.

Definition at line 442 of file imagemanager.h.

Referenced by SetRefinementClause().

◆ m_showType

int ImageDbReader::m_showType
protected

Type of images to display - pic only/video only/both.

Definition at line 443 of file imagemanager.h.

Referenced by SetRefinementClause().

◆ m_refineClause

QString ImageDbReader::m_refineClause
protected

SQL clause for image filtering/ordering.

Definition at line 444 of file imagemanager.h.

Referenced by GetChildren(), GetDirectory(), GetImages(), GetImageTree(), and SetRefinementClause().


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