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

A datastore of images for display by a screen. More...

#include <galleryviews.h>

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

Public Member Functions

 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...
 
virtual bool LoadFromDb (int parentId)
 Populate view with database images from a directory. 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 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...
 

Static Protected Member Functions

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

Protected Attributes

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

Detailed Description

A datastore of images for display by a screen.

A flat view provides a list of ordered images (no dirs) from a single directory (as required by a slideshow of a directory).

Definition at line 98 of file galleryviews.h.

Constructor & Destructor Documentation

◆ FlatView()

FlatView::FlatView ( SlideOrderType  order)
inlineexplicit

Definition at line 101 of file galleryviews.h.

◆ ~FlatView()

virtual FlatView::~FlatView ( )
inlinevirtual

Definition at line 103 of file galleryviews.h.

Member Function Documentation

◆ GetParentId()

int FlatView::GetParentId ( ) const
inline

◆ GetAllNodes()

ImageListK FlatView::GetAllNodes ( ) const

Get all images/dirs in view.

Returns
ImageList List of images/dirs

Definition at line 35 of file galleryviews.cpp.

Referenced by GalleryThumbView::BuildImageList().

◆ GetSelected()

ImagePtrK FlatView::GetSelected ( ) const

◆ HasNext()

ImagePtrK FlatView::HasNext ( int  inc) const

Peeks at next image in view but does not advance iterator.

Returns
ImageItem The next image or nullptr

Definition at line 136 of file galleryviews.cpp.

Referenced by GallerySlideView::ShowNextSlide(), and GallerySlideView::TransitionComplete().

◆ HasPrev()

ImagePtrK FlatView::HasPrev ( int  inc) const

Peeks at previous image in view but does not decrement iterator.

Returns
ImageItem The previous image or nullptr

Definition at line 170 of file galleryviews.cpp.

Referenced by GallerySlideView::ShowPrevSlide().

◆ Next()

ImagePtrK FlatView::Next ( int  inc)

Advance iterator and return next image, wrapping if necessary. Regenerates unordered views on wrap.

Returns
ImageItem Next image or nullptr if empty

Definition at line 148 of file galleryviews.cpp.

Referenced by GallerySlideView::ShowNextSlide().

◆ Prev()

ImagePtrK FlatView::Prev ( int  inc)

Decrements iterator and returns previous image. Wraps at start.

Returns
ImageItem Previous image or nullptr if empty

Definition at line 181 of file galleryviews.cpp.

Referenced by GallerySlideView::ShowPrevSlide().

◆ GetPosition()

QString FlatView::GetPosition ( void  ) const

Get positional status.

Returns
QString "m/n" where m is selected index, n is total count in view

Definition at line 59 of file galleryviews.cpp.

Referenced by GallerySlideView::SlideAvailable().

◆ Select()

bool FlatView::Select ( int  id,
int  fallback = 0 
)

Selects first occurrence of an image.

Parameters
idImage id
fallbackView index to select if image is not in view. Defaults to first image. If negative then current selection is not changed if the image is not found
Returns
bool True if the image was found

Definition at line 101 of file galleryviews.cpp.

Referenced by GalleryThumbView::DirSelectUp(), DirectoryView::LoadFromDb(), GalleryThumbView::SelectImage(), GalleryThumbView::SetUiSelection(), and GallerySlideView::Start().

◆ LoadFromDb()

bool FlatView::LoadFromDb ( int  parentId)
virtual

Populate view with database images from a directory.

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 in TreeView, and DirectoryView.

Definition at line 357 of file galleryviews.cpp.

Referenced by Next(), and GallerySlideView::Start().

◆ ClearImage()

QStringList FlatView::ClearImage ( int  id,
bool  remove = false 
)

Clear file from UI cache and optionally from view.

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

Definition at line 389 of file galleryviews.cpp.

Referenced by DirectoryView::RemoveImage().

◆ ClearCache()

void FlatView::ClearCache ( void  )

Clears UI cache.

Definition at line 376 of file galleryviews.cpp.

Referenced by DirectoryView::ClearCache().

◆ Update()

bool FlatView::Update ( int  id)

Updates view with images that have been updated.

Parameters
idImage id to update
Returns
bool True if the current selection has been updated

Definition at line 70 of file galleryviews.cpp.

Referenced by GallerySlideView::customEvent().

◆ Rotate()

void FlatView::Rotate ( int  id)

Rotate view so that starting image is at front.

Parameters
idThe image to be positioned

Definition at line 416 of file galleryviews.cpp.

Referenced by GallerySlideView::Start().

◆ Clear()

void FlatView::Clear ( bool  resetParent = true)

Reset view.

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

Definition at line 122 of file galleryviews.cpp.

Referenced by DirectoryView::Clear(), Populate(), and ~FlatView().

◆ GetCachedThumbUrl()

QString FlatView::GetCachedThumbUrl ( int  id) const
inline

Definition at line 121 of file galleryviews.h.

Referenced by GalleryThumbView::customEvent().

◆ CalculateSeasonalWeights()

WeightList FlatView::CalculateSeasonalWeights ( ImageList files)
staticprotected

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.

Parameters
filesList of database images
Returns
WeightList Corresponding list of weightings

Definition at line 294 of file galleryviews.cpp.

Referenced by Populate().

◆ Populate()

void FlatView::Populate ( ImageList files)
protected

Fills view with Db images, re-ordering them as required.

Parameters
filesList of images from database

Definition at line 199 of file galleryviews.cpp.

Referenced by LoadFromDb(), DirectoryView::LoadFromDb(), and TreeView::LoadFromDb().

◆ Cache()

void FlatView::Cache ( int  id,
int  parent,
const QString &  url,
const QString &  thumb 
)
protected

Cache image properties to optimize UI.

Parameters
idImage id
parentIts dir
urlImage url
thumbThumbnail url

Definition at line 437 of file galleryviews.cpp.

Referenced by DirectoryView::Cache(), and Populate().

Member Data Documentation

◆ m_parentId

int FlatView::m_parentId {-1}
protected

◆ m_order

SlideOrderType FlatView::m_order {kOrdered}
protected

Definition at line 131 of file galleryviews.h.

Referenced by Next(), and Populate().

◆ m_mgr

ImageManagerFe& FlatView::m_mgr
protected

◆ m_images

QHash<int, ImagePtrK> FlatView::m_images
protected

◆ m_sequence

ImageIdList FlatView::m_sequence
protected

◆ m_active

int FlatView::m_active {0}
protected

Sequence index of current selected image.

Definition at line 135 of file galleryviews.h.

Referenced by Clear(), GetPosition(), DirectoryView::GetPosition(), GetSelected(), HasNext(), HasPrev(), Next(), Prev(), and Select().

◆ m_fileCache

QHash<int, FileCacheEntry> FlatView::m_fileCache
protected

Caches displayed image files.

Definition at line 138 of file galleryviews.h.

Referenced by Cache(), DirectoryView::Cache(), ClearCache(), ClearImage(), GetCachedThumbUrl(), and DirectoryView::RemoveImage().


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