Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

merged userinterface.cpp manually

  • Loading branch information...
commit 36c808aca44234314dd3f8d3799467bac0674c8c 2 parents a88c343 + 3061d31
@Gabriano Gabriano authored
View
41 pages/confirmpage.cpp
@@ -2,13 +2,27 @@
#include "page.h"
#include "confirmpage.h"
+#include "vehicule.h"
-ConfirmPage::ConfirmPage(QWidget *parent) :
- Page(parent)
+ConfirmPage::ConfirmPage(Reservation *reservation,
+ UsagerModel *umodel,
+ VehiculeModel *vmodel,
+ StationModel *smodel,
+ QWidget *parent) :
+ Page(parent),
+ reservation(reservation),
+ umodel(umodel),
+ vmodel(vmodel),
+ smodel(smodel)
{
addTitle(trUtf8("Confirmer la réservation"));
- QPlainTextEdit *editor = new QPlainTextEdit(this);
+
+ editor = new QPlainTextEdit(this);
+ editor->setReadOnly(true);
+ editor->setFont(QFont("Courier"));
+
+
addWidget(editor);
QPushButton *btnPrevious = new QPushButton(this);
@@ -23,3 +37,24 @@ ConfirmPage::ConfirmPage(QWidget *parent) :
connect(btnMenu, SIGNAL(clicked()), SIGNAL(Menu()));
connect(btnConfirm, SIGNAL(clicked()), SIGNAL(Confirm()));
}
+
+void ConfirmPage::setEditorText() {
+ QString username = umodel->getUsager(reservation->getUsager())->getNom();
+ QString station = smodel->getStation(reservation->getStation())->getNom();
+ Vehicule *vehicule = vmodel->getVehicule(reservation->getVehicule());
+ QString vehiculeName = trUtf8("%1 %2 (%3)").arg(vehicule->getMarque())
+ .arg(vehicule->getModele()).arg(vehicule->getCouleur());
+
+ editor->setPlainText(
+ trUtf8("Usager : %1\n"
+ "Station : %2\n"
+ "Véhicule: %3\n"
+ "Départ : %4\n"
+ "Retour : %5\n")
+ .arg(username)
+ .arg(station)
+ .arg(vehiculeName)
+ .arg(reservation->getDebut().toString("dd MMM yyyy hh:mm"))
+ .arg(reservation->getFin().toString("dd MMM yyyy hh:mm"))
+ );
+}
View
20 pages/confirmpage.h
@@ -4,17 +4,35 @@
#include <QtGui>
#include "page.h"
+#include "reservation.h"
+#include "usagermodel.h"
+#include "vehiculemodel.h"
+#include "reservationmodel.h"
+#include "stationmodel.h"
class ConfirmPage : public Page
{
Q_OBJECT
public:
- explicit ConfirmPage(QWidget *parent = 0);
+ explicit ConfirmPage(Reservation *reservation,
+ UsagerModel *umodel,
+ VehiculeModel *vmodel,
+ StationModel *smodel,
+ QWidget *parent = 0);
+
+private:
+ Reservation *reservation;
+ UsagerModel *umodel;
+ VehiculeModel *vmodel;
+ StationModel *smodel;
+ QPlainTextEdit *editor;
+
signals:
void Confirm();
public slots:
+ void setEditorText();
};
View
29 userinterface.cpp
@@ -44,9 +44,8 @@ UserInterface::UserInterface(
pages = new QMap<PageName, Page*>;
- reservation = new Reservation(this);
+ reservation = new Reservation(QDateTime::currentDateTime(), QDateTime::currentDateTime(), 0, 0, 0, this);
currentPosition = new GeoPosition(0, 0);
- stationModel->updateCurrentPosition(*currentPosition);
stationProxy = new StationSortProxy(this);
stationProxy->setSourceModel(stationModel);
@@ -70,8 +69,12 @@ void UserInterface::createPages() {
pages->insert(Page_SelectStation, new SelectStationPage(stationProxy, this));
pages->insert(Page_SelectTime, new SelectTimePage(this));
pages->insert(Page_SelectCar, new SelectCarPage(vehiculeProxy, this));
- pages->insert(Page_Confirm, new ConfirmPage(this));
- pages->insert(Page_Bookings, new BookingsPage(reservationProxy, this));
+ pages->insert(Page_Confirm, new ConfirmPage(reservation,
+ usagerModel,
+ vehiculeModel,
+ stationModel,
+ this));
+ pages->insert(Page_Bookings, new BookingsPage(this));
pages->insert(Page_Comments, new CommentsPage(this)); // comments main page
pages->insert(Page_WriteComment, new WriteCommentPage(this)); // comment editing
pages->insert(Page_Unexpected, new UnexpectedPage(this));
@@ -95,6 +98,7 @@ void UserInterface::createPages() {
// Connections for main menu
connect(getPage(Page_MainMenu), SIGNAL(BookCar()), this, SLOT(gotoFindStationPage()));
+ connect(getPage(Page_MainMenu), SIGNAL(BookCar()), this, SLOT(resetReservation()));
connect(getPage(Page_MainMenu), SIGNAL(ViewBookings()), this, SLOT(gotoBookings()));
connect(getPage(Page_MainMenu), SIGNAL(LeaveComment()), this, SLOT(gotoCommentPage()));
connect(getPage(Page_MainMenu), SIGNAL(ReportUnexpected()), this, SLOT(gotoUnexpected()));
@@ -132,11 +136,14 @@ void UserInterface::createPages() {
connect(getPage(Page_SelectCar), SIGNAL(Previous()), this, SLOT(gotoSelectTime()));
connect(getPage(Page_SelectCar), SIGNAL(Next()), this, SLOT(gotoConfirm()));
connect(getPage(Page_SelectCar), SIGNAL(carSelected(qint64)), this, SLOT(setCarId(qint64)));
+ connect(getPage(Page_SelectCar), SIGNAL(Next()), getPage(Page_Confirm), SLOT(setEditorText()));
// Connections for confirm
connect(getPage(Page_Confirm), SIGNAL(Menu()), this, SLOT(gotoMainMenu()));
connect(getPage(Page_Confirm), SIGNAL(Previous()), this, SLOT(gotoSelectCar()));
connect(getPage(Page_Confirm), SIGNAL(Confirm()), this, SLOT(gotoMainMenu()));
+ connect(getPage(Page_Confirm), SIGNAL(Confirm()), this, SLOT(saveReservation()));
+
// Connections for bookings
connect(getPage(Page_Bookings), SIGNAL(Menu()), this, SLOT(gotoMainMenu()));
@@ -258,3 +265,17 @@ void UserInterface::setStationId(qint64 stationId) {
void UserInterface::setCarId(qint64 carId) {
reservation->setVehicule(carId);
}
+
+
+void UserInterface::resetReservation() {
+ reservation->setDebut(QDateTime::currentDateTime());
+ reservation->setFin(QDateTime::currentDateTime());
+ reservation->setStation(0);
+ reservation->setVehicule(0);
+ reservation->setUsager(user->getId());
+}
+
+
+void UserInterface::saveReservation() {
+ reservationModel->addReservation(reservation);
+}
View
3  userinterface.h
@@ -55,6 +55,7 @@ class UserInterface : public QMainWindow
ReservationFilterProxy *reservationProxy;
GeoPosition *currentPosition;
Reservation *reservation;
+ ReservationModel *reservationModel;
public slots:
@@ -77,6 +78,8 @@ public slots:
void setStationId(qint64 stationId);
void setCarId(qint64 carId);
void setUser(qint64 id);
+ void resetReservation();
+ void saveReservation();
};
#endif // USERINTERFACE_H
Please sign in to comment.
Something went wrong with that request. Please try again.