Permalink
Browse files

manual merge

  • Loading branch information...
Gabriano committed Apr 26, 2011
2 parents 4735528 + 7353bec commit 2f546724d44c02ae891ac185d612b82f9aadd946
View
@@ -155,6 +155,7 @@ MainWindow::MainWindow(QWidget *parent) :
UserInterface *userInterface = new UserInterface(smodel, vmodel, umodel, rmodel, this);
connect(this, SIGNAL(interfaceUsagerId(qint64)), userInterface, SLOT(setUser(qint64)));
+ emit interfaceUsagerId(2);
userInterface->show();
}
View
@@ -16,20 +16,29 @@ SelectCarPage::SelectCarPage(VehiculeFilterProxy *vproxy, QWidget *parent) :
view->setSelectionBehavior(QAbstractItemView::SelectRows);
view->setSelectionMode(QAbstractItemView::SingleSelection);
view->verticalHeader()->hide();
- view->hideColumn(0);
+ view->hideColumn(Vehicule::COL_ID);
view->resizeColumnsToContents();
view->resizeRowsToContents();
addWidget(view);
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"));
+ btnNext->setEnabled(false);
QPushButton *btnMenu = new QPushButton(trUtf8("Menu"), this);
addBottomButtons(btnPrevious, btnMenu, btnNext);
connect(btnPrevious, SIGNAL(clicked()), SIGNAL(Previous()));
connect(btnMenu, SIGNAL(clicked()), SIGNAL(Menu()));
connect(btnNext, SIGNAL(clicked()), SIGNAL(Next()));
+ connect(view, SIGNAL(clicked(QModelIndex)), this, SLOT(selectedCar(QModelIndex)));
+}
+
+void SelectCarPage::selectedCar(QModelIndex index) {
+ btnNext->setEnabled(true);
+
+ QModelIndex index2 = index.model()->index(index.row(), Vehicule::COL_ID);
+ emit carSelected(index2.data().toInt());
}
View
@@ -2,6 +2,7 @@
#define SELECTCARPAGE_H
#include <QtGui>
+#include <QModelIndex>
#include "page.h"
#include "vehiculefilterproxy.h"
@@ -14,11 +15,13 @@ class SelectCarPage : public Page
private:
VehiculeFilterProxy *vehiculeProxy;
+ QPushButton *btnNext;
signals:
-
+ void carSelected(qint64 carId);
public slots:
+ void selectedCar(QModelIndex index);
};
@@ -50,6 +50,9 @@ SelectStationPage::SelectStationPage(
void SelectStationPage::stationSelected(QModelIndex index) {
btnNext->setEnabled(true);
+
+ QModelIndex index2 = index.model()->index(index.row(), Station::COL_ID);
+ emit selectedStation(index2.data().toInt());
}
@@ -17,6 +17,7 @@ class SelectStationPage : public Page
signals:
void showInfoStation(Station *station);
+ void selectedStation(qint64 stationId);
public slots:
void stationSelected(QModelIndex index);
View
@@ -55,9 +55,15 @@ SelectTimePage::SelectTimePage(QWidget *parent) :
connect(btnPrevious, SIGNAL(clicked()), SIGNAL(Previous()));
connect(btnMenu, SIGNAL(clicked()), SIGNAL(Menu()));
connect(btnNext, SIGNAL(clicked()), SIGNAL(Next()));
+ connect(btnNext, SIGNAL(clicked()), this, SLOT(emitDates()));
}
void SelectTimePage::setMinimalEndDateTime(QDateTime time) {
QDateTime fifteenMinutesPast = time.addSecs(15 * 60);
endTime->setMinimumDateTime(fifteenMinutesPast);
}
+
+
+void SelectTimePage::emitDates() {
+ emit selectedTime(startTime->dateTime(), endTime->dateTime());
+}
View
@@ -12,9 +12,11 @@ class SelectTimePage : public Page
explicit SelectTimePage(QWidget *parent = 0);
signals:
+ void selectedTime(QDateTime start, QDateTime end);
public slots:
void setMinimalEndDateTime(QDateTime time);
+ void emitDates();
private:
QDateTimeEdit *startTime;
View
@@ -1,7 +1,7 @@
/****************************************************************************
** Resource object code
**
-** Created: Mon Apr 25 22:04:50 2011
+** Created: Tue Apr 26 10:13:33 2011
** by: The Resource Compiler for Qt version 4.7.2
**
** WARNING! All changes made in this file will be lost!
View
@@ -24,6 +24,7 @@
#include <QDateTime>
#include <QStringList>
+
class ReservationModel;
class Reservation : public QObject
@@ -34,6 +35,7 @@ class Reservation : public QObject
enum Colonnes { COL_ID, COL_DEBUT, COL_FIN, COL_VEHICULE, COL_USAGER, COL_STATION, COL_PERSO };
public:
+ Reservation(QObject *parent=0) : QObject(parent) {}
explicit Reservation(QDateTime debut, QDateTime fin, qint64 vehicule, qint64 usager, qint64 station, QObject *parent=0);
QVariant field(uint column, int role) const;
@@ -59,6 +61,7 @@ class Reservation : public QObject
static uint headerCount();
static QVariant header(uint column);
+
private:
static qint64 idCount;
qint64 id;
@@ -78,7 +81,6 @@ class Reservation : public QObject
friend QDataStream& operator<<(QDataStream& ds, const ReservationModel &pos);
friend QDataStream& operator>>(QDataStream& ds, ReservationModel &pos);
//pour le déserialisateur seulement ...
- Reservation(QObject *parent=0) : QObject(parent) {}
Reservation(const Reservation &n);
};
View
@@ -223,3 +223,12 @@ QDataStream& operator>>(QDataStream &ds, ReservationModel &model)
model.endResetModel();
return ds;
}
+
+
+qint64 ReservationModel::getVehiculeStation(qint64 vehiculeId) {
+ foreach (Reservation* reservation, reservations) {
+ if (reservation->getVehicule() == vehiculeId)
+ return reservation->getStation();
+ }
+ return -1;
+}
View
@@ -22,6 +22,8 @@
#include <QAbstractTableModel>
#include <QMap>
#include "reservation.h"
+#include "station.h"
+#include "vehicule.h"
class ReservationProxyModel;
@@ -54,6 +56,8 @@ class ReservationModel : public QAbstractTableModel
static const quint32 MAGIC_NUMBER = 0x182f3a41;
+ qint64 getVehiculeStation(qint64 vehiculeId);
+
private:
QVariant fieldAt(const QModelIndex &index, int role) const;
View
@@ -168,6 +168,8 @@ void Robot::simulInitialise(QDateTime now)
umodel->addUsager(new Usager(trUtf8("Sébastien"),GeoPosition(25.1,41.9),umodel));
umodel->addUsager(new Usager(trUtf8("Nicolas"),GeoPosition(15.1,42.9),umodel));
umodel->addUsager(new Usager(trUtf8("Maria"),GeoPosition(34.8,49.1),umodel));
+ umodel->addUsager(new Usager(trUtf8("Vincent"),GeoPosition(45.301944, -74.303889),umodel));
+ umodel->addUsager(new Usager(trUtf8("Eric"),GeoPosition(45.525, -73.877),umodel));
//
View
@@ -1,7 +1,7 @@
/********************************************************************************
** Form generated from reading UI file 'cartewidget.ui'
**
-** Created: Mon Apr 25 22:02:45 2011
+** Created: Tue Apr 26 10:11:30 2011
** by: Qt User Interface Compiler version 4.7.2
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
View
@@ -1,7 +1,7 @@
/********************************************************************************
** Form generated from reading UI file 'mainwindow.ui'
**
-** Created: Mon Apr 25 22:02:45 2011
+** Created: Tue Apr 26 10:11:30 2011
** by: Qt User Interface Compiler version 4.7.2
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
View
@@ -1,7 +1,7 @@
/********************************************************************************
** Form generated from reading UI file 'userinterface.ui'
**
-** Created: Mon Apr 25 22:02:45 2011
+** Created: Tue Apr 26 10:11:30 2011
** by: Qt User Interface Compiler version 4.7.2
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
View
@@ -41,25 +41,41 @@ UserInterface::UserInterface(
{
ui->setupUi(this);
- setUser(2);
- currentPosition = new GeoPosition(45.52, -73.58);
+ pages = new QMap<PageName, Page*>;
+
+ reservation = new Reservation(this);
+ currentPosition = new GeoPosition(0, 0);
stationModel->updateCurrentPosition(*currentPosition);
stationProxy = new StationSortProxy(this);
stationProxy->setSourceModel(stationModel);
stationProxy->setDynamicSortFilter(true);
stationProxy->sort(1);
- vehiculeProxy = new VehiculeFilterProxy(this);
+ vehiculeProxy = new VehiculeFilterProxy(rmodel, reservation, this);
vehiculeProxy->setSourceModel(vehiculeModel);
vehiculeProxy->setDynamicSortFilter(true);
+}
+void UserInterface::createPages() {
+ pages->clear();
+ 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(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(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));
+ pages->insert(Page_Email, new MyMessagesPage(this));
- reservationProxy = new ReservationProxyModel(this);
- reservationProxy->setSourceModel(reservationModel);
-
- pages = new QMap<PageName, Page*>;
- createPages();
+ for (int i = 0; i < ui->stackedWidget->count(); ++i) {
+ QWidget *w = ui->stackedWidget->widget(i);
+ ui->stackedWidget->removeWidget(w);
+ }
QMapIterator<PageName, Page*> iter(*pages);
while (iter.hasNext()) {
@@ -96,16 +112,21 @@ UserInterface::UserInterface(
connect(getPage(Page_SelectStation), SIGNAL(Previous()), this, SLOT(gotoSelectPosition()));
connect(getPage(Page_SelectStation), SIGNAL(Next()), this, SLOT(gotoSelectTime()));
connect(getPage(Page_SelectStation), SIGNAL(showInfoStation(Station*)), this, SLOT(showInfoStation(Station*)));
+ connect(getPage(Page_SelectStation), SIGNAL(selectedStation(qint64)), this, SLOT(setStationId(qint64)));
+ connect(getPage(Page_SelectStation), SIGNAL(selectedStation(qint64)), vehiculeProxy, SLOT(invalidate()));
// Connections for select time
connect(getPage(Page_SelectTime), SIGNAL(Menu()), this, SLOT(gotoMainMenu()));
connect(getPage(Page_SelectTime), SIGNAL(Previous()), this, SLOT(gotoSelectStation()));
connect(getPage(Page_SelectTime), SIGNAL(Next()), this, SLOT(gotoSelectCar()));
+ connect(getPage(Page_SelectTime), SIGNAL(selectedTime(QDateTime, QDateTime)), this, SLOT(setTimes(QDateTime, QDateTime)));
+ connect(getPage(Page_SelectTime), SIGNAL(selectedTime(QDateTime, QDateTime)), vehiculeProxy, SLOT(invalidate()));
// Connections for select car
connect(getPage(Page_SelectCar), SIGNAL(Menu()), this, SLOT(gotoMainMenu()));
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)));
// Connections for confirm
connect(getPage(Page_Confirm), SIGNAL(Menu()), this, SLOT(gotoMainMenu()));
@@ -134,29 +155,19 @@ UserInterface::UserInterface(
connect(getPage(Page_Email), SIGNAL(Menu()), this, SLOT(gotoMainMenu()));
}
-void UserInterface::createPages() {
- 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(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(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));
- pages->insert(Page_Email, new MyMessagesPage(this));
-}
-
UserInterface::~UserInterface()
{
delete ui;
}
void UserInterface::setUser(qint64 id) {
+ createPages();
user = usagerModel->getUsager(id);
+ *currentPosition = user->getPosition();
+ stationModel->updateCurrentPosition(*currentPosition);
ui->lblUserName->setText(user->getNom());
+ stationProxy->invalidate();
+ vehiculeProxy->invalidate();
}
Page* UserInterface::getPage(PageName name) {
@@ -229,3 +240,16 @@ void UserInterface::showInfoStation(Station *station) {
ui->stackedWidget->setCurrentIndex(ui->stackedWidget->indexOf(infoStationPage));
connect(infoStationPage, SIGNAL(Previous()), this, SLOT(gotoSelectStation()));
}
+
+void UserInterface::setTimes(QDateTime start, QDateTime end) {
+ reservation->setDebut(start);
+ reservation->setFin(end);
+}
+
+void UserInterface::setStationId(qint64 stationId) {
+ reservation->setStation(stationId);
+}
+
+void UserInterface::setCarId(qint64 carId) {
+ reservation->setVehicule(carId);
+}
View
@@ -13,7 +13,8 @@
#include "vehiculemodel.h"
#include "usagermodel.h"
#include "vehiculefilterproxy.h"
-#include "reservationproxymodel.h"
+#include "reservation.h"
+#include "reservationmodel.h"
#include "geoposition.h"
enum PageName { Page_MainMenu,
@@ -52,6 +53,7 @@ class UserInterface : public QMainWindow
ReservationModel *reservationModel;
ReservationProxyModel *reservationProxy;
GeoPosition *currentPosition;
+ Reservation *reservation;
public slots:
@@ -70,6 +72,9 @@ public slots:
void setCurrentPosition(GeoPosition pos);
void gotoWriteComment();
void showInfoStation(Station *station);
+ void setTimes(QDateTime start, QDateTime end);
+ void setStationId(qint64 stationId);
+ void setCarId(qint64 carId);
void setUser(qint64 id);
};
Oops, something went wrong.

0 comments on commit 2f54672

Please sign in to comment.