--- a/Seafood/Fishes.cpp Fri Mar 26 15:22:34 2010 -0700
+++ b/Seafood/Fishes.cpp Wed Mar 31 16:09:36 2010 -0700
@@ -8,6 +8,7 @@
Fishes::Fishes(QObject *parent) : QObject(parent)
{
QSqlDatabase db;
+ this->dbErrString = "noErr";
// Find QSLite driver
db = QSqlDatabase::addDatabase("QSQLITE");
@@ -16,6 +17,7 @@
QString dbFile = QDesktopServices::storageLocation(QDesktopServices::DataLocation)
+ '/' // Qt Universal file separator
+ "seafood.db";
+ dbFile.replace("/","\\");
#else
// Windows assumed.
// unfortunately, "C:\Documents and Settings" is corrupted on my home PC. hard coding until I fix it. -jk
@@ -34,7 +36,7 @@
// Open databasee
if(!db.open())
{
- std::string errCode = db.lastError().databaseText().toStdString();
+ this->dbErrString = db.lastError().databaseText();
qWarning("DB: failed to open.");
@@ -66,6 +68,7 @@
{
QString detailsInHtml;
QSqlQuery query;
+ this->dbErrString = "noErr";
query.prepare("select details from ecoDetails "
"where fid in (select fid from fish where name = :name )");
@@ -75,6 +78,7 @@
{
QString errCode = "failed to get eco details " + query.lastError().text();
qWarning(errCode.toStdString().c_str());
+ this->dbErrString = name + " " + query.lastError().text();
}
detailsInHtml.append("<html> <title>name</title> <body> <h2>Eco Details</h2> <ul> ");
--- a/Seafood/Fishes.h Fri Mar 26 15:22:34 2010 -0700
+++ b/Seafood/Fishes.h Wed Mar 31 16:09:36 2010 -0700
@@ -14,6 +14,7 @@
const QStringList GetBest();
const QStringList GetOK();
const QStringList GetWorst();
+ const QString GetDbErr() { return dbErrString; };
QString getEcoDetails(QString name);
@@ -22,6 +23,7 @@
QStringList bestFish;
QStringList okFish;
QStringList worstFish;
+ QString dbErrString;
};
#endif // FISHES_H
--- a/Seafood/SeafoodTabbed.pro Fri Mar 26 15:22:34 2010 -0700
+++ b/Seafood/SeafoodTabbed.pro Wed Mar 31 16:09:36 2010 -0700
@@ -4,7 +4,7 @@
#
#-------------------------------------------------
-QT += core gui sql svg webkit network
+QT += core gui sql webkit
TARGET = SeafoodTabbed
TEMPLATE = app
@@ -19,5 +19,8 @@
FORMS += mainwindow.ui
-RESOURCES += \
- SeafoodTabbed.qrc
+databasefiles.sources = seafood.db
+databasefiles.path = .
+
+DEPLOYMENT += databasefiles
+
--- a/Seafood/SeafoodTabbed.pro.user Fri Mar 26 15:22:34 2010 -0700
+++ b/Seafood/SeafoodTabbed.pro.user Wed Mar 31 16:09:36 2010 -0700
@@ -2,7 +2,7 @@
<qtcreator>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
- <value type="int">0</value>
+ <value type="int">1</value>
</data>
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
@@ -103,8 +103,97 @@
</valuemap>
</data>
<data>
+ <variable>ProjectExplorer.Project.Target.1</variable>
+ <valuemap type="QVariantMap">
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Symbian Device</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Target.S60DeviceTarget</value>
+ <value key="ProjectExplorer.Target.ActiveBuildConfiguration" type="int">1</value>
+ <value key="ProjectExplorer.Target.ActiveRunConfiguration" type="int">0</value>
+ <valuemap key="ProjectExplorer.Target.BuildConfiguration.0" type="QVariantMap">
+ <valuemap key="ProjectExplorer.BuildConfiguration.BuildStep.0" type="QVariantMap">
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">qmake</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">QtProjectManager.QMakeBuildStep</value>
+ <valuelist key="QtProjectManager.QMakeBuildStep.QMakeArguments" type="QVariantList"/>
+ </valuemap>
+ <valuemap key="ProjectExplorer.BuildConfiguration.BuildStep.1" type="QVariantMap">
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Make</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
+ <value key="Qt4ProjectManager.MakeStep.Clean" type="bool">false</value>
+ <valuelist key="Qt4ProjectManager.MakeStep.MakeArguments" type="QVariantList"/>
+ <value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
+ </valuemap>
+ <value key="ProjectExplorer.BuildConfiguration.BuildStepsCount" type="int">2</value>
+ <valuemap key="ProjectExplorer.BuildConfiguration.CleanStep.0" type="QVariantMap">
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Make</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
+ <value key="Qt4ProjectManager.MakeStep.Clean" type="bool">true</value>
+ <valuelist key="Qt4ProjectManager.MakeStep.MakeArguments" type="QVariantList">
+ <value type="QString">clean</value>
+ </valuelist>
+ <value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
+ </valuemap>
+ <value key="ProjectExplorer.BuildConfiguration.CleanStepsCount" type="int">1</value>
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Debug</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Qt4BuildConfiguration</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration" type="int">2</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory" type="QString">C:\workspace\QtExamples\Seafood</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.ClearSystemEnvironment" type="bool">false</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId" type="int">5</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.ToolChain" type="int">6</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild" type="bool">false</value>
+ <valuelist key="Qt4ProjectManager.Qt4BuildConfiguration.UserEnvironmentChanges" type="QVariantList"/>
+ </valuemap>
+ <valuemap key="ProjectExplorer.Target.BuildConfiguration.1" type="QVariantMap">
+ <valuemap key="ProjectExplorer.BuildConfiguration.BuildStep.0" type="QVariantMap">
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">qmake</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">QtProjectManager.QMakeBuildStep</value>
+ <valuelist key="QtProjectManager.QMakeBuildStep.QMakeArguments" type="QVariantList"/>
+ </valuemap>
+ <valuemap key="ProjectExplorer.BuildConfiguration.BuildStep.1" type="QVariantMap">
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Make</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
+ <value key="Qt4ProjectManager.MakeStep.Clean" type="bool">false</value>
+ <valuelist key="Qt4ProjectManager.MakeStep.MakeArguments" type="QVariantList"/>
+ <value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
+ </valuemap>
+ <value key="ProjectExplorer.BuildConfiguration.BuildStepsCount" type="int">2</value>
+ <valuemap key="ProjectExplorer.BuildConfiguration.CleanStep.0" type="QVariantMap">
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Make</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
+ <value key="Qt4ProjectManager.MakeStep.Clean" type="bool">true</value>
+ <valuelist key="Qt4ProjectManager.MakeStep.MakeArguments" type="QVariantList">
+ <value type="QString">clean</value>
+ </valuelist>
+ <value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
+ </valuemap>
+ <value key="ProjectExplorer.BuildConfiguration.CleanStepsCount" type="int">1</value>
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Release</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Qt4BuildConfiguration</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration" type="int">0</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory" type="QString"></value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.ClearSystemEnvironment" type="bool">false</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId" type="int">5</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.ToolChain" type="int">6</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild" type="bool">false</value>
+ <valuelist key="Qt4ProjectManager.Qt4BuildConfiguration.UserEnvironmentChanges" type="QVariantList"/>
+ </valuemap>
+ <value key="ProjectExplorer.Target.BuildConfigurationCount" type="int">2</value>
+ <valuemap key="ProjectExplorer.Target.RunConfiguration.0" type="QVariantMap">
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">SeafoodTabbed on Symbian Device</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.S60DeviceRunConfiguration</value>
+ <valuelist key="Qt4ProjectManager.S60DeviceRunConfiguration.CommandLineArguments" type="QVariantList"/>
+ <value key="Qt4ProjectManager.S60DeviceRunConfiguration.CustomKeyPath" type="QString"></value>
+ <value key="Qt4ProjectManager.S60DeviceRunConfiguration.CustomSignaturePath" type="QString"></value>
+ <value key="Qt4ProjectManager.S60DeviceRunConfiguration.ProFile" type="QString">SeafoodTabbed.pro</value>
+ <value key="Qt4ProjectManager.S60DeviceRunConfiguration.SerialPortName" type="QString">COM23</value>
+ <value key="Qt4ProjectManager.S60DeviceRunConfiguration.SigningMode" type="int">0</value>
+ </valuemap>
+ <value key="ProjectExplorer.Target.RunConfigurationCount" type="int">1</value>
+ </valuemap>
+ </data>
+ <data>
<variable>ProjectExplorer.Project.TargetCount</variable>
- <value type="int">1</value>
+ <value type="int">2</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
--- a/Seafood/SeafoodTabbed.qrc Fri Mar 26 15:22:34 2010 -0700
+++ b/Seafood/SeafoodTabbed.qrc Wed Mar 31 16:09:36 2010 -0700
@@ -1,5 +1,1 @@
-<RCC>
- <qresource prefix="/database">
- <file>seafood.db</file>
- </qresource>
-</RCC>
+<RCC/>
--- a/Seafood/main.cpp Fri Mar 26 15:22:34 2010 -0700
+++ b/Seafood/main.cpp Wed Mar 31 16:09:36 2010 -0700
@@ -7,6 +7,7 @@
MainWindow w;
w.createMenus();
w.setWindowTitle("Seafood T");
+ w.setStyleSheet("* { background-color:rgb(199,147,88); padding: 7px ; color:rgb(255,255,255)}");
#if defined(Q_WS_S60) || defined(Q_WS_MAEMO_5)
w.showMaximized();
#else
--- a/Seafood/mainwindow.cpp Fri Mar 26 15:22:34 2010 -0700
+++ b/Seafood/mainwindow.cpp Wed Mar 31 16:09:36 2010 -0700
@@ -84,7 +84,7 @@
verAction = new QAction(tr("&Version"),this);
menuBar()->addAction(verAction);
- connect(verAction, SIGNAL(triggered()),this, SLOT(displayVersion()));
+ connect(verAction, SIGNAL(triggered()),this, SLOT(displayPath()));
exitAction = new QAction(tr("&Exit"),this);
menuBar()->addAction(exitAction);
@@ -105,22 +105,40 @@
{
QString selectedName;
+ QListWidgetItem *item=NULL;
+
+
switch (this->index)
{
+
case EBestList:
- selectedName = this->bestList->currentItem()->text();
+ item = this->bestList->currentItem();
+ if (item)
+ {
+ selectedName = item->text();
+ }
+
break;
case EOkList:
- selectedName = this->okList->currentItem()->text();
+ item = this->okList->currentItem();
+ if (item) {
+ selectedName = item->text();
+ }
break;
case EWorstList:
- selectedName = this->worstList->currentItem()->text();
+ item = this->worstList->currentItem();
+ if (item) {
+ selectedName = item->text();
+ }
break;
}
- this->ecoDetails->setHtml( this->fishDb->getEcoDetails(selectedName));
-
- this->stackedWidget->setCurrentIndex(MainWindow::EEcoPage);
+ if (!item) {
+ QMessageBox::information(this,"warning","select an item from list." );
+ } else {
+ this->ecoDetails->setHtml( this->fishDb->getEcoDetails(selectedName));
+ this->stackedWidget->setCurrentIndex(MainWindow::EEcoPage);
+ }
}
void MainWindow::displayList()
@@ -130,16 +148,7 @@
void MainWindow::displayPath()
{
- QString dbFile = QDesktopServices::storageLocation(QDesktopServices::DataLocation)
- + '/' // Qt Universal file separator
- + "seafood.db";
- QFile f(dbFile);
- if (f.exists()) {
- QMessageBox::information(this,"db not found ", dbFile);
- } else {
- QMessageBox::information(this,"found db @ ", dbFile);
- }
-
+ QMessageBox::information(this, "db Error",this->fishDb->GetDbErr());
}
void MainWindow::setCurrentList(int l)
@@ -156,8 +165,6 @@
this->index = EWorstList;
break;
}
-
-
}
void MainWindow::changeEvent(QEvent *e)
--- a/Seafood/ui_mainwindow.h Fri Mar 26 15:22:34 2010 -0700
+++ b/Seafood/ui_mainwindow.h Wed Mar 31 16:09:36 2010 -0700
@@ -1,7 +1,7 @@
/********************************************************************************
** Form generated from reading UI file 'mainwindow.ui'
**
-** Created: Thu Mar 25 13:34:10 2010
+** Created: Mon Mar 29 16:27:58 2010
** by: Qt User Interface Compiler version 4.6.2
**
** WARNING! All changes made in this file will be lost when recompiling UI file!