Skip to content

Commit

Permalink
Move annotation items and widgets from gui to app
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13190 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Mar 29, 2010
1 parent 466e864 commit 9f357ab
Show file tree
Hide file tree
Showing 18 changed files with 36 additions and 41 deletions.
5 changes: 1 addition & 4 deletions python/gui/qgsannotationitem.sip
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ class QgsAnnotationItem: QgsMapCanvasItem
QgsAnnotationItem( QgsMapCanvas* mapCanvas );
virtual ~QgsAnnotationItem();

/**Creates an editor widget (caller takes ownership)*/
virtual QDialog* createEditor() = 0;

void updatePosition();

QRectF boundingRect() const;
Expand Down Expand Up @@ -71,4 +68,4 @@ class QgsAnnotationItem: QgsMapCanvasItem

void _writeXML( QDomDocument& doc, QDomElement& itemElem ) const;
void _readXML( const QDomDocument& doc, const QDomElement& annotationElem );
};
};
5 changes: 1 addition & 4 deletions python/gui/qgsformannotationitem.sip
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ class QgsFormAnnotationItem: QObject, QgsAnnotationItem
//! paint function called by map canvas
void paint( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 );

/**Create a configuration dialog*/
QDialog* createEditor();

QSizeF minimumFrameSize() const;
/**Returns the optimal frame size*/
QSizeF preferredFrameSize() const;
Expand All @@ -28,4 +25,4 @@ class QgsFormAnnotationItem: QObject, QgsAnnotationItem

void writeXML( QDomDocument& doc ) const;
void readXML( const QDomDocument& doc, const QDomElement& itemElem );
};
};
4 changes: 1 addition & 3 deletions python/gui/qgstextannotationitem.sip
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ class QgsTextAnnotationItem: QgsAnnotationItem
QgsTextAnnotationItem( QgsMapCanvas* canvas );
~QgsTextAnnotationItem();

QDialog* createEditor();

/**Returns document (caller takes ownership)*/
QTextDocument* document() const;
/**Sets document (does not take ownership)*/
Expand All @@ -18,4 +16,4 @@ class QgsTextAnnotationItem: QgsAnnotationItem
void readXML( const QDomDocument& doc, const QDomElement& itemElem );

