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

A datastore of images for display by a screen. Provides an ordered list of dirs & images from a single directory, as required by a Thumbnail view. Permits marking of items and populates dir thumbnails from their subtree. More...

#include <galleryviews.h>

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

Public Member Functions

 DirectoryView (SlideOrderType order)
 Constructs a view of images & directories that can be marked. More...
 
ImagePtrK GetParent () const
 
QString GetPosition () const
 Get positional status. More...
 
bool LoadFromDb (int parentId) override
 Populate view from database as images/subdirs of a directory. View is ordered: Parent dir, sub-dirs, images. Dir thumbnails are derived from their subtree. More...
 
void Clear (bool resetParent=true)
 Resets view. More...
 
MenuSubjects GetMenuSubjects ()
 Determine current selection, markings & various info to support menu display. More...
 
QStringList RemoveImage (int id, bool deleted=false)
 Clear file/dir and all its ancestors from UI cache so that ancestor thumbnails are recalculated. Optionally deletes file/dir from view. More...
 
void ClearCache ()
 Clears UI cache. More...
 
void MarkAll ()
 Mark all images/dirs. More...
 
void Mark (int id, bool mark)
 Mark/unmark an image/dir. More...
 
void InvertMarked ()
 Mark all unmarked items, unmark all marked items. More...
 
void ClearMarked ()
 Unmark all items. More...
 
bool IsMarked (int id) const
 
- Public Member Functions inherited from FlatView
 FlatView (SlideOrderType order)
 
virtual ~FlatView ()
 
int GetParentId () const
 
ImageListK GetAllNodes () const
 Get all images/dirs in view. More...
 
ImagePtrK GetSelected () const
 Get current selection. More...
 
ImagePtrK HasNext (int inc) const
 Peeks at next image in view but does not advance iterator. More...
 
ImagePtrK HasPrev (int inc) const
 Peeks at previous image in view but does not decrement iterator. More...
 
ImagePtrK Next (int inc)
 Advance iterator and return next image, wrapping if necessary. Regenerates unordered views on wrap. More...
 
ImagePtrK Prev (int inc)
 Decrements iterator and returns previous image. Wraps at start. More...
 
QString GetPosition () const
 Get positional status. More...
 
bool Select (int id, int fallback=0)
 Selects first occurrence of an image. More...
 
QStringList ClearImage (int id, bool remove=false)
 Clear file from UI cache and optionally from view. More...
 
void ClearCache ()
 Clears UI cache. More...
 
bool Update (int id)
 Updates view with images that have been updated. More...
 
void Rotate (int id)
 Rotate view so that starting image is at front. More...
 
void Clear (bool resetParent=true)
 Reset view. More...
 
QString GetCachedThumbUrl (int id) const
 

Protected Member Functions

void SetDirectory (int newParent)
 Manage markings on tree navigation. More...
 
void LoadDirThumbs (ImageItem &parent, int thumbsNeeded, int level=0)
 Populate thumbs for a dir. More...
 
void PopulateThumbs (ImageItem &parent, int thumbsNeeded, const ImageList &files, const ImageList &dirs, int level=0)
 Populate directory stats & thumbnails recursively from database as follows: Use user cover, if assigned. Otherwise derive 4 thumbnails from: first 4 images, then 1st thumbnail from first 4 sub-dirs, then 2nd thumbnail from sub-dirs etc. More...
 
ImageIdList GetChildren () const
 
bool PopulateFromCache (ImageItem &dir, int required)
 Retrieve cached dir, if available. More...
 
void Cache (ImageItemK &dir, int thumbCount)
 Cache displayed dir. More...
 
- Protected Member Functions inherited from FlatView
void Populate (ImageList &files)
 Fills view with Db images, re-ordering them as required. More...
 
void Cache (int id, int parent, const QString &url, const QString &thumb)
 Cache image properties to optimize UI. More...
 

Protected Attributes

MarkedFiles m_marked
 Marked items in current dir/view. More...
 
MarkedFiles m_prevMarked
 Marked items in previous dir. More...
 
