Commit cac0425c authored by Boudewijn Rempt's avatar Boudewijn Rempt

Move KoView's autoscrolling to Sheets::View

That's the only place where this code was used, so move it there.
parent dc1fa3f7
......@@ -55,7 +55,6 @@
#include <kconfiggroup.h>
#include <kdeprintdialog.h>
#include <QTimer>
#include <QDockWidget>
#include <QToolBar>
#include <QApplication>
......@@ -92,7 +91,6 @@ public:
bool documentDeleted; // true when document gets deleted [can't use document==0
// since this only happens in ~QObject, and views
// get deleted by ~KoDocument].
QTimer *scrollTimer;
// Hmm sorry for polluting the private class with such a big inner class.
......@@ -188,9 +186,6 @@ KoView::KoView(KoPart *part, KoDocument *document, QWidget *parent)
this, SLOT(slotClearStatusText()));
}
d->scrollTimer = new QTimer(this);
connect(d->scrollTimer, SIGNAL(timeout()), this, SLOT(slotAutoScroll()));
// add all plugins.
foreach(const QString & docker, KoDockRegistry::instance()->keys()) {
KoDockFactoryBase *factory = KoDockRegistry::instance()->value(docker);
......@@ -205,7 +200,6 @@ KoView::KoView(KoPart *part, KoDocument *document, QWidget *parent)
KoView::~KoView()
{
delete d->scrollTimer;
if (!d->documentDeleted) {
if (d->document) {
d->part->removeView(this);
......@@ -363,57 +357,6 @@ void KoView::removeStatusBarItem(QWidget *widget)
}
}
void KoView::enableAutoScroll()
{
d->scrollTimer->start(50);
}
void KoView::disableAutoScroll()
{
d->scrollTimer->stop();
}
int KoView::autoScrollAcceleration(int offset) const
{
if (offset < 40)
return offset;
else
return offset*offset / 40;
}
void KoView::slotAutoScroll()
{
QPoint scrollDistance;
bool actuallyDoScroll = false;
QPoint pos(mapFromGlobal(QCursor::pos()));
//Provide progressive scrolling depending on the mouse position
if (pos.y() < topBorder()) {
scrollDistance.setY((int) - autoScrollAcceleration(- pos.y() + topBorder()));
actuallyDoScroll = true;
} else if (pos.y() > height() - bottomBorder()) {
scrollDistance.setY((int) autoScrollAcceleration(pos.y() - height() + bottomBorder()));
actuallyDoScroll = true;
}
if (pos.x() < leftBorder()) {
scrollDistance.setX((int) - autoScrollAcceleration(- pos.x() + leftBorder()));
actuallyDoScroll = true;
} else if (pos.x() > width() - rightBorder()) {
scrollDistance.setX((int) autoScrollAcceleration(pos.x() - width() + rightBorder()));
actuallyDoScroll = true;
}
if (actuallyDoScroll) {
pos = canvas()->mapFrom(this, pos);
QMouseEvent* event = new QMouseEvent(QEvent::MouseMove, pos, Qt::NoButton, Qt::NoButton,
QApplication::keyboardModifiers());
QApplication::postEvent(canvas(), event);
emit autoScroll(scrollDistance);
}
}
KoPrintJob * KoView::createPrintJob()
{
kWarning(30003) << "Printing not implemented in this application";
......
......@@ -167,16 +167,6 @@ public:
*/
virtual QWidget *canvas() const;
/**
* Sets up so that autoScroll signals are emitted when the mouse pointer is outside the view
*/
void enableAutoScroll();
/**
* Stops the emitting of autoScroll signals
*/
void disableAutoScroll();
/**
* In order to print the document represented by this view a new print job should
* be constructed that is capable of doing the printing.
......@@ -277,21 +267,18 @@ protected:
QString newObjectName();
signals:
void autoScroll(const QPoint &scrollDistance);
void regionInvalidated(const QRegion &region, bool erase);
void invalidated();
protected slots:
virtual void slotAutoScroll();
virtual void changeAuthorProfile(const QString &profileName);
private:
virtual void setupGlobalActions(void);
KoViewPrivate * const d;
int autoScrollAcceleration(int offset) const;
};
#endif
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