First working shot.

UBToolWidget API has been deactivated, there is certainly a lot of bugs, code is ugly.
Remember to fix commented sections (forgotten which ones).
preferencesAboutTextFull
Guillaume Burel 13 years ago
parent 371496178f
commit f79b28a891
  1. 4
      src/adaptors/publishing/UBDocumentPublisher.cpp
  2. 26
      src/api/UBW3CWidgetAPI.cpp
  3. 2
      src/api/UBW3CWidgetAPI.h
  4. 2
      src/api/UBWidgetMessageAPI.cpp
  5. 8
      src/api/UBWidgetUniboardAPI.cpp
  6. 2
      src/api/UBWidgetUniboardAPI.h
  7. 5
      src/domain/UBGraphicsWebView.cpp
  8. 4
      src/domain/UBGraphicsWidgetItem.cpp
  9. 30
      src/domain/UBGraphicsWidgetItem.h
  10. 4
      src/gui/UBToolWidget.cpp

@ -301,7 +301,7 @@ void UBDocumentPublisher::upgradeDocumentForPublishing()
QString startFile = widget->mainHtmlFileName(); QString startFile = widget->mainHtmlFileName();
jsonFile.write(QString(" \"startFile\": \"%1\",\n").arg(startFile).toUtf8()); jsonFile.write(QString(" \"startFile\": \"%1\",\n").arg(startFile).toUtf8());
QMap<QString, QString> preferences = widget->preferences(); QMap<QString, QString> preferences = widget->UBGraphicsWidgetItem::preferences();
jsonFile.write(QString(" \"preferences\": {\n").toUtf8()); jsonFile.write(QString(" \"preferences\": {\n").toUtf8());
@ -360,7 +360,7 @@ void UBDocumentPublisher::upgradeDocumentForPublishing()
void UBDocumentPublisher::generateWidgetPropertyScript(UBGraphicsW3CWidgetItem *widgetItem, int pageNumber) void UBDocumentPublisher::generateWidgetPropertyScript(UBGraphicsW3CWidgetItem *widgetItem, int pageNumber)
{ {
QMap<QString, QString> preferences = widgetItem->preferences(); QMap<QString, QString> preferences = widgetItem->UBGraphicsWidgetItem::preferences();
QMap<QString, QString> datastoreEntries = widgetItem->datastoreEntries(); QMap<QString, QString> datastoreEntries = widgetItem->datastoreEntries();
QString startFileName = widgetItem->mainHtmlFileName(); QString startFileName = widgetItem->mainHtmlFileName();

@ -118,7 +118,7 @@ void UBW3CWidgetAPI::openURL(const QString& url)
} }
UBW3CWidgetPreferenceAPI::UBW3CWidgetPreferenceAPI(UBGraphicsW3CWidgetItem *graphicsWidget, QOBject *parent) UBW3CWidgetPreferenceAPI::UBW3CWidgetPreferenceAPI(UBGraphicsW3CWidgetItem *graphicsWidget, QObject *parent)
: UBW3CWebStorage(parent) : UBW3CWebStorage(parent)
, mGraphicsW3CWidget(graphicsWidget) , mGraphicsW3CWidget(graphicsWidget)
{ {
@ -133,7 +133,7 @@ UBW3CWidgetPreferenceAPI::~UBW3CWidgetPreferenceAPI()
QString UBW3CWidgetPreferenceAPI::key(int index) QString UBW3CWidgetPreferenceAPI::key(int index)
{ {
QMap<QString, UBGraphicsWidgetItem::PreferenceValue> w3CPrefs = mGraphicsW3CWidget->preferences(); QMap<QString, UBGraphicsW3CWidgetItem::PreferenceValue> w3CPrefs = mGraphicsW3CWidget->preferences();
if (index < w3CPrefs.size()) if (index < w3CPrefs.size())
return w3CPrefs.keys().at(index); return w3CPrefs.keys().at(index);
@ -141,22 +141,28 @@ QString UBW3CWidgetPreferenceAPI::key(int index)
return ""; return "";
} }
QString UBW3CWidgetPreferenceAPI::getItem(const QString& key) QString UBW3CWidgetPreferenceAPI::getItem(const QString& key)
{ {
if (mGraphicsW3CWidget) { if (mGraphicsW3CWidget) {
QMap<QString, UBGraphicsWidgetItem::PreferenceValue> w3cPref = mGraphicsW3CWidget->preferences(); QMap<QString, QString> docPref = mGraphicsW3CWidget->UBGraphicsWidgetItem::preferences();
if (docPref.contains(key))
return docPref.value(key);
}
if (w3cPref.contains(key)) QMap<QString, UBGraphicsW3CWidgetItem::PreferenceValue> w3cPrefs = mGraphicsW3CWidget->preferences();
return w3cPref.value(key).value;
if (w3cPrefs.contains(key)) {
UBGraphicsW3CWidgetItem::PreferenceValue pref = w3cPrefs.value(key);
return pref.value;
} }
else
return ""; return "";
} }
int UBW3CWidgetPreferenceAPI::length() int UBW3CWidgetPreferenceAPI::length()
{ {
QMap<QString, UBGraphicsWidgetItem::PreferenceValue> w3cPrefs = mGraphicsW3CWidget-->preferences(); QMap<QString, UBGraphicsW3CWidgetItem::PreferenceValue> w3cPrefs = mGraphicsW3CWidget->preferences();
return w3cPrefs.size(); return w3cPrefs.size();
} }
@ -165,7 +171,7 @@ int UBW3CWidgetPreferenceAPI::length()
void UBW3CWidgetPreferenceAPI::setItem(const QString& key, const QString& value) void UBW3CWidgetPreferenceAPI::setItem(const QString& key, const QString& value)
{ {
if (mGraphicsW3CWidget) { if (mGraphicsW3CWidget) {
QMap<QString, UBGraphicsWidgetItem::PreferenceValue> w3cPrefs = mGraphicsW3CWidget->preferences(); QMap<QString, UBGraphicsW3CWidgetItem::PreferenceValue> w3cPrefs = mGraphicsW3CWidget->preferences();
if (w3cPrefs.contains(key) && !w3cPrefs.value(key).readonly) if (w3cPrefs.contains(key) && !w3cPrefs.value(key).readonly)
mGraphicsW3CWidget->setPreference(key, value); mGraphicsW3CWidget->setPreference(key, value);
@ -173,6 +179,8 @@ void UBW3CWidgetPreferenceAPI::setItem(const QString& key, const QString& value)
} }
void UBW3CWidgetPreferenceAPI::removeItem(const QString& key) void UBW3CWidgetPreferenceAPI::removeItem(const QString& key)
{ {
if (mGraphicsW3CWidget) if (mGraphicsW3CWidget)

@ -108,7 +108,7 @@ class UBW3CWidgetPreferenceAPI : public UBW3CWebStorage
Q_OBJECT; Q_OBJECT;
public: public:
UBW3CWidgetPreferenceAPI(UBGraphicsW3CWidgetItem *graphicsWidget, QOBject *parent = 0); UBW3CWidgetPreferenceAPI(UBGraphicsW3CWidgetItem *graphicsWidget, QObject *parent = 0);
virtual ~UBW3CWidgetPreferenceAPI(); virtual ~UBW3CWidgetPreferenceAPI();

@ -17,7 +17,7 @@
#include "core/UBApplication.h" #include "core/UBApplication.h"
#include "domain/UBGraphicsWidget.h" #include "domain/UBGraphicsWebView.h"
#include "core/memcheck.h" #include "core/memcheck.h"

@ -79,7 +79,7 @@ UBWidgetUniboardAPI::UBWidgetUniboardAPI(UBGraphicsScene *pScene, UBGraphicsWidg
if (w3CGraphicsWidget) if (w3CGraphicsWidget)
{ {
mMessagesAPI = new UBWidgetMessageAPI(w3CGraphicsWidget->w3cWidget()); mMessagesAPI = new UBWidgetMessageAPI(w3CGraphicsWidget);
mDatastoreAPI = new UBDatastoreAPI(w3CGraphicsWidget); mDatastoreAPI = new UBDatastoreAPI(w3CGraphicsWidget);
} }
@ -547,7 +547,7 @@ void UBWidgetUniboardAPI::ProcessDropEvent(QDropEvent *event)
QDropEvent readyEvent(dropPoint, dropActions, &dropMimeData, dropMouseButtons, dropModifiers); QDropEvent readyEvent(dropPoint, dropActions, &dropMimeData, dropMouseButtons, dropModifiers);
//sending event to destination either it had been downloaded or not //sending event to destination either it had been downloaded or not
QApplication::sendEvent(mGraphicsWidget->widgetWebView(),&readyEvent); QApplication::sendEvent(mGraphicsWidget,&readyEvent);
readyEvent.acceptProposedAction(); readyEvent.acceptProposedAction();
} }
@ -602,11 +602,11 @@ void UBWidgetUniboardAPI::onDownloadFinished(bool pSuccess, sDownloadFileDesc de
//To make js interpreter accept drop event we need to generate move event first. //To make js interpreter accept drop event we need to generate move event first.
QDragMoveEvent pseudoMove(dropPoint, desc.dropActions, &dropMimeData, desc.dropMouseButtons, desc.dropModifiers); QDragMoveEvent pseudoMove(dropPoint, desc.dropActions, &dropMimeData, desc.dropMouseButtons, desc.dropModifiers);
QApplication::sendEvent(mGraphicsWidget->widgetWebView(),&pseudoMove); QApplication::sendEvent(mGraphicsWidget,&pseudoMove);
QDropEvent readyEvent(dropPoint, desc.dropActions, &dropMimeData, desc.dropMouseButtons, desc.dropModifiers); QDropEvent readyEvent(dropPoint, desc.dropActions, &dropMimeData, desc.dropMouseButtons, desc.dropModifiers);
//sending event to destination either it had been downloaded or not //sending event to destination either it had been downloaded or not
QApplication::sendEvent(mGraphicsWidget->widgetWebView(),&readyEvent); QApplication::sendEvent(mGraphicsWidget,&readyEvent);
readyEvent.acceptProposedAction(); readyEvent.acceptProposedAction();
} }

@ -57,7 +57,7 @@ class UBWidgetUniboardAPI : public QObject
* *
* some potential values are * some potential values are
* *
* enlocale * en
* en-UK * en-UK
* fr * fr
* fr-CH * fr-CH

@ -48,7 +48,7 @@ UBGraphicsWebView::~UBGraphicsWebView()
QVariant UBGraphicsWebView::itemChange(GraphicsItemChange change, const QVariant &value) QVariant UBGraphicsWebView::itemChange(GraphicsItemChange change, const QVariant &value)
{ {
if (change == QGraphicsItem::ItemCursorHasChanged && scene()) /*if (change == QGraphicsItem::ItemCursorHasChanged && scene())
{ {
unsetCursor(); unsetCursor();
} }
@ -66,10 +66,11 @@ QVariant UBGraphicsWebView::itemChange(GraphicsItemChange change, const QVariant
scene()->setActiveWindow(0); scene()->setActiveWindow(0);
} }
} }
} }*/
QVariant newValue = mDelegate->itemChange(change, value); QVariant newValue = mDelegate->itemChange(change, value);
return QGraphicsWebView::itemChange(change, newValue); return QGraphicsWebView::itemChange(change, newValue);
//return QGraphicsWebView::itemChange(change, value);
} }
void UBGraphicsWebView::setUuid(const QUuid &pUuid) void UBGraphicsWebView::setUuid(const QUuid &pUuid)

@ -924,9 +924,9 @@ UBItem* UBGraphicsW3CWidgetItem::deepCopy() const
copy->resize(this->size().width(), this->size().height()); copy->resize(this->size().width(), this->size().height());
foreach(QString key, mPreferences.keys()) foreach(QString key, UBGraphicsWidgetItem::preferences().keys())
{ {
copy->setPreference(key, mPreferences.value(key)); copy->setPreference(key, UBGraphicsWidgetItem::preferences().value(key));
} }
foreach(QString key, mDatastore.keys()) foreach(QString key, mDatastore.keys())

@ -100,8 +100,6 @@ class UBGraphicsWidgetItem : public UBGraphicsWebView
bool hasEmbededObjects(); bool hasEmbededObjects();
bool hasEmbededFlash(); bool hasEmbededFlash();
void resize(qreal width, qreal height);
QSize nominalSize() const QSize nominalSize() const
{ {
return mNominalSize; return mNominalSize;
@ -191,7 +189,7 @@ class UBGraphicsWidgetItem : public UBGraphicsWebView
virtual void injectInlineJavaScript(); virtual void injectInlineJavaScript();
virtual void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); virtual void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
virtual void dropEvent(QDropEvent *); //virtual void dropEvent(QDropEvent *);
/* end from */ /* end from */
protected slots: protected slots:
@ -274,6 +272,26 @@ class UBGraphicsW3CWidgetItem : public UBGraphicsWidgetItem
static bool hasNPAPIWrapper(const QString& pMimeType); static bool hasNPAPIWrapper(const QString& pMimeType);
class PreferenceValue
{
public:
PreferenceValue()
{
// NOOP
}
PreferenceValue(const QString& pValue, bool pReadonly)
{
value = pValue;
readonly = pReadonly;
}
QString value;
bool readonly;
};
class Metadata class Metadata
{ {
public: public:
@ -286,6 +304,10 @@ class UBGraphicsW3CWidgetItem : public UBGraphicsWidgetItem
QString version; QString version;
}; };
QMap<QString, PreferenceValue> preferences()
{
return mPreferences;
}
Metadata metadatas() const Metadata metadatas() const
{ {
@ -300,6 +322,8 @@ class UBGraphicsW3CWidgetItem : public UBGraphicsWidgetItem
private: private:
QMap<QString, PreferenceValue> mPreferences;
UBW3CWidgetAPI* mW3CWidgetAPI; UBW3CWidgetAPI* mW3CWidgetAPI;
static bool sTemplateLoaded; static bool sTemplateLoaded;

@ -131,12 +131,12 @@ void UBToolWidget::javaScriptWindowObjectCleared()
mToolWidget->page()->mainFrame()->addToJavaScriptWindowObject("sankore", uniboardAPI); mToolWidget->page()->mainFrame()->addToJavaScriptWindowObject("sankore", uniboardAPI);
UBW3CWidget* w3c = dynamic_cast<UBW3CWidget*>(mToolWidget); /*UBW3CWidget* w3c = dynamic_cast<UBW3CWidget*>(mToolWidget);
if (w3c) if (w3c)
{ {
UBW3CWidgetAPI* widgetAPI = new UBW3CWidgetAPI(w3c); UBW3CWidgetAPI* widgetAPI = new UBW3CWidgetAPI(w3c);
mToolWidget->page()->mainFrame()->addToJavaScriptWindowObject("widget", widgetAPI); mToolWidget->page()->mainFrame()->addToJavaScriptWindowObject("widget", widgetAPI);
} }*/
} }

Loading…
Cancel
Save