++<<<<<<< HEAD:situare.pro
+# -------------------------------------------------
+# Project created by QtCreator 2010-03-26T07:57:35
+# -------------------------------------------------
+TARGET = Situare
+TEMPLATE = app
+QT += network \
+ testlib
+INCLUDEPATH += . \
+ src/tests/testmap/ \
+ src/map/
+SOURCES += src/map/mapfetcher.cpp \
+ src/map/mapengine.cpp \
+ tests/testmap/testmapfetcher.cpp \
+# tests/testmap/testmapengine.cpp \
+ src/ui/mainwindow.cpp \
+ tests/testmap/networkaccessmanagermock.cpp \
+ tests/testmap/networkreplymock.cpp
+HEADERS += src/map/mapfetcher.h \
+ src/map/mapengine.h \
+ src/ui/mainwindow.h \
+ tests/testmap/networkaccessmanagermock.h \
+ tests/testmap/networkreplymock.h
++=======
+ QMAKEVERSION = $$[QMAKE_VERSION]
+ ISQT4 = $$find(QMAKEVERSION, ^[2-9])
+ isEmpty( ISQT4 ) {
+ error("Use the qmake include with Qt4.6.2 or greater");
+ }
+ TEMPLATE = subdirs
+ SUBDIRS = src
++>>>>>>> master:situare.pro
- /*
- Situare - A location system for Facebook
- Copyright (C) 2010 Ixonos Plc. Authors:
+/*
+ Situare - A location system for Facebook
+ Copyright (C) 2010 Ixonos Plc. Authors:
- Sami Rämö - sami.ramo@ixonos.com
+ Jussi Laitinen - jussi.laitinen@ixonos.com
- Situare is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
+ Situare is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ version 2 as published by the Free Software Foundation.
- Situare is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Situare; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
- USA.
- */
+ Situare is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+ You should have received a copy of the GNU General Public License
+ along with Situare; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA.
+*/
#ifndef MAPENGINE_H
#define MAPENGINE_H
-#include "mapview.h"
-#include "mapscene.h"
+#include <QtCore>
-
-class MapEngine
+/**
+* @brief MapEngine controls Map.
+*
+* @class MapEngine mapengine.h "map/mapengine.h"
+*/
+class MapEngine : public QObject
{
-public:
- MapEngine();
- MapEngine(MapView *mapView);
- QPoint convertTileNumberToSceneCoordinate(int zoomLevel, QPoint tileNumber);
+ Q_OBJECT
public:
- static const int TILE_SIZE_X = 256;
- static const int TILE_SIZE_Y = 256;
- static const int MAX_ZOOM_LEVEL = 18;
+ /**
+ * @brief Constructor for the MapEngine.
+ *
+ * @fn MapEngine
+ * @param parent QObject
+ */
+ MapEngine(QObject *parent = 0);
+
+ /**
+ * @brief Transforms coordinates to tile x,y values.
+ *
+ * @fn latLonToTile
+ * @param latitude latitude value
+ * @param longitude longitude value
+ * @param zoom zoom level
+ * @return QPoint tile x,y
+ */
+ QPoint latLonToTile(qreal latitude, qreal longitude, int zoom);
+
+ /**
+ * @brief Transforms tile x value to longitude.
+ *
+ * @fn tileXToLongitude
+ * @param x tile x value
+ * @param zoom zoom value
+ * @return qreal longitude
+ */
+ qreal tileXToLongitude(int x, int zoom);
-private:
- MapView *m_mapView;
- MapScene *m_mapScene;
+ /**
+ * @brief Transforms tile y value to latitude.
+ *
+ * @fn tileYToLatitude
+ * @param y tile y value
+ * @param zoom zoom value
+ * @return qreal latitude
+ */
+ qreal tileYToLatitude(int y, int zoom);
};
#endif // MAPENGINE_H
--/*
- Situare - A location system for Facebook
- Copyright (C) 2010 Ixonos Plc. Authors:
-
- Henri Lampela - henri.lampela@ixonos.com
-
- Situare is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- version 2 as published by the Free Software Foundation.
-
- Situare is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Situare; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
- USA.
- */
-
- #include <QPushButton>
- #include <QVBoxLayout>
-
- #include "mainwindow.h"
- #include "mapfetcher.h"
-
- MainWindow::MainWindow(QWidget *parent)
- : QWidget(parent)
- {
- this->setWindowTitle(tr("Situare"));
-
- QNetworkAccessManager *manager = new QNetworkAccessManager(this);
- mapFetcher = new MapFetcher(this, manager);
-
- connect(mapFetcher, SIGNAL(mapImageReceived(QUrl,QPixmap)), this, SLOT(imageReceived(QUrl,QPixmap)));
-
- QPushButton *button = new QPushButton("Fetch");
- QLabel *label = new QLabel(this);
- connect(button, SIGNAL(clicked()), this, SLOT(debug()));
-
- QWidget *widget = new QWidget(this);
- QVBoxLayout *vbox = new QVBoxLayout;
- vbox->addWidget(button);
- vbox->addWidget(label);
- widget->setLayout(vbox);
- this->setLayout(vbox);
- }
-
- void MainWindow::imageReceived(const QUrl &url, const QPixmap &image)
- {
- qDebug() << __PRETTY_FUNCTION__;
- QLabel *label = new QLabel();
- label->setPixmap(image);
- label->show();
- }
-
- void MainWindow::debug()
- {
- qDebug() << __PRETTY_FUNCTION__;
- for (int i = 4; i < 6; ++i)
- for (int j = 0; j < 2; ++j)
- mapFetcher->fetchMapImage(QUrl(QString("http://tile.openstreetmap.org/mapnik/13/467%1/213%2.png")
- .arg(i).arg(j)));
- }
-
- MainWindow::~MainWindow()
- {
-
- }
- Situare - A location system for Facebook
- Copyright (C) 2010 Ixonos Plc. Authors:
-
- Henri Lampela - henri.lampela@ixonos.com
- Kaj Wallin - kaj.wallin@ixonos.com
-
- Situare is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- version 2 as published by the Free Software Foundation.
-
- Situare is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Situare; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
- USA.
-*/
-
-#include <QtGui>
-#include "mainwindow.h"
-#include "listviewscreen.h"
-#include "mapviewscreen.h"
-
-MainWindow::MainWindow(QWidget *parent)
- : QMainWindow(parent)
-{
- qDebug() << __PRETTY_FUNCTION__;
- QWidget *widget = new QWidget;
- setCentralWidget(widget);
- createViews();
- QVBoxLayout *mainLayout = new QVBoxLayout;
- infoLabel = new QLabel(tr("Click \"view\", to change between views"),this);
- infoLabel->setAttribute(Qt::WA_TranslucentBackground, true);
- mainLayout->addWidget(infoLabel);
- mainLayout->addWidget(situareViews);
- widget->setLayout(mainLayout);
- createMenus();
-
- setWindowTitle(tr("View"));
-}
-
-MainWindow::~MainWindow()
-{
- qDebug() << __PRETTY_FUNCTION__;
- delete toListViewAct;
- delete toMapViewAct;
- delete situareViews;
- delete infoLabel;
-}
-
-void MainWindow::createMenus()
-{
- qDebug() << __PRETTY_FUNCTION__;
- toListViewAct = new QAction(tr("List"), this);
- connect(toListViewAct, SIGNAL(triggered()), this, SLOT(toListView()));
- toMapViewAct = new QAction(tr("Map"), this);
- connect(toMapViewAct, SIGNAL(triggered()), this, SLOT(toMapView()));
- viewMenu = menuBar()->addMenu(tr("View"));
- viewMenu->addAction(toListViewAct);
- viewMenu->addAction(toMapViewAct);
-}
-
-void MainWindow::createViews()
-{
- qDebug() << __PRETTY_FUNCTION__;
- situareViews = new QStackedWidget;
- situareViews->addWidget(new ListViewScreen);
- situareViews->addWidget(new MapViewScreen);
-}
-
-void MainWindow::toListView()
-{
- qDebug() << __PRETTY_FUNCTION__;
- switchView(0);
-}
-
-void MainWindow::toMapView()
-{
- qDebug() << __PRETTY_FUNCTION__;
- switchView(1);
-}
-
-void MainWindow::switchView(int nextIndex)
-{
- qDebug() << __PRETTY_FUNCTION__ << ":" << nextIndex;
- if (nextIndex < 0 || nextIndex > 1) {
- qDebug() << tr("Illegal parameter value in MainWindow::switchView");
- return;
- }
- situareViews->setCurrentIndex(nextIndex);
- infoLabel->setText(tr("Current: %1").arg(situareViews->currentIndex()));
- switch (situareViews->currentIndex()) {
- case 0:
- setWindowTitle(tr("List"));
- break;
- case 1:
- setWindowTitle(tr("Map"));
- break;
- default:
- qDebug() << tr("Illegal switch value in MainWindow::switchView");
- break;
- }
-}
-
-int MainWindow::getViewIndex()
-{
- return situareViews->currentIndex();
-}
--/*
- Situare - A location system for Facebook
- Copyright (C) 2010 Ixonos Plc. Authors:
-
- Henri Lampela - henri.lampela@ixonos.com
-
- Situare is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- version 2 as published by the Free Software Foundation.
-
- Situare is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Situare; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
- USA.
- */
-
- #ifndef MAINWINDOW_H
- #define MAINWINDOW_H
-
- #include <QtGui/QMainWindow>
- #include <QLabel>
- #include <QUrl>
- #include <QPixmap>
- #include <QWidget>
- #include "mapfetcher.h"
-
- class MainWindow : public QWidget
- {
- Q_OBJECT
-
- public:
- MainWindow(QWidget *parent = 0);
- ~MainWindow();
-
- signals:
- void fetchImage(const QUrl &url);
-
- public slots:
- void debug();
- void imageReceived(const QUrl &url, const QPixmap &image);
-
- private:
- MapFetcher *mapFetcher;
- };
-
- #endif // MAINWINDOW_H
- Situare - A location system for Facebook
- Copyright (C) 2010 Ixonos Plc. Authors:
-
- Henri Lampela - henri.lampela@ixonos.com
- Kaj Wallin - kaj.wallin@ixonos.com
-
- Situare is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- version 2 as published by the Free Software Foundation.
-
- Situare is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Situare; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
- USA.
-*/
-
-
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
-
-#include <QtGui/QMainWindow>
-#include <QWidget>
-#include <QDebug>
-
-class QLabel;
-class QStackedWidget;
-
-/**
-* @Main Window Class
-*
-* @class MainWindow mainwindow.h "src/ui/mainwindow.h"
-*/
-class MainWindow : public QMainWindow
-{
- Q_OBJECT
-
-public:
- MainWindow(QWidget *parent = 0);
- ~MainWindow();
-
- /**
- * @brief Public method to get current index of the view. Used for Unit testing
- *
- * @fn getViewIndex
- */
- int getViewIndex();
-
-private:
- /**
- * @brief Private method to create List and Map views as a stacked widget
- *
- * @fn createViews
- */
- void createViews();
- /**
- * @brief Widget Stack object for the List and Map Views
- *
- * @var situareViews
- */
- QStackedWidget *situareViews;
-
- /**
- * @brief Private method to create the Menu items
- *
- * @fn createMenus
- */
- void createMenus();
- QMenu *viewMenu;
-
- /**
- * @brief Action item for changing view to List View
- *
- * @var toListViewAct
- */
- QAction *toListViewAct;
- /**
- * @brief Action item for changing view to Map View
- *
- * @var toMapViewAct
- */
- QAction *toMapViewAct;
-
- /**
- * @brief Method used to switch active view.
- *
- * @fn switchView
- * @param int 0 for listview, 1 for mapview
- */
- void switchView(int);
-
- /**
- * @brief DUMMY LABEL, REMOVE WHEN BOTH VIEWS ARE COMPLETE
- *
- * @var infoLabel
- * @todo REMOVE THIS
- */
- QLabel *infoLabel;
-
-
-public slots:
- /**
- * @brief Public slot, which initiates toListViewAct action to switch view
- *
- * @fn toListView
- */
- void toListView();
- /**
- * @brief Public slot, which initiates toMapViewAct action to switch view
- *
- * @fn toMapView
- */
- void toMapView();
-};
-
-#endif // MAINWINDOW_H