[Kst] branches/work/kst/portto4/kst/src/libkstapp
Adam Treat
treat at kde.org
Sat May 26 02:12:00 CEST 2007
SVN commit 668329 by treat:
* Initialize the scene rect to the size of whatever
the view is when it is first shown. Not sure if this
is what we really want.
M +14 -2 kstplotview.cpp
M +3 -0 kstplotview.h
--- branches/work/kst/portto4/kst/src/libkstapp/kstplotview.cpp #668328:668329
@@ -14,6 +14,7 @@
#include "kstapplication.h"
#include <QDebug>
+#include <QTimer>
#include <QUndoStack>
#include <QResizeEvent>
#include <QGraphicsScene>
@@ -116,11 +117,18 @@
}
}
+
void KstPlotView::setVisible(bool visible) {
QGraphicsView::setVisible(visible);
+ QTimer::singleShot(0, this, SLOT(initializeSceneRect()));
+}
- setSceneRect(QRectF(0, 0, width(), height()));
+void KstPlotView::initializeSceneRect() {
+
+ //Maybe this should be the size of the desktop?
+ setSceneRect(QRectF(0, 0, width() - 1.0, height() - 1.0));
+
//See what I'm doing
QLinearGradient l(0,0,0,height());
l.setColorAt(0, Qt::white);
@@ -128,9 +136,13 @@
setBackgroundBrush(l);
}
+
void KstPlotView::resizeEvent(QResizeEvent *event) {
QGraphicsView::resizeEvent(event);
- fitInView(sceneRect());
+
+ if (size() != sceneRect().size() && sceneRect().isValid()) {
+ fitInView(sceneRect());
+ }
}
#include "kstplotview.moc"
--- branches/work/kst/portto4/kst/src/libkstapp/kstplotview.h #668328:668329
@@ -51,6 +51,9 @@
void setVisible(bool visible);
void resizeEvent(QResizeEvent *event);
+private Q_SLOTS:
+ void initializeSceneRect();
+
private:
QUndoStack *_undoStack;
KstPlotItem *_currentPlotItem;
More information about the Kst
mailing list