Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added My Messages

  • Loading branch information...
commit e76d466e5d8fbfd2ef80089c6d0904a1a611f7d9 1 parent fa539b8
@gnuvince authored
View
28 pages/confirmpage.cpp
@@ -40,20 +40,20 @@ void ConfirmPage::setEditorText() {
QString username = umodel->getUsager(reservation->getUsager())->getNom();
QString station = smodel->getStation(reservation->getStation())->getNom();
Vehicule *vehicule = vmodel->getVehicule(reservation->getVehicule());
-
-
- editor->setPlainText(
- trUtf8("Usager : %1\n"
- "Station : %2\n"
- "Véhicule: %3\n"
- "Départ : %4\n"
- "Retour : %5\n")
- .arg(username)
- .arg(station)
- .arg(vehicule->getName())
- .arg(reservation->getDebut().toString("dd MMM yyyy hh:mm"))
- .arg(reservation->getFin().toString("dd MMM yyyy hh:mm"))
- );
+ QString confirmMessage = trUtf8("RÉSERVATION\n"
+ "===========\n"
+ "Usager : %1\n"
+ "Station : %2\n"
+ "Véhicule: %3\n"
+ "Départ : %4\n"
+ "Retour : %5\n")
+ .arg(username)
+ .arg(station)
+ .arg(vehicule->getName())
+ .arg(reservation->getDebut().toString("dd MMM yyyy hh:mm"))
+ .arg(reservation->getFin().toString("dd MMM yyyy hh:mm"));
+
+ editor->setPlainText(confirmMessage);
}
void ConfirmPage::setReservation(Reservation *res) {
View
3  pages/confirmpage.h
@@ -19,13 +19,14 @@ class ConfirmPage : public Page
StationModel *smodel,
QWidget *parent = 0);
void setReservation(Reservation *res);
+ QPlainTextEdit *editor;
+
private:
Reservation *reservation;
UsagerModel *umodel;
VehiculeModel *vmodel;
StationModel *smodel;
- QPlainTextEdit *editor;
signals:
View
25 pages/mymessagespage.cpp
@@ -3,15 +3,17 @@
#include "page.h"
#include "mymessagespage.h"
+#include "note.h"
-MyMessagesPage::MyMessagesPage(QWidget *parent) :
- Page(parent)
+MyMessagesPage::MyMessagesPage(qint64 uid, NoteModel *nmodel, QWidget *parent) :
+ Page(parent),
+ uid(uid),
+ noteModel(nmodel)
{
addTitle(trUtf8("Mes messages"));
- QTableView *messages = new QTableView(this);
- addWidget(messages);
- QTextEdit *msgtext = new QTextEdit(this);
+ msgtext = new QTextEdit(this);
+ msgtext->setFont(QFont("Courier"));
addWidget(msgtext);
QPushButton *btnMenu = new QPushButton(trUtf8("Menu"), this);
@@ -20,3 +22,16 @@ MyMessagesPage::MyMessagesPage(QWidget *parent) :
connect(btnMenu, SIGNAL(clicked()), SIGNAL(Menu()));
}
+
+void MyMessagesPage::updateMessages() {
+ msgtext->clear();
+
+ QString s;
+ foreach (Note* n, noteModel->getNotes()) {
+ if (n->getUsager() == uid) {
+ s.append(n->getDescription());
+ s.append("\n\n");
+ }
+ }
+ msgtext->setPlainText(s);
+}
View
9 pages/mymessagespage.h
@@ -4,16 +4,23 @@
#include <QtGui>
#include "page.h"
+#include "notemodel.h"
class MyMessagesPage : public Page
{
Q_OBJECT
public:
- explicit MyMessagesPage(QWidget *parent = 0);
+ explicit MyMessagesPage(qint64 uid, NoteModel *nmodel, QWidget *parent = 0);
+
+private:
+ qint64 uid;
+ NoteModel *noteModel;
+ QTextEdit *msgtext;
signals:
public slots:
+ void updateMessages();
};
View
10 userinterface.cpp
@@ -78,7 +78,7 @@ void UserInterface::createPages() {
pages->insert(Page_Bookings, new BookingsPage(reservationProxy,
this));
pages->insert(Page_WriteComment, new WriteCommentPage(user->getId(), noteModel, reservationModel, stationModel, vehiculeModel, this));
- pages->insert(Page_Email, new MyMessagesPage(this));
+ pages->insert(Page_Email, new MyMessagesPage(user->getId(), noteModel, this));
for (int i = 0; i < ui->stackedWidget->count(); ++i) {
QWidget *w = ui->stackedWidget->widget(i);
@@ -95,6 +95,7 @@ void UserInterface::createPages() {
// Connections for email
connect(ui->btnEnveloppe, SIGNAL(clicked()), this, SLOT(gotoEmailPage()));
+ connect(ui->btnEnveloppe, SIGNAL(clicked()), getPage(Page_Email), SLOT(updateMessages()));
// Connections for main menu
connect(getPage(Page_MainMenu), SIGNAL(BookCar()), this, SLOT(gotoFindStationPage()));
@@ -282,5 +283,12 @@ void UserInterface::resetReservation() {
void UserInterface::saveReservation() {
reservationModel->addReservation(reservation);
+ QString confirmMessage = dynamic_cast<ConfirmPage*>(getPage(Page_Confirm))->editor->toPlainText();
+ noteModel->addNote(new Note(user->getId(),
+ QDateTime::currentDateTime(),
+ Note::TYPE_USAGER,
+ user->getId(),
+ confirmMessage,
+ this));
QMessageBox::information(this, trUtf8("Réservation complétée"), trUtf8("Votre réservation a été complété et enregistré avec succès."), QMessageBox::Ok);
}
Please sign in to comment.
Something went wrong with that request. Please try again.