author | ar <ar> | 2004-05-31 15:26:50 (UTC) |
---|---|---|
committer | ar <ar> | 2004-05-31 15:26:50 (UTC) |
commit | 27dfc34d411dee76f09f5e516c60b0a64eb35948 (patch) (side-by-side diff) | |
tree | b7f7259497630390e352a1257cac5dc59f5399a6 /noncore/apps/tableviewer/db | |
parent | 27b09fe4f930b96e82cea9fb0eb1a9b87f7ec062 (diff) | |
download | opie-27dfc34d411dee76f09f5e516c60b0a64eb35948.zip opie-27dfc34d411dee76f09f5e516c60b0a64eb35948.tar.gz opie-27dfc34d411dee76f09f5e516c60b0a64eb35948.tar.bz2 |
- convert qWarning to owarn
-rw-r--r-- | noncore/apps/tableviewer/db/common.cpp | 165 | ||||
-rw-r--r-- | noncore/apps/tableviewer/db/datacache.cpp | 68 | ||||
-rw-r--r-- | noncore/apps/tableviewer/db/datacache.h | 24 |
3 files changed, 130 insertions, 127 deletions
diff --git a/noncore/apps/tableviewer/db/common.cpp b/noncore/apps/tableviewer/db/common.cpp index b58af85..c35dbea 100644 --- a/noncore/apps/tableviewer/db/common.cpp +++ b/noncore/apps/tableviewer/db/common.cpp @@ -17,6 +17,6 @@ ** not clear to you. ** -**********************************************************************/ -#include "common.h" +**********************************************************************/ +#include "common.h" #include "datacache.h" @@ -89,5 +89,5 @@ int QStringVector::compareItems(Item a, Item b) QString *qa = (QString *)a; QString *qb = (QString *)b; - + return QString::compare(*qa, *qb); } @@ -95,5 +95,5 @@ int QStringVector::compareItems(Item a, Item b) /*! \class TVVariant - A way of abstracting void * and keeping information on + A way of abstracting void * and keeping information on the keytypes and behaviours in one place */ @@ -321,5 +321,5 @@ void TVVariant::load(QDataStream &s ) break; default: - ofatal << "Unrecognized data type" << oendl; + ofatal << "Unrecognized data type" << oendl; } } @@ -383,5 +383,5 @@ const QString TVVariant::toString() const case Time: return ((QTime*)d->value.ptr)->toString(); - case Int: + case Int: return QString::number(d->value.i); case Invalid: @@ -425,5 +425,5 @@ const QDate TVVariant::toDate() const return QDate(year, month, day); } - + return QDate(); @@ -434,5 +434,5 @@ const QTime TVVariant::toTime() const if(d->typ == Time) return *((QTime *)d->value.ptr); - + if(d->typ == String) { QString q = toString(); @@ -455,5 +455,5 @@ const QTime TVVariant::toTime() const detach(); \ return *((Q##f*)d->value.ptr); } - + TV_VARIANT_AS(String) TV_VARIANT_AS(Date) @@ -561,5 +561,5 @@ bool TVVariant::closer(TVVariant n, TVVariant o) /* Nothing is close to an invalid, so nothing can be closer */ if(d->typ == Invalid) - return FALSE; + return FALSE; /* can't be closer if of different type */ @@ -573,5 +573,5 @@ bool TVVariant::closer(TVVariant n, TVVariant o) switch(type()){ case String: { - /* case for strings is close is a substring.. closer is + /* case for strings is close is a substring.. closer is * earlier alphabetically */ QString qs1 = n.toString().lower(); @@ -583,5 +583,5 @@ bool TVVariant::closer(TVVariant n, TVVariant o) /* contains sub-str, if later than is not closer */ - if(QString::compare(qs1, qs2) > 0) + if(QString::compare(qs1, qs2) > 0) return FALSE; return TRUE; @@ -594,11 +594,11 @@ bool TVVariant::closer(TVVariant n, TVVariant o) int diff1 = (i1 - iv); - if (diff1 < 0) + if (diff1 < 0) diff1 = -diff1; int diff2 = (i2 - iv); - if (diff2 < 0) + if (diff2 < 0) diff2 = -diff2; - if (diff1 < diff2) + if (diff1 < diff2) return TRUE; return FALSE; @@ -611,8 +611,8 @@ bool TVVariant::closer(TVVariant n, TVVariant o) /* definition of closer is the least difference in days */ int diff1 = i1.daysTo(iv); - if (diff1 < 0) + if (diff1 < 0) diff1 = -diff1; int diff2 = i2.daysTo(iv); - if (diff2 < 0) + if (diff2 < 0) diff2 = -diff2; @@ -628,8 +628,8 @@ bool TVVariant::closer(TVVariant n, TVVariant o) /* definition of closer is the least difference in days */ int diff1 = i1.msecsTo(iv); - if (diff1 < 0) + if (diff1 < 0) diff1 = -diff1; int diff2 = i2.msecsTo(iv); - if (diff2 < 0) + if (diff2 < 0) diff2 = -diff2; if (diff1 < diff2) @@ -650,5 +650,5 @@ bool TVVariant::close(TVVariant n) /* Nothing is close to an invalid, so nothing can be closer */ if(type() == Invalid) - return FALSE; + return FALSE; /* can't be close if of different type */ @@ -658,5 +658,5 @@ bool TVVariant::close(TVVariant n) switch(type()){ case String: { - /* case for strings is close is a substring.. closer is + /* case for strings is close is a substring.. closer is * earlier alphabetically */ QString qs1 = n.toString().lower(); @@ -667,5 +667,5 @@ bool TVVariant::close(TVVariant n) return TRUE; } - case Int: + case Int: case Date: case Time: @@ -682,5 +682,5 @@ bool TVVariant::close(TVVariant n) \class Key \brief document me! - + document me! */ @@ -689,5 +689,5 @@ Key::Key() : kname(), kexample(), kflags(0) { } Key::Key(QString name, TVVariant example, int flags) : - kname(name), kexample(example), kflags(flags) { } + kname(name), kexample(example), kflags(flags) { } Key::Key(const Key &other) @@ -698,5 +698,5 @@ Key::Key(const Key &other) } -Key& Key::operator=(const Key& key) +Key& Key::operator=(const Key& key) { kname = key.kname; @@ -778,5 +778,5 @@ void Key::setNewFlag(bool v) Constructs a KeyList */ -KeyList::KeyList() : QIntDict<Key>(20) +KeyList::KeyList() : QIntDict<Key>(20) { setAutoDelete(TRUE); @@ -784,5 +784,5 @@ KeyList::KeyList() : QIntDict<Key>(20) /* Should be deep copy, but isn't */ -KeyList::KeyList(const KeyList &k) : QIntDict<Key>(k) +KeyList::KeyList(const KeyList &k) : QIntDict<Key>(k) { KeyListIterator it(k); @@ -823,5 +823,5 @@ bool KeyList::operator!=(const KeyList &other) Returns the number of keys stored in the KeyList */ -int KeyList::getNumFields() const +int KeyList::getNumFields() const { return count(); @@ -848,19 +848,18 @@ int KeyList::addKey(QString name, TVVariant::KeyType type) TVVariant e = TVVariant("0"); switch(type) { - case TVVariant::String: + case TVVariant::String: return addKey(name, TVVariant("<undefined>").asString()); break; - case TVVariant::Date: + case TVVariant::Date: return addKey(name, TVVariant(QDate::currentDate()).asDate()); break; - case TVVariant::Time: + case TVVariant::Time: return addKey(name, TVVariant(QTime(0,0,0)).toTime()); break; - case TVVariant::Int: + case TVVariant::Int: return addKey(name, TVVariant(0).toInt()); break; default: - qWarning(QObject::tr("KeyList::addKey() Cannot make default " - "value for type %1, Key not added.").arg(type)); + owarn << "KeyList::addKey() Cannot make default value for type " << type << ", Key not added." << oendl; break; } @@ -868,5 +867,5 @@ int KeyList::addKey(QString name, TVVariant::KeyType type) } -void KeyList::setKeyFlags(int i, int flag) +void KeyList::setKeyFlags(int i, int flag) { if(find(i)) @@ -881,5 +880,5 @@ int KeyList::getKeyFlags(int i) const } -bool KeyList::checkNewFlag(int i) const +bool KeyList::checkNewFlag(int i) const { if (find(i)) @@ -888,5 +887,5 @@ bool KeyList::checkNewFlag(int i) const } -void KeyList::setNewFlag(int i, bool f) +void KeyList::setNewFlag(int i, bool f) { if(!find(i)) @@ -895,5 +894,5 @@ void KeyList::setNewFlag(int i, bool f) } -bool KeyList::checkDeleteFlag(int i) const +bool KeyList::checkDeleteFlag(int i) const { if (find(i)) @@ -902,5 +901,5 @@ bool KeyList::checkDeleteFlag(int i) const } -void KeyList::setDeleteFlag(int i, bool f) +void KeyList::setDeleteFlag(int i, bool f) { if(!find(i)) @@ -919,5 +918,5 @@ QString KeyList::getKeyName(int i) const } -void KeyList::setKeyName(int i, const QString &n) +void KeyList::setKeyName(int i, const QString &n) { if(find(i)) @@ -935,5 +934,5 @@ TVVariant::KeyType KeyList::getKeyType(int i) const } -void KeyList::setKeyType(int i, TVVariant::KeyType t) +void KeyList::setKeyType(int i, TVVariant::KeyType t) { if(!find(i)) @@ -1041,7 +1040,7 @@ QDataStream &operator>>( QDataStream &s, KeyList &k) /*! - Constructs a DataElem. This function needs a container because the - size, types of keys and primary key are all defined by the containing - database + Constructs a DataElem. This function needs a container because the + size, types of keys and primary key are all defined by the containing + database */ DataElem::DataElem(DBStore *c) : values(20) @@ -1087,5 +1086,5 @@ QDataStream &operator>>( QDataStream &s, DataElem &d) s >> size; /* redundent data but makes streaming easier */ if (size != d.getNumFields()) { - owarn << "DataSize mis-match" << oendl; + owarn << "DataSize mis-match" << oendl; return s; /* sanity check failed.. don't load */ } @@ -1110,10 +1109,10 @@ KeyList DataElem::getKeys() const } -/*! +/*! This function determines whether field index i of the element has been set yet. - \return A boolean value that is TRUE if the specfied field of this - element has been set and FALSE if the field has not yet been set + \return A boolean value that is TRUE if the specfied field of this + element has been set and FALSE if the field has not yet been set */ bool DataElem::hasValidValue(int i) const @@ -1121,17 +1120,17 @@ bool DataElem::hasValidValue(int i) const if(!values.find(i)) return FALSE; - if(!contained->getKeys()->validIndex(i)) + if(!contained->getKeys()->validIndex(i)) return FALSE; return values.find(i)->isValid(); } -/*! +/*! This function determines whether field name qs of the element has been set yet. - \return A boolean value that is TRUE if the specfied field of this - element has been set and FALSE if the field has not yet been set + \return A boolean value that is TRUE if the specfied field of this + element has been set and FALSE if the field has not yet been set */ -bool DataElem::hasValidValue(QString qs) const +bool DataElem::hasValidValue(QString qs) const { int i = contained->getKeyIndex(qs); @@ -1140,5 +1139,5 @@ bool DataElem::hasValidValue(QString qs) const /*! returns the type of the field specified by index i */ -TVVariant::KeyType DataElem::getFieldType(int i) const +TVVariant::KeyType DataElem::getFieldType(int i) const { return contained->getKeyType(i); @@ -1152,7 +1151,7 @@ TVVariant::KeyType DataElem::getFieldType(QString qs) const } -/*! - returns a pointer to the data stored in field index i for this - data element, (value may not be valid) +/*! + returns a pointer to the data stored in field index i for this + data element, (value may not be valid) */ TVVariant DataElem::getField(int i) const @@ -1163,7 +1162,7 @@ TVVariant DataElem::getField(int i) const } -/*! - returns a pointer to the data stored in field name qs for this - data element, (value may not be valid) +/*! + returns a pointer to the data stored in field name qs for this + data element, (value may not be valid) */ TVVariant DataElem::getField(QString qs) const @@ -1180,5 +1179,5 @@ TVVariant DataElem::getField(QString qs) const \param q a string that can be parsed to get the value to be set */ -void DataElem::setField(int i, QString q) +void DataElem::setField(int i, QString q) { /* from the type of the field, parse q and store */ @@ -1209,7 +1208,5 @@ void DataElem::setField(int i, QString q) } default: - qWarning( - QObject::tr("DataElem::setField(%1, %2) No valid type found").arg(i).arg(q) - ); + owarn << "DataElem::setField(" << i << ", " << q << ") No valid type found" << oendl; } } @@ -1220,7 +1217,7 @@ void DataElem::setField(int i, QString q) \param i index of the field to set - \param value a pointer to the (already allocated) value to set + \param value a pointer to the (already allocated) value to set */ -void DataElem::setField(int i, TVVariant value) +void DataElem::setField(int i, TVVariant value) { if (value.isValid()) { @@ -1237,5 +1234,5 @@ void DataElem::setField(int i, TVVariant value) \param q a string that can be parsed to get the value to be set */ -void DataElem::setField(QString qs, QString q) +void DataElem::setField(QString qs, QString q) { /* from the type of the field, parse q and store */ @@ -1249,5 +1246,5 @@ void DataElem::setField(QString qs, QString q) \param qs name of the field to set - \param value a pointer to the (already allocated) value to set + \param value a pointer to the (already allocated) value to set */ void DataElem::setField(QString qs, TVVariant value) @@ -1268,5 +1265,5 @@ void DataElem::unsetField(QString qs) /*! - Converts the data element to a Rich Text QString + Converts the data element to a Rich Text QString */ QString DataElem::toQString() const @@ -1291,5 +1288,5 @@ QString DataElem::toQString() const /*! formats individual fields to strings so can be displayed */ -QString DataElem::toQString(int i) const +QString DataElem::toQString(int i) const { if(hasValidValue(i)) { @@ -1299,5 +1296,5 @@ QString DataElem::toQString(int i) const } /*! formats individual fields to strings so can be sorted by QListView */ -QString DataElem::toSortableQString(int i) const +QString DataElem::toSortableQString(int i) const { QString scratch = ""; @@ -1314,5 +1311,5 @@ QString DataElem::toSortableQString(int i) const case TVVariant::Date: { static QDate epochD(1800, 1, 1); - scratch.sprintf("%08d", + scratch.sprintf("%08d", epochD.daysTo(getField(i).toDate())); break; @@ -1320,5 +1317,5 @@ QString DataElem::toSortableQString(int i) const case TVVariant::Time: { static QTime epochT(0, 0, 0); - scratch.sprintf("%08d", + scratch.sprintf("%08d", epochT.msecsTo(getField(i).toTime())); break; @@ -1381,10 +1378,10 @@ bool DataElem::contains(int i, TVVariant v) const /* meaningless for time */ /* meaningless for dates */ - case TVVariant::Int: + case TVVariant::Int: case TVVariant::Time: case TVVariant::Date: break; default: - owarn << "Tried to compare unknown data type" << oendl; + owarn << "Tried to compare unknown data type" << oendl; } return FALSE; @@ -1407,10 +1404,10 @@ bool DataElem::startsWith(int i, TVVariant v) const /* meaningless for time */ /* meaningless for dates */ - case TVVariant::Int: + case TVVariant::Int: case TVVariant::Time: case TVVariant::Date: return FALSE; default: - owarn << "Tried to compare unknown data type" << oendl; + owarn << "Tried to compare unknown data type" << oendl; } return FALSE; @@ -1433,10 +1430,10 @@ bool DataElem::endsWith(int i, TVVariant v) const /* meaningless for time */ /* meaningless for dates */ - case TVVariant::Int: + case TVVariant::Int: case TVVariant::Time: case TVVariant::Date: return FALSE; default: - owarn << "Tried to compare unknown data type" << oendl; + owarn << "Tried to compare unknown data type" << oendl; } return FALSE; @@ -1447,7 +1444,7 @@ bool DataElem::endsWith(int i, TVVariant v) const parameter. - \return + \return <UL> - <LI>TRUE if the first element is a closer match to the target than the + <LI>TRUE if the first element is a closer match to the target than the second element</LI> <LI>FALSE if the first element is not a closer match to the target than @@ -1457,5 +1454,5 @@ bool DataElem::endsWith(int i, TVVariant v) const bool DataElem::closer(DataElem*d1, DataElem *d2, TVVariant target, int column) { - int type; + int type; if(!d1) return FALSE; @@ -1470,9 +1467,9 @@ bool DataElem::closer(DataElem*d1, DataElem *d2, TVVariant target, int column) if (type != d2->getField(column).type()) { /* can't do compare */ - owarn << "Tried to compare two incompatable types" << oendl; + owarn << "Tried to compare two incompatable types" << oendl; return FALSE; } return target.closer(d1->getField(column), d2->getField(column)); - } + } return target.close(d1->getField(column)); } 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 @@ -17,5 +17,5 @@ ** not clear to you. ** -**********************************************************************/ +**********************************************************************/ /* * This file is used to load the xml files that represent the database. @@ -64,8 +64,8 @@ DBStore::DBStore() } -//TODO +//TODO /*! - Reinitializes the table to empty (include a resize of the master table, - which should free some memory) + Reinitializes the table to empty (include a resize of the master table, + which should free some memory) */ void DBStore::freeTable() @@ -94,5 +94,5 @@ DBStore::~DBStore() /*! - This function opens the given xml file, loads it and sets up the + This function opens the given xml file, loads it and sets up the appropriate data structures. @@ -102,5 +102,5 @@ DBStore::~DBStore() bool DBStore::openSource(QIODevice *inDev, const QString &source) { - /* first check if db is already open, if contains data.. then clear */ + /* first check if db is already open, if contains data.. then clear */ if(number_elems > 0) { freeTable(); @@ -110,12 +110,12 @@ bool DBStore::openSource(QIODevice *inDev, const QString &source) { archive = new DBXml(this); } else if (source == "text/csv") { - archive = new DBCsv(this); + archive = new DBCsv(this); } else - return false; + return false; return (archive->openSource(inDev)); } -bool DBStore::saveSource(QIODevice *outDev, const QString &source) +bool DBStore::saveSource(QIODevice *outDev, const QString &source) { /* saving a new file */ @@ -123,8 +123,8 @@ bool DBStore::saveSource(QIODevice *outDev, const QString &source) if (source == "text/x-xml-tableviewer") { archive = new DBXml(this); - } else if (source == "text/x-xml-tableviewer") { + } else if (source == "text/x-xml-tableviewer") { archive = new DBCsv(this); } else - return false; + return false; } @@ -134,8 +134,8 @@ bool DBStore::saveSource(QIODevice *outDev, const QString &source) if (source == "text/x-xml-tableviewer") { archive = new DBXml(this); - } else if (source == "text/x-xml-tableviewer") { + } else if (source == "text/x-xml-tableviewer") { archive = new DBCsv(this); - } else - return false; + } else + return false; } @@ -143,5 +143,5 @@ bool DBStore::saveSource(QIODevice *outDev, const QString &source) } -/*! +/*! This function is used to add new elements to the database. If the database has already reached the maximum allowable size this function does not alter @@ -157,7 +157,7 @@ void DBStore::addItem(DataElem *delem) void DBStore::addItemInternal(DataElem *delem) { - /* if already full, don't over fill, do a qWarning though */ + /* if already full, don't over fill, do a owarn though */ if (full) { - owarn << "Attempted to add items to already full table" << oendl; + owarn << "Attempted to add items to already full table" << oendl; return; } @@ -186,11 +186,11 @@ void DBStore::removeItem(DataElem *r) { int position = master_table.findRef(r); - if(position != -1) { - /* there is at least one item, this is it */ - /* replace this with the last element, decrease the element count */ - master_table.insert(position, master_table.at(--number_elems)); - master_table.remove(number_elems); - delete r; - } + if(position != -1) { + /* there is at least one item, this is it */ + /* replace this with the last element, decrease the element count */ + master_table.insert(position, master_table.at(--number_elems)); + master_table.remove(number_elems); + delete r; + } } @@ -202,5 +202,5 @@ void DBStore::removeItem(DataElem *r) void DBStore::setName(const QString &n) { - name = n; + name = n; } @@ -212,9 +212,9 @@ void DBStore::setName(const QString &n) QString DBStore::getName() { - return name; + return name; } /*! - Retrieves a pointer to the key representation of the database for + Retrieves a pointer to the key representation of the database for other classes to use as reference. @@ -236,5 +236,5 @@ void DBStore::setKeys(KeyList *k) /*! - Sets the current element to the first element of the database + Sets the current element to the first element of the database */ void DBStore::first() @@ -244,5 +244,5 @@ void DBStore::first() /*! - Sets the current element to the last element of the database + Sets the current element to the last element of the database */ void DBStore::last() @@ -258,5 +258,5 @@ bool DBStore::next() { unsigned int new_current_elem = current_elem + 1; - if (current_elem < number_elems) + if (current_elem < number_elems) /* was valid before inc (it is possible but unlikely that inc current elem will change it from invalid to valid) */ @@ -279,5 +279,5 @@ bool DBStore::previous() /* was valid */ if (new_current_elem < number_elems) { - /* still is (if was 0, then now -1, but as is unsigned will wrap + /* still is (if was 0, then now -1, but as is unsigned will wrap and hence be invalid */ current_elem = new_current_elem; @@ -289,12 +289,12 @@ bool DBStore::previous() /*! Returns the current data element in the database. Which element is current - is affected by newly added items, findItem, next, previous, first and + is affected by newly added items, findItem, next, previous, first and last functions \return a pointer to the current data element */ -DataElem *DBStore::getCurrentData() +DataElem *DBStore::getCurrentData() { - if (current_elem >= number_elems) + if (current_elem >= number_elems) return NULL; return master_table[current_elem]; diff --git a/noncore/apps/tableviewer/db/datacache.h b/noncore/apps/tableviewer/db/datacache.h index c5dc637..e38050c 100644 --- a/noncore/apps/tableviewer/db/datacache.h +++ b/noncore/apps/tableviewer/db/datacache.h @@ -28,7 +28,13 @@ #define __DATACACHE_H__ +#include "common.h" + +/* OPIE */ +#include <opie2/odebug.h> +using namespace Opie::Core; + +/* QT */ #include <qstring.h> #include <qvector.h> -#include "common.h" class DBStore; @@ -46,10 +52,10 @@ public: virtual bool openSource(QIODevice *) { - qWarning("DBAccess::openSource not yet implemented"); + owarn << "DBAccess::openSource not yet implemented" << oendl; return false; } virtual bool saveSource(QIODevice *) { - qWarning("DBAccess::saveSource(QString) not yet implemented"); + owarn << "DBAccess::saveSource(QString) not yet implemented" << oendl; return false; } @@ -71,5 +77,5 @@ public: void addItem(DataElem *); void addItemInternal(DataElem *); - void removeItem(DataElem *); + void removeItem(DataElem *); // Set the name of the database @@ -107,13 +113,13 @@ public: void last(); - bool next(); - bool previous(); + bool next(); + bool previous(); - DataElem* getCurrentData(); + DataElem* getCurrentData(); private: /* does the work of freeing used memory */ void freeTable(); - QString name; + QString name; QVector<DataElem> master_table; @@ -124,5 +130,5 @@ private: unsigned int number_elems; unsigned int table_size; /* should always be a power of 2 */ - bool full; /* since because we are using an int for indexing there is + bool full; /* since because we are using an int for indexing there is an upper limit on the number of items we can store. */ unsigned int current_elem; |