Permalink
Browse files

Merge

  • Loading branch information...
2 parents 8e3c2fa + 5d8d1f4 commit 8c5eb9b3f2d4f07c5ce0453e78cf47e37300a89d @gnuvince committed Apr 27, 2011
Showing with 223 additions and 22 deletions.
  1. +57 −13 Makefile
  2. +3 −0 mainwindow.cpp
  3. +29 −2 pages/bookingspage.cpp
  4. +9 −1 pages/bookingspage.h
  5. +4 −3 projet.pro
  6. +64 −0 reservationfilterproxy.cpp
  7. +36 −0 reservationfilterproxy.h
  8. +17 −2 userinterface.cpp
  9. +4 −1 userinterface.h
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -154,8 +154,11 @@ MainWindow::MainWindow(QWidget *parent) :
CarteWidget::setScene(scene);
UserInterface *userInterface = new UserInterface(smodel, vmodel, umodel, rmodel, this);
+ qDebug() << "new UserInterface done";
connect(this, SIGNAL(interfaceUsagerId(qint64)), userInterface, SLOT(setUser(qint64)));
+ qDebug() << "connect interfaceUsagerId done";
emit interfaceUsagerId(2);
+ qDebug() << "emit interfaceUsagerId done";
userInterface->show();
}
View
@@ -1,17 +1,41 @@
#include <QtGui>
#include <QTableView>
+#include <QModelIndex>
#include "page.h"
#include "bookingspage.h"
+#include "reservationfilterproxy.h"
-BookingsPage::BookingsPage(QWidget *parent) :
- Page(parent)
+
+BookingsPage::BookingsPage(
+ ReservationFilterProxy *rproxy,
+ QWidget *parent) :
+ Page(parent),
+ reservationProxy(rproxy)
{
addTitle(trUtf8("Mes réservations"));
QTableView *bookings = new QTableView(this);
+ qDebug() << "BookingsPage setModel(reservationProxy):" << reservationProxy;
+ bookings->setModel(reservationProxy);
+ qDebug() << "BookingsPage setModel done";
+ bookings->setSelectionBehavior(QAbstractItemView::SelectRows);
+ bookings->setSelectionMode(QAbstractItemView::SingleSelection);
+ bookings->verticalHeader()->hide();
+ bookings->hideColumn(0);
+ bookings->resizeColumnToContents(2);
+ bookings->resizeColumnToContents(3);
+ bookings->resizeColumnToContents(4);
+ bookings->resizeColumnToContents(5);
+ bookings->resizeColumnToContents(6);
+ bookings->resizeRowsToContents();
addWidget(bookings);
+
+ QFont font = bookings->font();
+ font.setPointSize(8);
+ bookings->setFont(font);
+
QPushButton *btnMenu = new QPushButton(trUtf8("Menu"), this);
QWidget *optionsWidget = new QWidget(this);
@@ -28,4 +52,7 @@ BookingsPage::BookingsPage(QWidget *parent) :
addBottomButtons(0, btnMenu, 0);
connect(btnMenu, SIGNAL(clicked()), SIGNAL(Menu()));
+ connect(past, SIGNAL(clicked(bool)), SIGNAL(includePastRes(bool)));
+ connect(current, SIGNAL(clicked(bool)), SIGNAL(includeCurrentRes(bool)));
+ connect(futur, SIGNAL(clicked(bool)), SIGNAL(includeFuturRes(bool)));
}
View
@@ -4,17 +4,25 @@
#include <QtGui>
#include "page.h"
+#include "reservationfilterproxy.h"
class BookingsPage : public Page
{
Q_OBJECT
public:
- explicit BookingsPage(QWidget *parent = 0);
+ explicit BookingsPage(
+ ReservationFilterProxy *rproxy,
+ QWidget *parent = 0);
signals:
+ void includePastRes(bool);
+ void includeCurrentRes(bool);
+ void includeFuturRes(bool);
public slots:
+private:
+ ReservationFilterProxy *reservationProxy;
};
#endif // BOOKINGSPAGE_H
View
@@ -47,13 +47,13 @@ HEADERS += geoposition.h \
stationsortproxy.h \
pages/commentspage.h \
pages/unexpectedpage.h \
- pages/myrsvppage.h \
pages/bookingspage.h \
pages/mymessagespage.h \
pages/writecommentpage.h \
pages/infostationpage.h \
vehiculefilterproxy.h \
- pages/infocarpage.h
+ pages/infocarpage.h \
+ reservationfilterproxy.h
FORMS += mainwindow.ui \
cartewidget.ui \
userinterface.ui
@@ -95,7 +95,8 @@ SOURCES += geoposition.cpp \
pages/writecommentpage.cpp \
pages/infostationpage.cpp \
vehiculefilterproxy.cpp \
- pages/infocarpage.cpp
+ pages/infocarpage.cpp \
+ reservationfilterproxy.cpp
RESOURCES += \
icones.qrc
View
@@ -0,0 +1,64 @@
+#include <QDateTime>
+#include "reservationfilterproxy.h"
+#include "reservation.h"
+
+#include <QDebug>
+
+ReservationFilterProxy::ReservationFilterProxy(QObject *parent) :
+ QSortFilterProxyModel(parent)
+{
+ user = 0;
+}
+
+
+bool ReservationFilterProxy::filterAcceptsColumn(int source_column, const QModelIndex &source_parent) const {
+ return source_column == Reservation::COL_ID
+ || source_column == Reservation::COL_DEBUT
+ || source_column == Reservation::COL_FIN
+ || source_column == Reservation::COL_VEHICULE
+ || source_column == Reservation::COL_USAGER
+ || source_column == Reservation::COL_STATION
+ || source_column == Reservation::COL_PERSO;
+}
+
+
+bool ReservationFilterProxy::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const {
+ if (user == 0)
+ return false;
+
+
+ QModelIndex indexUser = sourceModel()->index(source_row, Reservation::COL_USAGER);
+ if (user->getId() == indexUser.data().toInt()) {
+ QDateTime now = QDateTime::currentDateTime();
+ QDateTime resStart = sourceModel()->index(source_row, Reservation::COL_DEBUT).data().toDateTime();
+ QDateTime resEnd = sourceModel()->index(source_row, Reservation::COL_FIN).data().toDateTime();
+
+ if (currentResIncluded && (now > resStart) && (now < resEnd)) {
+ return true;
+ }
+ if (futurResIncluded && (now < resStart)) {
+ return true;
+ }
+ if (pastResIncluded && (now > resEnd)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+void ReservationFilterProxy::setUser(Usager *user) {
+ qDebug() << "ReservationFilterProxy::setUser done";
+ this->user = user;
+}
+
+void ReservationFilterProxy::includePastRes(bool p) {
+ this->pastResIncluded = p;
+}
+
+void ReservationFilterProxy::includeCurrentRes(bool p) {
+ this->currentResIncluded = p;
+}
+
+void ReservationFilterProxy::includeFuturRes(bool p) {
+ this->futurResIncluded = p;
+}
View
@@ -0,0 +1,36 @@
+#ifndef RESERVATIONFILTERPROXY_H
+#define RESERVATIONFILTERPROXY_H
+
+#include <QSortFilterProxyModel>
+
+#include "reservationmodel.h"
+#include "usager.h"
+
+class ReservationFilterProxy : public QSortFilterProxyModel
+{
+ Q_OBJECT
+public:
+ explicit ReservationFilterProxy(QObject *parent = 0);
+ void setUser(Usager *user);
+
+protected:
+ bool filterAcceptsColumn(int source_column, const QModelIndex &source_parent) const;
+ bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
+
+private:
+ ReservationModel *reservationModel;
+ Usager *user;
+ bool pastResIncluded;
+ bool currentResIncluded;
+ bool futurResIncluded;
+
+signals:
+
+public slots:
+ void includePastRes(bool p);
+ void includeCurrentRes(bool p);
+ void includeFuturRes(bool p);
+
+};
+
+#endif // RESERVATIONFILTERPROXY_H
View
@@ -20,6 +20,8 @@
#include "station.h"
#include "stationmodel.h"
#include "stationsortproxy.h"
+#include "reservation.h"
+#include "reservationfilterproxy.h"
#include <QDebug>
@@ -53,6 +55,11 @@ UserInterface::UserInterface(
vehiculeProxy = new VehiculeFilterProxy(rmodel, this);
vehiculeProxy->setSourceModel(vehiculeModel);
vehiculeProxy->setDynamicSortFilter(true);
+
+ reservationProxy = new ReservationFilterProxy(this);
+ qDebug() << "new ReservationFilterProxy done";
+ reservationProxy->setSourceModel(reservationModel);
+ reservationProxy->setDynamicSortFilter(true);
}
void UserInterface::createPages() {
@@ -67,7 +74,8 @@ void UserInterface::createPages() {
vehiculeModel,
stationModel,
this));
- pages->insert(Page_Bookings, new BookingsPage(this));
+ pages->insert(Page_Bookings, new BookingsPage(reservationProxy,
+ 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));
@@ -141,6 +149,9 @@ void UserInterface::createPages() {
// Connections for bookings
connect(getPage(Page_Bookings), SIGNAL(Menu()), this, SLOT(gotoMainMenu()));
+ connect(getPage(Page_Bookings), SIGNAL(includePastRes(bool)), reservationProxy, SLOT(includePastRes(bool)));
+ connect(getPage(Page_Bookings), SIGNAL(includeCurrentRes(bool)), reservationProxy, SLOT(includeCurrentRes(bool)));
+ connect(getPage(Page_Bookings), SIGNAL(includeFuturRes(bool)), reservationProxy, SLOT(includeFuturRes(bool)));
// Connections for comments
connect(getPage(Page_Comments), SIGNAL(Menu()), this, SLOT(gotoMainMenu()));
@@ -167,8 +178,12 @@ UserInterface::~UserInterface()
}
void UserInterface::setUser(qint64 id) {
- createPages();
user = usagerModel->getUsager(id);
+ qDebug() << "active user identified";
+ reservationProxy->setUser(user);
+ qDebug() << "setUser done";
+ createPages();
+ qDebug() << "createPages done";
*currentPosition = user->getPosition();
stationModel->updateCurrentPosition(*currentPosition);
ui->lblUserName->setText(user->getNom());
View
@@ -15,6 +15,7 @@
#include "vehiculefilterproxy.h"
#include "reservation.h"
#include "reservationmodel.h"
+#include "reservationfilterproxy.h"
#include "geoposition.h"
enum PageName { Page_MainMenu,
@@ -50,9 +51,11 @@ class UserInterface : public QMainWindow
VehiculeModel *vehiculeModel;
VehiculeFilterProxy *vehiculeProxy;
UsagerModel *usagerModel;
+ ReservationModel *reservationModel;
+ ReservationFilterProxy *reservationProxy;
GeoPosition *currentPosition;
Reservation *reservation;
- ReservationModel *reservationModel;
+ //ReservationModel *reservationModel;
public slots:

0 comments on commit 8c5eb9b

Please sign in to comment.