Commit f3a449f5 authored by Yimgo's avatar Yimgo

Cosmetics in UBGrahicsWebView and UBGraphicsWidgetItem classes.

parent 4cbdf772
...@@ -13,20 +13,18 @@ ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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 @@ ...@@ -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 ...@@ -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);
}; };
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment