summaryrefslogtreecommitdiff
path: root/noncore/apps/tableviewer/db/common.cpp
Side-by-side diff
Diffstat (limited to 'noncore/apps/tableviewer/db/common.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/tableviewer/db/common.cpp28
1 files changed, 18 insertions, 10 deletions
diff --git a/noncore/apps/tableviewer/db/common.cpp b/noncore/apps/tableviewer/db/common.cpp
index dbf9370..6e544ba 100644
--- a/noncore/apps/tableviewer/db/common.cpp
+++ b/noncore/apps/tableviewer/db/common.cpp
@@ -1,52 +1,60 @@
/**********************************************************************
** 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 "common.h"
+#include "datacache.h"
+
+/* OPIE */
+#include <opie2/odebug.h>
+#include <qpe/timestring.h>
+using namespace Opie::Core;
+
+/* QT */
#include <qstring.h>
#include <qheader.h>
#include <qvector.h>
#include <qdatetime.h>
-#include <qpe/timestring.h>
-#include "common.h"
-#include "datacache.h"
+
+/* STD */
#include <assert.h>
+#include <stdlib.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)
break;
/* just skip this char */
}
@@ -291,49 +299,49 @@ void TVVariant::load(QDataStream &s )
}
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;
default:
- qFatal("Unrecognized data type");
+ ofatal << "Unrecognized data type" << oendl;
}
}
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;
}
}
@@ -1057,49 +1065,49 @@ QDataStream &operator<<( QDataStream &s, const DataElem &d)
int size = d.getNumFields();
s << size; /* redundent data but makes streaming easier */
KeyList k = d.getKeys();
KeyListIterator it(k);
while(it.current()) {
s << (Q_UINT16)it.currentKey();
s << d.getField(it.currentKey());
++it;
}
return s;
}
QDataStream &operator>>( QDataStream &s, DataElem &d)
{
int i;
int size;
TVVariant t;
int index = 0;
s >> size; /* redundent data but makes streaming easier */
if (size != d.getNumFields()) {
- qWarning("DataSize mis-match");
+ owarn << "DataSize mis-match" << oendl;
return s; /* sanity check failed.. don't load */
}
for(i = 0; i < size; i++) {
s >> (Q_UINT16)index;
s >> t;
d.setField(index, t);
}
return s;
}
/*! Returns the number of possible (not valid) fields in the data element */
int DataElem::getNumFields() const
{
return contained->getNumFields();
}
KeyList DataElem::getKeys() const
{
return *(contained->getKeys());
}
/*!
This function determines whether field index i of the element has been
@@ -1356,115 +1364,115 @@ bool DataElem::equalTo(int i, TVVariant v) const
}
bool DataElem::contains(int i, TVVariant v) const
{
if (!hasValidValue(i)) return FALSE;
if (getField(i).type() != v.type())
return FALSE;
switch(getField(i).type()) {
case TVVariant::String: {
QString qs1 = getField(i).toString().lower();
QString qs2 = v.toString().lower();
if (qs1.contains(qs2) > 0) return TRUE;
break;
}
/* meaningless for ints */
/* meaningless for time */
/* meaningless for dates */
case TVVariant::Int:
case TVVariant::Time:
case TVVariant::Date:
break;
default:
- qWarning("Tried to compare unknown data type");
+ owarn << "Tried to compare unknown data type" << oendl;
}
return FALSE;
}
bool DataElem::startsWith(int i, TVVariant v) const
{
if (!hasValidValue(i)) return FALSE;
if (getField(i).type() != v.type())
return FALSE;
switch(getField(i).type()) {
case TVVariant::String: {
QString qs1 = getField(i).toString().lower();
QString qs2 = v.toString().lower();
return qs1.startsWith(qs2);
}
/* meaningless for ints */
/* meaningless for time */
/* meaningless for dates */
case TVVariant::Int:
case TVVariant::Time:
case TVVariant::Date:
return FALSE;
default:
- qWarning("Tried to compare unknown data type");
+ owarn << "Tried to compare unknown data type" << oendl;
}
return FALSE;
}
bool DataElem::endsWith(int i, TVVariant v) const
{
if (!hasValidValue(i)) return FALSE;
if (getField(i).type() != v.type())
return FALSE;
switch(getField(i).type()) {
case TVVariant::String: {
QString qs1 = getField(i).toString().lower();
QString qs2 = v.toString().lower();
return qs1.startsWith(qs2);
}
/* meaningless for ints */
/* meaningless for time */
/* meaningless for dates */
case TVVariant::Int:
case TVVariant::Time:
case TVVariant::Date:
return FALSE;
default:
- qWarning("Tried to compare unknown data type");
+ owarn << "Tried to compare unknown data type" << oendl;
}
return FALSE;
}
/*!
Determins which of the first to parameters are closer to the third, target
parameter.
\return
<UL>
<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
the second element</LI>
</UL>
*/
bool DataElem::closer(DataElem*d1, DataElem *d2, TVVariant target, int column)
{
int type;
if(!d1) return FALSE;
if (!d1->hasValidValue(column)) return FALSE;
if(!target.isValid()) return FALSE;
type = d1->getField(column).type();
if(d2) {
if (type != d2->getField(column).type()) {
/* can't do compare */
- qWarning("Tried to compare two incompatable types");
+ 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));
}