parent
15f89fc7a2
commit
3dd07bb46d
@ -0,0 +1,88 @@ |
||||
#include "UBTBDocumentEditWidget.h" |
||||
#include "customWidgets/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) |
||||
{ |
||||
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); |
||||
|
||||
// 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); |
||||
|
||||
// Metadata
|
||||
mpMetadataLabel = new QLabel(tr("Metadata"), mpContainer); |
||||
mpMetadataLabel->setAlignment(Qt::AlignLeft); |
||||
//mpMetadataLabel->setObjectName("UBTeacherBarPreviewSubtitle");
|
||||
mContainerLayout.addWidget(mpMetadataLabel, 0); |
||||
|
||||
// License
|
||||
mpLicenseLabel = new QLabel(tr("License"), mpContainer); |
||||
mpLicenseLabel->setAlignment(Qt::AlignLeft); |
||||
//mpLicenseLabel->setObjectName("UBTeacherBarPreviewSubtitle");
|
||||
mContainerLayout.addWidget(mpLicenseLabel, 0); |
||||
|
||||
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())); |
||||
} |
||||
|
||||
UBTBDocumentEditWidget::~UBTBDocumentEditWidget() |
||||
{ |
||||
DELETEPTR(mpTitleLabel); |
||||
DELETEPTR(mpTitle); |
||||
DELETEPTR(mpTargetLabel); |
||||
DELETEPTR(mpTarget); |
||||
DELETEPTR(mpMetadataLabel); |
||||
DELETEPTR(mpLicenseLabel); |
||||
DELETEPTR(mpPageViewButton); |
||||
DELETEPTR(mpPreviewButton); |
||||
} |
||||
|
||||
void UBTBDocumentEditWidget::onPageView() |
||||
{ |
||||
emit changeTBState(eTeacherBarState_PageEdit); |
||||
} |
||||
|
||||
void UBTBDocumentEditWidget::onPreview() |
||||
{ |
||||
emit changeTBState(eTeacherBarState_DocumentPreview); |
||||
} |
@ -0,0 +1,45 @@ |
||||
#ifndef UBTBDOCUMENTEDITWIDGET_H |
||||
#define UBTBDOCUMENTEDITWIDGET_H |
||||
|
||||
#include <QVBoxLayout> |
||||
#include <QPushButton> |
||||
#include <QLabel> |
||||
#include <QLineEdit> |
||||
#include <QTextEdit> |
||||
|
||||
#include "UBTeacherBarDataMgr.h" |
||||
|
||||
class UBTBDocumentEditWidget : public QWidget |
||||
{ |
||||
Q_OBJECT |
||||
public: |
||||
UBTBDocumentEditWidget(UBTeacherBarDataMgr* pDataMgr, QWidget* parent=0, const char* name="UBTBDocumentEditWidget"); |
||||
~UBTBDocumentEditWidget(); |
||||
|
||||
signals: |
||||
void changeTBState(eTeacherBarState state); |
||||
|
||||
private slots: |
||||
void onPageView(); |
||||
void onPreview(); |
||||
|
||||
private: |
||||
QVBoxLayout mLayout; |
||||
QHBoxLayout mPageLayout; |
||||
QHBoxLayout mPreviewLayout; |
||||
QVBoxLayout mContainerLayout; |
||||
QPushButton* mpPageViewButton; |
||||
QPushButton* mpPreviewButton; |
||||
|
||||
QWidget* mpContainer; |
||||
QLabel* mpTitleLabel; |
||||
QLineEdit* mpTitle; |
||||
QLabel* mpTargetLabel; |
||||
QTextEdit* mpTarget; |
||||
QLabel* mpMetadataLabel; |
||||
QLabel* mpLicenseLabel; |
||||
|
||||
UBTeacherBarDataMgr* mpDataMgr; |
||||
}; |
||||
|
||||
#endif // UBTBDOCUMENTEDITWIDGET_H
|
@ -0,0 +1,48 @@ |
||||
#include "customWidgets/UBGlobals.h" |
||||
#include "UBTBDocumentPreviewWidget.h" |
||||
|
||||
UBTBDocumentPreviewWidget::UBTBDocumentPreviewWidget(UBTeacherBarDataMgr *pDataMgr, QWidget *parent, const char *name):QWidget(parent) |
||||
, mpPageViewButton(NULL) |
||||
, mpEditButton(NULL) |
||||
{ |
||||
setObjectName(name); |
||||
mpDataMgr = pDataMgr; |
||||
|
||||
setLayout(&mLayout); |
||||
|
||||
mpPageViewButton = new QPushButton(tr("Page View"), this); |
||||
mpPageViewButton->setObjectName("DockPaletteWidgetButton"); |
||||
mPageLayout.addStretch(1); |
||||
mPageLayout.addWidget(mpPageViewButton, 0); |
||||
mPageLayout.addStretch(1); |
||||
mLayout.addLayout(&mPageLayout); |
||||
|
||||
// TODO : Add the elements here
|
||||
|
||||
mpEditButton = new QPushButton(tr("Edit"), this); |
||||
mpEditButton->setObjectName("DockPaletteWidgetButton"); |
||||
mPreviewLayout.addStretch(1); |
||||
mPreviewLayout.addWidget(mpEditButton, 0); |
||||
mPreviewLayout.addStretch(1); |
||||
mLayout.addLayout(&mPreviewLayout); |
||||
|
||||
connect(mpPageViewButton, SIGNAL(clicked()), this, SLOT(onPageView())); |
||||
connect(mpEditButton, SIGNAL(clicked()), this, SLOT(onEdit())); |
||||
} |
||||
|
||||
UBTBDocumentPreviewWidget::~UBTBDocumentPreviewWidget() |
||||
{ |
||||
DELETEPTR(mpPageViewButton); |
||||
DELETEPTR(mpEditButton); |
||||
} |
||||
|
||||
void UBTBDocumentPreviewWidget::onEdit() |
||||
{ |
||||
emit changeTBState(eTeacherBarState_DocumentEdit); |
||||
} |
||||
|
||||
void UBTBDocumentPreviewWidget::onPageView() |
||||
{ |
||||
emit changeTBState(eTeacherBarState_PagePreview); |
||||
} |
||||
|
@ -0,0 +1,33 @@ |
||||
#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(); |
||||
|
||||
signals: |
||||
void changeTBState(eTeacherBarState state); |
||||
|
||||
private slots: |
||||
void onPageView(); |
||||
void onEdit(); |
||||
|
||||
private: |
||||
QVBoxLayout mLayout; |
||||
QHBoxLayout mPageLayout; |
||||
QHBoxLayout mPreviewLayout; |
||||
QPushButton* mpPageViewButton; |
||||
QPushButton* mpEditButton; |
||||
|
||||
UBTeacherBarDataMgr* mpDataMgr; |
||||
}; |
||||
|
||||
#endif // UBTBDOCUMENTPREVIEWWIDGET_H
|
@ -0,0 +1,417 @@ |
||||
#include "customWidgets/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; |
||||
setAttribute(Qt::WA_StyledBackground, true); |
||||
setStyleSheet(UBApplication::globalStyleSheet()); |
||||
|
||||
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"); |
||||
connect(mpTitle, SIGNAL(textChanged(const QString&)), this, SLOT(onTitleTextChanged(const QString&))); |
||||
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(onValueChanged())); |
||||
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))); |
||||
} |
||||
|
||||
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::onValueChanged() |
||||
{ |
||||
mpDataMgr->setPageTitle(mpTitle->text()); |
||||
mpDataMgr->setComments(mpComments->document()->toPlainText()); |
||||
emit valueChanged(); |
||||
} |
||||
|
||||
void UBTBPageEditWidget::onActionButton() |
||||
{ |
||||
UBTeacherStudentAction* pAction = new UBTeacherStudentAction(this); |
||||
mpDataMgr->actions() << pAction; |
||||
mpActions->addWidget(pAction); |
||||
} |
||||
|
||||
void UBTBPageEditWidget::onLinkButton() |
||||
{ |
||||
UBUrlWidget* pUrl = new UBUrlWidget(this); |
||||
mpDataMgr->urls() << pUrl; |
||||
mpLinks->addWidget(pUrl); |
||||
} |
||||
|
||||
void UBTBPageEditWidget::onMediaDropped(const QString &url) |
||||
{ |
||||
if("" != url){ |
||||
QWidget* pMedia = mpMediaContainer->generateMediaWidget(url); |
||||
if(NULL != pMedia){ |
||||
mpDataMgr->medias() << pMedia; |
||||
mpMediaContainer->addWidget(pMedia); |
||||
} |
||||
} |
||||
} |
||||
|
||||
|
||||
void UBTBPageEditWidget::saveInfos(sTeacherBarInfos *infos) |
||||
{ |
||||
if(NULL != infos){ |
||||
infos->title = mpTitle->text(); |
||||
|
||||
// Actions
|
||||
for(int i=0; i<mpDataMgr->actions().size(); i++){ |
||||
infos->actions << QString("%0;%1").arg(mpDataMgr->actions().at(i)->comboValue()).arg(mpDataMgr->actions().at(i)->text()); |
||||
} |
||||
// Media
|
||||
foreach(QString media, mpMediaContainer->mediaUrls()){ |
||||
infos->medias << media; |
||||
} |
||||
|
||||
// Links
|
||||
for(int j=0; j<mpDataMgr->urls().size(); j++){ |
||||
if("" != mpDataMgr->urls().at(j)->url()){ |
||||
infos->urls << mpDataMgr->urls().at(j)->url(); |
||||
} |
||||
} |
||||
// Comments
|
||||
infos->comments = mpComments->document()->toPlainText(); |
||||
} |
||||
} |
||||
|
||||
void UBTBPageEditWidget::loadInfos(sTeacherBarInfos* infos) |
||||
{ |
||||
if(NULL != infos){ |
||||
// Title
|
||||
mpTitle->setText(infos->title); |
||||
mpDataMgr->setPageTitle(infos->title); |
||||
|
||||
// Actions
|
||||
for(int i=0; i<infos->actions.size(); i++){ |
||||
QStringList qslAction = infos->actions.at(i).split(";"); |
||||
if(qslAction.size() >= 2){ |
||||
UBTeacherStudentAction* pAction = new UBTeacherStudentAction(this); |
||||
pAction->setComboValue(qslAction.at(0).toInt()); |
||||
pAction->setText(qslAction.at(1)); |
||||
mpDataMgr->actions() << pAction; |
||||
mpActions->addWidget(pAction); |
||||
} |
||||
} |
||||
// Media
|
||||
foreach(QString url, infos->medias){ |
||||
if("" != url){ |
||||
QWidget* pMedia = mpMediaContainer->generateMediaWidget(url); |
||||
if(NULL != pMedia){ |
||||
mpDataMgr->medias() << pMedia; |
||||
mpMediaContainer->addWidget(pMedia); |
||||
} |
||||
} |
||||
} |
||||
|
||||
// Links
|
||||
for(int j=0; j<infos->urls.size(); j++){ |
||||
QString qsUrl = infos->urls.at(j); |
||||
if("" != qsUrl){ |
||||
UBUrlWidget* pLink = new UBUrlWidget(this); |
||||
pLink->setUrl(qsUrl); |
||||
mpDataMgr->urls() << pLink; |
||||
mpLinks->addWidget(pLink); |
||||
} |
||||
} |
||||
// Comments
|
||||
if(NULL != mpComments){ |
||||
mpComments->document()->setPlainText(infos->comments); |
||||
} |
||||
} |
||||
} |
||||
|
||||
void UBTBPageEditWidget::onDocumentEditClicked() |
||||
{ |
||||
emit changeTBState(eTeacherBarState_DocumentEdit); |
||||
} |
||||
|
||||
void UBTBPageEditWidget::onPagePreviewClicked() |
||||
{ |
||||
emit changeTBState(eTeacherBarState_PagePreview); |
||||
} |
||||
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
UBUrlWidget::UBUrlWidget(QWidget *parent, const char *name):QWidget(parent) |
||||
, mpLayout(NULL) |
||||
, mpUrlLabel(NULL) |
||||
, mpUrl(NULL) |
||||
{ |
||||
setObjectName(name); |
||||
setAttribute(Qt::WA_StyledBackground, true); |
||||
setStyleSheet(UBApplication::globalStyleSheet()); |
||||
|
||||
mpLayout = new QVBoxLayout(this); |
||||
setLayout(mpLayout); |
||||
|
||||
mpLabelLayout = new QHBoxLayout(this); |
||||
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(this); |
||||
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); |
||||
} |
||||
|
||||
UBUrlWidget::~UBUrlWidget() |
||||
{ |
||||
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) |
||||
{ |
||||
QStringList list = url.split(";"); |
||||
if(NULL != mpUrl){ |
||||
mpUrl->setText(list.at(0)); |
||||
mpTitle->setText(list.at(1)); |
||||
} |
||||
} |
||||
|
||||
// ------------------------------------------------------------------------------------------------------------------------------------
|
||||
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); |
||||
QLabel* label = new QLabel(); |
||||
pix.scaledToWidth(label->width()); |
||||
label->resize(pix.width(), pix.height()); |
||||
label->setPixmap(pix); |
||||
label->setScaledContents(true); |
||||
pW = label; |
||||
} |
||||
else if(mimeType.contains("video") || mimeType.contains("audio")){ |
||||
UBMediaWidget* mediaPlayer = new UBMediaWidget(mimeType.contains("audio")?eMediaType_Audio:eMediaType_Video); |
||||
mediaPlayer->setFile(url); |
||||
pW = mediaPlayer; |
||||
} |
||||
else{ |
||||
qWarning() << "pMediaPath" << url; |
||||
qWarning() << "bad idea to come here"; |
||||
} |
||||
|
||||
return pW; |
||||
} |
@ -0,0 +1,92 @@ |
||||
#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 "interfaces/IDropable.h" |
||||
#include "UBTeacherBarDataMgr.h" |
||||
|
||||
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 saveInfos(sTeacherBarInfos* infos); |
||||
void loadInfos(sTeacherBarInfos* infos); |
||||
|
||||
signals: |
||||
void valueChanged(); |
||||
void changeTBState(eTeacherBarState state); |
||||
|
||||
private slots: |
||||
void onValueChanged(); |
||||
void onActionButton(); |
||||
void onLinkButton(); |
||||
void onMediaDropped(const QString& url); |
||||
void onDocumentEditClicked(); |
||||
void onPagePreviewClicked(); |
||||
|
||||
private: |
||||
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; |
||||
}; |
||||
|
||||
#endif // UBTBPAGEEDITWIDGET_H
|
@ -0,0 +1,97 @@ |
||||
#include "core/UBApplication.h" |
||||
#include "customWidgets/UBGlobals.h" |
||||
#include "UBTeacherBarDataMgr.h" |
||||
|
||||
UBTeacherBarDataMgr::UBTeacherBarDataMgr() |
||||
{ |
||||
|
||||
} |
||||
|
||||
UBTeacherBarDataMgr::~UBTeacherBarDataMgr() |
||||
{ |
||||
|
||||
} |
||||
|
||||
void UBTeacherBarDataMgr::clearLists() |
||||
{ |
||||
mActionList.clear(); |
||||
mUrlList.clear(); |
||||
mMediaList.clear(); |
||||
} |
||||
|
||||
UBTeacherStudentAction::UBTeacherStudentAction(QWidget *parent, const char *name):QWidget(parent) |
||||
, mpText(NULL) |
||||
, mpLayout(NULL) |
||||
, mpComboLayout(NULL) |
||||
, mpCombo(NULL) |
||||
{ |
||||
setObjectName(name); |
||||
|
||||
setAttribute(Qt::WA_StyledBackground, true); |
||||
setStyleSheet(UBApplication::globalStyleSheet()); |
||||
|
||||
// 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); |
||||
|
||||
} |
||||
|
||||
UBTeacherStudentAction::~UBTeacherStudentAction() |
||||
{ |
||||
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); |
||||
} |
||||
} |
@ -0,0 +1,109 @@ |
||||
#ifndef UBTEACHERBARDATAMGR_H |
||||
#define UBTEACHERBARDATAMGR_H |
||||
|
||||
#include <QString> |
||||
#include <QWidget> |
||||
#include <QTextEdit> |
||||
#include <QLineEdit> |
||||
#include <QLabel> |
||||
#include <QHBoxLayout> |
||||
#include <QVBoxLayout> |
||||
#include <QComboBox> |
||||
|
||||
typedef enum{ |
||||
eTeacherBarState_DocumentEdit, |
||||
eTeacherBarState_DocumentPreview, |
||||
eTeacherBarState_PageEdit, |
||||
eTeacherBarState_PagePreview |
||||
}eTeacherBarState; |
||||
|
||||
typedef enum{ |
||||
eActionOwner_Teacher, |
||||
eActionOwner_Student |
||||
}eActionOwner; |
||||
|
||||
class UBTeacherStudentAction : public QWidget |
||||
{ |
||||
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 QWidget |
||||
{ |
||||
public: |
||||
UBUrlWidget(QWidget* parent=0, const char* name="UBUrlWidget"); |
||||
~UBUrlWidget(); |
||||
|
||||
QString url(); |
||||
void setUrl(const QString& url); |
||||
|
||||
private: |
||||
QVBoxLayout* mpLayout; |
||||
QHBoxLayout* mpLabelLayout; |
||||
QHBoxLayout* mpTitleLayout; |
||||
QLabel* mpUrlLabel; |
||||
QLineEdit* mpUrl; |
||||
|
||||
QLabel* mpTitleLabel; |
||||
QLineEdit* mpTitle; |
||||
}; |
||||
|
||||
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;} |
||||
|
||||
// Page Title
|
||||
void setPageTitle(const QString& title){mPageTitle = title;} |
||||
QString pageTitle(){return mPageTitle;} |
||||
|
||||
// Actions
|
||||
QVector<UBTeacherStudentAction*> actions(){return mActionList;} |
||||
|
||||
// Medias
|
||||
QVector<QWidget*> medias(){return mMediaList;} |
||||
|
||||
// Urls
|
||||
QVector<UBUrlWidget*> urls(){return mUrlList;} |
||||
|
||||
// Comments
|
||||
void setComments(const QString& c){mComments = c;} |
||||
QString comments(){return mComments;} |
||||
|
||||
// Others
|
||||
void clearLists(); |
||||
|
||||
private: |
||||
QString mSessionTitle; |
||||
QString mSessionTarget; |
||||
QString mPageTitle; |
||||
QString mComments; |
||||
|
||||
QVector<UBTeacherStudentAction*> mActionList; |
||||
QVector<UBUrlWidget*> mUrlList; |
||||
QVector<QWidget*> mMediaList; |
||||
}; |
||||
|
||||
#endif // UBTEACHERBARDATAMGR_H
|
@ -0,0 +1,314 @@ |
||||
#include "core/UBApplication.h" |
||||
#include "customWidgets/UBGlobals.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) |
||||
{ |
||||
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 QLabel(this); |
||||
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(const QString &owner) |
||||
{ |
||||
if(NULL != mpOwner && NULL != mpContent){ |
||||
switch(owner.toInt()){ |
||||
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); |
||||
} |
||||
} |
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------
|
||||
UBTBPreviewContainer::UBTBPreviewContainer(QWidget *parent, const char *name):UBWidgetList(parent) |
||||
{ |
||||
setObjectName(name); |
||||
} |
||||
|
||||
UBTBPreviewContainer::~UBTBPreviewContainer() |
||||
{ |
||||
|
||||
} |
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
UBTeacherBarPreviewWidget::UBTeacherBarPreviewWidget(UBTeacherBarDataMgr* pDataMgr, QWidget *parent, const char *name):QWidget(parent) |
||||
, mpEditButton(NULL) |
||||
, mpTitle(NULL) |
||||
, mpDuration(NULL) |
||||
, mpActionsLabel(NULL) |
||||
, mpMediaLabel(NULL) |
||||
, mpCommentsLabel(NULL) |
||||
, mpComments(NULL) |
||||
, mpLinksLabel(NULL) |
||||
, mpContentContainer(NULL) |
||||
{ |
||||
setObjectName(name); |
||||
mpDataMgr = pDataMgr; |
||||
setLayout(&mLayout); |
||||
|
||||
setAttribute(Qt::WA_StyledBackground, true); |
||||
setStyleSheet(UBApplication::globalStyleSheet()); |
||||
|
||||
// Build the Preview widget
|
||||
// Title + duration
|
||||
mpTitle = new QLabel(this); |
||||
mpTitle->setObjectName("UBTeacherBarPreviewTitle"); |
||||
mpTitle->setWordWrap(true); |
||||
mpTitle->setAlignment(Qt::AlignCenter); |
||||
mpDuration = new QLabel(this); |
||||
mTitleDurationLayout.addWidget(mpTitle, 0); |
||||
mTitleDurationLayout.addWidget(mpDuration, 1); |
||||
mLayout.addLayout(&mTitleDurationLayout, 0); |
||||
|
||||
mpContentContainer = new UBTBPreviewContainer(this); |
||||
mLayout.addWidget(mpContentContainer, 1); |
||||
//mLayout.addWidget(&mMediaViewer, 1);
|
||||
// The next line is disgusting. This is a quickfix that must be reworked later
|
||||
mMediaViewer.setContentsMargins(-9, -9, -9, -9); |
||||
|
||||
hideElements(); |
||||
|
||||
// Edit button
|
||||
mpEditButton = new QPushButton(tr("Edit infos"), this); |
||||
mpEditButton->setObjectName("DockPaletteWidgetButton"); |
||||
mEditLayout.addStretch(1); |
||||
mEditLayout.addWidget(mpEditButton, 0); |
||||
mEditLayout.addStretch(1); |
||||
mLayout.addLayout(&mEditLayout, 0); |
||||
|
||||
|
||||
connect(mpEditButton, SIGNAL(clicked()), this, SLOT(onEdit())); |
||||
} |
||||
|
||||
UBTeacherBarPreviewWidget::~UBTeacherBarPreviewWidget() |
||||
{ |
||||
DELETEPTR(mpLinksLabel); |
||||
DELETEPTR(mpComments); |
||||
DELETEPTR(mpTitle); |
||||
DELETEPTR(mpDuration); |
||||
DELETEPTR(mpActionsLabel); |
||||
DELETEPTR(mpMediaLabel); |
||||
DELETEPTR(mpCommentsLabel); |
||||
DELETEPTR(mpContentContainer); |
||||
DELETEPTR(mpEditButton); |
||||
} |
||||
|
||||
void UBTeacherBarPreviewWidget::onEdit() |
||||
{ |
||||
emit showEditMode(); |
||||
} |
||||
|
||||
void UBTeacherBarPreviewWidget::setTitle(const QString &title) |
||||
{ |
||||
if(NULL != mpTitle){ |
||||
mpTitle->setText(title); |
||||
} |
||||
} |
||||
|
||||
void UBTeacherBarPreviewWidget::setComments(const QString &comments) |
||||
{ |
||||
if("" != comments){ |
||||
mWidgets.clear(); |
||||
mpComments->setText(comments); |
||||
mpComments->setVisible(true); |
||||
mpCommentsLabel->setVisible(true); |
||||
mWidgets << mpCommentsLabel; |
||||
mMediaViewer.loadWidgets(mWidgets, false); |
||||
mWidgets.clear(); |
||||
mWidgets << mpComments; |
||||
mMediaViewer.loadWidgets(mWidgets, true); |
||||
} |
||||
} |
||||
|
||||
void UBTeacherBarPreviewWidget::clean() |
||||
{ |
||||
mMediaViewer.cleanMedia(); |
||||
|
||||
foreach(QWidget* eachWidget, mStoredWidgets){ |
||||
delete eachWidget; |
||||
eachWidget = NULL; |
||||
} |
||||
mStoredWidgets.clear(); |
||||
|
||||
hideElements(); |
||||
} |
||||
|
||||
void UBTeacherBarPreviewWidget::hideElements() |
||||
{ |
||||
mpActionsLabel = new QLabel(tr("Actions"), this); |
||||
mpActionsLabel->setObjectName("UBTeacherBarPreviewSubtitle"); |
||||
mpMediaLabel = new QLabel(tr("Medias"), this); |
||||
mpMediaLabel->setObjectName("UBTeacherBarPreviewSubtitle"); |
||||
mpCommentsLabel = new QLabel(tr("Comments"), this); |
||||
mpCommentsLabel->setObjectName("UBTeacherBarPreviewSubtitle"); |
||||
mpComments = new QLabel(this); |
||||
mpComments->setWordWrap(true); |
||||
mpComments->setObjectName("UBTeacherBarPreviewComments"); |
||||
mpLinksLabel = new QLabel(tr("Links"), this); |
||||
mpLinksLabel->setObjectName("UBTeacherBarPreviewSubtitle"); |
||||
|
||||
mpActionsLabel->setVisible(false); |
||||
mpMediaLabel->setVisible(false); |
||||
mpCommentsLabel->setVisible(false); |
||||
mpComments->setVisible(false); |
||||
mpLinksLabel->setVisible(false); |
||||
} |
||||
|
||||
void UBTeacherBarPreviewWidget::setActions(QStringList actions) |
||||
{ |
||||
if(!actions.empty()){ |
||||
mWidgets.clear(); |
||||
mpActionsLabel->setVisible(true); |
||||
mWidgets << mpActionsLabel; |
||||
mediaViewer()->loadWidgets(mWidgets,false); |
||||
mWidgets.clear(); |
||||
foreach(QString action, actions){ |
||||
QStringList desc = action.split(';'); |
||||
if(2 <= desc.size()){ |
||||
QString owner = desc.at(0); |
||||
QString act = desc.at(1); |
||||
mpTmpAction = new UBActionPreview(this); |
||||
mpTmpAction->setOwner(owner); |
||||
mpTmpAction->setContent(act); |
||||
mWidgets << mpTmpAction; |
||||
} |
||||
} |
||||
mMediaViewer.loadWidgets(mWidgets, true); |
||||
} |
||||
} |
||||
|
||||
void UBTeacherBarPreviewWidget::setLinks(QStringList links) |
||||
{ |
||||
if(!links.empty()){ |
||||
mWidgets.clear(); |
||||
mpLinksLabel->setVisible(true); |
||||
mWidgets << mpLinksLabel; |
||||
mMediaViewer.loadWidgets(mWidgets, false); |
||||
mWidgets.clear(); |
||||
foreach(QString link, links){ |
||||
mpTmpLink = new QLabel(link, this); |
||||
mpTmpLink->setOpenExternalLinks(true); |
||||
mWidgets << mpTmpLink; |
||||
} |
||||
mMediaViewer.loadWidgets(mWidgets, true); |
||||
} |
||||
} |
||||
|
||||
void UBTeacherBarPreviewWidget::loadInfos(sTeacherBarInfos *infos) |
||||
{ |
||||
if(NULL != infos){ |
||||
setTitle(infos->title); |
||||
mediaViewer()->loadMedia(infos->medias); |
||||
|
||||
// Add the comments
|
||||
//setComments();
|
||||
} |
||||
} |
@ -0,0 +1,96 @@ |
||||
#ifndef UBTEACHERBARPREVIEWWIDGET_H |
||||
#define UBTEACHERBARPREVIEWWIDGET_H |
||||
|
||||
#include <QLabel> |
||||
#include <QVBoxLayout> |
||||
#include <QPushButton> |
||||
|
||||
#include "core/UBPersistenceManager.h" |
||||
#include "customWidgets/UBWidgetList.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(const QString& owner); |
||||
void setContent(const QString& content); |
||||
|
||||
private: |
||||
QLabel* mpOwner; |
||||
QLabel* 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(); |
||||
UBTeacherBarPreviewMedia* mediaViewer() {return &mMediaViewer;} |
||||
void setTitle(const QString& title); |
||||
void setComments(const QString& comments); |
||||
void setActions(QStringList actions); |
||||
void setLinks(QStringList links); |
||||
void clean(); |
||||
QLabel* mediaLabel() { return mpMediaLabel;} |
||||
void loadInfos(sTeacherBarInfos* infos); |
||||
|
||||
signals: |
||||
void showEditMode(); |
||||
|
||||
private slots: |
||||
void onEdit(); |
||||
|
||||
private: |
||||
void hideElements(); |
||||
|
||||
QVBoxLayout mLayout; |
||||
QHBoxLayout mEditLayout; |
||||
QHBoxLayout mTitleDurationLayout; |
||||
UBTeacherBarPreviewMedia mMediaViewer; |
||||
QList<QWidget*> mWidgets; |
||||
QList<QWidget*> mStoredWidgets; |
||||
|
||||
QPushButton* mpEditButton; |
||||
QLabel* mpTitle; |
||||
QLabel* mpDuration; |
||||
QLabel* mpActionsLabel; |
||||
QLabel* mpMediaLabel; |
||||
QLabel* mpCommentsLabel; |
||||
QLabel* mpComments; |
||||
QLabel* mpLinksLabel; |
||||
QLabel* mpTmpLink; |
||||
UBActionPreview* mpTmpAction; |
||||
UBTBPreviewContainer* mpContentContainer; |
||||
UBTeacherBarDataMgr* mpDataMgr; |
||||
}; |
||||
|
||||
#endif // UBTEACHERBARPREVIEWWIDGET_H
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue