author | llornkcor <llornkcor> | 2002-03-09 20:00:31 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-03-09 20:00:31 (UTC) |
commit | 767f33638631d29bca260aab66c1224ab2108af7 (patch) (unidiff) | |
tree | e8c66841e18a4f106e0650e1e29d21e706bcef14 /noncore/apps/tableviewer/db/common.cpp | |
parent | 3095bf47c523afcf5441057db23050767f69ebf9 (diff) | |
download | opie-767f33638631d29bca260aab66c1224ab2108af7.zip opie-767f33638631d29bca260aab66c1224ab2108af7.tar.gz opie-767f33638631d29bca260aab66c1224ab2108af7.tar.bz2 |
got tableviewer compiling to find out what the heck it is- and I still can't tell
Diffstat (limited to 'noncore/apps/tableviewer/db/common.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/tableviewer/db/common.cpp | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/noncore/apps/tableviewer/db/common.cpp b/noncore/apps/tableviewer/db/common.cpp index 4c70e54..71844a5 100644 --- a/noncore/apps/tableviewer/db/common.cpp +++ b/noncore/apps/tableviewer/db/common.cpp | |||
@@ -13,25 +13,25 @@ | |||
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
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 | #include <stdlib.h> | 20 | #include <stdlib.h> |
21 | #include <qstring.h> | 21 | #include <qstring.h> |
22 | #include <qheader.h> | 22 | #include <qheader.h> |
23 | #include <qvector.h> | 23 | #include <qvector.h> |
24 | #include <qdatetime.h> | 24 | #include <qdatetime.h> |
25 | #include <timestring.h> | 25 | #include <qpe/timestring.h> |
26 | #include "common.h" | 26 | #include "common.h" |
27 | #include "datacache.h" | 27 | #include "datacache.h" |
28 | #include <assert.h> | 28 | #include <assert.h> |
29 | 29 | ||
30 | static const int del_flag = 0x1; | 30 | static const int del_flag = 0x1; |
31 | static const int new_flag = 0x2; | 31 | static const int new_flag = 0x2; |
32 | 32 | ||
33 | /* Helper function */ | 33 | /* Helper function */ |
34 | 34 | ||
35 | int parseNextNumber(QString *q) { | 35 | int parseNextNumber(QString *q) { |
36 | QChar c; | 36 | QChar c; |
37 | uint i; | 37 | uint i; |
@@ -301,27 +301,27 @@ void TVVariant::load(QDataStream &s ) | |||
301 | { | 301 | { |
302 | QDate *x = new QDate; | 302 | QDate *x = new QDate; |
303 | s >> *x; | 303 | s >> *x; |
304 | d->value.ptr = x; | 304 | d->value.ptr = x; |
305 | } | 305 | } |
306 | break; | 306 | break; |
307 | case Int: | 307 | case Int: |
308 | { | 308 | { |
309 | int x; | 309 | int x; |
310 | s >> x; | 310 | s >> x; |
311 | d->value.i = x; | 311 | d->value.i = x; |
312 | } | 312 | } |
313 | break; | 313 | break; |
314 | default: | 314 | default: |
315 | qFatal("Unrecognized data type"); | 315 | qFatal("Unrecognized data type"); |
316 | } | 316 | } |
317 | } | 317 | } |
318 | 318 | ||
319 | void TVVariant::save( QDataStream &s ) const | 319 | void TVVariant::save( QDataStream &s ) const |
320 | { | 320 | { |
321 | s << type(); | 321 | s << type(); |
322 | 322 | ||
323 | switch( d->typ ) { | 323 | switch( d->typ ) { |
324 | case String: | 324 | case String: |
325 | s << *((QString *)d->value.ptr); | 325 | s << *((QString *)d->value.ptr); |
326 | break; | 326 | break; |
327 | case Date: | 327 | case Date: |
@@ -381,25 +381,25 @@ const QString TVVariant::toString() const | |||
381 | return QString::null; | 381 | return QString::null; |
382 | } | 382 | } |
383 | return QString::null; | 383 | return QString::null; |
384 | } | 384 | } |
385 | 385 | ||
386 | // TODO DO, this properly, */ | 386 | // TODO DO, this properly, */ |
387 | int TVVariant::toInt() const | 387 | int TVVariant::toInt() const |
388 | { | 388 | { |
389 | if(d->typ == Int) | 389 | if(d->typ == Int) |
390 | return d->value.i; | 390 | return d->value.i; |
391 | 391 | ||
392 | if(d->typ == String) { | 392 | if(d->typ == String) { |
393 | QString tmpq(*(QString *)d->value.ptr); | 393 | QString tmpq(*(QString *)d->value.ptr); |
394 | return parseNextNumber(&tmpq); | 394 | return parseNextNumber(&tmpq); |
395 | } | 395 | } |
396 | 396 | ||
397 | return 0; | 397 | return 0; |
398 | } | 398 | } |
399 | 399 | ||
400 | const QDate TVVariant::toDate() const | 400 | const QDate TVVariant::toDate() const |
401 | { | 401 | { |
402 | if(d->typ == Date) | 402 | if(d->typ == Date) |
403 | return *((QDate *)d->value.ptr); | 403 | return *((QDate *)d->value.ptr); |
404 | 404 | ||
405 | if(d->typ == String) { | 405 | if(d->typ == String) { |
@@ -675,27 +675,27 @@ bool TVVariant::close(TVVariant n) | |||
675 | \brief document me! | 675 | \brief document me! |
676 | 676 | ||
677 | document me! | 677 | document me! |
678 | */ | 678 | */ |
679 | 679 | ||
680 | Key::Key() : kname(), kexample(), kflags(0) { } | 680 | Key::Key() : kname(), kexample(), kflags(0) { } |
681 | 681 | ||
682 | Key::Key(QString name, TVVariant example, int flags = 0) : | 682 | Key::Key(QString name, TVVariant example, int flags = 0) : |
683 | kname(name), kexample(example), kflags(flags) { } | 683 | kname(name), kexample(example), kflags(flags) { } |
684 | 684 | ||
685 | Key::Key(const Key &other) | 685 | Key::Key(const Key &other) |
686 | { | 686 | { |
687 | kname = other.kname; | 687 | kname = other.kname; |
688 | kexample = other.kexample; | 688 | kexample = other.kexample; |
689 | kflags = other.kflags; | 689 | kflags = other.kflags; |
690 | } | 690 | } |
691 | 691 | ||
692 | Key& Key::operator=(const Key& key) | 692 | Key& Key::operator=(const Key& key) |
693 | { | 693 | { |
694 | kname = key.kname; | 694 | kname = key.kname; |
695 | kexample = key.kexample; | 695 | kexample = key.kexample; |
696 | kflags = key.kflags; | 696 | kflags = key.kflags; |
697 | return *this; | 697 | return *this; |
698 | } | 698 | } |
699 | 699 | ||
700 | QString Key::name() const | 700 | QString Key::name() const |
701 | { | 701 | { |
@@ -769,53 +769,53 @@ void Key::setNewFlag(bool v) | |||
769 | /*! | 769 | /*! |
770 | Constructs a KeyList | 770 | Constructs a KeyList |
771 | */ | 771 | */ |
772 | KeyList::KeyList() : QIntDict<Key>(20) | 772 | KeyList::KeyList() : QIntDict<Key>(20) |
773 | { | 773 | { |
774 | setAutoDelete(TRUE); | 774 | setAutoDelete(TRUE); |
775 | } | 775 | } |
776 | 776 | ||
777 | /* Should be deep copy, but isn't */ | 777 | /* Should be deep copy, but isn't */ |
778 | KeyList::KeyList(const KeyList &k) : QIntDict<Key>(k) | 778 | KeyList::KeyList(const KeyList &k) : QIntDict<Key>(k) |
779 | { | 779 | { |
780 | KeyListIterator it(k); | 780 | KeyListIterator it(k); |
781 | while(it.current()) { | 781 | while(it.current()) { |
782 | replace(it.currentKey(), new Key(*it.current())); | 782 | replace(it.currentKey(), new Key(*it.current())); |
783 | ++it; | 783 | ++it; |
784 | } | 784 | } |
785 | 785 | ||
786 | setAutoDelete(TRUE); | 786 | setAutoDelete(TRUE); |
787 | } | 787 | } |
788 | 788 | ||
789 | /*! | 789 | /*! |
790 | Destroys a KeyList | 790 | Destroys a KeyList |
791 | */ | 791 | */ |
792 | KeyList::~KeyList() { | 792 | KeyList::~KeyList() { |
793 | } | 793 | } |
794 | 794 | ||
795 | /* Do a comparision base on Keys */ | 795 | /* Do a comparision base on Keys */ |
796 | bool KeyList::operator!=(const KeyList &other) | 796 | bool KeyList::operator!=(const KeyList &other) |
797 | { | 797 | { |
798 | KeyListIterator it(*this); | 798 | KeyListIterator it(*this); |
799 | 799 | ||
800 | if (other.getNumFields() != getNumFields()) | 800 | if (other.getNumFields() != getNumFields()) |
801 | return TRUE; | 801 | return TRUE; |
802 | 802 | ||
803 | while(it.current()) { | 803 | while(it.current()) { |
804 | //it.currentKey(), it.current(); | 804 | //it.currentKey(), it.current(); |
805 | if (other.getKeyName(it.currentKey()) != getKeyName(it.currentKey())) | 805 | if (other.getKeyName(it.currentKey()) != getKeyName(it.currentKey())) |
806 | return TRUE; | 806 | return TRUE; |
807 | if (other.getKeyType(it.currentKey()) != getKeyType(it.currentKey())) | 807 | if (other.getKeyType(it.currentKey()) != getKeyType(it.currentKey())) |
808 | return TRUE; | 808 | return TRUE; |
809 | ++it; | 809 | ++it; |
810 | } | 810 | } |
811 | return FALSE; | 811 | return FALSE; |
812 | } | 812 | } |
813 | 813 | ||
814 | /*! | 814 | /*! |
815 | Returns the number of keys stored in the KeyList | 815 | Returns the number of keys stored in the KeyList |
816 | */ | 816 | */ |
817 | int KeyList::getNumFields() const | 817 | int KeyList::getNumFields() const |
818 | { | 818 | { |
819 | return count(); | 819 | return count(); |
820 | } | 820 | } |
821 | 821 | ||
@@ -1173,25 +1173,25 @@ TVVariant DataElem::getField(QString qs) const | |||
1173 | */ | 1173 | */ |
1174 | void DataElem::setField(int i, QString q) | 1174 | void DataElem::setField(int i, QString q) |
1175 | { | 1175 | { |
1176 | /* from the type of the field, parse q and store */ | 1176 | /* from the type of the field, parse q and store */ |
1177 | TVVariant::KeyType kt = contained->getKeyType(i); | 1177 | TVVariant::KeyType kt = contained->getKeyType(i); |
1178 | 1178 | ||
1179 | TVVariant t = TVVariant(q); | 1179 | TVVariant t = TVVariant(q); |
1180 | 1180 | ||
1181 | switch(kt) { | 1181 | switch(kt) { |
1182 | case TVVariant::Int: { | 1182 | case TVVariant::Int: { |
1183 | t.asInt(); | 1183 | t.asInt(); |
1184 | setField(i, t); | 1184 | setField(i, t); |
1185 | return; | 1185 | return; |
1186 | } | 1186 | } |
1187 | case TVVariant::String: { | 1187 | case TVVariant::String: { |
1188 | t.asString(); | 1188 | t.asString(); |
1189 | setField(i, t); | 1189 | setField(i, t); |
1190 | return; | 1190 | return; |
1191 | } | 1191 | } |
1192 | case TVVariant::Date: { | 1192 | case TVVariant::Date: { |
1193 | t.asDate(); | 1193 | t.asDate(); |
1194 | setField(i, t); | 1194 | setField(i, t); |
1195 | return; | 1195 | return; |
1196 | } | 1196 | } |
1197 | case TVVariant::Time: { | 1197 | case TVVariant::Time: { |
@@ -1261,25 +1261,25 @@ void DataElem::unsetField(QString qs) | |||
1261 | /*! | 1261 | /*! |
1262 | Converts the data element to a Rich Text QString | 1262 | Converts the data element to a Rich Text QString |
1263 | */ | 1263 | */ |
1264 | QString DataElem::toQString() const | 1264 | QString DataElem::toQString() const |
1265 | { | 1265 | { |
1266 | /* lets make an attempt at this function */ | 1266 | /* lets make an attempt at this function */ |
1267 | int i; | 1267 | int i; |
1268 | QString scratch = ""; | 1268 | QString scratch = ""; |
1269 | 1269 | ||
1270 | QIntDictIterator<TVVariant> it(values); | 1270 | QIntDictIterator<TVVariant> it(values); |
1271 | 1271 | ||
1272 | while (it.current()) { | 1272 | while (it.current()) { |
1273 | i = it.currentKey(); | 1273 | i = it.currentKey(); |
1274 | if(hasValidValue(i)) { | 1274 | if(hasValidValue(i)) { |
1275 | scratch += "<B>" + contained->getKeyName(i) + ":</B> "; | 1275 | scratch += "<B>" + contained->getKeyName(i) + ":</B> "; |
1276 | scratch += getField(i).toString(); | 1276 | scratch += getField(i).toString(); |
1277 | scratch += "<br>"; | 1277 | scratch += "<br>"; |
1278 | } | 1278 | } |
1279 | ++it; | 1279 | ++it; |
1280 | } | 1280 | } |
1281 | return scratch; | 1281 | return scratch; |
1282 | } | 1282 | } |
1283 | 1283 | ||
1284 | /*! formats individual fields to strings so can be displayed */ | 1284 | /*! formats individual fields to strings so can be displayed */ |
1285 | QString DataElem::toQString(int i) const | 1285 | QString DataElem::toQString(int i) const |