Diffstat (limited to 'noncore/apps/tableviewer/tableviewer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/tableviewer/tableviewer.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
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 | |||
@@ -1,65 +1,67 @@ | |||
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 */ | ||
22 | #include "tableviewer.h" | 21 | #include "tableviewer.h" |
23 | #include "ui/tvbrowseview.h" | 22 | #include "ui/tvbrowseview.h" |
24 | #include "ui/tvfilterview.h" | 23 | #include "ui/tvfilterview.h" |
25 | #include "ui/tvlistview.h" | 24 | #include "ui/tvlistview.h" |
26 | #include "ui/tveditview.h" | 25 | #include "ui/tveditview.h" |
27 | #include "ui/tvkeyedit.h" | 26 | #include "ui/tvkeyedit.h" |
28 | #include "db/datacache.h" | 27 | #include "db/datacache.h" |
29 | 28 | ||
30 | /* QPE includes */ | 29 | /* OPIE */ |
30 | #include <opie2/odebug.h> | ||
31 | #include <qpe/fileselector.h> | 31 | #include <qpe/fileselector.h> |
32 | #include <qpe/resource.h> | 32 | #include <qpe/resource.h> |
33 | #include <qtoolbar.h> | 33 | using namespace Opie::Core; |
34 | 34 | ||
35 | /* QTE includes */ | 35 | /* QT */ |
36 | #include <qmenubar.h> | 36 | #include <qmenubar.h> |
37 | #include <qtoolbar.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> |
43 | |||
42 | /*! | 44 | /*! |
43 | \class TableViewerWindow | 45 | \class TableViewerWindow |
44 | \brief The main window widget of the application | 46 | \brief The main window widget of the application |
45 | 47 | ||
46 | This is the main widget of the table viewer application. | 48 | This is the main widget of the table viewer application. |
47 | It is the co-ordination point. | 49 | It is the co-ordination point. |
48 | */ | 50 | */ |
49 | 51 | ||
50 | /*! | 52 | /*! |
51 | Constructs a new TableViewerWindow | 53 | Constructs a new TableViewerWindow |
52 | */ | 54 | */ |
53 | TableViewerWindow::TableViewerWindow(QWidget *parent, const char *name, WFlags f) | 55 | TableViewerWindow::TableViewerWindow(QWidget *parent, const char *name, WFlags f) |
54 | : QMainWindow(parent, name, f) | 56 | : QMainWindow(parent, name, f) |
55 | { | 57 | { |
56 | setCaption(tr("Table Viewer")); | 58 | setCaption(tr("Table Viewer")); |
57 | 59 | ||
58 | /* Build data */ | 60 | /* Build data */ |
59 | ds = new DBStore(); | 61 | ds = new DBStore(); |
60 | doc.setType("text/x-xml-tableviewer"); | 62 | doc.setType("text/x-xml-tableviewer"); |
61 | doc.setName("table"); | 63 | doc.setName("table"); |
62 | 64 | ||
63 | dirty = FALSE; | 65 | dirty = FALSE; |
64 | ts.current_column = 0; | 66 | ts.current_column = 0; |
65 | ts.kRep = ds->getKeys(); | 67 | ts.kRep = ds->getKeys(); |
@@ -180,49 +182,49 @@ TableViewerWindow::~TableViewerWindow() | |||
180 | saveDocument(); | 182 | saveDocument(); |
181 | } | 183 | } |
182 | 184 | ||
183 | /*! | 185 | /*! |
184 | Opens a file dialog and loads the file specified by the dialog | 186 | Opens a file dialog and loads the file specified by the dialog |
185 | */ | 187 | */ |
186 | void TableViewerWindow::selectDocument() | 188 | void TableViewerWindow::selectDocument() |
187 | { | 189 | { |
188 | if(dirty) | 190 | if(dirty) |
189 | saveDocument(); | 191 | saveDocument(); |
190 | current_view = FileState; | 192 | current_view = FileState; |
191 | cw->raiseWidget(current_view); | 193 | cw->raiseWidget(current_view); |
192 | fileSelector->reread(); | 194 | fileSelector->reread(); |
193 | } | 195 | } |
194 | 196 | ||
195 | void TableViewerWindow::saveDocument() | 197 | void TableViewerWindow::saveDocument() |
196 | { | 198 | { |
197 | if(!dirty) | 199 | if(!dirty) |
198 | return; | 200 | return; |
199 | 201 | ||
200 | FileManager fm; | 202 | FileManager fm; |
201 | QIODevice *dev = fm.saveFile(doc); | 203 | QIODevice *dev = fm.saveFile(doc); |
202 | 204 | ||
203 | if(!ds->saveSource(dev, doc.type())){ | 205 | if(!ds->saveSource(dev, doc.type())){ |
204 | qWarning("Save unsuccessful"); | 206 | owarn << "Save unsuccessful" << oendl; |
205 | return; | 207 | return; |
206 | } | 208 | } |
207 | dev->close(); | 209 | dev->close(); |
208 | dirty = FALSE; | 210 | dirty = FALSE; |
209 | } | 211 | } |
210 | 212 | ||
211 | void TableViewerWindow::newDocument() | 213 | void TableViewerWindow::newDocument() |
212 | { | 214 | { |
213 | DocLnk nf; | 215 | DocLnk nf; |
214 | nf.setType("text/x-xml-tableviewer"); | 216 | nf.setType("text/x-xml-tableviewer"); |
215 | nf.setName("table"); | 217 | nf.setName("table"); |
216 | 218 | ||
217 | delete ds; | 219 | delete ds; |
218 | ds = new DBStore(); | 220 | ds = new DBStore(); |
219 | 221 | ||
220 | ts.current_column = 0; | 222 | ts.current_column = 0; |
221 | ts.kRep = ds->getKeys(); | 223 | ts.kRep = ds->getKeys(); |
222 | browseView->reset(); | 224 | browseView->reset(); |
223 | listView->reset(); | 225 | listView->reset(); |
224 | filterView->reset(); | 226 | filterView->reset(); |
225 | 227 | ||
226 | doc = nf; | 228 | doc = nf; |
227 | dirty = FALSE; | 229 | dirty = FALSE; |
228 | 230 | ||
@@ -267,49 +269,49 @@ void TableViewerWindow::openDocument(const DocLnk &f) | |||
267 | filterView->rebuildKeys(); | 269 | filterView->rebuildKeys(); |
268 | 270 | ||
269 | ds->first(); | 271 | ds->first(); |
270 | /* set up the list view */ | 272 | /* set up the list view */ |
271 | listView->clearItems(); | 273 | listView->clearItems(); |
272 | do { | 274 | do { |
273 | d = ds->getCurrentData(); | 275 | d = ds->getCurrentData(); |
274 | if(d) | 276 | if(d) |
275 | listView->addItem(d); | 277 | listView->addItem(d); |
276 | } while(ds->next()); | 278 | } while(ds->next()); |
277 | 279 | ||
278 | /* Set up browse view, Will be based of structure of listView */ | 280 | /* Set up browse view, Will be based of structure of listView */ |
279 | listView->first(); | 281 | listView->first(); |
280 | ts.current_elem = listView->getCurrentData(); | 282 | ts.current_elem = listView->getCurrentData(); |
281 | browseView->rebuildData(); | 283 | browseView->rebuildData(); |
282 | listView->rebuildData(); | 284 | listView->rebuildData(); |
283 | 285 | ||
284 | QString scratch = "Table Viewer";/* later take from constant */ | 286 | QString scratch = "Table Viewer";/* later take from constant */ |
285 | scratch += " - "; | 287 | scratch += " - "; |
286 | scratch += ds->getName(); | 288 | scratch += ds->getName(); |
287 | setCaption(tr(scratch)); | 289 | setCaption(tr(scratch)); |
288 | 290 | ||
289 | dirty = FALSE; | 291 | dirty = FALSE; |
290 | } else { | 292 | } else { |
291 | qWarning(tr("could not load Document")); | 293 | owarn << tr("could not load Document") << oendl; |
292 | } | 294 | } |
293 | dev->close(); | 295 | dev->close(); |
294 | } | 296 | } |
295 | 297 | ||
296 | /*! | 298 | /*! |
297 | Moves to the first item of the current table | 299 | Moves to the first item of the current table |
298 | */ | 300 | */ |
299 | void TableViewerWindow::firstItem() | 301 | void TableViewerWindow::firstItem() |
300 | { | 302 | { |
301 | listView->first(); | 303 | listView->first(); |
302 | ts.current_elem = listView->getCurrentData(); | 304 | ts.current_elem = listView->getCurrentData(); |
303 | browseView->rebuildData(); | 305 | browseView->rebuildData(); |
304 | } | 306 | } |
305 | 307 | ||
306 | /*! | 308 | /*! |
307 | Moves to the lat item of the current table | 309 | Moves to the lat item of the current table |
308 | */ | 310 | */ |
309 | void TableViewerWindow::lastItem() | 311 | void TableViewerWindow::lastItem() |
310 | { | 312 | { |
311 | listView->last(); | 313 | listView->last(); |
312 | ts.current_elem = listView->getCurrentData(); | 314 | ts.current_elem = listView->getCurrentData(); |
313 | browseView->rebuildData(); | 315 | browseView->rebuildData(); |
314 | } | 316 | } |
315 | 317 | ||