123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- /**
- * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
- * All rights reserved.
- *
- * For the applicable distribution terms see the license.txt -file, included in
- * the distribution.
- */
- #include <QtGui/QApplication>
- #include <QDeclarativeContext>
- #include <QDeclarativeEngine>
- #include "qmlapplicationviewer.h"
- #include "declarativepurchaselistmodel.h"
- #include "ItemstatusImageProvider.h"
- #include <QFile>
- #include <QTextStream>
- void myMessageHandler(QtMsgType type, const char *msg)
- {
- QString txt;
- switch (type) {
- case QtDebugMsg:
- txt = QString("Debug: %1").arg(msg);
- break;
- case QtWarningMsg:
- txt = QString("Warning: %1").arg(msg);
- break;
- case QtCriticalMsg:
- txt = QString("Critical: %1").arg(msg);
- break;
- case QtFatalMsg:
- txt = QString("Fatal: %1").arg(msg);
- abort();
- }
- QFile outFile("c:/data/inapppurchase.log");
- outFile.open(QIODevice::WriteOnly | QIODevice::Append);
- QTextStream ts(&outFile);
- ts << txt << endl;
- }
- int main(int argc, char *argv[])
- {
- QApplication app(argc, argv);
- qInstallMsgHandler(myMessageHandler);
- QmlApplicationViewer viewer;
- viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
- //connecting model to QML
- DeclarativePurchaseListModel model;
- QDeclarativeContext *ctxt = viewer.rootContext();
- ctxt->setContextProperty("drmListModel", &model);
- ItemstatusImageProvider itemStatusProvider(model);
- viewer.engine()->addImageProvider("imagestatusprovider", &itemStatusProvider);
- viewer.setMainQmlFile(QLatin1String("qml/inapppurchase/main.qml"));
- viewer.showExpanded();
- return app.exec();
- }
|