First backup of the teacherbar preview widget

preferencesAboutTextFull
shibakaneki 13 years ago
parent 8a27f4b6e5
commit 079f7534c8
  1. 75
      src/gui/UBTeacherBarWidget.cpp
  2. 22
      src/gui/UBTeacherBarWidget.h

@ -43,6 +43,7 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock
, mpLinkButton(NULL) , mpLinkButton(NULL)
, mpLinkLayout(NULL) , mpLinkLayout(NULL)
, mpStackWidget(NULL) , mpStackWidget(NULL)
, mpPreview(NULL)
{ {
setObjectName(name); setObjectName(name);
mName = "TeacherBarWidget"; mName = "TeacherBarWidget";
@ -63,9 +64,12 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock
mpContainer = new QWidget(this); mpContainer = new QWidget(this);
mpContainer->setObjectName("DockPaletteWidgetBox"); mpContainer->setObjectName("DockPaletteWidgetBox");
mpPreview = new UBTeacherBarPreviewWidget(this);
mpStackWidget = new QStackedWidget(this); mpStackWidget = new QStackedWidget(this);
mpContainerLayout->addWidget(mpStackWidget); mpContainerLayout->addWidget(mpStackWidget);
mpStackWidget->addWidget(mpContainer); mpStackWidget->addWidget(mpContainer);
mpStackWidget->addWidget(mpPreview);
mpLayout = new QVBoxLayout(mpContainer); mpLayout = new QVBoxLayout(mpContainer);
mpContainer->setLayout(mpLayout); mpContainer->setLayout(mpLayout);
@ -144,6 +148,7 @@ UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDock
connect(mpTitle, SIGNAL(textChanged(QString)), this, SLOT(onValueChanged())); connect(mpTitle, SIGNAL(textChanged(QString)), this, SLOT(onValueChanged()));
connect(mpActionButton, SIGNAL(clicked()), this, SLOT(onActionButton())); connect(mpActionButton, SIGNAL(clicked()), this, SLOT(onActionButton()));
connect(mpLinkButton, SIGNAL(clicked()), this, SLOT(onLinkButton())); connect(mpLinkButton, SIGNAL(clicked()), this, SLOT(onLinkButton()));
connect(mpPreview, SIGNAL(showEditMode()), this, SLOT(onShowEditMode()));
} }
UBTeacherBarWidget::~UBTeacherBarWidget() UBTeacherBarWidget::~UBTeacherBarWidget()
@ -240,6 +245,10 @@ UBTeacherBarWidget::~UBTeacherBarWidget()
delete mpContainerLayout; delete mpContainerLayout;
mpContainerLayout = NULL; mpContainerLayout = NULL;
} }
if(NULL != mpPreview){
delete mpPreview;
mpPreview = NULL;
}
if(NULL != mpStackWidget){ if(NULL != mpStackWidget){
delete mpStackWidget; delete mpStackWidget;
mpStackWidget = NULL; mpStackWidget = NULL;
@ -248,11 +257,7 @@ UBTeacherBarWidget::~UBTeacherBarWidget()
void UBTeacherBarWidget::onValueChanged() void UBTeacherBarWidget::onValueChanged()
{ {
if( mpTitle->text() == "" && if(isEmpty())
mpLinks->empty() &&
mpActions->empty() &&
mpDropMediaZone->empty() &&
mpComments->document()->toPlainText() == "")
{ {
mIconToLeft = QPixmap(":images/teacher_open_disabled.png"); mIconToLeft = QPixmap(":images/teacher_open_disabled.png");
mIconToRight = QPixmap(":images/teacher_close_disabled.png"); mIconToRight = QPixmap(":images/teacher_close_disabled.png");
@ -345,6 +350,19 @@ void UBTeacherBarWidget::loadContent()
if(NULL != mpComments){ if(NULL != mpComments){
mpComments->document()->setPlainText(nextInfos.comments); mpComments->document()->setPlainText(nextInfos.comments);
} }
if(!isEmpty()){
mpStackWidget->setCurrentWidget(mpPreview);
}
}
bool UBTeacherBarWidget::isEmpty()
{
return mpTitle->text() == "" &&
mpLinks->empty() &&
mpActions->empty() &&
mpDropMediaZone->empty() &&
mpComments->document()->toPlainText() == "";
} }
void UBTeacherBarWidget::onTitleTextChanged(const QString& text) void UBTeacherBarWidget::onTitleTextChanged(const QString& text)
@ -385,6 +403,11 @@ void UBTeacherBarWidget::clearWidgetLists()
} }
} }
void UBTeacherBarWidget::onShowEditMode()
{
mpStackWidget->setCurrentWidget(mpContainer);
}
// --------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------
UBTeacherStudentAction::UBTeacherStudentAction(QWidget *parent, const char *name):QWidget(parent) UBTeacherStudentAction::UBTeacherStudentAction(QWidget *parent, const char *name):QWidget(parent)
, mpText(NULL) , mpText(NULL)
@ -650,3 +673,45 @@ void UBUrlWidget::setUrl(const QString &url)
mpUrl->setText(url); mpUrl->setText(url);
} }
} }
// ------------------------------------------------------------------------------------
UBTeacherBarPreviewWidget::UBTeacherBarPreviewWidget(QWidget *parent, const char *name):QWidget(parent)
, mpLayout(NULL)
, mpEditButton(NULL)
, mpEditLayout(NULL)
{
setObjectName(name);
mpLayout = new QVBoxLayout(this);
setLayout(mpLayout);
mpEditButton = new QPushButton(tr("Edit infos"), this);
mpEditLayout = new QHBoxLayout();
mpEditLayout->addStretch(1);
mpEditLayout->addWidget(mpEditButton, 0);
mpEditLayout->addStretch(1);
mpLayout->addLayout(mpEditLayout);
connect(mpEditButton, SIGNAL(clicked()), this, SLOT(onEdit()));
}
UBTeacherBarPreviewWidget::~UBTeacherBarPreviewWidget()
{
if(NULL != mpEditButton){
delete mpEditButton;
mpEditButton = NULL;
}
if(NULL != mpEditLayout){
delete mpEditLayout;
mpEditLayout = NULL;
}
if(NULL != mpLayout){
delete mpLayout;
mpLayout = NULL;
}
}
void UBTeacherBarPreviewWidget::onEdit()
{
emit showEditMode();
}

