Seafood/mainwindow.cpp
author John Kern <johnk@symbian.org>
Thu, 08 Apr 2010 19:31:52 -0700
changeset 15 0f80a0f39475
parent 14 a16afe3df8c9
child 16 e26c25b72a12
permissions -rwxr-xr-x
populate the nutrition table
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
     1
#include <QFile>
15
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
     2
#include <QtGlobal>
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
     3
 #include <QDebug>
3
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
     4
#include <QIcon>
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
     5
#include <QListWidget>
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
     6
#include <QMessageBox>
7
John Kern <johnk@symbian.org>
parents: 3
diff changeset
     7
#include <QStackedWidget>
3
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
     8
#include <QTableWidget>
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
     9
#include <QDesktopServices>
7
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    10
#include <QWebView>
3
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    11
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    12
#include "Fishes.h"
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    13
#include "mainwindow.h"
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    14
#include "ui_mainwindow.h"
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    15
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    16
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    17
MainWindow::MainWindow(QWidget *parent) :
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    18
    QMainWindow(parent),
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    19
    ui(new Ui::MainWindow)
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    20
{
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    21
    ui->setupUi(this);
7
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    22
    setContextMenuPolicy(Qt::NoContextMenu);
10
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
    23
    this->fishDb = new Fishes(this);
3
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    24
7
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    25
    this->stackedWidget = new QStackedWidget;
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    26
10
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
    27
    // lists of fish
3
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    28
    this->tabWidget = new QTabWidget;
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    29
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    30
    this->bestList = new QListWidget;
14
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
    31
    this->bestList->addItems(this->fishDb->getBest());
3
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    32
    this->tabWidget->addTab(this->bestList, "best");
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    33
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    34
    this->okList = new QListWidget;
14
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
    35
    this->okList->addItems(this->fishDb->getOK());
3
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    36
    this->tabWidget->addTab(this->okList, "ok");
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    37
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    38
    this->worstList = new QListWidget;
14
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
    39
    this->worstList->addItems(this->fishDb->getWorst());
3
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    40
    this->tabWidget->addTab(this->worstList, "worst");
7
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    41
10
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
    42
    this->index = EBestList;
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
    43
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
    44
    connect(this->tabWidget, SIGNAL(currentChanged(int)),
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
    45
            this, SLOT(setCurrentList(int)));
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
    46
7
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    47
    this->stackedWidget->addWidget(tabWidget); // associated with EListPage
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    48
10
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
    49
    // Eco details
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
    50
7
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    51
    this->ecoDetails = new QWebView;
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    52
    this->ecoDetails->setHtml("<html><title>Eco Details</title><ul><li>not yet implemented</li></ul></html>");
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    53
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    54
    this->stackedWidget->addWidget(this->ecoDetails); // associated with EEcoPage
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    55
10
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
    56
    // Nutrition page
7
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    57
    this->stackedWidget->addWidget(ui->centralWidget); // associated with ENutritionPage
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    58
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    59
    setCentralWidget(stackedWidget);
3
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    60
}
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    61
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    62
MainWindow::~MainWindow()
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    63
{
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    64
    delete ui;
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    65
}
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    66
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    67
void MainWindow::createMenus()
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    68
    {
7
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    69
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    70
        ecoAction = new QAction(tr("&eco details"),this);
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    71
        menuBar()->addAction(ecoAction);
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    72
        connect(ecoAction, SIGNAL(triggered()),this, SLOT(displayEcoDetails()));
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    73
3
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    74
        nuAction = new QAction(tr("&Nutrition"),this);
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    75
        menuBar()->addAction(nuAction);
7
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    76
        connect(nuAction, SIGNAL(triggered()),this, SLOT(displayNutrition()));
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    77
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    78
        fishesAction = new QAction(tr("&List Fishes"),this);
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    79
        menuBar()->addAction(fishesAction);
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    80
        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
    81
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    82
        verAction = new QAction(tr("&Version"),this);
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    83
        menuBar()->addAction(verAction);
14
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
    84
        connect(verAction, SIGNAL(triggered()),this, SLOT(displayVersion()));
3
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    85
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    86
        exitAction = new QAction(tr("&Exit"),this);
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    87
        menuBar()->addAction(exitAction);
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    88
        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
    89
    }
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    90
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    91
void MainWindow::displayVersion()
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    92
{
10
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
    93
    QMessageBox::information(this,"Qt Version", qVersion());
7
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    94
}
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    95
14
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
    96
 QString MainWindow::currentlySelectedItem()
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
    97
 {
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
    98
     QString selectedName;
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
    99
     QListWidgetItem *item=NULL;
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   100
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   101
     switch (this->index)
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   102
     {
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   103
     case EBestList:
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   104
         item = this->bestList->currentItem();
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   105
         if (item)
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   106
         {
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   107
             selectedName = item->text();
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   108
         }
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   109
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   110
         break;
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   111
     case EOkList:
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   112
         item = this->okList->currentItem();
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   113
         if (item) {
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   114
             selectedName = item->text();
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   115
         }
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   116
         break;
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   117
     case EWorstList:
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   118
         item = this->worstList->currentItem();
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   119
         if (item) {
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   120
             selectedName = item->text();
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   121
         }
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   122
         break;
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   123
     }
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   124
     return selectedName;
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   125
 }
