Start implementing an add item tool

This commit is contained in:
Nyall Dawson 2017-07-04 13:55:30 +10:00
parent 25034979e3
commit a6ccd63bc8
7 changed files with 144 additions and 4 deletions

View File

@ -277,6 +277,7 @@
%Include layout/qgslayoutdesignerinterface.sip
%Include layout/qgslayoutview.sip
%Include layout/qgslayoutviewtool.sip
%Include layout/qgslayoutviewtooladditem.sip
%Include locator/qgslocator.sip
%Include locator/qgslocatorfilter.sip
%Include locator/qgslocatorwidget.sip

View File

@ -9,6 +9,10 @@
%ModuleHeaderCode
#include <qgslayoutviewtooladditem.h>
%End
class QgsLayoutViewTool : QObject
{
%Docstring
@ -23,8 +27,8 @@ class QgsLayoutViewTool : QObject
%End
%ConvertToSubClassCode
if ( dynamic_cast<QgsMapToolZoom *>( sipCpp ) != NULL )
sipType = sipType_QgsMapToolZoom;
if ( dynamic_cast<QgsLayoutViewToolAddItem *>( sipCpp ) != NULL )
sipType = sipType_QgsLayoutViewToolAddItem;
else
sipType = NULL;
%End

View File

@ -0,0 +1,46 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/layout/qgslayoutviewtooladditem.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
class QgsLayoutViewToolAddItem : QgsLayoutViewTool
{
%Docstring
Layout view tool for adding items to a layout.
.. versionadded:: 3.0
%End
%TypeHeaderCode
#include "qgslayoutviewtooladditem.h"
%End
public:
QgsLayoutViewToolAddItem( QgsLayoutView *view );
int itemType() const;
%Docstring
Returns the item type for items created by the tool.
.. seealso:: setItemType()
:rtype: int
%End
void setItemType( int type );
%Docstring
Sets the item ``type`` for items created by the tool.
.. seealso:: itemType()
%End
};
/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/layout/qgslayoutviewtooladditem.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/

View File

@ -160,6 +160,7 @@ SET(QGIS_GUI_SRCS
layout/qgslayoutview.cpp
layout/qgslayoutviewtool.cpp
layout/qgslayoutviewtooladditem.cpp
locator/qgslocator.cpp
locator/qgslocatorfilter.cpp
@ -625,6 +626,7 @@ SET(QGIS_GUI_MOC_HDRS
layout/qgslayoutdesignerinterface.h
layout/qgslayoutview.h
layout/qgslayoutviewtool.h
layout/qgslayoutviewtooladditem.h
locator/qgslocator.h
locator/qgslocatorfilter.h

View File

@ -27,6 +27,12 @@ class QWheelEvent;
class QKeyEvent;
class QgsLayoutView;
#ifdef SIP_RUN
% ModuleHeaderCode
#include <qgslayoutviewtooladditem.h>
% End
#endif
/**
* \ingroup gui
* Abstract base class for all layout view tools.
@ -39,8 +45,8 @@ class GUI_EXPORT QgsLayoutViewTool : public QObject
#ifdef SIP_RUN
SIP_CONVERT_TO_SUBCLASS_CODE
if ( dynamic_cast<QgsMapToolZoom *>( sipCpp ) != NULL )
sipType = sipType_QgsMapToolZoom;
if ( dynamic_cast<QgsLayoutViewToolAddItem *>( sipCpp ) != NULL )
sipType = sipType_QgsLayoutViewToolAddItem;
else
sipType = NULL;
SIP_END

View File

@ -0,0 +1,27 @@
/***************************************************************************
qgslayoutviewtooladditem.cpp
----------------------------
Date : July 2017
Copyright : (C) 2017 Nyall Dawson
Email : nyall dot dawson at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "qgslayoutviewtooladditem.h"
QgsLayoutViewToolAddItem::QgsLayoutViewToolAddItem( QgsLayoutView *view )
: QgsLayoutViewTool( view, tr( "Add item" ) )
{
}
int QgsLayoutViewToolAddItem::itemType() const
{
return mItemType;
}

View File

@ -0,0 +1,54 @@
/***************************************************************************
qgslayoutviewtooladditem.h
--------------------------
Date : July 2017
Copyright : (C) 2017 Nyall Dawson
Email : nyall dot dawson at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSLAYOUTVIEWTOOLADDITEM_H
#define QGSLAYOUTVIEWTOOLADDITEM_H
#include "qgis.h"
#include "qgis_gui.h"
#include "qgslayoutviewtool.h"
/**
* \ingroup gui
* Layout view tool for adding items to a layout.
* \since QGIS 3.0
*/
class GUI_EXPORT QgsLayoutViewToolAddItem : public QgsLayoutViewTool
{
Q_OBJECT
public:
QgsLayoutViewToolAddItem( QgsLayoutView *view );
/**
* Returns the item type for items created by the tool.
* \see setItemType()
*/
int itemType() const;
/**
* Sets the item \a type for items created by the tool.
* \see itemType()
*/
void setItemType( int type );
private:
int mItemType = 0;
};
#endif // QGSLAYOUTVIEWTOOLADDITEM_H