added a listview to support orange lab fw default tip
authorJohn Kern <johnk@symbian.org>
Thu, 16 Sep 2010 10:59:11 -0700
changeset 49 d9d4ea56179a
parent 48 863c77d15828
added a listview to support orange lab fw
contactengine/ContactList.ui
contactengine/contactengine.pro
contactengine/contactlist.cpp
contactengine/contactlist.h
contactengine/main.cpp
contactengine/mainview.cpp
contactengine/mainview.h
contactengine/mainwindow.h
contactengine/resouce.qrc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contactengine/ContactList.ui	Thu Sep 16 10:59:11 2010 -0700
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Form</class>
+ <widget class="QWidget" name="Form">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>337</width>
+    <height>529</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <widget class="QSplitter" name="splitter">
+   <property name="geometry">
+    <rect>
+     <x>10</x>
+     <y>20</y>
+     <width>256</width>
+     <height>401</height>
+    </rect>
+   </property>
+   <property name="orientation">
+    <enum>Qt::Vertical</enum>
+   </property>
+   <widget class="QComboBox" name="comboBox">
+    <property name="minimumSize">
+     <size>
+      <width>0</width>
+      <height>83</height>
+     </size>
+    </property>
+   </widget>
+   <widget class="QListView" name="listView"/>
+  </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
--- a/contactengine/contactengine.pro	Fri Sep 10 09:00:20 2010 -0700
+++ b/contactengine/contactengine.pro	Thu Sep 16 10:59:11 2010 -0700
@@ -1,52 +1,62 @@
-#-------------------------------------------------
-#
-# Project created by QtCreator 2010-08-03T16:15:24
-#
-#-------------------------------------------------
-
-QT       += core gui sql svg
-
-TARGET = contactengine
-TEMPLATE = app
-
-CONFIG += debug
-
-SOURCES += main.cpp\
-        mainwindow.cpp \
-    contactsengine.cpp \
-    dbtools.cpp \
-    detailsgv.cpp
-
-HEADERS  += mainwindow.h \
-    contactsengine.h \
-    database.h \
-    dbtools.h \
-    database.h \
-    detailsgv.h
-
-
-FORMS    += mainwindow.ui
-
-CONFIG += mobility
-MOBILITY = contacts
-
-unix:INCLUDEPATH += /home/johnk/libs/include/QtContacts /home/johnk/libs/include/
-unix:LIBS += -L/home/johnk/libs/lib -lQtContacts
-
-databasefiles.sources = contacts.csv
-databasefiles.path = .
-
-DEPLOYMENT += databasefiles
-
-symbian {
-    TARGET.UID3 = 0xec200759
-    TARGET.CAPABILITY += ReadUserData WriteUserData
-    TARGET.EPOCSTACKSIZE = 0x14000
-    TARGET.EPOCHEAPSIZE = 0x020000 0x800000
-}
-
-RESOURCES += \
-    resouce.qrc
-
-OTHER_FILES += \
-    readme.txt
+#-------------------------------------------------
+#
+# Project created by QtCreator 2010-08-03T16:15:24
+#
+#-------------------------------------------------
+
+QT       += core gui sql svg
+
+TARGET = contactengine
+TEMPLATE = app
+
+CONFIG += debug
+
+include( apptemplatesrc/apptemplate.pri)
+
+DEPENDPATH += apptemplatesrc
+
+DEFINES += USE_ORANGE_FW
+
+SOURCES += main.cpp\
+        mainwindow.cpp \
+    contactsengine.cpp \
+    dbtools.cpp \
+    detailsgv.cpp \
+    mainview.cpp \
+    contactlist.cpp
+
+HEADERS  += mainwindow.h \
+    contactsengine.h \
+    database.h \
+    dbtools.h \
+    database.h \
+    detailsgv.h \
+    mainview.h \
+    contactlist.h
+
+FORMS    += mainwindow.ui \
+    ContactList.ui
+
+CONFIG += mobility
+MOBILITY = contacts messaging
+
+unix:INCLUDEPATH += /home/johnk/libs/include/QtContacts /home/johnk/libs/include/
+unix:LIBS += -L/home/johnk/libs/lib -lQtContacts
+
+databasefiles.sources = contacts.csv
+databasefiles.path = .
+
+DEPLOYMENT += databasefiles
+
+symbian {
+    TARGET.UID3 = 0xec200759
+    TARGET.CAPABILITY += ReadUserData WriteUserData ReadDeviceData WriteDeviceData
+    TARGET.EPOCSTACKSIZE = 0x14000
+    TARGET.EPOCHEAPSIZE = 0x020000 0x800000
+}
+
+RESOURCES += \
+    resouce.qrc
+
+OTHER_FILES += \
+    readme.txt
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contactengine/contactlist.cpp	Thu Sep 16 10:59:11 2010 -0700
@@ -0,0 +1,59 @@
+#include <OLApplication.h>
+#include <QMessageBox>
+#include "contactlist.h"
+
+ContactList::ContactList(QWidget *parent) :
+    QWidget(parent),
+    ui(new Ui::Form)
+{
+    ui->setupUi(this);
+
+    this->ce = new ContactsEngine(this);
+
+    connect(this->ce, SIGNAL(errorOccurred(QString)),
+            this,SLOT(errorOccurred(QString)));
+
+    this->ce->createManager();
+
+    connect(ui->comboBox, SIGNAL( activated ( const QString &  )),
+            this->ce, SLOT(setManager(const QString &) ));
+
+
+    ui->comboBox->addItems(this->ce->dataSources());
+    ui->listView->setModel(this->ce);
+
+}
+
+
+void ContactList::errorOccurred(QString err)
+{
+    QMessageBox::information(this, "foo", err);
+}
+
+// just should all contacts.
+void ContactList::showAllContacts()
+{
+    OLApplication* app = dynamic_cast<OLApplication*>(qApp);
+    app->showBanner("(all) NYI", false);
+}
+
+// source the list of contacts by proximity to the phone.
+void ContactList::sortByGeo()
+{
+    OLApplication* app = dynamic_cast<OLApplication*>(qApp);
+    app->showBanner("(geo) NYI", false);
+}
+
+// show all contacts at a particular event.
+void ContactList::showEvents()
+{
+    OLApplication* app = dynamic_cast<OLApplication*>(qApp);
+    app->showBanner("(events) NYI", false);
+}
+
+// show call log
+void ContactList::showLogs()
+{
+    OLApplication* app = dynamic_cast<OLApplication*>(qApp);
+    app->showBanner("(logs) NYI", false);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contactengine/contactlist.h	Thu Sep 16 10:59:11 2010 -0700
@@ -0,0 +1,34 @@
+#ifndef CONTACTLIST_H
+#define CONTACTLIST_H
+
+#include <QWidget>
+
+#include "contactsengine.h"
+#include "ui_ContactList.h"
+
+class ContactList : public QWidget
+{
+    Q_OBJECT
+public:
+    explicit ContactList(QWidget *parent = 0);
+
+signals:
+
+public slots:
+    // just should all contacts.
+    void showAllContacts();
+    // source the list of contacts by proximity to the phone.
+    void sortByGeo();
+    // show all contacts at a particular event.
+    void showEvents();
+    // show call log
+    void showLogs();
+
+    void errorOccurred(QString);
+
+private:
+    Ui::Form *ui;
+    ContactsEngine *ce;
+};
+
+#endif // CONTACTLIST_H
--- a/contactengine/main.cpp	Fri Sep 10 09:00:20 2010 -0700
+++ b/contactengine/main.cpp	Thu Sep 16 10:59:11 2010 -0700
@@ -1,9 +1,18 @@
 #include <QtGui/QApplication>
 #include <QDesktopServices>
 #include <QDir>
+#include <QDebug>
+#include <QLabel>
+
+#ifdef USE_ORANGE_FW
+#include <OLApplication.h>
+#include <OLPixmapWidget.h>
+#include "mainview.h"
+#include "contactlist.h"
+#else
 #include "mainwindow.h"
 #include "dbtools.h"
-#include <QDebug>
+#endif
 
 // Tech Tip: By default, Actions is added to the Options menu. The
 // idea is to support context menus on non-touch mobiles.
@@ -17,12 +26,34 @@
     }
 }
 
