backup of the teacher bar preview

preferencesAboutTextFull
shibakaneki 13 years ago
parent a7f3ff3d9f
commit abdea843ff
  1. 99
      src/gui/UBTeacherBarWidget.cpp
  2. 8
      src/gui/UBTeacherBarWidget.h

@ -365,9 +365,33 @@ void UBTeacherBarWidget::loadContent()
}else{ }else{
mpPreview->setDuration(eDuration_ThreeQuarter); mpPreview->setDuration(eDuration_ThreeQuarter);
} }
mpPreview->setComments(mpComments->document()->toPlainText());
mpPreview->mediaViewer()->cleanMedia(); mpPreview->clean();
// Add the actions
if(!mActionList.empty()){
QStringList actions;
foreach(UBTeacherStudentAction* action, mActionList){
QString desc = QString("%0;%1").arg(action->comboValue()).arg(action->text());
actions << desc;
}
mpPreview->setActions(actions);
}
// Add the media
mpPreview->mediaViewer()->loadMedia(nextInfos.medias); mpPreview->mediaViewer()->loadMedia(nextInfos.medias);
// Add the links
if(!mUrlList.empty()){
QStringList links;
foreach(UBUrlWidget* url, mUrlList){
links << url->url();
}
mpPreview->setLinks(links);
}
// Add the comments
mpPreview->setComments(mpComments->document()->toPlainText());
} }
} }
@ -697,6 +721,7 @@ UBTeacherBarPreviewWidget::UBTeacherBarPreviewWidget(QWidget *parent, const char
, mpMediaLabel(NULL) , mpMediaLabel(NULL)
, mpCommentsLabel(NULL) , mpCommentsLabel(NULL)
, mpComments(NULL) , mpComments(NULL)
, mpLinksLabel(NULL)
{ {
setObjectName(name); setObjectName(name);
@ -733,6 +758,8 @@ UBTeacherBarPreviewWidget::UBTeacherBarPreviewWidget(QWidget *parent, const char
//mLayout.addLayout(&mMediaLabelLayout, 0); //mLayout.addLayout(&mMediaLabelLayout, 0);
mLayout.addWidget(&mMediaViewer, 1); mLayout.addWidget(&mMediaViewer, 1);
mpLinksLabel = new QLabel(tr("Links"), this);
mpLinksLabel->setObjectName("UBTeacherBarPreviewSubtitle");
// Comments // Comments
mpCommentsLabel = new QLabel(tr("Comments"), this); mpCommentsLabel = new QLabel(tr("Comments"), this);
@ -760,6 +787,10 @@ UBTeacherBarPreviewWidget::UBTeacherBarPreviewWidget(QWidget *parent, const char
UBTeacherBarPreviewWidget::~UBTeacherBarPreviewWidget() UBTeacherBarPreviewWidget::~UBTeacherBarPreviewWidget()
{ {
if(NULL != mpLinksLabel){
delete mpLinksLabel;
mpLinksLabel = NULL;
}
if(NULL != mpComments){ if(NULL != mpComments){
delete mpComments; delete mpComments;
mpComments = NULL; mpComments = NULL;
@ -825,8 +856,64 @@ void UBTeacherBarPreviewWidget::setDuration(eDuration duration)
void UBTeacherBarPreviewWidget::setComments(const QString &comments) void UBTeacherBarPreviewWidget::setComments(const QString &comments)
{ {
if(NULL != mpComments){ if("" != comments){
mWidgets.clear();
mpComments->setText(comments); mpComments->setText(comments);
mpComments->setVisible(true);
mpCommentsLabel->setVisible(true);
mWidgets << mpCommentsLabel;
mWidgets << mpComments;
mMediaViewer.loadWidgets(mWidgets);
}
}
void UBTeacherBarPreviewWidget::clean()
{
mMediaViewer.cleanMedia();
hideElements();
}
void UBTeacherBarPreviewWidget::hideElements()
{
mpActionsLabel->setVisible(false);
mpMediaLabel->setVisible(false);
mpCommentsLabel->setVisible(false);
mpComments->setVisible(false);
mpLinksLabel->setVisible(false);
}
void UBTeacherBarPreviewWidget::setActions(QStringList actions)
{
if(!actions.empty()){
mWidgets.clear();
mpActionsLabel->setVisible(true);
mWidgets << mpActionsLabel;
foreach(QString action, actions){
QStringList desc = action.split(';');
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
}
}
mMediaViewer.loadWidgets(mWidgets);
}
}
void UBTeacherBarPreviewWidget::setLinks(QStringList links)
{
if(!links.empty()){
mWidgets.clear();
mpLinksLabel->setVisible(true);
mWidgets << mpLinksLabel;
foreach(QString link, links){
mpTmpLink = new QLabel(link, this);
mpTmpLink->setOpenExternalLinks(true);
mWidgets << mpTmpLink;
}
mMediaViewer.loadWidgets(mWidgets);
} }
} }
@ -853,8 +940,10 @@ UBTeacherBarPreviewMedia::~UBTeacherBarPreviewMedia()
void UBTeacherBarPreviewMedia::cleanMedia() void UBTeacherBarPreviewMedia::cleanMedia()
{ {
foreach(QWidget* eachWidget, mWidgetList.keys()){ foreach(QWidget* eachWidget, mWidgetList.keys()){
delete eachWidget; if(QString(eachWidget->metaObject()->className()).contains("UBDraggable")){
eachWidget = NULL; delete eachWidget;
eachWidget = NULL;
}
} }
mWidgetList.clear(); mWidgetList.clear();
} }

@ -117,6 +117,9 @@ public:
void setTitle(const QString& title); void setTitle(const QString& title);
void setDuration(eDuration duration); void setDuration(eDuration duration);
void setComments(const QString& comments); void setComments(const QString& comments);
void setActions(QStringList actions);
void setLinks(QStringList links);
void clean();
signals: signals:
void showEditMode(); void showEditMode();
@ -125,6 +128,8 @@ private slots:
void onEdit(); void onEdit();
private: private:
void hideElements();
QVBoxLayout mLayout; QVBoxLayout mLayout;
QHBoxLayout mEditLayout; QHBoxLayout mEditLayout;
QHBoxLayout mTitleDurationLayout; QHBoxLayout mTitleDurationLayout;
@ -132,6 +137,7 @@ private:
QHBoxLayout mMediaLabelLayout; QHBoxLayout mMediaLabelLayout;
QHBoxLayout mCommentsLabelLayout; QHBoxLayout mCommentsLabelLayout;
UBTeacherBarPreviewMedia mMediaViewer; UBTeacherBarPreviewMedia mMediaViewer;
QList<QWidget*> mWidgets;
QPushButton* mpEditButton; QPushButton* mpEditButton;
QLabel* mpTitle; QLabel* mpTitle;
@ -140,6 +146,8 @@ private:
QLabel* mpMediaLabel; QLabel* mpMediaLabel;
QLabel* mpCommentsLabel; QLabel* mpCommentsLabel;
QLabel* mpComments; QLabel* mpComments;
QLabel* mpLinksLabel;
QLabel* mpTmpLink;
}; };
class UBTeacherBarWidget : public UBDockPaletteWidget class UBTeacherBarWidget : public UBDockPaletteWidget

Loading…
Cancel
Save