AlbumShaper  1.0a3
Public Member Functions | Private Attributes | List of all members
RecentAlbums Class Reference

This class maintains and handles saving and loading a list of recently viewed albums. More...

#include <recentAlbums.h>

Collaboration diagram for RecentAlbums:
Collaboration graph
[legend]

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 More...
 
QStringList albumLocations
 
QStringList albumPhotoCounts
 
uint maxItems
 max allowable items in list More...
 

Detailed Description

This class maintains and handles saving and loading a list of recently viewed albums.

Definition at line 26 of file recentAlbums.h.

Constructor & Destructor Documentation

§ RecentAlbums()

RecentAlbums::RecentAlbums ( )

Definition at line 20 of file recentAlbums.cpp.

References MAX_RECENT_ALBUMS, and maxItems.

21 {
23 }
#define MAX_RECENT_ALBUMS
uint maxItems
max allowable items in list
Definition: recentAlbums.h:60

Member Function Documentation

§ clearList()

void RecentAlbums::clearList ( )

Definition at line 25 of file recentAlbums.cpp.

References albumLocations, albumNames, and albumPhotoCounts.

Referenced by TitleWidget::clearOpenRecentMenu().

26 {
27  albumNames.clear();
28  albumLocations.clear();
29  albumPhotoCounts.clear();
30 }
QStringList albumPhotoCounts
Definition: recentAlbums.h:57
QStringList albumNames
lists of album names and locations
Definition: recentAlbums.h:55
QStringList albumLocations
Definition: recentAlbums.h:56

§ getEntry()

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

43 {
44  name = *( albumNames.at (index) );
45  location = *( albumLocations.at (index) );
46  photoCount = *( albumPhotoCounts.at (index) );
47 }
QStringList albumPhotoCounts
Definition: recentAlbums.h:57
QStringList albumNames
lists of album names and locations
Definition: recentAlbums.h:55
QStringList albumLocations
Definition: recentAlbums.h:56

§ getMaxItems()

int RecentAlbums::getMaxItems ( )

Definition at line 37 of file recentAlbums.cpp.

References maxItems.

Referenced by TitleWidget::populateOpenRecentMenu(), and TitleWidget::TitleWidget().

38 {
39  return maxItems;
40 }
uint maxItems
max allowable items in list
Definition: recentAlbums.h:60

§ insertEntry()

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

53 {
54  //items are inserted at back during intialization of list when
55  //starting up the program. no duplicates should exist so no checking is performed
56  if(insertAtBack || albumNames.count() == 0)
57  {
58  albumNames.append ( name );
59  albumLocations.append ( location );
60  albumPhotoCounts.append( photos );
61  }
62  //items are inserted at the front of the list when either:
63  //1.) a new album is saved or
64  //2.) an album is opened.
65  //the list must then be checked for duplicates and any such duplicates should be removed
66  else
67  {
68  //prepend item
69  albumNames.prepend(name);
70  albumLocations.prepend(location);
71  albumPhotoCounts.prepend(photos);
72 
73  QStringList::Iterator namesIterator=albumNames.find(name);
74  QStringList::Iterator locationsIterator=albumLocations.find(location);
75  QStringList::Iterator photoCountsIterator=albumPhotoCounts.find(photos);
76 
77  //search list for dupes
78  while( true )
79  {
80  //move to next item.
81  namesIterator++;
82  locationsIterator++;
83  photoCountsIterator++;
84 
85  //if location matches remove item
86  if( location.compare(*locationsIterator) == 0 )
87  {
88  albumNames.remove ( namesIterator );
89  albumLocations.remove ( locationsIterator );
90  albumPhotoCounts.remove( photoCountsIterator );
91  break;
92  }
93 
94  //end of list? stop
95  if( namesIterator == albumNames.end() ) break;
96  }
97 
98  }//end else
99 
100  //truncate list as necessary
101  while(albumNames.count() > maxItems )
102  {
103  albumNames.remove( albumNames.last() );
104  albumLocations.remove( albumLocations.last() );
105  albumPhotoCounts.remove( albumPhotoCounts.last() );
106  }
107 }
QStringList albumPhotoCounts
Definition: recentAlbums.h:57
QStringList albumNames
lists of album names and locations
Definition: recentAlbums.h:55
QStringList albumLocations
Definition: recentAlbums.h:56
uint maxItems
max allowable items in list
Definition: recentAlbums.h:60

§ numEntries()

int RecentAlbums::numEntries ( )

Definition at line 32 of file recentAlbums.cpp.

References albumNames.

Referenced by TitleWidget::refreshOpenRecentMenu(), and Window::~Window().

33 {
34  return albumNames.count();
35 }
QStringList albumNames
lists of album names and locations
Definition: recentAlbums.h:55

Member Data Documentation

§ albumLocations

QStringList RecentAlbums::albumLocations
private

Definition at line 56 of file recentAlbums.h.

Referenced by clearList(), getEntry(), and insertEntry().

§ albumNames

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

§ albumPhotoCounts

QStringList RecentAlbums::albumPhotoCounts
private

Definition at line 57 of file recentAlbums.h.

Referenced by clearList(), getEntry(), and insertEntry().

§ maxItems

uint RecentAlbums::maxItems
private

max allowable items in list

Definition at line 60 of file recentAlbums.h.

Referenced by getMaxItems(), insertEntry(), and RecentAlbums().


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