[QGIS Commit] r8642 -
branches/advanced_printing_branch/src/app/composer
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Tue Jun 10 09:42:51 EDT 2008
Author: mhugent
Date: 2008-06-10 09:42:51 -0400 (Tue, 10 Jun 2008)
New Revision: 8642
Modified:
branches/advanced_printing_branch/src/app/composer/qgscomposeritem.cpp
branches/advanced_printing_branch/src/app/composer/qgscomposeritem.h
branches/advanced_printing_branch/src/app/composer/qgscomposerscalebar.cpp
branches/advanced_printing_branch/src/app/composer/qgscomposerscalebar.h
branches/advanced_printing_branch/src/app/composer/qgscomposerview.cpp
branches/advanced_printing_branch/src/app/composer/qgscomposition.cpp
Log:
Implement hover event for items to show resize cursor also if mouse button is not pressed
Modified: branches/advanced_printing_branch/src/app/composer/qgscomposeritem.cpp
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgscomposeritem.cpp 2008-06-10 13:39:26 UTC (rev 8641)
+++ branches/advanced_printing_branch/src/app/composer/qgscomposeritem.cpp 2008-06-10 13:42:51 UTC (rev 8642)
@@ -30,12 +30,14 @@
{
mPlotStyle = QgsComposition::Preview;
setFlag(QGraphicsItem::ItemIsSelectable, true);
+ setAcceptsHoverEvents(true);
}
QgsComposerItem::QgsComposerItem(qreal x, qreal y, qreal width, qreal height, QGraphicsItem* parent): QGraphicsRectItem(0, 0, width, height, parent), mBoundingResizeRectangle(0), mFrame(true)
{
mPlotStyle = QgsComposition::Preview;
setFlag(QGraphicsItem::ItemIsSelectable, true);
+ setAcceptsHoverEvents(true);
QTransform t;
t.translate(x, y);
@@ -344,3 +346,12 @@
double dpiPaintDevice = (p->device()->logicalDpiX() + p->device()->logicalDpiY()) / 2;
return (25.4 / dpiPaintDevice / 0.376); //consider 1 point equals 0.376 mm
}
+
+void QgsComposerItem::hoverMoveEvent ( QGraphicsSceneHoverEvent * event )
+{
+ qWarning("QgsComposerItem::hoverMoveEvent");
+ if(isSelected())
+ {
+ setCursor(cursorForPosition(event->pos()));
+ }
+}
Modified: branches/advanced_printing_branch/src/app/composer/qgscomposeritem.h
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgscomposeritem.h 2008-06-10 13:39:26 UTC (rev 8641)
+++ branches/advanced_printing_branch/src/app/composer/qgscomposeritem.h 2008-06-10 13:42:51 UTC (rev 8642)
@@ -119,6 +119,8 @@
virtual void mousePressEvent ( QGraphicsSceneMouseEvent * event );
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
+ virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
+
/**Finds out the appropriate cursor for the current mouse position in the widget (e.g. move in the middle, resize at border)*/
Qt::CursorShape cursorForPosition(const QPointF& itemCoordPos);
Modified: branches/advanced_printing_branch/src/app/composer/qgscomposerscalebar.cpp
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgscomposerscalebar.cpp 2008-06-10 13:39:26 UTC (rev 8641)
+++ branches/advanced_printing_branch/src/app/composer/qgscomposerscalebar.cpp 2008-06-10 13:42:51 UTC (rev 8642)
@@ -15,6 +15,26 @@
***************************************************************************/
#include "qgscomposerscalebar.h"
+
+QgsComposerScaleBar::QgsComposerScaleBar(QgsComposition* composition)
+{
+
+}
+
+QgsComposerScaleBar::~QgsComposerScaleBar()
+{
+
+}
+
+void QgsComposerScaleBar::paint (QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget)
+{
+ //soon...
+}
+
+
+
+#if 0
+#include "qgscomposerscalebar.h"
#include "qgscomposermap.h"
#include "qgsproject.h"
@@ -576,3 +596,5 @@
{
return true;
}
+
+#endif //0
Modified: branches/advanced_printing_branch/src/app/composer/qgscomposerscalebar.h
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgscomposerscalebar.h 2008-06-10 13:39:26 UTC (rev 8641)
+++ branches/advanced_printing_branch/src/app/composer/qgscomposerscalebar.h 2008-06-10 13:42:51 UTC (rev 8642)
@@ -16,6 +16,56 @@
#ifndef QGSCOMPOSERSCALEBAR_H
#define QGSCOMPOSERSCALEBAR_H
+#include "qgscomposeritem.h"
+#include <QPen>
+
+class QgsComposerScaleBar: public QgsComposerItem
+{
+ public:
+
+ enum Style
+ {
+ Bar_Ticks_Down,
+ Bar_Ticks_Middle,
+ Bar_Ticks_Up,
+ Single_Box,
+ Double_Box,
+ };
+
+ QgsComposerScaleBar(QgsComposition* composition);
+ ~QgsComposerScaleBar();
+
+ /** \brief Reimplementation of QCanvasItem::paint*/
+ void paint (QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget);
+
+
+ protected:
+
+ /**Reference to composer map object*/
+ QgsComposerMap* mComposerMap;
+ /**Number of segments on right side*/
+ int mNumSegments;
+ /**Number of segments on left side*/
+ int mNumSegmentsLeft;
+ /**Size of a segment (in map units)*/
+ int mNumUnitsPerSegment;
+ /**Labeling of map units*/
+ QString mUnitLabeling;
+ /**Font*/
+ QFont mFont;
+ /**Outline*/
+ QPen mPen;
+ /**Fill*/
+ QBrush mBrush;
+ /**Height of bars/lines*/
+ double mHeight;
+
+};
+
+#endif //QGSCOMPOSERSCALEBAR_H
+
+#if 0
+
#include "ui_qgscomposerscalebarbase.h"
#include "qgscomposeritem.h"
#include <QAbstractGraphicsShapeItem>
@@ -149,4 +199,4 @@
void sizeChanged ( void );
};
-#endif
+#endif //0
Modified: branches/advanced_printing_branch/src/app/composer/qgscomposerview.cpp
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgscomposerview.cpp 2008-06-10 13:39:26 UTC (rev 8641)
+++ branches/advanced_printing_branch/src/app/composer/qgscomposerview.cpp 2008-06-10 13:42:51 UTC (rev 8642)
@@ -62,6 +62,7 @@
mComposer->composition()->mouseMoveEvent(e);
if(mComposer->composition()->tool() == QgsComposition::Select)
{
+ qWarning("using default implementation of mouseMoveEvent");
QGraphicsView::mouseMoveEvent(e);
}
}
Modified: branches/advanced_printing_branch/src/app/composer/qgscomposition.cpp
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgscomposition.cpp 2008-06-10 13:39:26 UTC (rev 8641)
+++ branches/advanced_printing_branch/src/app/composer/qgscomposition.cpp 2008-06-10 13:42:51 UTC (rev 8642)
@@ -752,7 +752,7 @@
}
// Start new
- if ( tool == AddVectorLegend ) { // Create temporary object
+ /*if ( tool == AddVectorLegend ) { // Create temporary object
if ( mNewCanvasItem ) delete mNewCanvasItem;
// Create new object outside the visible area
@@ -763,7 +763,7 @@
mView->viewport()->setMouseTracking ( true ); // to recieve mouse move
}
- /*else if ( tool == AddLabel ) {
+ else if ( tool == AddLabel ) {
if ( mNewCanvasItem ) delete mNewCanvasItem;
// Create new object outside the visible area
@@ -774,7 +774,7 @@
//mComposer->showItemOptions(lab);
mView->viewport()->setMouseTracking ( true ); // to recieve mouse move
- }*/
+ }
else if ( tool == AddScalebar ) {
if ( mNewCanvasItem ) delete mNewCanvasItem;
@@ -925,6 +925,7 @@
bool QgsComposition::writeSettings ( void )
{
+#if 0
QString path, val;
path.sprintf("/composition_%d/", mId );
QgsProject::instance()->writeEntry( "Compositions", path+"width", mUserPaperWidth );
@@ -938,12 +939,14 @@
}
QgsProject::instance()->writeEntry( "Compositions", path+"orientation", val );
-
+#endif //0
return true;
}
bool QgsComposition::readSettings ( void )
{
+#if 0
+
#ifdef QGISDEBUG
std::cout << "QgsComposition::readSettings" << std::endl;
#endif
@@ -1024,7 +1027,7 @@
mCanvas->update();
-
+#endif //0
return true;
}
More information about the QGIS-commit
mailing list