-rw-r--r-- | noncore/apps/tableviewer/main.cpp | 6 | ||||
-rw-r--r-- | noncore/apps/tableviewer/tableviewer.cpp | 26 | ||||
-rw-r--r-- | noncore/apps/tableviewer/tableviewer.h | 3 |
3 files changed, 32 insertions, 3 deletions
diff --git a/noncore/apps/tableviewer/main.cpp b/noncore/apps/tableviewer/main.cpp index 56c567f..d17ee65 100644 --- a/noncore/apps/tableviewer/main.cpp +++ b/noncore/apps/tableviewer/main.cpp @@ -11,22 +11,22 @@ ** 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 <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); + TableViewerWindow mw; + 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 0456b41..fbb5c24 100644 --- a/noncore/apps/tableviewer/tableviewer.cpp +++ b/noncore/apps/tableviewer/tableviewer.cpp @@ -21,32 +21,33 @@ /* 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 <qpe/fileselector.h> #include <qpe/resource.h> #include <qpe/qpetoolbar.h> /* QTE includes */ #include <qpe/qpemenubar.h> +#include <qpe/qpetoolbar.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 */ @@ -221,32 +222,37 @@ void TableViewerWindow::newDocument() 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::setDocument(const QString &f) +{ + openDocument(DocLnk(f, TRUE)); +} + 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(); @@ -276,32 +282,52 @@ void TableViewerWindow::openDocument(const DocLnk &f) 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 first item of the current table +*/ +void TableViewerWindow::firstItem() +{ + listView->first(); + ts.current_elem = listView->getCurrentData(); + browseView->rebuildData(); +} + +/*! + Moves to the lat item of the current table +*/ +void TableViewerWindow::lastItem() +{ + listView->last(); + ts.current_elem = listView->getCurrentData(); + browseView->rebuildData(); +} + +/*! 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(); diff --git a/noncore/apps/tableviewer/tableviewer.h b/noncore/apps/tableviewer/tableviewer.h index 0d3c39d..817db21 100644 --- a/noncore/apps/tableviewer/tableviewer.h +++ b/noncore/apps/tableviewer/tableviewer.h @@ -36,34 +36,37 @@ 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 setDocument(const QString &); void openDocument(const DocLnk &); + void firstItem(); + void lastItem(); 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); |