backup of the teacher bar preview

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

@ -365,9 +365,33 @@ void UBTeacherBarWidget::loadContent()
}else{
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);
// 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)
, mpCommentsLabel(NULL)
, mpComments(NULL)
, mpLinksLabel(NULL)
{
setObjectName(name);
@ -733,6 +758,8 @@ UBTeacherBarPreviewWidget::UBTeacherBarPreviewWidget(QWidget *parent, const char
//mLayout.addLayout(&mMediaLabelLayout, 0);
mLayout.addWidget(&mMediaViewer, 1);
mpLinksLabel = new QLabel(tr("Links"), this);
mpLinksLabel->setObjectName("UBTeacherBarPreviewSubtitle");
// Comments
mpCommentsLabel = new QLabel(tr("Comments"), this);
@ -760,6 +787,10 @@ UBTeacherBarPreviewWidget::UBTeacherBarPreviewWidget(QWidget *parent, const char
UBTeacherBarPreviewWidget::~UBTeacherBarPreviewWidget()
{
if(NULL != mpLinksLabel){
delete mpLinksLabel;
mpLinksLabel = NULL;
}
if(NULL != mpComments){
delete mpComments;
mpComments = NULL;
@ -825,8 +856,64 @@ void UBTeacherBarPreviewWidget::setDuration(eDuration duration)
void UBTeacherBarPreviewWidget::setComments(const QString &comments)
{
if(NULL != mpComments){
if("" != comments){
mWidgets.clear();
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,9 +940,11 @@ UBTeacherBarPreviewMedia::~UBTeacherBarPreviewMedia()
void UBTeacherBarPreviewMedia::cleanMedia()
{
foreach(QWidget* eachWidget, mWidgetList.keys()){
if(QString(eachWidget->metaObject()->className()).contains("UBDraggable")){
delete eachWidget;
eachWidget = NULL;
}
}
mWidgetList.clear();
}

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

Loading…
Cancel
Save