Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

intermediate commit

  • Loading branch information...
commit e4773098e5a720db5ec344cb50e90a2b1d24a87d 1 parent d73cbfd
@gnuvince authored
View
2  mainwindow.cpp
@@ -153,7 +153,7 @@ MainWindow::MainWindow(QWidget *parent) :
//important tout le monde partage la scène !
CarteWidget::setScene(scene);
- UserInterface *userInterface = new UserInterface(smodel, vmodel, this);
+ UserInterface *userInterface = new UserInterface(smodel, vmodel, rmodel, this);
userInterface->show();
}
View
13 pages/selectcarpage.cpp
@@ -16,15 +16,16 @@ 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);
@@ -32,4 +33,12 @@ SelectCarPage::SelectCarPage(VehiculeFilterProxy *vproxy, QWidget *parent) :
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
5 pages/selectcarpage.h
@@ -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);
};
View
3  pages/selectstationpage.cpp
@@ -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());
}
View
1  pages/selectstationpage.h
@@ -17,6 +17,7 @@ class SelectStationPage : public Page
signals:
void showInfoStation(Station *station);
+ void selectedStation(qint64 stationId);
public slots:
void stationSelected(QModelIndex index);
View
6 pages/selecttimepage.cpp
@@ -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
2  pages/selecttimepage.h
@@ -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
2  qrc_icones.cpp
@@ -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
4 reservation.h
@@ -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
9 reservationmodel.cpp
@@ -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
4 reservationmodel.h
@@ -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
2  ui_cartewidget.h
@@ -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
2  ui_mainwindow.h
@@ -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
2  ui_userinterface.h
@@ -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
24 userinterface.cpp
@@ -28,6 +28,7 @@
UserInterface::UserInterface(
StationModel *smodel,
VehiculeModel *vmodel,
+ ReservationModel *rmodel,
QWidget *parent) :
QMainWindow(parent),
stationModel(smodel),
@@ -36,6 +37,9 @@ UserInterface::UserInterface(
{
ui->setupUi(this);
+ qDebug() << "Nombre total de vehicules: " << stationModel->getStations().count();
+
+ reservation = new Reservation(this);
currentPosition = new GeoPosition(45.52, -73.58);
stationModel->updateCurrentPosition(*currentPosition);
@@ -44,7 +48,7 @@ UserInterface::UserInterface(
stationProxy->setDynamicSortFilter(true);
stationProxy->sort(1);
- vehiculeProxy = new VehiculeFilterProxy(this);
+ vehiculeProxy = new VehiculeFilterProxy(rmodel, reservation, this);
vehiculeProxy->setSourceModel(vehiculeModel);
vehiculeProxy->setDynamicSortFilter(true);
@@ -98,16 +102,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()));
@@ -212,3 +221,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
7 userinterface.h
@@ -12,6 +12,8 @@
#include "stationsortproxy.h"
#include "vehiculemodel.h"
#include "vehiculefilterproxy.h"
+#include "reservation.h"
+#include "reservationmodel.h"
#include "geoposition.h"
enum PageName { Page_MainMenu,
@@ -31,6 +33,7 @@ class UserInterface : public QMainWindow
explicit UserInterface(
StationModel *smodel,
VehiculeModel *vmodel,
+ ReservationModel *rmodel,
QWidget *parent = 0);
~UserInterface();
@@ -43,6 +46,7 @@ class UserInterface : public QMainWindow
VehiculeModel *vehiculeModel;
VehiculeFilterProxy *vehiculeProxy;
GeoPosition *currentPosition;
+ Reservation *reservation;
public slots:
@@ -61,6 +65,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);
};
#endif // USERINTERFACE_H
View
19 vehiculefilterproxy.cpp
@@ -1,8 +1,12 @@
#include "vehiculefilterproxy.h"
#include "vehicule.h"
-VehiculeFilterProxy::VehiculeFilterProxy(QObject *parent) :
- QSortFilterProxyModel(parent)
+#include <QDebug>
+
+VehiculeFilterProxy::VehiculeFilterProxy(ReservationModel *rmodel, Reservation *reservation, QObject *parent) :
+ QSortFilterProxyModel(parent),
+ reservationModel(rmodel),
+ reservation(reservation)
{
}
@@ -11,10 +15,19 @@ bool VehiculeFilterProxy::filterAcceptsColumn(int source_column, const QModelInd
return source_column == Vehicule::COL_ID
|| source_column == Vehicule::COL_MARQUE
|| source_column == Vehicule::COL_MODELE
+ || source_column == Vehicule::COL_COULEUR
|| source_column == Vehicule::COL_INFO;
}
bool VehiculeFilterProxy::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const {
- return true;
+ QModelIndex index = sourceModel()->index(source_row, Vehicule::COL_ID);
+ qint64 vehiculeId = index.data().toInt();
+ foreach (Reservation *res, reservationModel->getReservations()) {
+ if (res->getVehicule() == vehiculeId && res->getStation() == reservation->getStation()
+ && reservationModel->testReservation(reservation)) {
+ return true;
+ }
+ }
+ return false;
}
View
9 vehiculefilterproxy.h
@@ -3,16 +3,23 @@
#include <QSortFilterProxyModel>
+#include "reservation.h"
+#include "reservationmodel.h"
+
class VehiculeFilterProxy : public QSortFilterProxyModel
{
Q_OBJECT
public:
- explicit VehiculeFilterProxy(QObject *parent = 0);
+ explicit VehiculeFilterProxy(ReservationModel *rmodel, Reservation *reservation, QObject *parent = 0);
protected:
bool filterAcceptsColumn(int source_column, const QModelIndex &source_parent) const;
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
+private:
+ ReservationModel *reservationModel;
+ Reservation *reservation;
+
signals:
public slots:
Please sign in to comment.
Something went wrong with that request. Please try again.