QHash< int, DirCacheEntrym_dirCache
 Caches displayed image dirs. More...
 
- Protected Attributes inherited from FlatView
int m_parentId {-1}
 
SlideOrderType m_order {kOrdered}
 
ImageManagerFem_mgr
 
QHash< int, ImagePtrKm_images
 Image objects currently displayed. More...
 
ImageIdList m_sequence
 The sequence in which to display images. More...
 
int m_active {0}
 Sequence index of current selected image. More...
 
QHash< int, FileCacheEntrym_fileCache
 Caches displayed image files. More...
 

Additional Inherited Members

- Static Protected Member Functions inherited from FlatView
static WeightList CalculateSeasonalWeights (ImageList &files)
 This method calculates a weight for the item based on how closely it was taken to the current time of year. This means that New Year's pictures will be displayed very frequently on every New Year's, and that anniversary pictures will be favored again every anniversary. The weights are chosen using a beta distribution with a tunable shape parameter. More...
 

Detailed Description

A datastore of images for display by a screen. Provides an ordered list of dirs & images from a single directory, as required by a Thumbnail view. Permits marking of items and populates dir thumbnails from their subtree.

Definition at line 170 of file galleryviews.h.

Constructor & Destructor Documentation

◆ DirectoryView()

DirectoryView::DirectoryView ( SlideOrderType  order)
explicit

Constructs a view of images & directories that can be marked.

Parameters
orderOrdering to use for view

Definition at line 472 of file galleryviews.cpp.

Member Function Documentation

◆ GetParent()

ImagePtrK DirectoryView::GetParent ( ) const
inline

◆ GetPosition()

QString DirectoryView::GetPosition ( ) const

Get positional status.

Returns
QString "m/n" where m is selected index (0 for parent), n is total images

Definition at line 484 of file galleryviews.cpp.

Referenced by GalleryThumbView::SetUiSelection().

◆ LoadFromDb()

bool DirectoryView::LoadFromDb ( int  parentId)
overridevirtual

Populate view from database as images/subdirs of a directory. View is ordered: Parent dir, sub-dirs, images. Dir thumbnails are derived from their subtree.

Parameters
parentIdThe dir id, if positive. Otherwise the view is refreshed using the existing parent dir
Returns
bool True if resulting view is not empty

Reimplemented from FlatView.

Definition at line 498 of file galleryviews.cpp.

Referenced by GalleryThumbView::LoadData().

◆ Clear()

void DirectoryView::Clear ( bool  resetParent = true)

Resets view.

Parameters
resetParentparent id is only reset to root when this is set

Definition at line 716 of file galleryviews.cpp.

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

◆ GetMenuSubjects()

MenuSubjects DirectoryView::GetMenuSubjects ( )

Determine current selection, markings & various info to support menu display.

Returns
MenuSubjects Current state

Definition at line 811 of file galleryviews.cpp.

Referenced by GalleryThumbView::MenuMain().

◆ RemoveImage()

QStringList DirectoryView::RemoveImage ( int  id,
bool  deleted = false 
)

Clear file/dir and all its ancestors from UI cache so that ancestor thumbnails are recalculated. Optionally deletes file/dir from view.

Parameters
idImage id
deletedIf true, file is also deleted from view
Returns
QStringList Url of image & thumbnail to remove from image cache

Definition at line 906 of file galleryviews.cpp.

Referenced by GalleryThumbView::RemoveImages().

◆ ClearCache()

void DirectoryView::ClearCache ( )

◆ MarkAll()

void DirectoryView::MarkAll ( )

Mark all images/dirs.

Definition at line 727 of file galleryviews.cpp.

Referenced by GalleryThumbView::DoMarkAll().

◆ Mark()

void DirectoryView::Mark ( int  id,
bool  mark 
)

Mark/unmark an image/dir.

Parameters
idThe image/dir
markIf true, mark item. Otherwise unmark

Definition at line 740 of file galleryviews.cpp.

