main.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /**
  2. * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
  3. * All rights reserved.
  4. *
  5. * For the applicable distribution terms see the license.txt -file, included in
  6. * the distribution.
  7. */
  8. #include <QtGui/QApplication>
  9. #include <QDeclarativeContext>
  10. #include <QDeclarativeEngine>
  11. #include "qmlapplicationviewer.h"
  12. #include "declarativepurchaselistmodel.h"
  13. #include "ItemstatusImageProvider.h"
  14. #include <QFile>
  15. #include <QTextStream>
  16. void myMessageHandler(QtMsgType type, const char *msg)
  17. {
  18. QString txt;
  19. switch (type) {
  20. case QtDebugMsg:
  21. txt = QString("Debug: %1").arg(msg);
  22. break;
  23. case QtWarningMsg:
  24. txt = QString("Warning: %1").arg(msg);
  25. break;
  26. case QtCriticalMsg:
  27. txt = QString("Critical: %1").arg(msg);
  28. break;
  29. case QtFatalMsg:
  30. txt = QString("Fatal: %1").arg(msg);
  31. abort();
  32. }
  33. QFile outFile("c:/data/inapppurchase.log");
  34. outFile.open(QIODevice::WriteOnly | QIODevice::Append);
  35. QTextStream ts(&outFile);
  36. ts << txt << endl;
  37. }
  38. int main(int argc, char *argv[])
  39. {
  40. QApplication app(argc, argv);
  41. qInstallMsgHandler(myMessageHandler);
  42. QmlApplicationViewer viewer;
  43. viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
  44. //connecting model to QML
  45. DeclarativePurchaseListModel model;
  46. QDeclarativeContext *ctxt = viewer.rootContext();
  47. ctxt->setContextProperty("drmListModel", &model);
  48. ItemstatusImageProvider itemStatusProvider(model);
  49. viewer.engine()->addImageProvider("imagestatusprovider", &itemStatusProvider);
  50. viewer.setMainQmlFile(QLatin1String("qml/inapppurchase/main.qml"));
  51. viewer.showExpanded();
  52. return app.exec();
  53. }