Skip to content

Commit bb1bded

Browse files
committed
- changes to sipify script
- updated gsdataitem header: - added qgis.h include - skip sDataItemPtr - remove , between SIP annotations - run sipify for qgsvector and qgsdataitem
1 parent 18a3f32 commit bb1bded

File tree

4 files changed

+48
-71
lines changed

4 files changed

+48
-71
lines changed

python/core/qgsdataitem.sip

+25-50
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,22 @@ class QgsDataItem : QObject
2424
%End
2525

2626
%ConvertToSubClassCode
27-
if (qobject_cast<QgsLayerItem*>(sipCpp))
28-
sipType = sipType_QgsLayerItem;
29-
else if (qobject_cast<QgsErrorItem*>(sipCpp))
30-
sipType = sipType_QgsErrorItem;
31-
else if (qobject_cast<QgsDirectoryItem*>(sipCpp))
32-
sipType = sipType_QgsDirectoryItem;
33-
else if (qobject_cast<QgsFavoritesItem*>(sipCpp))
34-
sipType = sipType_QgsFavoritesItem;
35-
else if (qobject_cast<QgsZipItem*>(sipCpp))
36-
sipType = sipType_QgsZipItem;
37-
else if (qobject_cast<QgsDataCollectionItem*>(sipCpp))
38-
sipType = sipType_QgsDataCollectionItem;
39-
else if (qobject_cast<QgsProjectItem*>(sipCpp))
40-
sipType = sipType_QgsProjectItem;
41-
else
42-
sipType = 0;
27+
if ( qobject_cast<QgsLayerItem *>( sipCpp ) )
28+
sipType = sipType_QgsLayerItem;
29+
else if ( qobject_cast<QgsErrorItem *>( sipCpp ) )
30+
sipType = sipType_QgsErrorItem;
31+
else if ( qobject_cast<QgsDirectoryItem *>( sipCpp ) )
32+
sipType = sipType_QgsDirectoryItem;
33+
else if ( qobject_cast<QgsFavoritesItem *>( sipCpp ) )
34+
sipType = sipType_QgsFavoritesItem;
35+
else if ( qobject_cast<QgsZipItem *>( sipCpp ) )
36+
sipType = sipType_QgsZipItem;
37+
else if ( qobject_cast<QgsDataCollectionItem *>( sipCpp ) )
38+
sipType = sipType_QgsDataCollectionItem;
39+
else if ( qobject_cast<QgsProjectItem *>( sipCpp ) )
40+
sipType = sipType_QgsProjectItem;
41+
else
42+
sipType = 0;
4343
%End
4444
public:
4545
enum Type
@@ -100,14 +100,14 @@ Create new data item.
100100
Inserts a new child item. The child will be inserted at a position using an alphabetical order based on mName.
101101
\param child child item to insert. Ownership is transferred, and item parent will be set and relevant connections made.
102102
\param refresh - set to true to refresh populated item, emitting relevant signals to the model
103-
\see deleteChildItem()
103+
.. seealso:: deleteChildItem()
104104
%End
105105

106106
virtual void deleteChildItem( QgsDataItem *child );
107107
%Docstring
108108
Removes and deletes a child item, emitting relevant signals to the model.
109109
\param child child to remove. Item must exist as a current child.
110-
\see addChildItem()
110+
.. seealso:: addChildItem()
111111
%End
112112

113113
virtual QgsDataItem *removeChildItem( QgsDataItem *child ) /TransferBack/;
@@ -140,15 +140,15 @@ Create new data item.
140140
%Docstring
141141
Returns whether the item accepts drag and dropped layers - e.g. for importing a dataset to a provider.
142142
Subclasses should override this and handleDrop() to accept dropped layers.
143-
\see handleDrop()
143+
.. seealso:: handleDrop()
144144
:rtype: bool
145145
%End
146146

147147
virtual bool handleDrop( const QMimeData * /*data*/, Qt::DropAction /*action*/ );
148148
%Docstring
149149
Attempts to process the mime data dropped on this item. Subclasses must override this and acceptDrop() if they
150150
accept dropped layers.
151-
\see acceptDrop()
151+
.. seealso:: acceptDrop()
152152
:rtype: bool
153153
%End
154154

