Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 4f45e7bdfd4a5ff17f5f8eaab90d017f > files > 1497

albumshaper-2.1-6mdv2010.0.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>AlbumShaper: recentAlbums.cpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.9 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
    </ul>
  </div>
<h1>recentAlbums.cpp</h1><a href="recentAlbums_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">//==============================================</span>
<a name="l00002"></a>00002 <span class="comment">//  copyright            : (C) 2003-2005 by Will Stokes</span>
<a name="l00003"></a>00003 <span class="comment">//==============================================</span>
<a name="l00004"></a>00004 <span class="comment">//  This program is free software; you can redistribute it</span>
<a name="l00005"></a>00005 <span class="comment">//  and/or modify it under the terms of the GNU General</span>
<a name="l00006"></a>00006 <span class="comment">//  Public License as published by the Free Software</span>
<a name="l00007"></a>00007 <span class="comment">//  Foundation; either version 2 of the License, or</span>
<a name="l00008"></a>00008 <span class="comment">//  (at your option) any later version.</span>
<a name="l00009"></a>00009 <span class="comment">//==============================================</span>
<a name="l00010"></a>00010 
<a name="l00011"></a>00011 <span class="comment">//Systemwide includes</span>
<a name="l00012"></a>00012 <span class="preprocessor">#include &lt;qstring.h&gt;</span>
<a name="l00013"></a>00013 
<a name="l00014"></a>00014 <span class="comment">//Projectwide includes</span>
<a name="l00015"></a>00015 <span class="preprocessor">#include "<a class="code" href="recentAlbums_8h.html">recentAlbums.h</a>"</span>
<a name="l00016"></a>00016 
<a name="l00017"></a><a class="code" href="recentAlbums_8cpp.html#79a6277e847638283a40a440cde38129">00017</a> <span class="preprocessor">#define MAX_RECENT_ALBUMS 9</span>
<a name="l00018"></a>00018 <span class="preprocessor"></span>
<a name="l00019"></a>00019 <span class="comment">//==============================================</span>
<a name="l00020"></a><a class="code" href="classRecentAlbums.html#2b7d9ceef7bb8d10b0a844a0fed63a9e">00020</a> <a class="code" href="classRecentAlbums.html#2b7d9ceef7bb8d10b0a844a0fed63a9e">RecentAlbums::RecentAlbums</a>()
<a name="l00021"></a>00021 {
<a name="l00022"></a>00022   <a class="code" href="classRecentAlbums.html#9e817f14ffe9a73f810e4a0a0e97498b" title="max allowable items in list">maxItems</a> = <a class="code" href="recentAlbums_8cpp.html#79a6277e847638283a40a440cde38129">MAX_RECENT_ALBUMS</a>;
<a name="l00023"></a>00023 }
<a name="l00024"></a>00024 <span class="comment">//==============================================</span>
<a name="l00025"></a><a class="code" href="classRecentAlbums.html#9c26ecee7fb362d2ab57d4f2d94697c1">00025</a> <span class="keywordtype">void</span> <a class="code" href="classRecentAlbums.html#9c26ecee7fb362d2ab57d4f2d94697c1">RecentAlbums::clearList</a>()
<a name="l00026"></a>00026 {
<a name="l00027"></a>00027   <a class="code" href="classRecentAlbums.html#3a385fc2e0091cdeb81ac006f8c9993f" title="lists of album names and locations">albumNames</a>.clear();
<a name="l00028"></a>00028   <a class="code" href="classRecentAlbums.html#cd530b6a335dfb33daed5d84eb148e8c">albumLocations</a>.clear();
<a name="l00029"></a>00029   <a class="code" href="classRecentAlbums.html#6c5670926bda752b6133634c9b4fb563">albumPhotoCounts</a>.clear();
<a name="l00030"></a>00030 }
<a name="l00031"></a>00031 <span class="comment">//==============================================</span>
<a name="l00032"></a><a class="code" href="classRecentAlbums.html#9317f48a9b255a663f8581dccd7871a1">00032</a> <span class="keywordtype">int</span> <a class="code" href="classRecentAlbums.html#9317f48a9b255a663f8581dccd7871a1">RecentAlbums::numEntries</a>()
<a name="l00033"></a>00033 {
<a name="l00034"></a>00034   <span class="keywordflow">return</span> <a class="code" href="classRecentAlbums.html#3a385fc2e0091cdeb81ac006f8c9993f" title="lists of album names and locations">albumNames</a>.count();
<a name="l00035"></a>00035 }
<a name="l00036"></a>00036 <span class="comment">//==============================================</span>
<a name="l00037"></a><a class="code" href="classRecentAlbums.html#294c4ca6e52cf3fd35e259b55d03eab9">00037</a> <span class="keywordtype">int</span> <a class="code" href="classRecentAlbums.html#294c4ca6e52cf3fd35e259b55d03eab9">RecentAlbums::getMaxItems</a>()
<a name="l00038"></a>00038 {
<a name="l00039"></a>00039   <span class="keywordflow">return</span> <a class="code" href="classRecentAlbums.html#9e817f14ffe9a73f810e4a0a0e97498b" title="max allowable items in list">maxItems</a>;
<a name="l00040"></a>00040 }
<a name="l00041"></a>00041 <span class="comment">//==============================================</span>
<a name="l00042"></a><a class="code" href="classRecentAlbums.html#42c965a7ddc3cd255c99489ce08ffd9f">00042</a> <span class="keywordtype">void</span> <a class="code" href="classRecentAlbums.html#42c965a7ddc3cd255c99489ce08ffd9f">RecentAlbums::getEntry</a> ( <span class="keywordtype">int</span> index, QString&amp; name, QString&amp; location, QString&amp; photoCount )
<a name="l00043"></a>00043 {
<a name="l00044"></a>00044   name       = *( <a class="code" href="classRecentAlbums.html#3a385fc2e0091cdeb81ac006f8c9993f" title="lists of album names and locations">albumNames</a>.at       (index) );
<a name="l00045"></a>00045   location   = *( <a class="code" href="classRecentAlbums.html#cd530b6a335dfb33daed5d84eb148e8c">albumLocations</a>.at   (index) );
<a name="l00046"></a>00046   photoCount = *( <a class="code" href="classRecentAlbums.html#6c5670926bda752b6133634c9b4fb563">albumPhotoCounts</a>.at (index) );  
<a name="l00047"></a>00047 }
<a name="l00048"></a>00048 <span class="comment">//==============================================</span>
<a name="l00049"></a><a class="code" href="classRecentAlbums.html#85a976a736d0b794f2469fd5029f495b">00049</a> <span class="keywordtype">void</span> <a class="code" href="classRecentAlbums.html#85a976a736d0b794f2469fd5029f495b">RecentAlbums::insertEntry</a> ( QString name, 
<a name="l00050"></a>00050                                  QString location, 
<a name="l00051"></a>00051                                  QString photos, 
<a name="l00052"></a>00052                                  <span class="keywordtype">bool</span> insertAtBack )
<a name="l00053"></a>00053 {
<a name="l00054"></a>00054   <span class="comment">//items are inserted at back during intialization of list when</span>
<a name="l00055"></a>00055   <span class="comment">//starting up the program. no duplicates should exist so no checking is performed</span>
<a name="l00056"></a>00056   <span class="keywordflow">if</span>(insertAtBack || <a class="code" href="classRecentAlbums.html#3a385fc2e0091cdeb81ac006f8c9993f" title="lists of album names and locations">albumNames</a>.count() == 0)
<a name="l00057"></a>00057   {
<a name="l00058"></a>00058     <a class="code" href="classRecentAlbums.html#3a385fc2e0091cdeb81ac006f8c9993f" title="lists of album names and locations">albumNames</a>.append      ( name     );
<a name="l00059"></a>00059     <a class="code" href="classRecentAlbums.html#cd530b6a335dfb33daed5d84eb148e8c">albumLocations</a>.append  ( location );
<a name="l00060"></a>00060     <a class="code" href="classRecentAlbums.html#6c5670926bda752b6133634c9b4fb563">albumPhotoCounts</a>.append( photos   ); 
<a name="l00061"></a>00061   }
<a name="l00062"></a>00062   <span class="comment">//items are inserted at the front of the list when either:</span>
<a name="l00063"></a>00063   <span class="comment">//1.) a new album is saved or</span>
<a name="l00064"></a>00064   <span class="comment">//2.) an album is opened.</span>
<a name="l00065"></a>00065   <span class="comment">//the list must then be checked for duplicates and any such duplicates should be removed</span>
<a name="l00066"></a>00066   <span class="keywordflow">else</span>
<a name="l00067"></a>00067   {
<a name="l00068"></a>00068     <span class="comment">//prepend item</span>
<a name="l00069"></a>00069     QStringList::Iterator namesIterator       = ++<a class="code" href="classRecentAlbums.html#3a385fc2e0091cdeb81ac006f8c9993f" title="lists of album names and locations">albumNames</a>.prepend       ( name     );
<a name="l00070"></a>00070     QStringList::Iterator locationsIterator   = ++<a class="code" href="classRecentAlbums.html#cd530b6a335dfb33daed5d84eb148e8c">albumLocations</a>.prepend   ( location );
<a name="l00071"></a>00071     QStringList::Iterator photoCountsIterator = ++<a class="code" href="classRecentAlbums.html#6c5670926bda752b6133634c9b4fb563">albumPhotoCounts</a>.prepend ( photos   );
<a name="l00072"></a>00072 
<a name="l00073"></a>00073     <span class="comment">//search list for dupes</span>
<a name="l00074"></a>00074     <span class="keywordflow">while</span>( <span class="keyword">true</span> )
<a name="l00075"></a>00075     {
<a name="l00076"></a>00076       <span class="comment">//if location matches remove item</span>
<a name="l00077"></a>00077       <span class="keywordflow">if</span>( location.compare(*locationsIterator) == 0 )
<a name="l00078"></a>00078       {
<a name="l00079"></a>00079         <a class="code" href="classRecentAlbums.html#3a385fc2e0091cdeb81ac006f8c9993f" title="lists of album names and locations">albumNames</a>.remove      ( namesIterator       );
<a name="l00080"></a>00080         <a class="code" href="classRecentAlbums.html#cd530b6a335dfb33daed5d84eb148e8c">albumLocations</a>.remove  ( locationsIterator   );
<a name="l00081"></a>00081         <a class="code" href="classRecentAlbums.html#6c5670926bda752b6133634c9b4fb563">albumPhotoCounts</a>.remove( photoCountsIterator );
<a name="l00082"></a>00082         <span class="keywordflow">break</span>;
<a name="l00083"></a>00083       }
<a name="l00084"></a>00084 
<a name="l00085"></a>00085       <span class="comment">//end of list? stop</span>
<a name="l00086"></a>00086       <span class="keywordflow">if</span>( namesIterator == <a class="code" href="classRecentAlbums.html#3a385fc2e0091cdeb81ac006f8c9993f" title="lists of album names and locations">albumNames</a>.end() ) <span class="keywordflow">break</span>;
<a name="l00087"></a>00087       
<a name="l00088"></a>00088       <span class="comment">//move to next item.</span>
<a name="l00089"></a>00089       namesIterator++;
<a name="l00090"></a>00090       locationsIterator++;
<a name="l00091"></a>00091       photoCountsIterator++; 
<a name="l00092"></a>00092     }
<a name="l00093"></a>00093 
<a name="l00094"></a>00094   }<span class="comment">//end else</span>
<a name="l00095"></a>00095 
<a name="l00096"></a>00096   <span class="comment">//truncate list as necessary</span>
<a name="l00097"></a>00097   <span class="keywordflow">while</span>(<a class="code" href="classRecentAlbums.html#3a385fc2e0091cdeb81ac006f8c9993f" title="lists of album names and locations">albumNames</a>.count() &gt; <a class="code" href="classRecentAlbums.html#9e817f14ffe9a73f810e4a0a0e97498b" title="max allowable items in list">maxItems</a> )
<a name="l00098"></a>00098   {
<a name="l00099"></a>00099     <a class="code" href="classRecentAlbums.html#3a385fc2e0091cdeb81ac006f8c9993f" title="lists of album names and locations">albumNames</a>.remove( <a class="code" href="classRecentAlbums.html#3a385fc2e0091cdeb81ac006f8c9993f" title="lists of album names and locations">albumNames</a>.last() );
<a name="l00100"></a>00100     <a class="code" href="classRecentAlbums.html#cd530b6a335dfb33daed5d84eb148e8c">albumLocations</a>.remove( <a class="code" href="classRecentAlbums.html#cd530b6a335dfb33daed5d84eb148e8c">albumLocations</a>.last() );
<a name="l00101"></a>00101     <a class="code" href="classRecentAlbums.html#6c5670926bda752b6133634c9b4fb563">albumPhotoCounts</a>.remove( <a class="code" href="classRecentAlbums.html#6c5670926bda752b6133634c9b4fb563">albumPhotoCounts</a>.last() );
<a name="l00102"></a>00102   }  
<a name="l00103"></a>00103 }
<a name="l00104"></a>00104 <span class="comment">//==============================================</span>
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Generated on Sun Aug 23 02:34:27 2009 for AlbumShaper by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.9 </small></address>
</body>
</html>