author | mickeyl <mickeyl> | 2004-04-04 13:54:40 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-04-04 13:54:40 (UTC) |
commit | 16cf79e90b5217f8d4bfce2a0fa817ae4b73db36 (patch) (side-by-side diff) | |
tree | 0701eae15aa606a0211a2fccfde0eafdac69357c /noncore/apps/tableviewer | |
parent | 8d2d2664e5f544b8292806e617deb7a0e4170dc0 (diff) | |
download | opie-16cf79e90b5217f8d4bfce2a0fa817ae4b73db36.zip opie-16cf79e90b5217f8d4bfce2a0fa817ae4b73db36.tar.gz opie-16cf79e90b5217f8d4bfce2a0fa817ae4b73db36.tar.bz2 |
convert to Opie Debugging Framework
-rw-r--r-- | noncore/apps/tableviewer/db/common.cpp | 28 | ||||
-rw-r--r-- | noncore/apps/tableviewer/db/datacache.cpp | 12 | ||||
-rw-r--r-- | noncore/apps/tableviewer/db/xmlsource.cpp | 30 | ||||
-rw-r--r-- | noncore/apps/tableviewer/tableviewer.cpp | 14 | ||||
-rw-r--r-- | noncore/apps/tableviewer/tableviewer.pro | 0 | ||||
-rw-r--r-- | noncore/apps/tableviewer/ui/tvlistview.cpp | 9 |
6 files changed, 62 insertions, 31 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 @@ -8,33 +8,41 @@ ** 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; @@ -303,25 +311,25 @@ void TVVariant::load(QDataStream &s ) 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: @@ -1069,25 +1077,25 @@ QDataStream &operator<<( QDataStream &s, const DataElem &d) 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 */ @@ -1368,25 +1376,25 @@ bool DataElem::contains(int i, TVVariant v) const 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()) { @@ -1394,25 +1402,25 @@ bool DataElem::startsWith(int i, TVVariant v) const 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()) { @@ -1420,25 +1428,25 @@ bool DataElem::endsWith(int i, TVVariant v) const 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> @@ -1452,19 +1460,19 @@ bool DataElem::closer(DataElem*d1, DataElem *d2, TVVariant target, int column) 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)); } diff --git a/noncore/apps/tableviewer/db/datacache.cpp b/noncore/apps/tableviewer/db/datacache.cpp index 7c14eef..6380e1b 100644 --- a/noncore/apps/tableviewer/db/datacache.cpp +++ b/noncore/apps/tableviewer/db/datacache.cpp @@ -17,27 +17,35 @@ ** 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, * otherwise any other data headings are allowed. */ #include "datacache.h" #include "xmlsource.h" #include "csvsource.h" -#include <stdlib.h> + +/* OPIE */ +#include <opie2/odebug.h> +using namespace Opie::Core; + +/* QT */ #include <qheader.h> +/* STD */ +#include <stdlib.h> + #define INIT_TABLE_SIZE 128 /*! \class DBStore datastore.h \brief The DBStore class is the class responsible for storing, sorting and searching the data loaded by the application */ /*! Constructs a DBStore item @@ -141,25 +149,25 @@ bool DBStore::saveSource(QIODevice *outDev, const QString &source) \param delm An already allocated and initialized data element to be added */ void DBStore::addItem(DataElem *delem) { addItemInternal(delem); } void DBStore::addItemInternal(DataElem *delem) { /* if already full, don't over fill, do a qWarning though */ if (full) { - qWarning("Attempted to add items to already full table"); + owarn << "Attempted to add items to already full table" << oendl; return; } master_table.insert(number_elems, delem); current_elem = number_elems; number_elems++; if(number_elems >= table_size) { /* filled current table, double if we can */ table_size = table_size << 1; diff --git a/noncore/apps/tableviewer/db/xmlsource.cpp b/noncore/apps/tableviewer/db/xmlsource.cpp index 94fec36..4ca6aee 100644 --- a/noncore/apps/tableviewer/db/xmlsource.cpp +++ b/noncore/apps/tableviewer/db/xmlsource.cpp @@ -9,30 +9,36 @@ ** 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 "xmlsource.h" -#include <qdict.h> -#include <stdlib.h> -#include <qtextstream.h> #include "../xmlencodeattr.h" +/* OPIE */ +#include <opie2/odebug.h> +using namespace Opie::Core; +/* QT */ +#include <qdict.h> +#include <qtextstream.h> + +/* STD */ +#include <stdlib.h> DBXml::DBXml(DBStore *d) { dstore = d; } QString DBXml::type() { return "xml"; } bool DBXml::openSource(QIODevice *inDev) @@ -131,25 +137,25 @@ DBXmlHandler::DBXmlHandler(DBStore *ds) current_keyrep = 0; } /*! Destroys the DBXmlHandler */ DBXmlHandler::~DBXmlHandler() { } QString DBXmlHandler::errorProtocol() { - qWarning("Error reading file"); + owarn << "Error reading file" << oendl; return errorProt; } bool DBXmlHandler::startDocument() { errorProt = ""; state = StateInit; return TRUE; } bool DBXmlHandler::startElement(const QString&, const QString&, const QString& qName, const QXmlAttributes& atts) @@ -163,49 +169,49 @@ bool DBXmlHandler::startElement(const QString&, const QString&, if (state == StateDocument && qName == "header") { state = StateHeader; if (current_keyrep) delete current_keyrep; current_keyrep = new KeyList(); return TRUE; } if (state == StateHeader && qName == "key") { /* Ok, adding a new key to our KeyList TODO */ state = StateKey; last_key_type = TVVariant::String; key = atts.value("name"); if (key.isEmpty()) { - qWarning("empty key name"); + owarn << "empty key name" << oendl; return FALSE; } if(!atts.value("type").isEmpty()) last_key_type = TVVariant::nameToType(atts.value("type")); return TRUE; } if (state == StateDocument && qName == "record") { state = StateRecord; current_data = new DataElem(data_store); // Now expecting a <record> tag return TRUE; } if (state == StateRecord) { state = StateField; /* the qName is the name of a key */ if (!keyIndexList[qName]) { /* invalid key, we failed */ - qWarning("Invalid key in record"); + owarn << "Invalid key in record" << oendl; return FALSE; } keyIndex = *keyIndexList[qName]; return TRUE; } - qWarning("Unable to determine tag type"); + owarn << "Unable to determine tag type" << oendl; return FALSE; } bool DBXmlHandler::endElement(const QString&, const QString&, const QString& qName) { switch(state) { case StateField: // TODO checks 'could' be done of the popped value state = StateRecord; break; case StateKey: @@ -216,25 +222,25 @@ bool DBXmlHandler::endElement(const QString&, const QString&, data_store->setKeys(current_keyrep); state = StateDocument; break; case StateRecord: data_store->addItem(current_data); state = StateDocument; break; case StateDocument: // we are done... break; default: // should only get a 'endElement' from one of the above states. - qWarning("Invalid end tag"); + owarn << "Invalid end tag" << oendl; return FALSE; break; } return TRUE; } bool DBXmlHandler::characters(const QString& ch) { // this is where the 'between tag' stuff happens. // e.g. the stuff between tags. QString ch_simplified = ch.simplifyWhiteSpace(); @@ -245,53 +251,53 @@ bool DBXmlHandler::characters(const QString& ch) int *tmp_val = new int; /* We just grabbed the display name of a key */ *tmp_val = current_keyrep->addKey(ch_simplified, last_key_type); keyIndexList.insert(key, tmp_val); return TRUE; } if (state == StateField) { /* Ok, need to add data here */ current_data->setField(keyIndex, ch_simplified); return TRUE; } - qWarning("Junk characters found... ignored"); + owarn << "Junk characters found... ignored" << oendl; return TRUE; } QString DBXmlHandler::errorString() { return "the document is not in the expected file format"; } bool DBXmlHandler::warning(const QXmlParseException& exception) { errorProt += QString("warning parsing error: %1 in line %2, column %3\n" ) .arg(exception.message()) .arg(exception.lineNumber()) .arg(exception.columnNumber()); - qWarning(errorProt); + owarn << errorProt << oendl; return QXmlDefaultHandler::fatalError(exception); } bool DBXmlHandler::error(const QXmlParseException& exception) { errorProt += QString("error parsing error: %1 in line %2, column %3\n" ) .arg(exception.message()) .arg(exception.lineNumber()) .arg(exception.columnNumber()); - qWarning(errorProt); + owarn << errorProt << oendl; return QXmlDefaultHandler::fatalError(exception); } bool DBXmlHandler::fatalError(const QXmlParseException& exception) { errorProt += QString("fatal parsing error: %1 in line %2, column %3\n" ) .arg(exception.message()) .arg(exception.lineNumber()) .arg(exception.columnNumber()); - qWarning(errorProt); + owarn << errorProt << oendl; return QXmlDefaultHandler::fatalError(exception); } diff --git a/noncore/apps/tableviewer/tableviewer.cpp b/noncore/apps/tableviewer/tableviewer.cpp index 102b94c..9538cb3 100644 --- a/noncore/apps/tableviewer/tableviewer.cpp +++ b/noncore/apps/tableviewer/tableviewer.cpp @@ -9,45 +9,47 @@ ** 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. ** **********************************************************************/ -/* local includes */ #include "tableviewer.h" #include "ui/tvbrowseview.h" #include "ui/tvfilterview.h" #include "ui/tvlistview.h" #include "ui/tveditview.h" #include "ui/tvkeyedit.h" #include "db/datacache.h" -/* QPE includes */ +/* OPIE */ +#include <opie2/odebug.h> #include <qpe/fileselector.h> #include <qpe/resource.h> -#include <qtoolbar.h> +using namespace Opie::Core; -/* QTE includes */ +/* QT */ #include <qmenubar.h> +#include <qtoolbar.h> #include <qpopupmenu.h> #include <qapplication.h> #include <qwidgetstack.h> #include <qlayout.h> #include <qbuffer.h> + /*! \class TableViewerWindow \brief The main window widget of the application This is the main widget of the table viewer application. It is the co-ordination point. */ /*! Constructs a new TableViewerWindow */ TableViewerWindow::TableViewerWindow(QWidget *parent, const char *name, WFlags f) @@ -192,25 +194,25 @@ void TableViewerWindow::selectDocument() fileSelector->reread(); } void TableViewerWindow::saveDocument() { if(!dirty) return; FileManager fm; QIODevice *dev = fm.saveFile(doc); if(!ds->saveSource(dev, doc.type())){ - qWarning("Save unsuccessful"); + owarn << "Save unsuccessful" << oendl; return; } dev->close(); dirty = FALSE; } void TableViewerWindow::newDocument() { DocLnk nf; nf.setType("text/x-xml-tableviewer"); nf.setName("table"); @@ -279,25 +281,25 @@ void TableViewerWindow::openDocument(const DocLnk &f) listView->first(); ts.current_elem = listView->getCurrentData(); browseView->rebuildData(); listView->rebuildData(); QString scratch = "Table Viewer";/* later take from constant */ scratch += " - "; scratch += ds->getName(); setCaption(tr(scratch)); dirty = FALSE; } else { - qWarning(tr("could not load Document")); + owarn << tr("could not load Document") << oendl; } dev->close(); } /*! Moves to the first item of the current table */ void TableViewerWindow::firstItem() { listView->first(); ts.current_elem = listView->getCurrentData(); browseView->rebuildData(); diff --git a/noncore/apps/tableviewer/tableviewer.pro b/noncore/apps/tableviewer/tableviewer.pro index 1de23bb..564f50f 100644 --- a/noncore/apps/tableviewer/tableviewer.pro +++ b/noncore/apps/tableviewer/tableviewer.pro diff --git a/noncore/apps/tableviewer/ui/tvlistview.cpp b/noncore/apps/tableviewer/ui/tvlistview.cpp index b10ff1d..c3e6432 100644 --- a/noncore/apps/tableviewer/ui/tvlistview.cpp +++ b/noncore/apps/tableviewer/ui/tvlistview.cpp @@ -8,26 +8,33 @@ ** 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 "tvlistview.h" #include "../db/common.h" + +/* OPIE */ +#include <opie2/odebug.h> +using namespace Opie::Core; + +/* QT */ #include <qtoolbutton.h> #include <qlistview.h> #include <qlayout.h> void TVListViewPrivate::setColumnWidth(int column, int width) { if(width > 70) width = 70; QListView::setColumnWidth(column, width); } void TVListViewPrivate::setSorting(int column, bool increasing) { @@ -154,25 +161,25 @@ void TVListView::clearItems() delete it; it = new QListViewItemIterator(listViewDisplay); } void TVListView::first() { delete it; it = new QListViewItemIterator(listViewDisplay); } void TVListView::last() { - qWarning("TVListView::last not yet implemented"); + owarn << "TVListView::last not yet implemented" << oendl; } void TVListView::next() { QListViewItemIterator tmp = *it; (*it)++; if (!it->current()) { *it = tmp; } } void TVListView::previous() |