@@ -157,7 +157,7 @@ Create new data item.
157157
Returns true if the item may be dragged.
158158
Default implementation returns false.
159159
A draggable item has to implement mimeUri() that will be used to pass data.
160-
\see mimeUri()
160+
.. seealso:: mimeUri()
161161
.. versionadded:: 3.0
162162
:rtype: bool
163163
%End
@@ -166,7 +166,7 @@ Create new data item.
166166
%Docstring
167167
Return mime URI for the data item.
168168
Items that return valid URI will be returned in mime data when dragging a selection from browser model.
169-
\see hasDragEnabled()
169+
.. seealso:: hasDragEnabled()
170170
.. versionadded:: 3.0
171171
:rtype: QgsMimeDataUtils.Uri
172172
%End
@@ -190,7 +190,6 @@ Create new data item.
190190

191191
virtual Capabilities capabilities2() const;
192192
%Docstring
193-
### QGIS 3 - rename to capabilities()
194193
:rtype: Capabilities
195194
%End
196195

@@ -202,14 +201,12 @@ Create new data item.
202201

203202
static int findItem( QVector<QgsDataItem *> items, QgsDataItem *item );
204203
%Docstring
205-
Find child index in vector of items using '==' operator
206204
:rtype: int
207205
%End
208206

209207

210208
Type type() const;
211209
%Docstring
212-
members
213210
:rtype: Type
214211
%End
215212

@@ -250,9 +247,6 @@ Create path component replacing path separators
250247
%End
251248

252249
void setIcon( const QIcon &icon );
253-
%Docstring
254-
or implement icon().
255-
%End
256250
void setIconName( const QString &iconName );
257251

258252
void setToolTip( const QString &msg );
@@ -262,9 +256,6 @@ or implement icon().
262256
%End
263257

264258
static void deleteLater( QVector<QgsDataItem *> &items );
265-
%Docstring
266-
deleteLater() items anc clear the vector
267-
%End
268259

269260
void moveToThread( QThread *targetThread );
270261
%Docstring
@@ -304,9 +295,6 @@ Move object and all its descendants to thread
304295
%End
305296

306297
virtual void populate( bool foreground = false );
307-
%Docstring
308-
\param foreground run createChildren in foreground
309-
%End
310298

311299
virtual void depopulate();
312300
%Docstring
@@ -367,10 +355,6 @@ class QgsLayerItem : QgsDataItem
367355

368356

369357
virtual bool equal( const QgsDataItem *other );
370-
%Docstring
371-
--- reimplemented from QgsDataItem ---
372-
:rtype: bool
373-
%End
374358

375359
virtual bool hasDragEnabled() const;
376360

@@ -471,9 +455,6 @@ class QgsDataCollectionItem : QgsDataItem
471455
static QIcon iconDir(); // shared icon: open/closed directory
472456
static QIcon iconDataCollection(); // default icon for data collection
473457
};
474-
%Docstring
475-
:rtype: QIcon
476-
%End
477458

