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();
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());
@ -360,7 +360,7 @@ void UBDocumentPublisher::upgradeDocumentForPublishing()
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();
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)
, mGraphicsW3CWidget(graphicsWidget)
{
@ -133,7 +133,7 @@ UBW3CWidgetPreferenceAPI::~UBW3CWidgetPreferenceAPI()
QString UBW3CWidgetPreferenceAPI::key(int index)
{
QMap<QString, UBGraphicsWidgetItem::PreferenceValue> w3CPrefs = mGraphicsW3CWidget->preferences();
QMap<QString, UBGraphicsW3CWidgetItem::PreferenceValue> w3CPrefs = mGraphicsW3CWidget->preferences();
if (index < w3CPrefs.size())
return w3CPrefs.keys().at(index);
@ -141,22 +141,28 @@ QString UBW3CWidgetPreferenceAPI::key(int index)
return "";
}
QString UBW3CWidgetPreferenceAPI::getItem(const QString& key)
{
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))
return w3cPref.value(key).value;
QMap<QString, UBGraphicsW3CWidgetItem::PreferenceValue> w3cPrefs = mGraphicsW3CWidget->preferences();
if (w3cPrefs.contains(key)) {
UBGraphicsW3CWidgetItem::PreferenceValue pref = w3cPrefs.value(key);
return pref.value;
}
else
return "";
}
int UBW3CWidgetPreferenceAPI::length()
{
QMap<QString, UBGraphicsWidgetItem::PreferenceValue> w3cPrefs = mGraphicsW3CWidget-->preferences();
QMap<QString, UBGraphicsW3CWidgetItem::PreferenceValue> w3cPrefs = mGraphicsW3CWidget->preferences();
return w3cPrefs.size();
}
@ -165,7 +171,7 @@ int UBW3CWidgetPreferenceAPI::length()
void UBW3CWidgetPreferenceAPI::setItem(const QString& key, const QString& value)
{
if (mGraphicsW3CWidget) {
QMap<QString, UBGraphicsWidgetItem::PreferenceValue> w3cPrefs = mGraphicsW3CWidget->preferences();
QMap<QString, UBGraphicsW3CWidgetItem::PreferenceValue> w3cPrefs = mGraphicsW3CWidget->preferences();
if (w3cPrefs.contains(key) && !w3cPrefs.value(key).readonly)
mGraphicsW3CWidget->setPreference(key, value);
@ -173,6 +179,8 @@ void UBW3CWidgetPreferenceAPI::setItem(const QString& key, const QString& value)
}
void UBW3CWidgetPreferenceAPI::removeItem(const QString& key)
{
if (mGraphicsW3CWidget)

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

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

@ -79,7 +79,7 @@ UBWidgetUniboardAPI::UBWidgetUniboardAPI(UBGraphicsScene *pScene, UBGraphicsWidg
if (w3CGraphicsWidget)
{
mMessagesAPI = new UBWidgetMessageAPI(w3CGraphicsWidget->w3cWidget());
mMessagesAPI = new UBWidgetMessageAPI(w3CGraphicsWidget);
mDatastoreAPI = new UBDatastoreAPI(w3CGraphicsWidget);
}
@ -547,7 +547,7 @@ void UBWidgetUniboardAPI::ProcessDropEvent(QDropEvent *event)
QDropEvent readyEvent(dropPoint, dropActions, &dropMimeData, dropMouseButtons, dropModifiers);
//sending event to destination either it had been downloaded or not
QApplication::sendEvent(mGraphicsWidget->widgetWebView(),&readyEvent);
QApplication::sendEvent(mGraphicsWidget,&readyEvent);
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.
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);
//sending event to destination either it had been downloaded or not
QApplication::sendEvent(mGraphicsWidget->widgetWebView(),&readyEvent);
QApplication::sendEvent(mGraphicsWidget,&readyEvent);
readyEvent.acceptProposedAction();
}

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

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

@ -924,9 +924,9 @@ UBItem* UBGraphicsW3CWidgetItem::deepCopy() const
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())

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

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

Loading…
Cancel
Save