Dragndrop operations on w3cwidgets, some code cleaning unused files in file system

preferencesAboutTextFull
Ivan Ilin 13 years ago
parent 21e57fbc83
commit 969706ae17
  1. 8
      src/adaptors/UBSvgSubsetAdaptor.cpp
  2. 21
      src/api/UBWidgetUniboardAPI.cpp
  3. 25
      src/api/UBWidgetUniboardAPI.h
  4. 6
      src/board/UBBoardController.cpp
  5. 133
      src/board/UBBoardView.cpp
  6. 5
      src/board/UBBoardView.h
  7. 2
      src/board/UBLibraryController.cpp
  8. 3
      src/core/UBApplication.cpp
  9. 1
      src/core/UBSettings.cpp
  10. 6
      src/domain/UBGraphicsAudioItem.h
  11. 14
      src/domain/UBGraphicsMediaItem.cpp
  12. 4
      src/domain/UBGraphicsMediaItem.h
  13. 2
      src/domain/UBGraphicsPDFItem.h
  14. 1
      src/domain/UBGraphicsPixmapItem.h
  15. 2
      src/domain/UBGraphicsProxyWidget.h
  16. 2
      src/domain/UBGraphicsScene.cpp
  17. 2
      src/domain/UBGraphicsTextItem.h
  18. 6
      src/domain/UBGraphicsVideoItem.h
  19. 4
      src/domain/UBGraphicsWidgetItem.cpp
  20. 2
      src/domain/UBGraphicsWidgetItem.h
  21. 1
      src/domain/UBItem.h
  22. 17
      src/frameworks/UBCoreGraphicsScene.cpp
  23. 22
      src/frameworks/UBFileSystemUtils.cpp
  24. 2
      src/frameworks/UBFileSystemUtils.h
  25. 5
      src/gui/UBThumbnailWidget.cpp
  26. 1
      src/tools/UBGraphicsCurtainItem.h

@ -1827,13 +1827,13 @@ UBGraphicsAudioItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::audioItemFromSvg()
return 0; return 0;
} }
QString href = audioHref.toString(); QString href = mDocumentPath + "/" + audioHref.toString();
//Claudio this is necessary to fix the absolute path added on Sankore 3.1 1.00.00 //Claudio this is necessary to fix the absolute path added on Sankore 3.1 1.00.00
//The absoult path doesn't work when you want to share Sankore documents. //The absoult path doesn't work when you want to share Sankore documents.
if(!href.startsWith("audios/")){ if(!href.startsWith("audios/")){
int indexOfAudioDirectory = href.lastIndexOf("audios"); int indexOfAudioDirectory = href.lastIndexOf("audios");
href = href.right(href.length() - indexOfAudioDirectory); href = mDocumentPath + "/" + href.right(href.length() - indexOfAudioDirectory);
} }
UBGraphicsAudioItem* audioItem = new UBGraphicsAudioItem(href); UBGraphicsAudioItem* audioItem = new UBGraphicsAudioItem(href);
@ -1861,13 +1861,13 @@ UBGraphicsVideoItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::videoItemFromSvg()
return 0; return 0;
} }
QString href = videoHref.toString(); QString href = mDocumentPath + "/" + videoHref.toString();
//Claudio this is necessary to fix the absolute path added on Sankore 3.1 1.00.00 //Claudio this is necessary to fix the absolute path added on Sankore 3.1 1.00.00
//The absoult path doesn't work when you want to share Sankore documents. //The absoult path doesn't work when you want to share Sankore documents.
if(!href.startsWith("videos/")){ if(!href.startsWith("videos/")){
int indexOfAudioDirectory = href.lastIndexOf("videos"); int indexOfAudioDirectory = href.lastIndexOf("videos");
href = href.right(href.length() - indexOfAudioDirectory); href = mDocumentPath + "/" + href.right(href.length() - indexOfAudioDirectory);
} }
UBGraphicsVideoItem* videoItem = new UBGraphicsVideoItem(href); UBGraphicsVideoItem* videoItem = new UBGraphicsVideoItem(href);

