MythTV  master
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ImageDb< FS > Class Template Reference

Database API. More...

#include <imagemanager.h>

Inheritance diagram for ImageDb< FS >:
Inheritance graph
[legend]
Collaboration diagram for ImageDb< FS >:
Collaboration graph
[legend]

Public Member Functions

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

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

Protected Attributes

QString m_table
 Db table name. More...
 

Detailed Description

template<class FS>
class ImageDb< FS >

Database API.

Requires a filesystem adapter Only handles a single id format, ie. local ids or remote ids Provides ordering & filters (SQL does the work)

Definition at line 277 of file imagemanager.h.

Constructor & Destructor Documentation

◆ ImageDb()

template<class FS >
ImageDb< FS >::ImageDb ( QString  table)
inlineexplicitprotected

Definition at line 307 of file imagemanager.h.

Member Function Documentation

◆ GetImages()

template<class FS >
int ImageDb< FS >::GetImages ( const QString &  ids,
ImageList files,
ImageList dirs,
const QString &  refine = "" 
) const

Read database images/dirs by id.

Parameters
[in]idsComma-separated list of ids
[in,out]filesList of files
[in,out]dirsList of dirs
[in]refineSQL clause to refine selection & apply ordering
Returns
int Number of items matching query, -1 on SQL error

Definition at line 555 of file imagemanager.cpp.

Referenced by ImageDbReader::GetImages().

◆ GetDescendants()

template<class FS >
bool ImageDb< FS >::GetDescendants ( const QString &  ids,
ImageList files,
ImageList dirs 
) const

Return images and all of their descendants.

Parameters
[in]idsImage ids
[in,out]filesOrdered/filtered files
[in,out]dirsOrdered/filtered dirs

Definition at line 635 of file imagemanager.cpp.

Referenced by ImageDbReader::GetDescendants().

◆ InsertDbImage()

template<class FS >
int ImageDb< FS >::InsertDbImage ( ImageItemK im,
bool  checkForDuplicate = false 
) const

Adds new image to database, optionally checking for existing filepath.

Parameters
imImage to add
checkForDuplicateIf true, the image will not be added if its filepath already exists in Db.
Returns
int Id of new image or the existing image with same filepath

Definition at line 771 of file imagemanager.cpp.

◆ UpdateDbImage()

template<class FS >
bool ImageDb< FS >::UpdateDbImage ( ImageItemK im) const

Updates or creates database image or dir.

Item does not need to pre-exist

Parameters
imImage or dir

Definition at line 829 of file imagemanager.cpp.

◆ RemoveFromDB()

template<class FS >
QStringList ImageDb< FS >::RemoveFromDB ( const ImageList imList) const

Remove images/dirs from database.

Item does not need to exist in db

Parameters
imListList of items to delete
Returns
QStringList List of ids that were successfully removed

Definition at line 872 of file imagemanager.cpp.

◆ SetHidden()

template<class FS >
bool ImageDb< FS >::SetHidden ( bool  hide,
const QString &  ids 
) const

Sets hidden status of an image/dir in database.

Parameters
hideTrue = hidden, False = unhidden
idsList of item ids
Returns
bool False if db update failed

Definition at line 902 of file imagemanager.cpp.

◆ SetCover()

template<class FS >
bool ImageDb< FS >::SetCover ( int  dir,
int  id 
) const

Set the thumbnail(s) to be used for a dir.

Parameters
dirDir id
idImage id to use as cover/thumbnail

Definition at line 928 of file imagemanager.cpp.

◆ SetOrientation()

template<class FS >
bool ImageDb< FS >::SetOrientation ( int  id,
int  orientation 
) const

Sets image orientation in Db.

Parameters
idImage id
orientationExif orientation code

Definition at line 952 of file imagemanager.cpp.

◆ ReadAllImages()

template<class FS >
bool ImageDb< FS >::ReadAllImages ( ImageHash files,
ImageHash dirs 
) const

Read all database images and dirs as map. No filters or ordering applied.

Parameters
[in,out]filesMap <filepath, image>
[in,out]dirsMap <filepath, dir>

Definition at line 704 of file imagemanager.cpp.

◆ ClearDb()

template<class FS >
void ImageDb< FS >::ClearDb ( int  devId,
const QString &  action 
)

Clear Db for device & remove device.

Parameters
devIdDevice id, 0 to clear all devices
actionThe myth protocol message. Determines whether/how much information is removed from the database.
Returns
Either list of ids that have been deleted or "ALL" with list of filepath prefixes that will remove device images from the UI image cache

Definition at line 735 of file imagemanager.cpp.

◆ GetChildren()

template<class FS >
int ImageDb< FS >::GetChildren ( const QString &  ids,
ImageList files,
ImageList dirs,
const QString &  refine = "" 
) const

Read immediate children of a dir.

Parameters
[in,out]dirsList of child subdirs
[in,out]filesList of child files
[in]idsComma-separated list of dir ids
[in]refineSQL clause to refine selection & apply ordering
Returns
int Number of items matching query, -1 on SQL error

Definition at line 575 of file imagemanager.cpp.

Referenced by ImageDbReader::GetChildren().

◆ GetImageTree()

template<class FS >
bool ImageDb< FS >::GetImageTree ( int  id,
ImageList files,
const QString &  refine 
) const

Returns all files in the sub-tree of a dir.

Parameters
[in,out]filesList of images within sub-tree. Direct children first, then depth-first traversal of peer sub-dirs. Each level ordered as per refine criteria
idDir id
refineSQL clause defining filter & ordering criteria

Definition at line 684 of file imagemanager.cpp.

Referenced by ImageDbReader::GetImageTree().

◆ GetDirectory()

template<class FS >
int ImageDb< FS >::GetDirectory ( int  id,
ImagePtr parent,
ImageList files,
ImageList dirs,
const QString &  refine 
) const

Read a dir and its immediate children from Db.

Parameters
[in]idDir id
[out]parentDir item
[in,out]dirsOrdered/filtered child subdirs
[in,out]filesOrdered/filtered child files
[in]refineSQL clause for filtering/ordering child images
Returns
int Number of items matching query.

Definition at line 593 of file imagemanager.cpp.

Referenced by ImageDbReader::GetDirectory().

◆ GetDescendantCount()

template<class FS >
void ImageDb< FS >::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.

Parameters
[in]idDir id
[in]allSum whole table (without filtering on dir path)
[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 1013 of file imagemanager.cpp.

Referenced by ImageDbReader::GetDescendantCount().

◆ CreateImage()

template<class FS >
ImageItem * ImageDb< FS >::CreateImage ( const MSqlQuery query) const
protected

Create image from Db query data.

Parameters
queryDb query result
Returns
ImageItem An image object

Definition at line 512 of file imagemanager.cpp.

◆ ReadImages()

template<class FS >
int ImageDb< FS >::ReadImages ( ImageList dirs,
ImageList files,
const QString &  selector 
) const
protected

Read selected database images/dirs.

Parameters
[out]dirsList of the dirs
[out]filesList of the files
selectorSQL clause specifying selection and ordering of images
Returns
int Number of items retreved

Definition at line 978 of file imagemanager.cpp.

Member Data Documentation

◆ m_table

template<class FS >
QString ImageDb< FS >::m_table
protected

Db table name.

Definition at line 313 of file imagemanager.h.


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