author | llornkcor <llornkcor> | 2002-03-09 20:00:31 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-03-09 20:00:31 (UTC) |
commit | 767f33638631d29bca260aab66c1224ab2108af7 (patch) (side-by-side diff) | |
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 @@ -1,49 +1,49 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include <stdlib.h> #include <qstring.h> #include <qheader.h> #include <qvector.h> #include <qdatetime.h> -#include <timestring.h> +#include <qpe/timestring.h> #include "common.h" #include "datacache.h" #include <assert.h> static const int del_flag = 0x1; static const int new_flag = 0x2; /* Helper function */ int parseNextNumber(QString *q) { QChar c; uint i; int result = 0; bool found_digits = FALSE; for(i = 0; i < q->length(); i++) { c = q->at(i); if (c.isDigit()) { if (found_digits) result *= 10; found_digits = TRUE; result += c.digitValue(); } else { if (found_digits) @@ -289,51 +289,51 @@ void TVVariant::load(QDataStream &s ) s >> *x; d->value.ptr = x; } break; case Time: { QTime *x = new QTime; s >> *x; d->value.ptr = x; } break; case Date: { QDate *x = new QDate; s >> *x; d->value.ptr = x; } break; case Int: { int x; s >> x; d->value.i = x; } - break; + break; default: - qFatal("Unrecognized data type"); + qFatal("Unrecognized data type"); } } void TVVariant::save( QDataStream &s ) const { s << type(); switch( d->typ ) { case String: s << *((QString *)d->value.ptr); break; case Date: s << *((QDate *)d->value.ptr); break; case Time: s << *((QTime *)d->value.ptr); break; case Int: s << d->value.i; break; case Invalid: break; } } @@ -369,49 +369,49 @@ const QString TVVariant::toString() const { switch(d->typ) { case String: return *((QString*)d->value.ptr); case Date: return ((QDate*)d->value.ptr)->toString(); case Time: return ((QTime*)d->value.ptr)->toString(); case Int: return QString::number(d->value.i); case Invalid: default: return QString::null; } return QString::null; } // TODO DO, this properly, */ int TVVariant::toInt() const { if(d->typ == Int) return d->value.i; if(d->typ == String) { - QString tmpq(*(QString *)d->value.ptr); + QString tmpq(*(QString *)d->value.ptr); return parseNextNumber(&tmpq); } return 0; } const QDate TVVariant::toDate() const { if(d->typ == Date) return *((QDate *)d->value.ptr); if(d->typ == String) { QString q = toString(); /* date format is day mon d yyyy */ /* ignore the first three letters, read the next three for month.. etc */ int day = parseNextNumber(&q); int month = parseNextNumber(&q); int year = parseNextNumber(&q); if (!QDate::isValid(year, month, day)) return QDate(); return QDate(year, month, day); @@ -663,51 +663,51 @@ bool TVVariant::close(TVVariant n) case Time: return TRUE; default: /* don't know how to do 'closer' on this type, hence never closer * or even close */ break; } return FALSE; } /*! \class Key \brief document me! document me! */ Key::Key() : kname(), kexample(), kflags(0) { } Key::Key(QString name, TVVariant example, int flags = 0) : kname(name), kexample(example), kflags(flags) { } Key::Key(const Key &other) { - kname = other.kname; - kexample = other.kexample; - kflags = other.kflags; + kname = other.kname; + kexample = other.kexample; + kflags = other.kflags; } Key& Key::operator=(const Key& key) { kname = key.kname; kexample = key.kexample; kflags = key.kflags; return *this; } QString Key::name() const { return QString(kname); } TVVariant Key::example() const { return TVVariant(kexample); } TVVariant::KeyType Key::type() const { return kexample.type(); } @@ -757,77 +757,77 @@ void Key::setNewFlag(bool v) if(newFlag() != v) kflags = kflags ^ new_flag; } /*! \class KeyList \brief A represntation of keys used for a table. The KeyList class is used to store the representation of keys used in table headings by DBStore. It stores the names and types of the keys */ /*! Constructs a KeyList */ KeyList::KeyList() : QIntDict<Key>(20) { setAutoDelete(TRUE); } /* Should be deep copy, but isn't */ KeyList::KeyList(const KeyList &k) : QIntDict<Key>(k) { KeyListIterator it(k); - while(it.current()) { - replace(it.currentKey(), new Key(*it.current())); - ++it; - } + while(it.current()) { + replace(it.currentKey(), new Key(*it.current())); + ++it; + } setAutoDelete(TRUE); } /*! Destroys a KeyList */ KeyList::~KeyList() { } /* Do a comparision base on Keys */ bool KeyList::operator!=(const KeyList &other) { KeyListIterator it(*this); if (other.getNumFields() != getNumFields()) - return TRUE; + return TRUE; while(it.current()) { - //it.currentKey(), it.current(); - if (other.getKeyName(it.currentKey()) != getKeyName(it.currentKey())) - return TRUE; - if (other.getKeyType(it.currentKey()) != getKeyType(it.currentKey())) - return TRUE; - ++it; + //it.currentKey(), it.current(); + if (other.getKeyName(it.currentKey()) != getKeyName(it.currentKey())) + return TRUE; + if (other.getKeyType(it.currentKey()) != getKeyType(it.currentKey())) + return TRUE; + ++it; } return FALSE; } /*! Returns the number of keys stored in the KeyList */ int KeyList::getNumFields() const { return count(); } /*! Adds a new key to the KeyList \param name the name of the new key \param type the type of the new key */ int KeyList::addKey(QString name, TVVariant example) { int i = count(); while(find(i) && (i > -1)) i--; replace(i, new Key(name, example, 0)); @@ -1161,49 +1161,49 @@ TVVariant DataElem::getField(int i) const TVVariant DataElem::getField(QString qs) const { int i = contained->getKeyIndex(qs); return getField(i); } /*! Sets the value of the elements field index i to the value represented in the QString q. \param i index of the field to set \param q a string that can be parsed to get the value to be set */ void DataElem::setField(int i, QString q) { /* from the type of the field, parse q and store */ TVVariant::KeyType kt = contained->getKeyType(i); TVVariant t = TVVariant(q); switch(kt) { case TVVariant::Int: { t.asInt(); setField(i, t); - return; + return; } case TVVariant::String: { t.asString(); setField(i, t); return; } case TVVariant::Date: { t.asDate(); setField(i, t); return; } case TVVariant::Time: { t.asTime(); setField(i, t); return; } default: qWarning( QObject::tr("DataElem::setField(%1, %2) No valid type found").arg(i).arg(q) ); } } /*! @@ -1249,49 +1249,49 @@ void DataElem::setField(QString qs, TVVariant value) } void DataElem::unsetField(int i) { values.remove(i); } void DataElem::unsetField(QString qs) { int i = contained->getKeyIndex(qs); unsetField(i); } /*! Converts the data element to a Rich Text QString */ QString DataElem::toQString() const { /* lets make an attempt at this function */ int i; QString scratch = ""; QIntDictIterator<TVVariant> it(values); while (it.current()) { - i = it.currentKey(); + i = it.currentKey(); if(hasValidValue(i)) { scratch += "<B>" + contained->getKeyName(i) + ":</B> "; scratch += getField(i).toString(); scratch += "<br>"; } ++it; } return scratch; } /*! formats individual fields to strings so can be displayed */ QString DataElem::toQString(int i) const { if(hasValidValue(i)) { return getField(i).toString(); } return ""; } /*! formats individual fields to strings so can be sorted by QListView */ QString DataElem::toSortableQString(int i) const { QString scratch = ""; if(hasValidValue(i)) { switch (contained->getKeyType(i)) { |