Skip to content

Commit a6ccd63

Browse files
committedJul 11, 2017
Start implementing an add item tool
1 parent 2503497 commit a6ccd63

File tree

7 files changed

+144
-4
lines changed

7 files changed

+144
-4
lines changed
 

‎python/gui/gui_auto.sip

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@
277277
%Include layout/qgslayoutdesignerinterface.sip
278278
%Include layout/qgslayoutview.sip
279279
%Include layout/qgslayoutviewtool.sip
280+
%Include layout/qgslayoutviewtooladditem.sip
280281
%Include locator/qgslocator.sip
281282
%Include locator/qgslocatorfilter.sip
282283
%Include locator/qgslocatorwidget.sip

‎python/gui/layout/qgslayoutviewtool.sip

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99

1010

1111

12+
%ModuleHeaderCode
13+
#include <qgslayoutviewtooladditem.h>
14+
%End
15+
1216
class QgsLayoutViewTool : QObject
1317
{
1418
%Docstring
@@ -23,8 +27,8 @@ class QgsLayoutViewTool : QObject
2327
%End
2428

2529
%ConvertToSubClassCode
26-
if ( dynamic_cast<QgsMapToolZoom *>( sipCpp ) != NULL )
27-
sipType = sipType_QgsMapToolZoom;
30+
if ( dynamic_cast<QgsLayoutViewToolAddItem *>( sipCpp ) != NULL )
31+
sipType = sipType_QgsLayoutViewToolAddItem;
2832
else
2933
sipType = NULL;
3034
%End
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/************************************************************************
2+
* This file has been generated automatically from *
3+
* *
4+
* src/gui/layout/qgslayoutviewtooladditem.h *
5+
* *
6+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
7+
************************************************************************/
8+
9+
10+
11+
class QgsLayoutViewToolAddItem : QgsLayoutViewTool
12+
{
13+
%Docstring
14+
Layout view tool for adding items to a layout.
15+
.. versionadded:: 3.0
16+
%End
17+
18+
%TypeHeaderCode
19+
#include "qgslayoutviewtooladditem.h"
20+
%End
21+
public:
22+
23+
QgsLayoutViewToolAddItem( QgsLayoutView *view );
24+
25+
int itemType() const;
26+
%Docstring
27+
Returns the item type for items created by the tool.
28+
.. seealso:: setItemType()
29+
:rtype: int
30+
%End
31+
32+
void setItemType( int type );
33+
%Docstring
34+
Sets the item ``type`` for items created by the tool.
35+
.. seealso:: itemType()
36+
%End
37+
38+
};
39+
40+
/************************************************************************
41+
* This file has been generated automatically from *
42+
* *
43+
* src/gui/layout/qgslayoutviewtooladditem.h *
44+
* *
45+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
46+
************************************************************************/

‎src/gui/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ SET(QGIS_GUI_SRCS
160160

161161
layout/qgslayoutview.cpp
162162
layout/qgslayoutviewtool.cpp
163+
layout/qgslayoutviewtooladditem.cpp
163164

164165
locator/qgslocator.cpp
165166
locator/qgslocatorfilter.cpp
@@ -625,6 +626,7 @@ SET(QGIS_GUI_MOC_HDRS
625626
layout/qgslayoutdesignerinterface.h
626627
layout/qgslayoutview.h
627628
layout/qgslayoutviewtool.h
629+
layout/qgslayoutviewtooladditem.h
628630

629631
locator/qgslocator.h
630632
locator/qgslocatorfilter.h

‎src/gui/layout/qgslayoutviewtool.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ class QWheelEvent;
2727
class QKeyEvent;
2828
class QgsLayoutView;
2929

30+
#ifdef SIP_RUN
31+
% ModuleHeaderCode
32+
#include <qgslayoutviewtooladditem.h>
33+
% End
34+
#endif
35+
3036
/**
3137
* \ingroup gui
3238
* Abstract base class for all layout view tools.
@@ -39,8 +45,8 @@ class GUI_EXPORT QgsLayoutViewTool : public QObject
3945

4046
#ifdef SIP_RUN
4147
SIP_CONVERT_TO_SUBCLASS_CODE
42-
if ( dynamic_cast<QgsMapToolZoom *>( sipCpp ) != NULL )
43-
sipType = sipType_QgsMapToolZoom;
48+
if ( dynamic_cast<QgsLayoutViewToolAddItem *>( sipCpp ) != NULL )
49+
sipType = sipType_QgsLayoutViewToolAddItem;
4450
else
4551
sipType = NULL;
4652
SIP_END
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/***************************************************************************
2+
qgslayoutviewtooladditem.cpp
3+
----------------------------
4+
Date : July 2017
5+
Copyright : (C) 2017 Nyall Dawson
6+
Email : nyall dot dawson at gmail dot com
7+
***************************************************************************
8+
* *
9+
* This program is free software; you can redistribute it and/or modify *
10+
* it under the terms of the GNU General Public License as published by *
11+
* the Free Software Foundation; either version 2 of the License, or *
12+
* (at your option) any later version. *
13+
* *
14+
***************************************************************************/
15+
16+
#include "qgslayoutviewtooladditem.h"
17+
18+
QgsLayoutViewToolAddItem::QgsLayoutViewToolAddItem( QgsLayoutView *view )
19+
: QgsLayoutViewTool( view, tr( "Add item" ) )
20+
{
21+
22+
}
23+
24+
int QgsLayoutViewToolAddItem::itemType() const
25+
{
26+
return mItemType;
27+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/***************************************************************************
2+
qgslayoutviewtooladditem.h
3+
--------------------------
4+
Date : July 2017
5+
Copyright : (C) 2017 Nyall Dawson
6+
Email : nyall dot dawson at gmail dot com
7+
***************************************************************************
8+
* *
9+
* This program is free software; you can redistribute it and/or modify *
10+
* it under the terms of the GNU General Public License as published by *
11+
* the Free Software Foundation; either version 2 of the License, or *
12+
* (at your option) any later version. *
13+
* *
14+
***************************************************************************/
15+
16+
#ifndef QGSLAYOUTVIEWTOOLADDITEM_H
17+
#define QGSLAYOUTVIEWTOOLADDITEM_H
18+
19+
#include "qgis.h"
20+
#include "qgis_gui.h"
21+
#include "qgslayoutviewtool.h"
22+
23+
/**
24+
* \ingroup gui
25+
* Layout view tool for adding items to a layout.
26+
* \since QGIS 3.0
27+
*/
28+
class GUI_EXPORT QgsLayoutViewToolAddItem : public QgsLayoutViewTool
29+
{
30+
31+
Q_OBJECT
32+
33+
public:
34+
35+
QgsLayoutViewToolAddItem( QgsLayoutView *view );
36+
37+
/**
38+
* Returns the item type for items created by the tool.
39+
* \see setItemType()
40+
*/
41+
int itemType() const;
42+
43+
/**
44+
* Sets the item \a type for items created by the tool.
45+
* \see itemType()
46+
*/
47+
void setItemType( int type );
48+
49+
private:
50+
51+
int mItemType = 0;
52+
};
53+
54+
#endif // QGSLAYOUTVIEWTOOLADDITEM_H

0 commit comments

Comments
 (0)
Please sign in to comment.