00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include <qstring.h>
00013
00014
00015 #include "recentAlbums.h"
00016
00017 #define MAX_RECENT_ALBUMS 9
00018
00019
00020 RecentAlbums::RecentAlbums()
00021 {
00022 maxItems = MAX_RECENT_ALBUMS;
00023 }
00024
00025 void RecentAlbums::clearList()
00026 {
00027 albumNames.clear();
00028 albumLocations.clear();
00029 albumPhotoCounts.clear();
00030 }
00031
00032 int RecentAlbums::numEntries()
00033 {
00034 return albumNames.count();
00035 }
00036
00037 int RecentAlbums::getMaxItems()
00038 {
00039 return maxItems;
00040 }
00041
00042 void RecentAlbums::getEntry ( int index, QString& name, QString& location, QString& photoCount )
00043 {
00044 name = *( albumNames.at (index) );
00045 location = *( albumLocations.at (index) );
00046 photoCount = *( albumPhotoCounts.at (index) );
00047 }
00048
00049 void RecentAlbums::insertEntry ( QString name,
00050 QString location,
00051 QString photos,
00052 bool insertAtBack )
00053 {
00054
00055
00056 if(insertAtBack || albumNames.count() == 0)
00057 {
00058 albumNames.append ( name );
00059 albumLocations.append ( location );
00060 albumPhotoCounts.append( photos );
00061 }
00062
00063
00064
00065
00066 else
00067 {
00068
00069 QStringList::Iterator namesIterator = ++albumNames.prepend ( name );
00070 QStringList::Iterator locationsIterator = ++albumLocations.prepend ( location );
00071 QStringList::Iterator photoCountsIterator = ++albumPhotoCounts.prepend ( photos );
00072
00073
00074 while( true )
00075 {
00076
00077 if( location.compare(*locationsIterator) == 0 )
00078 {
00079 albumNames.remove ( namesIterator );
00080 albumLocations.remove ( locationsIterator );
00081 albumPhotoCounts.remove( photoCountsIterator );
00082 break;
00083 }
00084
00085
00086 if( namesIterator == albumNames.end() ) break;
00087
00088
00089 namesIterator++;
00090 locationsIterator++;
00091 photoCountsIterator++;
00092 }
00093
00094 }
00095
00096
00097 while(albumNames.count() > maxItems )
00098 {
00099 albumNames.remove( albumNames.last() );
00100 albumLocations.remove( albumLocations.last() );
00101 albumPhotoCounts.remove( albumPhotoCounts.last() );
00102 }
00103 }
00104