Cosmetics in UBGrahicsWebView and UBGraphicsWidgetItem classes.

preferencesAboutTextFull
Yimgo 12 years ago
parent 4cbdf77263
commit f3a449f519
  1. 38
      src/domain/UBGraphicsWebView.cpp
  2. 3
      src/domain/UBGraphicsWebView.h
  3. 1019
      src/domain/UBGraphicsWidgetItem.cpp
  4. 277
      src/domain/UBGraphicsWidgetItem.h

@ -13,20 +13,18 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "UBGraphicsWebView.h"
#include <QtGui> #include <QtGui>
#include <QtWebKit> #include <QtWebKit>
#include "UBGraphicsWebView.h"
#include "UBGraphicsScene.h" #include "UBGraphicsScene.h"
#include "UBGraphicsItemDelegate.h" #include "UBGraphicsItemDelegate.h"
#include "UBGraphicsDelegateFrame.h" #include "UBGraphicsDelegateFrame.h"
#include "core/memcheck.h" #include "core/memcheck.h"
UBGraphicsWebView::UBGraphicsWebView(QGraphicsItem* parent) : UBGraphicsWebView::UBGraphicsWebView(QGraphicsItem* parent)
QGraphicsWebView(parent) : QGraphicsWebView(parent)
{ {
setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object); setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object);
@ -68,30 +66,17 @@ void UBGraphicsWebView::setUuid(const QUuid &pUuid)
void UBGraphicsWebView::mousePressEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsWebView::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
if (mDelegate->mousePressEvent(event)) if (!mDelegate->mousePressEvent(event))
{ setSelected(true); /* forcing selection */
//NOOP
}
else
{
// QT Proxy Widget is a bit lazy, we force the selection ...
setSelected(true);
}
QGraphicsWebView::mousePressEvent(event); QGraphicsWebView::mousePressEvent(event);
} }
void UBGraphicsWebView::mouseMoveEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsWebView::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{ {
if (mDelegate->mouseMoveEvent(event)) if (!mDelegate->mouseMoveEvent(event))
{
// NOOP;
}
else
{
QGraphicsWebView::mouseMoveEvent(event); QGraphicsWebView::mouseMoveEvent(event);
}
} }
@ -103,7 +88,7 @@ void UBGraphicsWebView::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsWebView::wheelEvent(QGraphicsSceneWheelEvent *event) void UBGraphicsWebView::wheelEvent(QGraphicsSceneWheelEvent *event)
{ {
if( mDelegate->weelEvent(event) ) if (mDelegate->weelEvent(event))
{ {
QGraphicsWebView::wheelEvent(event); QGraphicsWebView::wheelEvent(event);
event->accept(); event->accept();
@ -113,20 +98,18 @@ void UBGraphicsWebView::wheelEvent(QGraphicsSceneWheelEvent *event)
void UBGraphicsWebView::hoverEnterEvent(QGraphicsSceneHoverEvent *event) void UBGraphicsWebView::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{ {
Q_UNUSED(event) Q_UNUSED(event)
// NOOP /* NOOP */
} }
void UBGraphicsWebView::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) void UBGraphicsWebView::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{ {
Q_UNUSED(event) Q_UNUSED(event)
// NOOP /* NOOP */
} }
void UBGraphicsWebView::setDelegate(UBGraphicsItemDelegate* pDelegate) void UBGraphicsWebView::setDelegate(UBGraphicsItemDelegate* pDelegate)
{ {
if (mDelegate) if (mDelegate)
{
delete mDelegate; delete mDelegate;
}
mDelegate = pDelegate; mDelegate = pDelegate;
} }
@ -140,8 +123,7 @@ void UBGraphicsWebView::resize(qreal w, qreal h)
void UBGraphicsWebView::resize(const QSizeF & pSize) void UBGraphicsWebView::resize(const QSizeF & pSize)
{ {
if (pSize != size()) if (pSize != size()) {
{
QGraphicsWebView::setMaximumSize(pSize.width(), pSize.height()); QGraphicsWebView::setMaximumSize(pSize.width(), pSize.height());
QGraphicsWebView::resize(pSize.width(), pSize.height()); QGraphicsWebView::resize(pSize.width(), pSize.height());
if (mDelegate) if (mDelegate)

@ -19,7 +19,6 @@
#include <QtGui> #include <QtGui>
#include <QtWebKit> #include <QtWebKit>
#include "UBItem.h" #include "UBItem.h"
#include "UBResizableGraphicsItem.h" #include "UBResizableGraphicsItem.h"
@ -56,8 +55,6 @@ class UBGraphicsWebView: public QGraphicsWebView, public UBItem, public UBResiza
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event); virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
virtual bool event(QEvent *event); virtual bool event(QEvent *event);
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value); virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
}; };

File diff suppressed because it is too large Load Diff

@ -19,10 +19,10 @@
#include <QtWebKit> #include <QtWebKit>
#include <QDomElement> #include <QDomElement>
#include "core/UB.h"
#include "UBGraphicsWebView.h" #include "UBGraphicsWebView.h"
#include "core/UB.h"
class UBWidgetUniboardAPI; class UBWidgetUniboardAPI;
class UBGraphicsScene; class UBGraphicsScene;
class UBW3CWidgetAPI; class UBW3CWidgetAPI;
@ -46,143 +46,72 @@ class UBGraphicsWidgetItem : public UBGraphicsWebView
UBGraphicsWidgetItem(QGraphicsItem *parent = 0, int widgetType = 0); UBGraphicsWidgetItem(QGraphicsItem *parent = 0, int widgetType = 0);
~UBGraphicsWidgetItem(); ~UBGraphicsWidgetItem();
virtual UBGraphicsScene* scene();
virtual void initialize(); virtual void initialize();
virtual UBItem* deepCopy() const = 0; QUrl mainHtml();
void loadMainHtml();
QUrl widgetUrl();
QString mainHtmlFileName();
bool hasEmbededObjects();
bool hasEmbededFlash();
bool canBeContent();
bool canBeTool();
/* preferences */
void setPreference(const QString& key, QString value);
QString preference(const QString& key) const; QString preference(const QString& key) const;
void setPreference(const QString& key, QString value);
QMap<QString, QString> preferences() const; QMap<QString, QString> preferences() const;
void removePreference(const QString& key); void removePreference(const QString& key);
void removeAllPreferences(); void removeAllPreferences();
/* datastore */
void setDatastoreEntry(const QString& key, QString value);
QString datastoreEntry(const QString& key) const; QString datastoreEntry(const QString& key) const;
void setDatastoreEntry(const QString& key, QString value);
QMap<QString, QString> datastoreEntries() const; QMap<QString, QString> datastoreEntries() const;
void removeDatastoreEntry(const QString& key); void removeDatastoreEntry(const QString& key);
void removeAllDatastoreEntries(); void removeAllDatastoreEntries();
virtual UBGraphicsItemDelegate* Delegate() const {return mDelegate; } virtual UBGraphicsItemDelegate* Delegate() const;
virtual void remove(); virtual void remove();
void removeScript(); void removeScript();
QString downloadUrl(const QString &fileUrl, const QString &extention);
QString downloadWeb(const QString &fileUrl);
void processDropEvent(QDropEvent *event); void processDropEvent(QDropEvent *event);
bool isDropableData(const QMimeData *data) const; bool isDropableData(const QMimeData *data) const;
virtual void setOwnFolder(const QUrl &newFolder) {ownFolder = newFolder;} virtual QUrl getOwnFolder() const;
virtual QUrl getOwnFolder() const {return ownFolder;} virtual void setOwnFolder(const QUrl &newFolder);
virtual void setSnapshotPath(const QUrl &newFilePath){SnapshotFile = newFilePath;} virtual void setSnapshotPath(const QUrl &newFilePath);
virtual QUrl getSnapshotPath(){return SnapshotFile;} virtual QUrl getSnapshotPath();
virtual void clearSource(); virtual void clearSource();
virtual void setUuid(const QUuid &pUuid);
/* from UBAbstractWidget */
void loadMainHtml();
QUrl mainHtml() virtual void setUuid(const QUuid &pUuid);
{
return mMainHtmlUrl;
}
QUrl widgetUrl()
{
return mWidgetUrl;
}
QString mainHtmlFileName() QSize nominalSize() const;
{
return mMainHtmlFileName;
}
bool hasEmbededObjects(); bool hasLoadedSuccessfully() const;
bool hasEmbededFlash();
QSize nominalSize() const bool freezable();
{ bool resizable();
return mNominalSize; bool isFrozen();
}
bool canBeContent(); QPixmap snapshot();
bool canBeTool(); void setSnapshot(const QPixmap& pix);
QPixmap takeSnapshot();
bool hasLoadedSuccessfully() const
{
return (mInitialLoadDone && !mLoadIsErronous);
}
bool freezable()
{
return mIsFreezable;
}
bool resizable() virtual UBItem* deepCopy() const = 0;
{ virtual UBGraphicsScene* scene();
return mIsResizable;
}
static QString iconFilePath(const QUrl& pUrl);
static QString widgetName(const QUrl& pUrl);
static int widgetType(const QUrl& pUrl); static int widgetType(const QUrl& pUrl);
static QString widgetName(const QUrl& pUrl);
bool isFrozen() static QString iconFilePath(const QUrl& pUrl);
{
return mIsFrozen;
}
QPixmap snapshot(){
return mSnapshot;
}
void setSnapshot(const QPixmap& pix);
QPixmap takeSnapshot();
public slots: public slots:
void freeze(); void freeze();
void unFreeze(); void unFreeze();
/* end from */
protected: protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
virtual bool eventFilter(QObject *obj, QEvent *event);
virtual void sendJSEnterEvent();
virtual void sendJSLeaveEvent();
QMap<QString, QString> mPreferences;
QMap<QString, QString> mDatastore;
/* from UBAbstractWidget*/
bool mMouseIsPressed;
bool mFirstReleaseAfterMove;
QUrl mMainHtmlUrl;
QString mMainHtmlFileName;
QUrl mWidgetUrl;
QSize mNominalSize;
bool mIsResizable;
bool mInitialLoadDone;
bool mLoadIsErronous;
bool mIsFreezable;
int mCanBeContent;
int mCanBeTool;
enum OSType enum OSType
{ {
type_NONE = 0, // 0000 type_NONE = 0, // 0000
@ -192,33 +121,49 @@ class UBGraphicsWidgetItem : public UBGraphicsWebView
type_ALL = 7, // 0111 type_ALL = 7, // 0111
}; };
virtual void injectInlineJavaScript(); bool mFirstReleaseAfterMove;
virtual void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); bool mInitialLoadDone;
bool mIsFreezable;
bool mIsResizable;
bool mLoadIsErronous;
bool mMouseIsPressed;
int mCanBeContent;
int mCanBeTool;
QSize mNominalSize;
QString mMainHtmlFileName;
QUrl mMainHtmlUrl;
QUrl mWidgetUrl;
QMap<QString, QString> mDatastore;
QMap<QString, QString> mPreferences;
//virtual void dropEvent(QDropEvent *); virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
/* end from */ virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
virtual bool eventFilter(QObject *obj, QEvent *event);
virtual void sendJSEnterEvent();
virtual void sendJSLeaveEvent();
virtual void injectInlineJavaScript();
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
protected slots: protected slots:
void geometryChangeRequested(const QRect& geom); void geometryChangeRequested(const QRect& geom);
virtual void javaScriptWindowObjectCleared(); virtual void javaScriptWindowObjectCleared();
/* from UBAbstractWidget*/
void mainFrameLoadFinished(bool ok); void mainFrameLoadFinished(bool ok);
/* end from */
private: private:
QPointF mLastMousePos; bool mIsFrozen;
bool mShouldMoveWidget; bool mIsTakingSnapshot;
bool mShouldMoveWidget;
UBWidgetUniboardAPI* mUniboardAPI; UBWidgetUniboardAPI* mUniboardAPI;
QPixmap mSnapshot;
QPointF mLastMousePos;
QUrl ownFolder; QUrl ownFolder;
QUrl SnapshotFile; QUrl SnapshotFile;
/* from UBAbstractWidget*/
static QStringList sInlineJavaScripts;
static bool sInlineJavaScriptLoaded; static bool sInlineJavaScriptLoaded;
bool mIsFrozen; static QStringList sInlineJavaScripts;
QPixmap mSnapshot;
bool mIsTakingSnapshot;
/* end from */
}; };
class UBGraphicsAppleWidgetItem : public UBGraphicsWidgetItem class UBGraphicsAppleWidgetItem : public UBGraphicsWidgetItem
@ -227,17 +172,16 @@ class UBGraphicsAppleWidgetItem : public UBGraphicsWidgetItem
public: public:
UBGraphicsAppleWidgetItem(const QUrl& pWidgetUrl, QGraphicsItem *parent = 0); UBGraphicsAppleWidgetItem(const QUrl& pWidgetUrl, QGraphicsItem *parent = 0);
~UBGraphicsAppleWidgetItem(); ~UBGraphicsAppleWidgetItem();
enum { Type = UBGraphicsItemType::AppleWidgetItemType }; virtual int type() const;
virtual int type() const
{
return Type;
}
virtual UBItem* deepCopy() const;
virtual void setUuid(const QUuid &pUuid); virtual void setUuid(const QUuid &pUuid);
virtual UBItem* deepCopy() const;
enum
{
Type = UBGraphicsItemType::AppleWidgetItemType
};
}; };
@ -246,43 +190,13 @@ class UBGraphicsW3CWidgetItem : public UBGraphicsWidgetItem
Q_OBJECT Q_OBJECT
public: public:
UBGraphicsW3CWidgetItem(const QUrl& pWidgetUrl, QGraphicsItem *parent = 0);
~UBGraphicsW3CWidgetItem();
enum { Type = UBGraphicsItemType::W3CWidgetItemType };
virtual int type() const
{
return Type;
}
virtual UBItem* deepCopy() const;
virtual void paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget );
virtual void setUuid(const QUuid &pUuid);
static QString createNPAPIWrapper(const QString& url,
const QString& pMimeType = QString(), const QSize& sizeHint = QSize(300, 150),
const QString& pName = QString());
static QString createNPAPIWrapperInDir(const QString& url, const QDir& pDir,
const QString& pMimeType = QString(), const QSize& sizeHint = QSize(300, 150),
const QString& pName = QString());
static QString createHtmlWrapperInDir(const QString& html, const QDir& pDir,
const QSize& sizeHint, const QString& pName);
static QString freezedWidgetPage();
static bool hasNPAPIWrapper(const QString& pMimeType);
class PreferenceValue class PreferenceValue
{ {
public: public:
PreferenceValue() PreferenceValue()
{ {
// NOOP /* NOOP */
} }
@ -292,8 +206,8 @@ class UBGraphicsW3CWidgetItem : public UBGraphicsWidgetItem
readonly = pReadonly; readonly = pReadonly;
} }
QString value;
bool readonly; bool readonly;
QString value;
}; };
class Metadata class Metadata
@ -308,39 +222,44 @@ class UBGraphicsW3CWidgetItem : public UBGraphicsWidgetItem
QString version; QString version;
}; };
QMap<QString, PreferenceValue> preferences() enum
{ {
return mPreferences; Type = UBGraphicsItemType::W3CWidgetItemType
} };
Metadata metadatas() const UBGraphicsW3CWidgetItem(const QUrl& pWidgetUrl, QGraphicsItem *parent = 0);
{ ~UBGraphicsW3CWidgetItem();
return mMetadatas;
} virtual int type() const;
virtual void setUuid(const QUuid &pUuid);
virtual UBItem* deepCopy() const;
virtual void paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget );
QMap<QString, PreferenceValue> preferences();
Metadata metadatas() const;
static QString createNPAPIWrapper(const QString& url, const QString& pMimeType = QString(), const QSize& sizeHint = QSize(300, 150), const QString& pName = QString());
static QString createNPAPIWrapperInDir(const QString& url, const QDir& pDir, const QString& pMimeType = QString(), const QSize& sizeHint = QSize(300, 150), const QString& pName = QString());
static QString createHtmlWrapperInDir(const QString& html, const QDir& pDir, const QSize& sizeHint, const QString& pName);
static QString freezedWidgetPage();
static bool hasNPAPIWrapper(const QString& pMimeType);
Metadata mMetadatas; Metadata mMetadatas;
private slots: private slots:
virtual void javaScriptWindowObjectCleared(); virtual void javaScriptWindowObjectCleared();
private: private:
static void loadNPAPIWrappersTemplates();
QMap<QString, PreferenceValue> mPreferences; static QString textForSubElementByLocale(QDomElement rootElement, QString subTagName, QLocale locale);
UBW3CWidgetAPI* mW3CWidgetAPI; UBW3CWidgetAPI* mW3CWidgetAPI;
QMap<QString, PreferenceValue> mPreferences;
static bool sTemplateLoaded; static bool sTemplateLoaded;
static QMap<QString, QString> sNPAPIWrapperTemplates;
static QString sNPAPIWrappperConfigTemplate; static QString sNPAPIWrappperConfigTemplate;
static QMap<QString, QString> sNPAPIWrapperTemplates;
static void loadNPAPIWrappersTemplates();
static QString textForSubElementByLocale(QDomElement rootElement, QString subTagName, QLocale locale);
}; };
#endif // UBGRAPHICSWIDGETITEM_H #endif // UBGRAPHICSWIDGETITEM_H

Loading…
Cancel
Save