#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 |
Definition at line 26 of file recentAlbums.h.
RecentAlbums::RecentAlbums | ( | ) |
Definition at line 20 of file recentAlbums.cpp.
References MAX_RECENT_ALBUMS, and maxItems.
00021 { 00022 maxItems = MAX_RECENT_ALBUMS; 00023 }
void RecentAlbums::clearList | ( | ) |
Definition at line 25 of file recentAlbums.cpp.
References albumLocations, albumNames, and albumPhotoCounts.
Referenced by TitleWidget::clearOpenRecentMenu().
00026 { 00027 albumNames.clear(); 00028 albumLocations.clear(); 00029 albumPhotoCounts.clear(); 00030 }
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().
00043 { 00044 name = *( albumNames.at (index) ); 00045 location = *( albumLocations.at (index) ); 00046 photoCount = *( albumPhotoCounts.at (index) ); 00047 }
int RecentAlbums::getMaxItems | ( | ) |
Definition at line 37 of file recentAlbums.cpp.
References maxItems.
Referenced by TitleWidget::populateOpenRecentMenu(), and TitleWidget::TitleWidget().
00038 { 00039 return maxItems; 00040 }
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().
00053 { 00054 //items are inserted at back during intialization of list when 00055 //starting up the program. no duplicates should exist so no checking is performed 00056 if(insertAtBack || albumNames.count() == 0) 00057 { 00058 albumNames.append ( name ); 00059 albumLocations.append ( location ); 00060 albumPhotoCounts.append( photos ); 00061 } 00062 //items are inserted at the front of the list when either: 00063 //1.) a new album is saved or 00064 //2.) an album is opened. 00065 //the list must then be checked for duplicates and any such duplicates should be removed 00066 else 00067 { 00068 //prepend item 00069 QStringList::Iterator namesIterator = ++albumNames.prepend ( name ); 00070 QStringList::Iterator locationsIterator = ++albumLocations.prepend ( location ); 00071 QStringList::Iterator photoCountsIterator = ++albumPhotoCounts.prepend ( photos ); 00072 00073 //search list for dupes 00074 while( true ) 00075 { 00076 //if location matches remove item 00077 if( location.compare(*locationsIterator) == 0 ) 00078 { 00079 albumNames.remove ( namesIterator ); 00080 albumLocations.remove ( locationsIterator ); 00081 albumPhotoCounts.remove( photoCountsIterator ); 00082 break; 00083 } 00084 00085 //end of list? stop 00086 if( namesIterator == albumNames.end() ) break; 00087 00088 //move to next item. 00089 namesIterator++; 00090 locationsIterator++; 00091 photoCountsIterator++; 00092 } 00093 00094 }//end else 00095 00096 //truncate list as necessary 00097 while(albumNames.count() > maxItems ) 00098 { 00099 albumNames.remove( albumNames.last() ); 00100 albumLocations.remove( albumLocations.last() ); 00101 albumPhotoCounts.remove( albumPhotoCounts.last() ); 00102 } 00103 }
int RecentAlbums::numEntries | ( | ) |
Definition at line 32 of file recentAlbums.cpp.
References albumNames.
Referenced by TitleWidget::refreshOpenRecentMenu(), and Window::~Window().
00033 { 00034 return albumNames.count(); 00035 }
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().