Add a method to position the dialog just with the QGV

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=754467
This commit is contained in:
Alexis Ménard 2007-12-29 21:38:00 +00:00
parent 87429288bc
commit b7e978d04c
2 changed files with 28 additions and 17 deletions

View File

@ -171,12 +171,15 @@ void Dialog::position(QGraphicsSceneEvent *event, const QRectF boundingRect, QPo
QWidget *viewWidget = event->widget() ? event->widget()->parentWidget() : 0;
//QPointF scenePos = mapToScene(boundingRect.topLeft());
QGraphicsView *view = qobject_cast<QGraphicsView*>(viewWidget);
position(view,boundingRect,scenePos);
}
void Dialog::position(QGraphicsView * view,const QRectF boundingRect,QPointF scenePos)
{
if (view) {
QPoint viewPos = view->mapFromScene(scenePos);
QPoint globalPos = view->mapToGlobal(viewPos);
if ((globalPos.ry()-height())< 0) {
//scenePos = mapToScene(boundingRect.bottomLeft());
scenePos = QPointF(scenePos.x() + boundingRect.width(), scenePos.y() + boundingRect.height());
viewPos = view->mapFromScene(scenePos);
globalPos = view->mapToGlobal(viewPos)+QPoint(0,10);

View File

@ -24,6 +24,7 @@
#include <QtGui/QWidget>
#include <QtGui/QGraphicsSceneEvent>
#include <QtGui/QGraphicsView>
#include <plasma/plasma_export.h>
@ -63,6 +64,13 @@ class PLASMA_EXPORT Dialog : public QWidget
*/
void position(QGraphicsSceneEvent *event, const QRectF boundingRect, QPointF scenePos);
/**
* @arg view The QGV where is displayed the applet
* @arg scenePos the absolute position on the scene.
* @arg boundingRect the boundingRect() from the applet.
*/
void position(QGraphicsView * view,const QRectF boundingRect,QPointF scenePos);
protected:
/**
* Reimplemented from QWidget