Permalink
Browse files

Added infocarpage

  • Loading branch information...
1 parent 7e91355 commit 8e3c2fa8d453e25dd95f035ed75122b02b631e1b @gnuvince committed Apr 27, 2011
View
102 Makefile

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -0,0 +1,60 @@
+#include <QtGui>
+
+#include "infocarpage.h"
+#include "vehicule.h"
+
+QLabel* InfoCarPage::titleLabel(QString title) {
+ QLabel *label = new QLabel(title);
+ QFont font = label->font();
+ font.setPointSize(8);
+ font.setBold(true);
+ label->setFont(font);
+ return label;
+}
+
+InfoCarPage::InfoCarPage(Vehicule &vehicule, QWidget *parent) :
+ Page(parent),
+ vehicule(vehicule)
+{
+ addTitle(trUtf8("Info-Véhicule"));
+
+ QVBoxLayout *layout = new QVBoxLayout(this);
+
+ QString vehiculeName = QString("%1 %2").arg(vehicule.getMarque()).arg(vehicule.getModele());
+ QLabel *nameLabel = new QLabel(vehiculeName, this);
+
+ QFont normalFont = nameLabel->font();
+ normalFont.setPointSize(8);
+
+ nameLabel->setWordWrap(true);
+
+ QLabel *descriptionLabel = new QLabel(vehicule.getDescription(), this);
+ descriptionLabel->setFont(normalFont);
+ descriptionLabel->setWordWrap(true);
+
+
+ QPixmap photo = vehicule.getPhoto().scaled(QSize(220, 1), Qt::KeepAspectRatioByExpanding);
+ QLabel *photoLabel = new QLabel();
+ photoLabel->setPixmap(photo);
+
+ layout->addWidget(nameLabel);
+ layout->addWidget(titleLabel(trUtf8("Description:")));
+ layout->addWidget(descriptionLabel);
+ layout->addWidget(titleLabel(trUtf8("Photo:")));
+ layout->addWidget(photoLabel);
+
+ QWidget *widget = new QWidget(this);
+ widget->setLayout(layout);
+
+ QScrollArea *scroller = new QScrollArea(this);
+ scroller->setWidget(widget);
+
+ addWidget(scroller);
+
+ QPushButton *returnButton = new QPushButton(trUtf8("Retour"));
+ returnButton->setIcon(QIcon(":/icones/data/icons/arrow_left.png"));
+
+ addBottomButtons(0, returnButton, 0);
+
+ connect(returnButton, SIGNAL(clicked()), SIGNAL(Previous()));
+}
View
@@ -0,0 +1,24 @@
+#ifndef INFOCARPAGE_H
+#define INFOCARPAGE_H
+
+#include <QtGui>
+#include "vehicule.h"
+#include "page.h"
+
+class InfoCarPage : public Page
+{
+ Q_OBJECT
+public:
+ explicit InfoCarPage(Vehicule &vehicule, QWidget *parent = 0);
+ QLabel* titleLabel(QString title);
+
+private:
+ Vehicule &vehicule;
+
+signals:
+
+public slots:
+
+};
+
+#endif // INFOCARPAGE_H
@@ -5,7 +5,7 @@
#include "infostationpage.h"
-QLabel* titleLabel(QString title) {
+QLabel* InfoStationPage::titleLabel(QString title) {
QLabel *label = new QLabel(title);
QFont font = label->font();
font.setPointSize(8);
View
@@ -11,6 +11,7 @@ class InfoStationPage : public Page
Q_OBJECT
public:
explicit InfoStationPage(Station &station, QWidget *parent = 0);
+ QLabel* titleLabel(QString title);
signals:
View
@@ -3,6 +3,7 @@
#include "page.h"
#include "selectcarpage.h"
+#include "vehiculemodel.h"
#include "vehiculefilterproxy.h"
SelectCarPage::SelectCarPage(VehiculeFilterProxy *vproxy, QWidget *parent) :
@@ -34,6 +35,7 @@ SelectCarPage::SelectCarPage(VehiculeFilterProxy *vproxy, QWidget *parent) :
connect(btnMenu, SIGNAL(clicked()), SIGNAL(Menu()));
connect(btnNext, SIGNAL(clicked()), SIGNAL(Next()));
connect(view, SIGNAL(clicked(QModelIndex)), this, SLOT(selectedCar(QModelIndex)));
+ connect(view, SIGNAL(clicked(QModelIndex)), this, SLOT(showInformation(QModelIndex)));
}
void SelectCarPage::selectedCar(QModelIndex index) {
@@ -42,3 +44,14 @@ void SelectCarPage::selectedCar(QModelIndex index) {
QModelIndex index2 = index.model()->index(index.row(), Vehicule::COL_ID);
emit carSelected(index2.data().toInt());
}
+
+
+void SelectCarPage::showInformation(QModelIndex index) {
+ if (index.column() == 4) {
+ QModelIndex index2 = index.model()->index(index.row(), Vehicule::COL_ID);
+ qint64 vehiculeId = index2.data().toInt();
+ VehiculeModel *model = (VehiculeModel*)(vehiculeProxy->sourceModel());
+ Vehicule *vehicule = model->getVehicule(vehiculeId);
+ emit showInfoVehicule(vehicule);
+ }
+}
View
@@ -6,6 +6,7 @@
#include "page.h"
#include "vehiculefilterproxy.h"
+#include "vehicule.h"
class SelectCarPage : public Page
{
@@ -19,9 +20,11 @@ class SelectCarPage : public Page
signals:
void carSelected(qint64 carId);
+ void showInfoVehicule(Vehicule *vehicule);
public slots:
void selectedCar(QModelIndex index);
+ void showInformation(QModelIndex index);
};
@@ -25,7 +25,6 @@ SelectStationPage::SelectStationPage(
view->resizeColumnToContents(3);
view->resizeRowsToContents();
- connect(view, SIGNAL(clicked(QModelIndex)), this, SLOT(showInformation(QModelIndex)));
QFont font = view->font();
font.setPointSize(8);
@@ -46,6 +45,8 @@ SelectStationPage::SelectStationPage(
connect(btnPrevious, SIGNAL(clicked()), SIGNAL(Previous()));
connect(btnNext, SIGNAL(clicked()), SIGNAL(Next()));
connect(view, SIGNAL(clicked(QModelIndex)), this, SLOT(stationSelected(QModelIndex)));
+ connect(view, SIGNAL(clicked(QModelIndex)), this, SLOT(showInformation(QModelIndex)));
+
}
void SelectStationPage::stationSelected(QModelIndex index) {
@@ -58,7 +59,7 @@ void SelectStationPage::stationSelected(QModelIndex index) {
void SelectStationPage::showInformation(QModelIndex index) {
if (index.column() == 3) {
- QModelIndex index2 = index.model()->index(index.row(), 0);
+ QModelIndex index2 = index.model()->index(index.row(), Station::COL_ID);
qint64 stationId = index2.data().toInt();
StationModel *model = (StationModel*)(stationModel->sourceModel());
Station *station = model->getStation(stationId);
View
@@ -52,7 +52,8 @@ HEADERS += geoposition.h \
pages/mymessagespage.h \
pages/writecommentpage.h \
pages/infostationpage.h \
- vehiculefilterproxy.h
+ vehiculefilterproxy.h \
+ pages/infocarpage.h
FORMS += mainwindow.ui \
cartewidget.ui \
userinterface.ui
@@ -93,7 +94,8 @@ SOURCES += geoposition.cpp \
pages/mymessagespage.cpp \
pages/writecommentpage.cpp \
pages/infostationpage.cpp \
- vehiculefilterproxy.cpp
+ vehiculefilterproxy.cpp \
+ pages/infocarpage.cpp
RESOURCES += \
icones.qrc
View
@@ -15,6 +15,7 @@
#include "pages/mymessagespage.h"
#include "pages/writecommentpage.h"
#include "pages/infostationpage.h"
+#include "pages/infocarpage.h"
#include "station.h"
#include "stationmodel.h"
@@ -127,6 +128,7 @@ void UserInterface::createPages() {
connect(getPage(Page_SelectCar), SIGNAL(Menu()), this, SLOT(gotoMainMenu()));
connect(getPage(Page_SelectCar), SIGNAL(Previous()), this, SLOT(gotoSelectTime()));
connect(getPage(Page_SelectCar), SIGNAL(Next()), this, SLOT(gotoConfirm()));
+ connect(getPage(Page_SelectCar), SIGNAL(showInfoVehicule(Vehicule*)), this, SLOT(showInfoVehicule(Vehicule*)));
connect(getPage(Page_SelectCar), SIGNAL(carSelected(qint64)), this, SLOT(setCarId(qint64)));
connect(getPage(Page_SelectCar), SIGNAL(Next()), getPage(Page_Confirm), SLOT(setEditorText()));
@@ -245,6 +247,14 @@ void UserInterface::showInfoStation(Station *station) {
connect(infoStationPage, SIGNAL(Previous()), this, SLOT(gotoSelectStation()));
}
+
+void UserInterface::showInfoVehicule(Vehicule *vehicule) {
+ InfoCarPage *infoCarPage = new InfoCarPage(*vehicule, this);
+ ui->stackedWidget->addWidget(infoCarPage);
+ ui->stackedWidget->setCurrentIndex(ui->stackedWidget->indexOf(infoCarPage));
+ connect(infoCarPage, SIGNAL(Previous()), this, SLOT(gotoSelectCar()));
+}
+
void UserInterface::setTimes(QDateTime start, QDateTime end) {
reservation->setDebut(start);
reservation->setFin(end);
View
@@ -71,6 +71,7 @@ public slots:
void setCurrentPosition(GeoPosition pos);
void gotoWriteComment();
void showInfoStation(Station *station);
+ void showInfoVehicule(Vehicule *vehicule);
void setTimes(QDateTime start, QDateTime end);
void setStationId(qint64 stationId);
void setCarId(qint64 carId);

0 comments on commit 8e3c2fa

Please sign in to comment.