From 395d6d3bdb2ebb7686906a22fe6b22624b08d6f4 Mon Sep 17 00:00:00 2001 From: pavelpa Date: Tue, 19 Jan 2010 19:44:23 +0000 Subject: [PATCH] event-dialog - displayed persons/presenters names - implemented Event::persons() method to get persons names associated with the given event ID --- src/gui/eventdialog.cpp | 8 ++- src/gui/eventdialog.ui | 51 ++++++++++++++-- src/gui/mainwindow.ui | 125 ++++++++++++++++++++-------------------- src/mvc/event.cpp | 28 +++++++++ src/mvc/event.h | 2 + 5 files changed, 145 insertions(+), 69 deletions(-) diff --git a/src/gui/eventdialog.cpp b/src/gui/eventdialog.cpp index 8dd8f79..dbd277d 100644 --- a/src/gui/eventdialog.cpp +++ b/src/gui/eventdialog.cpp @@ -1,13 +1,19 @@ #include "eventdialog.h" +#include + EventDialog::EventDialog(const QModelIndex &aIndex, QWidget *aParent) : QDialog(aParent) , mIndex(aIndex) { setupUi(this); + + abstract->setStyleSheet("background-color : transparent;"); + description->setStyleSheet("background-color : transparent;"); + Event *event = static_cast(mIndex.internalPointer()); title->setText(event->title()); - persons->setText(QString::number(event->id())); + persons->setText(event->persons().join(" and ")); abstract->setPlainText(event->abstract()); description->setPlainText(event->description()); } diff --git a/src/gui/eventdialog.ui b/src/gui/eventdialog.ui index 33b00c0..4955acb 100644 --- a/src/gui/eventdialog.ui +++ b/src/gui/eventdialog.ui @@ -5,13 +5,16 @@ 0 0 - 339 - 250 + 445 + 298 Dialog + + false + @@ -34,7 +37,7 @@ - Here go persons + persons go here @@ -43,20 +46,58 @@ Abstract: + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + - + + + false + + + QFrame::NoFrame + + + QFrame::Plain + + + 1 + + + true + + + false + + + false + + Description: + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + - + + + QFrame::NoFrame + + + QFrame::Plain + + + true + + diff --git a/src/gui/mainwindow.ui b/src/gui/mainwindow.ui index e9d255e..024a1a3 100644 --- a/src/gui/mainwindow.ui +++ b/src/gui/mainwindow.ui @@ -1,8 +1,7 @@ - - + MainWindow - - + + 0 0 @@ -10,35 +9,35 @@ 373 - + 400 300 - + MainWindow - - - - - - 1 + + + + + + 0 - - + + Day View - - - + + + - + - - + + 16777215 16777215 @@ -50,36 +49,36 @@ - - + + Favourites - - - + + + - + - + - - + + Activities - - - + + + - + - - + + 16777215 16777215 @@ -91,13 +90,13 @@ - - + + Search - - + + Map @@ -105,50 +104,50 @@ - - + + 0 0 531 - 24 + 22 - - + + File - - + + - - + + Help - - + + - - + + - - - + + + Import Schedule - - + + About Qt - - + + About application - - + + Quit @@ -174,11 +173,11 @@ MainWindow close() - + -1 -1 - + 266 187 diff --git a/src/mvc/event.cpp b/src/mvc/event.cpp index d2c31c4..18b6e33 100644 --- a/src/mvc/event.cpp +++ b/src/mvc/event.cpp @@ -72,6 +72,7 @@ QList Event::getFavByDate(const QDate& date, int conferenceId) QString Event::room() const { QSqlQuery query; + // TODO: conference ID isn't used here query.prepare("SELECT name FROM room WHERE id = (SELECT xid_room FROM event_room WHERE xid_event = :id)"); query.bindValue(":id", id()); query.exec(); @@ -83,9 +84,36 @@ QString Event::room() const return QString("not-available"); } +QStringList Event::persons() const +{ + QSqlQuery query; + // TODO: conference ID isn't used here + query.prepare("SELECT person.name FROM person INNER JOIN event_person ON person.id = event_person.xid_person AND event_person.xid_event = :id"); + query.bindValue(":id", id()); + query.exec(); + // TODO: handle qeury error + //qDebug() << query.lastError(); + + QStringList persons; + while(query.next()) + persons.append(query.record().value("name").toString()); + + return persons; +} + void Event::setRoom(const QString &room) { + Q_UNUSED(room); + qWarning("WARINING: setRoom() is NOT IMPLEMENTED YET"); // TODO: implement } +void Event::setPersons(const QStringList &persons) +{ + Q_UNUSED(persons); + + qWarning("WARINING: setPersons() is NOT IMPLEMENTED YET"); + // TODO: implement +} + diff --git a/src/mvc/event.h b/src/mvc/event.h index 781345d..97d97a7 100644 --- a/src/mvc/event.h +++ b/src/mvc/event.h @@ -48,6 +48,7 @@ public: QString description() const { return value("description").toString(); } // records from other tables associated with 'id' QString room() const; + QStringList persons() const; // Table 1 void setId(int id) { setValue("id", id); } @@ -67,6 +68,7 @@ public: void setDescription(const QString& description) { setValue("description", description); } // records from other tables associated with 'id' void setRoom(const QString& room); + void setPersons(const QStringList &persons); friend class EventTest; }; -- 2.39.5