summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoopesh Chander <roop@forwardbias.in>2009-11-24 11:39:39 +0530
committerRoopesh Chander <roop@forwardbias.in>2009-11-24 12:50:12 +0530
commit13c556fcc67ca90e40a8a6c868d295d37954cda7 (patch)
tree2f5708cef4c304dfe7219783a66ccc0c61c26fa6
parent4a6ad95a377dbe878a90c286d7c5682d7263b3f9 (diff)
fix coding style using astyle
astyle --indent=spaces=4 --brackets=linux --indent-labels --pad=oper --unpad=paren --one-line=keep-statements --convert-tabs --indent-preprocessor
-rw-r--r--addressbar.cpp9
-rw-r--r--graphicstoolbar.cpp56
-rw-r--r--graphicstoolbar.h3
-rw-r--r--graphicsview.cpp10
-rw-r--r--mainwindow.cpp86
-rw-r--r--mainwindow.h8
-rw-r--r--resizeuihelper.cpp99
-rw-r--r--searchlineedit.cpp4
-rw-r--r--webscrap.cpp167
-rw-r--r--webscrap.h3
-rw-r--r--webview.cpp51
11 files changed, 308 insertions, 188 deletions
diff --git a/addressbar.cpp b/addressbar.cpp
index 979e0e6..b48b761 100644
--- a/addressbar.cpp
+++ b/addressbar.cpp
@@ -13,15 +13,18 @@ AddressBar::AddressBar(QWidget *parent)
setPalette(p);
}
-void AddressBar::setProgress(int progress) {
+void AddressBar::setProgress(int progress)
+{
m_progress = progress;
}
-int AddressBar::progress() const {
+int AddressBar::progress() const
+{
return m_progress;
}
-void AddressBar::paintEvent(QPaintEvent *event) {
+void AddressBar::paintEvent(QPaintEvent *event)
+{
QPainter painter(this);
int progressWidth = width() * (progress() / 100.0);
painter.setPen(Qt::NoPen);
diff --git a/graphicstoolbar.cpp b/graphicstoolbar.cpp
index b61ada0..2c290af 100644
--- a/graphicstoolbar.cpp
+++ b/graphicstoolbar.cpp
@@ -10,7 +10,8 @@
#include <QGraphicsSceneHoverEvent>
#include "graphicstoolbar.h"
-bool HoverOutEventTransition::eventTest(QEvent *e) {
+bool HoverOutEventTransition::eventTest(QEvent *e)
+{
if (! QEventTransition::eventTest(e))
return false;
QGraphicsWidget *toolbar = qobject_cast<QGraphicsWidget*>(eventSource());
@@ -21,9 +22,9 @@ bool HoverOutEventTransition::eventTest(QEvent *e) {
}
GraphicsToolBar::GraphicsToolBar(QGraphicsScene *scene, QGraphicsItem * parent, Qt::WindowFlags wFlags)
- : QGraphicsWidget(parent, wFlags)
- , m_scene(scene)
- , m_fillLevel(100)
+ : QGraphicsWidget(parent, wFlags)
+ , m_scene(scene)
+ , m_fillLevel(100)
{
m_scene->addItem(this);
m_layout = new QGraphicsLinearLayout(Qt::Horizontal, this);
@@ -90,7 +91,8 @@ GraphicsToolBar::GraphicsToolBar(QGraphicsScene *scene, QGraphicsItem * parent,
m_stateMachine.start();
}
-void GraphicsToolBar::setGraphicsEffectsEnabled(bool enabled) {
+void GraphicsToolBar::setGraphicsEffectsEnabled(bool enabled)
+{
m_isGraphicsEffectsEnabled = enabled;
if (!enabled)
setGraphicsEffect(0);
@@ -98,40 +100,49 @@ void GraphicsToolBar::setGraphicsEffectsEnabled(bool enabled) {
setGraphicsEffect(m_blurEffect);
}
-bool GraphicsToolBar::graphicsEffectsEnabled() const {
+bool GraphicsToolBar::graphicsEffectsEnabled() const
+{
return m_isGraphicsEffectsEnabled;
}
-QGraphicsRotation* GraphicsToolBar::rotation() const {
+QGraphicsRotation* GraphicsToolBar::rotation() const
+{
return m_rotation;
}
-void GraphicsToolBar::addWidget(QWidget *widget) {
+void GraphicsToolBar::addWidget(QWidget *widget)
+{
QGraphicsWidget *gw = m_scene->addWidget(widget);
m_layout->addItem(gw);
}
-void GraphicsToolBar::setBackgroundBrush(QBrush brush) {
+void GraphicsToolBar::setBackgroundBrush(QBrush brush)
+{
m_bgBrush = brush;
}
-QBrush GraphicsToolBar::backgroundBrush() const {
+QBrush GraphicsToolBar::backgroundBrush() const
+{
return m_bgBrush;
}
-void GraphicsToolBar::setFillLevelBrush(QBrush brush) {
+void GraphicsToolBar::setFillLevelBrush(QBrush brush)
+{
m_fillLevelBrush = brush;
}
-QBrush GraphicsToolBar::fillLevelBrush() const {
+QBrush GraphicsToolBar::fillLevelBrush() const
+{
return m_fillLevelBrush;
}
-void GraphicsToolBar::setFillLevel(int percent) {
+void GraphicsToolBar::setFillLevel(int percent)
+{
m_fillLevel = qMax(0, qMin(percent, 100));
}
-void GraphicsToolBar::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
+void GraphicsToolBar::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+{
Q_UNUSED(option);
Q_UNUSED(widget);
painter->save();
@@ -146,28 +157,31 @@ void GraphicsToolBar::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
painter->restore();
}
-void GraphicsToolBar::transitionBlurEnabledTo(bool enabled) {
+void GraphicsToolBar::transitionBlurEnabledTo(bool enabled)
+{
if (! graphicsEffectsEnabled())
return;
QParallelAnimationGroup *animGroup = new QParallelAnimationGroup(this);
QPropertyAnimation *blurAnimation = new QPropertyAnimation(m_blurEffect, "blurRadius", animGroup);
blurAnimation->setStartValue(enabled ? 0 : 5);
- blurAnimation->setEndValue(enabled? 5 : 0);
- blurAnimation->setDuration(enabled? 200 : 200);
+ blurAnimation->setEndValue(enabled ? 5 : 0);
+ blurAnimation->setDuration(enabled ? 200 : 200);
QPropertyAnimation *opacityAnimation = new QPropertyAnimation(this, "opacity", animGroup);
- opacityAnimation->setStartValue(enabled? 1.0 : 0.7);
- opacityAnimation->setEndValue(enabled? 0.7 : 1.0);
+ opacityAnimation->setStartValue(enabled ? 1.0 : 0.7);
+ opacityAnimation->setEndValue(enabled ? 0.7 : 1.0);
animGroup->addAnimation(blurAnimation);
animGroup->addAnimation(opacityAnimation);
animGroup->start(QAbstractAnimation::DeleteWhenStopped);
}
-void GraphicsToolBar::show() {
+void GraphicsToolBar::show()
+{
QGraphicsWidget::show();
setOpacity(1.0);
m_blurEffect->setProperty("blurRadius", 0);
}
-void GraphicsToolBar::hide() {
+void GraphicsToolBar::hide()
+{
QGraphicsWidget::hide();
}
diff --git a/graphicstoolbar.h b/graphicstoolbar.h
index 2a56d7a..7a2ecfc 100644
--- a/graphicstoolbar.h
+++ b/graphicstoolbar.h
@@ -11,7 +11,8 @@
#include <QStateMachine>
#include <QEventTransition>
-class HoverOutEventTransition : public QEventTransition {
+class HoverOutEventTransition : public QEventTransition
+{
public:
HoverOutEventTransition(QObject *object, QEvent::Type type, QState *sourceState = 0)
: QEventTransition(object, type, sourceState) {
diff --git a/graphicsview.cpp b/graphicsview.cpp
index 5dc35af..cd30617 100644
--- a/graphicsview.cpp
+++ b/graphicsview.cpp
@@ -1,16 +1,18 @@
#include "graphicsview.h"
GraphicsView::GraphicsView(QWidget * parent)
- : QGraphicsView(parent)
- , m_centralWidget(0)
+ : QGraphicsView(parent)
+ , m_centralWidget(0)
{
}
-void GraphicsView::setCentralWidget(QGraphicsWidget *item) {
+void GraphicsView::setCentralWidget(QGraphicsWidget *item)
+{
m_centralWidget = item;
}
-void GraphicsView::resizeEvent(QResizeEvent *event) {
+void GraphicsView::resizeEvent(QResizeEvent *event)
+{
Q_UNUSED(event);
event->setAccepted(false);
if (!viewport())
diff --git a/mainwindow.cpp b/mainwindow.cpp
index 00962db..a87ad25 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -17,8 +17,8 @@
#include "searchlineedit.h"
MainWindow::MainWindow(QWidget *parent)
- : GraphicsView(parent)
- , m_settings(new QSettings("Nokia", "WebScraps", this))
+ : GraphicsView(parent)
+ , m_settings(new QSettings("Nokia", "WebScraps", this))
{
setScene(new QGraphicsScene);
setMouseTracking(true);
@@ -54,7 +54,7 @@ MainWindow::MainWindow(QWidget *parent)
// define transitions
QSignalTransition *transitionToBrowser = seeScraps->addTransition(m_gotoBrowserButton, SIGNAL(clicked()), browseWeb);
QSignalTransition *transitionToScraps = browseWeb->addTransition(m_gotoScrapsButton, SIGNAL(clicked()), seeScraps);
- QSignalTransition *transitionToScraps2 = browseWeb->addTransition(m_webView, SIGNAL(scrapAdded(QUrl,QSize,QRect,QPoint)), seeScraps);
+ QSignalTransition *transitionToScraps2 = browseWeb->addTransition(m_webView, SIGNAL(scrapAdded(QUrl, QSize, QRect, QPoint)), seeScraps);
// associate animations and actions
transitionToBrowser->addAnimation(m_scrapsToBrowserAnimation);
@@ -78,7 +78,8 @@ MainWindow::MainWindow(QWidget *parent)
void MainWindow::addScrap(QUrl url, QSize pageSize,
QRect scrapRect, QPoint position,
qreal xScale, qreal yScale,
- int refreshIntervalMins) {
+ int refreshIntervalMins)
+{
WebScrap *webscrap = new WebScrap(url, pageSize, scrapRect);
webscrap->setRefreshInterval(refreshIntervalMins * 60 * 1000); // milliseconds
WebScrapContainer *container = new WebScrapContainer(webscrap, scene(), xScale, yScale);
@@ -93,7 +94,8 @@ void MainWindow::addScrap(QUrl url, QSize pageSize,
addScrapToAnimations(container);
}
-void MainWindow::initBrowser() {
+void MainWindow::initBrowser()
+{
m_webView = new WebView(scene());
m_webView->setPos(sceneRect().topLeft());
m_webView->setOpacity(0);
@@ -102,10 +104,11 @@ void MainWindow::initBrowser() {
m_webView->load(QUrl("http://qt.nokia.com/"));
connect(m_webView, SIGNAL(loadFinished(bool)), SLOT(adjustLocation()));
connect(m_webView, SIGNAL(titleChanged(const QString&)), SLOT(adjustTitle()));
- connect(m_webView, SIGNAL(scrapAdded(QUrl,QSize,QRect,QPoint)), SLOT(addScrap(QUrl, QSize, QRect, QPoint)));
+ connect(m_webView, SIGNAL(scrapAdded(QUrl, QSize, QRect, QPoint)), SLOT(addScrap(QUrl, QSize, QRect, QPoint)));
}
-void MainWindow::createScrapsToolbar(QGraphicsScene *scene) {
+void MainWindow::createScrapsToolbar(QGraphicsScene *scene)
+{
m_scrapsToolbar = new GraphicsToolBar(scene);
m_scrapsToolbar->hide();
m_dropDownList = new QComboBox;
@@ -130,7 +133,8 @@ void MainWindow::createScrapsToolbar(QGraphicsScene *scene) {
connect(m_searchBar, SIGNAL(textChanged(QString)), SLOT(searchTextChanged(QString)));
}
-void MainWindow::createBrowserToolbar(QGraphicsScene *scene) {
+void MainWindow::createBrowserToolbar(QGraphicsScene *scene)
+{
m_browserToolbar = new GraphicsToolBar(scene);
m_browserToolbar->hide();
m_addressBar = new AddressBar;
@@ -196,11 +200,12 @@ void MainWindow::adjustTitle()
setWindowTitle(title);
}
-void MainWindow::createAnimations() {
+void MainWindow::createAnimations()
+{
m_scrapsEnter = new QParallelAnimationGroup(this); // scraps will be added to this later
m_scrapsLeave = new QParallelAnimationGroup(this); // scraps will be added to this later
m_scrapsFlyOffset = QApplication::desktop()->screenGeometry().bottomRight()
- - QApplication::desktop()->screenGeometry().topLeft();
+ - QApplication::desktop()->screenGeometry().topLeft();
QAbstractAnimation *browserEnter = createBrowserAnim(Enter, this);
QAbstractAnimation *browserLeave = createBrowserAnim(Leave, this);
@@ -213,7 +218,8 @@ void MainWindow::createAnimations() {
m_scrapsToBrowserAnimation->addAnimation(browserEnter);
}
-void MainWindow::addScrapToAnimations(WebScrapContainer *container) {
+void MainWindow::addScrapToAnimations(WebScrapContainer *container)
+{
Q_ASSERT(m_scrapsEnter);
Q_ASSERT(m_scrapsLeave);
@@ -233,7 +239,8 @@ void MainWindow::addScrapToAnimations(WebScrapContainer *container) {
container->setLeaveAnimation(leaveAnim);
}
-void MainWindow::removeScrapFromAnimations(WebScrapContainer *container) {
+void MainWindow::removeScrapFromAnimations(WebScrapContainer *container)
+{
QPropertyAnimation *enterAnim = container->enterAnimation();
m_scrapsEnter->removeAnimation(enterAnim);
enterAnim->deleteLater();
@@ -243,7 +250,8 @@ void MainWindow::removeScrapFromAnimations(WebScrapContainer *container) {
leaveAnim->deleteLater();
}
-QAbstractAnimation* MainWindow::createBrowserAnim(const Movement move, QObject *parent) {
+QAbstractAnimation* MainWindow::createBrowserAnim(const Movement move, QObject *parent)
+{
QPropertyAnimation *anim = new QPropertyAnimation(m_webView, "opacity", parent);
anim->setDuration(250);
if (move == Enter) {
@@ -257,16 +265,17 @@ QAbstractAnimation* MainWindow::createBrowserAnim(const Movement move, QObject *
return anim;
}
-QAbstractAnimation* MainWindow::createToolbarAnim(GraphicsToolBar *fromToolbar, GraphicsToolBar *toToolbar, RotateDirection direction, QObject *parent) {
+QAbstractAnimation* MainWindow::createToolbarAnim(GraphicsToolBar *fromToolbar, GraphicsToolBar *toToolbar, RotateDirection direction, QObject *parent)
+{
QSequentialAnimationGroup *seqAnim = new QSequentialAnimationGroup(parent);
QPropertyAnimation *rotateAnim1 = new QPropertyAnimation(fromToolbar->rotation(), "angle", seqAnim);
fromToolbar->rotation()->setOrigin(QVector3D(fromToolbar->rect().center()));
rotateAnim1->setDuration(250);
rotateAnim1->setStartValue(0.0);
if (direction == Clockwise)
- rotateAnim1->setEndValue(80.0);
+ rotateAnim1->setEndValue(80.0);
else
- rotateAnim1->setEndValue(-80.0);
+ rotateAnim1->setEndValue(-80.0);
QPointF delta = fromToolbar->rect().center() - toToolbar->rect().center();
toToolbar->setPos(fromToolbar->pos());
@@ -287,7 +296,8 @@ QAbstractAnimation* MainWindow::createToolbarAnim(GraphicsToolBar *fromToolbar,
return seqAnim;
}
-void MainWindow::bubbleUpScrap(QGraphicsWidget *scrap) {
+void MainWindow::bubbleUpScrap(QGraphicsWidget *scrap)
+{
if (!scrap && sender())
scrap = qobject_cast<QGraphicsWidget*>(sender());
if (scrap) {
@@ -300,7 +310,8 @@ void MainWindow::bubbleUpScrap(QGraphicsWidget *scrap) {
}
}
-void MainWindow::bubbleUpScraps(QList<QGraphicsWidget*> scraps) {
+void MainWindow::bubbleUpScraps(QList<QGraphicsWidget*> scraps)
+{
if (!scraps.isEmpty()) {
foreach(QGraphicsWidget *s, m_scraps) {
if (scraps.contains(s) && s->zValue() < 1000)
@@ -311,7 +322,8 @@ void MainWindow::bubbleUpScraps(QList<QGraphicsWidget*> scraps) {
}
}
-void MainWindow::removeSenderScrap() {
+void MainWindow::removeSenderScrap()
+{
WebScrapContainer *scrap = 0;
if (sender())
scrap = qobject_cast<WebScrapContainer*>(sender());
@@ -320,7 +332,7 @@ void MainWindow::removeSenderScrap() {
for (int i = 0; i < m_scraps.count(); i++) {
if (m_scraps.at(i) == scrap) {
m_scraps.removeAt(i);
- m_dropDownList->removeItem(i+1);
+ m_dropDownList->removeItem(i + 1);
}
}
scrap->deleteLater();
@@ -329,7 +341,8 @@ void MainWindow::removeSenderScrap() {
adjustTitle();
}
-void MainWindow::updateDropDownList() {
+void MainWindow::updateDropDownList()
+{
WebScrap *scrap = 0;
if (sender())
scrap = qobject_cast<WebScrap*>(sender());
@@ -344,7 +357,8 @@ void MainWindow::updateDropDownList() {
}
}
-void MainWindow::scrapDropDownListActivated(int index) {
+void MainWindow::scrapDropDownListActivated(int index)
+{
WebScrapContainer *scrap = m_dropDownList->itemData(index).value<WebScrapContainer*>();
for (int i = 0; i < m_scraps.count(); i++) {
WebScrapContainer *ithScrap = qobject_cast<WebScrapContainer*>(m_scraps.at(i));
@@ -353,7 +367,8 @@ void MainWindow::scrapDropDownListActivated(int index) {
bubbleUpScrap(scrap);
}
-void MainWindow::searchTextChanged(const QString& text) {
+void MainWindow::searchTextChanged(const QString& text)
+{
QList<QGraphicsWidget*> matchingScraps;
for (int i = 0; i < m_scraps.count(); i++) {
WebScrapContainer *ithScrap = qobject_cast<WebScrapContainer*>(m_scraps.at(i));
@@ -365,7 +380,8 @@ void MainWindow::searchTextChanged(const QString& text) {
bubbleUpScraps(matchingScraps);
}
-void MainWindow::saveSettings() {
+void MainWindow::saveSettings()
+{
m_settings->setValue("mainwindow/size", size());
m_settings->setValue("mainwindow/pos", pos());
m_settings->setValue("browser/url", m_webView->url().toString());
@@ -393,7 +409,8 @@ void MainWindow::saveSettings() {
m_settings->endArray();
}
-void MainWindow::loadSettings() {
+void MainWindow::loadSettings()
+{
if (m_settings->contains("mainwindow/size"))
resize(m_settings->value("mainwindow/size", size()).toSize());
if (m_settings->contains("mainwindow/pos"))
@@ -420,33 +437,38 @@ void MainWindow::loadSettings() {
addScrap(QUrl("http://dilbert.com/"), QSize(640, 199),
QRect(20, 197, 640, 199), QPoint(14, 285));
addScrap(QUrl("http://www.cnn.com/"), QSize(248, 281),
- QRect(9, 508, 248, 281), QPoint(677,39));
+ QRect(9, 508, 248, 281), QPoint(677, 39));
addScrap(QUrl("http://www.techcrunch.com/"), QSize(667, 257),
- QRect(5, 174, 667, 257), QPoint(543,363), 0.6, 0.6);
+ QRect(5, 174, 667, 257), QPoint(543, 363), 0.6, 0.6);
resize(950, 540);
}
m_settings->endArray();
}
-void MainWindow::setWebTitleShown(bool shown) {
+void MainWindow::setWebTitleShown(bool shown)
+{
m_isWebTitleShown = shown;
}
-bool MainWindow::webTitleShown() const {
+bool MainWindow::webTitleShown() const
+{
return m_isWebTitleShown;
}
-void MainWindow::showBrowserToolbar() {
+void MainWindow::showBrowserToolbar()
+{
QAbstractAnimation *anim = createToolbarAnim(m_scrapsToolbar, m_browserToolbar, AntiClockwise, this);
anim->start(QAbstractAnimation::DeleteWhenStopped);
}
-void MainWindow::showScrapsToolbar() {
+void MainWindow::showScrapsToolbar()
+{
QAbstractAnimation *anim = createToolbarAnim(m_browserToolbar, m_scrapsToolbar, Clockwise, this);
anim->start(QAbstractAnimation::DeleteWhenStopped);
}
-void MainWindow::disableScrapSelection() {
+void MainWindow::disableScrapSelection()
+{
if (m_selectScrapsButton)
m_selectScrapsButton->setChecked(false);
}
diff --git a/mainwindow.h b/mainwindow.h
index d79df99..abca69d 100644
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -17,11 +17,13 @@
#include "webscrap.h"
#include "addressbar.h"
-namespace Ui {
- class MainWindow;
+namespace Ui
+{
+class MainWindow;
}
-class MainWindow : public GraphicsView {
+class MainWindow : public GraphicsView
+{
Q_OBJECT
Q_PROPERTY(bool webTitleShown READ webTitleShown WRITE setWebTitleShown)
public:
diff --git a/resizeuihelper.cpp b/resizeuihelper.cpp
index 5719098..0907b79 100644
--- a/resizeuihelper.cpp
+++ b/resizeuihelper.cpp
@@ -9,9 +9,9 @@
#include <QWidget>
ResizeUiHelper::ResizeUiHelper(QGraphicsItem *item, QObject *parent)
- : QObject(parent)
- , m_item(0)
- , m_widget(0)
+ : QObject(parent)
+ , m_item(0)
+ , m_widget(0)
{
item->scene()->addItem(this);
item->installSceneEventFilter(this);
@@ -23,9 +23,9 @@ ResizeUiHelper::ResizeUiHelper(QGraphicsItem *item, QObject *parent)
}
ResizeUiHelper::ResizeUiHelper(QWidget *widget, QObject *parent)
- : QObject(parent)
- , m_item(0)
- , m_widget(0)
+ : QObject(parent)
+ , m_item(0)
+ , m_widget(0)
{
widget->installEventFilter(this);
widget->setMouseTracking(true);
@@ -34,54 +34,65 @@ ResizeUiHelper::ResizeUiHelper(QWidget *widget, QObject *parent)
reset();
}
-void ResizeUiHelper::reset() {
+void ResizeUiHelper::reset()
+{
m_gripsEnabled.fill(true, int(ResizeUiHelper::Left) + 1);
m_gripSize = QSizeF(5, 5);
m_isResizeInProgress = false;
}
-void ResizeUiHelper::setRect(QRectF rect) {
+void ResizeUiHelper::setRect(QRectF rect)
+{
m_rect = rect;
}
-QRectF ResizeUiHelper::rect() const {
+QRectF ResizeUiHelper::rect() const
+{
return m_rect;
}
-void ResizeUiHelper::setResizeEnabled(bool enabled) {
+void ResizeUiHelper::setResizeEnabled(bool enabled)
+{
m_isResizeEnabled = enabled;
}
-bool ResizeUiHelper::resizeEnabled() const {
+bool ResizeUiHelper::resizeEnabled() const
+{
return m_isResizeEnabled;
}
-void ResizeUiHelper::setResizeGripEnabled(GripId grip, bool enabled) {
+void ResizeUiHelper::setResizeGripEnabled(GripId grip, bool enabled)
+{
Q_ASSERT(grip <= ResizeUiHelper::Left);
m_gripsEnabled[int(grip)] = enabled;
}
-bool ResizeUiHelper::resizeGripEnabled(GripId grip) const {
+bool ResizeUiHelper::resizeGripEnabled(GripId grip) const
+{
Q_ASSERT(grip <= ResizeUiHelper::Left);
return m_gripsEnabled[int(grip)];
}
-void ResizeUiHelper::setAllResizeGripsEnabled(bool enabled) {
+void ResizeUiHelper::setAllResizeGripsEnabled(bool enabled)
+{
for (int i = int(ResizeUiHelper::TopLeft); i <= int(ResizeUiHelper::Left); i++)
setResizeGripEnabled(GripId(i), enabled);
}
-void ResizeUiHelper::setGripSize(QSizeF sz) {
+void ResizeUiHelper::setGripSize(QSizeF sz)
+{
m_gripSize = sz;
}
-QSizeF ResizeUiHelper::gripSize() const {
+QSizeF ResizeUiHelper::gripSize() const
+{
return m_gripSize;
}
-QRectF ResizeUiHelper::gripRect(GripId grip) const {
+QRectF ResizeUiHelper::gripRect(GripId grip) const
+{
QPointF pt;
- switch(grip) {
+ switch (grip) {
case ResizeUiHelper::TopLeft:
pt = m_rect.topLeft(); break;
case ResizeUiHelper::TopRight:
@@ -105,8 +116,9 @@ QRectF ResizeUiHelper::gripRect(GripId grip) const {
return QRectF(tl, m_gripSize);
}
-QCursor ResizeUiHelper::gripCursor(GripId grip) const {
- switch(grip) {
+QCursor ResizeUiHelper::gripCursor(GripId grip) const
+{
+ switch (grip) {
case ResizeUiHelper::TopLeft:
case ResizeUiHelper::BottomRight:
return Qt::SizeFDiagCursor;
@@ -124,7 +136,8 @@ QCursor ResizeUiHelper::gripCursor(GripId grip) const {
}
}
-bool ResizeUiHelper::eventFilter(QObject *watched, QEvent * event) {
+bool ResizeUiHelper::eventFilter(QObject *watched, QEvent * event)
+{
Q_UNUSED(watched);
QMouseEvent *mouseEvent = dynamic_cast<QMouseEvent*>(event);
QPointF eventPos;
@@ -134,24 +147,25 @@ bool ResizeUiHelper::eventFilter(QObject *watched, QEvent * event) {
return false;
QEvent::Type eventType;
switch (event->type()) {
- case QEvent::MouseMove:
- if ((mouseEvent->buttons() & Qt::LeftButton) == Qt::LeftButton)
- eventType = QEvent::GraphicsSceneMouseMove;
- else
- eventType = QEvent::GraphicsSceneHoverMove;
- break;
- case QEvent::MouseButtonPress:
- eventType = QEvent::GraphicsSceneMousePress;
- break;
- case QEvent::MouseButtonRelease:
+ case QEvent::MouseMove:
+ if ((mouseEvent->buttons() & Qt::LeftButton) == Qt::LeftButton)
eventType = QEvent::GraphicsSceneMouseMove;
- default:
- return false;
+ else
+ eventType = QEvent::GraphicsSceneHoverMove;
+ break;
+ case QEvent::MouseButtonPress:
+ eventType = QEvent::GraphicsSceneMousePress;
+ break;
+ case QEvent::MouseButtonRelease:
+ eventType = QEvent::GraphicsSceneMouseMove;
+ default:
+ return false;
}
return genericEventFilter(eventType, eventPos);
}
-bool ResizeUiHelper::sceneEventFilter(QGraphicsItem *watched, QEvent* event) {
+bool ResizeUiHelper::sceneEventFilter(QGraphicsItem *watched, QEvent* event)
+{
Q_UNUSED(watched);
QGraphicsSceneHoverEvent *hoverEvent = dynamic_cast<QGraphicsSceneHoverEvent*>(event);
QGraphicsSceneMouseEvent *mouseEvent = dynamic_cast<QGraphicsSceneMouseEvent*>(event);
@@ -165,7 +179,8 @@ bool ResizeUiHelper::sceneEventFilter(QGraphicsItem *watched, QEvent* event) {
return genericEventFilter(event->type(), eventPos);
}
-bool ResizeUiHelper::genericEventFilter(QEvent::Type eventType, QPointF eventPos) {
+bool ResizeUiHelper::genericEventFilter(QEvent::Type eventType, QPointF eventPos)
+{
if (!resizeEnabled())
return false;
if (eventType == QEvent::GraphicsSceneMouseRelease) {
@@ -201,12 +216,13 @@ bool ResizeUiHelper::genericEventFilter(QEvent::Type eventType, QPointF eventPos
return false;
}
-QRectF ResizeUiHelper::rectResize(QRectF originalRect, GripId activeSection, QPointF originalPoint, QPointF newPoint) {
+QRectF ResizeUiHelper::rectResize(QRectF originalRect, GripId activeSection, QPointF originalPoint, QPointF newPoint)
+{
qreal dx1 = 0;
qreal dy1 = 0;
qreal dx2 = 0;
qreal dy2 = 0;
- switch(activeSection) {
+ switch (activeSection) {
case ResizeUiHelper::Left:
dx1 = newPoint.x() - originalPoint.x();
break;
@@ -244,18 +260,21 @@ QRectF ResizeUiHelper::rectResize(QRectF originalRect, GripId activeSection, QPo
return (m_rect = newRect);
}
-void ResizeUiHelper::setWatchedCursor(QCursor cursor) {
+void ResizeUiHelper::setWatchedCursor(QCursor cursor)
+{
if (m_item)
m_item->setCursor(cursor);
if (m_widget)
m_widget->setCursor(cursor);
}
-QRectF ResizeUiHelper::boundingRect() const { // dummy
+QRectF ResizeUiHelper::boundingRect() const // dummy
+{
return QRectF();
}
-void ResizeUiHelper::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) { // dummy
+void ResizeUiHelper::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) // dummy
+{
Q_UNUSED(painter);
Q_UNUSED(option);
Q_UNUSED(widget);
diff --git a/searchlineedit.cpp b/searchlineedit.cpp
index 0923478..715247c 100644
--- a/searchlineedit.cpp
+++ b/searchlineedit.cpp
@@ -14,7 +14,7 @@
#include <QPainter>
SearchLineEdit::SearchLineEdit(QWidget *parent)
- : QLineEdit(parent)
+ : QLineEdit(parent)
{
clearButton = new QToolButton(this);
QPixmap pixmap = QPixmap(":/icons/close.png").scaledToHeight(15, Qt::SmoothTransformation);
@@ -37,7 +37,7 @@ void SearchLineEdit::resizeEvent(QResizeEvent *)
QSize sz = clearButton->sizeHint();
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
clearButton->move(rect().right() - frameWidth - sz.width(),
- (rect().bottom() + 1 - sz.height())/2);
+ (rect().bottom() + 1 - sz.height()) / 2);
}
void SearchLineEdit::updateCloseButton(const QString& text)
diff --git a/webscrap.cpp b/webscrap.cpp
index 22532d4..e6b89af 100644
--- a/webscrap.cpp
+++ b/webscrap.cpp
@@ -52,67 +52,81 @@ WebScrap::WebScrap(QUrl url, QSize pageSize, QRect scrapRect, QGraphicsItem * pa
m_scalePix = QPixmap(":/icons/scale.png").scaled(20, 20, Qt::KeepAspectRatio, Qt::SmoothTransformation);
}
-void WebScrap::setScrapRect(QRect r) {
+void WebScrap::setScrapRect(QRect r)
+{
m_scrapRect = r;
if (! m_isLoading)
page()->mainFrame()->setScrollPosition(scrapRect().topLeft());
}
-QRect WebScrap::scrapRect() const {
+QRect WebScrap::scrapRect() const
+{
return m_scrapRect;
}
-void WebScrap::savePos() {
+void WebScrap::savePos()
+{
m_savedPos = pos();
}
-QPointF WebScrap::savedPos() const {
+QPointF WebScrap::savedPos() const
+{
return m_savedPos;
}
-void WebScrap::setRefreshInterval(int msecs) {
+void WebScrap::setRefreshInterval(int msecs)
+{
m_refreshInterval = msecs;
m_refreshTimer->setInterval(msecs);
m_refreshTimer->start();
}
-int WebScrap::refreshInterval() const {
+int WebScrap::refreshInterval() const
+{
return m_refreshInterval;
}
-const QTimer* WebScrap::refreshTimer() const {
+const QTimer* WebScrap::refreshTimer() const
+{
return m_refreshTimer;
}
-void WebScrap::setDimensionsFixed(bool fixed) {
+void WebScrap::setDimensionsFixed(bool fixed)
+{
m_isDimensionsFixed = fixed;
setMouseClicksEnabled(fixed);
update();
}
-bool WebScrap::dimensionsFixed() const {
+bool WebScrap::dimensionsFixed() const
+{
return m_isDimensionsFixed;
}
-void WebScrap::setMouseClicksEnabled(bool enabled) {
+void WebScrap::setMouseClicksEnabled(bool enabled)
+{
m_isMouseClicksEnabled = enabled;
}
-bool WebScrap::mouseClicksEnabled() const {
+bool WebScrap::mouseClicksEnabled() const
+{
return m_isMouseClicksEnabled;
}
-void WebScrap::onLoadStarted() {
+void WebScrap::onLoadStarted()
+{
m_isLoading = true;
}
-void WebScrap::onLoadFinished() {
+void WebScrap::onLoadFinished()
+{
page()->mainFrame()->setScrollPosition(scrapRect().topLeft());
m_isLoading = false;
update();
}
-void WebScrap::onRefresh() {
+void WebScrap::onRefresh()
+{
if (!m_isDimensionsFixed)
return;
// save current look as an image, so we can paint that while it's loading
@@ -124,11 +138,13 @@ void WebScrap::onRefresh() {
reload();
}
-void WebScrap::openUrlInExternalBrowser(QUrl url) {
+void WebScrap::openUrlInExternalBrowser(QUrl url)
+{
QDesktopServices::openUrl(url);
}
-void WebScrap::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
+void WebScrap::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
+{
if (!dimensionsFixed()) {
QPointF delta = event->lastPos() - event->pos();
setScrapRect(scrapRect().adjusted(delta.x(), delta.y(), delta.x(), delta.y()));
@@ -138,11 +154,12 @@ void WebScrap::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
}
}
-bool WebScrap::event(QEvent *e) {
+bool WebScrap::event(QEvent *e)
+{
if (!mouseClicksEnabled()) {
if (e->type() == QEvent::GraphicsSceneMousePress ||
- e->type() == QEvent::GraphicsSceneMouseRelease ||
- e->type() == QEvent::GraphicsSceneMouseDoubleClick) {
+ e->type() == QEvent::GraphicsSceneMouseRelease ||
+ e->type() == QEvent::GraphicsSceneMouseDoubleClick) {
e->accept();
return true;
}
@@ -150,7 +167,8 @@ bool WebScrap::event(QEvent *e) {
return QGraphicsWebView::event(e);
}
-void WebScrap::paint(QPainter* painter, const QStyleOptionGraphicsItem* options, QWidget* widget) {
+void WebScrap::paint(QPainter* painter, const QStyleOptionGraphicsItem* options, QWidget* widget)
+{
painter->save();
QPainterPath clipPath;
@@ -175,7 +193,7 @@ void WebScrap::paint(QPainter* painter, const QStyleOptionGraphicsItem* options,
painter->setOpacity(0.6);
if (!dimensionsFixed())
painter->drawPixmap(rect().center().x() - m_adjustablePix.width() / 2, rect().center().y() - m_adjustablePix.height() / 2,
- m_adjustablePix);
+ m_adjustablePix);
} else {
painter->setOpacity(1.0);
@@ -191,16 +209,17 @@ void WebScrap::paint(QPainter* painter, const QStyleOptionGraphicsItem* options,
painter->restore();
}
-bool WebScrap::highlightText(const QString& text) {
+bool WebScrap::highlightText(const QString& text)
+{
page()->findText(QString(""), QWebPage::HighlightAllOccurrences); // clear any existing highlight
if (text.isEmpty())
return false;
if (page()->findText(text, QWebPage::HighlightAllOccurrences)) {
- foreach (QWebElement element, page()->mainFrame()->findAllElements("*")) {
+ foreach(QWebElement element, page()->mainFrame()->findAllElements("*")) {
if (element.firstChild().isNull()
- && element.geometry().intersects(m_scrapRect)
- && element.toPlainText().contains(text, Qt::CaseInsensitive))
- return true;
+ && element.geometry().intersects(m_scrapRect)
+ && element.toPlainText().contains(text, Qt::CaseInsensitive))
+ return true;
}
}
if ((url().host() + url().path()).contains(text, Qt::CaseInsensitive))
@@ -211,21 +230,21 @@ bool WebScrap::highlightText(const QString& text) {
}
WebScrapContainer::WebScrapContainer(WebScrap *scrap, QGraphicsScene *scene, qreal xScale, qreal yScale)
- : QGraphicsWidget(0)
- , m_scene(scene)
- , m_scrap(scrap)
- , m_located(false)
- , m_searchMatched(false)
- , m_enterAnimation(0)
- , m_leaveAnimation(0)
+ : QGraphicsWidget(0)
+ , m_scene(scene)
+ , m_scrap(scrap)
+ , m_located(false)
+ , m_searchMatched(false)
+ , m_enterAnimation(0)
+ , m_leaveAnimation(0)
{
scene->addItem(this);
// create the frame
QRect scrapRect = scrap->scrapRect();
QRect containerRect(0, 0,
- (scrapRect.width() * xScale) + s_padding * 2,
- (scrapRect.height() * yScale) + s_titlePadding + s_padding);
+ (scrapRect.width() * xScale) + s_padding * 2,
+ (scrapRect.height() * yScale) + s_titlePadding + s_padding);
setGeometry(containerRect);
setBoundingRect(containerRect);
setFlag(QGraphicsItem::ItemIsMovable, true);
@@ -264,31 +283,37 @@ WebScrapContainer::WebScrapContainer(WebScrap *scrap, QGraphicsScene *scene, qre
setGraphicsEffect(m_glow);
}
-void WebScrapContainer::setBoundingRect(QRectF rect) {
+void WebScrapContainer::setBoundingRect(QRectF rect)
+{
m_boundingRect = rect;
}
-QRectF WebScrapContainer::boundingRect() const {
+QRectF WebScrapContainer::boundingRect() const
+{
return m_boundingRect;
}
-void WebScrapContainer::setTitle(const QString& title) {
+void WebScrapContainer::setTitle(const QString& title)
+{
m_title = title;
}
-void WebScrapContainer::mousePressEvent(QGraphicsSceneMouseEvent *event) {
+void WebScrapContainer::mousePressEvent(QGraphicsSceneMouseEvent *event)
+{
emit frameClicked();
QGraphicsWidget::mousePressEvent(event);
}
-void WebScrapContainer::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
+void WebScrapContainer::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
+{
QPropertyAnimation *enterAnim = enterAnimation();
if (enterAnim)
enterAnim->setEndValue(pos());
QGraphicsWidget::mouseReleaseEvent(event);
}
-void WebScrapContainer::createToolbar() {
+void WebScrapContainer::createToolbar()
+{
m_toolbar = new GraphicsToolBar(m_scene);
QString stylesheet = "QToolButton {"
" margin: 0px;"
@@ -333,7 +358,8 @@ void WebScrapContainer::createToolbar() {
connect(m_reloadButton, SIGNAL(clicked()), m_scrap, SLOT(onRefresh()));
}
-void WebScrapContainer::createEditToolbar() {
+void WebScrapContainer::createEditToolbar()
+{
m_editToolbar = new GraphicsToolBar(m_scene);
QLabel *label = new QLabel(tr("Refresh every"));
m_refreshIntervalLineEdit = new QLineEdit;
@@ -381,7 +407,8 @@ void WebScrapContainer::createEditToolbar() {
connect(m_resetZoomPushButton, SIGNAL(clicked()), SLOT(handleResetZoomClicked()));
}
-void WebScrapContainer::handleCloseButtonClicked() {
+void WebScrapContainer::handleCloseButtonClicked()
+{
QMessageBox msg;
msg.setWindowTitle("Removing scrap");
msg.setText(tr("Are you sure you want to remove this scrap?"));
@@ -394,18 +421,19 @@ void WebScrapContainer::handleCloseButtonClicked() {
emit removeSelf();
}
-void WebScrapContainer::handleEditButtonClicked(bool checked) {
+void WebScrapContainer::handleEditButtonClicked(bool checked)
+{
m_editToolbar->setVisible(checked);
m_scrap->setDimensionsFixed(!checked);
if (!checked) {
int minutes = m_refreshIntervalLineEdit->text().toInt();
switch (m_refreshUnitComboBox->currentIndex()) {
- case 2: minutes *= 24; // days
- case 1: minutes *= 60; // hours
- case 0: minutes *= 1; // minutes
- default: break;
- }
- m_scrap->setRefreshInterval(minutes * 60 * 1000); // milliseconds
+ case 2: minutes *= 24; // days
+ case 1: minutes *= 60; // hours
+ case 0: minutes *= 1; // minutes
+ default: break;
+ }
+ m_scrap->setRefreshInterval(minutes * 60 * 1000); // milliseconds
}
if (checked)
setGraphicsEffect(0);
@@ -416,7 +444,8 @@ void WebScrapContainer::handleEditButtonClicked(bool checked) {
m_closeButton->setEnabled(!checked);
}
-void WebScrapContainer::handleResetZoomClicked() {
+void WebScrapContainer::handleResetZoomClicked()
+{
m_scrapScale->setXScale(1.0);
m_scrapScale->setYScale(1.0);
QSize scrapSize = webScrap()->size().toSize();
@@ -427,7 +456,8 @@ void WebScrapContainer::handleResetZoomClicked() {
m_resizer->setRect(m_scrap->boundingRect());
}
-void WebScrapContainer::handleRectResized(QRectF rect) {
+void WebScrapContainer::handleRectResized(QRectF rect)
+{
if (m_scrap->dimensionsFixed()) {
m_scrapScale->setXScale(rect.width() * m_scrapScale->xScale() / m_scrap->scrapRect().width());
m_scrapScale->setYScale(rect.height() * m_scrapScale->yScale() / m_scrap->scrapRect().height());
@@ -446,29 +476,35 @@ void WebScrapContainer::handleRectResized(QRectF rect) {
update();
}
-WebScrap* WebScrapContainer::webScrap() const {
+WebScrap* WebScrapContainer::webScrap() const
+{
return m_scrap;
}
-const QGraphicsScale* WebScrapContainer::scrapScale() const {
+const QGraphicsScale* WebScrapContainer::scrapScale() const
+{
return m_scrapScale;
}
-void WebScrapContainer::setLocated(bool located) {
+void WebScrapContainer::setLocated(bool located)
+{
m_located = located;
updateGlow();
}
-void WebScrapContainer::setSearchMatched(bool matched) {
+void WebScrapContainer::setSearchMatched(bool matched)
+{
m_searchMatched = matched;
updateGlow();
}
-QGraphicsDropShadowEffect* WebScrapContainer::glow() const {
+QGraphicsDropShadowEffect* WebScrapContainer::glow() const
+{
return m_glow;
}
-void WebScrapContainer::updateGlow() {
+void WebScrapContainer::updateGlow()
+{
if (m_located)
glow()->setProperty("color", Qt::blue);
else if (m_searchMatched)
@@ -477,23 +513,28 @@ void WebScrapContainer::updateGlow() {
glow()->setProperty("color", Qt::black);
}
-void WebScrapContainer::setEnterAnimation(QPropertyAnimation *animation) {
+void WebScrapContainer::setEnterAnimation(QPropertyAnimation *animation)
+{
m_enterAnimation = animation;
}
-QPropertyAnimation* WebScrapContainer::enterAnimation() const {
+QPropertyAnimation* WebScrapContainer::enterAnimation() const
+{
return m_enterAnimation;
}
-void WebScrapContainer::setLeaveAnimation(QPropertyAnimation *animation) {
+void WebScrapContainer::setLeaveAnimation(QPropertyAnimation *animation)
+{
m_leaveAnimation = animation;
}
-QPropertyAnimation* WebScrapContainer::leaveAnimation() const {
+QPropertyAnimation* WebScrapContainer::leaveAnimation() const
+{
return m_leaveAnimation;
}
-void WebScrapContainer::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) {
+void WebScrapContainer::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
+{
Q_UNUSED(widget);
painter->setPen(Qt::NoPen);
painter->setBrush(m_backgroundBrush);
diff --git a/webscrap.h b/webscrap.h
index aad2d9f..a668e26 100644
--- a/webscrap.h
+++ b/webscrap.h
@@ -60,7 +60,8 @@ private:
bool m_isLoading, m_isMouseClicksEnabled;
};
-class WebScrapContainer : public QGraphicsWidget {
+class WebScrapContainer : public QGraphicsWidget
+{
Q_OBJECT
public:
const static int s_padding, s_titlePadding;
diff --git a/webview.cpp b/webview.cpp
index 7d8daa6..0fbe6bc 100644
--- a/webview.cpp
+++ b/webview.cpp
@@ -23,7 +23,8 @@ WebView::WebView(QGraphicsScene *scene, QGraphicsItem * parent)
connect(m_resizer, SIGNAL(rectResized(QRectF)), SLOT(setScrolledScrapRect(QRectF)));
}
-void WebView::createAddScrapToolbar() {
+void WebView::createAddScrapToolbar()
+{
m_addScrapToolbar = new GraphicsToolBar(m_scene);
m_cancelButton = new QPushButton(tr("Cancel"));
m_addButton = new QPushButton(tr("Add"));
@@ -39,7 +40,8 @@ void WebView::createAddScrapToolbar() {
connect(m_addButton, SIGNAL(clicked()), SLOT(addScrap()));
}
-void WebView::showAddScrapToolbar() {
+void WebView::showAddScrapToolbar()
+{
if (!m_scrapRect.isValid())
return;
m_addScrapToolbar->setPos(m_scrapRect.translated(-page()->mainFrame()->scrollPosition()).topRight());
@@ -50,21 +52,25 @@ void WebView::showAddScrapToolbar() {
m_addScrapToolbar->setVisible(true);
}
-void WebView::hideAddScrapToolbar() {
+void WebView::hideAddScrapToolbar()
+{
m_addScrapToolbar->setVisible(false);
}
-void WebView::setScrapRect(QRect rect) {
+void WebView::setScrapRect(QRect rect)
+{
QRect updateRect = m_scrapRect.united(rect);
m_scrapRect = rect;
update(updateRect.translated(-page()->mainFrame()->scrollPosition()));
}
-void WebView::setScrolledScrapRect(QRectF rect) {
+void WebView::setScrolledScrapRect(QRectF rect)
+{
setScrapRect(rect.translated(page()->mainFrame()->scrollPosition()).toRect());
}
-void WebView::selectScrap() {
+void WebView::selectScrap()
+{
m_scrapSelected = true;
showAddScrapToolbar();
m_resizer->setRect(m_scrapRect.translated(-page()->mainFrame()->scrollPosition()));
@@ -73,7 +79,8 @@ void WebView::selectScrap() {
page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
}
-void WebView::unselectScrap() {
+void WebView::unselectScrap()
+{
m_scrapSelected = false;
hideAddScrapToolbar();
m_resizer->setResizeEnabled(false);
@@ -82,14 +89,16 @@ void WebView::unselectScrap() {
page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAsNeeded);
}
-void WebView::addScrap() {
+void WebView::addScrap()
+{
if (m_scrapSelectionEnabled && m_scrapSelected && m_scrapRect.isValid())
emit scrapAdded(url(), page()->viewportSize(), m_scrapRect, m_scrapRect.translated(-page()->mainFrame()->scrollPosition()).topLeft());
m_scrapSelected = false;
hideAddScrapToolbar();
}
-void WebView::setScrapSelectionEnabled(bool enabled) {
+void WebView::setScrapSelectionEnabled(bool enabled)
+{
if (m_scrapSelectionEnabled == enabled)
return;
m_scrapSelectionEnabled = enabled;
@@ -97,7 +106,8 @@ void WebView::setScrapSelectionEnabled(bool enabled) {
unselectScrap();
}
-bool WebView::scrapSelectionEnabled() const {
+bool WebView::scrapSelectionEnabled() const
+{
return m_scrapSelectionEnabled;
}
@@ -109,8 +119,8 @@ void WebView::hoverMoveEvent(QGraphicsSceneHoverEvent* event)
}
QWebFrame* mainFrame = page()->mainFrame();
if (mainFrame != page()->frameAt(event->pos().toPoint()) ||
- mainFrame->scrollBarGeometry(Qt::Horizontal).contains(event->pos().toPoint()) ||
- mainFrame->scrollBarGeometry(Qt::Vertical).contains(event->pos().toPoint())) {
+ mainFrame->scrollBarGeometry(Qt::Horizontal).contains(event->pos().toPoint()) ||
+ mainFrame->scrollBarGeometry(Qt::Vertical).contains(event->pos().toPoint())) {
m_scrapRect = QRect();
QGraphicsWebView::hoverMoveEvent(event);
return;
@@ -142,7 +152,7 @@ void WebView::mousePressEvent(QGraphicsSceneMouseEvent *event)
return;
}
if (page()->mainFrame()->scrollBarGeometry(Qt::Horizontal).contains(event->pos().toPoint()) ||
- page()->mainFrame()->scrollBarGeometry(Qt::Vertical).contains(event->pos().toPoint())) {
+ page()->mainFrame()->scrollBarGeometry(Qt::Vertical).contains(event->pos().toPoint())) {
QGraphicsWebView::mousePressEvent(event);
return;
}
@@ -155,7 +165,8 @@ void WebView::mousePressEvent(QGraphicsSceneMouseEvent *event)
}
}
-void WebView::keyPressEvent(QKeyEvent *event) {
+void WebView::keyPressEvent(QKeyEvent *event)
+{
if (m_scrapSelectionEnabled && event->key() == Qt::Key_Escape) {
unselectScrap();
return;
@@ -216,18 +227,22 @@ void WebView::paint(QPainter* painter, const QStyleOptionGraphicsItem* options,
}
}
-void WebView::show() {
+void WebView::show()
+{
QGraphicsWebView::show();
}
-void WebView::hide() {
+void WebView::hide()
+{
QGraphicsWebView::hide();
}
-void WebView::enableCachedMode() {
+void WebView::enableCachedMode()
+{
setCacheMode(QGraphicsItem::DeviceCoordinateCache, QSize(1000, 1000));
}
-void WebView::disableCachedMode() {
+void WebView::disableCachedMode()
+{
setCacheMode(QGraphicsItem::NoCache);
}