AlbumShaper
1.0a3
|
This class maintains and handles saving and loading a list of recently viewed albums. More...
#include <recentAlbums.h>
Public Member Functions | |
RecentAlbums () | |
void | clearList () |
int | numEntries () |
int | getMaxItems () |
void | getEntry (int index, QString &name, QString &location, QString &photoCount) |
void | insertEntry (QString name, QString location, QString photos="-1", bool insertAtBack=true) |
Private Attributes | |
QStringList | albumNames |
lists of album names and locations | |
QStringList | albumLocations |
QStringList | albumPhotoCounts |
uint | maxItems |
max allowable items in list |
This class maintains and handles saving and loading a list of recently viewed albums.
Definition at line 26 of file recentAlbums.h.
RecentAlbums::RecentAlbums | ( | ) |
Definition at line 20 of file recentAlbums.cpp.
References MAX_RECENT_ALBUMS, and maxItems.
{ maxItems = MAX_RECENT_ALBUMS; }
void RecentAlbums::clearList | ( | ) |
Definition at line 25 of file recentAlbums.cpp.
References albumLocations, albumNames, and albumPhotoCounts.
Referenced by TitleWidget::clearOpenRecentMenu().
{ albumNames.clear(); albumLocations.clear(); albumPhotoCounts.clear(); }
void RecentAlbums::getEntry | ( | int | index, |
QString & | name, | ||
QString & | location, | ||
QString & | photoCount | ||
) |
Definition at line 42 of file recentAlbums.cpp.
References albumLocations, albumNames, and albumPhotoCounts.
Referenced by TitleWidget::loadRecentAlbum(), TitleWidget::refreshOpenRecentMenu(), and Window::~Window().
{ name = *( albumNames.at (index) ); location = *( albumLocations.at (index) ); photoCount = *( albumPhotoCounts.at (index) ); }
int RecentAlbums::getMaxItems | ( | ) |
Definition at line 37 of file recentAlbums.cpp.
References maxItems.
Referenced by TitleWidget::populateOpenRecentMenu(), and TitleWidget::TitleWidget().
{ return maxItems; }
void RecentAlbums::insertEntry | ( | QString | name, |
QString | location, | ||
QString | photos = "-1" , |
||
bool | insertAtBack = true |
||
) |
Definition at line 49 of file recentAlbums.cpp.
References albumLocations, albumNames, albumPhotoCounts, and maxItems.
Referenced by TitleWidget::loadAlbum(), TitleWidget::saveAlbum(), TitleWidget::saveAsAlbum(), and TitleWidget::TitleWidget().
{ //items are inserted at back during intialization of list when //starting up the program. no duplicates should exist so no checking is performed if(insertAtBack || albumNames.count() == 0) { albumNames.append ( name ); albumLocations.append ( location ); albumPhotoCounts.append( photos ); } //items are inserted at the front of the list when either: //1.) a new album is saved or //2.) an album is opened. //the list must then be checked for duplicates and any such duplicates should be removed else { //prepend item QStringList::Iterator namesIterator = ++albumNames.prepend ( name ); QStringList::Iterator locationsIterator = ++albumLocations.prepend ( location ); QStringList::Iterator photoCountsIterator = ++albumPhotoCounts.prepend ( photos ); //search list for dupes while( true ) { //if location matches remove item if( location.compare(*locationsIterator) == 0 ) { albumNames.remove ( namesIterator ); albumLocations.remove ( locationsIterator ); albumPhotoCounts.remove( photoCountsIterator ); break; } //end of list? stop if( namesIterator == albumNames.end() ) break; //move to next item. namesIterator++; locationsIterator++; photoCountsIterator++; } }//end else //truncate list as necessary while(albumNames.count() > maxItems ) { albumNames.remove( albumNames.last() ); albumLocations.remove( albumLocations.last() ); albumPhotoCounts.remove( albumPhotoCounts.last() ); } }
int RecentAlbums::numEntries | ( | ) |
Definition at line 32 of file recentAlbums.cpp.
References albumNames.
Referenced by TitleWidget::refreshOpenRecentMenu(), and Window::~Window().
{ return albumNames.count(); }
QStringList RecentAlbums::albumLocations [private] |
Definition at line 56 of file recentAlbums.h.
Referenced by clearList(), getEntry(), and insertEntry().
QStringList RecentAlbums::albumNames [private] |
lists of album names and locations
Definition at line 55 of file recentAlbums.h.
Referenced by clearList(), getEntry(), insertEntry(), and numEntries().
QStringList RecentAlbums::albumPhotoCounts [private] |
Definition at line 57 of file recentAlbums.h.
Referenced by clearList(), getEntry(), and insertEntry().
uint RecentAlbums::maxItems [private] |
max allowable items in list
Definition at line 60 of file recentAlbums.h.
Referenced by getMaxItems(), insertEntry(), and RecentAlbums().