contactengine/mainwindow.cpp
author John Kern <johnk@symbian.org>
Fri, 13 Aug 2010 15:33:51 -0700
changeset 30 33e489bb7487
parent 25 adbe71832e2b
child 34 93c5a58496b6
permissions -rwxr-xr-x
add options menu
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23
51fcdd1558d8 clean up
John Kern <johnk@symbian.org>
parents: 19
diff changeset
     1
#include <QComboBox>
30
33e489bb7487 add options menu
John Kern <johnk@symbian.org>
parents: 25
diff changeset
     2
#include <QMenuBar>
25
adbe71832e2b runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents: 23
diff changeset
     3
#include <QMessageBox>
adbe71832e2b runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents: 23
diff changeset
     4
adbe71832e2b runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents: 23
diff changeset
     5
#include <QDebug>
23
51fcdd1558d8 clean up
John Kern <johnk@symbian.org>
parents: 19
diff changeset
     6
19
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
     7
#include "mainwindow.h"
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
     8
#include "ui_mainwindow.h"
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
     9
#include "contactsengine.h"
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    10
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    11
MainWindow::MainWindow(QWidget *parent) :
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    12
    QMainWindow(parent),
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    13
    ui(new Ui::MainWindow)
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    14
{
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    15
    ui->setupUi(this);
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    16
    this->ce = new ContactsEngine(this);
25
adbe71832e2b runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents: 23
diff changeset
    17
adbe71832e2b runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents: 23
diff changeset
    18
    connect(this->ce, SIGNAL(errorOccurred(QString)),
adbe71832e2b runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents: 23
diff changeset
    19
            this,SLOT(errorOccurred(QString)));
23
51fcdd1558d8 clean up
John Kern <johnk@symbian.org>
parents: 19
diff changeset
    20
51fcdd1558d8 clean up
John Kern <johnk@symbian.org>
parents: 19
diff changeset
    21
    connect(ui->comboBox, SIGNAL( activated ( const QString &  )),
51fcdd1558d8 clean up
John Kern <johnk@symbian.org>
parents: 19
diff changeset
    22
            this->ce, SLOT(setManager(const QString &) ));
19
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    23
25
adbe71832e2b runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents: 23
diff changeset
    24
    this->ce->createManager();
adbe71832e2b runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents: 23
diff changeset
    25
19
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    26
    ui->comboBox->addItems(this->ce->dataSources());
23
51fcdd1558d8 clean up
John Kern <johnk@symbian.org>
parents: 19
diff changeset
    27
    ui->listView->setModel(this->ce);
30
33e489bb7487 add options menu
John Kern <johnk@symbian.org>
parents: 25
diff changeset
    28
33e489bb7487 add options menu
John Kern <johnk@symbian.org>
parents: 25
diff changeset
    29
    this->createMenus();
33e489bb7487 add options menu
John Kern <johnk@symbian.org>
parents: 25
diff changeset
    30
}
33e489bb7487 add options menu
John Kern <johnk@symbian.org>
parents: 25
diff changeset
    31
33e489bb7487 add options menu
John Kern <johnk@symbian.org>
parents: 25
diff changeset
    32
void MainWindow::createMenus()
33e489bb7487 add options menu
John Kern <johnk@symbian.org>
parents: 25
diff changeset
    33
    {
33e489bb7487 add options menu
John Kern <johnk@symbian.org>
parents: 25
diff changeset
    34
        verAction = new QAction(tr("&Version"),this);
33e489bb7487 add options menu
John Kern <johnk@symbian.org>
parents: 25
diff changeset
    35
        menuBar()->addAction(verAction);
33e489bb7487 add options menu
John Kern <johnk@symbian.org>
parents: 25
diff changeset
    36
        connect(verAction, SIGNAL(triggered()),this, SLOT(displayVersion()));
33e489bb7487 add options menu
John Kern <johnk@symbian.org>
parents: 25
diff changeset
    37
33e489bb7487 add options menu
John Kern <johnk@symbian.org>
parents: 25
diff changeset
    38
        exitAction = new QAction(tr("&Exit"),this);
33e489bb7487 add options menu
John Kern <johnk@symbian.org>
parents: 25
diff changeset
    39
        menuBar()->addAction(exitAction);
33e489bb7487 add options menu
John Kern <johnk@symbian.org>
parents: 25
diff changeset
    40
        connect(exitAction, SIGNAL(triggered()),this, SLOT(close()));
33e489bb7487 add options menu
John Kern <johnk@symbian.org>
parents: 25
diff changeset
    41
    }
33e489bb7487 add options menu
John Kern <johnk@symbian.org>
parents: 25
diff changeset
    42
33e489bb7487 add options menu
John Kern <johnk@symbian.org>
parents: 25
diff changeset
    43
void MainWindow::displayVersion()
33e489bb7487 add options menu
John Kern <johnk@symbian.org>
parents: 25
diff changeset
    44
{
33e489bb7487 add options menu
John Kern <johnk@symbian.org>
parents: 25
diff changeset
    45
    QMessageBox::information(this,"Qt Version", qVersion());
19
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    46
}
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    47
25
adbe71832e2b runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents: 23
diff changeset
    48
void MainWindow::errorOccurred(QString errMsg)
adbe71832e2b runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents: 23
diff changeset
    49
{
30
33e489bb7487 add options menu
John Kern <johnk@symbian.org>
parents: 25
diff changeset
    50
    QMessageBox::information(this,"Err Routed",errMsg);
25
adbe71832e2b runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents: 23
diff changeset
    51
    qDebug() << errMsg << endl;
adbe71832e2b runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents: 23
diff changeset
    52
}
19
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    53
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    54
MainWindow::~MainWindow()
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    55
{
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    56
    delete ui;
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    57
}