summaryrefslogtreecommitdiff
path: root/noncore/apps/tableviewer/tableviewer.cpp
authorllornkcor <llornkcor>2002-03-09 20:00:31 (UTC)
committer llornkcor <llornkcor>2002-03-09 20:00:31 (UTC)
commit767f33638631d29bca260aab66c1224ab2108af7 (patch) (unidiff)
treee8c66841e18a4f106e0650e1e29d21e706bcef14 /noncore/apps/tableviewer/tableviewer.cpp
parent3095bf47c523afcf5441057db23050767f69ebf9 (diff)
downloadopie-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
Diffstat (limited to 'noncore/apps/tableviewer/tableviewer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/tableviewer/tableviewer.cpp116
1 files changed, 58 insertions, 58 deletions
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
@@ -25,23 +25,23 @@
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 "fileselector.h" 31#include <qpe/fileselector.h>
32#include "resource.h" 32#include <qpe/resource.h>
33#include <qpe/qpetoolbar.h>
33 34
34/* QTE includes */ 35/* QTE includes */
35#include <qpe/qpemenubar.h> 36#include <qpe/qpemenubar.h>
36#include <qpopupmenu.h> 37#include <qpopupmenu.h>
37#include <qapplication.h> 38#include <qapplication.h>
38#include <qwidgetstack.h> 39#include <qwidgetstack.h>
39#include <qlayout.h> 40#include <qlayout.h>
40#include <qbuffer.h> 41#include <qbuffer.h>
41
42/*! 42/*!
43 \class TableViewerWindow 43 \class TableViewerWindow
44 \brief The main window widget of the application 44 \brief The main window widget of the application
45 45
46 This is the main widget of the table viewer application. 46 This is the main widget of the table viewer application.
47 It is the co-ordination point. 47 It is the co-ordination point.
@@ -90,61 +90,61 @@ TableViewerWindow::TableViewerWindow(QWidget *parent, const char *name, WFlags f
90 90
91 QVBoxLayout *main_layout = new QVBoxLayout; 91 QVBoxLayout *main_layout = new QVBoxLayout;
92 92
93 /* Build tool bar */ 93 /* Build tool bar */
94 navigation = new QPEToolBar(this, "navigation"); 94 navigation = new QPEToolBar(this, "navigation");
95 QToolButton *newItemButton = new QToolButton( 95 QToolButton *newItemButton = new QToolButton(
96 QIconSet(Resource::loadImage("new")), "New Item", QString::null, 96 QIconSet(Resource::loadPixmap("new")), "New Item", QString::null,
97 this, SLOT(newItemSlot()), navigation, "New Item"); 97 this, SLOT(newItemSlot()), navigation, "New Item");
98 QToolButton *editItemButton = new QToolButton( 98 QToolButton *editItemButton = new QToolButton(
99 QIconSet(Resource::loadImage("edit")), "Edit Item", QString::null, 99 QIconSet(Resource::loadPixmap("edit")), "Edit Item", QString::null,
100 this, SLOT(editItemSlot()), navigation, "Edit Item"); 100 this, SLOT(editItemSlot()), navigation, "Edit Item");
101 QToolButton *deleteItemButton = new QToolButton( 101 QToolButton *deleteItemButton = new QToolButton(
102 QIconSet(Resource::loadImage("trash")), "Delete Item", 102 QIconSet(Resource::loadPixmap("trash")), "Delete Item",
103 QString::null, this, 103 QString::null, this,
104 SLOT(deleteItemSlot()), navigation, "Delete Item"); 104 SLOT(deleteItemSlot()), navigation, "Delete Item");
105 105
106 navigation->addSeparator(); 106 navigation->addSeparator();
107 107
108 QToolButton *firstItemButton = new QToolButton( 108 QToolButton *firstItemButton = new QToolButton(
109 QIconSet(Resource::loadImage("fastback")), "First Item", 109 QIconSet(Resource::loadPixmap("fastback")), "First Item",
110 QString::null, this, 110 QString::null, this,
111 SLOT(firstItem()), navigation, "First Item"); 111 SLOT(firstItem()), navigation, "First Item");
112 QToolButton *previousItemButton = new QToolButton( 112 QToolButton *previousItemButton = new QToolButton(
113 QIconSet(Resource::loadImage("back")), "Previous Item", 113 QIconSet(Resource::loadPixmap("back")), "Previous Item",
114 QString::null, this, 114 QString::null, this,
115 SLOT(previousItem()), navigation, "Previous Item"); 115 SLOT(previousItem()), navigation, "Previous Item");
116 QToolButton *nextItemButton = new QToolButton( 116 QToolButton *nextItemButton = new QToolButton(
117 QIconSet(Resource::loadImage("forward")), "Next Item", 117 QIconSet(Resource::loadPixmap("forward")), "Next Item",
118 QString::null, this, 118 QString::null, this,
119 SLOT(nextItem()), navigation, "Next Item"); 119 SLOT(nextItem()), navigation, "Next Item");
120 QToolButton *lastItemButton = new QToolButton( 120 QToolButton *lastItemButton = new QToolButton(
121 QIconSet(Resource::loadImage("fastforward")), "Last Item", 121 QIconSet(Resource::loadPixmap("fastforward")), "Last Item",
122 QString::null, this, 122 QString::null, this,
123 SLOT(lastItem()), navigation, "Last Item"); 123 SLOT(lastItem()), navigation, "Last Item");
124 124
125 navigation->addSeparator(); 125 navigation->addSeparator();
126 QToolButton *browseButton = new QToolButton( 126 QToolButton *browseButton = new QToolButton(
127 QIconSet(Resource::loadImage("day")), "View Single Item", 127 QIconSet(Resource::loadPixmap("day")), "View Single Item",
128 QString::null, this, 128 QString::null, this,
129 SLOT(browseViewSlot()), navigation, "View Single Item"); 129 SLOT(browseViewSlot()), navigation, "View Single Item");
130 QToolButton *listButton = new QToolButton( 130 QToolButton *listButton = new QToolButton(
131 QIconSet(Resource::loadImage("month")), "View Multiple Items", 131 QIconSet(Resource::loadPixmap("month")), "View Multiple Items",
132 QString::null, this, 132 QString::null, this,
133 SLOT(listViewSlot()), navigation, "View Multiple Items"); 133 SLOT(listViewSlot()), navigation, "View Multiple Items");
134 134
135 setToolBarsMovable(FALSE); 135 setToolBarsMovable(FALSE);
136 setToolBarsMovable(FALSE); 136 setToolBarsMovable(FALSE);
137 setToolBarsMovable(FALSE); 137 setToolBarsMovable(FALSE);
138 138
139/* Build widgets */ 139/* Build widgets */
140 browseView = new TVBrowseView(&ts, this, 0); 140 browseView = new TVBrowseView(&ts, this, 0);
141 listView = new TVListView(&ts, this, 0); 141 listView = new TVListView(&ts, this, 0);
142 filterView = new TVFilterView(&ts, this, 0); 142 filterView = new TVFilterView(&ts, this, 0);
143 fileSelector = new FileSelector("text/csv;text/x-xml-tableviewer", 143 fileSelector = new FileSelector("text/csv;text/x-xml-tableviewer",
144 this, "fileselector"); 144 this, "fileselector");
145 fileSelector->setNewVisible(FALSE); 145 fileSelector->setNewVisible(FALSE);
146 fileSelector->setCloseVisible(FALSE); 146 fileSelector->setCloseVisible(FALSE);
147 147
148 cw = new QWidgetStack(this, 0); 148 cw = new QWidgetStack(this, 0);
149 cw->addWidget(listView, ListState); 149 cw->addWidget(listView, ListState);
150 cw->addWidget(browseView, BrowseState); 150 cw->addWidget(browseView, BrowseState);
@@ -159,13 +159,13 @@ TableViewerWindow::TableViewerWindow(QWidget *parent, const char *name, WFlags f
159 this, SLOT(searchOnKey(int, TVVariant))); 159 this, SLOT(searchOnKey(int, TVVariant)));
160 connect(browseView, SIGNAL(sortChanged(int)), 160 connect(browseView, SIGNAL(sortChanged(int)),
161 this, SLOT(setPrimaryKey(int))); 161 this, SLOT(setPrimaryKey(int)));
162 162
163 connect(fileSelector, SIGNAL(closeMe()), this, SLOT(browseViewSlot())); 163 connect(fileSelector, SIGNAL(closeMe()), this, SLOT(browseViewSlot()));
164 connect(fileSelector, SIGNAL(fileSelected(const DocLnk &)), 164 connect(fileSelector, SIGNAL(fileSelected(const DocLnk &)),
165 this, SLOT(openDocument(const DocLnk &))); 165 this, SLOT(openDocument(const DocLnk &)));
166 166
167 main_layout->addWidget(menu); 167 main_layout->addWidget(menu);
168 main_layout->addWidget(cw); 168 main_layout->addWidget(cw);
169 169
170 setCentralWidget(cw); 170 setCentralWidget(cw);
171 171
@@ -174,38 +174,38 @@ TableViewerWindow::TableViewerWindow(QWidget *parent, const char *name, WFlags f
174/*! 174/*!
175 Destroys the TableViewerWindow 175 Destroys the TableViewerWindow
176*/ 176*/
177TableViewerWindow::~TableViewerWindow() 177TableViewerWindow::~TableViewerWindow()
178{ 178{
179 if(dirty) 179 if(dirty)
180 saveDocument(); 180 saveDocument();
181} 181}
182 182
183/*! 183/*!
184 Opens a file dialog and loads the file specified by the dialog 184 Opens a file dialog and loads the file specified by the dialog
185*/ 185*/
186void TableViewerWindow::selectDocument() 186void TableViewerWindow::selectDocument()
187{ 187{
188 if(dirty) 188 if(dirty)
189 saveDocument(); 189 saveDocument();
190 current_view = FileState; 190 current_view = FileState;
191 cw->raiseWidget(current_view); 191 cw->raiseWidget(current_view);
192 fileSelector->reread(); 192 fileSelector->reread();
193} 193}
194 194
195void TableViewerWindow::saveDocument() 195void TableViewerWindow::saveDocument()
196{ 196{
197 if(!dirty) 197 if(!dirty)
198 return; 198 return;
199 199
200 FileManager fm; 200 FileManager fm;
201 QIODevice *dev = fm.saveFile(doc); 201 QIODevice *dev = fm.saveFile(doc);
202 202
203 if(!ds->saveSource(dev, doc.type())){ 203 if(!ds->saveSource(dev, doc.type())){
204 qWarning("Save unsuccessful"); 204 qWarning("Save unsuccessful");
205 return; 205 return;
206 } 206 }
207 dev->close(); 207 dev->close();
208 dirty = FALSE; 208 dirty = FALSE;
209} 209}
210 210
211void TableViewerWindow::newDocument() 211void TableViewerWindow::newDocument()
@@ -226,36 +226,36 @@ void TableViewerWindow::newDocument()
226 doc = nf; 226 doc = nf;
227 dirty = FALSE; 227 dirty = FALSE;
228 228
229 current_view = BrowseState; 229 current_view = BrowseState;
230 cw->raiseWidget(current_view); 230 cw->raiseWidget(current_view);
231 231
232 /* now set up for editing the keys */ 232 /* now set up for editing the keys */
233 ts.kRep->addKey("key", TVVariant::String); 233 ts.kRep->addKey("key", TVVariant::String);
234 editKeysSlot(); 234 editKeysSlot();
235} 235}
236 236
237void TableViewerWindow::openDocument(const DocLnk &f) 237void TableViewerWindow::openDocument(const DocLnk &f)
238{ 238{
239 239
240 if (!f.isValid()) 240 if (!f.isValid())
241 return; 241 return;
242 242
243 FileManager fm; 243 FileManager fm;
244 QIODevice *dev = fm.openFile(f); 244 QIODevice *dev = fm.openFile(f);
245 doc = f; 245 doc = f;
246 246
247 if(ds->openSource(dev, doc.type())) { 247 if(ds->openSource(dev, doc.type())) {
248 DataElem *d; 248 DataElem *d;
249 249
250 browseView->reset(); 250 browseView->reset();
251 listView->reset(); 251 listView->reset();
252 filterView->reset(); 252 filterView->reset();
253 253
254 current_view = BrowseState; 254 current_view = BrowseState;
255 cw->raiseWidget(current_view); 255 cw->raiseWidget(current_view);
256 256
257 /* set up new table state and ensure sub widgets have a reference */ 257 /* set up new table state and ensure sub widgets have a reference */
258 ts.current_column = 0; 258 ts.current_column = 0;
259 ts.kRep = ds->getKeys(); 259 ts.kRep = ds->getKeys();
260 browseView->rebuildKeys(); 260 browseView->rebuildKeys();
261 listView->rebuildKeys(); 261 listView->rebuildKeys();
@@ -278,13 +278,13 @@ void TableViewerWindow::openDocument(const DocLnk &f)
278 278
279 QString scratch = "Table Viewer";/* later take from constant */ 279 QString scratch = "Table Viewer";/* later take from constant */
280 scratch += " - "; 280 scratch += " - ";
281 scratch += ds->getName(); 281 scratch += ds->getName();
282 setCaption(tr(scratch)); 282 setCaption(tr(scratch));
283 283
284 dirty = FALSE; 284 dirty = FALSE;
285 } else { 285 } else {
286 qWarning(tr("could not load Document")); 286 qWarning(tr("could not load Document"));
287 } 287 }
288 dev->close(); 288 dev->close();
289} 289}
290 290
@@ -326,13 +326,13 @@ void TableViewerWindow::applyFilter()
326 listView->clearItems(); 326 listView->clearItems();
327 ds->first(); 327 ds->first();
328 do { 328 do {
329 d = ds->getCurrentData(); 329 d = ds->getCurrentData();
330 if(d) 330 if(d)
331 if(filterView->passesFilter(d)) 331 if(filterView->passesFilter(d))
332 listView->addItem(d); 332 listView->addItem(d);
333 } while(ds->next()); 333 } while(ds->next());
334 listView->first(); 334 listView->first();
335 listView->rebuildData(); 335 listView->rebuildData();
336} 336}
337 337
338/*! 338/*!
@@ -362,42 +362,42 @@ void TableViewerWindow::filterViewSlot()
362 362
363 363
364 364
365void TableViewerWindow::editItemSlot() 365void TableViewerWindow::editItemSlot()
366{ 366{
367 if(TVEditView::openEditItemDialog(&ts, ts.current_elem, this)) { 367 if(TVEditView::openEditItemDialog(&ts, ts.current_elem, this)) {
368 listView->rebuildData(); 368 listView->rebuildData();
369 browseView->rebuildData(); 369 browseView->rebuildData();
370 dirty = TRUE; 370 dirty = TRUE;
371 } 371 }
372} 372}
373 373
374void TableViewerWindow::newItemSlot() 374void TableViewerWindow::newItemSlot()
375{ 375{
376 DataElem *d = new DataElem(ds); 376 DataElem *d = new DataElem(ds);
377 if (TVEditView::openEditItemDialog(&ts, d, this)) { 377 if (TVEditView::openEditItemDialog(&ts, d, this)) {
378 378
379 ds->addItem(d); 379 ds->addItem(d);
380 ts.current_elem = d; 380 ts.current_elem = d;
381 applyFilter(); 381 applyFilter();
382 listView->rebuildData(); 382 listView->rebuildData();
383 browseView->rebuildData(); 383 browseView->rebuildData();
384 dirty = TRUE; 384 dirty = TRUE;
385 } 385 }
386} 386}
387 387
388void TableViewerWindow::deleteItemSlot() 388void TableViewerWindow::deleteItemSlot()
389{ 389{
390 /* delete the actual item, then do a 'filter' */ 390 /* delete the actual item, then do a 'filter' */
391 DataElem *to_remove = ts.current_elem; 391 DataElem *to_remove = ts.current_elem;
392 392
393 if(!to_remove) 393 if(!to_remove)
394 return; 394 return;
395 395
396 listView->removeItem(); 396 listView->removeItem();
397 ds->removeItem(to_remove); 397 ds->removeItem(to_remove);
398 398
399 applyFilter(); 399 applyFilter();
400 listView->rebuildData(); 400 listView->rebuildData();
401 browseView->rebuildData(); 401 browseView->rebuildData();
402 dirty = TRUE; 402 dirty = TRUE;
403} 403}
@@ -429,13 +429,13 @@ void TableViewerWindow::editKeysSlot()
429 d = ds->getCurrentData(); 429 d = ds->getCurrentData();
430 if(d) 430 if(d)
431 listView->addItem(d); 431 listView->addItem(d);
432 } while(ds->next()); 432 } while(ds->next());
433 433
434 /* Set up browse view, Will be based of structure of listView */ 434 /* Set up browse view, Will be based of structure of listView */
435 dirty = TRUE; 435 dirty = TRUE;
436 } 436 }
437} 437}
438 438
439/*! 439/*!
440 A Slot that allows for widgets above to indicate a search should be 440 A Slot that allows for widgets above to indicate a search should be
441 done on a specified key index for a specified value 441 done on a specified key index for a specified value