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 | |
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
-rw-r--r-- | noncore/apps/tableviewer/db/common.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/tableviewer/main.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/tableviewer/tableviewer.cpp | 24 | ||||
-rw-r--r-- | noncore/apps/tableviewer/tableviewer.h | 2 | ||||
-rw-r--r-- | noncore/apps/tableviewer/ui/commonwidgets.cpp | 3 | ||||
-rw-r--r-- | noncore/apps/tableviewer/ui/tvbrowseview.cpp | 2 |
6 files changed, 18 insertions, 17 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,409 +1,409 @@ /********************************************************************** ** 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) break; /* just skip this char */ } } /* now truncate q */ if (found_digits) q->remove(0, i); return result; } /*! \class QStringVector \brief A Vector of QStrings that can be sorted and searched Implmented in order to allow reverse lookup on the string name */ /*! This function implements the compare function in order to allow the searching and sorting of the QStringVector to occur \returns an int which is either <UL> <LI> < 0 if the first string is smaller than the second,</LI> <LI> > 0 if the first string is bigger then the second,</LI> <LI> == 0 if the first string is equal to the second.</LI> </UL> */ 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 the keytypes and behaviours in one place */ TVVariantPrivate::TVVariantPrivate() { typ = TVVariant::Invalid; } TVVariantPrivate::TVVariantPrivate( TVVariantPrivate *d) { switch(d->typ) { case TVVariant::Invalid: break; case TVVariant::String: value.ptr = new QString(*((QString *)d->value.ptr)); break; case TVVariant::Date: value.ptr = new QDate(*((QDate *)d->value.ptr)); break; case TVVariant::Time: value.ptr = new QTime(*((QTime *)d->value.ptr)); break; case TVVariant::Int: value.i = d->value.i; break; default: ASSERT( 0 ); } typ = d->typ; } TVVariantPrivate::~TVVariantPrivate() { clear(); } void TVVariantPrivate::clear() { switch( typ ) { case TVVariant::String: delete (QString *)value.ptr; break; case TVVariant::Date: delete (QDate *)value.ptr; break; case TVVariant::Time: delete (QTime *)value.ptr; break; case TVVariant::Invalid: case TVVariant::Int: break; } typ = TVVariant::Invalid; } /*! \class TVVariant blah */ TVVariant::TVVariant() { d = new TVVariantPrivate; } TVVariant::~TVVariant() { if (d->deref()) delete d; } TVVariant::TVVariant(const TVVariant& p) { d = new TVVariantPrivate; *this = p; } TVVariant::TVVariant(QDataStream& s) { d = new TVVariantPrivate; s >> *this; } TVVariant::TVVariant(const QString &val) { d = new TVVariantPrivate; d->typ = String; d->value.ptr = new QString(val); } TVVariant::TVVariant(const QDate &val) { d = new TVVariantPrivate; d->typ = Date; d->value.ptr = new QDate(val); } TVVariant::TVVariant(const QTime &val) { d = new TVVariantPrivate; d->typ = Time; d->value.ptr = new QTime(val); } TVVariant::TVVariant( int val ) { d = new TVVariantPrivate; d->typ = Int; d->value.i = val; } TVVariant& TVVariant::operator=(const TVVariant& variant ) { TVVariant& other = (TVVariant&) variant; other.d->ref(); if ( d->deref() ) delete d; d = other.d; return *this; } void TVVariant::detach() { if (d->count == 1) return; d->deref(); d = new TVVariantPrivate(d); } const QString TVVariant::typeName() const { return typeToName(d->typ); } void TVVariant::clear() { if (d->count > 1) { d->deref(); d = new TVVariantPrivate; return; } d->clear(); } const QString TVVariant::typeToName(KeyType typ) { switch(typ) { case String: return QString("String"); case Date: return QString("Date"); case Time: return QString("Time"); case Int: return QString("Int"); case Invalid: default: return QString("Invalid"); } return QString("Invalid"); } TVVariant::KeyType TVVariant::nameToType(const QString &name) { if(!qstrcmp("String", name)) return String; if(!qstrcmp("Date", name)) return Date; if(!qstrcmp("Time", name)) return Time; if(!qstrcmp("Int", name)) return Int; return Invalid; } void TVVariant::load(QDataStream &s ) { KeyType t; s >> t; d->typ = t; switch(t) { case Invalid: d->typ = t; break; case String: { QString *x = new QString; 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; default: 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; } } QDataStream& operator>>(QDataStream& s, TVVariant& p) { p.load( s ); return s; } QDataStream& operator<<(QDataStream &s, const TVVariant& p) { p.save( s ); return s; } QDataStream& operator>> (QDataStream &s, TVVariant::KeyType& p) { Q_UINT8 u = 0; s >> u; p = (TVVariant::KeyType) u; return s; } QDataStream& operator<< (QDataStream& s, const TVVariant::KeyType& p) { s << (Q_UINT8)p; return s; } 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); 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 diff --git a/noncore/apps/tableviewer/main.cpp b/noncore/apps/tableviewer/main.cpp index 736e1cf..56c567f 100644 --- a/noncore/apps/tableviewer/main.cpp +++ b/noncore/apps/tableviewer/main.cpp @@ -1,32 +1,32 @@ /********************************************************************** ** 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 "tableviewer.h" -#include <qpeapplication.h> +#include <qpe/qpeapplication.h> int main( int argc, char ** argv ) { QPEApplication a( argc, argv ); TableViewerWindow * mw = new TableViewerWindow; mw->setCaption( TableViewerWindow::tr("Table Viewer") ); a.showMainWidget(mw); return a.exec(); } diff --git a/noncore/apps/tableviewer/tableviewer.cpp b/noncore/apps/tableviewer/tableviewer.cpp index 0d4a412..0456b41 100644 --- a/noncore/apps/tableviewer/tableviewer.cpp +++ b/noncore/apps/tableviewer/tableviewer.cpp @@ -1,455 +1,455 @@ /********************************************************************** ** 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. ** **********************************************************************/ /* 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 */ -#include "fileselector.h" -#include "resource.h" +#include <qpe/fileselector.h> +#include <qpe/resource.h> +#include <qpe/qpetoolbar.h> /* QTE includes */ #include <qpe/qpemenubar.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) : QMainWindow(parent, name, f) { setCaption(tr("Table Viewer")); /* Build data */ ds = new DBStore(); doc.setType("text/x-xml-tableviewer"); doc.setName("table"); dirty = FALSE; ts.current_column = 0; ts.kRep = ds->getKeys(); /* build menus */ menu = new QPEMenuBar(this, 0); QPopupMenu *file_menu = new QPopupMenu; file_menu->insertItem("New", this, SLOT(newDocument())); file_menu->insertItem("Open", this, SLOT(selectDocument())); file_menu->insertSeparator(); file_menu->insertItem("Properties"); /* later will want to set this up to clean up first via this, SLOT(quit) */ menu->insertItem("Document", file_menu); QPopupMenu *edit_menu = new QPopupMenu; edit_menu->insertItem("Edit Item", this, SLOT(editItemSlot())); edit_menu->insertItem("Edit Keys", this, SLOT(editKeysSlot())); edit_menu->insertItem("Edit filters", this, SLOT(filterViewSlot())); menu->insertItem("Edit", edit_menu); QPopupMenu *view_menu = new QPopupMenu; view_menu->insertItem("Browse View", this, SLOT(browseViewSlot())); view_menu->insertItem("List View", this, SLOT(listViewSlot())); menu->insertItem("View", view_menu); QVBoxLayout *main_layout = new QVBoxLayout; /* Build tool bar */ navigation = new QPEToolBar(this, "navigation"); QToolButton *newItemButton = new QToolButton( - QIconSet(Resource::loadImage("new")), "New Item", QString::null, + QIconSet(Resource::loadPixmap("new")), "New Item", QString::null, this, SLOT(newItemSlot()), navigation, "New Item"); QToolButton *editItemButton = new QToolButton( - QIconSet(Resource::loadImage("edit")), "Edit Item", QString::null, + QIconSet(Resource::loadPixmap("edit")), "Edit Item", QString::null, this, SLOT(editItemSlot()), navigation, "Edit Item"); QToolButton *deleteItemButton = new QToolButton( - QIconSet(Resource::loadImage("trash")), "Delete Item", + QIconSet(Resource::loadPixmap("trash")), "Delete Item", QString::null, this, SLOT(deleteItemSlot()), navigation, "Delete Item"); navigation->addSeparator(); QToolButton *firstItemButton = new QToolButton( - QIconSet(Resource::loadImage("fastback")), "First Item", + QIconSet(Resource::loadPixmap("fastback")), "First Item", QString::null, this, SLOT(firstItem()), navigation, "First Item"); QToolButton *previousItemButton = new QToolButton( - QIconSet(Resource::loadImage("back")), "Previous Item", + QIconSet(Resource::loadPixmap("back")), "Previous Item", QString::null, this, SLOT(previousItem()), navigation, "Previous Item"); QToolButton *nextItemButton = new QToolButton( - QIconSet(Resource::loadImage("forward")), "Next Item", + QIconSet(Resource::loadPixmap("forward")), "Next Item", QString::null, this, SLOT(nextItem()), navigation, "Next Item"); QToolButton *lastItemButton = new QToolButton( - QIconSet(Resource::loadImage("fastforward")), "Last Item", + QIconSet(Resource::loadPixmap("fastforward")), "Last Item", QString::null, this, SLOT(lastItem()), navigation, "Last Item"); navigation->addSeparator(); QToolButton *browseButton = new QToolButton( - QIconSet(Resource::loadImage("day")), "View Single Item", + QIconSet(Resource::loadPixmap("day")), "View Single Item", QString::null, this, SLOT(browseViewSlot()), navigation, "View Single Item"); QToolButton *listButton = new QToolButton( - QIconSet(Resource::loadImage("month")), "View Multiple Items", + QIconSet(Resource::loadPixmap("month")), "View Multiple Items", QString::null, this, SLOT(listViewSlot()), navigation, "View Multiple Items"); setToolBarsMovable(FALSE); setToolBarsMovable(FALSE); setToolBarsMovable(FALSE); /* Build widgets */ browseView = new TVBrowseView(&ts, this, 0); listView = new TVListView(&ts, this, 0); filterView = new TVFilterView(&ts, this, 0); fileSelector = new FileSelector("text/csv;text/x-xml-tableviewer", this, "fileselector"); fileSelector->setNewVisible(FALSE); fileSelector->setCloseVisible(FALSE); cw = new QWidgetStack(this, 0); cw->addWidget(listView, ListState); cw->addWidget(browseView, BrowseState); cw->addWidget(filterView, FilterState); cw->addWidget(fileSelector, FileState); current_view = FileState; cw->raiseWidget(current_view); fileSelector->reread(); connect(browseView, SIGNAL(searchOnKey(int, TVVariant)), this, SLOT(searchOnKey(int, TVVariant))); connect(browseView, SIGNAL(sortChanged(int)), this, SLOT(setPrimaryKey(int))); connect(fileSelector, SIGNAL(closeMe()), this, SLOT(browseViewSlot())); connect(fileSelector, SIGNAL(fileSelected(const DocLnk &)), this, SLOT(openDocument(const DocLnk &))); main_layout->addWidget(menu); main_layout->addWidget(cw); setCentralWidget(cw); } /*! Destroys the TableViewerWindow */ TableViewerWindow::~TableViewerWindow() { if(dirty) saveDocument(); } /*! Opens a file dialog and loads the file specified by the dialog */ void TableViewerWindow::selectDocument() { if(dirty) saveDocument(); current_view = FileState; cw->raiseWidget(current_view); fileSelector->reread(); } void TableViewerWindow::saveDocument() { if(!dirty) return; FileManager fm; QIODevice *dev = fm.saveFile(doc); if(!ds->saveSource(dev, doc.type())){ qWarning("Save unsuccessful"); return; } dev->close(); dirty = FALSE; } void TableViewerWindow::newDocument() { DocLnk nf; nf.setType("text/x-xml-tableviewer"); nf.setName("table"); delete ds; ds = new DBStore(); ts.current_column = 0; ts.kRep = ds->getKeys(); browseView->reset(); listView->reset(); filterView->reset(); doc = nf; dirty = FALSE; current_view = BrowseState; cw->raiseWidget(current_view); /* now set up for editing the keys */ ts.kRep->addKey("key", TVVariant::String); editKeysSlot(); } void TableViewerWindow::openDocument(const DocLnk &f) { if (!f.isValid()) return; FileManager fm; QIODevice *dev = fm.openFile(f); doc = f; if(ds->openSource(dev, doc.type())) { DataElem *d; browseView->reset(); listView->reset(); filterView->reset(); current_view = BrowseState; cw->raiseWidget(current_view); /* set up new table state and ensure sub widgets have a reference */ ts.current_column = 0; ts.kRep = ds->getKeys(); browseView->rebuildKeys(); listView->rebuildKeys(); filterView->rebuildKeys(); ds->first(); /* set up the list view */ listView->clearItems(); do { d = ds->getCurrentData(); if(d) listView->addItem(d); } while(ds->next()); /* Set up browse view, Will be based of structure of listView */ 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")); } dev->close(); } /*! Moves to the next item of the current table */ void TableViewerWindow::nextItem() { listView->next(); ts.current_elem = listView->getCurrentData(); browseView->rebuildData(); } /*! Moves to the previous item of the current table */ void TableViewerWindow::previousItem() { listView->previous(); ts.current_elem = listView->getCurrentData(); browseView->rebuildData(); } /*! Raises the List View. This is a mode change for the application. */ void TableViewerWindow::listViewSlot() { if(current_view == FilterState) applyFilter(); current_view = ListState; cw->raiseWidget(current_view); } void TableViewerWindow::applyFilter() { DataElem *d; listView->clearItems(); ds->first(); do { d = ds->getCurrentData(); if(d) if(filterView->passesFilter(d)) listView->addItem(d); } while(ds->next()); listView->first(); listView->rebuildData(); } /*! Raises the Browse View. This is a mode change for the application. */ void TableViewerWindow::browseViewSlot() { if(current_view == FilterState) applyFilter(); ts.current_elem = listView->getCurrentData(); browseView->rebuildData(); current_view = BrowseState; cw->raiseWidget(current_view); } /*! Raises the List View. This is a mode change for the application. */ void TableViewerWindow::filterViewSlot() { current_view = FilterState; cw->raiseWidget(current_view); } void TableViewerWindow::editItemSlot() { if(TVEditView::openEditItemDialog(&ts, ts.current_elem, this)) { listView->rebuildData(); browseView->rebuildData(); dirty = TRUE; } } void TableViewerWindow::newItemSlot() { DataElem *d = new DataElem(ds); if (TVEditView::openEditItemDialog(&ts, d, this)) { ds->addItem(d); ts.current_elem = d; applyFilter(); listView->rebuildData(); browseView->rebuildData(); dirty = TRUE; } } void TableViewerWindow::deleteItemSlot() { /* delete the actual item, then do a 'filter' */ DataElem *to_remove = ts.current_elem; if(!to_remove) return; listView->removeItem(); ds->removeItem(to_remove); applyFilter(); listView->rebuildData(); browseView->rebuildData(); dirty = TRUE; } void TableViewerWindow::editKeysSlot() { DataElem *d; KeyList *k = TVKeyEdit::openEditKeysDialog(&ts, this); if(k) { /* set as new keys */ ds->setKeys(k); ts.current_column = 0; ts.kRep = k; browseView->reset(); listView->reset(); filterView->reset(); browseView->rebuildKeys(); listView->rebuildKeys(); filterView->rebuildKeys(); ds->first(); /* set up the list view */ listView->clearItems(); do { d = ds->getCurrentData(); if(d) listView->addItem(d); } while(ds->next()); /* Set up browse view, Will be based of structure of listView */ dirty = TRUE; } } /*! A Slot that allows for widgets above to indicate a search should be done on a specified key index for a specified value */ void TableViewerWindow::searchOnKey(int i, TVVariant v) { listView->findItem(i, v); ts.current_elem = listView->getCurrentData(); browseView->rebuildData(); } void TableViewerWindow::setPrimaryKey(int i) { ts.current_column = i; listView->rebuildData(); browseView->rebuildData(); } diff --git a/noncore/apps/tableviewer/tableviewer.h b/noncore/apps/tableviewer/tableviewer.h index 2d4686a..0d3c39d 100644 --- a/noncore/apps/tableviewer/tableviewer.h +++ b/noncore/apps/tableviewer/tableviewer.h @@ -1,109 +1,109 @@ /********************************************************************** ** 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. ** **********************************************************************/ #ifndef Tableviewer_H #define Tableviewer_H #include <qmainwindow.h> #include "db/common.h" -#include "fileselector.h" +#include <qpe/fileselector.h> /* Forward class declarations */ class QWidgetStack; class QDialog; class QMenuBar; class TVListView; class TVBrowseView; class TVFilterView; class TVEditView; class DBStore; class TableViewerWindow: public QMainWindow { Q_OBJECT public: TableViewerWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); ~TableViewerWindow(); public slots: void selectDocument(); void newDocument(); void saveDocument(); void openDocument(const DocLnk &); void nextItem(); void previousItem(); void listViewSlot(); void browseViewSlot(); void filterViewSlot(); void editItemSlot(); void newItemSlot(); void deleteItemSlot(); void editKeysSlot(); /* reveiw the sig. for this function TODO */ void searchOnKey(int, TVVariant); void setPrimaryKey(int); /* TODO add new event */ protected: /* TODO add new slots */ private slots: /* TODO add other widgets used here */ private: bool dirty; QMenuBar *menu; QToolBar *navigation; TVListView *listView; TVBrowseView *browseView; TVFilterView *filterView; TVEditView *editView; FileSelector *fileSelector; DocLnk doc; QWidgetStack *cw; DBStore *ds; TableState ts; /* not a pointer.. this class keeps the state */ enum UserState { BrowseState = 0, ListState, FilterState, EditState, FileState, }; UserState current_view; void applyFilter(); }; #endif diff --git a/noncore/apps/tableviewer/ui/commonwidgets.cpp b/noncore/apps/tableviewer/ui/commonwidgets.cpp index 0b4f3c2..bf4c36f 100644 --- a/noncore/apps/tableviewer/ui/commonwidgets.cpp +++ b/noncore/apps/tableviewer/ui/commonwidgets.cpp @@ -1,209 +1,210 @@ /********************************************************************** ** 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 <qlineedit.h> #include <qlayout.h> #include <qlabel.h> #include <qcombobox.h> -#include <datebookmonth.h> + +#include <qpe/datebookmonth.h> #include <qpopupmenu.h> #include <qspinbox.h> #include "commonwidgets.h" DateEdit::DateEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ) : QToolButton(parent, name) { QPopupMenu *m1 = new QPopupMenu(this); dateSelector = new DateBookMonth(m1, 0, TRUE); m1->insertItem(dateSelector); setPopup(m1); setPopupDelay(0); connect(dateSelector, SIGNAL(dateClicked(int, int, int)), this, SLOT(subValueChanged())); setText(dateSelector->selectedDate().toString()); } DateEdit::~DateEdit() {} QDate DateEdit::date() const { return dateSelector->selectedDate(); } void DateEdit::setDate(QDate d) { dateSelector->setDate(d.year(), d.month(), d.day()); setText(d.toString()); } QSizePolicy DateEdit::sizePolicy() const { QSizePolicy sp; sp.setHorData(QToolButton::sizePolicy().horData()); sp.setVerData(QSizePolicy::Fixed); return sp; } void DateEdit::clear() { QDate today = QDate::currentDate(); dateSelector->setDate(today.year(), today.month(), today.day()); setText(today.toString()); } void DateEdit::subValueChanged() { QDate current = dateSelector->selectedDate(); setText(current.toString()); emit valueChanged(current); } TimeEdit::TimeEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ) : QWidget(parent, name, f) { QHBoxLayout *layout = new QHBoxLayout(this, 0); layout->addWidget(hourKey = new QSpinBox(1, 12, 1, this)); hourKey->setWrapping(true); hourKey->setMinimumWidth(30); hourKey->setMaximumWidth(35); layout->addWidget(new QLabel(" : ", this)); layout->addWidget(minuteKey = new QSpinBox(0, 59, 1, this)); minuteKey->setWrapping(true); minuteKey->setMinimumWidth(30); minuteKey->setMaximumWidth(35); layout->addWidget(new QLabel(" : ", this)); layout->addWidget(secondKey = new QSpinBox(0, 59, 1, this, 0)); secondKey->setWrapping(true); secondKey->setMinimumWidth(30); secondKey->setMaximumWidth(35); layout->addWidget(ampm = new QComboBox(this)); ampm->insertItem("AM"); ampm->insertItem("PM"); layout->addStretch(-1); clear(); connect(secondKey, SIGNAL(valueChanged(const QString&)), this, SLOT(subValueChanged())); connect(minuteKey, SIGNAL(valueChanged(const QString&)), this, SLOT(subValueChanged())); connect(hourKey, SIGNAL(valueChanged(const QString&)), this, SLOT(subValueChanged())); connect(ampm, SIGNAL(activated(int)), this, SLOT(subValueChanged())); } TimeEdit::~TimeEdit() {} QTime TimeEdit::time() const { int s,m,h; s = secondKey->text().toInt(); m = minuteKey->text().toInt(); h = hourKey->text().toInt(); if(ampm->currentItem() == 1) { /* pm */ h = h + 12; } /* hour now ranges 1->24 */ if (h == 12) h = 0; if (h == 24) h = 12; if(QTime::isValid(h, m, s)) return QTime(h, m, s); return QTime(0, 0, 0); } void TimeEdit::setTime(QTime t) { int h = t.hour(); secondKey->setValue(t.second()); minuteKey->setValue(t.minute()); /* h 0..23 */ if (h > 11) { h -= 12; ampm->setCurrentItem(1); } else { ampm->setCurrentItem(0); } if (h == 0) h = 12; hourKey->setValue(h); } QSizePolicy TimeEdit::sizePolicy() const { QSizePolicy sp; sp.setHorData(QSizePolicy::Preferred); sp.setVerData(QSizePolicy::Fixed); return sp; } void TimeEdit::clear() { secondKey->setValue(0); minuteKey->setValue(0); hourKey->setValue(12); ampm->setCurrentItem(0); } void TimeEdit::subValueChanged() { emit valueChanged(time()); } IntEdit::IntEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ) : QSpinBox(INT_MIN, INT_MAX, 1, parent, name) { setValue(0); } IntEdit::~IntEdit() {} int IntEdit::value() { return cleanText().toInt(); } void IntEdit::clear() { setValue(0); } diff --git a/noncore/apps/tableviewer/ui/tvbrowseview.cpp b/noncore/apps/tableviewer/ui/tvbrowseview.cpp index f6da7b1..9bfc791 100644 --- a/noncore/apps/tableviewer/ui/tvbrowseview.cpp +++ b/noncore/apps/tableviewer/ui/tvbrowseview.cpp @@ -1,122 +1,122 @@ /********************************************************************** ** 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 "tvbrowseview.h" #include "browsekeyentry.h" #include <qtoolbutton.h> #include <qtextview.h> #include <qtextbrowser.h> #include <qlayout.h> /*! \class TVBrowseView \brief The widget describing how to draw the browse view user interface This widget allows for the user to browse through the table, one element at a time, or search on a single key. Its main goal is to show a single element in a readable format and make it easy for the user to rapidly find specific elements in the table. */ /*! Constructs a new TVBrowseView widget */ TVBrowseView::TVBrowseView(TableState *t, QWidget* parent = 0, const char *name = 0, WFlags fl =0) { if (!name) setName("BrowseView"); - setSizePolicy(QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding, 0, 0, sizePolicy().hasHeightForWidth() ) ); +// setSizePolicy(QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding, 0, 0, sizePolicy().hasHeightForWidth() ) ); QVBoxLayout *vlayout = new QVBoxLayout(this); textViewDisplay = new QTextBrowser(this, "textViewDisplay"); vlayout->addWidget( textViewDisplay ); keyEntry = new TVBrowseKeyEntry(this, "keyEntry"); vlayout->addWidget( keyEntry ); /* connect the signals down */ connect(keyEntry, SIGNAL(searchOnKey(int, TVVariant)), this, SIGNAL(searchOnKey(int, TVVariant))); connect(keyEntry, SIGNAL(sortChanged(int)), this, SIGNAL(sortChanged(int))); ts = t; keyEntry->setTableState(t); } /*! Destroys the TVBrowseView widget */ TVBrowseView::~TVBrowseView() { } void TVBrowseView::rebuildData() { if(!ts) return; if(!ts->current_elem) { /* also disable buttons */ textViewDisplay->setText(""); return; } setDisplayText(ts->current_elem); } /* Reset to initial state */ void TVBrowseView::reset() { textViewDisplay->setText(""); keyEntry->reset(); } /*! sets the data element to be displayed to element */ void TVBrowseView::setDisplayText(const DataElem *element) { QString rep = ""; KeyListIterator it(*ts->kRep); while (it.current()) { if (element->hasValidValue(it.currentKey())) { if(it.currentKey() == ts->current_column) { rep += "<A name=\"ckey\"></A><B><FONT COLOR=#FF0000>" + it.current()->name() + ":</FONT></B> "; } else { rep += "<B>" + it.current()->name() + ":</B> "; } rep += element->toQString(it.currentKey()) + "<BR>"; } ++it; } textViewDisplay->setText(rep); textViewDisplay->scrollToAnchor("ckey"); } void TVBrowseView::rebuildKeys() { keyEntry->rebuildKeys(); } |