@ -34,9 +34,12 @@
#include "adaptors/UBThumbnailAdaptor.h" #include "adaptors/UBThumbnailAdaptor.h"
#include "UBWidgetMessageAPI.h" #include "UBWidgetMessageAPI.h"
#include "frameworks/UBFileSystemUtils.h"
#include "core/memcheck.h" #include "core/memcheck.h"
const QString objectsPath = "objects";
UBWidgetUniboardAPI::UBWidgetUniboardAPI(UBGraphicsScene *pScene, UBGraphicsWidgetItem *widget) UBWidgetUniboardAPI::UBWidgetUniboardAPI(UBGraphicsScene *pScene, UBGraphicsWidgetItem *widget)
: QObject(pScene) : QObject(pScene)
, mScene(pScene) , mScene(pScene)
@ -433,14 +436,20 @@ void UBWidgetUniboardAPI::enableDropOnWidget()
mGraphicsWidget->setAcceptDrops(true); mGraphicsWidget->setAcceptDrops(true);
} }
QString UBWidgetUniboardAPI::downloadUrl(QString objectUrl) QString UBWidgetUniboardAPI::downloadUrl(const QString &objectUrl, const QString &extention)
{ {
qDebug() << "UBWidgetUniboardAPI : " << objectUrl; QString result;
QUrl widgetUrl = mGraphicsWidget->widgetWebView()->widgetUrl(); QUrl widgetUrl = mGraphicsWidget->widgetWebView()->widgetUrl();
QString destFileName =widgetUrl.toString()+ "/objects/" + QUuid::createUuid().toString(); QString destFileName =widgetUrl.toLocalFile() + "/objects/" + QUuid::createUuid().toString() + extention;
QFile(objectUrl).copy(destFileName);
qDebug() << "destFileName : " << destFileName; if (UBFileSystemUtils::copyFile(objectUrl, destFileName)) {
return destFileName.remove(widgetUrl.toString()); result = destFileName.remove(widgetUrl.toLocalFile());
} else {
qDebug() << "can't copy from " << widgetUrl << "to" << destFileName;
result = QString();
}
return result;
} }

