16 QMainWindow(parent), |
16 QMainWindow(parent), |
17 ui(new Ui::MainWindow) |
17 ui(new Ui::MainWindow) |
18 { |
18 { |
19 ui->setupUi(this); |
19 ui->setupUi(this); |
20 setContextMenuPolicy(Qt::NoContextMenu); |
20 setContextMenuPolicy(Qt::NoContextMenu); |
21 Fishes *f = new Fishes(); |
21 this->fishDb = new Fishes(this); |
22 |
22 |
23 this->stackedWidget = new QStackedWidget; |
23 this->stackedWidget = new QStackedWidget; |
24 |
24 |
|
25 // lists of fish |
25 this->tabWidget = new QTabWidget; |
26 this->tabWidget = new QTabWidget; |
26 // QIcon icon = new QIcon(":/database/icons/weather-sunny.svg"); |
|
27 // this->tabWidget->setTabIcon(1, icon); |
|
28 |
27 |
29 this->bestList = new QListWidget; |
28 this->bestList = new QListWidget; |
30 this->bestList->addItems(f->GetBest()); |
29 this->bestList->addItems(this->fishDb->GetBest()); |
31 this->tabWidget->addTab(this->bestList, "best"); |
30 this->tabWidget->addTab(this->bestList, "best"); |
32 |
31 |
33 this->okList = new QListWidget; |
32 this->okList = new QListWidget; |
34 this->okList->addItems(f->GetOK()); |
33 this->okList->addItems(this->fishDb->GetOK()); |
35 this->tabWidget->addTab(this->okList, "ok"); |
34 this->tabWidget->addTab(this->okList, "ok"); |
36 |
35 |
37 this->worstList = new QListWidget; |
36 this->worstList = new QListWidget; |
38 this->worstList->addItems(f->GetWorst()); |
37 this->worstList->addItems(this->fishDb->GetWorst()); |
39 this->tabWidget->addTab(this->worstList, "worst"); |
38 this->tabWidget->addTab(this->worstList, "worst"); |
40 |
39 |
|
40 this->index = EBestList; |
|
41 |
|
42 connect(this->tabWidget, SIGNAL(currentChanged(int)), |
|
43 this, SLOT(setCurrentList(int))); |
|
44 |
41 this->stackedWidget->addWidget(tabWidget); // associated with EListPage |
45 this->stackedWidget->addWidget(tabWidget); // associated with EListPage |
|
46 |
|
47 // Eco details |
42 |
48 |
43 this->ecoDetails = new QWebView; |
49 this->ecoDetails = new QWebView; |
44 this->ecoDetails->setHtml("<html><title>Eco Details</title><ul><li>not yet implemented</li></ul></html>"); |
50 this->ecoDetails->setHtml("<html><title>Eco Details</title><ul><li>not yet implemented</li></ul></html>"); |
45 |
51 |
46 this->stackedWidget->addWidget(this->ecoDetails); // associated with EEcoPage |
52 this->stackedWidget->addWidget(this->ecoDetails); // associated with EEcoPage |
47 |
53 |
|
54 // Nutrition page |
|
55 // this->model = new QSqlQueryModel; |
|
56 // this->model-> |
48 this->stackedWidget->addWidget(ui->centralWidget); // associated with ENutritionPage |
57 this->stackedWidget->addWidget(ui->centralWidget); // associated with ENutritionPage |
49 |
58 |
|
59 |
50 setCentralWidget(stackedWidget); |
60 setCentralWidget(stackedWidget); |
|
61 |
|
62 |
51 } |
63 } |
52 |
64 |
53 MainWindow::~MainWindow() |
65 MainWindow::~MainWindow() |
54 { |
66 { |
55 delete ui; |
67 delete ui; |
79 connect(exitAction, SIGNAL(triggered()),this, SLOT(close())); |
91 connect(exitAction, SIGNAL(triggered()),this, SLOT(close())); |
80 } |
92 } |
81 |
93 |
82 void MainWindow::displayVersion() |
94 void MainWindow::displayVersion() |
83 { |
95 { |
84 // QMessageBox::information(this,"Qt Version", qVersion()); |
96 QMessageBox::information(this,"Qt Version", qVersion()); |
85 QMessageBox::information(this,"selected item", "NYI"); |
|
86 } |
97 } |
87 |
98 |
88 void MainWindow::displayNutrition() |
99 void MainWindow::displayNutrition() |
89 { |
100 { |
90 this->stackedWidget->setCurrentIndex(MainWindow::ENutritionPage); |
101 this->stackedWidget->setCurrentIndex(MainWindow::ENutritionPage); |
91 } |
102 } |
92 |
103 |
93 void MainWindow::displayEcoDetails() |
104 void MainWindow::displayEcoDetails() |
94 { |
105 { |
|
106 |
|
107 QString selectedName; |
|
108 switch (this->index) |
|
109 { |
|
110 case EBestList: |
|
111 selectedName = this->bestList->currentItem()->text(); |
|
112 break; |
|
113 case EOkList: |
|
114 selectedName = this->okList->currentItem()->text(); |
|
115 break; |
|
116 case EWorstList: |
|
117 selectedName = this->worstList->currentItem()->text(); |
|
118 break; |
|
119 } |
|
120 |
|
121 this->ecoDetails->setHtml( this->fishDb->getEcoDetails(selectedName)); |
|
122 |
95 this->stackedWidget->setCurrentIndex(MainWindow::EEcoPage); |
123 this->stackedWidget->setCurrentIndex(MainWindow::EEcoPage); |
96 } |
124 } |
97 |
125 |
98 void MainWindow::displayList() |
126 void MainWindow::displayList() |
99 { |
127 { |
112 QMessageBox::information(this,"found db @ ", dbFile); |
140 QMessageBox::information(this,"found db @ ", dbFile); |
113 } |
141 } |
114 |
142 |
115 } |
143 } |
116 |
144 |
|
145 void MainWindow::setCurrentList(int l) |
|
146 { |
|
147 switch (l) |
|
148 { |
|
149 case 0: |
|
150 this->index = EBestList; |
|
151 break; |
|
152 case 1: |
|
153 this->index = EOkList; |
|
154 break; |
|
155 case 2: |
|
156 this->index = EWorstList; |
|
157 break; |
|
158 } |
|
159 |
|
160 |
|
161 } |
|
162 |
117 void MainWindow::changeEvent(QEvent *e) |
163 void MainWindow::changeEvent(QEvent *e) |
118 { |
164 { |
119 QMainWindow::changeEvent(e); |
165 QMainWindow::changeEvent(e); |
120 switch (e->type()) { |
166 switch (e->type()) { |
121 case QEvent::LanguageChange: |
167 case QEvent::LanguageChange: |