7
John Kern <johnk@symbian.org>
parents: 3
diff changeset
   126
John Kern <johnk@symbian.org>
parents: 3
diff changeset
   127
void MainWindow::displayEcoDetails()
John Kern <johnk@symbian.org>
parents: 3
diff changeset
   128
{
14
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   129
    QString selectedName = this->currentlySelectedItem();
11
f3dbeee07821 instrumented with debugging output
John Kern <johnk@symbian.org>
parents: 10
diff changeset
   130
14
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   131
    if (selectedName.isEmpty()) {
11
f3dbeee07821 instrumented with debugging output
John Kern <johnk@symbian.org>
parents: 10
diff changeset
   132
        QMessageBox::information(this,"warning","select an item from list." );
f3dbeee07821 instrumented with debugging output
John Kern <johnk@symbian.org>
parents: 10
diff changeset
   133
    } else {
f3dbeee07821 instrumented with debugging output
John Kern <johnk@symbian.org>
parents: 10
diff changeset
   134
        this->ecoDetails->setHtml( this->fishDb->getEcoDetails(selectedName));
f3dbeee07821 instrumented with debugging output
John Kern <johnk@symbian.org>
parents: 10
diff changeset
   135
        this->stackedWidget->setCurrentIndex(MainWindow::EEcoPage);
f3dbeee07821 instrumented with debugging output
John Kern <johnk@symbian.org>
parents: 10
diff changeset
   136
    }
7
John Kern <johnk@symbian.org>
parents: 3
diff changeset
   137
}
John Kern <johnk@symbian.org>
parents: 3
diff changeset
   138
14
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   139
void MainWindow::displayNutrition()
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   140
{
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   141
    QString selectedName = this->currentlySelectedItem();
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   142
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   143
    if (selectedName.isEmpty()) {
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   144
        QMessageBox::information(this,"warning","select an item from list." );
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   145
    } else {
15
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   146
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   147
        QMap<Fishes::TNUTRITION, QString> nutrition (this->fishDb->getNutrition(selectedName));
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   148
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   149
        const int COLUMN = 1;
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   150
        int row=0;
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   151
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   152
        QTableWidgetItem *newItem;
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   153
        newItem = new QTableWidgetItem(nutrition[Fishes::ECalories] );
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   154
        this->ui->tableWidget->setItem(row++,COLUMN, newItem);
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   155
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   156
        newItem = new QTableWidgetItem(nutrition[Fishes::ETotalFat] );
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   157
        this->ui->tableWidget->setItem(row++,COLUMN, newItem);
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   158
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   159
        newItem = new QTableWidgetItem(nutrition[Fishes::ETotalProtein] );
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   160
        this->ui->tableWidget->setItem(row++,COLUMN, newItem);
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   161
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   162
        newItem = new QTableWidgetItem(nutrition[Fishes::EOmega3] );
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   163
        this->ui->tableWidget->setItem(row++,COLUMN, newItem);
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   164
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   165
        newItem = new QTableWidgetItem(nutrition[Fishes::ECholesterol] );
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   166
        this->ui->tableWidget->setItem(row++,COLUMN, newItem);
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   167
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   168
        newItem = new QTableWidgetItem(nutrition[Fishes::ESodium] );
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   169
        this->ui->tableWidget->setItem(row,COLUMN, newItem);
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   170
14
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   171
        this->stackedWidget->setCurrentIndex(MainWindow::ENutritionPage);
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   172
    }
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   173
}
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   174
7
John Kern <johnk@symbian.org>
parents: 3
diff changeset
   175
void MainWindow::displayList()
John Kern <johnk@symbian.org>
parents: 3
diff changeset
   176
{
John Kern <johnk@symbian.org>
parents: 3
diff changeset
   177
    this->stackedWidget->setCurrentIndex(MainWindow::EListPage);
3
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
   178
}
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
   179
10
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
   180
void MainWindow::setCurrentList(int l)
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
   181
{
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
   182
    switch (l)
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
   183
    {
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
   184
    case 0:
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
   185
        this->index = EBestList;
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
   186
        break;
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
   187
    case 1:
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
   188
        this->index = EOkList;
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
   189
        break;
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
   190
    case 2:
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
   191
        this->index = EWorstList;
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
   192
        break;
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
   193
    }
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
   194
}
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
   195
3
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
   196
void MainWindow::changeEvent(QEvent *e)
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
   197
{
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
   198
    QMainWindow::changeEvent(e);
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
   199
    switch (e->type()) {
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
   200
    case QEvent::LanguageChange:
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
   201
        ui->retranslateUi(this);
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
   202
        break;
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
   203
    default:
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
   204
        break;
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
   205
    }
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
   206
}