Permalink
Browse files

User selection

  • Loading branch information...
1 parent d73cbfd commit 9e588f16d679de38a35dcce45a83000929d5f793 @Gabriano Gabriano committed Apr 26, 2011
Showing with 32 additions and 14 deletions.
  1. +2 −1 mainwindow.cpp
  2. +1 −0 stationmodel.cpp
  3. +23 −13 userinterface.cpp
  4. +6 −0 userinterface.h
View
@@ -153,7 +153,8 @@ 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, umodel, this);
+ connect(this, SIGNAL(interfaceUsagerId(qint64)), userInterface, SLOT(setUser(qint64)));
userInterface->show();
}
View
@@ -27,6 +27,7 @@
StationModel::StationModel(QObject *parent) :
QAbstractTableModel(parent)
{
+ currentPosition = new GeoPosition;
}
QVariant StationModel::fieldAt(const QModelIndex &index, int role) const
View
@@ -28,14 +28,17 @@
UserInterface::UserInterface(
StationModel *smodel,
VehiculeModel *vmodel,
+ UsagerModel *umodel,
QWidget *parent) :
QMainWindow(parent),
stationModel(smodel),
vehiculeModel(vmodel),
+ usagerModel(umodel),
ui(new Ui::UserInterface)
{
ui->setupUi(this);
+ setUser(2);
currentPosition = new GeoPosition(45.52, -73.58);
stationModel->updateCurrentPosition(*currentPosition);
@@ -49,19 +52,7 @@ UserInterface::UserInterface(
vehiculeProxy->setDynamicSortFilter(true);
pages = new QMap<PageName, Page*>;
-
- 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));
+ createPages();
QMapIterator<PageName, Page*> iter(*pages);
while (iter.hasNext()) {
@@ -136,11 +127,30 @@ 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) {
+ user = usagerModel->getUsager(id);
+ ui->lblUserName->setText(user->getNom());
+}
Page* UserInterface::getPage(PageName name) {
return pages->value(name);
View
@@ -11,6 +11,7 @@
#include "stationmodel.h"
#include "stationsortproxy.h"
#include "vehiculemodel.h"
+#include "usagermodel.h"
#include "vehiculefilterproxy.h"
#include "geoposition.h"
@@ -31,17 +32,21 @@ class UserInterface : public QMainWindow
explicit UserInterface(
StationModel *smodel,
VehiculeModel *vmodel,
+ UsagerModel *umodel,
QWidget *parent = 0);
~UserInterface();
private:
Ui::UserInterface *ui;
+ Usager *user;
QMap<PageName, Page*> *pages;
+ void createPages();
Page* getPage(PageName name);
StationModel *stationModel;
StationSortProxy *stationProxy;
VehiculeModel *vehiculeModel;
VehiculeFilterProxy *vehiculeProxy;
+ UsagerModel *usagerModel;
GeoPosition *currentPosition;
@@ -61,6 +66,7 @@ public slots:
void setCurrentPosition(GeoPosition pos);
void gotoWriteComment();
void showInfoStation(Station *station);
+ void setUser(qint64 id);
};
#endif // USERINTERFACE_H

0 comments on commit 9e588f1

Please sign in to comment.