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. 997
      src/domain/UBGraphicsWidgetItem.cpp
  4. 267
      src/domain/UBGraphicsWidgetItem.h

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

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

Loading…
Cancel
Save