Permalink
Browse files

working on bookingsPage

  • Loading branch information...
1 parent 36c808a commit f874f47fdc85922e6a4b9a369963d726e100b0d5 @Gabriano Gabriano committed Apr 27, 2011
Showing with 262 additions and 154 deletions.
  1. +228 −132 Makefile
  2. +3 −0 mainwindow.cpp
  3. +7 −6 pages/bookingspage.cpp
  4. +2 −2 pages/bookingspage.h
  5. +10 −7 reservationfilterproxy.cpp
  6. +2 −3 reservationfilterproxy.h
  7. +9 −3 userinterface.cpp
  8. +1 −1 userinterface.h
View
360 Makefile

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
@@ -7,16 +7,17 @@
BookingsPage::BookingsPage(
- ReservationFilterProxy *rmodel,
+ ReservationFilterProxy *rproxy,
QWidget *parent) :
- Page(parent),
- reservationModel(rmodel)
+ Page(parent),
+ reservationProxy(rproxy)
{
addTitle(trUtf8("Mes réservations"));
QTableView *bookings = new QTableView(this);
- addWidget(bookings);
- bookings->setModel(reservationModel);
+ qDebug() << "BookingsPage setModel(reservationProxy):" << reservationProxy;
+ bookings->setModel(reservationProxy);
+ qDebug() << "BookingsPage setModel done";
bookings->setSelectionBehavior(QAbstractItemView::SelectRows);
bookings->setSelectionMode(QAbstractItemView::SingleSelection);
bookings->verticalHeader()->hide();
@@ -27,8 +28,8 @@ BookingsPage::BookingsPage(
bookings->resizeColumnToContents(5);
bookings->resizeColumnToContents(6);
bookings->resizeRowsToContents();
+ addWidget(bookings);
- connect(bookings, SIGNAL(clicked(QModelIndex)), this, SLOT(showInformation(QModelIndex)));
QFont font = bookings->font();
font.setPointSize(8);
View
@@ -11,15 +11,15 @@ class BookingsPage : public Page
Q_OBJECT
public:
explicit BookingsPage(
- ReservationFilterProxy *rmodel,
+ ReservationFilterProxy *rproxy,
QWidget *parent = 0);
signals:
public slots:
private:
- ReservationFilterProxy *reservationModel;
+ ReservationFilterProxy *reservationProxy;
};
#endif // BOOKINGSPAGE_H
View
@@ -3,12 +3,10 @@
#include <QDebug>
-ReservationFilterProxy::ReservationFilterProxy(ReservationModel *rmodel, Reservation *reservation, Usager *user, QObject *parent) :
- QSortFilterProxyModel(parent),
- reservationModel(rmodel),
- reservation(reservation),
- user(user)
+ReservationFilterProxy::ReservationFilterProxy(QObject *parent) :
+ QSortFilterProxyModel(parent)
{
+ user = 0;
}
@@ -24,8 +22,8 @@ bool ReservationFilterProxy::filterAcceptsColumn(int source_column, const QModel
bool ReservationFilterProxy::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const {
- QModelIndex index = sourceModel()->index(source_row, Reservation::COL_ID);
- qint64 reservationId = index.data().toInt();
+ if (user == 0)
+ return false;
foreach (Reservation *res, reservationModel->getReservations()) {
qDebug() << "res user: " << res->getUsager();
@@ -36,3 +34,8 @@ bool ReservationFilterProxy::filterAcceptsRow(int source_row, const QModelIndex
}
return false;
}
+
+void ReservationFilterProxy::setUser(Usager *user) {
+ qDebug() << "ReservationFilterProxy::setUser done";
+ this->user = user;
+}
View
@@ -3,23 +3,22 @@
#include <QSortFilterProxyModel>
-#include "reservation.h"
#include "reservationmodel.h"
#include "usager.h"
class ReservationFilterProxy : public QSortFilterProxyModel
{
Q_OBJECT
public:
- explicit ReservationFilterProxy(ReservationModel *rmodel, Reservation *reservation, Usager *user, QObject *parent = 0);
+ 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;
- Reservation *reservation;
Usager *user;
signals:
View
@@ -56,7 +56,8 @@ UserInterface::UserInterface(
vehiculeProxy->setSourceModel(vehiculeModel);
vehiculeProxy->setDynamicSortFilter(true);
- reservationProxy = new ReservationFilterProxy(rmodel, reservation, user, this);
+ reservationProxy = new ReservationFilterProxy(this);
+ qDebug() << "new ReservationFilterProxy done";
reservationProxy->setSourceModel(reservationModel);
reservationProxy->setDynamicSortFilter(true);
}
@@ -74,7 +75,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));
@@ -173,8 +175,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
@@ -55,7 +55,7 @@ class UserInterface : public QMainWindow
ReservationFilterProxy *reservationProxy;
GeoPosition *currentPosition;
Reservation *reservation;
- ReservationModel *reservationModel;
+ //ReservationModel *reservationModel;
public slots:

0 comments on commit f874f47

Please sign in to comment.