Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

maillist.cpp

Go to the documentation of this file.
00001 /**********************************************************************
00002 ** Copyright (C) 2001 Trolltech AS.  All rights reserved.
00003 **
00004 ** This file is part of Qt Palmtop Environment.
00005 **
00006 ** This file may be distributed and/or modified under the terms of the
00007 ** GNU General Public License version 2 as published by the Free Software
00008 ** Foundation and appearing in the file LICENSE.GPL included in the
00009 ** packaging of this file.
00010 **
00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 **
00014 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00015 **
00016 ** Contact info@trolltech.com if any conditions of this licensing are
00017 ** not clear to you.
00018 **
00019 **********************************************************************/
00020 #include "maillist.h"
00021 
00022 void MailList::clear()
00023 {
00024   sortedList.setAutoDelete(TRUE);
00025   sortedList.clear();
00026   currentPos = 0;
00027 }
00028 
00029 int MailList::count()
00030 {
00031   return sortedList.count();
00032 }
00033 
00034 int* MailList::first()
00035 {
00036   dList *mPtr;
00037   
00038   if (sortedList.count() == 0)
00039     return NULL;
00040     
00041   mPtr = sortedList.at(0);
00042   currentPos = 1;
00043   return &(mPtr->serverId);
00044 }
00045 
00046 int* MailList::next()
00047 {
00048   dList *mPtr;
00049   
00050   if ( (currentPos) >= sortedList.count())
00051     return NULL;
00052   
00053   mPtr = sortedList.at(currentPos);
00054   currentPos++;
00055   return &(mPtr->serverId);
00056 }
00057 
00058 void MailList::sizeInsert(int serverId, uint size)
00059 {
00060   dList *tempPtr;
00061   int x;
00062   
00063   dList *newEntry = new dList;
00064   newEntry->serverId = serverId;
00065   newEntry->size = size;
00066   
00067   for (tempPtr = sortedList.first(); tempPtr != NULL; tempPtr = sortedList.next() ) {
00068     if (newEntry->size < tempPtr->size) {
00069       x = sortedList.at();
00070       sortedList.insert(x, newEntry);
00071       return;
00072     }
00073   }
00074   sortedList.append(newEntry);
00075 }
00076 
00077 void MailList::moveFront(int serverId, uint/* size*/)
00078 {
00079   dList *currentPtr;
00080   uint tempPos;
00081   QString temp;
00082   
00083   tempPos = currentPos;
00084   if ( tempPos >= sortedList.count() )
00085     return;
00086   currentPtr = sortedList.at(tempPos);
00087   while ( ((tempPos+1) < sortedList.count()) && ( currentPtr->serverId != serverId) ) {
00088     tempPos++;
00089     currentPtr = sortedList.at(tempPos);
00090   }
00091   
00092   if ( (currentPtr != NULL) && (currentPtr->serverId == serverId) ) {
00093     temp.setNum(currentPtr->serverId);
00094     qWarning("moved to front, message: " + temp);
00095     
00096     dList *itemPtr = sortedList.take(tempPos);
00097     sortedList.insert(currentPos, itemPtr);
00098   }
00099 
00100 }
00101 
00102 //only works if mail is not already in download
00103 bool MailList::remove(int serverId, uint /*size*/)
00104 {
00105   dList *currentPtr;
00106   uint tempPos;
00107   QString temp;
00108   
00109   tempPos = currentPos;
00110   if ( tempPos >=sortedList.count() )
00111     return FALSE;
00112   currentPtr = sortedList.at(tempPos);
00113   while ( ((tempPos + 1) < sortedList.count()) && ( currentPtr->serverId != serverId) ) {
00114     tempPos++;
00115     currentPtr = sortedList.at(tempPos);
00116   }
00117   
00118   if ( (currentPtr != NULL) && (currentPtr->serverId == serverId) ) {
00119     temp.setNum(currentPtr->serverId);
00120     qWarning("deleted message: " + temp);
00121     sortedList.remove(tempPos);
00122     
00123     return TRUE;
00124   }
00125   return FALSE;
00126 }
00127 
00128 void MailList::insert(int /*pos*/, int /*serverId*/, uint/* size*/)
00129 {
00130 //  sortedList.insert(pos, mPtr);
00131 }

Generated on Sat Nov 5 16:18:09 2005 for OPIE by  doxygen 1.4.2