82 menuBar()->addAction(fishesAction); |
82 menuBar()->addAction(fishesAction); |
83 connect(fishesAction, SIGNAL(triggered()),this, SLOT(displayList())); |
83 connect(fishesAction, SIGNAL(triggered()),this, SLOT(displayList())); |
84 |
84 |
85 verAction = new QAction(tr("&Version"),this); |
85 verAction = new QAction(tr("&Version"),this); |
86 menuBar()->addAction(verAction); |
86 menuBar()->addAction(verAction); |
87 connect(verAction, SIGNAL(triggered()),this, SLOT(displayVersion())); |
87 connect(verAction, SIGNAL(triggered()),this, SLOT(displayPath())); |
88 |
88 |
89 exitAction = new QAction(tr("&Exit"),this); |
89 exitAction = new QAction(tr("&Exit"),this); |
90 menuBar()->addAction(exitAction); |
90 menuBar()->addAction(exitAction); |
91 connect(exitAction, SIGNAL(triggered()),this, SLOT(close())); |
91 connect(exitAction, SIGNAL(triggered()),this, SLOT(close())); |
92 } |
92 } |
103 |
103 |
104 void MainWindow::displayEcoDetails() |
104 void MainWindow::displayEcoDetails() |
105 { |
105 { |
106 |
106 |
107 QString selectedName; |
107 QString selectedName; |
|
108 QListWidgetItem *item=NULL; |
|
109 |
|
110 |
108 switch (this->index) |
111 switch (this->index) |
109 { |
112 { |
|
113 |
110 case EBestList: |
114 case EBestList: |
111 selectedName = this->bestList->currentItem()->text(); |
115 item = this->bestList->currentItem(); |
|
116 if (item) |
|
117 { |
|
118 selectedName = item->text(); |
|
119 } |
|
120 |
112 break; |
121 break; |
113 case EOkList: |
122 case EOkList: |
114 selectedName = this->okList->currentItem()->text(); |
123 item = this->okList->currentItem(); |
|
124 if (item) { |
|
125 selectedName = item->text(); |
|
126 } |
115 break; |
127 break; |
116 case EWorstList: |
128 case EWorstList: |
117 selectedName = this->worstList->currentItem()->text(); |
129 item = this->worstList->currentItem(); |
|
130 if (item) { |
|
131 selectedName = item->text(); |
|
132 } |
118 break; |
133 break; |
119 } |
134 } |
120 |
135 |
121 this->ecoDetails->setHtml( this->fishDb->getEcoDetails(selectedName)); |
136 if (!item) { |
122 |
137 QMessageBox::information(this,"warning","select an item from list." ); |
123 this->stackedWidget->setCurrentIndex(MainWindow::EEcoPage); |
138 } else { |
|
139 this->ecoDetails->setHtml( this->fishDb->getEcoDetails(selectedName)); |
|
140 this->stackedWidget->setCurrentIndex(MainWindow::EEcoPage); |
|
141 } |
124 } |
142 } |
125 |
143 |
126 void MainWindow::displayList() |
144 void MainWindow::displayList() |
127 { |
145 { |
128 this->stackedWidget->setCurrentIndex(MainWindow::EListPage); |
146 this->stackedWidget->setCurrentIndex(MainWindow::EListPage); |
129 } |
147 } |
130 |
148 |
131 void MainWindow::displayPath() |
149 void MainWindow::displayPath() |
132 { |
150 { |
133 QString dbFile = QDesktopServices::storageLocation(QDesktopServices::DataLocation) |
151 QMessageBox::information(this, "db Error",this->fishDb->GetDbErr()); |
134 + '/' // Qt Universal file separator |
|
135 + "seafood.db"; |
|
136 QFile f(dbFile); |
|
137 if (f.exists()) { |
|
138 QMessageBox::information(this,"db not found ", dbFile); |
|
139 } else { |
|
140 QMessageBox::information(this,"found db @ ", dbFile); |
|
141 } |
|
142 |
|
143 } |
152 } |
144 |
153 |
145 void MainWindow::setCurrentList(int l) |
154 void MainWindow::setCurrentList(int l) |
146 { |
155 { |
147 switch (l) |
156 switch (l) |