parent
050d898ccd
commit
48bce1d8b1
@ -1,214 +0,0 @@ |
|||||||
#include <QDebug> |
|
||||||
|
|
||||||
#include "UBTBDocumentEditWidget.h" |
|
||||||
#include "globals/UBGlobals.h" |
|
||||||
|
|
||||||
UBTBDocumentEditWidget::UBTBDocumentEditWidget(UBTeacherBarDataMgr* pDataMgr, QWidget *parent, const char *name):QWidget(parent) |
|
||||||
, mpPageViewButton(NULL) |
|
||||||
, mpPreviewButton(NULL) |
|
||||||
, mpTitleLabel(NULL) |
|
||||||
, mpTitle(NULL) |
|
||||||
, mpTargetLabel(NULL) |
|
||||||
, mpTarget(NULL) |
|
||||||
, mpMetadataLabel(NULL) |
|
||||||
, mpLicenseLabel(NULL) |
|
||||||
, mpLicenseCombox(NULL) |
|
||||||
, mpKeywords(NULL) |
|
||||||
, mpLevel(NULL) |
|
||||||
, mpTopic(NULL) |
|
||||||
, mpAuthor(NULL) |
|
||||||
, mpKeywordLabel(NULL) |
|
||||||
, mpLevelLabel(NULL) |
|
||||||
, mpTopicLabel(NULL) |
|
||||||
, mpAuthorLabel(NULL) |
|
||||||
{ |
|
||||||
setObjectName(name); |
|
||||||
|
|
||||||
mpDataMgr = pDataMgr; |
|
||||||
|
|
||||||
setLayout(&mLayout); |
|
||||||
mLayout.setContentsMargins(0, 0, 0, 0); |
|
||||||
|
|
||||||
mpContainer = new QWidget(this); |
|
||||||
mpContainer->setObjectName("DockPaletteWidgetBox"); |
|
||||||
mLayout.addWidget(mpContainer, 1); |
|
||||||
mpContainer->setLayout(&mContainerLayout); |
|
||||||
|
|
||||||
// Title
|
|
||||||
mpTitleLabel = new QLabel(tr("Session Title"), mpContainer); |
|
||||||
mpTitleLabel->setAlignment(Qt::AlignLeft); |
|
||||||
mpTitleLabel->setObjectName("UBTeacherBarPreviewSubtitle"); |
|
||||||
mContainerLayout.addWidget(mpTitleLabel, 0); |
|
||||||
mpTitle = new QLineEdit(mpContainer); |
|
||||||
mpTitle->setObjectName("DockPaletteWidgetLineEdit"); |
|
||||||
mContainerLayout.addWidget(mpTitle, 0); |
|
||||||
mContainerLayout.addWidget(&mTitleSeparator); |
|
||||||
|
|
||||||
// Target
|
|
||||||
mpTargetLabel = new QLabel(tr("Session Target"), mpContainer); |
|
||||||
mpTargetLabel->setObjectName("UBTeacherBarPreviewSubtitle"); |
|
||||||
mContainerLayout.addWidget(mpTargetLabel, 0); |
|
||||||
mpTarget = new QTextEdit(mpContainer); |
|
||||||
mpTarget->setObjectName("UBTeacherBarTargetBox"); |
|
||||||
mContainerLayout.addWidget(mpTarget, 1); |
|
||||||
mContainerLayout.addWidget(&mTargetSeparator); |
|
||||||
|
|
||||||
// Metadata
|
|
||||||
mpMetadataLabel = new QLabel(tr("Metadata"), mpContainer); |
|
||||||
mpMetadataLabel->setObjectName("UBTeacherBarPreviewSubtitle"); |
|
||||||
mpMetadataLabel->setAlignment(Qt::AlignLeft); |
|
||||||
mContainerLayout.addWidget(mpMetadataLabel, 0); |
|
||||||
mpKeywords = new QLineEdit(this); |
|
||||||
mpKeywords->setObjectName("DockPaletteWidgetLineEdit"); |
|
||||||
mpLevel = new QComboBox(this); |
|
||||||
mpLevel->setObjectName("DockPaletteWidgetComboBox"); |
|
||||||
mpTopic = new QLineEdit(this); |
|
||||||
mpTopic->setObjectName("DockPaletteWidgetLineEdit"); |
|
||||||
mpAuthor = new QLineEdit(this); |
|
||||||
mpAuthor->setObjectName("DockPaletteWidgetLineEdit"); |
|
||||||
mpKeywordLabel = new QLabel(tr("Keywords:"), this); |
|
||||||
mpLevelLabel = new QLabel(tr("Level:"), this); |
|
||||||
mpTopicLabel = new QLabel(tr("Topic:"), this); |
|
||||||
mpAuthorLabel = new QLabel(tr("Author"), this); |
|
||||||
|
|
||||||
mKeywordLayout.addWidget(mpKeywordLabel, 0); |
|
||||||
mKeywordLayout.addWidget(mpKeywords, 1); |
|
||||||
mLevelLayout.addWidget(mpLevelLabel, 0); |
|
||||||
mLevelLayout.addWidget(mpLevel, 1); |
|
||||||
mTopicLayout.addWidget(mpTopicLabel, 0); |
|
||||||
mTopicLayout.addWidget(mpTopic, 1); |
|
||||||
mAuthorLayout.addWidget(mpAuthorLabel, 0); |
|
||||||
mAuthorLayout.addWidget(mpAuthor, 1); |
|
||||||
|
|
||||||
mContainerLayout.addLayout(&mKeywordLayout, 0); |
|
||||||
mContainerLayout.addLayout(&mLevelLayout, 0); |
|
||||||
mContainerLayout.addLayout(&mTopicLayout, 0); |
|
||||||
mContainerLayout.addLayout(&mAuthorLayout, 0); |
|
||||||
|
|
||||||
mContainerLayout.addWidget(&mLicenseSeparator); |
|
||||||
|
|
||||||
// License
|
|
||||||
mpLicenseLabel = new QLabel(tr("License"), mpContainer); |
|
||||||
mpLicenseLabel->setAlignment(Qt::AlignLeft); |
|
||||||
mpLicenseLabel->setObjectName("UBTeacherBarPreviewSubtitle"); |
|
||||||
mContainerLayout.addWidget(mpLicenseLabel, 0); |
|
||||||
mpLicenseCombox = new QComboBox(this); |
|
||||||
mpLicenseCombox->setObjectName("DockPaletteWidgetComboBox"); |
|
||||||
QStringList qslLicenses; |
|
||||||
qslLicenses << "CC BY"; |
|
||||||
qslLicenses << "CC BY-ND"; |
|
||||||
qslLicenses << "CC BY-NC-SA"; |
|
||||||
qslLicenses << "CC BY-SA"; |
|
||||||
qslLicenses << "CC BY-NC"; |
|
||||||
qslLicenses << "CC BY-NC-ND"; |
|
||||||
mpLicenseCombox->addItems(qslLicenses); |
|
||||||
mContainerLayout.addWidget(mpLicenseCombox); |
|
||||||
|
|
||||||
mpPageViewButton = new QPushButton(tr("Page View"), this); |
|
||||||
mpPageViewButton->setObjectName("DockPaletteWidgetButton"); |
|
||||||
mPreviewLayout.addWidget(mpPageViewButton, 0); |
|
||||||
mpPreviewButton = new QPushButton(tr("Preview"), this); |
|
||||||
mpPreviewButton->setObjectName("DockPaletteWidgetButton"); |
|
||||||
mPreviewLayout.addWidget(mpPreviewButton, 0); |
|
||||||
mPreviewLayout.addStretch(1); |
|
||||||
mLayout.addLayout(&mPreviewLayout, 0); |
|
||||||
|
|
||||||
connect(mpPageViewButton, SIGNAL(clicked()), this, SLOT(onPageView())); |
|
||||||
connect(mpPreviewButton, SIGNAL(clicked()), this, SLOT(onPreview())); |
|
||||||
connect(mpTitle, SIGNAL(textChanged(QString)), this, SLOT(onSessionTitleChanged())); |
|
||||||
connect(mpTarget, SIGNAL(textChanged()), this, SLOT(onSessionTargetChanged())); |
|
||||||
connect(mpLicenseCombox, SIGNAL(currentIndexChanged(int)), this, SLOT(onLicenseCurrentIndexChanged(int))); |
|
||||||
connect(mpKeywords, SIGNAL(textChanged(QString)), this, SLOT(onKeywordChanged(QString))); |
|
||||||
connect(mpLevel, SIGNAL(currentIndexChanged(QString)), this, SLOT(onLevelChanged(QString))); |
|
||||||
connect(mpTopic, SIGNAL(textChanged(QString)), this, SLOT(onTopicChanged(QString))); |
|
||||||
connect(mpAuthor, SIGNAL(textChanged(QString)), this, SLOT(onAuthorChanged(QString))); |
|
||||||
} |
|
||||||
|
|
||||||
UBTBDocumentEditWidget::~UBTBDocumentEditWidget() |
|
||||||
{ |
|
||||||
DELETEPTR(mpTitleLabel); |
|
||||||
DELETEPTR(mpTitle); |
|
||||||
DELETEPTR(mpTargetLabel); |
|
||||||
DELETEPTR(mpTarget); |
|
||||||
DELETEPTR(mpMetadataLabel); |
|
||||||
DELETEPTR(mpKeywordLabel); |
|
||||||
DELETEPTR(mpLevelLabel); |
|
||||||
DELETEPTR(mpTopicLabel); |
|
||||||
DELETEPTR(mpAuthorLabel); |
|
||||||
DELETEPTR(mpKeywords); |
|
||||||
DELETEPTR(mpLevel); |
|
||||||
DELETEPTR(mpTopic); |
|
||||||
DELETEPTR(mpAuthor); |
|
||||||
DELETEPTR(mpLicenseLabel); |
|
||||||
DELETEPTR(mpLicenseCombox); |
|
||||||
DELETEPTR(mpPageViewButton); |
|
||||||
DELETEPTR(mpPreviewButton); |
|
||||||
} |
|
||||||
|
|
||||||
void UBTBDocumentEditWidget::onPageView() |
|
||||||
{ |
|
||||||
emit changeTBState(eTeacherBarState_PageEdit); |
|
||||||
} |
|
||||||
|
|
||||||
void UBTBDocumentEditWidget::onPreview() |
|
||||||
{ |
|
||||||
emit changeTBState(eTeacherBarState_DocumentPreview); |
|
||||||
} |
|
||||||
|
|
||||||
void UBTBDocumentEditWidget::onSessionTitleChanged() |
|
||||||
{ |
|
||||||
mpDataMgr->setSessionTitle(mpTitle->text()); |
|
||||||
emit valueChanged(); |
|
||||||
} |
|
||||||
|
|
||||||
void UBTBDocumentEditWidget::onSessionTargetChanged() |
|
||||||
{ |
|
||||||
mpDataMgr->setSessionTarget(mpTarget->document()->toPlainText()); |
|
||||||
emit valueChanged(); |
|
||||||
} |
|
||||||
|
|
||||||
void UBTBDocumentEditWidget::onLicenseCurrentIndexChanged(int selection) |
|
||||||
{ |
|
||||||
mpDataMgr->setSessionLicence((eLicense)selection); |
|
||||||
emit valueChanged(); |
|
||||||
} |
|
||||||
|
|
||||||
void UBTBDocumentEditWidget::updateFields() |
|
||||||
{ |
|
||||||
mpTitle->setText(mpDataMgr->sessionTitle()); |
|
||||||
mpTarget->setPlainText(mpDataMgr->sessionTarget()); |
|
||||||
mpKeywords->setText(mpDataMgr->keywords()); |
|
||||||
// TODO: retrieve the level
|
|
||||||
mpTopic->setText(mpDataMgr->topic()); |
|
||||||
mpAuthor->setText(mpDataMgr->authors()); |
|
||||||
} |
|
||||||
|
|
||||||
void UBTBDocumentEditWidget::clearFields() |
|
||||||
{ |
|
||||||
mpTitle->setText(""); |
|
||||||
mpTarget->setPlainText(""); |
|
||||||
} |
|
||||||
|
|
||||||
void UBTBDocumentEditWidget::onKeywordChanged(const QString &kw) |
|
||||||
{ |
|
||||||
mpDataMgr->setKeywords(kw); |
|
||||||
emit valueChanged(); |
|
||||||
} |
|
||||||
|
|
||||||
void UBTBDocumentEditWidget::onLevelChanged(const QString &level) |
|
||||||
{ |
|
||||||
mpDataMgr->setLevel(level); |
|
||||||
emit valueChanged(); |
|
||||||
} |
|
||||||
|
|
||||||
void UBTBDocumentEditWidget::onTopicChanged(const QString &topic) |
|
||||||
{ |
|
||||||
mpDataMgr->setTopic(topic); |
|
||||||
emit valueChanged(); |
|
||||||
} |
|
||||||
|
|
||||||
void UBTBDocumentEditWidget::onAuthorChanged(const QString &authors) |
|
||||||
{ |
|
||||||
mpDataMgr->setAuthors(authors); |
|
||||||
emit valueChanged(); |
|
||||||
} |
|
@ -1,73 +0,0 @@ |
|||||||
#ifndef UBTBDOCUMENTEDITWIDGET_H |
|
||||||
#define UBTBDOCUMENTEDITWIDGET_H |
|
||||||
|
|
||||||
#include <QVBoxLayout> |
|
||||||
#include <QPushButton> |
|
||||||
#include <QLabel> |
|
||||||
#include <QLineEdit> |
|
||||||
#include <QTextEdit> |
|
||||||
#include <QComboBox> |
|
||||||
|
|
||||||
#include "UBTeacherBarDataMgr.h" |
|
||||||
|
|
||||||
class UBTBDocumentEditWidget : public QWidget |
|
||||||
{ |
|
||||||
Q_OBJECT |
|
||||||
public: |
|
||||||
UBTBDocumentEditWidget(UBTeacherBarDataMgr* pDataMgr, QWidget* parent=0, const char* name="UBTBDocumentEditWidget"); |
|
||||||
~UBTBDocumentEditWidget(); |
|
||||||
void updateFields(); |
|
||||||
void clearFields(); |
|
||||||
|
|
||||||
signals: |
|
||||||
void changeTBState(eTeacherBarState state); |
|
||||||
void valueChanged(); |
|
||||||
|
|
||||||
private slots: |
|
||||||
void onPageView(); |
|
||||||
void onPreview(); |
|
||||||
void onSessionTitleChanged(); |
|
||||||
void onSessionTargetChanged(); |
|
||||||
void onLicenseCurrentIndexChanged(int selection); |
|
||||||
void onKeywordChanged(const QString& kw); |
|
||||||
void onLevelChanged(const QString& level); |
|
||||||
void onTopicChanged(const QString& topic); |
|
||||||
void onAuthorChanged(const QString& authors); |
|
||||||
|
|
||||||
private: |
|
||||||
QVBoxLayout mLayout; |
|
||||||
QHBoxLayout mPageLayout; |
|
||||||
QHBoxLayout mPreviewLayout; |
|
||||||
QVBoxLayout mContainerLayout; |
|
||||||
QPushButton* mpPageViewButton; |
|
||||||
QPushButton* mpPreviewButton; |
|
||||||
UBTBSeparator mTitleSeparator; |
|
||||||
UBTBSeparator mTargetSeparator; |
|
||||||
UBTBSeparator mLicenseSeparator; |
|
||||||
|
|
||||||
QHBoxLayout mKeywordLayout; |
|
||||||
QHBoxLayout mLevelLayout; |
|
||||||
QHBoxLayout mTopicLayout; |
|
||||||
QHBoxLayout mAuthorLayout; |
|
||||||
|
|
||||||
QWidget* mpContainer; |
|
||||||
QLabel* mpTitleLabel; |
|
||||||
QLineEdit* mpTitle; |
|
||||||
QLabel* mpTargetLabel; |
|
||||||
QTextEdit* mpTarget; |
|
||||||
QLabel* mpMetadataLabel; |
|
||||||
QLabel* mpLicenseLabel; |
|
||||||
QComboBox* mpLicenseCombox; |
|
||||||
QLineEdit* mpKeywords; |
|
||||||
QComboBox* mpLevel; |
|
||||||
QLineEdit* mpTopic; |
|
||||||
QLineEdit* mpAuthor; |
|
||||||
QLabel* mpKeywordLabel; |
|
||||||
QLabel* mpLevelLabel; |
|
||||||
QLabel* mpTopicLabel; |
|
||||||
QLabel* mpAuthorLabel; |
|
||||||
|
|
||||||
UBTeacherBarDataMgr* mpDataMgr; |
|
||||||
}; |
|
||||||
|
|
||||||
#endif // UBTBDOCUMENTEDITWIDGET_H
|
|
@ -1,161 +0,0 @@ |
|||||||
#include "globals/UBGlobals.h" |
|
||||||
#include "UBTBDocumentPreviewWidget.h" |
|
||||||
|
|
||||||
UBTBDocumentPreviewWidget::UBTBDocumentPreviewWidget(UBTeacherBarDataMgr *pDataMgr, QWidget *parent, const char *name):QWidget(parent) |
|
||||||
, mpContainer(NULL) |
|
||||||
, mpPageViewButton(NULL) |
|
||||||
, mpEditButton(NULL) |
|
||||||
, mpSessionLabel(NULL) |
|
||||||
, mpSessionTitle(NULL) |
|
||||||
, mpAuthorLabel(NULL) |
|
||||||
, mpAuthors(NULL) |
|
||||||
, mpCreationDate(NULL) |
|
||||||
, mpTargetLabel(NULL) |
|
||||||
, mpTarget(NULL) |
|
||||||
, mpMetadataLabel(NULL) |
|
||||||
, mpKeywordLabel(NULL) |
|
||||||
, mpKeyword(NULL) |
|
||||||
, mpLevelLabel(NULL) |
|
||||||
, mpLevel(NULL) |
|
||||||
, mpTopicLabel(NULL) |
|
||||||
, mpTopic(NULL) |
|
||||||
, mpLicense(NULL) |
|
||||||
{ |
|
||||||
setObjectName(name); |
|
||||||
mpDataMgr = pDataMgr; |
|
||||||
|
|
||||||
setLayout(&mLayout); |
|
||||||
mLayout.setContentsMargins(0, 0, 0, 0); |
|
||||||
|
|
||||||
mpContainer = new QWidget(this); |
|
||||||
mpContainer->setLayout(&mContainerLayout); |
|
||||||
mpContainer->setObjectName("UBTBPreviewWidget"); |
|
||||||
|
|
||||||
// Session Title
|
|
||||||
mpSessionLabel = new QLabel(tr("Session"), mpContainer); |
|
||||||
mpSessionLabel->setAlignment(Qt::AlignRight); |
|
||||||
mpSessionLabel->setObjectName("UBTeacherBarPreviewSubtitle"); |
|
||||||
mContainerLayout.addWidget(mpSessionLabel, 0); |
|
||||||
mpSessionTitle = new QLabel(mpContainer); |
|
||||||
mpSessionTitle->setWordWrap(true); |
|
||||||
mpSessionTitle->setAlignment(Qt::AlignRight); |
|
||||||
mpSessionTitle->setObjectName("UBTeacherBarPreviewTitle"); |
|
||||||
mContainerLayout.addWidget(mpSessionTitle, 0); |
|
||||||
mContainerLayout.addWidget(&mTitleSeparator, 0); |
|
||||||
|
|
||||||
// Author(s)
|
|
||||||
mpAuthorLabel = new QLabel(tr("Author(s)"), mpContainer); |
|
||||||
mpAuthorLabel->setObjectName("UBTeacherBarPreviewSubtitle"); |
|
||||||
mContainerLayout.addWidget(mpAuthorLabel, 0); |
|
||||||
mpAuthors = new QLabel(mpContainer); |
|
||||||
mpAuthors->setWordWrap(true); |
|
||||||
mpAuthors->setStyleSheet("padding-left:5px;"); |
|
||||||
mContainerLayout.addWidget(mpAuthors, 0); |
|
||||||
mContainerLayout.addWidget(&mAuthorSeparator, 0); |
|
||||||
|
|
||||||
// Dates
|
|
||||||
mpCreationDate = new QLabel(tr("Created on: "), mpContainer); |
|
||||||
mpCreationDate->setStyleSheet("padding-left:5px;"); |
|
||||||
mContainerLayout.addWidget(mpCreationDate); |
|
||||||
mContainerLayout.addWidget(&mDateSeparator, 0); |
|
||||||
|
|
||||||
// Target
|
|
||||||
mpTargetLabel = new QLabel(tr("Target"), mpContainer); |
|
||||||
mpTargetLabel->setObjectName("UBTeacherBarPreviewSubtitle"); |
|
||||||
mContainerLayout.addWidget(mpTargetLabel,0); |
|
||||||
mpTarget = new QTextEdit(mpContainer); |
|
||||||
mpTarget->setReadOnly(true); |
|
||||||
mContainerLayout.addWidget(mpTarget, 1); |
|
||||||
mContainerLayout.addWidget(&mTargetSeparator, 0); |
|
||||||
|
|
||||||
// Metadata
|
|
||||||
mpMetadataLabel = new QLabel(tr("Metadata"), mpContainer); |
|
||||||
mpMetadataLabel->setObjectName("UBTeacherBarPreviewSubtitle"); |
|
||||||
mContainerLayout.addWidget(mpMetadataLabel, 0); |
|
||||||
|
|
||||||
// Keyword
|
|
||||||
mpKeywordLabel = new QLabel(tr("<b>Keywords:</b>"), mpContainer); |
|
||||||
mpKeywordLabel->setStyleSheet("padding-left:5px;"); |
|
||||||
mpKeyword = new QLabel(mpContainer); |
|
||||||
mpKeyword->setWordWrap(true); |
|
||||||
mKeywordLayout.addWidget(mpKeywordLabel, 0); |
|
||||||
mKeywordLayout.addWidget(mpKeyword, 1); |
|
||||||
mContainerLayout.addLayout(&mKeywordLayout, 0); |
|
||||||
|
|
||||||
// Level
|
|
||||||
mpLevelLabel = new QLabel(tr("<b>Level:</b>"), mpContainer); |
|
||||||
mpLevelLabel->setStyleSheet("padding-left:5px;"); |
|
||||||
mpLevel = new QLabel(mpContainer); |
|
||||||
mpLevel->setWordWrap(true); |
|
||||||
mLevelLayout.addWidget(mpLevelLabel, 0); |
|
||||||
mLevelLayout.addWidget(mpLevel, 1); |
|
||||||
mContainerLayout.addLayout(&mLevelLayout, 0); |
|
||||||
|
|
||||||
// Topic
|
|
||||||
mpTopicLabel = new QLabel(tr("<b>Topic:</b>"), mpContainer); |
|
||||||
mpTopicLabel->setStyleSheet("padding-left:5px;"); |
|
||||||
mpTopic = new QLabel(mpContainer); |
|
||||||
mpTopic->setWordWrap(true); |
|
||||||
mTopicLayout.addWidget(mpTopicLabel, 0); |
|
||||||
mTopicLayout.addWidget(mpTopic, 1); |
|
||||||
mContainerLayout.addLayout(&mTopicLayout, 0); |
|
||||||
mContainerLayout.addWidget(&mMetadataSeparator, 0); |
|
||||||
|
|
||||||
// License
|
|
||||||
mpLicense = new UBTBLicenseWidget(mpContainer); |
|
||||||
mContainerLayout.addWidget(mpLicense, 0); |
|
||||||
|
|
||||||
mLayout.addWidget(mpContainer, 1); |
|
||||||
|
|
||||||
mpPageViewButton = new QPushButton(tr("Page View"), this); |
|
||||||
mpPageViewButton->setObjectName("DockPaletteWidgetButton"); |
|
||||||
mpEditButton = new QPushButton(tr("Edit"), this); |
|
||||||
mpEditButton->setObjectName("DockPaletteWidgetButton"); |
|
||||||
|
|
||||||
mButtonsLayout.addWidget(mpPageViewButton, 0); |
|
||||||
mButtonsLayout.addWidget(mpEditButton, 0); |
|
||||||
mButtonsLayout.addStretch(1); |
|
||||||
|
|
||||||
mLayout.addLayout(&mButtonsLayout, 0); |
|
||||||
|
|
||||||
connect(mpPageViewButton, SIGNAL(clicked()), this, SLOT(onPageView())); |
|
||||||
connect(mpEditButton, SIGNAL(clicked()), this, SLOT(onEdit())); |
|
||||||
} |
|
||||||
|
|
||||||
UBTBDocumentPreviewWidget::~UBTBDocumentPreviewWidget() |
|
||||||
{ |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
void UBTBDocumentPreviewWidget::onEdit() |
|
||||||
{ |
|
||||||
emit changeTBState(eTeacherBarState_DocumentEdit); |
|
||||||
} |
|
||||||
|
|
||||||
void UBTBDocumentPreviewWidget::onPageView() |
|
||||||
{ |
|
||||||
emit changeTBState(eTeacherBarState_PagePreview); |
|
||||||
} |
|
||||||
|
|
||||||
void UBTBDocumentPreviewWidget::updateFields() |
|
||||||
{ |
|
||||||
mpSessionTitle->setText(mpDataMgr->sessionTitle()); |
|
||||||
mpAuthors->setText(mpDataMgr->authors()); |
|
||||||
mpCreationDate->setText(tr("<b>Creation Date:</b> %0").arg(mpDataMgr->creationDate())); |
|
||||||
mpTarget->setText(mpDataMgr->sessionTarget()); |
|
||||||
mpLicense->setLicense(mpDataMgr->sessionLicence()); |
|
||||||
mpKeyword->setText(mpDataMgr->keywords()); |
|
||||||
mpLevel->setText(mpDataMgr->level()); |
|
||||||
mpTopic->setText(mpDataMgr->topic()); |
|
||||||
} |
|
||||||
|
|
||||||
void UBTBDocumentPreviewWidget::clearFields() |
|
||||||
{ |
|
||||||
mpSessionTitle->setText(""); |
|
||||||
mpAuthors->setText(""); |
|
||||||
mpCreationDate->setText(""); |
|
||||||
mpTarget->setText(""); |
|
||||||
mpKeyword->setText(""); |
|
||||||
mpLevel->setText(""); |
|
||||||
mpTopic->setText(""); |
|
||||||
} |
|
@ -1,60 +0,0 @@ |
|||||||
#ifndef UBTBDOCUMENTPREVIEWWIDGET_H |
|
||||||
#define UBTBDOCUMENTPREVIEWWIDGET_H |
|
||||||
|
|
||||||
#include <QVBoxLayout> |
|
||||||
#include <QPushButton> |
|
||||||
|
|
||||||
#include "UBTeacherBarDataMgr.h" |
|
||||||
|
|
||||||
class UBTBDocumentPreviewWidget : public QWidget |
|
||||||
{ |
|
||||||
Q_OBJECT |
|
||||||
public: |
|
||||||
UBTBDocumentPreviewWidget(UBTeacherBarDataMgr* pDataMgr, QWidget* parent=0, const char* name="UBTBDocumentPreviewWidget"); |
|
||||||
~UBTBDocumentPreviewWidget(); |
|
||||||
void updateFields(); |
|
||||||
void clearFields(); |
|
||||||
|
|
||||||
signals: |
|
||||||
void changeTBState(eTeacherBarState state); |
|
||||||
|
|
||||||
private slots: |
|
||||||
void onPageView(); |
|
||||||
void onEdit(); |
|
||||||
|
|
||||||
private: |
|
||||||
QVBoxLayout mLayout; |
|
||||||
QHBoxLayout mButtonsLayout; |
|
||||||
|
|
||||||
QWidget* mpContainer; |
|
||||||
QVBoxLayout mContainerLayout; |
|
||||||
QPushButton* mpPageViewButton; |
|
||||||
QPushButton* mpEditButton; |
|
||||||
QLabel* mpSessionLabel; |
|
||||||
QLabel* mpSessionTitle; |
|
||||||
UBTBSeparator mTitleSeparator; |
|
||||||
QLabel* mpAuthorLabel; |
|
||||||
QLabel* mpAuthors; |
|
||||||
UBTBSeparator mAuthorSeparator; |
|
||||||
QLabel* mpCreationDate; |
|
||||||
UBTBSeparator mDateSeparator; |
|
||||||
QLabel* mpTargetLabel; |
|
||||||
QTextEdit* mpTarget; |
|
||||||
UBTBSeparator mTargetSeparator; |
|
||||||
QLabel* mpMetadataLabel; |
|
||||||
QHBoxLayout mKeywordLayout; |
|
||||||
QLabel* mpKeywordLabel; |
|
||||||
QLabel* mpKeyword; |
|
||||||
QHBoxLayout mLevelLayout; |
|
||||||
QLabel* mpLevelLabel; |
|
||||||
QLabel* mpLevel; |
|
||||||
QHBoxLayout mTopicLayout; |
|
||||||
QLabel* mpTopicLabel; |
|
||||||
QLabel* mpTopic; |
|
||||||
UBTBSeparator mMetadataSeparator; |
|
||||||
UBTBLicenseWidget* mpLicense; |
|
||||||
|
|
||||||
UBTeacherBarDataMgr* mpDataMgr; |
|
||||||
}; |
|
||||||
|
|
||||||
#endif // UBTBDOCUMENTPREVIEWWIDGET_H
|
|
@ -1,612 +0,0 @@ |
|||||||
#include "globals/UBGlobals.h" |
|
||||||
#include "core/UBApplication.h" |
|
||||||
#include "frameworks/UBFileSystemUtils.h" |
|
||||||
#include "gui/UBMediaPlayer.h" |
|
||||||
#include "customWidgets/UBMediaWidget.h" |
|
||||||
|
|
||||||
#include "UBTBPageEditWidget.h" |
|
||||||
|
|
||||||
UBTBPageEditWidget::UBTBPageEditWidget(UBTeacherBarDataMgr *pDataMgr, QWidget *parent, const char *name):QWidget(parent) |
|
||||||
, mpDataMgr(NULL) |
|
||||||
, mpTitleLabel(NULL) |
|
||||||
, mpTitle(NULL) |
|
||||||
, mpMediaLabel(NULL) |
|
||||||
, mpActionLabel(NULL) |
|
||||||
, mpActions(NULL) |
|
||||||
, mpActionButton(NULL) |
|
||||||
, mpLinkLabel(NULL) |
|
||||||
, mpLinks(NULL) |
|
||||||
, mpLinkButton(NULL) |
|
||||||
, mpCommentLabel(NULL) |
|
||||||
, mpComments(NULL) |
|
||||||
, mpDocumentEditbutton(NULL) |
|
||||||
, mpPagePreviewButton(NULL) |
|
||||||
, mpContainer(NULL) |
|
||||||
{ |
|
||||||
Q_UNUSED(name); |
|
||||||
mpDataMgr = pDataMgr; |
|
||||||
mActions.clear(); |
|
||||||
mUrls.clear(); |
|
||||||
setAttribute(Qt::WA_StyledBackground, true); |
|
||||||
setStyleSheet(UBApplication::globalStyleSheet()); |
|
||||||
mClearingFields = false; |
|
||||||
mLayout.setContentsMargins(0, 0, 0, 0); |
|
||||||
setLayout(&mLayout); |
|
||||||
|
|
||||||
mpContainer = new QWidget(this); |
|
||||||
mpContainer->setObjectName("DockPaletteWidgetBox"); |
|
||||||
mpContainer->setLayout(&mContainerLayout); |
|
||||||
mLayout.addWidget(mpContainer, 1); |
|
||||||
|
|
||||||
// Title
|
|
||||||
mpTitleLabel = new QLabel(tr("Title"), mpContainer); |
|
||||||
mpTitle = new QLineEdit(mpContainer); |
|
||||||
mpTitle->setObjectName("DockPaletteWidgetLineEdit"); |
|
||||||
mContainerLayout.addWidget(mpTitleLabel, 0); |
|
||||||
mContainerLayout.addWidget(mpTitle, 0); |
|
||||||
|
|
||||||
// Actions
|
|
||||||
mpActionLabel = new QLabel(tr("Actions"), mpContainer); |
|
||||||
mContainerLayout.addWidget(mpActionLabel, 0); |
|
||||||
mpActions = new UBWidgetList(mpContainer); |
|
||||||
mpActions->setEmptyText(tr("Add actions")); |
|
||||||
mContainerLayout.addWidget(mpActions, 1); |
|
||||||
mpActionButton = new QPushButton(mpContainer); |
|
||||||
mpActionButton->setObjectName("DockPaletteWidgetButton"); |
|
||||||
mpActionButton->setText(tr("Add action")); |
|
||||||
mActionLayout.addWidget(mpActionButton, 0); |
|
||||||
mActionLayout.addStretch(1); |
|
||||||
mContainerLayout.addLayout(&mActionLayout, 0); |
|
||||||
|
|
||||||
// Media
|
|
||||||
mpMediaLabel = new QLabel(tr("Medias"), mpContainer); |
|
||||||
mContainerLayout.addWidget(mpMediaLabel, 0); |
|
||||||
mpMediaContainer = new UBTBMediaContainer(mpContainer); |
|
||||||
mpMediaContainer->setEmptyText(tr("Drop media here")); |
|
||||||
mContainerLayout.addWidget(mpMediaContainer, 1); |
|
||||||
|
|
||||||
// Links
|
|
||||||
mpLinkLabel = new QLabel(tr("Links"), mpContainer); |
|
||||||
mContainerLayout.addWidget(mpLinkLabel, 0); |
|
||||||
mpLinks = new UBWidgetList(mpContainer); |
|
||||||
mContainerLayout.addWidget(mpLinks, 1); |
|
||||||
mpLinkButton = new QPushButton(tr("Add link"), mpContainer); |
|
||||||
mpLinkButton->setObjectName("DockPaletteWidgetButton"); |
|
||||||
mLinkLayout.addWidget(mpLinkButton, 0); |
|
||||||
mLinkLayout.addStretch(1); |
|
||||||
mContainerLayout.addLayout(&mLinkLayout, 0); |
|
||||||
|
|
||||||
// Comments
|
|
||||||
mpCommentLabel = new QLabel(tr("Comments"), mpContainer); |
|
||||||
mContainerLayout.addWidget(mpCommentLabel, 0); |
|
||||||
mpComments = new QTextEdit(mpContainer); |
|
||||||
mpComments->setObjectName("DockPaletteWidgetBox"); |
|
||||||
mpComments->setStyleSheet("background:white;"); |
|
||||||
mContainerLayout.addWidget(mpComments, 1); |
|
||||||
|
|
||||||
mpPagePreviewButton = new QPushButton(tr("Preview"), this); |
|
||||||
mpPagePreviewButton->setObjectName("DockPaletteWidgetButton"); |
|
||||||
mpDocumentEditbutton = new QPushButton(tr("Document View"), this); |
|
||||||
mpDocumentEditbutton->setObjectName("DockPaletteWidgetButton"); |
|
||||||
mPagePreviewLayout.addWidget(mpDocumentEditbutton, 0); |
|
||||||
mPagePreviewLayout.addWidget(mpPagePreviewButton, 0); |
|
||||||
mPagePreviewLayout.addStretch(1); |
|
||||||
mLayout.addLayout(&mPagePreviewLayout, 0); |
|
||||||
|
|
||||||
connect(mpTitle, SIGNAL(textChanged(QString)), this, SLOT(onTitleChanged())); |
|
||||||
connect(mpComments, SIGNAL(textChanged()), this, SLOT(onCommentsChanged())); |
|
||||||
connect(mpActionButton, SIGNAL(clicked()), this, SLOT(onActionButton())); |
|
||||||
connect(mpLinkButton, SIGNAL(clicked()), this, SLOT(onLinkButton())); |
|
||||||
connect(mpDocumentEditbutton, SIGNAL(clicked()), this, SLOT(onDocumentEditClicked())); |
|
||||||
connect(mpPagePreviewButton, SIGNAL(clicked()), this, SLOT(onPagePreviewClicked())); |
|
||||||
connect(mpMediaContainer, SIGNAL(mediaDropped(QString)), this, SLOT(onMediaDropped(QString))); |
|
||||||
connect(mpActions, SIGNAL(closeWidget(QWidget*)), this, SLOT(onCloseWidget(QWidget*))); |
|
||||||
connect(mpLinks, SIGNAL(closeWidget(QWidget*)), this, SLOT(onCloseWidget(QWidget*))); |
|
||||||
connect(mpMediaContainer, SIGNAL(closeWidget(QWidget*)), this, SLOT(onCloseWidget(QWidget*))); |
|
||||||
} |
|
||||||
|
|
||||||
UBTBPageEditWidget::~UBTBPageEditWidget() |
|
||||||
{ |
|
||||||
DELETEPTR(mpDocumentEditbutton); |
|
||||||
DELETEPTR(mpPagePreviewButton); |
|
||||||
DELETEPTR(mpComments); |
|
||||||
DELETEPTR(mpCommentLabel); |
|
||||||
DELETEPTR(mpLinks); |
|
||||||
DELETEPTR(mpLinkLabel); |
|
||||||
DELETEPTR(mpLinkButton); |
|
||||||
DELETEPTR(mpMediaLabel); |
|
||||||
DELETEPTR(mpActionButton); |
|
||||||
DELETEPTR(mpActionLabel); |
|
||||||
DELETEPTR(mpTitleLabel); |
|
||||||
DELETEPTR(mpTitle); |
|
||||||
} |
|
||||||
|
|
||||||
void UBTBPageEditWidget::onTitleChanged() |
|
||||||
{ |
|
||||||
if(!mClearingFields){ |
|
||||||
mpDataMgr->setPageTitle(mpTitle->text()); |
|
||||||
emit valueChanged(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void UBTBPageEditWidget::onCommentsChanged() |
|
||||||
{ |
|
||||||
if(!mClearingFields){ |
|
||||||
mpDataMgr->setComments(mpComments->document()->toPlainText()); |
|
||||||
emit valueChanged(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void UBTBPageEditWidget::onActionButton() |
|
||||||
{ |
|
||||||
UBTeacherStudentAction* pAction = new UBTeacherStudentAction(this); |
|
||||||
mActions << pAction; |
|
||||||
mpActions->addWidget(pAction); |
|
||||||
connectActions(pAction); |
|
||||||
emit valueChanged(); |
|
||||||
} |
|
||||||
|
|
||||||
void UBTBPageEditWidget::onLinkButton() |
|
||||||
{ |
|
||||||
UBUrlWidget* pUrl = new UBUrlWidget(this); |
|
||||||
mUrls << pUrl; |
|
||||||
mpLinks->addWidget(pUrl); |
|
||||||
connectActions(pUrl); |
|
||||||
emit valueChanged(); |
|
||||||
} |
|
||||||
|
|
||||||
void UBTBPageEditWidget::onMediaDropped(const QString &url) |
|
||||||
{ |
|
||||||
if("" != url){ |
|
||||||
QWidget* pMedia = mpMediaContainer->generateMediaWidget(url); |
|
||||||
if(NULL != pMedia){ |
|
||||||
mMedias << pMedia; |
|
||||||
mMediaUrls << url; |
|
||||||
//mpDataMgr->medias()->append(pMedia);
|
|
||||||
//mpDataMgr->addMediaUrl(url);
|
|
||||||
mpMediaContainer->addWidget(pMedia); |
|
||||||
connectActions(pMedia); |
|
||||||
emit valueChanged(); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void UBTBPageEditWidget::connectActions(QWidget* w) |
|
||||||
{ |
|
||||||
UBActionableWidget* pActionable = dynamic_cast<UBActionableWidget*>(w); |
|
||||||
if(NULL != pActionable){ |
|
||||||
connect(pActionable, SIGNAL(close(QWidget*)), this, SLOT(onCloseWidget(QWidget*))); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void UBTBPageEditWidget::onDocumentEditClicked() |
|
||||||
{ |
|
||||||
emit changeTBState(eTeacherBarState_DocumentEdit); |
|
||||||
} |
|
||||||
|
|
||||||
void UBTBPageEditWidget::onPagePreviewClicked() |
|
||||||
{ |
|
||||||
emit changeTBState(eTeacherBarState_PagePreview); |
|
||||||
} |
|
||||||
|
|
||||||
void UBTBPageEditWidget::saveFields() |
|
||||||
{ |
|
||||||
mpDataMgr->actions()->clear(); |
|
||||||
mpDataMgr->urls()->clear(); |
|
||||||
mpDataMgr->mediaUrls()->clear(); |
|
||||||
mpDataMgr->medias()->clear(); |
|
||||||
|
|
||||||
foreach(UBTeacherStudentAction* pAct, mActions){ |
|
||||||
sAction action; |
|
||||||
action.type = pAct->comboValue().toInt(); |
|
||||||
action.content = pAct->text(); |
|
||||||
mpDataMgr->actions()->append(action); |
|
||||||
} |
|
||||||
foreach(UBUrlWidget* pUrl, mUrls){ |
|
||||||
sLink link; |
|
||||||
link.title = pUrl->title(); |
|
||||||
link.link = pUrl->url(); |
|
||||||
mpDataMgr->urls()->append(link); |
|
||||||
} |
|
||||||
foreach(QString url, mMediaUrls){ |
|
||||||
qDebug() << "saving media :" << url; |
|
||||||
mpDataMgr->mediaUrls()->append(url); |
|
||||||
} |
|
||||||
foreach(QWidget* pMedia, mMedias){ |
|
||||||
mpDataMgr->medias()->append(pMedia); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void UBTBPageEditWidget::updateFields() |
|
||||||
{ |
|
||||||
// Title
|
|
||||||
mpTitle->setText(mpDataMgr->pageTitle()); |
|
||||||
// Actions
|
|
||||||
foreach(sAction action, *mpDataMgr->actions()){ |
|
||||||
UBTeacherStudentAction* pAction = new UBTeacherStudentAction(this); |
|
||||||
pAction->setComboValue(action.type); |
|
||||||
pAction->setText(action.content); |
|
||||||
mActions << pAction; |
|
||||||
mpActions->addWidget(pAction); |
|
||||||
connectActions(pAction); |
|
||||||
} |
|
||||||
// Medias
|
|
||||||
foreach(QString url, *mpDataMgr->mediaUrls()){ |
|
||||||
if(!url.isEmpty()){ |
|
||||||
mMediaUrls << url; |
|
||||||
QWidget* pWidget = mpMediaContainer->generateMediaWidget(url); |
|
||||||
if(pWidget != NULL){ |
|
||||||
mMedias << pWidget; |
|
||||||
mpMediaContainer->addWidget(pWidget); |
|
||||||
connectActions(pWidget); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
// Links
|
|
||||||
foreach(sLink link, *mpDataMgr->urls()){ |
|
||||||
UBUrlWidget* urlWidget = new UBUrlWidget(this); |
|
||||||
urlWidget->setTitle(link.title); |
|
||||||
urlWidget->setUrl(link.link); |
|
||||||
mUrls << urlWidget; |
|
||||||
mpLinks->addWidget(urlWidget); |
|
||||||
connectActions(urlWidget); |
|
||||||
} |
|
||||||
// Comments
|
|
||||||
mpComments->document()->setPlainText(mpDataMgr->comments()); |
|
||||||
} |
|
||||||
|
|
||||||
void UBTBPageEditWidget::clearFields() |
|
||||||
{ |
|
||||||
mClearingFields = true; |
|
||||||
// Title
|
|
||||||
mpTitle->setText(""); |
|
||||||
// Actions
|
|
||||||
foreach(UBTeacherStudentAction* pAction, mActions){ |
|
||||||
mpActions->removeWidget(pAction); |
|
||||||
DELETEPTR(pAction); |
|
||||||
} |
|
||||||
mActions.clear(); |
|
||||||
// Medias
|
|
||||||
foreach(QWidget* pMedia, mMedias){ |
|
||||||
if(NULL != pMedia){ |
|
||||||
mpMediaContainer->removeWidget(pMedia); |
|
||||||
DELETEPTR(pMedia); |
|
||||||
} |
|
||||||
} |
|
||||||
mMedias.clear(); |
|
||||||
mMediaUrls.clear(); |
|
||||||
// Links
|
|
||||||
foreach(UBUrlWidget* pLink, mUrls){ |
|
||||||
mpLinks->removeWidget(pLink); |
|
||||||
DELETEPTR(pLink); |
|
||||||
} |
|
||||||
mUrls.clear(); |
|
||||||
// Comments
|
|
||||||
mpComments->setText(""); |
|
||||||
|
|
||||||
mClearingFields = false; |
|
||||||
} |
|
||||||
|
|
||||||
void UBTBPageEditWidget::onCloseWidget(QWidget *w) |
|
||||||
{ |
|
||||||
if(NULL != w){ |
|
||||||
if("UBTeacherStudentAction" == w->objectName()){ |
|
||||||
UBTeacherStudentAction* pW = dynamic_cast<UBTeacherStudentAction*>(w); |
|
||||||
mpActions->removeWidget(pW); |
|
||||||
mActions.remove(mActions.indexOf(pW)); |
|
||||||
DELETEPTR(w); |
|
||||||
}else if("UBUrlWidget" == w->objectName()){ |
|
||||||
UBUrlWidget* pW = dynamic_cast<UBUrlWidget*>(w); |
|
||||||
mpLinks->removeWidget(pW); |
|
||||||
mUrls.remove(mUrls.indexOf(pW)); |
|
||||||
DELETEPTR(w); |
|
||||||
}else if("UBTBMediaPicture" == w->objectName()){ |
|
||||||
UBPictureWidget* pW = dynamic_cast<UBPictureWidget*>(w); |
|
||||||
mMediaUrls.removeOne(pW->url()); |
|
||||||
mpMediaContainer->removeWidget(w); |
|
||||||
mMedias.remove(mMedias.indexOf(w)); |
|
||||||
DELETEPTR(w); |
|
||||||
}else if("UBMediaWidget" == w->objectName()){ |
|
||||||
UBMediaWidget* pW = dynamic_cast<UBMediaWidget*>(w); |
|
||||||
mMediaUrls.removeOne(pW->url()); |
|
||||||
mpMediaContainer->removeWidget(w); |
|
||||||
mMedias.remove(mMedias.indexOf(w)); |
|
||||||
DELETEPTR(w); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------------------
|
|
||||||
UBUrlWidget::UBUrlWidget(QWidget *parent, const char *name):UBActionableWidget(parent, name) |
|
||||||
, mpLayout(NULL) |
|
||||||
, mpUrlLabel(NULL) |
|
||||||
, mpUrl(NULL) |
|
||||||
{ |
|
||||||
setAttribute(Qt::WA_StyledBackground, true); |
|
||||||
setStyleSheet(UBApplication::globalStyleSheet()); |
|
||||||
addAction(eAction_Close); |
|
||||||
|
|
||||||
mpLayout = new QVBoxLayout(this); |
|
||||||
setLayout(mpLayout); |
|
||||||
|
|
||||||
mpLabelLayout = new QHBoxLayout(0); |
|
||||||
mpUrlLabel = new QLabel(tr("Url"), this); |
|
||||||
mpLabelLayout->addWidget(mpUrlLabel, 0); |
|
||||||
mpUrl = new QLineEdit(this); |
|
||||||
mpUrl->setObjectName("DockPaletteWidgetLineEdit"); |
|
||||||
mpUrl->setMinimumHeight(20); |
|
||||||
mpLabelLayout->addWidget(mpUrl, 1); |
|
||||||
|
|
||||||
mpTitleLayout = new QHBoxLayout(0); |
|
||||||
mpTitleLabel = new QLabel(tr("Title"),this); |
|
||||||
mpTitleLayout->addWidget(mpTitleLabel,0); |
|
||||||
mpTitle = new QLineEdit(this); |
|
||||||
mpTitle->setObjectName("DockPaletteWidgetLineEdit"); |
|
||||||
mpTitle->setMinimumHeight(20); |
|
||||||
mpTitleLayout->addWidget(mpTitle,1); |
|
||||||
|
|
||||||
mpLayout->addLayout(mpTitleLayout); |
|
||||||
mpLayout->addLayout(mpLabelLayout); |
|
||||||
setActionsParent(this); |
|
||||||
} |
|
||||||
|
|
||||||
UBUrlWidget::~UBUrlWidget() |
|
||||||
{ |
|
||||||
unsetActionsParent(); |
|
||||||
DELETEPTR(mpTitle); |
|
||||||
DELETEPTR(mpTitleLabel); |
|
||||||
DELETEPTR(mpUrlLabel); |
|
||||||
DELETEPTR(mpUrl); |
|
||||||
DELETEPTR(mpTitleLayout); |
|
||||||
DELETEPTR(mpLabelLayout); |
|
||||||
DELETEPTR(mpLayout); |
|
||||||
} |
|
||||||
|
|
||||||
QString UBUrlWidget::url() |
|
||||||
{ |
|
||||||
QString str; |
|
||||||
|
|
||||||
if(NULL != mpUrl){ |
|
||||||
str = mpUrl->text();// + ";" + mpTitle->text();
|
|
||||||
} |
|
||||||
|
|
||||||
return str; |
|
||||||
} |
|
||||||
|
|
||||||
void UBUrlWidget::setUrl(const QString &url) |
|
||||||
{ |
|
||||||
if(NULL != mpUrl){ |
|
||||||
mpUrl->setText(url); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------------------------------------------
|
|
||||||
UBTBMediaContainer::UBTBMediaContainer(QWidget *parent, const char *name) : UBWidgetList(parent) |
|
||||||
{ |
|
||||||
setObjectName(name); |
|
||||||
setAcceptDrops(true); |
|
||||||
} |
|
||||||
|
|
||||||
UBTBMediaContainer::~UBTBMediaContainer() |
|
||||||
{ |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
void UBTBMediaContainer::dropEvent(QDropEvent* pEvent) |
|
||||||
{ |
|
||||||
QPixmap pixFromDropEvent; |
|
||||||
QString mimeType; |
|
||||||
QString resourcePath; |
|
||||||
if(pEvent->mimeData()->hasText()){ |
|
||||||
resourcePath = pEvent->mimeData()->text(); |
|
||||||
} |
|
||||||
else if(pEvent->mimeData()->hasUrls()){ |
|
||||||
resourcePath = pEvent->mimeData()->urls().at(0).toLocalFile(); |
|
||||||
} |
|
||||||
else if(pEvent->mimeData()->hasImage()){ |
|
||||||
pixFromDropEvent.loadFromData(pEvent->mimeData()->imageData().toByteArray()); |
|
||||||
if(!pixFromDropEvent.isNull()) |
|
||||||
mimeType = "image"; |
|
||||||
} |
|
||||||
|
|
||||||
if (mimeType.isEmpty() && resourcePath.isEmpty()){ |
|
||||||
pEvent->acceptProposedAction(); |
|
||||||
return; |
|
||||||
} |
|
||||||
if(!resourcePath.isEmpty()){ |
|
||||||
emit mediaDropped(resourcePath); |
|
||||||
pEvent->acceptProposedAction(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void UBTBMediaContainer::dragEnterEvent(QDragEnterEvent* pEvent) |
|
||||||
{ |
|
||||||
pEvent->acceptProposedAction(); |
|
||||||
} |
|
||||||
|
|
||||||
void UBTBMediaContainer::dragMoveEvent(QDragMoveEvent* pEvent) |
|
||||||
{ |
|
||||||
pEvent->acceptProposedAction(); |
|
||||||
} |
|
||||||
|
|
||||||
void UBTBMediaContainer::dragLeaveEvent(QDragLeaveEvent* pEvent) |
|
||||||
{ |
|
||||||
pEvent->accept(); |
|
||||||
} |
|
||||||
|
|
||||||
void UBTBMediaContainer::addMedia(const QString& mediaPath) |
|
||||||
{ |
|
||||||
if(!mediaPath.isEmpty()) |
|
||||||
mMediaList.append(mediaPath); |
|
||||||
else |
|
||||||
qWarning() << __FUNCTION__ << "empty path"; |
|
||||||
|
|
||||||
QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(mediaPath); |
|
||||||
if(mimeType.contains("image")){ |
|
||||||
QPixmap pix = QPixmap(mediaPath); |
|
||||||
QLabel* label = new QLabel(); |
|
||||||
label->setPixmap(pix); |
|
||||||
label->setScaledContents(true); |
|
||||||
addWidget(label); |
|
||||||
} |
|
||||||
else if(mimeType.contains("video") || mimeType.contains("audio")){ |
|
||||||
UBMediaPlayer* mediaPlayer = new UBMediaPlayer(); |
|
||||||
mediaPlayer->setFile(mediaPath); |
|
||||||
addWidget(mediaPlayer); |
|
||||||
} |
|
||||||
else{ |
|
||||||
qWarning() << "pMediaPath" << mediaPath; |
|
||||||
qWarning() << "bad idea to come here"; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
QStringList UBTBMediaContainer::mediaUrls() |
|
||||||
{ |
|
||||||
return mMediaList; |
|
||||||
} |
|
||||||
|
|
||||||
void UBTBMediaContainer::cleanMedias() |
|
||||||
{ |
|
||||||
mMediaList.clear(); |
|
||||||
} |
|
||||||
|
|
||||||
QWidget* UBTBMediaContainer::generateMediaWidget(const QString& url) |
|
||||||
{ |
|
||||||
QWidget* pW = NULL; |
|
||||||
|
|
||||||
if(!url.isEmpty()) |
|
||||||
mMediaList.append(url); |
|
||||||
else |
|
||||||
qWarning() << __FUNCTION__ << "empty path"; |
|
||||||
|
|
||||||
QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(url); |
|
||||||
if(mimeType.contains("image")){ |
|
||||||
QPixmap pix = QPixmap(url); |
|
||||||
UBPictureWidget* pic = new UBPictureWidget(); |
|
||||||
pic->setUrl(url); |
|
||||||
pix.scaledToWidth(pic->label()->width()); |
|
||||||
pic->label()->resize(pix.width(), pix.height()); |
|
||||||
pic->label()->setPixmap(pix); |
|
||||||
pic->label()->setScaledContents(true); |
|
||||||
pic->setObjectName("UBTBMediaPicture"); |
|
||||||
pW = pic; |
|
||||||
} |
|
||||||
else if(mimeType.contains("video") || mimeType.contains("audio")){ |
|
||||||
UBMediaWidget* mediaPlayer = new UBMediaWidget(mimeType.contains("audio")?eMediaType_Audio:eMediaType_Video); |
|
||||||
mediaPlayer->setFile(url); |
|
||||||
mediaPlayer->setUrl(url); |
|
||||||
pW = mediaPlayer; |
|
||||||
} |
|
||||||
else{ |
|
||||||
qWarning() << "pMediaPath" << url; |
|
||||||
qWarning() << "bad idea to come here"; |
|
||||||
} |
|
||||||
|
|
||||||
return pW; |
|
||||||
} |
|
||||||
|
|
||||||
UBTeacherStudentAction::UBTeacherStudentAction(QWidget *parent, const char *name):UBActionableWidget(parent, name) |
|
||||||
, mpText(NULL) |
|
||||||
, mpLayout(NULL) |
|
||||||
, mpComboLayout(NULL) |
|
||||||
, mpCombo(NULL) |
|
||||||
{ |
|
||||||
setAttribute(Qt::WA_StyledBackground, true); |
|
||||||
setStyleSheet(UBApplication::globalStyleSheet()); |
|
||||||
addAction(eAction_Close); |
|
||||||
|
|
||||||
// Create the GUI
|
|
||||||
mpLayout = new QHBoxLayout(this); |
|
||||||
setLayout(mpLayout); |
|
||||||
|
|
||||||
mpComboLayout = new QVBoxLayout(); |
|
||||||
|
|
||||||
mpCombo = new QComboBox(this); |
|
||||||
mpCombo->setObjectName("DockPaletteWidgetComboBox"); |
|
||||||
mpCombo->setMinimumWidth(80); |
|
||||||
mpCombo->addItem(tr("Teacher")); |
|
||||||
mpCombo->addItem(tr("Student")); |
|
||||||
mpComboLayout->addWidget(mpCombo, 0); |
|
||||||
mpComboLayout->addStretch(1); |
|
||||||
|
|
||||||
mpLayout->addLayout(mpComboLayout, 0); |
|
||||||
|
|
||||||
mpText = new QTextEdit(this); |
|
||||||
mpText->setObjectName("DockPaletteWidgetBox"); |
|
||||||
mpText->setStyleSheet("background:white;"); |
|
||||||
|
|
||||||
mpLayout->addWidget(mpText, 1); |
|
||||||
setActionsParent(this); |
|
||||||
} |
|
||||||
|
|
||||||
UBTeacherStudentAction::~UBTeacherStudentAction() |
|
||||||
{ |
|
||||||
unsetActionsParent(); |
|
||||||
DELETEPTR(mpCombo); |
|
||||||
DELETEPTR(mpText); |
|
||||||
DELETEPTR(mpComboLayout); |
|
||||||
DELETEPTR(mpLayout); |
|
||||||
} |
|
||||||
|
|
||||||
QString UBTeacherStudentAction::text() |
|
||||||
{ |
|
||||||
QString str; |
|
||||||
if(NULL != mpText){ |
|
||||||
str = mpText->document()->toPlainText(); |
|
||||||
} |
|
||||||
return str; |
|
||||||
} |
|
||||||
|
|
||||||
QString UBTeacherStudentAction::comboValue() |
|
||||||
{ |
|
||||||
QString str; |
|
||||||
|
|
||||||
if(NULL != mpCombo){ |
|
||||||
str = QString("%0").arg(mpCombo->currentIndex()); |
|
||||||
} |
|
||||||
|
|
||||||
return str; |
|
||||||
} |
|
||||||
|
|
||||||
void UBTeacherStudentAction::setComboValue(int value) |
|
||||||
{ |
|
||||||
if(NULL != mpCombo){ |
|
||||||
mpCombo->setCurrentIndex(value); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void UBTeacherStudentAction::setText(const QString& text) |
|
||||||
{ |
|
||||||
if(NULL != mpText){ |
|
||||||
mpText->document()->setPlainText(text); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
// -------------------------------------------------------------
|
|
||||||
UBPictureWidget::UBPictureWidget(QWidget *parent, const char *name):UBActionableWidget(parent, name) |
|
||||||
, mpLayout(NULL) |
|
||||||
, mpLabel(NULL) |
|
||||||
{ |
|
||||||
addAction(eAction_Close); |
|
||||||
mpLayout = new QVBoxLayout(this); |
|
||||||
setLayout(mpLayout); |
|
||||||
mpLayout->setContentsMargins(10, 0, 10, 0); |
|
||||||
mpLabel = new QLabel(this); |
|
||||||
mpLayout->addWidget(mpLabel); |
|
||||||
mpLabel->setGeometry( 10, 10, width()-2*10, height()); |
|
||||||
setActionsParent(mpLabel); |
|
||||||
} |
|
||||||
|
|
||||||
UBPictureWidget::~UBPictureWidget() |
|
||||||
{ |
|
||||||
unsetActionsParent(); |
|
||||||
DELETEPTR(mpLabel); |
|
||||||
DELETEPTR(mpLayout); |
|
||||||
} |
|
||||||
|
|
||||||
void UBPictureWidget::resizeEvent(QResizeEvent *ev) |
|
||||||
{ |
|
||||||
Q_UNUSED(ev); |
|
||||||
mpLabel->setGeometry( 10, 10, width()-2*10, height()); |
|
||||||
} |
|
@ -1,163 +0,0 @@ |
|||||||
#ifndef UBTBPAGEEDITWIDGET_H |
|
||||||
#define UBTBPAGEEDITWIDGET_H |
|
||||||
|
|
||||||
#include <QString> |
|
||||||
#include <QTextEdit> |
|
||||||
#include <QHBoxLayout> |
|
||||||
#include <QVBoxLayout> |
|
||||||
#include <QComboBox> |
|
||||||
#include <QLabel> |
|
||||||
#include <QPushButton> |
|
||||||
|
|
||||||
#include "core/UBPersistenceManager.h" |
|
||||||
#include "customWidgets/UBWidgetList.h" |
|
||||||
#include "customWidgets/UBActionableWidget.h" |
|
||||||
#include "interfaces/IDropable.h" |
|
||||||
#include "UBTeacherBarDataMgr.h" |
|
||||||
|
|
||||||
class UBTeacherStudentAction : public UBActionableWidget |
|
||||||
{ |
|
||||||
Q_OBJECT |
|
||||||
|
|
||||||
public: |
|
||||||
UBTeacherStudentAction(QWidget* parent=0, const char* name="UBTeacherStudentAction"); |
|
||||||
~UBTeacherStudentAction(); |
|
||||||
QString text(); |
|
||||||
QString comboValue(); |
|
||||||
void setComboValue(int value); |
|
||||||
void setText(const QString& text); |
|
||||||
|
|
||||||
private: |
|
||||||
QTextEdit* mpText; |
|
||||||
QHBoxLayout* mpLayout; |
|
||||||
QVBoxLayout* mpComboLayout; |
|
||||||
QComboBox* mpCombo; |
|
||||||
}; |
|
||||||
|
|
||||||
class UBUrlWidget : public UBActionableWidget |
|
||||||
{ |
|
||||||
public: |
|
||||||
UBUrlWidget(QWidget* parent=0, const char* name="UBUrlWidget"); |
|
||||||
~UBUrlWidget(); |
|
||||||
|
|
||||||
QString url(); |
|
||||||
void setUrl(const QString& url); |
|
||||||
|
|
||||||
QString title(){return mpTitle->text();} |
|
||||||
void setTitle(const QString& title){mpTitle->setText(title);} |
|
||||||
|
|
||||||
private: |
|
||||||
QVBoxLayout* mpLayout; |
|
||||||
QHBoxLayout* mpLabelLayout; |
|
||||||
QHBoxLayout* mpTitleLayout; |
|
||||||
QLabel* mpUrlLabel; |
|
||||||
QLineEdit* mpUrl; |
|
||||||
|
|
||||||
QLabel* mpTitleLabel; |
|
||||||
QLineEdit* mpTitle; |
|
||||||
}; |
|
||||||
|
|
||||||
class UBPictureWidget : public UBActionableWidget |
|
||||||
{ |
|
||||||
public: |
|
||||||
UBPictureWidget(QWidget* parent=0, const char* name="UBPictureWidget"); |
|
||||||
~UBPictureWidget(); |
|
||||||
|
|
||||||
QLabel* label(){return mpLabel;} |
|
||||||
void setUrl(const QString& url){mUrl = url;} |
|
||||||
QString url(){return mUrl;} |
|
||||||
|
|
||||||
protected: |
|
||||||
void resizeEvent(QResizeEvent* ev); |
|
||||||
|
|
||||||
private: |
|
||||||
QVBoxLayout* mpLayout; |
|
||||||
QLabel* mpLabel; |
|
||||||
QString mUrl; |
|
||||||
}; |
|
||||||
|
|
||||||
class UBTBMediaContainer : public UBWidgetList |
|
||||||
, public IDropable |
|
||||||
{ |
|
||||||
Q_OBJECT |
|
||||||
public: |
|
||||||
UBTBMediaContainer(QWidget* parent=0, const char* name="UBTBMediaContainer"); |
|
||||||
~UBTBMediaContainer(); |
|
||||||
QStringList mediaUrls(); |
|
||||||
QWidget* generateMediaWidget(const QString& url); |
|
||||||
void cleanMedias(); |
|
||||||
|
|
||||||
signals: |
|
||||||
void mediaDropped(const QString& url); |
|
||||||
|
|
||||||
protected: |
|
||||||
void dropEvent(QDropEvent* pEvent); |
|
||||||
void dragEnterEvent(QDragEnterEvent* pEvent); |
|
||||||
void dragMoveEvent(QDragMoveEvent* pEvent); |
|
||||||
void dragLeaveEvent(QDragLeaveEvent* pEvent); |
|
||||||
|
|
||||||
private: |
|
||||||
void addMedia(const QString& mediaPath); |
|
||||||
|
|
||||||
QStringList mMediaList; |
|
||||||
}; |
|
||||||
|
|
||||||
class UBTBPageEditWidget : public QWidget |
|
||||||
{ |
|
||||||
Q_OBJECT |
|
||||||
public: |
|
||||||
UBTBPageEditWidget(UBTeacherBarDataMgr* pDataMgr, QWidget* parent=0, const char* name="UBTBPageEditWidget"); |
|
||||||
~UBTBPageEditWidget(); |
|
||||||
void saveFields(); |
|
||||||
void updateFields(); |
|
||||||
void clearFields(); |
|
||||||
|
|
||||||
signals: |
|
||||||
void valueChanged(); |
|
||||||
void changeTBState(eTeacherBarState state); |
|
||||||
|
|
||||||
private slots: |
|
||||||
void onTitleChanged(); |
|
||||||
void onCommentsChanged(); |
|
||||||
void onActionButton(); |
|
||||||
void onLinkButton(); |
|
||||||
void onMediaDropped(const QString& url); |
|
||||||
void onDocumentEditClicked(); |
|
||||||
void onPagePreviewClicked(); |
|
||||||
void onCloseWidget(QWidget* w); |
|
||||||
|
|
||||||
private: |
|
||||||
void connectActions(QWidget* w); |
|
||||||
QVBoxLayout mLayout; |
|
||||||
QHBoxLayout mTitleLayout; |
|
||||||
QVBoxLayout mContainerLayout; |
|
||||||
QHBoxLayout mActionLayout; |
|
||||||
QHBoxLayout mLinkLayout; |
|
||||||
QHBoxLayout mDocumentViewLayout; |
|
||||||
QHBoxLayout mPagePreviewLayout; |
|
||||||
|
|
||||||
UBTeacherBarDataMgr* mpDataMgr; |
|
||||||
QLabel* mpTitleLabel; |
|
||||||
QLineEdit* mpTitle; |
|
||||||
QLabel* mpMediaLabel; |
|
||||||
UBTBMediaContainer* mpMediaContainer; |
|
||||||
QLabel* mpActionLabel; |
|
||||||
UBWidgetList* mpActions; |
|
||||||
QPushButton* mpActionButton; |
|
||||||
QLabel* mpLinkLabel; |
|
||||||
UBWidgetList* mpLinks; |
|
||||||
QPushButton* mpLinkButton; |
|
||||||
QLabel* mpCommentLabel; |
|
||||||
QTextEdit* mpComments; |
|
||||||
QPushButton* mpDocumentEditbutton; |
|
||||||
QPushButton* mpPagePreviewButton; |
|
||||||
QWidget* mpContainer; |
|
||||||
|
|
||||||
QVector<UBTeacherStudentAction*> mActions; |
|
||||||
QVector<UBUrlWidget*> mUrls; |
|
||||||
QVector<QWidget*> mMedias; |
|
||||||
QStringList mMediaUrls; |
|
||||||
bool mClearingFields; |
|
||||||
}; |
|
||||||
|
|
||||||
#endif // UBTBPAGEEDITWIDGET_H
|
|
@ -1,194 +0,0 @@ |
|||||||
#include <QDate> |
|
||||||
|
|
||||||
#include "UBTeacherBarDataMgr.h" |
|
||||||
|
|
||||||
#include "core/UBApplication.h" |
|
||||||
#include "core/UBPersistenceManager.h" |
|
||||||
|
|
||||||
#include "board/UBBoardController.h" |
|
||||||
|
|
||||||
#include "globals/UBGlobals.h" |
|
||||||
|
|
||||||
#include "adaptors/UBMetadataDcSubsetAdaptor.h" |
|
||||||
|
|
||||||
|
|
||||||
UBTeacherBarDataMgr::UBTeacherBarDataMgr() |
|
||||||
{ |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
UBTeacherBarDataMgr::~UBTeacherBarDataMgr() |
|
||||||
{ |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
void UBTeacherBarDataMgr::clearLists() |
|
||||||
{ |
|
||||||
mActionList.clear(); |
|
||||||
mUrlList.clear(); |
|
||||||
mMediaList.clear(); |
|
||||||
mMediaUrls.clear(); |
|
||||||
} |
|
||||||
|
|
||||||
void UBTeacherBarDataMgr::saveContent() |
|
||||||
{ |
|
||||||
// Store the page information in the UBZ
|
|
||||||
sTeacherBarInfos infos; |
|
||||||
|
|
||||||
// Page Title
|
|
||||||
infos.title = mPageTitle; |
|
||||||
// Actions
|
|
||||||
foreach(sAction action, mActionList){ |
|
||||||
infos.actions << QString("%0;%1").arg(action.type).arg(action.content); |
|
||||||
} |
|
||||||
// Media
|
|
||||||
foreach(QString media, mMediaUrls){ |
|
||||||
infos.medias << media; |
|
||||||
} |
|
||||||
// Links
|
|
||||||
foreach(sLink link, mUrlList){ |
|
||||||
if("" != link.title && "" != link.link){ |
|
||||||
infos.urls << QString("%0;%1").arg(link.title).arg(link.link); |
|
||||||
} |
|
||||||
} |
|
||||||
// Comments
|
|
||||||
infos.comments = mComments; |
|
||||||
|
|
||||||
UBDocumentProxy* documentProxy = UBApplication::boardController->activeDocument(); |
|
||||||
if(documentProxy){ |
|
||||||
UBPersistenceManager::persistenceManager()->persistTeacherBar(documentProxy, UBApplication::boardController->activeSceneIndex(), infos); |
|
||||||
|
|
||||||
documentProxy->setSessionTitle(mSessionTitle); |
|
||||||
documentProxy->setSessionTarget(mSessionTarget); |
|
||||||
documentProxy->setSessionLicence(QString("%0").arg(mSessionLicence)); |
|
||||||
documentProxy->setSessionKeywords(mKeywords); |
|
||||||
documentProxy->setSessionLevel(mLevel); |
|
||||||
documentProxy->setSessionTopic(mTopic); |
|
||||||
documentProxy->setSessionAuthor(mAuthors); |
|
||||||
|
|
||||||
UBMetadataDcSubsetAdaptor::persist(documentProxy); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void UBTeacherBarDataMgr::loadContent(bool docChanged) |
|
||||||
{ |
|
||||||
Q_UNUSED(docChanged); |
|
||||||
clearLists(); |
|
||||||
UBDocumentProxy* documentProxy = UBApplication::boardController->activeDocument(); |
|
||||||
|
|
||||||
sTeacherBarInfos nextInfos = UBPersistenceManager::persistenceManager()->getTeacherBarInfos(documentProxy, UBApplication::boardController->activeSceneIndex()); |
|
||||||
if(true/*docChanged*/){ |
|
||||||
mSessionTitle = documentProxy->sessionTitle(); |
|
||||||
mSessionTarget = documentProxy->sessionTarget(); |
|
||||||
mSessionLicence = (eLicense)documentProxy->sessionLicence().toInt(); |
|
||||||
mKeywords = documentProxy->sessionKeywords(); |
|
||||||
mLevel = documentProxy->sessionLevel(); |
|
||||||
mTopic = documentProxy->sessionTopic(); |
|
||||||
mAuthors = documentProxy->sessionAuthors(); |
|
||||||
if("" != documentProxy->documentDate()){ |
|
||||||
mCreationDate = documentProxy->documentDate(); |
|
||||||
}else{ |
|
||||||
mCreationDate = QDate::currentDate().toString("yyyy-MM-dd"); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
// Page Title
|
|
||||||
mPageTitle = nextInfos.title; |
|
||||||
// Actions
|
|
||||||
foreach(QString eachAction, nextInfos.actions){ |
|
||||||
QStringList qslAction = eachAction.split(";"); |
|
||||||
if(2 <= qslAction.size()){ |
|
||||||
sAction action; |
|
||||||
action.type = qslAction.at(0).toInt(); |
|
||||||
action.content = qslAction.at(1); |
|
||||||
mActionList << action; |
|
||||||
} |
|
||||||
} |
|
||||||
// Media URL
|
|
||||||
if((nextInfos.medias.size() == 1) && (nextInfos.medias.at(0) == "")){ |
|
||||||
// Do not retrieve it
|
|
||||||
} |
|
||||||
else{ |
|
||||||
mMediaUrls = nextInfos.medias; |
|
||||||
} |
|
||||||
|
|
||||||
// Links
|
|
||||||
foreach(QString eachUrl, nextInfos.urls){ |
|
||||||
QStringList qslUrl = eachUrl.split(';'); |
|
||||||
if(2 <= qslUrl.size()){ |
|
||||||
sLink link; |
|
||||||
link.title = qslUrl.at(0); |
|
||||||
link.link = qslUrl.at(1); |
|
||||||
mUrlList << link; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
// Comments
|
|
||||||
mComments = nextInfos.comments; |
|
||||||
} |
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------
|
|
||||||
UBTBSeparator::UBTBSeparator(QWidget *parent, const char *name):QFrame(parent) |
|
||||||
{ |
|
||||||
Q_UNUSED(name); |
|
||||||
setObjectName("UBTBSeparator"); |
|
||||||
setMinimumHeight(5); |
|
||||||
setMaximumHeight(5); |
|
||||||
} |
|
||||||
|
|
||||||
UBTBSeparator::~UBTBSeparator() |
|
||||||
{ |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------
|
|
||||||
UBTBLicenseWidget::UBTBLicenseWidget(QWidget *parent, const char *name):QWidget(parent) |
|
||||||
{ |
|
||||||
setObjectName(name); |
|
||||||
setLayout(&mLayout); |
|
||||||
|
|
||||||
mpIcon = new QLabel(this); |
|
||||||
mpText = new QLabel(this); |
|
||||||
mpText->setWordWrap(true); |
|
||||||
mLayout.addWidget(mpIcon); |
|
||||||
mLayout.addWidget(mpText); |
|
||||||
} |
|
||||||
|
|
||||||
UBTBLicenseWidget::~UBTBLicenseWidget() |
|
||||||
{ |
|
||||||
DELETEPTR(mpIcon); |
|
||||||
DELETEPTR(mpText); |
|
||||||
} |
|
||||||
|
|
||||||
void UBTBLicenseWidget::setLicense(eLicense lic) |
|
||||||
{ |
|
||||||
switch(lic){ |
|
||||||
case eLicense_CCBY: |
|
||||||
mpIcon->setPixmap(QPixmap(":images/licenses/ccby.png")); |
|
||||||
mpText->setText(tr("Creative Common License %0").arg("CC BY")); |
|
||||||
break; |
|
||||||
case eLicense_CCBYND: |
|
||||||
mpIcon->setPixmap(QPixmap(":images/licenses/ccbynd.png")); |
|
||||||
mpText->setText(tr("Creative Common License %0").arg("CC BY-ND")); |
|
||||||
break; |
|
||||||
case eLicense_CCBYNCSA: |
|
||||||
mpIcon->setPixmap(QPixmap(":images/licenses/ccbyncsa.png")); |
|
||||||
mpText->setText(tr("Creative Common License %0").arg("CC BY-NC-SA")); |
|
||||||
break; |
|
||||||
case eLicense_CCBYSA: |
|
||||||
mpIcon->setPixmap(QPixmap(":images/licenses/ccbysa.png")); |
|
||||||
mpText->setText(tr("Creative Common License %0").arg("CC BY-SA")); |
|
||||||
break; |
|
||||||
case eLicense_CCBYNC: |
|
||||||
mpIcon->setPixmap(QPixmap(":images/licenses/ccbync.png")); |
|
||||||
mpText->setText(tr("Creative Common License %0").arg("CC BY-NC")); |
|
||||||
break; |
|
||||||
case eLicense_CCBYNCND: |
|
||||||
mpIcon->setPixmap(QPixmap(":images/licenses/ccbyncnd.png")); |
|
||||||
mpText->setText(tr("Creative Common License %0").arg("CC BY-NC-ND")); |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
@ -1,150 +0,0 @@ |
|||||||
#ifndef UBTEACHERBARDATAMGR_H |
|
||||||
#define UBTEACHERBARDATAMGR_H |
|
||||||
|
|
||||||
#include <QString> |
|
||||||
#include <QWidget> |
|
||||||
#include <QTextEdit> |
|
||||||
#include <QLineEdit> |
|
||||||
#include <QLabel> |
|
||||||
#include <QHBoxLayout> |
|
||||||
#include <QVBoxLayout> |
|
||||||
#include <QComboBox> |
|
||||||
#include <QFrame> |
|
||||||
|
|
||||||
typedef enum{ |
|
||||||
eTeacherBarState_DocumentEdit, |
|
||||||
eTeacherBarState_DocumentPreview, |
|
||||||
eTeacherBarState_PageEdit, |
|
||||||
eTeacherBarState_PagePreview |
|
||||||
}eTeacherBarState; |
|
||||||
|
|
||||||
typedef enum{ |
|
||||||
eActionOwner_Teacher, |
|
||||||
eActionOwner_Student |
|
||||||
}eActionOwner; |
|
||||||
|
|
||||||
typedef struct{ |
|
||||||
int type; |
|
||||||
QString content; |
|
||||||
}sAction; |
|
||||||
|
|
||||||
typedef struct{ |
|
||||||
QString title; |
|
||||||
QString link; |
|
||||||
}sLink; |
|
||||||
|
|
||||||
typedef enum{ |
|
||||||
eLicense_CCBY, |
|
||||||
eLicense_CCBYND, |
|
||||||
eLicense_CCBYNCSA, |
|
||||||
eLicense_CCBYSA, |
|
||||||
eLicense_CCBYNC, |
|
||||||
eLicense_CCBYNCND |
|
||||||
}eLicense; |
|
||||||
|
|
||||||
class UBTBSeparator : public QFrame |
|
||||||
{ |
|
||||||
public: |
|
||||||
UBTBSeparator(QWidget* parent=0, const char* name="UBTBSeparator"); |
|
||||||
~UBTBSeparator(); |
|
||||||
}; |
|
||||||
|
|
||||||
class UBTBLicenseWidget : public QWidget |
|
||||||
{ |
|
||||||
public: |
|
||||||
UBTBLicenseWidget(QWidget* parent=0, const char* name="UBTBLicenseWidget"); |
|
||||||
~UBTBLicenseWidget(); |
|
||||||
void setLicense(eLicense lic); |
|
||||||
|
|
||||||
private: |
|
||||||
QHBoxLayout mLayout; |
|
||||||
QLabel* mpIcon; |
|
||||||
QLabel* mpText; |
|
||||||
}; |
|
||||||
|
|
||||||
class UBTeacherBarDataMgr |
|
||||||
{ |
|
||||||
public: |
|
||||||
UBTeacherBarDataMgr(); |
|
||||||
~UBTeacherBarDataMgr(); |
|
||||||
|
|
||||||
// Session Title
|
|
||||||
void setSessionTitle(const QString& title){mSessionTitle = title;} |
|
||||||
QString sessionTitle(){return mSessionTitle;} |
|
||||||
|
|
||||||
// Session Target
|
|
||||||
void setSessionTarget(const QString& target){mSessionTarget = target;} |
|
||||||
QString sessionTarget(){return mSessionTarget;} |
|
||||||
|
|
||||||
// Licence
|
|
||||||
void setSessionLicence(eLicense licence){mSessionLicence = licence;} |
|
||||||
eLicense sessionLicence(){return mSessionLicence;} |
|
||||||
|
|
||||||
// Page Title
|
|
||||||
void setPageTitle(const QString& title){mPageTitle = title;} |
|
||||||
QString pageTitle(){return mPageTitle;} |
|
||||||
|
|
||||||
// Actions
|
|
||||||
QVector<sAction>* actions(){return &mActionList;} |
|
||||||
|
|
||||||
// Medias
|
|
||||||
QVector<QWidget*>* medias(){return &mMediaList;} |
|
||||||
void addMediaUrl(const QString& url){mMediaUrls << url;} |
|
||||||
QStringList* mediaUrls(){return &mMediaUrls;} |
|
||||||
|
|
||||||
// Urls
|
|
||||||
QVector<sLink>* urls(){return &mUrlList;} |
|
||||||
|
|
||||||
// Comments
|
|
||||||
void setComments(const QString& c){mComments = c;} |
|
||||||
QString comments(){return mComments;} |
|
||||||
|
|
||||||
// Keywords
|
|
||||||
void setKeywords(const QString& kw){mKeywords = kw;} |
|
||||||
QString keywords(){return mKeywords;} |
|
||||||
|
|
||||||
// Level
|
|
||||||
void setLevel(const QString& level){mLevel = level;} |
|
||||||
QString level(){return mLevel;} |
|
||||||
|
|
||||||
// Topic
|
|
||||||
void setTopic(const QString& topic){mTopic = topic;} |
|
||||||
QString topic(){return mTopic;} |
|
||||||
|
|
||||||
// Authors
|
|
||||||
void setAuthors(const QString& authors){mAuthors = authors;} |
|
||||||
QString authors(){return mAuthors;} |
|
||||||
|
|
||||||
// Creation Date
|
|
||||||
void setCreationDate(const QString& date){mCreationDate = date;} |
|
||||||
QString creationDate(){return mCreationDate;} |
|
||||||
|
|
||||||
// Last Modification
|
|
||||||
void setLastModificationDate(const QString& date){mLastModif = date;} |
|
||||||
QString lastModificationDate(){return mLastModif;} |
|
||||||
|
|
||||||
// Others
|
|
||||||
void clearLists(); |
|
||||||
void saveContent(); |
|
||||||
void loadContent(bool docChanged = false); |
|
||||||
|
|
||||||
private: |
|
||||||
QString mSessionTitle; |
|
||||||
QString mSessionTarget; |
|
||||||
eLicense mSessionLicence; |
|
||||||
QString mPageTitle; |
|
||||||
QString mComments; |
|
||||||
QString mKeywords; |
|
||||||
QString mLevel; |
|
||||||
QString mTopic; |
|
||||||
QString mAuthors; |
|
||||||
QString mCreationDate; |
|
||||||
QString mLastModif; |
|
||||||
|
|
||||||
QVector<sAction> mActionList; |
|
||||||
QVector<sLink> mUrlList; |
|
||||||
QVector<QWidget*> mMediaList; |
|
||||||
QStringList mMediaUrls; |
|
||||||
}; |
|
||||||
|
|
||||||
#endif // UBTEACHERBARDATAMGR_H
|
|
@ -1,369 +0,0 @@ |
|||||||
#include "core/UBApplication.h" |
|
||||||
#include "globals/UBGlobals.h" |
|
||||||
#include "board/UBBoardController.h" |
|
||||||
#include "frameworks/UBFileSystemUtils.h" |
|
||||||
|
|
||||||
#include "UBTeacherBarPreviewWidget.h" |
|
||||||
|
|
||||||
|
|
||||||
UBTeacherBarPreviewMedia::UBTeacherBarPreviewMedia(QWidget* parent, const char* name) : QWidget(parent) |
|
||||||
{ |
|
||||||
setObjectName(name); |
|
||||||
mWidget = new UBWidgetList(parent); |
|
||||||
mLayout.addWidget(mWidget); |
|
||||||
setLayout(&mLayout); |
|
||||||
mWidgetList.clear(); |
|
||||||
} |
|
||||||
|
|
||||||
UBTeacherBarPreviewMedia::~UBTeacherBarPreviewMedia() |
|
||||||
{ |
|
||||||
DELETEPTR(mWidget); |
|
||||||
} |
|
||||||
|
|
||||||
void UBTeacherBarPreviewMedia::cleanMedia() |
|
||||||
{ |
|
||||||
foreach(QWidget* eachWidget, mWidgetList.keys()){ |
|
||||||
if(QString(eachWidget->metaObject()->className()).contains("UBDraggable")){ |
|
||||||
mWidget->removeWidget(eachWidget); |
|
||||||
delete eachWidget; |
|
||||||
eachWidget = NULL; |
|
||||||
} |
|
||||||
else{ |
|
||||||
mWidget->removeWidget(eachWidget); |
|
||||||
} |
|
||||||
} |
|
||||||
mWidgetList.clear(); |
|
||||||
} |
|
||||||
|
|
||||||
void UBTeacherBarPreviewMedia::loadWidgets(QList<QWidget*> pWidgetsList, bool isResizable) |
|
||||||
{ |
|
||||||
Q_UNUSED(isResizable); |
|
||||||
foreach(QWidget*eachWidget, pWidgetsList){ |
|
||||||
mWidget->addWidget(eachWidget); |
|
||||||
mWidgetList[eachWidget]="DRAG UNAVAILABLE"; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
//int UBTeacherBarPreviewMedia::loadMedia(QStringList pMedias)
|
|
||||||
//{
|
|
||||||
// int addedMedia = 0;
|
|
||||||
//// foreach(QString eachString, pMedias){
|
|
||||||
//// if(!eachString.isEmpty()){
|
|
||||||
//// QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(eachString);
|
|
||||||
//// if(mimeType.contains("image")){
|
|
||||||
//// UBDraggableLabel* label = new UBDraggableLabel();
|
|
||||||
//// label->loadImage(eachString);
|
|
||||||
//// mWidget->addWidget(label);
|
|
||||||
//// mWidgetList[label]=eachString;
|
|
||||||
//// addedMedia += 1;
|
|
||||||
//// }
|
|
||||||
//// else if(mimeType.contains("video") || mimeType.contains("audio")){
|
|
||||||
//// UBDraggableMediaPlayer* mediaPlayer = new UBDraggableMediaPlayer();
|
|
||||||
//// mediaPlayer->setFile(eachString);
|
|
||||||
//// mWidget->addWidget(mediaPlayer);
|
|
||||||
//// mWidgetList[mediaPlayer] = eachString;
|
|
||||||
//// addedMedia += 1;
|
|
||||||
//// }
|
|
||||||
//// else{
|
|
||||||
//// qWarning() << "pMediaPath" << eachString;
|
|
||||||
//// qWarning() << "bad idea to come here";
|
|
||||||
//// }
|
|
||||||
//// }
|
|
||||||
//// }
|
|
||||||
// return addedMedia;
|
|
||||||
//}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------------------
|
|
||||||
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 QTextEdit(this); |
|
||||||
mpContent->setReadOnly(true); |
|
||||||
mpContent->setObjectName("UBActionPreviewContent"); |
|
||||||
//mpContent->setWordWrap(true);
|
|
||||||
mLayout.addWidget(mpContent); |
|
||||||
setContentsMargins(-9, -9, -9, -9); |
|
||||||
} |
|
||||||
|
|
||||||
UBActionPreview::~UBActionPreview() |
|
||||||
{ |
|
||||||
if(NULL != mpOwner){ |
|
||||||
delete mpOwner; |
|
||||||
mpOwner = NULL; |
|
||||||
} |
|
||||||
if(NULL != mpContent){ |
|
||||||
delete mpContent; |
|
||||||
mpContent = NULL; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void UBActionPreview::setOwner(int owner) |
|
||||||
{ |
|
||||||
if(NULL != mpOwner && NULL != mpContent){ |
|
||||||
switch(owner){ |
|
||||||
case eActionOwner_Teacher: |
|
||||||
mpOwner->setText(tr("Teacher")); |
|
||||||
mpContent->setStyleSheet("background:lightblue; border:lightblue;"); |
|
||||||
break; |
|
||||||
|
|
||||||
case eActionOwner_Student: |
|
||||||
mpOwner->setText(tr("Student")); |
|
||||||
mpContent->setStyleSheet("background:lightgreen; border:lightgreen;"); |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void UBActionPreview::setContent(const QString &content) |
|
||||||
{ |
|
||||||
if(NULL != mpContent){ |
|
||||||
mpContent->setText(content); |
|
||||||
setMinimumHeight(mpOwner->height() + mpContent->document()->documentLayout()->documentSize().toSize().height()); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------------------------
|
|
||||||
UBTBPreviewContainer::UBTBPreviewContainer(QWidget *parent, const char *name):UBWidgetList(parent) |
|
||||||
{ |
|
||||||
setObjectName(name); |
|
||||||
mCanRemove = false; |
|
||||||
} |
|
||||||
|
|
||||||
UBTBPreviewContainer::~UBTBPreviewContainer() |
|
||||||
{ |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------
|
|
||||||
UBTeacherBarPreviewWidget::UBTeacherBarPreviewWidget(UBTeacherBarDataMgr* pDataMgr, QWidget *parent, const char *name):QWidget(parent) |
|
||||||
, mpEditButton(NULL) |
|
||||||
, mpDocumentButton(NULL) |
|
||||||
, mpSessionTitle(NULL) |
|
||||||
, mpTitle(NULL) |
|
||||||
, mpTitleLabel(NULL) |
|
||||||
, mpPageNbrLabel(NULL) |
|
||||||
, mpContentContainer(NULL) |
|
||||||
, mpScheduleLabel(NULL) |
|
||||||
, mpLicenseLabel(NULL) |
|
||||||
{ |
|
||||||
setObjectName(name); |
|
||||||
mpDataMgr = pDataMgr; |
|
||||||
setLayout(&mLayout); |
|
||||||
mLayout.setContentsMargins(0, 0, 0, 0); |
|
||||||
|
|
||||||
setAttribute(Qt::WA_StyledBackground, true); |
|
||||||
setStyleSheet(UBApplication::globalStyleSheet()); |
|
||||||
|
|
||||||
// Build the Preview widget
|
|
||||||
mpContainer = new QWidget(this); |
|
||||||
mpContainer->setObjectName("UBTBPreviewWidget"); |
|
||||||
mpContainer->setLayout(&mContainerLayout); |
|
||||||
mLayout.addWidget(mpContainer, 1); |
|
||||||
|
|
||||||
|
|
||||||
// Session Title
|
|
||||||
mpTitleContainer = new QWidget(mpContainer); |
|
||||||
mpTitleContainer->setLayout(&mTitleLayout); |
|
||||||
mpSessionTitle = new QLabel(mpContainer); |
|
||||||
mpSessionTitle->setText(tr("Session: ")); |
|
||||||
mpSessionTitle->setWordWrap(true); |
|
||||||
mpSessionTitle->setAlignment(Qt::AlignRight); |
|
||||||
mpSessionTitle->setObjectName("UBTBPreviewSessionTitle"); |
|
||||||
mContainerLayout.addWidget(mpSessionTitle); |
|
||||||
|
|
||||||
// Title
|
|
||||||
mpTitleContainer->setLayout(&mTitleLayout); |
|
||||||
mTitleLayout.setContentsMargins(0, 0, 0, 0); |
|
||||||
mpTitleLabel = new QLabel(mpTitleContainer); |
|
||||||
mpTitleLabel->setText(tr("Activity")); |
|
||||||
mpTitleLabel->setObjectName("UBTeacherBarPreviewSubtitle"); |
|
||||||
mTitleLayout.addWidget(mpTitleLabel, 0); |
|
||||||
mpTitle = new QLabel(mpTitleContainer); |
|
||||||
mpTitle->setObjectName("UBTeacherBarPreviewTitle"); |
|
||||||
mpTitle->setWordWrap(true); |
|
||||||
mpTitle->setAlignment(Qt::AlignLeft); |
|
||||||
mTitleLayout.addWidget(mpTitle, 1); |
|
||||||
mpPageNbrLabel = new QLabel(tr("Page n° "), mpTitleContainer); |
|
||||||
mpPageNbrLabel->setAlignment(Qt::AlignRight); |
|
||||||
mpPageNbrLabel->setObjectName("UBTBPreviewSessionTitle"); |
|
||||||
mTitleLayout.addWidget(mpPageNbrLabel); |
|
||||||
mTitleLayout.addWidget(&mTitleSeparator); |
|
||||||
mContainerLayout.addWidget(mpTitleContainer); |
|
||||||
|
|
||||||
// Content
|
|
||||||
mpContentContainer = new UBTBPreviewContainer(mpContainer); |
|
||||||
mContainerLayout.addWidget(mpContentContainer, 1); |
|
||||||
|
|
||||||
// License
|
|
||||||
mContainerLayout.addWidget(&mLicenseSeparator); |
|
||||||
mpLicenseLabel = new UBTBLicenseWidget(mpContainer); |
|
||||||
mContainerLayout.addWidget(mpLicenseLabel); |
|
||||||
|
|
||||||
// Document Button
|
|
||||||
mpDocumentButton = new QPushButton(tr("Document View"), this); |
|
||||||
mpDocumentButton->setObjectName("DockPaletteWidgetButton"); |
|
||||||
|
|
||||||
// Edit Button
|
|
||||||
mpEditButton = new QPushButton(tr("Edit"), this); |
|
||||||
mpEditButton->setObjectName("DockPaletteWidgetButton"); |
|
||||||
mEditLayout.addWidget(mpDocumentButton, 0); |
|
||||||
mEditLayout.addWidget(mpEditButton, 0); |
|
||||||
mEditLayout.addStretch(1); |
|
||||||
mLayout.addLayout(&mEditLayout, 0); |
|
||||||
|
|
||||||
|
|
||||||
connect(mpEditButton, SIGNAL(clicked()), this, SLOT(onEdit())); |
|
||||||
connect(mpDocumentButton, SIGNAL(clicked()), this, SLOT(onDocumentClicked())); |
|
||||||
connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(onActiveSceneChanged())); |
|
||||||
} |
|
||||||
|
|
||||||
UBTeacherBarPreviewWidget::~UBTeacherBarPreviewWidget() |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
void UBTeacherBarPreviewWidget::onActiveSceneChanged() |
|
||||||
{ |
|
||||||
mpPageNbrLabel->setText(tr("Page n° %0").arg(UBApplication::boardController->activeSceneIndex())); |
|
||||||
} |
|
||||||
|
|
||||||
void UBTeacherBarPreviewWidget::onEdit() |
|
||||||
{ |
|
||||||
emit showEditMode(); |
|
||||||
} |
|
||||||
|
|
||||||
void UBTeacherBarPreviewWidget::onDocumentClicked() |
|
||||||
{ |
|
||||||
emit showDocumentPreview(); |
|
||||||
} |
|
||||||
|
|
||||||
void UBTeacherBarPreviewWidget::updateFields() |
|
||||||
{ |
|
||||||
// Session Title
|
|
||||||
if("" != mpDataMgr->sessionTitle()){ |
|
||||||
mpSessionTitle->setText(mpDataMgr->sessionTitle()); |
|
||||||
mpSessionTitle->setVisible(true); |
|
||||||
}else{ |
|
||||||
mpSessionTitle->setVisible(false); |
|
||||||
} |
|
||||||
|
|
||||||
// Page Title
|
|
||||||
if("" != mpDataMgr->pageTitle()){ |
|
||||||
mpTitle->setText(mpDataMgr->pageTitle()); |
|
||||||
mpPageNbrLabel->setText(tr("Page n° %0").arg(UBApplication::boardController->activeSceneIndex())); |
|
||||||
mpTitleContainer->setVisible(true); |
|
||||||
}else{ |
|
||||||
mpTitleContainer->setVisible(false); |
|
||||||
} |
|
||||||
|
|
||||||
// Actions
|
|
||||||
generateActions(); |
|
||||||
|
|
||||||
// Media
|
|
||||||
generateMedias(); |
|
||||||
|
|
||||||
// Comments
|
|
||||||
generateComments(); |
|
||||||
|
|
||||||
// Links
|
|
||||||
generateLinks(); |
|
||||||
|
|
||||||
// License
|
|
||||||
mpLicenseLabel->setLicense(mpDataMgr->sessionLicence()); |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
void UBTeacherBarPreviewWidget::clearFields() |
|
||||||
{ |
|
||||||
// Session Title
|
|
||||||
mpSessionTitle->setText(""); |
|
||||||
|
|
||||||
// Page Title
|
|
||||||
mpTitle->setText(""); |
|
||||||
|
|
||||||
// Medias
|
|
||||||
if(!mStoredWidgets.empty()){ |
|
||||||
foreach(QWidget* pW, mStoredWidgets){ |
|
||||||
mpContentContainer->removeWidget(pW); |
|
||||||
DELETEPTR(pW); |
|
||||||
} |
|
||||||
mStoredWidgets.clear(); |
|
||||||
} |
|
||||||
|
|
||||||
// License
|
|
||||||
mpLicenseLabel->setLicense(eLicense_CCBY); |
|
||||||
} |
|
||||||
|
|
||||||
void UBTeacherBarPreviewWidget::generateActions() |
|
||||||
{ |
|
||||||
if(!mpDataMgr->actions()->empty()){ |
|
||||||
foreach(sAction act, *mpDataMgr->actions()){ |
|
||||||
mpTmpAction = new UBActionPreview(this); |
|
||||||
mpTmpAction->setOwner(act.type); |
|
||||||
mpTmpAction->setContent(act.content); |
|
||||||
mpContentContainer->addWidget(mpTmpAction); |
|
||||||
mStoredWidgets << mpTmpAction; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void UBTeacherBarPreviewWidget::generateMedias() |
|
||||||
{ |
|
||||||
if(isVisible()){ |
|
||||||
foreach(QString mediaUrl, *mpDataMgr->mediaUrls()){ |
|
||||||
QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(mediaUrl); |
|
||||||
if(mimeType.contains("image")){ |
|
||||||
mpTmpLabel = new UBDraggableLabel(); |
|
||||||
mpTmpLabel->loadImage(mediaUrl); |
|
||||||
mStoredWidgets << mpTmpLabel; |
|
||||||
mpContentContainer->addWidget(mpTmpLabel); |
|
||||||
} |
|
||||||
else if(mimeType.contains("video") || mimeType.contains("audio")){ |
|
||||||
UBDraggableMedia* mediaPlayer = new UBDraggableMedia(mimeType.contains("audio")?eMediaType_Audio:eMediaType_Video); |
|
||||||
mediaPlayer->setFile(mediaUrl); |
|
||||||
mStoredWidgets << mediaPlayer; |
|
||||||
mpContentContainer->addWidget(mediaPlayer); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void UBTeacherBarPreviewWidget::generateLinks() |
|
||||||
{ |
|
||||||
if(!mpDataMgr->urls()->empty()){ |
|
||||||
foreach(sLink link, *mpDataMgr->urls()){ |
|
||||||
mpTmpLink = new QLabel(QString("<a href='%0'>%1</a>").arg(link.link).arg(link.title), this); |
|
||||||
mpTmpLink->setObjectName("UBLinkPreview"); |
|
||||||
mpTmpLink->setOpenExternalLinks(true); |
|
||||||
mpContentContainer->addWidget(mpTmpLink); |
|
||||||
mStoredWidgets << mpTmpLink; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void UBTeacherBarPreviewWidget::generateComments() |
|
||||||
{ |
|
||||||
if("" != mpDataMgr->comments()){ |
|
||||||
mpTmpComment = new QTextEdit(this); |
|
||||||
mpTmpComment->setObjectName("UBCommentPreview"); |
|
||||||
mpTmpComment->setPlainText(mpDataMgr->comments()); |
|
||||||
mpTmpComment->setReadOnly(true); |
|
||||||
mpContentContainer->addWidget(mpTmpComment); |
|
||||||
mStoredWidgets << mpTmpComment; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void UBTeacherBarPreviewWidget::showEvent(QShowEvent* ev) |
|
||||||
{ |
|
||||||
Q_UNUSED(ev); |
|
||||||
updateFields(); |
|
||||||
} |
|
||||||
|
|
@ -1,125 +0,0 @@ |
|||||||
#ifndef UBTEACHERBARPREVIEWWIDGET_H |
|
||||||
#define UBTEACHERBARPREVIEWWIDGET_H |
|
||||||
|
|
||||||
#include <QLabel> |
|
||||||
#include <QVBoxLayout> |
|
||||||
#include <QPushButton> |
|
||||||
|
|
||||||
#include "core/UBPersistenceManager.h" |
|
||||||
#include "customWidgets/UBWidgetList.h" |
|
||||||
#include "customWidgets/UBMediaWidget.h" |
|
||||||
#include "customWidgets/UBDraggableMedia.h" |
|
||||||
#include "customWidgets/UBDraggableLabel.h" |
|
||||||
#include "UBTeacherBarDataMgr.h" |
|
||||||
|
|
||||||
class UBTeacherBarPreviewMedia : public QWidget |
|
||||||
{ |
|
||||||
Q_OBJECT |
|
||||||
public: |
|
||||||
UBTeacherBarPreviewMedia(QWidget* parent=0, const char* name="UBTeacherBarPreviewMedia"); |
|
||||||
~UBTeacherBarPreviewMedia(); |
|
||||||
// int loadMedia(QStringList pMedias);
|
|
||||||
void loadWidgets(QList<QWidget*> pWidgetList, bool isResizable = true); |
|
||||||
void cleanMedia(); |
|
||||||
|
|
||||||
private: |
|
||||||
UBWidgetList* mWidget; |
|
||||||
QVBoxLayout mLayout; |
|
||||||
QMap<QWidget*,QString>mWidgetList; |
|
||||||
}; |
|
||||||
|
|
||||||
class UBActionPreview : public QWidget |
|
||||||
{ |
|
||||||
public: |
|
||||||
UBActionPreview(QWidget* parent=0, const char* name="UBActionPreview"); |
|
||||||
~UBActionPreview(); |
|
||||||
void setOwner(int owner); |
|
||||||
void setContent(const QString& content); |
|
||||||
|
|
||||||
private: |
|
||||||
QLabel* mpOwner; |
|
||||||
QTextEdit* mpContent; |
|
||||||
|
|
||||||
QVBoxLayout mLayout; |
|
||||||
QHBoxLayout mOwnerLayout; |
|
||||||
}; |
|
||||||
|
|
||||||
class UBTBPreviewContainer : public UBWidgetList |
|
||||||
{ |
|
||||||
public: |
|
||||||
UBTBPreviewContainer(QWidget* parent=0, const char* name="UBTBPreviewContainer"); |
|
||||||
~UBTBPreviewContainer(); |
|
||||||
}; |
|
||||||
|
|
||||||
class UBTeacherBarPreviewWidget : public QWidget |
|
||||||
{ |
|
||||||
Q_OBJECT |
|
||||||
public: |
|
||||||
UBTeacherBarPreviewWidget(UBTeacherBarDataMgr* pDataMgr, QWidget* parent=0, const char* name="UBTeacherBarPreviewWidget"); |
|
||||||
~UBTeacherBarPreviewWidget(); |
|
||||||
void updateFields(); |
|
||||||
void clearFields(); |
|
||||||
|
|
||||||
signals: |
|
||||||
void showEditMode(); |
|
||||||
void showDocumentPreview(); |
|
||||||
|
|
||||||
protected: |
|
||||||
void showEvent(QShowEvent* ev); |
|
||||||
|
|
||||||
private slots: |
|
||||||
void onEdit(); |
|
||||||
void onActiveSceneChanged(); |
|
||||||
void onDocumentClicked(); |
|
||||||
|
|
||||||
private: |
|
||||||
void generateActions(); |
|
||||||
void generateMedias(); |
|
||||||
void generateLinks(); |
|
||||||
void generateComments(); |
|
||||||
|
|
||||||
QVBoxLayout mLayout; |
|
||||||
QVBoxLayout mContainerLayout; |
|
||||||
QHBoxLayout mEditLayout; |
|
||||||
QPushButton* mpEditButton; |
|
||||||
QPushButton* mpDocumentButton; |
|
||||||
|
|
||||||
QWidget* mpContainer; |
|
||||||
|
|
||||||
// Titles
|
|
||||||
QVBoxLayout mTitleLayout; |
|
||||||
UBTBSeparator mTitleSeparator; |
|
||||||
QWidget* mpTitleContainer; |
|
||||||
QLabel* mpSessionTitle; |
|
||||||
QLabel* mpTitle; |
|
||||||
QLabel* mpTitleLabel; |
|
||||||
QLabel* mpPageNbrLabel; |
|
||||||
UBTBPreviewContainer* mpContentContainer; |
|
||||||
|
|
||||||
// Schedule
|
|
||||||
QLabel* mpScheduleLabel; |
|
||||||
|
|
||||||
// License
|
|
||||||
UBTBSeparator mLicenseSeparator; |
|
||||||
UBTBLicenseWidget* mpLicenseLabel; |
|
||||||
|
|
||||||
|
|
||||||
/** Pointer to the datas */ |
|
||||||
UBTeacherBarDataMgr* mpDataMgr; |
|
||||||
/** The list of stored widgets */ |
|
||||||
QList<QWidget*> mStoredWidgets; |
|
||||||
/** A temporary action widget */ |
|
||||||
UBActionPreview* mpTmpAction; |
|
||||||
/** A temporary media widget */ |
|
||||||
UBTeacherBarPreviewMedia* mpTmpMedia; |
|
||||||
/** A temporary link */ |
|
||||||
QLabel* mpTmpLink; |
|
||||||
/** A temporary comments field */ |
|
||||||
QTextEdit* mpTmpComment; |
|
||||||
/** A temporary media object */ |
|
||||||
UBDraggableMedia* mTmpMedia; |
|
||||||
/** A temporary label object */ |
|
||||||
UBDraggableLabel* mpTmpLabel; |
|
||||||
}; |
|
||||||
|
|
||||||
#endif // UBTEACHERBARPREVIEWWIDGET_H
|
|
@ -1,185 +0,0 @@ |
|||||||
#include "UBTeacherBarWidget.h" |
|
||||||
|
|
||||||
#include "core/UBApplication.h" |
|
||||||
#include "core/UBPersistenceManager.h" |
|
||||||
|
|
||||||
#include "UBMainWindow.h" |
|
||||||
|
|
||||||
#include "document/UBDocumentController.h" |
|
||||||
#include "document/UBDocumentProxy.h" |
|
||||||
|
|
||||||
#include "board/UBBoardController.h" |
|
||||||
#include "board/UBBoardPaletteManager.h" |
|
||||||
|
|
||||||
#include "gui/UBMediaPlayer.h" |
|
||||||
|
|
||||||
#include "customWidgets/UBDraggableLabel.h" |
|
||||||
#include "customWidgets/UBMediaWidget.h" |
|
||||||
#include "globals/UBGlobals.h" |
|
||||||
|
|
||||||
#include "core/memcheck.h" |
|
||||||
|
|
||||||
UBTeacherBarWidget::UBTeacherBarWidget(QWidget *parent, const char *name):UBDockPaletteWidget(parent) |
|
||||||
, mpStackWidget(NULL) |
|
||||||
, mpPreview(NULL) |
|
||||||
, mpDocPreviewWidget(NULL) |
|
||||||
, mpDocEditWidget(NULL) |
|
||||||
{ |
|
||||||
setObjectName(name); |
|
||||||
mName = "TeacherBarWidget"; |
|
||||||
mVisibleState = true; |
|
||||||
mData.clearLists(); |
|
||||||
|
|
||||||
setAttribute(Qt::WA_StyledBackground, true); |
|
||||||
setStyleSheet(UBApplication::globalStyleSheet()); |
|
||||||
|
|
||||||
mIconToLeft = QPixmap(":images/teacher_open.png"); |
|
||||||
mIconToRight = QPixmap(":images/teacher_close.png"); |
|
||||||
|
|
||||||
// Create the GUI
|
|
||||||
setLayout(&mLayout); |
|
||||||
|
|
||||||
mpStackWidget = new QStackedWidget(this); |
|
||||||
mLayout.addWidget(mpStackWidget); |
|
||||||
mpPageEditWidget = new UBTBPageEditWidget(&mData, mpStackWidget); |
|
||||||
mpPreview = new UBTeacherBarPreviewWidget(&mData, mpStackWidget); |
|
||||||
mpDocPreviewWidget = new UBTBDocumentPreviewWidget(&mData, mpStackWidget); |
|
||||||
mpDocEditWidget = new UBTBDocumentEditWidget(&mData, mpStackWidget); |
|
||||||
|
|
||||||
mpStackWidget->addWidget(mpPageEditWidget); |
|
||||||
mpStackWidget->addWidget(mpPreview); |
|
||||||
mpStackWidget->addWidget(mpDocPreviewWidget); |
|
||||||
mpStackWidget->addWidget(mpDocEditWidget); |
|
||||||
|
|
||||||
connect(UBApplication::boardController, SIGNAL(activeSceneWillChange()), this, SLOT(saveContent())); |
|
||||||
connect(UBApplication::mainWindow->actionQuit, SIGNAL(triggered()), this, SLOT(saveContent())); |
|
||||||
connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(loadContentInfos())); |
|
||||||
connect(UBApplication::boardController, SIGNAL(activeDocumentChanged()), this, SLOT(onActiveDocumentChanged())); |
|
||||||
|
|
||||||
connect(mpPreview, SIGNAL(showEditMode()), this, SLOT(onShowEditMode())); |
|
||||||
connect(mpPreview, SIGNAL(showDocumentPreview()), this, SLOT(onShowDocumentPreview())); |
|
||||||
connect(mpDocPreviewWidget, SIGNAL(changeTBState(eTeacherBarState)), this, SLOT(onTBStateChanged(eTeacherBarState))); |
|
||||||
connect(mpDocEditWidget, SIGNAL(changeTBState(eTeacherBarState)), this, SLOT(onTBStateChanged(eTeacherBarState))); |
|
||||||
connect(mpPageEditWidget, SIGNAL(changeTBState(eTeacherBarState)), this, SLOT(onTBStateChanged(eTeacherBarState))); |
|
||||||
connect(mpPageEditWidget, SIGNAL(valueChanged()), this, SLOT(onValueChanged())); |
|
||||||
connect(mpDocEditWidget, SIGNAL(valueChanged()), this, SLOT(onValueChanged())); |
|
||||||
} |
|
||||||
|
|
||||||
UBTeacherBarWidget::~UBTeacherBarWidget() |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
void UBTeacherBarWidget::onActiveDocumentChanged() |
|
||||||
{ |
|
||||||
loadContent(true); |
|
||||||
} |
|
||||||
|
|
||||||
void UBTeacherBarWidget::onValueChanged() |
|
||||||
{ |
|
||||||
if(isEmpty()) |
|
||||||
{ |
|
||||||
mIconToLeft = QPixmap(":images/teacher_open_disabled.png"); |
|
||||||
mIconToRight = QPixmap(":images/teacher_close_disabled.png"); |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
mIconToLeft = QPixmap(":images/teacher_open.png"); |
|
||||||
mIconToRight = QPixmap(":images/teacher_close.png"); |
|
||||||
} |
|
||||||
|
|
||||||
UBApplication::boardController->paletteManager()->refreshPalettes(); |
|
||||||
} |
|
||||||
|
|
||||||
void UBTeacherBarWidget::saveContent() |
|
||||||
{ |
|
||||||
mpPageEditWidget->saveFields(); |
|
||||||
mData.saveContent(); |
|
||||||
} |
|
||||||
|
|
||||||
void UBTeacherBarWidget::loadContentInfos() |
|
||||||
{ |
|
||||||
loadContent(false); |
|
||||||
} |
|
||||||
|
|
||||||
void UBTeacherBarWidget::loadContent(bool docChanged) |
|
||||||
{ |
|
||||||
// Clear the old datas
|
|
||||||
mpPageEditWidget->clearFields(); |
|
||||||
mpPreview->clearFields(); |
|
||||||
if(docChanged){ |
|
||||||
mpDocEditWidget->clearFields(); |
|
||||||
mpDocPreviewWidget->clearFields(); |
|
||||||
} |
|
||||||
|
|
||||||
// Update the datas
|
|
||||||
mData.loadContent(docChanged); |
|
||||||
|
|
||||||
// Update the fields
|
|
||||||
mpPageEditWidget->updateFields(); |
|
||||||
//mpPreview->updateFields();
|
|
||||||
if(docChanged){ |
|
||||||
mpDocEditWidget->updateFields(); |
|
||||||
mpDocPreviewWidget->updateFields(); |
|
||||||
} |
|
||||||
|
|
||||||
if(!isEmpty()){ |
|
||||||
onTBStateChanged(eTeacherBarState_PagePreview); |
|
||||||
}else{ |
|
||||||
if(1 == UBApplication::boardController->activeDocument()->pageCount()){ |
|
||||||
onTBStateChanged(eTeacherBarState_DocumentEdit); |
|
||||||
}else{ |
|
||||||
onTBStateChanged(eTeacherBarState_PageEdit); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
bool UBTeacherBarWidget::isEmpty() |
|
||||||
{ |
|
||||||
return mData.pageTitle() == "" && |
|
||||||
mData.urls()->empty() && |
|
||||||
mData.actions()->empty() && |
|
||||||
mData.medias()->empty() && |
|
||||||
mData.comments() == "" && |
|
||||||
mData.authors() == "" && |
|
||||||
mData.keywords() == "" && |
|
||||||
mData.level() == "" && |
|
||||||
mData.topic() == ""; |
|
||||||
} |
|
||||||
|
|
||||||
void UBTeacherBarWidget::onShowEditMode() |
|
||||||
{ |
|
||||||
onTBStateChanged(eTeacherBarState_PageEdit); |
|
||||||
} |
|
||||||
|
|
||||||
void UBTeacherBarWidget::onShowDocumentPreview() |
|
||||||
{ |
|
||||||
onTBStateChanged(eTeacherBarState_DocumentPreview); |
|
||||||
} |
|
||||||
|
|
||||||
void UBTeacherBarWidget::onTBStateChanged(eTeacherBarState state) |
|
||||||
{ |
|
||||||
switch(state){ |
|
||||||
case eTeacherBarState_DocumentEdit: |
|
||||||
//mpDocEditWidget->updateFields();
|
|
||||||
mpStackWidget->setCurrentWidget(mpDocEditWidget); |
|
||||||
break; |
|
||||||
case eTeacherBarState_DocumentPreview: |
|
||||||
//mpDocPreviewWidget->updateFields();
|
|
||||||
mpStackWidget->setCurrentWidget(mpDocPreviewWidget); |
|
||||||
break; |
|
||||||
case eTeacherBarState_PageEdit: |
|
||||||
mpPageEditWidget->clearFields(); |
|
||||||
mpPageEditWidget->updateFields(); |
|
||||||
mpStackWidget->setCurrentWidget(mpPageEditWidget); |
|
||||||
break; |
|
||||||
case eTeacherBarState_PagePreview: |
|
||||||
saveContent(); |
|
||||||
mpPreview->clearFields(); |
|
||||||
if(mpPreview->isVisible()){ |
|
||||||
mpPreview->updateFields(); |
|
||||||
} |
|
||||||
mpStackWidget->setCurrentWidget(mpPreview); |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
@ -1,68 +0,0 @@ |
|||||||
#ifndef UBTEACHERBARWIDGET_H |
|
||||||
#define UBTEACHERBARWIDGET_H |
|
||||||
|
|
||||||
#include <QWidget> |
|
||||||
#include <QVBoxLayout> |
|
||||||
#include <QHBoxLayout> |
|
||||||
#include <QLabel> |
|
||||||
#include <QTextEdit> |
|
||||||
#include <QLineEdit> |
|
||||||
#include <QCheckBox> |
|
||||||
#include <QTabWidget> |
|
||||||
#include <QButtonGroup> |
|
||||||
#include <QPushButton> |
|
||||||
#include <QComboBox> |
|
||||||
#include <QStackedWidget> |
|
||||||
|
|
||||||
#include "UBDockPaletteWidget.h" |
|
||||||
#include "customWidgets/UBWidgetList.h" |
|
||||||
#include "interfaces/IDropable.h" |
|
||||||
#include "UBTeacherBarDataMgr.h" |
|
||||||
#include "UBTBDocumentPreviewWidget.h" |
|
||||||
#include "UBTBPageEditWidget.h" |
|
||||||
#include "UBTeacherBarPreviewWidget.h" |
|
||||||
#include "UBTBDocumentEditWidget.h" |
|
||||||
|
|
||||||
#define LABEL_MINWIDHT 80 |
|
||||||
|
|
||||||
class UBTeacherBarWidget : public UBDockPaletteWidget |
|
||||||
{ |
|
||||||
Q_OBJECT |
|
||||||
public: |
|
||||||
UBTeacherBarWidget(QWidget* parent=0, const char* name="UBTeacherBarWidget"); |
|
||||||
~UBTeacherBarWidget(); |
|
||||||
|
|
||||||
bool visibleInMode(eUBDockPaletteWidgetMode mode) |
|
||||||
{ |
|
||||||
return (mode == eUBDockPaletteWidget_BOARD); |
|
||||||
} |
|
||||||
|
|
||||||
void loadContent(bool docChanged = false); |
|
||||||
|
|
||||||
public slots: |
|
||||||
void saveContent(); |
|
||||||
|
|
||||||
private slots: |
|
||||||
void loadContentInfos(); |
|
||||||
void onValueChanged(); |
|
||||||
void onShowEditMode(); |
|
||||||
void onTBStateChanged(eTeacherBarState state); |
|
||||||
void onActiveDocumentChanged(); |
|
||||||
void onShowDocumentPreview(); |
|
||||||
|
|
||||||
private: |
|
||||||
bool isEmpty(); |
|
||||||
|
|
||||||
QVBoxLayout mLayout; |
|
||||||
QStackedWidget* mpStackWidget; |
|
||||||
eTeacherBarState mState; |
|
||||||
|
|
||||||
UBTBPageEditWidget* mpPageEditWidget; |
|
||||||
UBTeacherBarPreviewWidget* mpPreview; |
|
||||||
UBTBDocumentPreviewWidget* mpDocPreviewWidget; |
|
||||||
UBTBDocumentEditWidget* mpDocEditWidget; |
|
||||||
|
|
||||||
UBTeacherBarDataMgr mData; |
|
||||||
}; |
|
||||||
|
|
||||||
#endif // UBTEACHERBARWIDGET_H
|
|
Loading…
Reference in new issue