summaryrefslogtreecommitdiff
path: root/noncore/apps/tableviewer
authorar <ar>2004-05-31 15:26:50 (UTC)
committer ar <ar>2004-05-31 15:26:50 (UTC)
commit27dfc34d411dee76f09f5e516c60b0a64eb35948 (patch) (side-by-side diff)
treeb7f7259497630390e352a1257cac5dc59f5399a6 /noncore/apps/tableviewer
parent27b09fe4f930b96e82cea9fb0eb1a9b87f7ec062 (diff)
downloadopie-27dfc34d411dee76f09f5e516c60b0a64eb35948.zip
opie-27dfc34d411dee76f09f5e516c60b0a64eb35948.tar.gz
opie-27dfc34d411dee76f09f5e516c60b0a64eb35948.tar.bz2
- convert qWarning to owarn
Diffstat (limited to 'noncore/apps/tableviewer') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/tableviewer/browsekeyentry.cpp53
-rw-r--r--noncore/apps/tableviewer/db/common.cpp165
-rw-r--r--noncore/apps/tableviewer/db/datacache.cpp68
-rw-r--r--noncore/apps/tableviewer/db/datacache.h24
-rw-r--r--noncore/apps/tableviewer/ui/browsekeyentry.cpp49
-rw-r--r--noncore/apps/tableviewer/ui/filterkeyentry.cpp42
-rw-r--r--noncore/apps/tableviewer/ui/tvfilterview.cpp55
7 files changed, 234 insertions, 222 deletions
diff --git a/noncore/apps/tableviewer/browsekeyentry.cpp b/noncore/apps/tableviewer/browsekeyentry.cpp
index 04e7902..bab9af6 100644
--- a/noncore/apps/tableviewer/browsekeyentry.cpp
+++ b/noncore/apps/tableviewer/browsekeyentry.cpp
@@ -16,9 +16,14 @@
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
-**********************************************************************/
+**********************************************************************/
#include "browsekeyentry.h"
+/* OPIE */
+#include <opie2/odebug.h>
+using namespace Opie::Core;
+
+/* QT */
#include <qtoolbutton.h>
#include <qwidgetstack.h>
#include <qlayout.h>
@@ -28,9 +33,6 @@
#include <qhbox.h>
#include <qdatetime.h>
-//#include <iostream.h>
-#include <qheader.h>
-// For qWarning(const char *)
/*!
\class TVBrowseKeyEntry
@@ -42,7 +44,7 @@
*/
/*!
- Constructs the widget
+ Constructs the widget
*/
TVBrowseKeyEntry::TVBrowseKeyEntry(QWidget *parent, const char *name, WFlags f)
: QWidget(parent, name, f)
@@ -80,37 +82,37 @@ TVBrowseKeyEntry::TVBrowseKeyEntry(QWidget *parent, const char *name, WFlags f)
ws->addWidget(dateKey, stack_elem++);
ws->raiseWidget(0);
-
+
// TODO connect slots and signals....
- connect(changeKeyButton, SIGNAL(clicked()),
+ connect(changeKeyButton, SIGNAL(clicked()),
this, SLOT(changeKeyMenuSlot()));
- connect(resetButton, SIGNAL(clicked()),
+ connect(resetButton, SIGNAL(clicked()),
this, SLOT(resetKeySlot()));
- connect(textKey, SIGNAL(textChanged(const QString&)),
+ connect(textKey, SIGNAL(textChanged(const QString&)),
this, SLOT(searchOnText()));
- connect(dayKey, SIGNAL(textChanged(const QString&)),
+ connect(dayKey, SIGNAL(textChanged(const QString&)),
this, SLOT(searchOnText()));
- connect(monthKey, SIGNAL(textChanged(const QString&)),
+ connect(monthKey, SIGNAL(textChanged(const QString&)),
this, SLOT(searchOnText()));
- connect(yearKey, SIGNAL(textChanged(const QString&)),
+ connect(yearKey, SIGNAL(textChanged(const QString&)),
this, SLOT(searchOnText()));
- connect(secondKey, SIGNAL(textChanged(const QString&)),
+ connect(secondKey, SIGNAL(textChanged(const QString&)),
this, SLOT(searchOnText()));
- connect(minuteKey, SIGNAL(textChanged(const QString&)),
+ connect(minuteKey, SIGNAL(textChanged(const QString&)),
this, SLOT(searchOnText()));
- connect(hourKey, SIGNAL(textChanged(const QString&)),
+ connect(hourKey, SIGNAL(textChanged(const QString&)),
this, SLOT(searchOnText()));
-
+
h_layout->addWidget(ws);
h_layout->addWidget(resetButton);
h_layout->addWidget(changeKeyButton);
}
/*!
- Destructs the widget
+ Destructs the widget
*/
TVBrowseKeyEntry::~TVBrowseKeyEntry()
{
@@ -136,8 +138,8 @@ void TVBrowseKeyEntry::changeKeySlot(int id_param)
case kt_date:
ws->raiseWidget(2);
break;
- default:
- return;
+ default:
+ return;
}
}
@@ -146,7 +148,7 @@ void TVBrowseKeyEntry::changeKeySlot(int id_param)
*/
void TVBrowseKeyEntry::changeKeyMenuSlot()
{
- if(ts)
+ if(ts)
keyMenu->exec(changeKeyButton->mapToGlobal(QPoint(0,0)));
}
/*!
@@ -165,15 +167,15 @@ void TVBrowseKeyEntry::setTableState(TableState *t) {
keyMenu->clear();
for (i = 0; i < t->kRep->getNumFields(); i++) {
- keyMenu->insertItem(ts->kRep->getKeyName(i), this,
+ keyMenu->insertItem(ts->kRep->getKeyName(i), this,
SLOT(changeKeySlot(int)), 0, i);
keyMenu->setItemParameter(i, i);
}
}
/*!
- Searches on the current value of the key entry provided that the
- current key is of type text WARNING, TODO fix memory leaks
+ Searches on the current value of the key entry provided that the
+ current key is of type text WARNING, TODO fix memory leaks
*/
void TVBrowseKeyEntry::searchOnText()
{
@@ -228,8 +230,7 @@ void TVBrowseKeyEntry::searchOnText()
break;
}
default:
- qWarning("TVBrowseKeyEntry::searchOnText() "
- "cannot work out data type");
+ owarn << "TVBrowseKeyEntry::searchOnText() cannot work out data type" << oendl;
return;
}
emit searchOnKey(ts->current_column, sendkey);
@@ -239,4 +240,4 @@ void TVBrowseKeyEntry::searchOnText()
This signal indicates that a search on key index currentKeyId should be
done searching for the value v.
-*/
+*/
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
@@ -16,8 +16,8 @@
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
-**********************************************************************/
-#include "common.h"
+**********************************************************************/
+#include "common.h"
#include "datacache.h"
/* OPIE */
@@ -88,13 +88,13 @@ int QStringVector::compareItems(Item a, Item b)
{
QString *qa = (QString *)a;
QString *qb = (QString *)b;
-
+
return QString::compare(*qa, *qb);
}
/*!
\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
*/
@@ -320,7 +320,7 @@ void TVVariant::load(QDataStream &s )
}
break;
default:
- ofatal << "Unrecognized data type" << oendl;
+ ofatal << "Unrecognized data type" << oendl;
}
}
@@ -382,7 +382,7 @@ const QString TVVariant::toString() const
return ((QDate*)d->value.ptr)->toString();
case Time:
return ((QTime*)d->value.ptr)->toString();
- case Int:
+ case Int:
return QString::number(d->value.i);
case Invalid:
default:
@@ -424,7 +424,7 @@ const QDate TVVariant::toDate() const
return QDate();
return QDate(year, month, day);
}
-
+
return QDate();
}
@@ -433,7 +433,7 @@ const QTime TVVariant::toTime() const
{
if(d->typ == Time)
return *((QTime *)d->value.ptr);
-
+
if(d->typ == String) {
QString q = toString();
int hour = parseNextNumber(&q);
@@ -454,7 +454,7 @@ const QTime TVVariant::toTime() const
else \
detach(); \
return *((Q##f*)d->value.ptr); }
-
+
TV_VARIANT_AS(String)
TV_VARIANT_AS(Date)
TV_VARIANT_AS(Time)
@@ -560,7 +560,7 @@ 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 */
if(n.type() != type())
@@ -572,7 +572,7 @@ 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();
QString qs2 = o.toString().lower();
@@ -582,7 +582,7 @@ bool TVVariant::closer(TVVariant n, TVVariant o)
return FALSE;
/* 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;
}
@@ -593,13 +593,13 @@ bool TVVariant::closer(TVVariant n, TVVariant o)
int iv = toInt();
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;
}
@@ -610,10 +610,10 @@ 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;
if (diff1 < diff2)
@@ -627,10 +627,10 @@ 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)
return TRUE;
@@ -649,7 +649,7 @@ 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 */
if(n.type() != type())
@@ -657,7 +657,7 @@ 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();
QString qsv = toString().lower();
@@ -666,7 +666,7 @@ bool TVVariant::close(TVVariant n)
return FALSE;
return TRUE;
}
- case Int:
+ case Int:
case Date:
case Time:
return TRUE;
@@ -681,14 +681,14 @@ bool TVVariant::close(TVVariant n)
/*!
\class Key
\brief document me!
-
+
document me!
*/
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)
{
@@ -697,7 +697,7 @@ Key::Key(const Key &other)
kflags = other.kflags;
}
-Key& Key::operator=(const Key& key)
+Key& Key::operator=(const Key& key)
{
kname = key.kname;
kexample = key.kexample;
@@ -777,13 +777,13 @@ void Key::setNewFlag(bool v)
/*!
Constructs a KeyList
*/
-KeyList::KeyList() : QIntDict<Key>(20)
+KeyList::KeyList() : QIntDict<Key>(20)
{
setAutoDelete(TRUE);
}
/* 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);
while(it.current()) {
@@ -822,7 +822,7 @@ 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();
}
@@ -847,27 +847,26 @@ int KeyList::addKey(QString name, TVVariant::KeyType type)
/* generate a valid type for the example? */
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;
}
return -1;
}
-void KeyList::setKeyFlags(int i, int flag)
+void KeyList::setKeyFlags(int i, int flag)
{
if(find(i))
find(i)->setFlags(flag);
@@ -880,28 +879,28 @@ int KeyList::getKeyFlags(int i) const
return 0;
}
-bool KeyList::checkNewFlag(int i) const
+bool KeyList::checkNewFlag(int i) const
{
if (find(i))
return find(i)->newFlag();
return false;
}
-void KeyList::setNewFlag(int i, bool f)
+void KeyList::setNewFlag(int i, bool f)
{
if(!find(i))
return;
find(i)->setNewFlag(f);
}
-bool KeyList::checkDeleteFlag(int i) const
+bool KeyList::checkDeleteFlag(int i) const
{
if (find(i))
return find(i)->delFlag();
return false;
}
-void KeyList::setDeleteFlag(int i, bool f)
+void KeyList::setDeleteFlag(int i, bool f)
{
if(!find(i))
return;
@@ -918,7 +917,7 @@ QString KeyList::getKeyName(int i) const
return QString();
}
-void KeyList::setKeyName(int i, const QString &n)
+void KeyList::setKeyName(int i, const QString &n)
{
if(find(i))
find(i)->setName(n);
@@ -934,7 +933,7 @@ TVVariant::KeyType KeyList::getKeyType(int i) const
return TVVariant::Invalid;
}
-void KeyList::setKeyType(int i, TVVariant::KeyType t)
+void KeyList::setKeyType(int i, TVVariant::KeyType t)
{
if(!find(i))
return;
@@ -1040,9 +1039,9 @@ 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)
{
@@ -1086,7 +1085,7 @@ 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 */
}
@@ -1109,37 +1108,37 @@ KeyList DataElem::getKeys() const
return *(contained->getKeys());
}
-/*!
+/*!
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
{
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);
return hasValidValue(i);
}
/*! 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);
}
@@ -1151,9 +1150,9 @@ TVVariant::KeyType DataElem::getFieldType(QString qs) const
return contained->getKeyType(i);
}
-/*!
- 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
{
@@ -1162,9 +1161,9 @@ TVVariant DataElem::getField(int i) const
return TVVariant();
}
-/*!
- 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
{
@@ -1179,7 +1178,7 @@ TVVariant DataElem::getField(QString qs) const
\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)
+void DataElem::setField(int i, QString q)
{
/* from the type of the field, parse q and store */
TVVariant::KeyType kt = contained->getKeyType(i);
@@ -1208,9 +1207,7 @@ void DataElem::setField(int i, QString q)
return;
}
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;
}
}
@@ -1219,9 +1216,9 @@ void DataElem::setField(int i, QString q)
value.
\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()) {
values.remove(i);
@@ -1236,7 +1233,7 @@ void DataElem::setField(int i, TVVariant value)
\param qs name of the field to set
\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 */
int i = contained->getKeyIndex(qs);
@@ -1248,7 +1245,7 @@ void DataElem::setField(QString qs, QString q)
value.
\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)
{
@@ -1267,7 +1264,7 @@ 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
{
@@ -1290,7 +1287,7 @@ 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)) {
return getField(i).toString();
@@ -1298,7 +1295,7 @@ QString DataElem::toQString(int i) const
return "";
}
/*! 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 = "";
if(hasValidValue(i)) {
@@ -1313,13 +1310,13 @@ 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;
}
case TVVariant::Time: {
static QTime epochT(0, 0, 0);
- scratch.sprintf("%08d",
+ scratch.sprintf("%08d",
epochT.msecsTo(getField(i).toTime()));
break;
}
@@ -1380,12 +1377,12 @@ bool DataElem::contains(int i, TVVariant v) const
/* meaningless for ints */
/* 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;
}
@@ -1406,12 +1403,12 @@ bool DataElem::startsWith(int i, TVVariant v) const
/* meaningless for ints */
/* 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;
}
@@ -1432,12 +1429,12 @@ bool DataElem::endsWith(int i, TVVariant v) const
/* meaningless for ints */
/* 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;
}
@@ -1446,9 +1443,9 @@ bool DataElem::endsWith(int i, TVVariant v) const
Determins which of the first to parameters are closer to the third, target
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
the second element</LI>
@@ -1456,7 +1453,7 @@ 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;
@@ -1469,10 +1466,10 @@ bool DataElem::closer(DataElem*d1, DataElem *d2, TVVariant target, int column)
if(d2) {
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
@@ -16,7 +16,7 @@
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
-**********************************************************************/
+**********************************************************************/
/*
* This file is used to load the xml files that represent the database.
* The main requirment for said file is each data entry must contain a key,
@@ -63,10 +63,10 @@ DBStore::DBStore()
archive = 0;
}
-//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()
{
@@ -93,7 +93,7 @@ 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.
\param file_name A string representing the name of the file to be opened
@@ -101,7 +101,7 @@ 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();
}
@@ -109,23 +109,23 @@ bool DBStore::openSource(QIODevice *inDev, const QString &source) {
if (source == "text/x-xml-tableviewer") {
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 */
if(!archive) {
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;
}
/* changing file type */
@@ -133,16 +133,16 @@ bool DBStore::saveSource(QIODevice *outDev, const QString &source)
delete archive;
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;
}
return (archive->saveSource(outDev));
}
-/*!
+/*!
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
the database.
@@ -156,9 +156,9 @@ 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;
}
@@ -185,13 +185,13 @@ void DBStore::addItemInternal(DataElem *delem)
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;
+ }
}
/*!
@@ -201,7 +201,7 @@ void DBStore::removeItem(DataElem *r)
*/
void DBStore::setName(const QString &n)
{
- name = n;
+ name = n;
}
/*!
@@ -211,11 +211,11 @@ 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.
\return a pointer to the databases key representaion
@@ -235,7 +235,7 @@ 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()
{
@@ -243,7 +243,7 @@ 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()
{
@@ -257,7 +257,7 @@ void DBStore::last()
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) */
if (new_current_elem < number_elems) {
@@ -278,7 +278,7 @@ bool DBStore::previous()
if (current_elem < number_elems)
/* 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;
return true;
@@ -288,14 +288,14 @@ 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
@@ -27,9 +27,15 @@
#ifndef __DATACACHE_H__
#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;
@@ -45,12 +51,12 @@ 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;
}
@@ -70,7 +76,7 @@ public:
// Add an item
void addItem(DataElem *);
void addItemInternal(DataElem *);
- void removeItem(DataElem *);
+ void removeItem(DataElem *);
// Set the name of the database
void setName(const QString &name);
@@ -106,15 +112,15 @@ public:
void first();
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;
DBAccess *archive;
@@ -123,7 +129,7 @@ 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;
};
diff --git a/noncore/apps/tableviewer/ui/browsekeyentry.cpp b/noncore/apps/tableviewer/ui/browsekeyentry.cpp
index 42e24dd..6b78437 100644
--- a/noncore/apps/tableviewer/ui/browsekeyentry.cpp
+++ b/noncore/apps/tableviewer/ui/browsekeyentry.cpp
@@ -16,10 +16,13 @@
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
-**********************************************************************/
+**********************************************************************/
#include "browsekeyentry.h"
#include "commonwidgets.h"
+#include <opie2/odebug.h>
+using namespace Opie::Core;
+
#include <qtoolbutton.h>
#include <qwidgetstack.h>
#include <qlayout.h>
@@ -29,9 +32,6 @@
#include <qhbox.h>
#include <qdatetime.h>
-#include <qheader.h>
-// For qWarning(const char *)
-
/*!
\class TVBrowseKeyEntry
\brief a Widget used enter keys into the TVBrowseViewWidget
@@ -42,7 +42,7 @@
*/
/*!
- Constructs the widget
+ Constructs the widget
*/
TVBrowseKeyEntry::TVBrowseKeyEntry(QWidget *parent, const char *name, WFlags f)
: QWidget(parent, name, f)
@@ -73,36 +73,36 @@ TVBrowseKeyEntry::TVBrowseKeyEntry(QWidget *parent, const char *name, WFlags f)
ws->addWidget(dateKey, TVVariant::Date);
ws->raiseWidget(TVVariant::String);
-
+
// TODO connect slots and signals....
- connect(changeKeyButton, SIGNAL(clicked()),
+ connect(changeKeyButton, SIGNAL(clicked()),
this, SLOT(changeKeyMenuSlot()));
- connect(resetButton, SIGNAL(clicked()),
+ connect(resetButton, SIGNAL(clicked()),
textKey, SLOT(clear()));
- connect(resetButton, SIGNAL(clicked()),
+ connect(resetButton, SIGNAL(clicked()),
intKey, SLOT(clear()));
- connect(resetButton, SIGNAL(clicked()),
+ connect(resetButton, SIGNAL(clicked()),
dateKey, SLOT(clear()));
- connect(resetButton, SIGNAL(clicked()),
+ connect(resetButton, SIGNAL(clicked()),
timeKey, SLOT(clear()));
h_layout->addWidget(ws);
h_layout->addWidget(resetButton);
h_layout->addWidget(changeKeyButton);
- connect(textKey, SIGNAL(textChanged(const QString&)),
+ connect(textKey, SIGNAL(textChanged(const QString&)),
this, SLOT(searchOnText()));
- connect(intKey, SIGNAL(valueChanged(int)),
+ connect(intKey, SIGNAL(valueChanged(int)),
this, SLOT(searchOnText()));
- connect(dateKey, SIGNAL(valueChanged(const QDate&)),
+ connect(dateKey, SIGNAL(valueChanged(const QDate&)),
this, SLOT(searchOnText()));
- connect(timeKey, SIGNAL(valueChanged(const QTime&)),
+ connect(timeKey, SIGNAL(valueChanged(const QTime&)),
this, SLOT(searchOnText()));
}
/*!
- Destructs the widget
+ Destructs the widget
*/
TVBrowseKeyEntry::~TVBrowseKeyEntry()
{
@@ -126,7 +126,7 @@ void TVBrowseKeyEntry::changeKeySlot(int id_param)
*/
void TVBrowseKeyEntry::changeKeyMenuSlot()
{
- if(ts)
+ if(ts)
keyMenu->exec(changeKeyButton->mapToGlobal(QPoint(0,0)));
}
@@ -146,7 +146,7 @@ void TVBrowseKeyEntry::rebuildKeys() {
KeyListIterator it(*ts->kRep);
for (i = 0; i < ts->kRep->getNumFields(); i++) {
- keyMenu->insertItem(it.current()->name(), this,
+ keyMenu->insertItem(it.current()->name(), this,
SLOT(changeKeySlot(int)), 0, i);
keyMenu->setItemParameter(i, it.currentKey());
++it;
@@ -163,8 +163,8 @@ void TVBrowseKeyEntry::reset()
keyMenu->clear();
}
/*!
- Searches on the current value of the key entry provided that the
- current key is of type text WARNING, TODO fix memory leaks
+ Searches on the current value of the key entry provided that the
+ current key is of type text WARNING, TODO fix memory leaks
*/
void TVBrowseKeyEntry::searchOnText()
{
@@ -189,11 +189,10 @@ void TVBrowseKeyEntry::searchOnText()
sendkey = TVVariant(QDate(dateKey->date()));
break;
}
- case TVVariant::Invalid:
- break;
+ case TVVariant::Invalid:
+ break;
default:
- qWarning("TVBrowseKeyEntry::searchOnText() "
- "cannot work out data type");
+ owarn << "TVBrowseKeyEntry::searchOnText() cannot work out data type" << oendl;
return;
}
emit searchOnKey(ts->current_column, sendkey);
@@ -203,4 +202,4 @@ void TVBrowseKeyEntry::searchOnText()
This signal indicates that a search on key index currentKeyId should be
done searching for the value v.
-*/
+*/
diff --git a/noncore/apps/tableviewer/ui/filterkeyentry.cpp b/noncore/apps/tableviewer/ui/filterkeyentry.cpp
index d108fbd..4d74d6b 100644
--- a/noncore/apps/tableviewer/ui/filterkeyentry.cpp
+++ b/noncore/apps/tableviewer/ui/filterkeyentry.cpp
@@ -16,10 +16,15 @@
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
-**********************************************************************/
+**********************************************************************/
#include "filterkeyentry.h"
#include "commonwidgets.h"
+/* OPIE */
+#include <opie2/odebug.h>
+using namespace Opie::Core;
+
+/* QT */
#include <qwidgetstack.h>
#include <qcombobox.h>
#include <qlayout.h>
@@ -98,13 +103,13 @@ TVFilterKeyEntry::TVFilterKeyEntry(QWidget *parent, const char *name, WFlags f)
ws->addWidget(dateEntry, TVVariant::Date);
/* connect the signals down */
- connect(textKey, SIGNAL(textChanged(const QString&)),
+ connect(textKey, SIGNAL(textChanged(const QString&)),
this, SIGNAL(valueChanged()));
- connect(intKey, SIGNAL(valueChanged(int)),
+ connect(intKey, SIGNAL(valueChanged(int)),
this, SIGNAL(valueChanged()));
- connect(dateKey, SIGNAL(valueChanged(const QDate&)),
+ connect(dateKey, SIGNAL(valueChanged(const QDate&)),
this, SIGNAL(valueChanged()));
- connect(timeKey, SIGNAL(valueChanged(const QTime&)),
+ connect(timeKey, SIGNAL(valueChanged(const QTime&)),
this, SIGNAL(valueChanged()));
connect(intCombo, SIGNAL(activated(int)), this, SIGNAL(valueChanged()));
@@ -119,13 +124,13 @@ TVFilterKeyEntry::TVFilterKeyEntry(QWidget *parent, const char *name, WFlags f)
}
/*!
- Destructs the widget
+ Destructs the widget
*/
TVFilterKeyEntry::~TVFilterKeyEntry()
{
}
-void TVFilterKeyEntry::setKey(int i)
+void TVFilterKeyEntry::setKey(int i)
{
if (!ts) return;
@@ -183,25 +188,24 @@ TVVariant TVFilterKeyEntry::getCompareValue()
int tmp;
switch(current_type) {
- case TVVariant::String:
- sendkey = TVVariant(QString(textKey->text()));
- break;
- case TVVariant::Int: {
+ case TVVariant::String:
+ sendkey = TVVariant(QString(textKey->text()));
+ break;
+ case TVVariant::Int: {
sendkey = TVVariant(intKey->value());
- break;
- }
+ break;
+ }
case TVVariant::Time: {
- sendkey = TVVariant(QTime(timeKey->time()));
- break;
+ sendkey = TVVariant(QTime(timeKey->time()));
+ break;
}
case TVVariant::Date: {
- sendkey = TVVariant(QDate(dateKey->date()));
- break;
+ sendkey = TVVariant(QDate(dateKey->date()));
+ break;
}
default: {
sendkey = TVVariant(0);
- qWarning("TVFilterKeyEntry::getCompareValue() "
- "cannot work out data type");
+ owarn << "TVFilterKeyEntry::getCompareValue() cannot work out data type" << oendl;
}
}
return sendkey;
diff --git a/noncore/apps/tableviewer/ui/tvfilterview.cpp b/noncore/apps/tableviewer/ui/tvfilterview.cpp
index 22f1fb7..198c8b5 100644
--- a/noncore/apps/tableviewer/ui/tvfilterview.cpp
+++ b/noncore/apps/tableviewer/ui/tvfilterview.cpp
@@ -18,6 +18,13 @@
**
**********************************************************************/
#include "tvfilterview.h"
+
+/* OPIE */
+#include <opie2/odebug.h>
+#include <qpe/qpeapplication.h>
+using namespace Opie::Core;
+
+/* QT */
#include <qtoolbutton.h>
#include <qcombobox.h>
#include <qlistview.h>
@@ -26,13 +33,12 @@
#include <qpushbutton.h>
#include <qlabel.h>
-#include <qpe/qpeapplication.h>
TVFilterView::TVFilterView(TableState *t, QWidget* parent,
const char *name, WFlags fl ) : QDialog(parent, name, TRUE, fl)
{
- if ( !name )
- setName( "Filter View" );
+ if ( !name )
+ setName( "Filter View" );
QVBoxLayout *vlayout = new QVBoxLayout(this);
@@ -88,8 +94,8 @@ TVFilterView::TVFilterView(TableState *t, QWidget* parent,
connect(keyEntry, SIGNAL(valueChanged()), this, SLOT( updateTerm() ));
connect(keyNameCombo, SIGNAL(activated(int)), this, SLOT( updateTerm() ));
- connect(display, SIGNAL(selectionChanged(QListViewItem*)), this,
- SLOT(setTerm(QListViewItem*)));
+ connect(display, SIGNAL(selectionChanged(QListViewItem*)), this,
+ SLOT(setTerm(QListViewItem*)));
ts = t;
current = 0;
@@ -102,7 +108,7 @@ TVFilterView::TVFilterView(TableState *t, QWidget* parent,
}
/*!
- Destroys the TVFilterView widget
+ Destroys the TVFilterView widget
*/
TVFilterView::~TVFilterView()
{
@@ -118,26 +124,26 @@ void TVFilterView::reset()
keyIds.clear();
}
-void TVFilterView::rebuildKeys()
+void TVFilterView::rebuildKeys()
{
int i;
if (!ts) return;
if(!ts->kRep) return;
keyEntry->setTableState(ts);
-
+
/* set up the list of keys that can be compared on */
keyNameCombo->clear();
KeyListIterator it(*ts->kRep);
i = 0;
while(it.current()) {
- if(ts->kRep->validIndex(it.currentKey())) {
- keyNameCombo->insertItem(it.current()->name());
- keyIds.insert(i, it.currentKey());
- ++i;
- }
- ++it;
+ if(ts->kRep->validIndex(it.currentKey())) {
+ keyNameCombo->insertItem(it.current()->name());
+ keyIds.insert(i, it.currentKey());
+ ++i;
+ }
+ ++it;
}
}
@@ -146,7 +152,7 @@ bool TVFilterView::passesFilter(DataElem *d) {
FilterTerm *t;
-
+
for (t = terms.first(); t != 0; t = terms.next() ) {
/* check against filter */
switch(t->ct) {
@@ -175,8 +181,7 @@ bool TVFilterView::passesFilter(DataElem *d) {
return false;
break;
default:
- qWarning("TVFilterView::passesFilter() "
- "unrecognized filter type");
+ owarn << "TVFilterView::passesFilter() unrecognized filter type" << oendl;
return false;
}
}
@@ -194,7 +199,7 @@ bool TVFilterView::filterActive() const
}
/* SLOTS */
-void TVFilterView::newTerm()
+void TVFilterView::newTerm()
{
if (!ts) return;
@@ -212,7 +217,7 @@ void TVFilterView::newTerm()
keyNameCombo->setEnabled(true);
}
-void TVFilterView::updateTerm()
+void TVFilterView::updateTerm()
{
FilterTerm *term;
/* Read the widget values (keyname, compare type, value)
@@ -231,7 +236,7 @@ void TVFilterView::updateTerm()
keyEntry->setKey(term->keyIndex); /* so the next two items make sense */
term->ct = keyEntry->getCompareType(),
term->value = keyEntry->getCompareValue();
-
+
keyString = keyNameCombo->currentText();
switch(term->ct) {
@@ -260,14 +265,14 @@ void TVFilterView::updateTerm()
vString = term->value.toString();
/* remove old view */
- if (term->view)
+ if (term->view)
delete(term->view);
term->view = new QListViewItem(display, 0, keyString, cmpString, vString);
display->setSelected(term->view, true);
}
/* deletes current term */
-void TVFilterView::deleteTerm()
+void TVFilterView::deleteTerm()
{
if(!current) return;
if (current->view)
@@ -284,7 +289,7 @@ void TVFilterView::deleteTerm()
}
/* clears all terminations */
-void TVFilterView::clearTerms()
+void TVFilterView::clearTerms()
{
while(current)
deleteTerm();
@@ -292,7 +297,7 @@ void TVFilterView::clearTerms()
void TVFilterView::setTerm(QListViewItem *target)
{
- /* Iterate through the list to find item with view=target..
+ /* Iterate through the list to find item with view=target..
* set as current, delete */
FilterTerm *term = current;
@@ -301,6 +306,6 @@ void TVFilterView::setTerm(QListViewItem *target)
break;
if (!current) {
- current = term;
+ current = term;
}
}