author | John Kern <johnk@symbian.org> |
Thu, 25 Mar 2010 16:49:34 -0700 | |
changeset 7 | 7ee47a65f1ad |
parent 3 | e6d1a78b6db9 |
child 10 | 79eeacfd15ff |
permissions | -rw-r--r-- |
3
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
1 |
#include <QFile> |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
2 |
#include <QIcon> |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
3 |
#include <QListWidget> |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
4 |
#include <QMessageBox> |
7 | 5 |
#include <QStackedWidget> |
3
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
6 |
#include <QTableWidget> |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
7 |
#include <QDesktopServices> |
7 | 8 |
#include <QWebView> |
3
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
9 |
|
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
10 |
#include "Fishes.h" |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
11 |
#include "mainwindow.h" |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
12 |
#include "ui_mainwindow.h" |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
13 |
|
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
14 |
|
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
15 |
MainWindow::MainWindow(QWidget *parent) : |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
16 |
QMainWindow(parent), |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
17 |
ui(new Ui::MainWindow) |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
18 |
{ |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
19 |
ui->setupUi(this); |
7 | 20 |
setContextMenuPolicy(Qt::NoContextMenu); |
3
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
21 |
Fishes *f = new Fishes(); |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
22 |
|
7 | 23 |
this->stackedWidget = new QStackedWidget; |
24 |
||
3
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
25 |
this->tabWidget = new QTabWidget; |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
26 |
// QIcon icon = new QIcon(":/database/icons/weather-sunny.svg"); |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
27 |
// this->tabWidget->setTabIcon(1, icon); |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
28 |
|
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
29 |
this->bestList = new QListWidget; |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
30 |
this->bestList->addItems(f->GetBest()); |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
31 |
this->tabWidget->addTab(this->bestList, "best"); |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
32 |
|
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
33 |
this->okList = new QListWidget; |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
34 |
this->okList->addItems(f->GetOK()); |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
35 |
this->tabWidget->addTab(this->okList, "ok"); |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
36 |
|
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
37 |
this->worstList = new QListWidget; |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
38 |
this->worstList->addItems(f->GetWorst()); |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
39 |
this->tabWidget->addTab(this->worstList, "worst"); |
7 | 40 |
|
41 |
this->stackedWidget->addWidget(tabWidget); // associated with EListPage |
|
42 |
||
43 |
this->ecoDetails = new QWebView; |
|
44 |
this->ecoDetails->setHtml("<html><title>Eco Details</title><ul><li>not yet implemented</li></ul></html>"); |
|
45 |
||
46 |
this->stackedWidget->addWidget(this->ecoDetails); // associated with EEcoPage |
|
47 |
||
48 |
this->stackedWidget->addWidget(ui->centralWidget); // associated with ENutritionPage |
|
49 |
||
50 |
setCentralWidget(stackedWidget); |
|
3
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
51 |
} |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
52 |
|
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
53 |
MainWindow::~MainWindow() |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
54 |
{ |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
55 |
delete ui; |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
56 |
} |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
57 |
|
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
58 |
void MainWindow::createMenus() |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
59 |
{ |
7 | 60 |
|
61 |
ecoAction = new QAction(tr("&eco details"),this); |
|
62 |
menuBar()->addAction(ecoAction); |
|
63 |
connect(ecoAction, SIGNAL(triggered()),this, SLOT(displayEcoDetails())); |
|
64 |
||
3
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
65 |
nuAction = new QAction(tr("&Nutrition"),this); |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
66 |
menuBar()->addAction(nuAction); |
7 | 67 |
connect(nuAction, SIGNAL(triggered()),this, SLOT(displayNutrition())); |
68 |
||
69 |
fishesAction = new QAction(tr("&List Fishes"),this); |
|
70 |
menuBar()->addAction(fishesAction); |
|
71 |
connect(fishesAction, SIGNAL(triggered()),this, SLOT(displayList())); |
|
3
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
72 |
|
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
73 |
verAction = new QAction(tr("&Version"),this); |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
74 |
menuBar()->addAction(verAction); |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
75 |
connect(verAction, SIGNAL(triggered()),this, SLOT(displayVersion())); |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
76 |
|
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
77 |
exitAction = new QAction(tr("&Exit"),this); |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
78 |
menuBar()->addAction(exitAction); |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
79 |
connect(exitAction, SIGNAL(triggered()),this, SLOT(close())); |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
80 |
} |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
81 |
|
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
82 |
void MainWindow::displayVersion() |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
83 |
{ |
7 | 84 |
// QMessageBox::information(this,"Qt Version", qVersion()); |
85 |
QMessageBox::information(this,"selected item", "NYI"); |
|
86 |
} |
|
87 |
||
88 |
void MainWindow::displayNutrition() |
|
89 |
{ |
|
90 |
this->stackedWidget->setCurrentIndex(MainWindow::ENutritionPage); |
|
91 |
} |
|
92 |
||
93 |
void MainWindow::displayEcoDetails() |
|
94 |
{ |
|
95 |
this->stackedWidget->setCurrentIndex(MainWindow::EEcoPage); |
|
96 |
} |
|
97 |
||
98 |
void MainWindow::displayList() |
|
99 |
{ |
|
100 |
this->stackedWidget->setCurrentIndex(MainWindow::EListPage); |
|
3
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
101 |
} |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
102 |
|
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
103 |
void MainWindow::displayPath() |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
104 |
{ |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
105 |
QString dbFile = QDesktopServices::storageLocation(QDesktopServices::DataLocation) |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
106 |
+ '/' // Qt Universal file separator |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
107 |
+ "seafood.db"; |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
108 |
QFile f(dbFile); |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
109 |
if (f.exists()) { |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
110 |
QMessageBox::information(this,"db not found ", dbFile); |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
111 |
} else { |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
112 |
QMessageBox::information(this,"found db @ ", dbFile); |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
113 |
} |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
114 |
|
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
115 |
} |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
116 |
|
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
117 |
void MainWindow::changeEvent(QEvent *e) |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
118 |
{ |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
119 |
QMainWindow::changeEvent(e); |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
120 |
switch (e->type()) { |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
121 |
case QEvent::LanguageChange: |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
122 |
ui->retranslateUi(this); |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
123 |
break; |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
124 |
default: |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
125 |
break; |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
126 |
} |
e6d1a78b6db9
wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff
changeset
|
127 |
} |