add import for lessons pages

preferencesAboutTextFull
Claudio Valerio 13 years ago
parent 201bcc33dd
commit 66db929290
  1. 58
      src/adaptors/UBSvgSubsetAdaptor.cpp
  2. 9
      src/adaptors/UBSvgSubsetAdaptor.h
  3. 90
      src/gui/UBTeacherGuideWidget.cpp
  4. 13
      src/gui/UBTeacherGuideWidget.h
  5. 89
      src/gui/UBTeacherGuideWidgetsTools.cpp
  6. 11
      src/gui/UBTeacherGuideWidgetsTools.h
  7. 8
      src/interfaces/IDataStorage.h

@ -53,6 +53,8 @@
#include "core/UBPersistenceManager.h"
#include "core/UBApplication.h"
#include "interfaces/IDataStorage.h"
#include "pdf/PDFRenderer.h"
#include "core/memcheck.h"
@ -68,6 +70,15 @@ const QString UBSvgSubsetAdaptor::sPixelUnit = "px";
const QString UBSvgSubsetAdaptor::sFontWeightPrefix = "font-weight:";
const QString UBSvgSubsetAdaptor::sFontStylePrefix = "font-style:";
const QString UBSvgSubsetAdaptor::sFormerUniboardDocumentNamespaceUri = "http://www.mnemis.com/uniboard";
QMap<QString,IDataStorage*> UBSvgSubsetAdaptor::additionalElementToStore;
// Why using such a string?
// Media file path are relative to the current document. So if we are reading the
// first page of a document the document path has not been updated.
// Concatenate relative media path with the old document path leads to mess
// This string is so used only for activeDocumentChanged signal
QString UBSvgSubsetAdaptor::sTeacherGuideNode = "";
@ -133,8 +144,7 @@ void UBSvgSubsetAdaptor::upgradeScene(UBDocumentProxy* proxy, const int pageInde
QDomDocument UBSvgSubsetAdaptor::loadSceneDocument(UBDocumentProxy* proxy, const int pPageIndex)
{
QString fileName = proxy->persistencePath() +
UBFileSystemUtils::digitFileFormat("/page%1.svg", pPageIndex + 1);
QString fileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg", UBApplication::boardController->pageFromSceneIndex(pPageIndex));
QFile file(fileName);
QDomDocument doc("page");
@ -157,8 +167,7 @@ QDomDocument UBSvgSubsetAdaptor::loadSceneDocument(UBDocumentProxy* proxy, const
void UBSvgSubsetAdaptor::setSceneUuid(UBDocumentProxy* proxy, const int pageIndex, QUuid pUuid)
{
QString fileName = proxy->persistencePath() +
UBFileSystemUtils::digitFileFormat("/page%1.svg", pageIndex + 1);
QString fileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg", UBApplication::boardController->pageFromSceneIndex(pageIndex));
QFile file(fileName);
@ -207,6 +216,16 @@ void UBSvgSubsetAdaptor::setSceneUuid(UBDocumentProxy* proxy, const int pageInde
}
}
bool UBSvgSubsetAdaptor::addElementToBeStored(QString domName, IDataStorage *dataStorageClass)
{
if(domName.isEmpty() || additionalElementToStore.contains(domName)){
qWarning() << "Error adding the element that should persist";
return false;
}
additionalElementToStore.insert(domName,dataStorageClass);
return true;
}
QString UBSvgSubsetAdaptor::uniboardDocumentNamespaceUriFromVersion(int mFileVersion)
{
@ -216,8 +235,7 @@ QString UBSvgSubsetAdaptor::uniboardDocumentNamespaceUriFromVersion(int mFileVer
UBGraphicsScene* UBSvgSubsetAdaptor::loadScene(UBDocumentProxy* proxy, const int pageIndex)
{
QString fileName = proxy->persistencePath() +
UBFileSystemUtils::digitFileFormat("/page%1.svg", pageIndex + 1);
QString fileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg", UBApplication::boardController->pageFromSceneIndex(pageIndex));
QFile file(fileName);
@ -243,7 +261,7 @@ UBGraphicsScene* UBSvgSubsetAdaptor::loadScene(UBDocumentProxy* proxy, const int
QUuid UBSvgSubsetAdaptor::sceneUuid(UBDocumentProxy* proxy, const int pageIndex)
{
QString fileName = proxy->persistencePath() +
UBFileSystemUtils::digitFileFormat("/page%1.svg", pageIndex + 1);
UBFileSystemUtils::digitFileFormat("/page%1.svg", UBApplication::boardController->pageFromSceneIndex(pageIndex));
QFile file(fileName);
@ -709,7 +727,7 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
UBGraphicsItem::assignZValue(triangle, zFromSvg);
}
}
else if(mXmlReader.name() == "cache")
else if (mXmlReader.name() == "cache")
{
UBGraphicsCache* cache = cacheFromSvg();
if(cache)
@ -830,6 +848,18 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
currentWidget->setDatastoreEntry(key, value);
}
else if (mXmlReader.name() == "teacherBar" || mXmlReader.name() == "teacherGuide"){
sTeacherGuideNode.clear();
sTeacherGuideNode += "<teacherGuide version=\"" + mXmlReader.attributes().value("version").toString() + "\">";
sTeacherGuideNode += "\n";
}
else if (mXmlReader.name() == "media" || mXmlReader.name() == "link" || mXmlReader.name() == "title" || mXmlReader.name() == "comment" || mXmlReader.name() == "action")
{
sTeacherGuideNode += "<" + mXmlReader.name().toString() + " ";
foreach(QXmlStreamAttribute attribute, mXmlReader.attributes())
sTeacherGuideNode += attribute.name().toString() + "=\"" + attribute.value().toString() + "\" ";
sTeacherGuideNode += " />\n";
}
else
{
// NOOP
@ -853,6 +883,14 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
mGroupDarkBackgroundColor = QColor();
mGroupLightBackgroundColor = QColor();
}
else if (mXmlReader.name() == "teacherBar" || mXmlReader.name() == "teacherGuide"){
sTeacherGuideNode += "</teacherGuide>";
QMap<QString,IDataStorage*> elements = getAdditionalElementToStore();
IDataStorage* storageClass = elements.value("teacherGuide");
if(storageClass){
storageClass->load(sTeacherGuideNode);
}
}
}
}
@ -1152,7 +1190,7 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene()
}
mXmlWriter.writeEndDocument();
QString fileName = mDocumentPath + UBFileSystemUtils::digitFileFormat("/page%1.svg", mPageIndex + 1);
QString fileName = mDocumentPath + UBFileSystemUtils::digitFileFormat("/page%1.svg", UBApplication::boardController->pageFromSceneIndex(mPageIndex));
QFile file(fileName);
if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate))
@ -1167,7 +1205,7 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene()
}
else
{
qDebug() << "ignoring unmodified page" << mPageIndex + 1;
qDebug() << "ignoring unmodified page" << UBApplication::boardController->pageFromSceneIndex(mPageIndex);
}
return true;