@ -27,26 +27,25 @@ class UBWidgetMessageAPI;
class UBDatastoreAPI; class UBDatastoreAPI;
class UBDocumentDatastoreAPI; class UBDocumentDatastoreAPI;
class UBWidgetUniboardAPI : public QObject class UBWidgetUniboardAPI : public QObject
{ {
Q_OBJECT; Q_OBJECT
/** /**
* The number of pages in the current document * The number of pages in the current document
*/ */
Q_PROPERTY(int pageCount READ pageCount SCRIPTABLE true); Q_PROPERTY(int pageCount READ pageCount SCRIPTABLE true)
/** /**
* The page number of the current page * The page number of the current page
*/ */
Q_PROPERTY(int currentPageNumber READ currentPageNumber SCRIPTABLE true); Q_PROPERTY(int currentPageNumber READ currentPageNumber SCRIPTABLE true)
/** /**
* instance UUID, return a unique identifier for the widget, this value is guaranted to be unique * instance UUID, return a unique identifier for the widget, this value is guaranted to be unique
* and constant for a widget, deprecated, use window.widget.uuid instead * and constant for a widget, deprecated, use window.widget.uuid instead
*/ */
Q_PROPERTY(QString uuid READ uuid SCRIPTABLE true); Q_PROPERTY(QString uuid READ uuid SCRIPTABLE true)
/** /**
* Returns the language and eventually the country of this locale as a string of the form * Returns the language and eventually the country of this locale as a string of the form
@ -63,11 +62,11 @@ class UBWidgetUniboardAPI : public QObject
* fr-FR * fr-FR
* *
*/ */
Q_PROPERTY(QString lang READ lang SCRIPTABLE true); Q_PROPERTY(QString lang READ lang SCRIPTABLE true)
Q_PROPERTY(QObject* messages READ messages SCRIPTABLE true); Q_PROPERTY(QObject* messages READ messages SCRIPTABLE true)
Q_PROPERTY(QObject* datastore READ datastore SCRIPTABLE true); Q_PROPERTY(QObject* datastore READ datastore SCRIPTABLE true)
public: public:
@ -245,7 +244,7 @@ class UBWidgetUniboardAPI : public QObject
* When an object is dropped on a widget, this one send us the informations to download it locally. * When an object is dropped on a widget, this one send us the informations to download it locally.
* this method download the object on the widget directory and return the path of the downloaded object * this method download the object on the widget directory and return the path of the downloaded object
*/ */
QString downloadUrl(QString objectUrl); QString downloadUrl(const QString &objectUrl, const QString &extention = "");
private: private:
@ -272,13 +271,13 @@ class UBWidgetUniboardAPI : public QObject
class UBDatastoreAPI : public QObject class UBDatastoreAPI : public QObject
{ {
Q_OBJECT; Q_OBJECT
Q_PROPERTY(QObject* document READ document SCRIPTABLE true); Q_PROPERTY(QObject* document READ document SCRIPTABLE true)
public: public:
UBDatastoreAPI(UBGraphicsW3CWidgetItem *widget); UBDatastoreAPI(UBGraphicsW3CWidgetItem *widget);
virtual ~UBDatastoreAPI(){}; virtual ~UBDatastoreAPI(){;}
QObject* document(); QObject* document();
@ -291,7 +290,7 @@ class UBDatastoreAPI : public QObject
class UBDocumentDatastoreAPI : public UBW3CWebStorage class UBDocumentDatastoreAPI : public UBW3CWebStorage
{ {
Q_OBJECT; Q_OBJECT
public: public:
UBDocumentDatastoreAPI(UBGraphicsW3CWidgetItem *graphicsWidget); UBDocumentDatastoreAPI(UBGraphicsW3CWidgetItem *graphicsWidget);

@ -1221,7 +1221,7 @@ void UBBoardController::ClearUndoStack()
while (itUniq.hasNext()) while (itUniq.hasNext())
{ {
QGraphicsItem* item = itUniq.next(); QGraphicsItem* item = itUniq.next();
UBGraphicsScene *scene = (UBGraphicsScene*)item->scene(); UBGraphicsScene *scene = dynamic_cast<UBGraphicsScene*>(item->scene());
if(!scene) if(!scene)
{ {
mActiveScene->deleteItem(item); mActiveScene->deleteItem(item);
@ -1365,15 +1365,13 @@ void UBBoardController::documentSceneChanged(UBDocumentProxy* pDocumentProxy, in
} }
} }
void UBBoardController::closing() void UBBoardController::closing()
{ {
mIsClosing = true; mIsClosing = true;
ClearUndoStack();
lastWindowClosed(); lastWindowClosed();
} }
void UBBoardController::lastWindowClosed() void UBBoardController::lastWindowClosed()
{ {
if (!mCleanupDone) if (!mCleanupDone)

@ -15,6 +15,7 @@
#include "UBBoardView.h" #include "UBBoardView.h"
#include <QtGui> #include <QtGui>
#include <QtXml>
#include "UBDrawingController.h" #include "UBDrawingController.h"
@ -48,6 +49,24 @@
#include "core/memcheck.h" #include "core/memcheck.h"
//Known extentions for files, add if you know more supported
const QString audioExtentions = ".mp3.wma.ogg";
const QString videoExtentions = ".avi.flv";
const QString imageExtentions = ".png.jpg.tif.bmp.tga";
const QString htmlExtentions = ".htm.html.xhtml";
//Allways use aliases instead of const char* itself
const QString imageAlias = "image";
const QString videoAlias = "video";
const QString audioAlias = "audio";
const QString htmlAlias = "html";
//Xml tag names
const QString tMainSection = "mimedata";
const QString tType = "type";
const QString tPath = "path";
UBBoardView::UBBoardView (UBBoardController* pController, QWidget* pParent) UBBoardView::UBBoardView (UBBoardController* pController, QWidget* pParent)
: QGraphicsView (pParent) : QGraphicsView (pParent)
, mController (pController) , mController (pController)
@ -720,64 +739,93 @@ void UBBoardView::dragMoveEvent (QDragMoveEvent *event)
UBGraphicsWidgetItem* graphicsWidget = dynamic_cast<UBGraphicsWidgetItem*>(graphicsItemAtPos); UBGraphicsWidgetItem* graphicsWidget = dynamic_cast<UBGraphicsWidgetItem*>(graphicsItemAtPos);
if (graphicsWidget && graphicsWidget->acceptDrops()){ if (graphicsWidget && graphicsWidget->acceptDrops()){
if (isDropableData(event->mimeData())) {
QPoint newPoint(graphicsWidget->mapFromScene(mapToScene(event->pos())).toPoint()); QPoint newPoint(graphicsWidget->mapFromScene(mapToScene(event->pos())).toPoint());
QDragMoveEvent newEvent(newPoint, event->dropAction(), event->mimeData(), event->mouseButtons(), event->keyboardModifiers()); QDragMoveEvent newEvent(newPoint, event->dropAction(), event->mimeData(), event->mouseButtons(), event->keyboardModifiers());
QApplication::sendEvent(graphicsWidget->widgetWebView(),&newEvent); QApplication::sendEvent(graphicsWidget->widgetWebView(),&newEvent);
return; } else {
event->ignore();
} }
} else {
event->acceptProposedAction(); event->acceptProposedAction();
} }
QList<QUrl> UBBoardView::processMimeData(const QMimeData* pMimeData)
{
QList<QUrl> result;
if(pMimeData->hasHtml())
{
QString qsHtml = pMimeData->html();
result.append(QUrl(UBApplication::urlFromHtml(qsHtml)));
} }
if (pMimeData->hasUrls()) QString UBBoardView::processMimeData(const QMimeData *pMimeData, UBGraphicsWidgetItem *widget)
{ {
result.append(pMimeData->urls()); QString mimeXml;
return result; QXmlStreamWriter writer(&mimeXml);
} writer.setAutoFormatting(true);
writer.writeStartDocument();
writer.writeStartElement(tMainSection);
if (pMimeData->hasImage()) if (pMimeData->hasUrls()) {
{ QList<QUrl> urls = pMimeData->urls();
qWarning() << "Not supported yet";
}
if (pMimeData->hasText()) QString ext = fileExtention(urls.at(0).toLocalFile());
{ if (ext.isNull()) {
if("" != pMimeData->text()){ qDebug() << "unknown file type";
// Sometimes, it is possible to have an URL as text. we check here if it is the case return QString();
QString qsTmp = pMimeData->text().remove(QRegExp("[\\0]"));
if(qsTmp.startsWith("http")){
result.append(QUrl(qsTmp));
} }
else{ QString fileType = typeForExtention(ext);
qWarning() << "what to do with this : " << pMimeData->text(); if (fileType.isNull()) {
//mActiveScene->addText(pMimeData->text(), pPos); qDebug() << "unknown extention";
return QString();
} }
//writing type of element
writer.writeTextElement(tType, fileType);
QString fileName = urls.at(0).toLocalFile();
QString destName = widget->downloadUrl(fileName, ext);
if (destName.isNull()) {
qDebug() << "error at creating destination folder";
return QString();
}
//writing path to created object
writer.writeTextElement(tPath, destName);
} }
else{
#ifdef Q_WS_MACX writer.writeEndElement();
// With Safari, in 95% of the drops, the mime datas are hidden in Apple Web Archive pasteboard type. writer.writeEndDocument();
// This is due to the way Safari is working so we have to dig into the pasteboard in order to retrieve
// the data. return mimeXml;
QString qsUrl = UBPlatformUtils::urlFromClipboard();
if("" != qsUrl){
// We finally got the url of the dropped ressource! Let's import it!
result.append(QUrl(qsUrl));
} }
#endif
QString UBBoardView::fileExtention(const QString &filename)
{
int pos = filename.lastIndexOf(".");
if (pos != -1)
return filename.right(filename.size() - pos);
else
return QString();
} }
QString UBBoardView::typeForExtention(const QString &extention)
{
QString result = QString();
if (audioExtentions.contains(extention)) {
result = audioAlias;
} else if (videoExtentions.contains(extention)) {
result = videoAlias;
} else if (imageExtentions.contains(extention)) {
result = imageAlias;
} else if (htmlExtentions.contains(extention)) {
result = htmlAlias;
} }
return result; return result;
} }
bool UBBoardView::isDropableData(const QMimeData *pMimeData)
{
if (pMimeData->hasUrls())
if (!typeForExtention(fileExtention(pMimeData->urls().at(0).toLocalFile())).isNull())
return true;
return false;
}
void UBBoardView::dropEvent (QDropEvent *event) void UBBoardView::dropEvent (QDropEvent *event)
{ {
@ -785,21 +833,18 @@ void UBBoardView::dropEvent (QDropEvent *event)
QGraphicsItem* graphicsItemAtPos = itemAt(event->pos().x(),event->pos().y()); QGraphicsItem* graphicsItemAtPos = itemAt(event->pos().x(),event->pos().y());
UBGraphicsWidgetItem* graphicsWidget = dynamic_cast<UBGraphicsWidgetItem*>(graphicsItemAtPos); UBGraphicsWidgetItem* graphicsWidget = dynamic_cast<UBGraphicsWidgetItem*>(graphicsItemAtPos);
bool acceptDrops(false);
if (graphicsWidget) {
acceptDrops = graphicsWidget->acceptDrops();
graphicsWidget->setAcceptDrops(true);
}
if (graphicsWidget && graphicsWidget->acceptDrops()){ if (graphicsWidget && graphicsWidget->acceptDrops()){
// A new event is build to avoid problem related to different way to pass the mime type // A new event is build to avoid problem related to different way to pass the mime type
// A parsing is done to try to provide a mimeType with only urls. // A parsing is done to try to provide a mimeType with only urls.
QMimeData mimeData; QMimeData mimeData;
mimeData.setData("Text",processMimeData(event->mimeData()).at(0).toString().toAscii()); QString str = processMimeData(event->mimeData(), graphicsWidget);
mimeData.setData("text/plain", str.toAscii());
QPoint newPoint(graphicsWidget->mapFromScene(mapToScene(event->pos())).toPoint()); QPoint newPoint(graphicsWidget->mapFromScene(mapToScene(event->pos())).toPoint());
QDropEvent cleanedEvent(newPoint, event->dropAction(), &mimeData, event->mouseButtons(), event->keyboardModifiers()); QDropEvent cleanedEvent(newPoint, event->dropAction(), &mimeData, event->mouseButtons(), event->keyboardModifiers());
QApplication::sendEvent(graphicsWidget->widgetWebView(),&cleanedEvent); QApplication::sendEvent(graphicsWidget->widgetWebView(),&cleanedEvent);
cleanedEvent.acceptProposedAction(); cleanedEvent.acceptProposedAction();
event->acceptProposedAction(); event->acceptProposedAction();
return; return;
} }
if(!event->source() || dynamic_cast<UBThumbnailWidget *>(event->source()) || dynamic_cast<QWebView*>(event->source())) if(!event->source() || dynamic_cast<UBThumbnailWidget *>(event->source()) || dynamic_cast<QWebView*>(event->source()))

@ -22,6 +22,7 @@
class UBBoardController; class UBBoardController;
class UBAppleWidget; class UBAppleWidget;
class UBGraphicsScene; class UBGraphicsScene;
class UBGraphicsWidgetItem;
class UBBoardView : public QGraphicsView class UBBoardView : public QGraphicsView
{ {
@ -87,6 +88,8 @@ class UBBoardView : public QGraphicsView
} }
QList<QUrl> processMimeData(const QMimeData* pMimeData); QList<QUrl> processMimeData(const QMimeData* pMimeData);
QString processMimeData(const QMimeData *pMimeData, UBGraphicsWidgetItem *widget);
bool isDropableData(const QMimeData *pMimeData);
UBBoardController* mController; UBBoardController* mController;
@ -113,6 +116,8 @@ class UBBoardView : public QGraphicsView
bool isAbsurdPoint(QPoint point); bool isAbsurdPoint(QPoint point);
bool mVirtualKeyboardActive; bool mVirtualKeyboardActive;
QString typeForExtention(const QString &extention);
QString fileExtention(const QString &filename);
private slots: private slots:

@ -649,7 +649,7 @@ QRectF UBLibraryController::visibleSceneRect()
void UBLibraryController::addImagesToCurrentPage(const QList<QUrl>& images) void UBLibraryController::addImagesToCurrentPage(const QList<QUrl>& images)
{ {
QPointF pos = visibleSceneRect().topLeft(); QPointF pos = visibleSceneRect().center();
foreach(const QUrl url, images) foreach(const QUrl url, images)
{ {

@ -138,7 +138,8 @@ UBApplication::UBApplication(const QString &id, int &argc, char **argv) : QtSing
QTranslator *translator = new QTranslator(this); QTranslator *translator = new QTranslator(this);
translator->load(UBPlatformUtils::preferredTranslation()); // translator->load(UBPlatformUtils::preferredTranslation());
translator->load("/home/ilia/Sankore/Sankore-3.1/resources/i18n/sankore_ru.qm");
installTranslator(translator); installTranslator(translator);

@ -362,6 +362,7 @@ void UBSettings::init()
podcastPublishToIntranet = new UBSetting(this, "IntranetPodcast", "PublishToIntranet", false); podcastPublishToIntranet = new UBSetting(this, "IntranetPodcast", "PublishToIntranet", false);
intranetPodcastPublishingUrl = new UBSetting(this, "IntranetPodcast", "PublishingUrl", ""); intranetPodcastPublishingUrl = new UBSetting(this, "IntranetPodcast", "PublishingUrl", "");
intranetPodcastAuthor = new UBSetting(this, "IntranetPodcast", "Author", ""); intranetPodcastAuthor = new UBSetting(this, "IntranetPodcast", "Author", "");
} }

@ -19,6 +19,8 @@
#include "phonon/seekslider.h" #include "phonon/seekslider.h"
#include "phonon/mediasource.h" #include "phonon/mediasource.h"
#include "core/UB.h" #include "core/UB.h"
#include "core/UBApplication.h"
#include "board/UBBoardController.h"
class UBGraphicsAudioItem : public UBGraphicsMediaItem class UBGraphicsAudioItem : public UBGraphicsMediaItem
{ {
@ -39,6 +41,10 @@ public:
virtual UBItem* deepCopy () const; virtual UBItem* deepCopy () const;
virtual UBGraphicsItemDelegate *Delegate() const {return mDelegate;} virtual UBGraphicsItemDelegate *Delegate() const {return mDelegate;}
virtual void clearSource()
{
UBGraphicsMediaItem::clearSource();
}
private slots: private slots:

@ -82,6 +82,20 @@ QVariant UBGraphicsMediaItem::itemChange(GraphicsItemChange change, const QVaria
return UBGraphicsProxyWidget::itemChange(change, value); return UBGraphicsProxyWidget::itemChange(change, value);
} }
void UBGraphicsMediaItem::clearSource()
{
QString path = mediaFileUrl().path();
//if path is absolute clean duplicated path string
if (!path.contains(UBApplication::boardController->activeDocument()->persistencePath()))
path = UBApplication::boardController->activeDocument()->persistencePath() + "/" + path;
QFile f(path);
f.setPermissions(path, QFile::ReadOwner | QFile::WriteOwner);
f.remove();
}
void UBGraphicsMediaItem::toggleMute() void UBGraphicsMediaItem::toggleMute()
{ {
mMuted = !mMuted; mMuted = !mMuted;

@ -18,6 +18,8 @@
#include "UBGraphicsProxyWidget.h" #include "UBGraphicsProxyWidget.h"
#include <phonon/AudioOutput> #include <phonon/AudioOutput>
#include <phonon/MediaObject> #include <phonon/MediaObject>
#include "core/UBApplication.h"
#include "board/UBBoardController.h"
class UBGraphicsMediaItem : public UBGraphicsProxyWidget class UBGraphicsMediaItem : public UBGraphicsProxyWidget
@ -65,6 +67,8 @@ protected:
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value); virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
virtual void clearSource();
Phonon::MediaObject *mMediaObject; Phonon::MediaObject *mMediaObject;
Phonon::AudioOutput *mAudioOutput; Phonon::AudioOutput *mAudioOutput;

@ -50,6 +50,8 @@ class UBGraphicsPDFItem: public GraphicsPDFItem, public UBItem, public UBGraphic
virtual UBGraphicsPixmapItem* toPixmapItem() const; virtual UBGraphicsPixmapItem* toPixmapItem() const;
virtual UBGraphicsItemDelegate *Delegate() const {return mDelegate;} virtual UBGraphicsItemDelegate *Delegate() const {return mDelegate;}
virtual void clearSource(){;}
protected: protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);

@ -50,6 +50,7 @@ class UBGraphicsPixmapItem : public QObject, public QGraphicsPixmapItem, public
qreal opacity() const; qreal opacity() const;
virtual UBGraphicsItemDelegate* Delegate() const {return mDelegate;} virtual UBGraphicsItemDelegate* Delegate() const {return mDelegate;}
virtual void clearSource(){;}
protected: protected:

@ -43,6 +43,8 @@ class UBGraphicsProxyWidget: public QGraphicsProxyWidget, public UBItem, public
virtual UBGraphicsItemDelegate* Delegate() const { return mDelegate;} virtual UBGraphicsItemDelegate* Delegate() const { return mDelegate;}
virtual void clearSource(){;}
protected: protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);

@ -1442,13 +1442,11 @@ void UBGraphicsScene::deselectAllItems()
} }
} }
bool UBGraphicsScene::isEmpty() const bool UBGraphicsScene::isEmpty() const
{ {
return mItemCount == 0; return mItemCount == 0;
} }
QGraphicsItem* UBGraphicsScene::setAsBackgroundObject(QGraphicsItem* item, bool pAdaptTransformation, bool pExpand) QGraphicsItem* UBGraphicsScene::setAsBackgroundObject(QGraphicsItem* item, bool pAdaptTransformation, bool pExpand)
{ {
if (mBackgroundObject) if (mBackgroundObject)

@ -80,6 +80,8 @@ class UBGraphicsTextItem : public QGraphicsTextItem, public UBItem, public UBRes
} }
virtual UBGraphicsItemDelegate *Delegate() const {return mDelegate;} virtual UBGraphicsItemDelegate *Delegate() const {return mDelegate;}
virtual void clearSource(){;}
signals: signals:
void textUndoCommandAdded(UBGraphicsTextItem *textItem); void textUndoCommandAdded(UBGraphicsTextItem *textItem);

@ -18,6 +18,8 @@
#include <phonon/VideoWidget> #include <phonon/VideoWidget>
#include "UBGraphicsMediaItem.h" #include "UBGraphicsMediaItem.h"
#include "core/UB.h" #include "core/UB.h"
#include "core/UBApplication.h"
#include "board/UBBoardController.h"
class UBGraphicsVideoItem : public UBGraphicsMediaItem class UBGraphicsVideoItem : public UBGraphicsMediaItem
{ {
@ -42,6 +44,10 @@ public:
} }
virtual UBGraphicsItemDelegate *Delegate() const {return mDelegate;} virtual UBGraphicsItemDelegate *Delegate() const {return mDelegate;}
virtual void clearSource()
{
UBGraphicsMediaItem::clearSource();
}
public slots: public slots:
void hasVideoChanged(bool hasVideo); void hasVideoChanged(bool hasVideo);

@ -246,6 +246,10 @@ void UBGraphicsWidgetItem::removeScript()
mWebKitWidget->page()->mainFrame()->evaluateJavaScript("if(widget && widget.onremove) { widget.onremove();}"); mWebKitWidget->page()->mainFrame()->evaluateJavaScript("if(widget && widget.onremove) { widget.onremove();}");
} }
} }
QString UBGraphicsWidgetItem::downloadUrl(const QString &fileUrl, const QString &extention)
{
return mUniboardAPI->downloadUrl(fileUrl, extention);
}
UBGraphicsAppleWidgetItem::UBGraphicsAppleWidgetItem(const QUrl& pWidgetUrl, QGraphicsItem *parent) UBGraphicsAppleWidgetItem::UBGraphicsAppleWidgetItem(const QUrl& pWidgetUrl, QGraphicsItem *parent)
: UBGraphicsWidgetItem(parent) : UBGraphicsWidgetItem(parent)

@ -66,8 +66,10 @@ class UBGraphicsWidgetItem : public UBGraphicsProxyWidget
virtual void remove(); virtual void remove();
void removeScript(); void removeScript();
QString downloadUrl(const QString &fileUrl, const QString &extention);
virtual void clearSource(){;}
protected: protected:

@ -105,6 +105,7 @@ public:
virtual void remove() = 0; virtual void remove() = 0;
virtual void clearSource(){;}
}; };
#endif // UBITEM_H #endif // UBITEM_H

@ -16,6 +16,9 @@
#include "UBCoreGraphicsScene.h" #include "UBCoreGraphicsScene.h"
#include "core/memcheck.h" #include "core/memcheck.h"
#include "domain/UBGraphicsAudioItem.h"
#include "domain/UBGraphicsVideoItem.h"
#include "domain/UBGraphicsMediaItem.h"
UBCoreGraphicsScene::UBCoreGraphicsScene(QObject * parent) UBCoreGraphicsScene::UBCoreGraphicsScene(QObject * parent)
: QGraphicsScene ( parent ) : QGraphicsScene ( parent )
@ -58,6 +61,20 @@ bool UBCoreGraphicsScene::deleteItem(QGraphicsItem* item)
{ {
if(mItemsToDelete.contains(item)) if(mItemsToDelete.contains(item))
{ {
UBGraphicsItem* item_casted = 0;
switch (item->type())
{
case UBGraphicsAudioItem::Type:
item_casted = dynamic_cast<UBGraphicsAudioItem*>(item);
break;
case UBGraphicsVideoItem::Type:
item_casted = dynamic_cast<UBGraphicsVideoItem*>(item);
break;
}
if (0 != item_casted)
item_casted->clearSource();
mItemsToDelete.remove(item); mItemsToDelete.remove(item);
delete item; delete item;
return true; return true;

@ -54,6 +54,28 @@ bool UBFileSystemUtils::isAZipFile(QString &filePath)
return result; return result;
} }
bool UBFileSystemUtils::copyFile(const QString &source, const QString &Destination, bool overwrite)
{
if (!QFile::exists(source)) {
qDebug() << "file" << source << "does not present in fs";
return false;
}
if (QFile::exists(Destination)) {
if (QFileInfo(Destination).isFile() && overwrite) {
QFile::remove(Destination);
}
} else {
int pos = Destination.lastIndexOf(QDir::separator());
if (pos != -1) {
QString newpath = Destination.left(pos);
if (!QDir().mkpath(newpath)) {
qDebug() << "can't create a new path at " << newpath;
}
}
}
return QFile::copy(source, Destination);
}
QString UBFileSystemUtils::defaultTempDirPath() QString UBFileSystemUtils::defaultTempDirPath()
{ {
return QDesktopServices::storageLocation(QDesktopServices::TempLocation) + "/" + defaultTempDirName(); return QDesktopServices::storageLocation(QDesktopServices::TempLocation) + "/" + defaultTempDirName();

@ -65,6 +65,8 @@ class UBFileSystemUtils
static bool isAZipFile(QString &filePath); static bool isAZipFile(QString &filePath);
static bool copyFile(const QString &source, const QString &Destination, bool overwrite = false);
/** /**
* Compress a source directory in a zip file. * Compress a source directory in a zip file.
* @arg pDir the directory to add in zip * @arg pDir the directory to add in zip

@ -383,11 +383,8 @@ void UBThumbnailWidget::mouseReleaseEvent(QMouseEvent *event)
deleteLasso(); deleteLasso();
QGraphicsView::mouseReleaseEvent(event); QGraphicsView::mouseReleaseEvent(event);
if(elapsedTimeSincePress < STARTDRAGTIME) if(elapsedTimeSincePress < STARTDRAGTIME) {
{
if(!bSelectionInProgress)
emit mouseClick(itemAt(event->pos()), 0); emit mouseClick(itemAt(event->pos()), 0);
bSelectionInProgress = false;
} }
} }

@ -48,6 +48,7 @@ class UBGraphicsCurtainItem : public QObject, public QGraphicsRectItem, public U
//TODO UB 4.x not nice ... //TODO UB 4.x not nice ...
void triggerRemovedSignal(); void triggerRemovedSignal();
virtual UBGraphicsItemDelegate* Delegate() const {return mDelegate;} virtual UBGraphicsItemDelegate* Delegate() const {return mDelegate;}
virtual void clearSource(){};
signals: signals:

Loading…
Cancel
Save