Permalink
Browse files

Added distance calculation and disabled next button

  • Loading branch information...
1 parent 9db66e5 commit 527e4ab50eba17c4780c595472afd29528a922ef @gnuvince committed Apr 17, 2011
View
@@ -1,6 +1,6 @@
#############################################################################
# Makefile for building: projet
-# Generated by qmake (2.01a) (Qt 4.7.2) on: Fri Apr 15 14:03:25 2011
+# Generated by qmake (2.01a) (Qt 4.7.2) on: Sun Apr 17 16:28:11 2011
# Project: projet.pro
# Template: app
# Command: /usr/bin/qmake -spec /usr/share/qt/mkspecs/linux-g++-64 QMLJSDEBUGGER_PATH=/usr/share/qtcreator/qml/qmljsdebugger -o Makefile projet.pro
@@ -359,6 +359,9 @@ moc_cartewidget.cpp: geoposition.h \
/usr/bin/moc $(DEFINES) $(INCPATH) cartewidget.h -o moc_cartewidget.cpp
moc_userinterface.cpp: pages/page.h \
+ station.h \
+ geoposition.h \
+ stationmodel.h \
userinterface.h
/usr/bin/moc $(DEFINES) $(INCPATH) userinterface.h -o moc_userinterface.cpp
@@ -377,7 +380,10 @@ moc_selectpositionpage.cpp: pages/page.h \
pages/selectpositionpage.h
/usr/bin/moc $(DEFINES) $(INCPATH) pages/selectpositionpage.h -o moc_selectpositionpage.cpp
-moc_selectstationpage.cpp: pages/page.h \
+moc_selectstationpage.cpp: stationmodel.h \
+ station.h \
+ geoposition.h \
+ pages/page.h \
pages/selectstationpage.h
/usr/bin/moc $(DEFINES) $(INCPATH) pages/selectstationpage.h -o moc_selectstationpage.cpp
@@ -556,13 +562,17 @@ cartewidget.o: cartewidget.cpp cartescene.h \
userinterface.o: userinterface.cpp userinterface.h \
pages/page.h \
+ station.h \
+ geoposition.h \
+ stationmodel.h \
ui_userinterface.h \
pages/mainmenupage.h \
pages/findstationpage.h \
pages/selectpositionpage.h \
pages/selectstationpage.h \
pages/selecttimepage.h \
- pages/selectcarpage.h
+ pages/selectcarpage.h \
+ pages/confirmpage.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o userinterface.o userinterface.cpp
page.o: pages/page.cpp pages/page.h
@@ -585,6 +595,9 @@ selectpositionpage.o: pages/selectpositionpage.cpp pages/page.h \
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o selectpositionpage.o pages/selectpositionpage.cpp
selectstationpage.o: pages/selectstationpage.cpp pages/selectstationpage.h \
+ stationmodel.h \
+ station.h \
+ geoposition.h \
pages/page.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o selectstationpage.o pages/selectstationpage.cpp
View
@@ -69,7 +69,7 @@ bool CarteWidget::eventFilter(QObject *, QEvent *ev)
flag->setVisible(true);
_flagPos = CarteScene::PointToGPS(pos);
//pour etre propre on devrait emettre le signal mais bon ...
- //emit editFinished();
+ emit editFinished();
}
}
return false;
View
@@ -18,11 +18,29 @@
#include "geoposition.h"
+#include <cmath>
+
GeoPosition::GeoPosition(qreal lat, qreal lon) :
lat(lat), lon(lon)
{
}
+
+qreal toRad(double deg) {
+ return deg * M_PI / 180.0;
+}
+
+qreal GeoPosition::distanceFrom(GeoPosition *other) {
+ qreal R = 6371; // Diameter of the Earth
+ qreal lat1 = toRad(this->getLat()),
+ lat2 = toRad(other->getLat()),
+ lon1 = toRad(this->getLon()),
+ lon2 = toRad(other->getLon());
+ return acos(sin(lat1) * sin(lat2) +
+ cos(lat1) * cos(lat2) *
+ cos(lon2 - lon1)) * R;
+}
+
QDataStream& operator<<(QDataStream &ds, const GeoPosition &pos)
{
ds << pos.lat << pos.lon;
View
@@ -39,6 +39,8 @@ class GeoPosition
qreal getLon() const { return lon; }
void setLon(qreal lon) { this->lon = lon; }
+ qreal distanceFrom(GeoPosition *other);
+
private:
qreal lat, lon;
View
@@ -40,7 +40,6 @@ MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
- /*
ui->setupUi(this);
QString abs_path;
@@ -154,10 +153,7 @@ MainWindow::MainWindow(QWidget *parent) :
//important tout le monde partage la scène !
CarteWidget::setScene(scene);
-
- */
-
- UserInterface *userInterface = new UserInterface(this);
+ UserInterface *userInterface = new UserInterface(smodel, this);
userInterface->show();
}
@@ -19,13 +19,19 @@ SelectPositionPage::SelectPositionPage(QWidget *parent) :
QPushButton *btnPrevious = new QPushButton(this);
btnPrevious->setIcon(QIcon(":/icones/data/icons/arrow_left.png"));
- QPushButton *btnNext = new QPushButton(this);
+ btnNext = new QPushButton(this);
btnNext->setIcon(QIcon(":/icones/data/icons/arrow_right.png"));
QPushButton *btnMenu = new QPushButton(trUtf8("Menu"), this);
+ btnNext->setEnabled(false);
addBottomButtons(btnPrevious, btnMenu, btnNext);
+ connect(mapWidget, SIGNAL(editFinished()), this, SLOT(enableNextButton()));
connect(btnPrevious, SIGNAL(clicked()), SIGNAL(Previous()));
connect(btnMenu, SIGNAL(clicked()), SIGNAL(Menu()));
connect(btnNext, SIGNAL(clicked()), SIGNAL(Next()));
}
+
+void SelectPositionPage::enableNextButton() {
+ btnNext->setEnabled(true);
+}
@@ -14,6 +14,10 @@ class SelectPositionPage : public Page
public slots:
+ void enableNextButton();
+
+private:
+ QPushButton *btnNext;
};
@@ -1,12 +1,25 @@
#include "selectstationpage.h"
#include "page.h"
+#include "stationmodel.h"
#include <QtGui>
-SelectStationPage::SelectStationPage(QWidget *parent) :
- Page(parent)
+SelectStationPage::SelectStationPage(
+ StationModel *smodel,
+ QWidget *parent) :
+ Page(parent),
+ stationModel(smodel)
{
QTableView *view = new QTableView(this);
+ view->setModel(stationModel);
+ view->setSelectionBehavior(QAbstractItemView::SelectRows);
+
+ QList<qint32> hiddenColumns;
+ hiddenColumns << 0 << 2 << 3 << 4 << 5 << 6;
+ foreach (qint32 col, hiddenColumns) {
+ view->hideColumn(col);
+ }
+
QPushButton *btnPrevious = new QPushButton(this);
btnPrevious->setIcon(QIcon(":/icones/data/icons/arrow_left.png"));
@@ -1,20 +1,27 @@
#ifndef SELECTSTATIONPAGE_H
#define SELECTSTATIONPAGE_H
+#include "stationmodel.h"
+
#include "page.h"
#include <QtGui>
class SelectStationPage : public Page
{
Q_OBJECT
public:
- explicit SelectStationPage(QWidget *parent = 0);
+ explicit SelectStationPage(
+ StationModel *smodel,
+ QWidget *parent = 0);
signals:
public slots:
+private:
+ StationModel *stationModel;
+
};
#endif // SELECTSTATIONPAGE_H
View
@@ -10,13 +10,18 @@
#include "pages/selectcarpage.h"
#include "pages/confirmpage.h"
+#include "stationmodel.h"
+
#include <QDebug>
#define DEFAULT_PAGE Page_MainMenu
-UserInterface::UserInterface(QWidget *parent) :
+UserInterface::UserInterface(
+ StationModel *smodel,
+ QWidget *parent) :
QMainWindow(parent),
+ stationModel(smodel),
ui(new Ui::UserInterface)
{
ui->setupUi(this);
@@ -28,7 +33,7 @@ UserInterface::UserInterface(QWidget *parent) :
pages->insert(Page_MainMenu, new MainMenuPage(this));
pages->insert(Page_FindStation, new FindStationPage(this));
pages->insert(Page_SelectPosition, new SelectPositionPage(this));
- pages->insert(Page_SelectStation, new SelectStationPage(this));
+ pages->insert(Page_SelectStation, new SelectStationPage(stationModel, this));
pages->insert(Page_SelectTime, new SelectTimePage(this));
pages->insert(Page_SelectCar, new SelectCarPage(this));
pages->insert(Page_Confirm, new ConfirmPage(this));
View
@@ -7,6 +7,8 @@
#include <QMap>
#include "pages/page.h"
+#include "station.h"
+#include "stationmodel.h"
enum PageName { Page_MainMenu,
Page_FindStation, Page_SelectPosition, Page_SelectStation, Page_SelectTime, Page_SelectCar, Page_Confirm,
@@ -21,13 +23,16 @@ class UserInterface : public QMainWindow
Q_OBJECT
public:
- explicit UserInterface(QWidget *parent = 0);
+ explicit UserInterface(
+ StationModel *smodel,
+ QWidget *parent = 0);
~UserInterface();
private:
Ui::UserInterface *ui;
QMap<PageName, Page*> *pages;
Page* getPage(PageName name);
+ StationModel *stationModel;
public slots:
void gotoPage(PageName name);

0 comments on commit 527e4ab

Please sign in to comment.