void paint( QPainter* painter );
};
};
9 changes: 6 additions & 3 deletions src/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ SET(QGIS_APP_SRCS
qgisappinterface.cpp
qgsabout.cpp
qgsaddattrdialog.cpp
qgsannotationwidget.cpp
qgsattributeactiondialog.cpp
qgsattributedialog.cpp
qgsattributetypedialog.cpp
Expand All @@ -17,6 +18,7 @@ SET(QGIS_APP_SRCS
qgscustomprojectiondialog.cpp
qgsdbfilterproxymodel.cpp
qgsdbtablemodel.cpp
qgsformannotationdialog.cpp
qgsspatialitefilterproxymodel.cpp
qgsspatialitetablemodel.cpp
qgsdelattrdialog.cpp
Expand Down Expand Up @@ -65,6 +67,7 @@ SET(QGIS_APP_SRCS
qgsprojectproperties.cpp
qgsrasterlayerproperties.cpp
qgssearchquerybuilder.cpp
qgstextannotationdialog.cpp
qgswmssourceselect.cpp
qgsshortcutsmanager.cpp
qgssinglesymboldialog.cpp
Expand Down Expand Up @@ -126,6 +129,7 @@ SET (QGIS_APP_MOC_HDRS
qgisappinterface.h
qgsabout.h
qgsaddattrdialog.h
qgsannotationwidget.h
qgsattributeactiondialog.h
qgsattributedialog.h
qgsattributetypedialog.h
Expand All @@ -137,15 +141,14 @@ SET (QGIS_APP_MOC_HDRS
qgscustomprojectiondialog.h
qgsdelattrdialog.h
qgsfieldcalculator.h
qgsformannotationdialog.h
qgsmaptoolmeasureangle.h
qgsnewvectorlayerdialog.h
qgsgraduatedsymboldialog.h
qgshelpviewer.h
qgsidentifyresults.h
qgslabeldialog.h

qgsmanageconnectionsdialog.h

qgsmaptoolidentify.h
qgsmaptoolsplitfeatures.h
qgsmaptoolvertexedit.h
Expand All @@ -161,7 +164,6 @@ SET (QGIS_APP_MOC_HDRS
qgsmaptooldeletevertex.h
qgsmaptoolmovevertex.h
qgsmaptoolsimplify.h

qgsmeasuretool.h
qgsmeasuredialog.h
qgsmergeattributesdialog.h
Expand All @@ -172,6 +174,7 @@ SET (QGIS_APP_MOC_HDRS
qgsprojectproperties.h
qgsrasterlayerproperties.h
qgssearchquerybuilder.h
qgstextannotationdialog.h
qgswmssourceselect.h
qgssinglesymboldialog.h
qgssnappingdialog.h
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
26 changes: 25 additions & 1 deletion src/app/qgsmaptoolannotation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
***************************************************************************/

#include "qgsmaptoolannotation.h"
#include "qgsformannotationdialog.h"
#include "qgsformannotationitem.h"
#include "qgslogger.h"
#include "qgsmapcanvas.h"
#include "qgstextannotationdialog.h"
#include "qgstextannotationitem.h"
#include <QDialog>
#include <QMouseEvent>
Expand All @@ -39,6 +41,28 @@ QgsAnnotationItem* QgsMapToolAnnotation::createItem( QMouseEvent* e )
return 0;
}

QDialog* QgsMapToolAnnotation::createItemEditor( QgsAnnotationItem* item )
{
if ( !item )
{
return 0;
}

QgsTextAnnotationItem* tItem = dynamic_cast<QgsTextAnnotationItem*>( item );
if ( tItem )
{
return new QgsTextAnnotationDialog( tItem );
}

QgsFormAnnotationItem* fItem = dynamic_cast<QgsFormAnnotationItem*>( item );
if ( fItem )
{
return new QgsFormAnnotationDialog( fItem );
}

return 0;
}

void QgsMapToolAnnotation::canvasReleaseEvent( QMouseEvent * e )
{
mCurrentMoveAction = QgsAnnotationItem::NoAction;
Expand Down Expand Up @@ -193,7 +217,7 @@ void QgsMapToolAnnotation::canvasDoubleClickEvent( QMouseEvent * e )
{
return;
}
QDialog* itemEditor = item->createEditor();
QDialog* itemEditor = createItemEditor( item );
if ( itemEditor )
{
itemEditor->exec();
Expand Down
2 changes: 2 additions & 0 deletions src/app/qgsmaptoolannotation.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class QgsMapToolAnnotation: public QgsMapTool
protected:
/**Creates a new item. To be implemented by subclasses. Returns 0 by default*/
virtual QgsAnnotationItem* createItem( QMouseEvent* e );
/**Creates an editor widget (caller takes ownership)*/
QDialog* createItemEditor( QgsAnnotationItem* item );

private:
/**Returns the topmost annotation item at the position (or 0 if none)*/
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 0 additions & 6 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ symbology-ng/characterwidget.cpp
qgisgui.cpp
qgisinterface.cpp
qgsannotationitem.cpp
qgsannotationwidget.cpp
qgsattributeeditor.cpp
qgslegendinterface.cpp
qgscolorbutton.cpp
Expand All @@ -33,7 +32,6 @@ qgsdetaileditemwidget.cpp
qgsdetaileditemdata.cpp
qgsencodingfiledialog.cpp
qgsfiledropedit.cpp
qgsformannotationdialog.cpp
qgsformannotationitem.cpp
qgsgenericprojectionselector.cpp
qgsmapcanvas.cpp
Expand All @@ -52,7 +50,6 @@ qgsprojectbadlayerguihandler.cpp
qgsprojectionselector.cpp
qgsquickprint.cpp
qgsrubberband.cpp
qgstextannotationdialog.cpp
qgstextannotationitem.cpp
qgsvertexmarker.cpp
qgsludialog.cpp
Expand All @@ -75,15 +72,13 @@ symbology-ng/qgsvectorrandomcolorrampv2dialog.h
symbology-ng/qgsvectorcolorbrewercolorrampv2dialog.h
symbology-ng/characterwidget.h

qgsannotationwidget.h
qgsattributeeditor.h
qgscomposerview.h
qgsdetaileditemdelegate.h
qgsdetaileditemwidget.h
qgslegendinterface.h
qgisinterface.h
qgsencodingfiledialog.h
qgsformannotationdialog.h
qgsformannotationitem.h
qgsgenericprojectionselector.h
qgsmapcanvas.h
Expand All @@ -93,7 +88,6 @@ qgsmessageviewer.h
qgscredentialdialog.h
qgsprojectionselector.h
qgsquickprint.h
qgstextannotationdialog.h
qgsludialog.h
qgsprojectbadlayerguihandler.h
)
Expand Down
3 changes: 0 additions & 3 deletions src/gui/qgsannotationitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ class GUI_EXPORT QgsAnnotationItem: public QgsMapCanvasItem
QgsAnnotationItem( QgsMapCanvas* mapCanvas );
virtual ~QgsAnnotationItem();

/**Creates an editor widget (caller takes ownership)*/
virtual QDialog* createEditor() = 0;

void updatePosition();

QRectF boundingRect() const;
Expand Down
6 changes: 0 additions & 6 deletions src/gui/qgsformannotationitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
***************************************************************************/

#include "qgsformannotationitem.h"
#include "qgsformannotationdialog.h"
#include "qgsattributeeditor.h"
#include "qgsfeature.h"
#include "qgslogger.h"
Expand Down Expand Up @@ -142,11 +141,6 @@ void QgsFormAnnotationItem::paint( QPainter * painter, const QStyleOptionGraphic
}
}

QDialog* QgsFormAnnotationItem::createEditor()
{
return new QgsFormAnnotationDialog( this );
}

QSizeF QgsFormAnnotationItem::minimumFrameSize() const
{
if ( mDesignerWidget )
Expand Down
3 changes: 0 additions & 3 deletions src/gui/qgsformannotationitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ class GUI_EXPORT QgsFormAnnotationItem: public QObject, public QgsAnnotationItem
//! paint function called by map canvas
void paint( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 );

/**Create a configuration dialog*/
QDialog* createEditor();

QSizeF minimumFrameSize() const;
/**Returns the optimal frame size*/
QSizeF preferredFrameSize() const;
Expand Down
6 changes: 0 additions & 6 deletions src/gui/qgstextannotationitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
***************************************************************************/

#include "qgstextannotationitem.h"
#include "qgstextannotationdialog.h"
#include <QDomDocument>
#include <QPainter>

Expand Down Expand Up @@ -46,11 +45,6 @@ void QgsTextAnnotationItem::setDocument( const QTextDocument* doc )
mDocument = doc->clone();
}

QDialog* QgsTextAnnotationItem::createEditor()
{
return new QgsTextAnnotationDialog( this );
}

void QgsTextAnnotationItem::paint( QPainter * painter )
{
if ( !painter || !mDocument )
Expand Down
2 changes: 0 additions & 2 deletions src/gui/qgstextannotationitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ class GUI_EXPORT QgsTextAnnotationItem: public QgsAnnotationItem
QgsTextAnnotationItem( QgsMapCanvas* canvas );
~QgsTextAnnotationItem();

QDialog* createEditor();

/**Returns document (caller takes ownership)*/
QTextDocument* document() const;
/**Sets document (does not take ownership)*/
Expand Down

0 comments on commit 9f357ab

Please sign in to comment.