@ -83,6 +83,25 @@ private:
QLineEdit* mpUrl; QLineEdit* mpUrl;
}; };
class UBTeacherBarPreviewWidget : public QWidget
{
Q_OBJECT
public:
UBTeacherBarPreviewWidget(QWidget* parent=0, const char* name="UBTeacherBarPreviewWidget");
~UBTeacherBarPreviewWidget();
signals:
void showEditMode();
private slots:
void onEdit();
private:
QVBoxLayout* mpLayout;
QPushButton* mpEditButton;
QHBoxLayout* mpEditLayout;
};
class UBTeacherBarWidget : public UBDockPaletteWidget class UBTeacherBarWidget : public UBDockPaletteWidget
{ {
Q_OBJECT Q_OBJECT
@ -97,9 +116,11 @@ private slots:
void onTitleTextChanged(const QString& text); void onTitleTextChanged(const QString& text);
void onActionButton(); void onActionButton();
void onLinkButton(); void onLinkButton();
void onShowEditMode();
private: private:
void clearWidgetLists(); void clearWidgetLists();
bool isEmpty();
QVBoxLayout* mpLayout; QVBoxLayout* mpLayout;
QHBoxLayout* mpTitleLayout; QHBoxLayout* mpTitleLayout;
QHBoxLayout* mpDurationLayout; QHBoxLayout* mpDurationLayout;
@ -125,6 +146,7 @@ private:
QLabel* mpCommentLabel; QLabel* mpCommentLabel;
QTextEdit* mpComments; QTextEdit* mpComments;
QStackedWidget* mpStackWidget; QStackedWidget* mpStackWidget;
UBTeacherBarPreviewWidget* mpPreview;
QVector<UBTeacherStudentAction*> mActionList; QVector<UBTeacherStudentAction*> mActionList;
QVector<UBUrlWidget*> mUrlList; QVector<UBUrlWidget*> mUrlList;

Loading…
Cancel
Save