-
+#ifdef USE_ORANGE_FW
 int main(int argc, char *argv[])
 {
+    OLApplication a(argc, argv);
+
+    MainView *mainView = new MainView(NULL);
+
+    disableContextMenu();
+
+    a.setWindowTitle("(OL)Contact App");
+    mainView->resize(a.viewSize());
+//    QLabel* test = new QLabel("main base view", mainView);
+//    Q_UNUSED(test);
+    ContactList *cl = new ContactList(mainView);
+    Q_UNUSED(cl)
+    mainView->connect(&a, SIGNAL(appStarted()), mainView, SLOT(startApp()));
+
+    return a.exec();
+}
+#else
+int main(int argc, char *argv[])
+{
+
     QApplication a(argc, argv);
     MainWindow w;
 
+
+
     DBTools dbt;
     QString dbLocation(":/contacts.csv");
 
@@ -31,12 +62,12 @@
 
     disableContextMenu();
 
-    w.setWindowTitle("Qt Study App");
+    w.setWindowTitle("Contact App");
 #if defined(Q_WS_S60)
     w.showMaximized();
 #else
     w.show();
 #endif
-
     return a.exec();
 }
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contactengine/mainview.cpp	Thu Sep 16 10:59:11 2010 -0700
@@ -0,0 +1,78 @@
+#include <QLabel>
+#include <QVBoxLayout>
+
+#include <OLApplication.h>
+#include <OLButton.h>
+#include <OLPixmapWidget.h>
+#include "mainview.h"
+
+
+#include "mainwindow.h"
+
+MainView::MainView(QWidget *parent) :
+    QWidget(parent)
+{
+    // setup toolbar
+    OLButton* btn = 0;
+    btn = addToolbarButton(":/images/icn_addmenu.png", "call");
+    connect(btn, SIGNAL(clicked()), this, SLOT(showAllContacts()));
+
+    btn = addToolbarButton(":/images/icn_addview.png", "SMS");
+    connect(btn, SIGNAL(clicked()), this, SLOT(sortByGeo()));
+}
+
+ OLButton* MainView::addToolbarButton(const QString& icon, const QString& text)
+ {
+     OLWidgetList wgtList;
+     OLApplication* app = dynamic_cast<OLApplication*>(qApp);
+     OLButton* btn = new OLButton();
+     QVBoxLayout* btnLayout = new QVBoxLayout(btn);
+     btnLayout->setMargin(0);
+     btnLayout->setSpacing(5);
+     btnLayout->setAlignment(Qt::AlignCenter);
+     OLPixmapWidget* btnIcon = new OLPixmapWidget(icon);
+     QLabel* btnText = new QLabel(text);
+     btnText->setStyleSheet("font-size: 10px;");
+     btnLayout->addWidget(btnIcon, 0, Qt::AlignHCenter);
+     btnLayout->addWidget(btnText, 0, Qt::AlignHCenter);
+     wgtList.append(btnText);
+     btn->setLayout(btnLayout);
+     app->addToolbarButton(btn, wgtList);
+
+     return btn;
+ }
+
+void MainView::startApp()
+{
+    OLApplication* app = dynamic_cast<OLApplication*>(qApp);
+    QSize viewSize = app->viewSize();
+    app->setView(this, OLApplication::systemdefault, true);
+}
+
+// just should all contacts.
+void MainView::showAllContacts()
+{
+    OLApplication* app = dynamic_cast<OLApplication*>(qApp);
+    app->showBanner("(all) NYI", false);
+}
+
+// source the list of contacts by proximity to the phone.
+void MainView::sortByGeo()
+{
+    OLApplication* app = dynamic_cast<OLApplication*>(qApp);
+    app->showBanner("(geo) NYI", false);
+}
+
+// show all contacts at a particular event.
+void MainView::showEvents()
+{
+    OLApplication* app = dynamic_cast<OLApplication*>(qApp);
+    app->showBanner("(events) NYI", false);
+}
+
+// show call log
+void MainView::showLogs()
+{
+    OLApplication* app = dynamic_cast<OLApplication*>(qApp);
+    app->showBanner("(logs) NYI", false);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contactengine/mainview.h	Thu Sep 16 10:59:11 2010 -0700
@@ -0,0 +1,40 @@
+#ifndef MAINVIEW_H
+#define MAINVIEW_H
+
+#include <QWidget>
+
+#include <OLButton.h>
+
+
+
+// Use this class with the Orange Labs FW.  Since the FW is full screen
+// it handles many issues QMainWindow does for a standard Qt app.
+
+class MainView : public QWidget
+{
+    Q_OBJECT
+public:
+    explicit MainView(QWidget *parent = 0);
+
+signals:
+
+public slots:
+    void startApp();
+
+    // just should all contacts.
+    void showAllContacts();
+    // source the list of contacts by proximity to the phone.
+    void sortByGeo();
+    // show all contacts at a particular event.
+    void showEvents();
+    // show call log
+    void showLogs();
+
+private:
+    OLButton* addToolbarButton(const QString& icon, const QString& text);
+
+private:
+    int m_count;
+};
+
+#endif // MAINVIEW_H
--- a/contactengine/mainwindow.h	Fri Sep 10 09:00:20 2010 -0700
+++ b/contactengine/mainwindow.h	Thu Sep 16 10:59:11 2010 -0700
@@ -9,6 +9,9 @@
     class MainWindow;
 }
 
+// If you are building this as a stand alone app (ie, not using the Orange Labs FW),
+// use this class.
+
 class MainWindow : public QMainWindow
 {
     Q_OBJECT
--- a/contactengine/resouce.qrc	Fri Sep 10 09:00:20 2010 -0700
+++ b/contactengine/resouce.qrc	Thu Sep 16 10:59:11 2010 -0700
@@ -2,5 +2,9 @@
     <qresource prefix="/">
         <file>contacts.csv</file>
         <file>images/johnny_automatic_marching_band_1.svg</file>
+        <file>images/icn_removeview.png</file>
+        <file>images/icn_addmenu.png</file>
+        <file>images/icn_addstackview.png</file>
+        <file>images/icn_addview.png</file>
     </qresource>
 </RCC>