From e114d8adf0163a4f33db8963136ef45e90600250 Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Fri, 6 Jan 2012 14:58:04 +0100 Subject: [PATCH] added the action preview in the teacher bar --- src/gui/UBTeacherBarWidget.cpp | 61 ++++++++++++++++++++++++++++++++-- src/gui/UBTeacherBarWidget.h | 22 ++++++++++++ 2 files changed, 80 insertions(+), 3 deletions(-) diff --git a/src/gui/UBTeacherBarWidget.cpp b/src/gui/UBTeacherBarWidget.cpp index cf155423..f20095d9 100644 --- a/src/gui/UBTeacherBarWidget.cpp +++ b/src/gui/UBTeacherBarWidget.cpp @@ -881,9 +881,10 @@ void UBTeacherBarPreviewWidget::setActions(QStringList actions) if(2 <= desc.size()){ QString owner = desc.at(0); QString act = desc.at(1); - - // TODO : Create the action widget here and add it to mWidgets - + mpTmpAction = new UBActionPreview(this); + mpTmpAction->setOwner(owner); + mpTmpAction->setContent(act); + mWidgets << mpTmpAction; } } mMediaViewer.loadWidgets(mWidgets); @@ -967,3 +968,57 @@ void UBTeacherBarPreviewMedia::loadMedia(QStringList pMedias) } } } + +// ----------------------------------------------------------------------------------------------- +UBActionPreview::UBActionPreview(QWidget *parent, const char *name):QWidget(parent) + , mpOwner(NULL) + , mpContent(NULL) +{ + setObjectName(name); + setLayout(&mLayout); + mpOwner = new QLabel(this); + mpOwner->setObjectName("UBActionPreviewOwner"); + mOwnerLayout.addWidget(mpOwner, 0); + mOwnerLayout.addStretch(1); + mLayout.addLayout(&mOwnerLayout); + mpContent = new QLabel(this); + mpContent->setObjectName("UBActionPreviewContent"); + mpContent->setWordWrap(true); + mLayout.addWidget(mpContent); +} + +UBActionPreview::~UBActionPreview() +{ + if(NULL != mpOwner){ + delete mpOwner; + mpOwner = NULL; + } + if(NULL != mpContent){ + delete mpContent; + mpContent = NULL; + } +} + +void UBActionPreview::setOwner(const QString &owner) +{ + if(NULL != mpOwner && NULL != mpContent){ + switch(owner.toInt()){ + case eActionOwner_Teacher: + mpOwner->setText(tr("Teacher")); + mpContent->setStyleSheet("background:lightblue;"); + break; + + case eActionOwner_Student: + mpOwner->setText(tr("Student")); + mpContent->setStyleSheet("background:lightgreen;"); + break; + } + } +} + +void UBActionPreview::setContent(const QString &content) +{ + if(NULL != mpContent){ + mpContent->setText(content); + } +} diff --git a/src/gui/UBTeacherBarWidget.h b/src/gui/UBTeacherBarWidget.h index 126af37d..3e53f97d 100644 --- a/src/gui/UBTeacherBarWidget.h +++ b/src/gui/UBTeacherBarWidget.h @@ -27,6 +27,11 @@ typedef enum{ eDuration_ThreeQuarter }eDuration; +typedef enum{ + eActionOwner_Teacher, + eActionOwner_Student +}eActionOwner; + class UBTeacherStudentAction : public QWidget { Q_OBJECT @@ -107,6 +112,22 @@ private: QLineEdit* mpUrl; }; +class UBActionPreview : public QWidget +{ +public: + UBActionPreview(QWidget* parent=0, const char* name="UBActionPreview"); + ~UBActionPreview(); + void setOwner(const QString& owner); + void setContent(const QString& content); + +private: + QLabel* mpOwner; + QLabel* mpContent; + + QVBoxLayout mLayout; + QHBoxLayout mOwnerLayout; +}; + class UBTeacherBarPreviewWidget : public QWidget { Q_OBJECT @@ -145,6 +166,7 @@ private: QLabel* mpComments; QLabel* mpLinksLabel; QLabel* mpTmpLink; + UBActionPreview* mpTmpAction; }; class UBTeacherBarWidget : public UBDockPaletteWidget