3 @author: Sudheer K. <scifi1947 at gmail.com>
4 @license: GNU General Public License
7 #include "marketstodayqmlview.h"
8 #include "configqmlview.h"
9 #include "sharedcontext.h"
10 #include <QDeclarativeEngine>
11 #include <QDeclarativeContext>
12 #include <QDeclarativeProperty>
13 #include <QGraphicsObject>
14 #include "logutility.h"
18 MarketsTodayQMLView::MarketsTodayQMLView(QWidget *parent) : QDeclarativeView(parent), logUtility(new LogUtility(this))
20 // Setup QDeclarativeView
21 //setAttribute(Qt::WA_OpaquePaintEvent);
22 //setAttribute(Qt::WA_TranslucentBackground);
23 setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
24 setAlignment(Qt::AlignCenter);
25 this->rootContext()->setContextProperty("logUtility",logUtility);
28 QSize MarketsTodayQMLView::sizeHint() const
30 return QSize(400, 365);
33 void MarketsTodayQMLView::displayConfigWindow() {
35 ConfigQMLView *configView = new ConfigQMLView(this->parentWidget(),this);
37 #if defined(Q_WS_MAEMO_5) | defined(Q_WS_MAEMO_6)
38 //For maemo use a common path
39 configView->engine()->setOfflineStoragePath("/home/user/.marketstoday/OfflineStorage");
41 configView->engine()->setOfflineStoragePath("qml/OfflineStorage");
43 configView->setResizeMode(QDeclarativeView::SizeRootObjectToView);
44 configView->setSource(QUrl("qrc:/qml/Config.qml"));
45 configView->setWindowTitle("Configuration");
46 QObject::connect((QObject*)configView->engine(), SIGNAL(quit()), configView, SLOT(configClosed()));
47 configView->showFullScreen();
50 void MarketsTodayQMLView::displayStockDetails(QString symbol){
52 QDeclarativeView *detailsView = new QDeclarativeView(this->parentWidget());
53 SharedContext *sharedContextObj = new SharedContext(detailsView);
54 sharedContextObj->setComponentToDisplay("StockQuoteDetails");
55 sharedContextObj->setStockSymbol(symbol);
58 #if defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
59 //For maemo fremantle or harmattan use a common path
60 strPath = QDir().homePath() + "/.marketstoday/OfflineStorage";
61 detailsView->engine()->setOfflineStoragePath(strPath);
63 detailsView->engine()->setOfflineStoragePath("qml/OfflineStorage");
66 detailsView->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
67 detailsView->setAlignment(Qt::AlignCenter);
68 detailsView->setResizeMode(QDeclarativeView::SizeRootObjectToView);
69 detailsView->rootContext()->setContextProperty("sharedContext",sharedContextObj);
70 detailsView->rootContext()->setContextProperty("logUtility",logUtility);
71 //This code is only used for widget in Fremantle, so use Legacy QML without components
72 detailsView->setSource(QUrl("qrc:/qml/MarketsTodayLegacyApp.qml"));
73 detailsView->setWindowTitle("Markets Today");
74 QObject::connect((QObject*)detailsView->engine(), SIGNAL(quit()), detailsView, SLOT(close()));
75 detailsView->setFixedSize(800,480);
76 detailsView->showFullScreen();
78 logUtility->logMessage("Stock Details window displayed");
81 void MarketsTodayQMLView::initialize(){
82 emit initializeWidget();
85 MarketsTodayQMLView::~MarketsTodayQMLView(){
86 qDebug() << "In destructor for MarketsTodayQMLView object";