summaryrefslogtreecommitdiff
path: root/noncore/apps/tableviewer/db/datacache.cpp
authorar <ar>2004-05-31 15:26:50 (UTC)
committer ar <ar>2004-05-31 15:26:50 (UTC)
commit27dfc34d411dee76f09f5e516c60b0a64eb35948 (patch) (unidiff)
treeb7f7259497630390e352a1257cac5dc59f5399a6 /noncore/apps/tableviewer/db/datacache.cpp
parent27b09fe4f930b96e82cea9fb0eb1a9b87f7ec062 (diff)
downloadopie-27dfc34d411dee76f09f5e516c60b0a64eb35948.zip
opie-27dfc34d411dee76f09f5e516c60b0a64eb35948.tar.gz
opie-27dfc34d411dee76f09f5e516c60b0a64eb35948.tar.bz2
- convert qWarning to owarn
Diffstat (limited to 'noncore/apps/tableviewer/db/datacache.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/tableviewer/db/datacache.cpp68
1 files changed, 34 insertions, 34 deletions
diff --git a/noncore/apps/tableviewer/db/datacache.cpp b/noncore/apps/tableviewer/db/datacache.cpp
index 6380e1b..de57961 100644
--- a/noncore/apps/tableviewer/db/datacache.cpp
+++ b/noncore/apps/tableviewer/db/datacache.cpp
@@ -16,7 +16,7 @@
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20/* 20/*
21 * This file is used to load the xml files that represent the database. 21 * This file is used to load the xml files that represent the database.
22 * The main requirment for said file is each data entry must contain a key, 22 * The main requirment for said file is each data entry must contain a key,
@@ -63,10 +63,10 @@ DBStore::DBStore()
63 archive = 0; 63 archive = 0;
64} 64}
65 65
66//TODO 66//TODO
67/*! 67/*!
68 Reinitializes the table to empty (include a resize of the master table, 68 Reinitializes the table to empty (include a resize of the master table,
69 which should free some memory) 69 which should free some memory)
70*/ 70*/
71void DBStore::freeTable() 71void DBStore::freeTable()
72{ 72{
@@ -93,7 +93,7 @@ DBStore::~DBStore()
93} 93}
94 94
95/*! 95/*!
96 This function opens the given xml file, loads it and sets up the 96 This function opens the given xml file, loads it and sets up the
97 appropriate data structures. 97 appropriate data structures.
98 98
99 \param file_name A string representing the name of the file to be opened 99 \param file_name A string representing the name of the file to be opened
@@ -101,7 +101,7 @@ DBStore::~DBStore()
101*/ 101*/
102bool DBStore::openSource(QIODevice *inDev, const QString &source) { 102bool DBStore::openSource(QIODevice *inDev, const QString &source) {
103 103
104 /* first check if db is already open, if contains data.. then clear */ 104 /* first check if db is already open, if contains data.. then clear */
105 if(number_elems > 0) { 105 if(number_elems > 0) {
106 freeTable(); 106 freeTable();
107 } 107 }
@@ -109,23 +109,23 @@ bool DBStore::openSource(QIODevice *inDev, const QString &source) {
109 if (source == "text/x-xml-tableviewer") { 109 if (source == "text/x-xml-tableviewer") {
110 archive = new DBXml(this); 110 archive = new DBXml(this);
111 } else if (source == "text/csv") { 111 } else if (source == "text/csv") {
112 archive = new DBCsv(this); 112 archive = new DBCsv(this);
113 } else 113 } else
114 return false; 114 return false;
115 115
116 return (archive->openSource(inDev)); 116 return (archive->openSource(inDev));
117} 117}
118 118
119bool DBStore::saveSource(QIODevice *outDev, const QString &source) 119bool DBStore::saveSource(QIODevice *outDev, const QString &source)
120{ 120{
121 /* saving a new file */ 121 /* saving a new file */
122 if(!archive) { 122 if(!archive) {
123 if (source == "text/x-xml-tableviewer") { 123 if (source == "text/x-xml-tableviewer") {
124 archive = new DBXml(this); 124 archive = new DBXml(this);
125 } else if (source == "text/x-xml-tableviewer") { 125 } else if (source == "text/x-xml-tableviewer") {
126 archive = new DBCsv(this); 126 archive = new DBCsv(this);
127 } else 127 } else
128 return false; 128 return false;
129 } 129 }
130 130
131 /* changing file type */ 131 /* changing file type */
@@ -133,16 +133,16 @@ bool DBStore::saveSource(QIODevice *outDev, const QString &source)
133 delete archive; 133 delete archive;
134 if (source == "text/x-xml-tableviewer") { 134 if (source == "text/x-xml-tableviewer") {
135 archive = new DBXml(this); 135 archive = new DBXml(this);
136 } else if (source == "text/x-xml-tableviewer") { 136 } else if (source == "text/x-xml-tableviewer") {
137 archive = new DBCsv(this); 137 archive = new DBCsv(this);
138 } else 138 } else
139 return false; 139 return false;
140 } 140 }
141 141
142 return (archive->saveSource(outDev)); 142 return (archive->saveSource(outDev));
143} 143}
144 144
145/*! 145/*!
146 This function is used to add new elements to the database. If the database 146 This function is used to add new elements to the database. If the database
147 has already reached the maximum allowable size this function does not alter 147 has already reached the maximum allowable size this function does not alter
148 the database. 148 the database.
@@ -156,9 +156,9 @@ void DBStore::addItem(DataElem *delem)
156 156
157void DBStore::addItemInternal(DataElem *delem) 157void DBStore::addItemInternal(DataElem *delem)
158{ 158{
159 /* if already full, don't over fill, do a qWarning though */ 159 /* if already full, don't over fill, do a owarn though */
160 if (full) { 160 if (full) {
161 owarn << "Attempted to add items to already full table" << oendl; 161 owarn << "Attempted to add items to already full table" << oendl;
162 return; 162 return;
163 } 163 }
164 164
@@ -185,13 +185,13 @@ void DBStore::addItemInternal(DataElem *delem)
185void DBStore::removeItem(DataElem *r) 185void DBStore::removeItem(DataElem *r)
186{ 186{
187 int position = master_table.findRef(r); 187 int position = master_table.findRef(r);
188 if(position != -1) { 188 if(position != -1) {
189 /* there is at least one item, this is it */ 189 /* there is at least one item, this is it */
190 /* replace this with the last element, decrease the element count */ 190 /* replace this with the last element, decrease the element count */
191 master_table.insert(position, master_table.at(--number_elems)); 191 master_table.insert(position, master_table.at(--number_elems));
192 master_table.remove(number_elems); 192 master_table.remove(number_elems);
193 delete r; 193 delete r;
194 } 194 }
195} 195}
196 196
197/*! 197/*!
@@ -201,7 +201,7 @@ void DBStore::removeItem(DataElem *r)
201*/ 201*/
202void DBStore::setName(const QString &n) 202void DBStore::setName(const QString &n)
203{ 203{
204 name = n; 204 name = n;
205} 205}
206 206
207/*! 207/*!
@@ -211,11 +211,11 @@ void DBStore::setName(const QString &n)
211*/ 211*/
212QString DBStore::getName() 212QString DBStore::getName()
213{ 213{
214 return name; 214 return name;
215} 215}
216 216
217/*! 217/*!
218 Retrieves a pointer to the key representation of the database for 218 Retrieves a pointer to the key representation of the database for
219 other classes to use as reference. 219 other classes to use as reference.
220 220
221 \return a pointer to the databases key representaion 221 \return a pointer to the databases key representaion
@@ -235,7 +235,7 @@ void DBStore::setKeys(KeyList *k)
235} 235}
236 236
237/*! 237/*!
238 Sets the current element to the first element of the database 238 Sets the current element to the first element of the database
239*/ 239*/
240void DBStore::first() 240void DBStore::first()
241{ 241{
@@ -243,7 +243,7 @@ void DBStore::first()
243} 243}
244 244
245/*! 245/*!
246 Sets the current element to the last element of the database 246 Sets the current element to the last element of the database
247*/ 247*/
248void DBStore::last() 248void DBStore::last()
249{ 249{
@@ -257,7 +257,7 @@ void DBStore::last()
257bool DBStore::next() 257bool DBStore::next()
258{ 258{
259 unsigned int new_current_elem = current_elem + 1; 259 unsigned int new_current_elem = current_elem + 1;
260 if (current_elem < number_elems) 260 if (current_elem < number_elems)
261 /* was valid before inc (it is possible but unlikely that inc current 261 /* was valid before inc (it is possible but unlikely that inc current
262 elem will change it from invalid to valid) */ 262 elem will change it from invalid to valid) */
263 if (new_current_elem < number_elems) { 263 if (new_current_elem < number_elems) {
@@ -278,7 +278,7 @@ bool DBStore::previous()
278 if (current_elem < number_elems) 278 if (current_elem < number_elems)
279 /* was valid */ 279 /* was valid */
280 if (new_current_elem < number_elems) { 280 if (new_current_elem < number_elems) {
281 /* still is (if was 0, then now -1, but as is unsigned will wrap 281 /* still is (if was 0, then now -1, but as is unsigned will wrap
282 and hence be invalid */ 282 and hence be invalid */
283 current_elem = new_current_elem; 283 current_elem = new_current_elem;
284 return true; 284 return true;
@@ -288,14 +288,14 @@ bool DBStore::previous()
288 288
289/*! 289/*!
290 Returns the current data element in the database. Which element is current 290 Returns the current data element in the database. Which element is current
291 is affected by newly added items, findItem, next, previous, first and 291 is affected by newly added items, findItem, next, previous, first and
292 last functions 292 last functions
293 293
294 \return a pointer to the current data element 294 \return a pointer to the current data element
295*/ 295*/
296DataElem *DBStore::getCurrentData() 296DataElem *DBStore::getCurrentData()
297{ 297{
298 if (current_elem >= number_elems) 298 if (current_elem >= number_elems)
299 return NULL; 299 return NULL;
300 return master_table[current_elem]; 300 return master_table[current_elem];
301} 301}