class SituareEnginePrivate
{
+ Q_DECLARE_PUBLIC(SituareEngine)
+ SituareEngine* q_ptr;
+
public:
+ FriendModel friendModel;
RouteModel routeModel;
+
+ QDeclarativeView* ui;
+
+ int progressIndicatorCount;
+
+ SituareEnginePrivate(SituareEngine* parent)
+ : q_ptr(parent), routeModel(0), ui(0), progressIndicatorCount(0)
+ {}
+
+ void toggleProgressIndicator(bool value)
+ {
+#ifdef QML_UI
+ qDebug() << __PRETTY_FUNCTION__;
+
+ #ifdef Q_WS_MAEMO_5
+ if(value) {
+ progressIndicatorCount++;
+ ui->setAttribute(Qt::WA_Maemo5ShowProgressIndicator, true);
+ } else {
+ if(progressIndicatorCount > 0)
+ progressIndicatorCount--;
+
+ if(progressIndicatorCount == 0)
+ ui->setAttribute(Qt::WA_Maemo5ShowProgressIndicator, false);
+ }
+ #else
+ Q_UNUSED(value);
+ #endif // Q_WS_MAEMO_5
+#else
+ Q_Q(SituareEngine);
+ q->m_ui->toggleProgressIndicator(value);
+#endif
+ }
};
SituareEngine::SituareEngine()
#ifdef QML_UI
qmlRegisterType<GeoMap>("MapPlugin", 1, 0, "GeoMap");
- QDeclarativeView* view = new QDeclarativeView(QApplication::desktop());
+ Q_D(SituareEngine);
+
+ d->ui = new QDeclarativeView(QApplication::desktop());
#ifdef Q_WS_MAEMO_5
-// view.setAttribute(Qt::WA_Maemo5AutoOrientation, true);
+// d->ui->setAttribute(Qt::WA_Maemo5AutoOrientation, true);
#endif
- Q_D(SituareEngine);
Rotation *rotation = new Rotation();
- view->rootContext()->setContextProperty("deviceRotation", static_cast<QObject *>(rotation));
- view->rootContext()->setContextProperty("facebookAuthenticator", m_facebookAuthenticator);
-
- // test segments
- for( int i = 0; i < 4; ++i) {
- RouteSegment segment;
- segment.setInstruction(i != 3 ? "Turn left" : "You're back at starting point");
- d->routeModel.addSegment(segment);
- }
- view->rootContext()->setContextProperty("routingModel", &d->routeModel);
- view->rootContext()->setContextProperty("friendModel", &d->friendModel);
- view->rootContext()->setContextProperty("engine", this);
+ d->ui->rootContext()->setContextProperty("deviceRotation", static_cast<QObject *>(rotation));
+ d->ui->rootContext()->setContextProperty("facebookAuthenticator", m_facebookAuthenticator);
++ d->ui->rootContext()->setContextProperty("routingModel", &d->routeModel);
++ d->ui->rootContext()->setContextProperty("friendModel", &d->friendModel);
++ d->ui->rootContext()->setContextProperty("engine", this);
+
+ d->ui->rootContext()->setContextProperty("routingModel", &d->routeModel);
+ d->ui->rootContext()->setContextProperty("engine", this);
- view->setSource(QUrl("qrc:/Main.qml"));
- view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
- view->show();
+ d->ui->setSource(QUrl("qrc:/Main.qml"));
+ d->ui->setResizeMode(QDeclarativeView::SizeRootObjectToView);
+ d->ui->show();
- connect(view->engine()->networkAccessManager(),
+ connect(d->ui->engine()->networkAccessManager(),
SIGNAL(sslErrors(QNetworkReply*, QList<QSslError>)),
m_facebookAuthenticator, SLOT(sslErrors(QNetworkReply*, QList<QSslError>)));
#else
emit userLocationReady(user);
emit friendsLocationsReady(friendsList);
- Q_D(SituareEngine);
+ d->friendModel.setFriends(friendsList);
}
void SituareEngine::routeFromTo(double fromLatitude, double fromLongitude, double toLatitude, double toLongitude)