@ -41,6 +41,7 @@ class UBGraphicsStroke;
class UBPersistenceManager;
class UBGraphicsTriangle;
class UBGraphicsCache;
class IDataStorage;
class UBSvgSubsetAdaptor
{
@ -58,9 +59,14 @@ class UBSvgSubsetAdaptor
static QUuid sceneUuid(UBDocumentProxy* proxy, const int pageIndex);
static void setSceneUuid(UBDocumentProxy* proxy, const int pageIndex, QUuid pUuid);
static bool addElementToBeStored(QString domName,IDataStorage* dataStorageClass);
static void convertPDFObjectsToImages(UBDocumentProxy* proxy);
static void convertSvgImagesToImages(UBDocumentProxy* proxy);
static QMap<QString,IDataStorage*> getAdditionalElementToStore() { return additionalElementToStore;}
static QString sTeacherGuideNode;
static const QString nsSvg;
static const QString nsXLink;
static const QString nsXHtml;
@ -86,6 +92,9 @@ class UBSvgSubsetAdaptor
static QString toSvgTransform(const QMatrix& matrix);
static QMatrix fromSvgTransform(const QString& transform);
static QMap<QString,IDataStorage*> additionalElementToStore;
class UBSvgSubsetReader
{
public:

@ -23,6 +23,8 @@
#include "UBTeacherGuideWidget.h"
#include "adaptors/UBSvgSubsetAdaptor.h"
#include "core/UBApplication.h"
#include "core/UBPersistenceManager.h"
#include "core/UBSettings.h"
@ -79,10 +81,12 @@ UBTeacherGuideEditionWidget::UBTeacherGuideEditionWidget(QWidget *parent, const
mpPageNumberLabel->setObjectName("UBTGPageNumberLabel");
mpLayout->addWidget(mpPageNumberLabel);
// tree basic configuration
if(UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool()){
mpDocumentTitle = new QLabel(this);
mpDocumentTitle->setText("Document title");
mpDocumentTitle->setObjectName("UBTGEditionDocumentTitle");
mpDocumentTitle->setObjectName("UBTGPresentationDocumentTitle");
mpLayout->addWidget(mpDocumentTitle);
}
mpPageTitle = new UBTGAdaptableText(0,this);
mpPageTitle->setObjectName("UBTGEditionPageTitle");
@ -124,6 +128,11 @@ UBTeacherGuideEditionWidget::UBTeacherGuideEditionWidget(QWidget *parent, const
mpRootWidgetItem->addChild(mpAddAnActionItem);
mpRootWidgetItem->addChild(mpAddAMediaItem);
mpRootWidgetItem->addChild(mpAddALinkItem);
if(UBSettings::settings()->teacherGuideLessonPagesActivated->get().toBool()){
UBSvgSubsetAdaptor::addElementToBeStored(QString("teacherGuide"),this);
connect(UBApplication::boardController,SIGNAL(activeDocumentChanged()),this,SLOT(onActiveDocumentChanged()));
}
}
UBTeacherGuideEditionWidget::~UBTeacherGuideEditionWidget()
@ -142,16 +151,52 @@ UBTeacherGuideEditionWidget::~UBTeacherGuideEditionWidget()
void UBTeacherGuideEditionWidget::showEvent(QShowEvent* event)
{
mpPageTitle->setFocus();
mpComment->setFocus();
// mpPageTitle->setFocus();
// mpComment->setFocus();
setFocus();
QWidget::showEvent(event);
}
void UBTeacherGuideEditionWidget::onActiveSceneChanged()
void UBTeacherGuideEditionWidget::onActiveDocumentChanged()
{
load(UBSvgSubsetAdaptor::sTeacherGuideNode);
}
void UBTeacherGuideEditionWidget::load(QString element)
{
cleanData();
QDomDocument doc("TeacherGuide");
doc.setContent(element);
for(QDomElement element = doc.documentElement().firstChildElement(); !element.isNull(); element = element.nextSiblingElement()) {
QString tagName = element.tagName();
if(tagName == "title")
mpPageTitle->setInitialText(element.attribute("value"));
else if(tagName == "comment")
mpComment->setInitialText(element.attribute("value"));
else if(tagName == "media")
onAddItemClicked(mpAddAMediaItem,0,&element);
else if(tagName == "link")
onAddItemClicked(mpAddALinkItem,0,&element);
else if(tagName == "action")
onAddItemClicked(mpAddAnActionItem,0,&element);
}
}
QDomElement* UBTeacherGuideEditionWidget::save(QDomElement* parentElement)
{
qDebug() << parentElement;
return 0;
}
void UBTeacherGuideEditionWidget::onActiveSceneChanged()
{
mpPageNumberLabel->setText(tr("Page: %0").arg(UBApplication::boardController->currentPage()));
UBDocumentProxy* documentProxy = UBApplication::boardController->activeDocument();
if(mpDocumentTitle)
mpDocumentTitle->setText(documentProxy->metaData(UBSettings::sessionTitle).toString());
}
void UBTeacherGuideEditionWidget::cleanData()
@ -165,7 +210,6 @@ void UBTeacherGuideEditionWidget::cleanData()
foreach(QTreeWidgetItem* item, children){
DELETEPTR(item);
}
}
QList<QTreeWidgetItem*> UBTeacherGuideEditionWidget::getChildrenList(QTreeWidgetItem* widgetItem)
@ -206,7 +250,7 @@ QVector<tUBGEElementNode*> UBTeacherGuideEditionWidget::getData()
return result;
}
void UBTeacherGuideEditionWidget::onAddItemClicked(QTreeWidgetItem* widget, int column)
void UBTeacherGuideEditionWidget::onAddItemClicked(QTreeWidgetItem* widget, int column, QDomElement *element)
{
int addSubItemWidgetType = widget->data(column,Qt::UserRole).toInt();
if(addSubItemWidgetType != eUBTGAddSubItemWidgetType_None){
@ -217,15 +261,24 @@ void UBTeacherGuideEditionWidget::onAddItemClicked(QTreeWidgetItem* widget, int
switch(addSubItemWidgetType)
{
case eUBTGAddSubItemWidgetType_Action:
mpTreeWidget->setItemWidget(newWidgetItem,0,new UBTGActionWidget(widget));
case eUBTGAddSubItemWidgetType_Action:{
UBTGActionWidget* actionWidget = new UBTGActionWidget(widget);
if(element) actionWidget->initializeWithDom(*element);
mpTreeWidget->setItemWidget(newWidgetItem,0,actionWidget);
break;
case eUBTGAddSubItemWidgetType_Media:
mpTreeWidget->setItemWidget(newWidgetItem,0,new UBTGMediaWidget(widget));
}
case eUBTGAddSubItemWidgetType_Media:{
UBTGMediaWidget* mediaWidget = new UBTGMediaWidget(widget);
if(element) mediaWidget->initializeWithDom(*element);
mpTreeWidget->setItemWidget(newWidgetItem,0,mediaWidget);
break;
case eUBTGAddSubItemWidgetType_Url:
mpTreeWidget->setItemWidget(newWidgetItem,0,new UBTGUrlWidget());
}
case eUBTGAddSubItemWidgetType_Url:{
UBTGUrlWidget* urlWidget = new UBTGUrlWidget();
if(element) urlWidget->initializeWithDom(*element);
mpTreeWidget->setItemWidget(newWidgetItem,0,urlWidget);
break;
}
default:
delete newWidgetItem;
qCritical() << "onAddItemClicked no action set";
@ -296,13 +349,13 @@ UBTeacherGuidePresentationWidget::UBTeacherGuidePresentationWidget(QWidget *pare
mpModePushButton->installEventFilter(this);
connect(mpModePushButton,SIGNAL(clicked()),parentWidget(),SLOT(changeMode()));
mpButtonTitleLayout->addWidget(mpModePushButton);
if(UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool()){
mpDocumentTitle = new QLabel(this);
mpDocumentTitle->setObjectName("UBTGPresentationDocumentTitle");
mpDocumentTitle->setText(tr("Document title"));
mpButtonTitleLayout->addWidget(mpModePushButton);
mpButtonTitleLayout->addWidget(mpDocumentTitle);
}
mpLayout->addLayout(mpButtonTitleLayout);
@ -376,14 +429,15 @@ void UBTeacherGuidePresentationWidget::onActiveSceneChanged()
{
cleanData();
mpPageNumberLabel->setText(tr("Page: %0").arg(UBApplication::boardController->currentPage()));
UBDocumentProxy* documentProxy = UBApplication::boardController->activeDocument();
if(mpDocumentTitle)
mpDocumentTitle->setText(documentProxy->metaData(UBSettings::sessionTitle).toString());
}
void UBTeacherGuidePresentationWidget::createMediaButtonItem()
{
if(!mpMediaSwitchItem){
//create the media button
mpMediaSwitchItem = new QTreeWidgetItem(mpRootWidgetItem);
//mpMediaSwitchItem->setIcon(0,QIcon(":images/plus.svg"));
mpMediaSwitchItem->setText(0,"+");
mpMediaSwitchItem->setExpanded(false);
mpMediaSwitchItem->setData(0,tUBTGTreeWidgetItemRole_HasAnAction,tUBTGActionAssociateOnClickItem_EXPAND);

@ -23,8 +23,11 @@ class QVBoxLayout;
class QPushButton;
class UBDocumentProxy;
#include "UBTeacherGuideWidgetsTools.h"
#include "interfaces/IDataStorage.h"
typedef enum
{
tUBTGZeroPageMode_EDITION,
@ -34,7 +37,7 @@ typedef enum
/***************************************************************************
* class UBTeacherGuideEditionWidget *
***************************************************************************/
class UBTeacherGuideEditionWidget : public QWidget
class UBTeacherGuideEditionWidget : public QWidget , public IDataStorage
{
Q_OBJECT
public:
@ -43,8 +46,11 @@ public:
void cleanData();
QVector<tUBGEElementNode*> getData();
void load(QString element);
QDomElement* save(QDomElement* parentElement);
public slots:
void onAddItemClicked(QTreeWidgetItem* widget, int column);
void onAddItemClicked(QTreeWidgetItem* widget, int column, QDomElement* element = 0);
void onActiveSceneChanged();
void showEvent(QShowEvent* event);
@ -64,6 +70,9 @@ private:
UBAddItem* mpAddAMediaItem;
UBAddItem* mpAddALinkItem;
private slots:
void onActiveDocumentChanged();
};

@ -26,6 +26,9 @@
#include "UBTeacherGuideWidgetsTools.h"
#include "core/UBPersistenceManager.h"
#include "core/UBApplication.h"
#include "board/UBBoardController.h"
#include "domain/UBW3CWidget.h"
@ -87,6 +90,11 @@ UBTGActionWidget::~UBTGActionWidget()
DELETEPTR(mpLayout);
}
void UBTGActionWidget::initializeWithDom(QDomElement element)
{
mpOwner->setCurrentIndex(element.attribute("owner").toInt());
mpTask->setInitialText(element.attribute("task"));
}
tUBGEElementNode* UBTGActionWidget::saveData()
{
@ -195,6 +203,12 @@ void UBTGAdaptableText::onTextChanged()
}
mIsUpdatingSize = false;
}
void UBTGAdaptableText::setInitialText(const QString& text)
{
setText(text);
setReadOnly(false);
onTextChanged();
}
void UBTGAdaptableText::showText(const QString & text)
{
@ -266,8 +280,9 @@ UBTGMediaWidget::UBTGMediaWidget(QTreeWidgetItem* widget, QWidget* parent,const
, mpMediaLabelWidget(NULL)
, mpMediaWidget(NULL)
, mpWebView(NULL)
, mRelativePath(QString(""))
, mMediaPath(QString(""))
, mIsPresentationMode(false)
, mIsInitializationMode(false)
{
setObjectName(name);
mpDropMeWidget = new QLabel();
@ -280,7 +295,7 @@ UBTGMediaWidget::UBTGMediaWidget(QTreeWidgetItem* widget, QWidget* parent,const
setMinimumHeight(250);
}
UBTGMediaWidget::UBTGMediaWidget(QString relativePath, QTreeWidgetItem* widget, QWidget* parent,const char* name): QStackedWidget(parent)
UBTGMediaWidget::UBTGMediaWidget(QString mediaPath, QTreeWidgetItem* widget, QWidget* parent,const char* name): QStackedWidget(parent)
, mpTreeWidgetItem(widget)
, mpDropMeWidget(NULL)
, mpWorkWidget(NULL)
@ -289,13 +304,14 @@ UBTGMediaWidget::UBTGMediaWidget(QString relativePath, QTreeWidgetItem* widget,
, mpMediaLabelWidget(NULL)
, mpMediaWidget(NULL)
, mpWebView(NULL)
, mRelativePath(relativePath)
, mMediaPath(mediaPath)
, mIsPresentationMode(true)
, mMediaType("")
, mIsInitializationMode(false)
{
setObjectName(name);
setAcceptDrops(false);
createWorkWidget(mRelativePath);
createWorkWidget();
setFixedHeight(200);
}
@ -313,6 +329,17 @@ UBTGMediaWidget::~UBTGMediaWidget()
DELETEPTR(mpWorkWidget);
}
void UBTGMediaWidget::initializeWithDom(QDomElement element)
{
mIsInitializationMode = true;
setAcceptDrops(false);
mMediaPath = UBApplication::boardController->activeDocument()->persistencePath() + "/" + element.attribute("relativePath");
createWorkWidget();
setFixedHeight(200);
mpTitle->setInitialText(element.attribute("title"));
mIsInitializationMode = false;
}
void UBTGMediaWidget::hideEvent(QHideEvent* event)
{
if(mpWebView)
@ -323,10 +350,8 @@ void UBTGMediaWidget::hideEvent(QHideEvent* event)
void UBTGMediaWidget::showEvent(QShowEvent* event)
{
QWidget::showEvent(event);
if(mpWebView){
qDebug() << mRelativePath;
mpWebView->load(QUrl(mRelativePath + "/index.htm"));
}
if(mpWebView)
mpWebView->load(QUrl(mMediaPath + "/index.htm"));
}
tUBGEElementNode* UBTGMediaWidget::saveData()
@ -336,7 +361,7 @@ tUBGEElementNode* UBTGMediaWidget::saveData()
tUBGEElementNode* result = new tUBGEElementNode();
result->type = "media";
result->attributes.insert("title",mpTitle->text());
result->attributes.insert("relativePath",mRelativePath);
result->attributes.insert("relativePath",mMediaPath);
result->attributes.insert("mediaType",mMediaType);
return result;
}
@ -346,31 +371,40 @@ void UBTGMediaWidget::dragEnterEvent(QDragEnterEvent *event)
event->accept();
}
void UBTGMediaWidget::createWorkWidget(QString& path)
void UBTGMediaWidget::createWorkWidget()
{
QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(path);
QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(mMediaPath);
bool setMedia = true;
mRelativePath = path;
UBDocumentProxy* proxyDocument = UBApplication::boardController->activeDocument();
if(mimeType.contains("audio") || mimeType.contains("video")){
mMediaType = mimeType.contains("audio")? "audio":"movie";
mpMediaWidget = new UBMediaWidget(mimeType.contains("audio")?eMediaType_Audio:eMediaType_Video);
mpMediaWidget->setFile(path);
if(mIsPresentationMode || mIsInitializationMode){
mpMediaWidget->setFile(mMediaPath);
}
else{
mMediaPath = UBPersistenceManager::persistenceManager()->addObjectToTeacherGuideDirectory(proxyDocument, mMediaPath);
mpMediaWidget->setFile(mMediaPath);
}
}
else if(mimeType.contains("image")){
mMediaType = "image";
if(!(mIsPresentationMode || mIsInitializationMode))
mMediaPath = UBPersistenceManager::persistenceManager()->addObjectToTeacherGuideDirectory(proxyDocument, mMediaPath);
mpMediaLabelWidget = new QLabel();
QPixmap pixmap = QPixmap(QUrl(path).toLocalFile());
QPixmap pixmap = QPixmap(mMediaPath);
pixmap = pixmap.scaledToWidth(mpTreeWidgetItem->treeWidget()->size().width());
mpMediaLabelWidget->setPixmap(pixmap);
mpMediaLabelWidget->setScaledContents(true);
}
else if(mimeType.contains("application")){
mMediaType = "w3c";
if(!mIsPresentationMode){
QDir baseW3CDirectory("/home/claudio");
mRelativePath = UBW3CWidget::createNPAPIWrapperInDir(path,baseW3CDirectory,mimeType,QSize(100,100),"flashahaha");
if(!(mIsPresentationMode || mIsInitializationMode)){
QDir baseW3CDirectory(UBPersistenceManager::persistenceManager()->teacherGuideAbsoluteObjectPath(proxyDocument));
mMediaPath = UBW3CWidget::createNPAPIWrapperInDir(mMediaPath,baseW3CDirectory,mimeType,QSize(100,100),QUuid::createUuid());
}
mpWebView = new UBDraggableWeb(mRelativePath);
mpWebView = new UBDraggableWeb(mMediaPath);
mpWebView->setAcceptDrops(false);
mpWebView->settings()->setAttribute(QWebSettings::JavaEnabled, true);
mpWebView->settings()->setAttribute(QWebSettings::PluginsEnabled, true);
@ -380,7 +414,7 @@ void UBTGMediaWidget::createWorkWidget(QString& path)
mpWebView->settings()->setAttribute(QWebSettings::JavascriptCanAccessClipboard, true);
mpWebView->settings()->setAttribute(QWebSettings::DnsPrefetchEnabled, true);
mpWebView->load(QUrl(mRelativePath+"/index.htm"));
mpWebView->load(QUrl(mMediaPath+"/index.htm"));
}
else{
qDebug() << "createWorkWidget mime type not handled" << mimeType;
@ -420,13 +454,12 @@ void UBTGMediaWidget::createWorkWidget(QString& path)
void UBTGMediaWidget::parseMimeData(const QMimeData* pMimeData)
{
QString path;
if(pMimeData){
if(pMimeData->hasText()){
path = QUrl::fromLocalFile(pMimeData->text()).toString();
mMediaPath = QUrl::fromLocalFile(pMimeData->text()).toString();
}
else if(pMimeData->hasUrls()){
path = pMimeData->urls().at(0).toString();
mMediaPath = pMimeData->urls().at(0).toString();
}
else if(pMimeData->hasImage()){
qDebug() << "Not yet implemented";
@ -435,7 +468,7 @@ void UBTGMediaWidget::parseMimeData(const QMimeData* pMimeData)
else
qDebug() << "No mime data present";
createWorkWidget(path);
createWorkWidget();
}
void UBTGMediaWidget::dropEvent(QDropEvent* event)
@ -451,9 +484,9 @@ void UBTGMediaWidget::mousePressEvent(QMouseEvent *event)
else{
QDrag *drag = new QDrag(this);
QMimeData *mimeData = new QMimeData;
QMimeData *mimeData = new QMimeData();
QList<QUrl> urlList;
urlList << QUrl(mRelativePath);
urlList << QUrl(mMediaPath);
mimeData->setUrls(urlList);
drag->setMimeData(mimeData);
@ -490,6 +523,12 @@ UBTGUrlWidget::~UBTGUrlWidget()
DELETEPTR(mpLayout);
}
void UBTGUrlWidget::initializeWithDom(QDomElement element)
{
mpTitle->setText(element.attribute("title"));
mpUrl->setText(element.attribute("url"));
}
tUBGEElementNode* UBTGUrlWidget::saveData()
{
tUBGEElementNode* result = new tUBGEElementNode();

@ -74,6 +74,7 @@ public:
~UBTGActionWidget();
void update();
tUBGEElementNode* saveData();
void initializeWithDom(QDomElement element);
private:
QVBoxLayout* mpLayout;
@ -94,6 +95,7 @@ public:
void bottomMargin(int newValue);
void setPlaceHolderText(QString text);
QString text();
void setInitialText(const QString& text);
public slots:
void onTextChanged();
@ -134,9 +136,10 @@ class UBTGMediaWidget : public QStackedWidget , public iUBTGSaveData
Q_OBJECT
public:
UBTGMediaWidget(QTreeWidgetItem* widget = 0, QWidget* parent = 0, const char* name = "UBTGMediaWidget");
UBTGMediaWidget(QString relativePath, QTreeWidgetItem* widget = 0, QWidget* parent = 0, const char* name = "UBTGMediaWidget");
UBTGMediaWidget(QString mediaPath, QTreeWidgetItem* widget = 0, QWidget* parent = 0, const char* name = "UBTGMediaWidget");
~UBTGMediaWidget();
tUBGEElementNode* saveData();
void initializeWithDom(QDomElement element);
protected:
void dragEnterEvent(QDragEnterEvent* event);
@ -147,7 +150,7 @@ protected:
private:
void parseMimeData(const QMimeData* pMimeData);
void createWorkWidget(QString& path);
void createWorkWidget();
void updateSize();
QTreeWidgetItem* mpTreeWidgetItem;
@ -158,9 +161,10 @@ private:
QLabel* mpMediaLabelWidget;
UBMediaWidget* mpMediaWidget;
UBDraggableWeb* mpWebView;
QString mRelativePath;
QString mMediaPath;
bool mIsPresentationMode;
QString mMediaType;
bool mIsInitializationMode;
};
@ -171,6 +175,7 @@ public:
UBTGUrlWidget(QWidget* parent = 0, const char* name = "UBTGUrlWidget");
~UBTGUrlWidget();
tUBGEElementNode* saveData();
void initializeWithDom(QDomElement element);
private:
QVBoxLayout* mpLayout;
QLineEdit* mpTitle;

@ -16,4 +16,12 @@
#ifndef IDATASTORAGE_H
#define IDATASTORAGE_H
class QDomElement;
class IDataStorage
{
public:
virtual void load(QString element) = 0;
virtual QDomElement* save(QDomElement* parentElement) = 0 ;
};
#endif // IDATASTORAGE_H

Loading…
Cancel
Save