Permalink
Browse files

Added Eric and Vincent as users

  • Loading branch information...
1 parent d2ad21f commit 7353becaf2d2b4f67e49e7155cd46f9a1aa7b657 @gnuvince committed Apr 26, 2011
Showing with 30 additions and 21 deletions.
  1. +1 −2 mainwindow.cpp
  2. +2 −0 robot.cpp
  3. +27 −19 userinterface.cpp
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();
}
@@ -286,8 +287,6 @@ void MainWindow::changeInterfaceUsagerId(qint64 id)
if (!u) {
//normalement u est valide mais bon ..
QMessageBox::warning(this, trUtf8("Usager invalide"), trUtf8("L'usager que vous avez sélectionné n'existe pas"),QMessageBox::Ok);
- } else {
- QMessageBox::information(this, trUtf8("Changement d'interface usager"), trUtf8("Lorsque vous recevez le signal MainWindow::interfaceUsagerId(qint64 id), vous devez afficher l'interface de l'usager correspondant.\n\nPar exemple, ceci est l'interface de l'usager %1 qui a l'id %2 ! Cette interface est minimaliste, mais elle est là :). La votre devrait être plus conséquente !").arg(u->getNom()).arg(id), QMessageBox::Ok);
}
}
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
@@ -39,10 +39,10 @@ UserInterface::UserInterface(
{
ui->setupUi(this);
+ pages = new QMap<PageName, Page*>;
reservation = new Reservation(this);
- setUser(2);
- currentPosition = new GeoPosition(45.52, -73.58);
+ currentPosition = new GeoPosition(0, 0);
stationModel->updateCurrentPosition(*currentPosition);
stationProxy = new StationSortProxy(this);
@@ -53,9 +53,27 @@ UserInterface::UserInterface(
vehiculeProxy = new VehiculeFilterProxy(rmodel, reservation, this);
vehiculeProxy->setSourceModel(vehiculeModel);
vehiculeProxy->setDynamicSortFilter(true);
+}
- pages = new QMap<PageName, Page*>;
- createPages();
+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));
+
+ 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()) {
@@ -135,29 +153,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) {

0 comments on commit 7353bec

Please sign in to comment.