summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-03-11 13:35:07 (UTC)
committer llornkcor <llornkcor>2002-03-11 13:35:07 (UTC)
commitd9406acf405148290c11a49fc09f5ed6b1258843 (patch) (unidiff)
treefe3ca4c79917a1ff052ad63e65434b9b372c5d0b
parentaeb745907f05b7d0729d273f72b5641e890a4c27 (diff)
downloadopie-d9406acf405148290c11a49fc09f5ed6b1258843.zip
opie-d9406acf405148290c11a49fc09f5ed6b1258843.tar.gz
opie-d9406acf405148290c11a49fc09f5ed6b1258843.tar.bz2
adde patch for Pru'homme
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/tableviewer/main.cpp6
-rw-r--r--noncore/apps/tableviewer/tableviewer.cpp26
-rw-r--r--noncore/apps/tableviewer/tableviewer.h3
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
@@ -1,32 +1,32 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include "tableviewer.h" 20#include "tableviewer.h"
21#include <qpe/qpeapplication.h> 21#include <qpe/qpeapplication.h>
22 22
23int main( int argc, char ** argv ) 23int main( int argc, char ** argv )
24{ 24{
25 QPEApplication a( argc, argv ); 25 QPEApplication a( argc, argv );
26 26
27 TableViewerWindow * mw = new TableViewerWindow; 27 TableViewerWindow mw;
28 mw->setCaption( TableViewerWindow::tr("Table Viewer") ); 28 mw.setCaption( TableViewerWindow::tr("Table Viewer") );
29 a.showMainWidget(mw); 29 a.showMainWidget(&mw);
30 30
31 return a.exec(); 31 return a.exec();
32} 32}
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
@@ -1,132 +1,133 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21/* local includes */ 21/* local includes */
22#include "tableviewer.h" 22#include "tableviewer.h"
23#include "ui/tvbrowseview.h" 23#include "ui/tvbrowseview.h"
24#include "ui/tvfilterview.h" 24#include "ui/tvfilterview.h"
25#include "ui/tvlistview.h" 25#include "ui/tvlistview.h"
26#include "ui/tveditview.h" 26#include "ui/tveditview.h"
27#include "ui/tvkeyedit.h" 27#include "ui/tvkeyedit.h"
28#include "db/datacache.h" 28#include "db/datacache.h"
29 29
30/* QPE includes */ 30/* QPE includes */
31#include <qpe/fileselector.h> 31#include <qpe/fileselector.h>
32#include <qpe/resource.h> 32#include <qpe/resource.h>
33#include <qpe/qpetoolbar.h> 33#include <qpe/qpetoolbar.h>
34 34
35/* QTE includes */ 35/* QTE includes */
36#include <qpe/qpemenubar.h> 36#include <qpe/qpemenubar.h>
37#include <qpe/qpetoolbar.h>
37#include <qpopupmenu.h> 38#include <qpopupmenu.h>
38#include <qapplication.h> 39#include <qapplication.h>
39#include <qwidgetstack.h> 40#include <qwidgetstack.h>
40#include <qlayout.h> 41#include <qlayout.h>
41#include <qbuffer.h> 42#include <qbuffer.h>
42/*! 43/*!
43 \class TableViewerWindow 44 \class TableViewerWindow
44 \brief The main window widget of the application 45 \brief The main window widget of the application
45 46
46 This is the main widget of the table viewer application. 47 This is the main widget of the table viewer application.
47 It is the co-ordination point. 48 It is the co-ordination point.
48*/ 49*/
49 50
50/*! 51/*!
51 Constructs a new TableViewerWindow 52 Constructs a new TableViewerWindow
52*/ 53*/
53TableViewerWindow::TableViewerWindow(QWidget *parent, const char *name, WFlags f) 54TableViewerWindow::TableViewerWindow(QWidget *parent, const char *name, WFlags f)
54 : QMainWindow(parent, name, f) 55 : QMainWindow(parent, name, f)
55{ 56{
56 setCaption(tr("Table Viewer")); 57 setCaption(tr("Table Viewer"));
57 58
58/* Build data */ 59/* Build data */
59 ds = new DBStore(); 60 ds = new DBStore();
60 doc.setType("text/x-xml-tableviewer"); 61 doc.setType("text/x-xml-tableviewer");
61 doc.setName("table"); 62 doc.setName("table");
62 63
63 dirty = FALSE; 64 dirty = FALSE;
64 ts.current_column = 0; 65 ts.current_column = 0;
65 ts.kRep = ds->getKeys(); 66 ts.kRep = ds->getKeys();
66 67
67/* build menus */ 68/* build menus */
68 menu = new QPEMenuBar(this, 0); 69 menu = new QPEMenuBar(this, 0);
69 70
70 QPopupMenu *file_menu = new QPopupMenu; 71 QPopupMenu *file_menu = new QPopupMenu;
71 file_menu->insertItem("New", this, SLOT(newDocument())); 72 file_menu->insertItem("New", this, SLOT(newDocument()));
72 73
73 file_menu->insertItem("Open", this, SLOT(selectDocument())); 74 file_menu->insertItem("Open", this, SLOT(selectDocument()));
74 file_menu->insertSeparator(); 75 file_menu->insertSeparator();
75 file_menu->insertItem("Properties"); 76 file_menu->insertItem("Properties");
76 77
77 /* later will want to set this up to clean up first via this, SLOT(quit) */ 78 /* later will want to set this up to clean up first via this, SLOT(quit) */
78 menu->insertItem("Document", file_menu); 79 menu->insertItem("Document", file_menu);
79 80
80 QPopupMenu *edit_menu = new QPopupMenu; 81 QPopupMenu *edit_menu = new QPopupMenu;
81 edit_menu->insertItem("Edit Item", this, SLOT(editItemSlot())); 82 edit_menu->insertItem("Edit Item", this, SLOT(editItemSlot()));
82 edit_menu->insertItem("Edit Keys", this, SLOT(editKeysSlot())); 83 edit_menu->insertItem("Edit Keys", this, SLOT(editKeysSlot()));
83 edit_menu->insertItem("Edit filters", this, SLOT(filterViewSlot())); 84 edit_menu->insertItem("Edit filters", this, SLOT(filterViewSlot()));
84 menu->insertItem("Edit", edit_menu); 85 menu->insertItem("Edit", edit_menu);
85 86
86 QPopupMenu *view_menu = new QPopupMenu; 87 QPopupMenu *view_menu = new QPopupMenu;
87 view_menu->insertItem("Browse View", this, SLOT(browseViewSlot())); 88 view_menu->insertItem("Browse View", this, SLOT(browseViewSlot()));
88 view_menu->insertItem("List View", this, SLOT(listViewSlot())); 89 view_menu->insertItem("List View", this, SLOT(listViewSlot()));
89 menu->insertItem("View", view_menu); 90 menu->insertItem("View", view_menu);
90 91
91 QVBoxLayout *main_layout = new QVBoxLayout; 92 QVBoxLayout *main_layout = new QVBoxLayout;
92 93
93 /* Build tool bar */ 94 /* Build tool bar */
94 navigation = new QPEToolBar(this, "navigation"); 95 navigation = new QPEToolBar(this, "navigation");
95 QToolButton *newItemButton = new QToolButton( 96 QToolButton *newItemButton = new QToolButton(
96 QIconSet(Resource::loadPixmap("new")), "New Item", QString::null, 97 QIconSet(Resource::loadPixmap("new")), "New Item", QString::null,
97 this, SLOT(newItemSlot()), navigation, "New Item"); 98 this, SLOT(newItemSlot()), navigation, "New Item");
98 QToolButton *editItemButton = new QToolButton( 99 QToolButton *editItemButton = new QToolButton(
99 QIconSet(Resource::loadPixmap("edit")), "Edit Item", QString::null, 100 QIconSet(Resource::loadPixmap("edit")), "Edit Item", QString::null,
100 this, SLOT(editItemSlot()), navigation, "Edit Item"); 101 this, SLOT(editItemSlot()), navigation, "Edit Item");
101 QToolButton *deleteItemButton = new QToolButton( 102 QToolButton *deleteItemButton = new QToolButton(
102 QIconSet(Resource::loadPixmap("trash")), "Delete Item", 103 QIconSet(Resource::loadPixmap("trash")), "Delete Item",
103 QString::null, this, 104 QString::null, this,
104 SLOT(deleteItemSlot()), navigation, "Delete Item"); 105 SLOT(deleteItemSlot()), navigation, "Delete Item");
105 106
106 navigation->addSeparator(); 107 navigation->addSeparator();
107 108
108 QToolButton *firstItemButton = new QToolButton( 109 QToolButton *firstItemButton = new QToolButton(
109 QIconSet(Resource::loadPixmap("fastback")), "First Item", 110 QIconSet(Resource::loadPixmap("fastback")), "First Item",
110 QString::null, this, 111 QString::null, this,
111 SLOT(firstItem()), navigation, "First Item"); 112 SLOT(firstItem()), navigation, "First Item");
112 QToolButton *previousItemButton = new QToolButton( 113 QToolButton *previousItemButton = new QToolButton(
113 QIconSet(Resource::loadPixmap("back")), "Previous Item", 114 QIconSet(Resource::loadPixmap("back")), "Previous Item",
114 QString::null, this, 115 QString::null, this,
115 SLOT(previousItem()), navigation, "Previous Item"); 116 SLOT(previousItem()), navigation, "Previous Item");
116 QToolButton *nextItemButton = new QToolButton( 117 QToolButton *nextItemButton = new QToolButton(
117 QIconSet(Resource::loadPixmap("forward")), "Next Item", 118 QIconSet(Resource::loadPixmap("forward")), "Next Item",
118 QString::null, this, 119 QString::null, this,
119 SLOT(nextItem()), navigation, "Next Item"); 120 SLOT(nextItem()), navigation, "Next Item");
120 QToolButton *lastItemButton = new QToolButton( 121 QToolButton *lastItemButton = new QToolButton(
121 QIconSet(Resource::loadPixmap("fastforward")), "Last Item", 122 QIconSet(Resource::loadPixmap("fastforward")), "Last Item",
122 QString::null, this, 123 QString::null, this,
123 SLOT(lastItem()), navigation, "Last Item"); 124 SLOT(lastItem()), navigation, "Last Item");
124 125
125 navigation->addSeparator(); 126 navigation->addSeparator();
126 QToolButton *browseButton = new QToolButton( 127 QToolButton *browseButton = new QToolButton(
127 QIconSet(Resource::loadPixmap("day")), "View Single Item", 128 QIconSet(Resource::loadPixmap("day")), "View Single Item",
128 QString::null, this, 129 QString::null, this,
129 SLOT(browseViewSlot()), navigation, "View Single Item"); 130 SLOT(browseViewSlot()), navigation, "View Single Item");
130 QToolButton *listButton = new QToolButton( 131 QToolButton *listButton = new QToolButton(
131 QIconSet(Resource::loadPixmap("month")), "View Multiple Items", 132 QIconSet(Resource::loadPixmap("month")), "View Multiple Items",
132 QString::null, this, 133 QString::null, this,
@@ -141,247 +142,272 @@ TableViewerWindow::TableViewerWindow(QWidget *parent, const char *name, WFlags f
141 listView = new TVListView(&ts, this, 0); 142 listView = new TVListView(&ts, this, 0);
142 filterView = new TVFilterView(&ts, this, 0); 143 filterView = new TVFilterView(&ts, this, 0);
143 fileSelector = new FileSelector("text/csv;text/x-xml-tableviewer", 144 fileSelector = new FileSelector("text/csv;text/x-xml-tableviewer",
144 this, "fileselector"); 145 this, "fileselector");
145 fileSelector->setNewVisible(FALSE); 146 fileSelector->setNewVisible(FALSE);
146 fileSelector->setCloseVisible(FALSE); 147 fileSelector->setCloseVisible(FALSE);
147 148
148 cw = new QWidgetStack(this, 0); 149 cw = new QWidgetStack(this, 0);
149 cw->addWidget(listView, ListState); 150 cw->addWidget(listView, ListState);
150 cw->addWidget(browseView, BrowseState); 151 cw->addWidget(browseView, BrowseState);
151 cw->addWidget(filterView, FilterState); 152 cw->addWidget(filterView, FilterState);
152 cw->addWidget(fileSelector, FileState); 153 cw->addWidget(fileSelector, FileState);
153 154
154 current_view = FileState; 155 current_view = FileState;
155 cw->raiseWidget(current_view); 156 cw->raiseWidget(current_view);
156 fileSelector->reread(); 157 fileSelector->reread();
157 158
158 connect(browseView, SIGNAL(searchOnKey(int, TVVariant)), 159 connect(browseView, SIGNAL(searchOnKey(int, TVVariant)),
159 this, SLOT(searchOnKey(int, TVVariant))); 160 this, SLOT(searchOnKey(int, TVVariant)));
160 connect(browseView, SIGNAL(sortChanged(int)), 161 connect(browseView, SIGNAL(sortChanged(int)),
161 this, SLOT(setPrimaryKey(int))); 162 this, SLOT(setPrimaryKey(int)));
162 163
163 connect(fileSelector, SIGNAL(closeMe()), this, SLOT(browseViewSlot())); 164 connect(fileSelector, SIGNAL(closeMe()), this, SLOT(browseViewSlot()));
164 connect(fileSelector, SIGNAL(fileSelected(const DocLnk &)), 165 connect(fileSelector, SIGNAL(fileSelected(const DocLnk &)),
165 this, SLOT(openDocument(const DocLnk &))); 166 this, SLOT(openDocument(const DocLnk &)));
166 167
167 main_layout->addWidget(menu); 168 main_layout->addWidget(menu);
168 main_layout->addWidget(cw); 169 main_layout->addWidget(cw);
169 170
170 setCentralWidget(cw); 171 setCentralWidget(cw);
171 172
172} 173}
173 174
174/*! 175/*!
175 Destroys the TableViewerWindow 176 Destroys the TableViewerWindow
176*/ 177*/
177TableViewerWindow::~TableViewerWindow() 178TableViewerWindow::~TableViewerWindow()
178{ 179{
179 if(dirty) 180 if(dirty)
180 saveDocument(); 181 saveDocument();
181} 182}
182 183
183/*! 184/*!
184 Opens a file dialog and loads the file specified by the dialog 185 Opens a file dialog and loads the file specified by the dialog
185*/ 186*/
186void TableViewerWindow::selectDocument() 187void TableViewerWindow::selectDocument()
187{ 188{
188 if(dirty) 189 if(dirty)
189 saveDocument(); 190 saveDocument();
190 current_view = FileState; 191 current_view = FileState;
191 cw->raiseWidget(current_view); 192 cw->raiseWidget(current_view);
192 fileSelector->reread(); 193 fileSelector->reread();
193} 194}
194 195
195void TableViewerWindow::saveDocument() 196void TableViewerWindow::saveDocument()
196{ 197{
197 if(!dirty) 198 if(!dirty)
198 return; 199 return;
199 200
200 FileManager fm; 201 FileManager fm;
201 QIODevice *dev = fm.saveFile(doc); 202 QIODevice *dev = fm.saveFile(doc);
202 203
203 if(!ds->saveSource(dev, doc.type())){ 204 if(!ds->saveSource(dev, doc.type())){
204 qWarning("Save unsuccessful"); 205 qWarning("Save unsuccessful");
205 return; 206 return;
206 } 207 }
207 dev->close(); 208 dev->close();
208 dirty = FALSE; 209 dirty = FALSE;
209} 210}
210 211
211void TableViewerWindow::newDocument() 212void TableViewerWindow::newDocument()
212{ 213{
213 DocLnk nf; 214 DocLnk nf;
214 nf.setType("text/x-xml-tableviewer"); 215 nf.setType("text/x-xml-tableviewer");
215 nf.setName("table"); 216 nf.setName("table");
216 217
217 delete ds; 218 delete ds;
218 ds = new DBStore(); 219 ds = new DBStore();
219 220
220 ts.current_column = 0; 221 ts.current_column = 0;
221 ts.kRep = ds->getKeys(); 222 ts.kRep = ds->getKeys();
222 browseView->reset(); 223 browseView->reset();
223 listView->reset(); 224 listView->reset();
224 filterView->reset(); 225 filterView->reset();
225 226
226 doc = nf; 227 doc = nf;
227 dirty = FALSE; 228 dirty = FALSE;
228 229
229 current_view = BrowseState; 230 current_view = BrowseState;
230 cw->raiseWidget(current_view); 231 cw->raiseWidget(current_view);
231 232
232 /* now set up for editing the keys */ 233 /* now set up for editing the keys */
233 ts.kRep->addKey("key", TVVariant::String); 234 ts.kRep->addKey("key", TVVariant::String);
234 editKeysSlot(); 235 editKeysSlot();
235} 236}
236 237
238void TableViewerWindow::setDocument(const QString &f)
239{
240 openDocument(DocLnk(f, TRUE));
241}
242
237void TableViewerWindow::openDocument(const DocLnk &f) 243void TableViewerWindow::openDocument(const DocLnk &f)
238{ 244{
239 245
240 if (!f.isValid()) 246 if (!f.isValid())
241 return; 247 return;
242 248
243 FileManager fm; 249 FileManager fm;
244 QIODevice *dev = fm.openFile(f); 250 QIODevice *dev = fm.openFile(f);
245 doc = f; 251 doc = f;
246 252
247 if(ds->openSource(dev, doc.type())) { 253 if(ds->openSource(dev, doc.type())) {
248 DataElem *d; 254 DataElem *d;
249 255
250 browseView->reset(); 256 browseView->reset();
251 listView->reset(); 257 listView->reset();
252 filterView->reset(); 258 filterView->reset();
253 259
254 current_view = BrowseState; 260 current_view = BrowseState;
255 cw->raiseWidget(current_view); 261 cw->raiseWidget(current_view);
256 262
257 /* set up new table state and ensure sub widgets have a reference */ 263 /* set up new table state and ensure sub widgets have a reference */
258 ts.current_column = 0; 264 ts.current_column = 0;
259 ts.kRep = ds->getKeys(); 265 ts.kRep = ds->getKeys();
260 browseView->rebuildKeys(); 266 browseView->rebuildKeys();
261 listView->rebuildKeys(); 267 listView->rebuildKeys();
262 filterView->rebuildKeys(); 268 filterView->rebuildKeys();
263 269
264 ds->first(); 270 ds->first();
265 /* set up the list view */ 271 /* set up the list view */
266 listView->clearItems(); 272 listView->clearItems();
267 do { 273 do {
268 d = ds->getCurrentData(); 274 d = ds->getCurrentData();
269 if(d) 275 if(d)
270 listView->addItem(d); 276 listView->addItem(d);
271 } while(ds->next()); 277 } while(ds->next());
272 278
273 /* Set up browse view, Will be based of structure of listView */ 279 /* Set up browse view, Will be based of structure of listView */
274 listView->first(); 280 listView->first();
275 ts.current_elem = listView->getCurrentData(); 281 ts.current_elem = listView->getCurrentData();
276 browseView->rebuildData(); 282 browseView->rebuildData();
277 listView->rebuildData(); 283 listView->rebuildData();
278 284
279 QString scratch = "Table Viewer";/* later take from constant */ 285 QString scratch = "Table Viewer";/* later take from constant */
280 scratch += " - "; 286 scratch += " - ";
281 scratch += ds->getName(); 287 scratch += ds->getName();
282 setCaption(tr(scratch)); 288 setCaption(tr(scratch));
283 289
284 dirty = FALSE; 290 dirty = FALSE;
285 } else { 291 } else {
286 qWarning(tr("could not load Document")); 292 qWarning(tr("could not load Document"));
287 } 293 }
288 dev->close(); 294 dev->close();
289} 295}
290 296
291/*! 297/*!
298 Moves to the first item of the current table
299*/
300void TableViewerWindow::firstItem()
301{
302 listView->first();
303 ts.current_elem = listView->getCurrentData();
304 browseView->rebuildData();
305}
306
307/*!
308 Moves to the lat item of the current table
309*/
310void TableViewerWindow::lastItem()
311{
312 listView->last();
313 ts.current_elem = listView->getCurrentData();
314 browseView->rebuildData();
315}
316
317/*!
292 Moves to the next item of the current table 318 Moves to the next item of the current table
293*/ 319*/
294void TableViewerWindow::nextItem() 320void TableViewerWindow::nextItem()
295{ 321{
296 listView->next(); 322 listView->next();
297 ts.current_elem = listView->getCurrentData(); 323 ts.current_elem = listView->getCurrentData();
298 browseView->rebuildData(); 324 browseView->rebuildData();
299} 325}
300 326
301/*! 327/*!
302 Moves to the previous item of the current table 328 Moves to the previous item of the current table
303*/ 329*/
304void TableViewerWindow::previousItem() 330void TableViewerWindow::previousItem()
305{ 331{
306 listView->previous(); 332 listView->previous();
307 ts.current_elem = listView->getCurrentData(); 333 ts.current_elem = listView->getCurrentData();
308 browseView->rebuildData(); 334 browseView->rebuildData();
309} 335}
310 336
311/*! 337/*!
312 Raises the List View. This is a mode change for the application. 338 Raises the List View. This is a mode change for the application.
313*/ 339*/
314void TableViewerWindow::listViewSlot() 340void TableViewerWindow::listViewSlot()
315{ 341{
316 if(current_view == FilterState) 342 if(current_view == FilterState)
317 applyFilter(); 343 applyFilter();
318 current_view = ListState; 344 current_view = ListState;
319 cw->raiseWidget(current_view); 345 cw->raiseWidget(current_view);
320} 346}
321 347
322void TableViewerWindow::applyFilter() 348void TableViewerWindow::applyFilter()
323{ 349{
324 DataElem *d; 350 DataElem *d;
325 351
326 listView->clearItems(); 352 listView->clearItems();
327 ds->first(); 353 ds->first();
328 do { 354 do {
329 d = ds->getCurrentData(); 355 d = ds->getCurrentData();
330 if(d) 356 if(d)
331 if(filterView->passesFilter(d)) 357 if(filterView->passesFilter(d))
332 listView->addItem(d); 358 listView->addItem(d);
333 } while(ds->next()); 359 } while(ds->next());
334 listView->first(); 360 listView->first();
335 listView->rebuildData(); 361 listView->rebuildData();
336} 362}
337 363
338/*! 364/*!
339 Raises the Browse View. This is a mode change for the application. 365 Raises the Browse View. This is a mode change for the application.
340*/ 366*/
341void TableViewerWindow::browseViewSlot() 367void TableViewerWindow::browseViewSlot()
342{ 368{
343 if(current_view == FilterState) 369 if(current_view == FilterState)
344 applyFilter(); 370 applyFilter();
345 371
346 ts.current_elem = listView->getCurrentData(); 372 ts.current_elem = listView->getCurrentData();
347 browseView->rebuildData(); 373 browseView->rebuildData();
348 374
349 current_view = BrowseState; 375 current_view = BrowseState;
350 cw->raiseWidget(current_view); 376 cw->raiseWidget(current_view);
351} 377}
352 378
353/*! 379/*!
354 Raises the List View. This is a mode change for the application. 380 Raises the List View. This is a mode change for the application.
355*/ 381*/
356void TableViewerWindow::filterViewSlot() 382void TableViewerWindow::filterViewSlot()
357{ 383{
358 current_view = FilterState; 384 current_view = FilterState;
359 cw->raiseWidget(current_view); 385 cw->raiseWidget(current_view);
360} 386}
361 387
362 388
363 389
364 390
365void TableViewerWindow::editItemSlot() 391void TableViewerWindow::editItemSlot()
366{ 392{
367 if(TVEditView::openEditItemDialog(&ts, ts.current_elem, this)) { 393 if(TVEditView::openEditItemDialog(&ts, ts.current_elem, this)) {
368 listView->rebuildData(); 394 listView->rebuildData();
369 browseView->rebuildData(); 395 browseView->rebuildData();
370 dirty = TRUE; 396 dirty = TRUE;
371 } 397 }
372} 398}
373 399
374void TableViewerWindow::newItemSlot() 400void TableViewerWindow::newItemSlot()
375{ 401{
376 DataElem *d = new DataElem(ds); 402 DataElem *d = new DataElem(ds);
377 if (TVEditView::openEditItemDialog(&ts, d, this)) { 403 if (TVEditView::openEditItemDialog(&ts, d, this)) {
378 404
379 ds->addItem(d); 405 ds->addItem(d);
380 ts.current_elem = d; 406 ts.current_elem = d;
381 applyFilter(); 407 applyFilter();
382 listView->rebuildData(); 408 listView->rebuildData();
383 browseView->rebuildData(); 409 browseView->rebuildData();
384 dirty = TRUE; 410 dirty = TRUE;
385 } 411 }
386} 412}
387 413
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
@@ -1,109 +1,112 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef Tableviewer_H 20#ifndef Tableviewer_H
21#define Tableviewer_H 21#define Tableviewer_H
22 22
23#include <qmainwindow.h> 23#include <qmainwindow.h>
24#include "db/common.h" 24#include "db/common.h"
25#include <qpe/fileselector.h> 25#include <qpe/fileselector.h>
26 26
27/* Forward class declarations */ 27/* Forward class declarations */
28class QWidgetStack; 28class QWidgetStack;
29class QDialog; 29class QDialog;
30class QMenuBar; 30class QMenuBar;
31 31
32class TVListView; 32class TVListView;
33class TVBrowseView; 33class TVBrowseView;
34class TVFilterView; 34class TVFilterView;
35class TVEditView; 35class TVEditView;
36 36
37class DBStore; 37class DBStore;
38 38
39class TableViewerWindow: public QMainWindow 39class TableViewerWindow: public QMainWindow
40{ 40{
41 Q_OBJECT 41 Q_OBJECT
42public: 42public:
43 TableViewerWindow( QWidget *parent = 0, 43 TableViewerWindow( QWidget *parent = 0,
44 const char *name = 0, WFlags f = 0 ); 44 const char *name = 0, WFlags f = 0 );
45 ~TableViewerWindow(); 45 ~TableViewerWindow();
46 46
47public slots: 47public slots:
48 void selectDocument(); 48 void selectDocument();
49 49
50 void newDocument(); 50 void newDocument();
51 void saveDocument(); 51 void saveDocument();
52 void setDocument(const QString &);
52 void openDocument(const DocLnk &); 53 void openDocument(const DocLnk &);
53 54
55 void firstItem();
56 void lastItem();
54 void nextItem(); 57 void nextItem();
55 void previousItem(); 58 void previousItem();
56 59
57 void listViewSlot(); 60 void listViewSlot();
58 void browseViewSlot(); 61 void browseViewSlot();
59 void filterViewSlot(); 62 void filterViewSlot();
60 63
61 void editItemSlot(); 64 void editItemSlot();
62 void newItemSlot(); 65 void newItemSlot();
63 void deleteItemSlot(); 66 void deleteItemSlot();
64 67
65 void editKeysSlot(); 68 void editKeysSlot();
66 69
67 /* reveiw the sig. for this function TODO */ 70 /* reveiw the sig. for this function TODO */
68 void searchOnKey(int, TVVariant); 71 void searchOnKey(int, TVVariant);
69 void setPrimaryKey(int); 72 void setPrimaryKey(int);
70 73
71/* TODO add new event */ 74/* TODO add new event */
72protected: 75protected:
73 76
74/* TODO add new slots */ 77/* TODO add new slots */
75private slots: 78private slots:
76 79
77/* TODO add other widgets used here */ 80/* TODO add other widgets used here */
78private: 81private:
79 bool dirty; 82 bool dirty;
80 83
81 QMenuBar *menu; 84 QMenuBar *menu;
82 QToolBar *navigation; 85 QToolBar *navigation;
83 86
84 TVListView *listView; 87 TVListView *listView;
85 TVBrowseView *browseView; 88 TVBrowseView *browseView;
86 TVFilterView *filterView; 89 TVFilterView *filterView;
87 TVEditView *editView; 90 TVEditView *editView;
88 FileSelector *fileSelector; 91 FileSelector *fileSelector;
89 92
90 DocLnk doc; 93 DocLnk doc;
91 94
92 QWidgetStack *cw; 95 QWidgetStack *cw;
93 DBStore *ds; 96 DBStore *ds;
94 TableState ts; /* not a pointer.. this class keeps the state */ 97 TableState ts; /* not a pointer.. this class keeps the state */
95 98
96 enum UserState { 99 enum UserState {
97 BrowseState = 0, 100 BrowseState = 0,
98 ListState, 101 ListState,
99 FilterState, 102 FilterState,
100 EditState, 103 EditState,
101 FileState, 104 FileState,
102 }; 105 };
103 106
104 UserState current_view; 107 UserState current_view;
105 108
106 void applyFilter(); 109 void applyFilter();
107}; 110};
108 111
109#endif 112#endif