kpilot/lib
pilotDatabase.cc00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include "options.h"
00033
00034 #include <time.h>
00035 #include <pi-appinfo.h>
00036
00037 #include <qstringlist.h>
00038
00039 #include <kglobal.h>
00040
00041 #include "pilotDatabase.h"
00042 #include "pilotRecord.h"
00043
00044 static int creationCount = 0;
00045 static QStringList *createdNames = 0L;
00046
00047 PilotDatabase::PilotDatabase(const QString &s) :
00048 fDBOpen(false),
00049 fName(s)
00050 {
00051 FUNCTIONSETUP;
00052 creationCount++;
00053 if (!createdNames)
00054 {
00055 createdNames = new QStringList();
00056 }
00057 createdNames->append(s.isEmpty() ? CSL1("<empty>") : s);
00058 }
00059
00060 PilotDatabase::~PilotDatabase()
00061 {
00062 FUNCTIONSETUP;
00063 creationCount--;
00064 if (createdNames)
00065 {
00066 createdNames->remove(fName.isEmpty() ? CSL1("<empty>") : fName);
00067 }
00068 }
00069
00070 int PilotDatabase::count()
00071 {
00072 FUNCTIONSETUP;
00073 #ifdef DEBUG
00074 DEBUGLIBRARY << fname << ": " << creationCount << " databases." << endl;
00075 if (createdNames)
00076 {
00077 DEBUGLIBRARY << fname << ": "
00078 << createdNames->join(CSL1(",")) << endl;
00079 }
00080 #endif
00081 return creationCount;
00082 }
00083
00084 Pilot::RecordIDList PilotDatabase::idList()
00085 {
00086 Pilot::RecordIDList l;
00087
00088 for (unsigned int i = 0 ; ; i++)
00089 {
00090 PilotRecord *r = readRecordByIndex(i);
00091 if (!r) break;
00092 l.append(r->id());
00093 delete r;
00094 }
00095
00096 return l;
00097 }
00098
00099 Pilot::RecordIDList PilotDatabase::modifiedIDList()
00100 {
00101 Pilot::RecordIDList l;
00102
00103 resetDBIndex();
00104 while(1)
00105 {
00106 PilotRecord *r = readNextModifiedRec();
00107 if (!r) break;
00108 l.append(r->id());
00109 delete r;
00110 }
00111
00112 return l;
00113 }
00114
|