478459
class QgsDirectoryItem : QgsDataCollectionItem
479460
{
@@ -616,13 +597,13 @@ class QgsFavoritesItem : QgsDataCollectionItem
616597
void addDirectory( const QString &directory );
617598
%Docstring
618599
Adds a new directory to the favorites group.
619-
\see removeDirectory()
600+
.. seealso:: removeDirectory()
620601
%End
621602

622603
void removeDirectory( QgsDirectoryItem *item );
623604
%Docstring
624605
Removes an existing directory from the favorites group.
625-
\see addDirectory()
606+
.. seealso:: addDirectory()
626607
%End
627608

628609
static QIcon iconFavorites();
@@ -655,12 +636,6 @@ class QgsZipItem : QgsDataCollectionItem
655636
:rtype: list of str
656637
%End
657638

658-
static QVector<dataItem_t *> sDataItemPtr;
659-
%Docstring
660-
.. note::
661-
662-
not available via Python bindings
663-
%End
664639
static QStringList sProviderNames;
665640

666641
static QString vsiPrefix( const QString &uri );
@@ -674,7 +649,7 @@ class QgsZipItem : QgsDataCollectionItem
674649
:rtype: QgsDataItem
675650
%End
676651

677-
static QgsDataItem *itemFromPath( QgsDataItem *parent, const QString &filePath, const QString &name, const QString &path ) /Factory/, /PyName=itemFromFilePath/;
652+
static QgsDataItem *itemFromPath( QgsDataItem *parent, const QString &filePath, const QString &name, const QString &path ) /Factory,PyName=itemFromFilePath/;
678653
%Docstring
679654
Creates a new data item from the specified path.
680655
.. note::

python/core/qgsvector.sip

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,14 @@ Swaps the sign of the x and y components of the vector.
9797
double x() const;
9898
%Docstring
9999
Returns the vector's x-component.
100-
\see y()
100+
.. seealso:: y()
101101
:rtype: float
102102
%End
103103

104104
double y() const;
105105
%Docstring
106106
Returns the vector's y-component.
107-
\see x()
107+
.. seealso:: x()
108108
:rtype: float
109109
%End
110110

scripts/sipify.pl

+2-1
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,9 @@ sub remove_constructor_or_body {
326326
# top level should stasy public
327327
dbg_info
328328
$ACCESS[$#ACCESS] = PUBLIC;
329-
$comment = '';
330329
}
330+
$comment = '';
331+
$return_type = '';
331332
$private_section_line = '';
332333
}
333334
dbg_info("new bracket balance: @global_bracket_nesting_index");

src/core/qgsdataitem.h

+19-18
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#ifndef QGSDATAITEM_H
1818
#define QGSDATAITEM_H
1919

20+
#include "qgis.h"
2021
#include "qgis_core.h"
2122
#include <QFileSystemWatcher>
2223
#include <QFutureWatcher>
@@ -48,22 +49,22 @@ class CORE_EXPORT QgsDataItem : public QObject
4849

4950
#ifdef SIP_RUN
5051
SIP_CONVERT_TO_SUBCLASS_CODE
51-
if (qobject_cast<QgsLayerItem*>(sipCpp))
52-
sipType = sipType_QgsLayerItem;
53-
else if (qobject_cast<QgsErrorItem*>(sipCpp))
54-
sipType = sipType_QgsErrorItem;
55-
else if (qobject_cast<QgsDirectoryItem*>(sipCpp))
56-
sipType = sipType_QgsDirectoryItem;
57-
else if (qobject_cast<QgsFavoritesItem*>(sipCpp))
58-
sipType = sipType_QgsFavoritesItem;
59-
else if (qobject_cast<QgsZipItem*>(sipCpp))
60-
sipType = sipType_QgsZipItem;
61-
else if (qobject_cast<QgsDataCollectionItem*>(sipCpp))
62-
sipType = sipType_QgsDataCollectionItem;
63-
else if (qobject_cast<QgsProjectItem*>(sipCpp))
64-
sipType = sipType_QgsProjectItem;
65-
else
66-
sipType = 0;
52+
if ( qobject_cast<QgsLayerItem *>( sipCpp ) )
53+
sipType = sipType_QgsLayerItem;
54+
else if ( qobject_cast<QgsErrorItem *>( sipCpp ) )
55+
sipType = sipType_QgsErrorItem;
56+
else if ( qobject_cast<QgsDirectoryItem *>( sipCpp ) )
57+
sipType = sipType_QgsDirectoryItem;
58+
else if ( qobject_cast<QgsFavoritesItem *>( sipCpp ) )
59+
sipType = sipType_QgsFavoritesItem;
60+
else if ( qobject_cast<QgsZipItem *>( sipCpp ) )
61+
sipType = sipType_QgsZipItem;
62+
else if ( qobject_cast<QgsDataCollectionItem *>( sipCpp ) )
63+
sipType = sipType_QgsDataCollectionItem;
64+
else if ( qobject_cast<QgsProjectItem *>( sipCpp ) )
65+
sipType = sipType_QgsProjectItem;
66+
else
67+
sipType = 0;
6768
SIP_END
6869
#endif
6970

@@ -571,7 +572,7 @@ class CORE_EXPORT QgsZipItem : public QgsDataCollectionItem
571572
QStringList getZipFileList();
572573

573574
//! \note not available via Python bindings
574-
static QVector<dataItem_t *> sDataItemPtr;
575+
static QVector<dataItem_t *> sDataItemPtr SIP_SKIP;
575576
static QStringList sProviderNames;
576577

577578
static QString vsiPrefix( const QString &uri ) { return qgsVsiPrefix( uri ); }
@@ -585,7 +586,7 @@ class CORE_EXPORT QgsZipItem : public QgsDataCollectionItem
585586
* Creates a new data item from the specified path.
586587
* \note available in Python as itemFromFilePath
587588
*/
588-
static QgsDataItem *itemFromPath( QgsDataItem *parent, const QString &filePath, const QString &name, const QString &path ) SIP_FACTORY, SIP_PYNAME(itemFromFilePath);
589+
static QgsDataItem *itemFromPath( QgsDataItem *parent, const QString &filePath, const QString &name, const QString &path ) SIP_FACTORY SIP_PYNAME( itemFromFilePath );
589590

590591
static QIcon iconZip();
591592

0 commit comments

Comments
 (0)