Referenced by GalleryThumbView::DoHideItem(), GalleryThumbView::DoHideMarked(), GalleryThumbView::DoMarkItem(), and GalleryThumbView::Move().

◆ InvertMarked()

void DirectoryView::InvertMarked ( )

Mark all unmarked items, unmark all marked items.

Definition at line 759 of file galleryviews.cpp.

Referenced by GalleryThumbView::MarkInvertAll().

◆ ClearMarked()

void DirectoryView::ClearMarked ( )

Unmark all items.

Definition at line 770 of file galleryviews.cpp.

Referenced by Clear(), and GalleryThumbView::DoMarkAll().

◆ IsMarked()

bool DirectoryView::IsMarked ( int  id) const
inline

◆ SetDirectory()

void DirectoryView::SetDirectory ( int  newParent)
protected

Manage markings on tree navigation.

Parameters
newParentId of new parent dir

Definition at line 781 of file galleryviews.cpp.

Referenced by LoadFromDb().

◆ LoadDirThumbs()

void DirectoryView::LoadDirThumbs ( ImageItem parent,
int  thumbsNeeded,
int  level = 0 
)
protected

Populate thumbs for a dir.

Parameters
parentParent dir
thumbsNeededNumber of thumbnails needed
levelRecursion depth

Definition at line 570 of file galleryviews.cpp.

Referenced by LoadFromDb(), and PopulateThumbs().

◆ PopulateThumbs()

void DirectoryView::PopulateThumbs ( ImageItem parent,
int  thumbsNeeded,
const ImageList files,
const ImageList dirs,
int  level = 0 
)
protected

Populate directory stats & thumbnails recursively from database as follows: Use user cover, if assigned. Otherwise derive 4 thumbnails from: first 4 images, then 1st thumbnail from first 4 sub-dirs, then 2nd thumbnail from sub-dirs etc.

Parameters
parentThe parent dir
thumbsNeededNumber of thumbnails required
filesA list of files to process
dirsA list of directories to process
levelRecursion level (to detect recursion deadlocks)

Definition at line 595 of file galleryviews.cpp.

Referenced by LoadDirThumbs(), and LoadFromDb().

◆ GetChildren()

ImageIdList DirectoryView::GetChildren ( ) const
inlineprotected

Definition at line 197 of file galleryviews.h.

Referenced by InvertMarked(), and MarkAll().

◆ PopulateFromCache()

bool DirectoryView::PopulateFromCache ( ImageItem dir,
int  required 
)
protected

Retrieve cached dir, if available.

Parameters
dirDir image
requiredNumber of thumbnails required
Returns
bool True if a cache entry exists

Definition at line 844 of file galleryviews.cpp.

Referenced by LoadDirThumbs(), and LoadFromDb().

◆ Cache()

void DirectoryView::Cache ( ImageItemK dir,
int  thumbCount 
)
protected

Cache displayed dir.

Parameters
dirDir image
thumbCountNumber of populated thumbnails

Definition at line 864 of file galleryviews.cpp.

Referenced by PopulateThumbs().

Member Data Documentation

◆ m_marked

MarkedFiles DirectoryView::m_marked
protected

Marked items in current dir/view.

Definition at line 201 of file galleryviews.h.

Referenced by ClearMarked(), DirectoryView(), GetMenuSubjects(), InvertMarked(), IsMarked(), LoadFromDb(), Mark(), MarkAll(), RemoveImage(), and SetDirectory().

◆ m_prevMarked

MarkedFiles DirectoryView::m_prevMarked
protected

Marked items in previous dir.

Definition at line 202 of file galleryviews.h.

Referenced by ClearMarked(), DirectoryView(), GetMenuSubjects(), InvertMarked(), IsMarked(), Mark(), MarkAll(), RemoveImage(), and SetDirectory().

◆ m_dirCache

QHash<int, DirCacheEntry> DirectoryView::m_dirCache
protected

Caches displayed image dirs.

Definition at line 205 of file galleryviews.h.

Referenced by Cache(), ClearCache(), PopulateFromCache(), and RemoveImage().


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