Geometrize  1.0
An application for geometrizing images into geometric primitives
Classes | Signals | Public Member Functions | Private Attributes | Friends | List of all members
geometrize::RecentItems Class Reference

The RecentItems class encapsulates a list of items that were recently interacted with. The class keeps a record of these items stored in preferences. Useful for keeping track of recently opened files. More...

#include <recentitems.h>

Inheritance diagram for geometrize::RecentItems:
Inheritance graph
[legend]
Collaboration diagram for geometrize::RecentItems:
Collaboration graph
[legend]

Classes

class  RecentItemsImpl
 

Signals

void signal_added (const RecentItem &item)
 signal_added is emitted after an item is added. More...
 
void signal_removed (const QString &itemId)
 signal_removed is emitted after an item is removed. More...
 
void signal_cleared ()
 signal_cleared is emitted after the recent items are cleared. More...
 

Public Member Functions

 RecentItems (const QString &group, unsigned int maxItems)
 RecentItems Creates a new RecentItems instance. More...
 
RecentItemsoperator= (RecentItems &)=delete
 
 RecentItems (RecentItems &)=delete
 
 RecentItems (RecentItems &&)=delete
 
virtual ~RecentItems ()
 
QList< RecentItemgetItems () const
 getItems Gets the recent items. More...
 
void add (const QString &itemId, const QString &itemDisplayName)
 add Adds an item to the recent items. More...
 
void remove (const QString &itemId)
 remove Removes an item from the recent items. More...
 
void clear ()
 clear Removes all items from the recent items. More...
 

Private Attributes

std::unique_ptr< RecentItemsImpld
 

Friends

void swap (RecentItems &first, RecentItems &second)
 

Detailed Description

The RecentItems class encapsulates a list of items that were recently interacted with. The class keeps a record of these items stored in preferences. Useful for keeping track of recently opened files.

Constructor & Destructor Documentation

◆ RecentItems() [1/3]

geometrize::RecentItems::RecentItems ( const QString &  group,
unsigned int  maxItems 
)

RecentItems Creates a new RecentItems instance.

Parameters
groupThe base path group to use for storing the recent items in settings e.g. "recent_image_paths", "recent_video_names" etc.
maxItemsThe maximum number of items to load. The most recent items will be loaded initially, and the oldest items will be replaced when new items are added over the limit.
164  : d{std::make_unique<RecentItemsImpl>(group, maxItems)}
165 {
166 }

◆ RecentItems() [2/3]

geometrize::RecentItems::RecentItems ( RecentItems )
delete

◆ RecentItems() [3/3]

geometrize::RecentItems::RecentItems ( RecentItems &&  )
delete

◆ ~RecentItems()

geometrize::RecentItems::~RecentItems ( )
virtual
169 {
170 }

Member Function Documentation

◆ add()

void geometrize::RecentItems::add ( const QString &  itemId,
const QString &  itemDisplayName 
)

add Adds an item to the recent items.

Parameters
itemIdA unique id for the item (e.g. a complete file path).
itemDisplayNameA display name for the item (e.g. a file name).
178 {
179  if(d->getItemCount() > d->getMaxItemCount()) {
180  remove(d->getOldestItemKey());
181  }
182 
183  const bool preexisting{d->contains(itemId)};
184  if(!preexisting) {
185  const RecentItem item{d->addItem(itemId, itemDisplayName)};
186  emit signal_added(item);
187  }
188 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ clear()

void geometrize::RecentItems::clear ( )

clear Removes all items from the recent items.

197 {
198  d->clearItems();
199  emit signal_cleared();
200 }
Here is the caller graph for this function:

◆ getItems()

QList< RecentItem > geometrize::RecentItems::getItems ( ) const

getItems Gets the recent items.

Returns
A list of the recent items, sorted from most recently interacted with to oldest.
173 {
174  return d->getItems();
175 }
Here is the caller graph for this function:

◆ operator=()

RecentItems& geometrize::RecentItems::operator= ( RecentItems )
delete

◆ remove()

void geometrize::RecentItems::remove ( const QString &  itemId)

remove Removes an item from the recent items.

Parameters
itemIdThe item id to remove.
191 {
192  d->removeItem(itemId);
193  emit signal_removed(itemId);
194 }
Here is the caller graph for this function:

◆ signal_added

void geometrize::RecentItems::signal_added ( const RecentItem item)
signal

signal_added is emitted after an item is added.

Parameters
itemThe item that was added.
Here is the caller graph for this function:

◆ signal_cleared

void geometrize::RecentItems::signal_cleared ( )
signal

signal_cleared is emitted after the recent items are cleared.

Here is the caller graph for this function:

◆ signal_removed

void geometrize::RecentItems::signal_removed ( const QString &  itemId)
signal

signal_removed is emitted after an item is removed.

Parameters
itemIdThe id of the item that was removed.
Here is the caller graph for this function:

Friends And Related Function Documentation

◆ swap

void swap ( RecentItems first,
RecentItems second 
)
friend

Member Data Documentation

◆ d

std::unique_ptr<RecentItemsImpl> geometrize::RecentItems::d
private

The documentation for this class was generated from the following files:
geometrize::RecentItems::d
std::unique_ptr< RecentItemsImpl > d
Definition: recentitems.h:77
geometrize::RecentItems::signal_cleared
void signal_cleared()
signal_cleared is emitted after the recent items are cleared.
geometrize::RecentItems::signal_removed
void signal_removed(const QString &itemId)
signal_removed is emitted after an item is removed.
geometrize::RecentItems::remove
void remove(const QString &itemId)
remove Removes an item from the recent items.
Definition: recentitems.cpp:190
geometrize::RecentItems::signal_added
void signal_added(const RecentItem &item)
signal_added is emitted after an item is added.