Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- changes to sipify script
- updated gsdataitem header:
  - added qgis.h include
  - skip sDataItemPtr
  - remove , between SIP annotations
- run sipify for qgsvector and qgsdataitem
  • Loading branch information
doublebyte1 committed May 1, 2017
1 parent 18a3f32 commit bb1bded
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 71 deletions.
75 changes: 25 additions & 50 deletions python/core/qgsdataitem.sip
Expand Up @@ -24,22 +24,22 @@ class QgsDataItem : QObject
%End

%ConvertToSubClassCode
if (qobject_cast<QgsLayerItem*>(sipCpp))
sipType = sipType_QgsLayerItem;
else if (qobject_cast<QgsErrorItem*>(sipCpp))
sipType = sipType_QgsErrorItem;
else if (qobject_cast<QgsDirectoryItem*>(sipCpp))
sipType = sipType_QgsDirectoryItem;
else if (qobject_cast<QgsFavoritesItem*>(sipCpp))
sipType = sipType_QgsFavoritesItem;
else if (qobject_cast<QgsZipItem*>(sipCpp))
sipType = sipType_QgsZipItem;
else if (qobject_cast<QgsDataCollectionItem*>(sipCpp))
sipType = sipType_QgsDataCollectionItem;
else if (qobject_cast<QgsProjectItem*>(sipCpp))
sipType = sipType_QgsProjectItem;
else
sipType = 0;
if ( qobject_cast<QgsLayerItem *>( sipCpp ) )
sipType = sipType_QgsLayerItem;
else if ( qobject_cast<QgsErrorItem *>( sipCpp ) )
sipType = sipType_QgsErrorItem;
else if ( qobject_cast<QgsDirectoryItem *>( sipCpp ) )
sipType = sipType_QgsDirectoryItem;
else if ( qobject_cast<QgsFavoritesItem *>( sipCpp ) )
sipType = sipType_QgsFavoritesItem;
else if ( qobject_cast<QgsZipItem *>( sipCpp ) )
sipType = sipType_QgsZipItem;
else if ( qobject_cast<QgsDataCollectionItem *>( sipCpp ) )
sipType = sipType_QgsDataCollectionItem;
else if ( qobject_cast<QgsProjectItem *>( sipCpp ) )
sipType = sipType_QgsProjectItem;
else
sipType = 0;
%End
public:
enum Type
Expand Down Expand Up @@ -100,14 +100,14 @@ Create new data item.
Inserts a new child item. The child will be inserted at a position using an alphabetical order based on mName.
\param child child item to insert. Ownership is transferred, and item parent will be set and relevant connections made.
\param refresh - set to true to refresh populated item, emitting relevant signals to the model
\see deleteChildItem()
.. seealso:: deleteChildItem()
%End

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

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

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

Expand All @@ -157,7 +157,7 @@ Create new data item.
Returns true if the item may be dragged.
Default implementation returns false.
A draggable item has to implement mimeUri() that will be used to pass data.
\see mimeUri()
.. seealso:: mimeUri()
.. versionadded:: 3.0
:rtype: bool
%End
Expand All @@ -166,7 +166,7 @@ Create new data item.
%Docstring
Return mime URI for the data item.
Items that return valid URI will be returned in mime data when dragging a selection from browser model.
\see hasDragEnabled()
.. seealso:: hasDragEnabled()
.. versionadded:: 3.0
:rtype: QgsMimeDataUtils.Uri
%End
Expand All @@ -190,7 +190,6 @@ Create new data item.

virtual Capabilities capabilities2() const;
%Docstring
### QGIS 3 - rename to capabilities()
:rtype: Capabilities
%End

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

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


Type type() const;
%Docstring
members
:rtype: Type
%End

Expand Down Expand Up @@ -250,9 +247,6 @@ Create path component replacing path separators
%End

void setIcon( const QIcon &icon );
%Docstring
or implement icon().
%End
void setIconName( const QString &iconName );

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

static void deleteLater( QVector<QgsDataItem *> &items );
%Docstring
deleteLater() items anc clear the vector
%End

void moveToThread( QThread *targetThread );
%Docstring
Expand Down Expand Up @@ -304,9 +295,6 @@ Move object and all its descendants to thread
%End

virtual void populate( bool foreground = false );
%Docstring
\param foreground run createChildren in foreground
%End

virtual void depopulate();
%Docstring
Expand Down Expand Up @@ -367,10 +355,6 @@ class QgsLayerItem : QgsDataItem


virtual bool equal( const QgsDataItem *other );
%Docstring
--- reimplemented from QgsDataItem ---
:rtype: bool
%End

virtual bool hasDragEnabled() const;

Expand Down Expand Up @@ -471,9 +455,6 @@ class QgsDataCollectionItem : QgsDataItem
static QIcon iconDir(); // shared icon: open/closed directory
static QIcon iconDataCollection(); // default icon for data collection
};
%Docstring
:rtype: QIcon
%End

class QgsDirectoryItem : QgsDataCollectionItem
{
Expand Down Expand Up @@ -616,13 +597,13 @@ class QgsFavoritesItem : QgsDataCollectionItem
void addDirectory( const QString &directory );
%Docstring
Adds a new directory to the favorites group.
\see removeDirectory()
.. seealso:: removeDirectory()
%End

void removeDirectory( QgsDirectoryItem *item );
%Docstring
Removes an existing directory from the favorites group.
\see addDirectory()
.. seealso:: addDirectory()
%End

static QIcon iconFavorites();
Expand Down Expand Up @@ -655,12 +636,6 @@ class QgsZipItem : QgsDataCollectionItem
:rtype: list of str
%End

static QVector<dataItem_t *> sDataItemPtr;
%Docstring
.. note::

not available via Python bindings
%End
static QStringList sProviderNames;

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

static QgsDataItem *itemFromPath( QgsDataItem *parent, const QString &filePath, const QString &name, const QString &path ) /Factory/, /PyName=itemFromFilePath/;
static QgsDataItem *itemFromPath( QgsDataItem *parent, const QString &filePath, const QString &name, const QString &path ) /Factory,PyName=itemFromFilePath/;
%Docstring
Creates a new data item from the specified path.
.. note::
Expand Down
4 changes: 2 additions & 2 deletions python/core/qgsvector.sip
Expand Up @@ -97,14 +97,14 @@ Swaps the sign of the x and y components of the vector.
double x() const;
%Docstring
Returns the vector's x-component.
\see y()
.. seealso:: y()
:rtype: float
%End

double y() const;
%Docstring
Returns the vector's y-component.
\see x()
.. seealso:: x()
:rtype: float
%End

Expand Down
3 changes: 2 additions & 1 deletion scripts/sipify.pl
Expand Up @@ -326,8 +326,9 @@ sub remove_constructor_or_body {
# top level should stasy public
dbg_info
$ACCESS[$#ACCESS] = PUBLIC;
$comment = '';
}
$comment = '';
$return_type = '';
$private_section_line = '';
}
dbg_info("new bracket balance: @global_bracket_nesting_index");
Expand Down
37 changes: 19 additions & 18 deletions src/core/qgsdataitem.h
Expand Up @@ -17,6 +17,7 @@
#ifndef QGSDATAITEM_H
#define QGSDATAITEM_H

#include "qgis.h"
#include "qgis_core.h"
#include <QFileSystemWatcher>
#include <QFutureWatcher>
Expand Down Expand Up @@ -48,22 +49,22 @@ class CORE_EXPORT QgsDataItem : public QObject

#ifdef SIP_RUN
SIP_CONVERT_TO_SUBCLASS_CODE
if (qobject_cast<QgsLayerItem*>(sipCpp))
sipType = sipType_QgsLayerItem;
else if (qobject_cast<QgsErrorItem*>(sipCpp))
sipType = sipType_QgsErrorItem;
else if (qobject_cast<QgsDirectoryItem*>(sipCpp))
sipType = sipType_QgsDirectoryItem;
else if (qobject_cast<QgsFavoritesItem*>(sipCpp))
sipType = sipType_QgsFavoritesItem;
else if (qobject_cast<QgsZipItem*>(sipCpp))
sipType = sipType_QgsZipItem;
else if (qobject_cast<QgsDataCollectionItem*>(sipCpp))
sipType = sipType_QgsDataCollectionItem;
else if (qobject_cast<QgsProjectItem*>(sipCpp))
sipType = sipType_QgsProjectItem;
else
sipType = 0;
if ( qobject_cast<QgsLayerItem *>( sipCpp ) )
sipType = sipType_QgsLayerItem;
else if ( qobject_cast<QgsErrorItem *>( sipCpp ) )
sipType = sipType_QgsErrorItem;
else if ( qobject_cast<QgsDirectoryItem *>( sipCpp ) )
sipType = sipType_QgsDirectoryItem;
else if ( qobject_cast<QgsFavoritesItem *>( sipCpp ) )
sipType = sipType_QgsFavoritesItem;
else if ( qobject_cast<QgsZipItem *>( sipCpp ) )
sipType = sipType_QgsZipItem;
else if ( qobject_cast<QgsDataCollectionItem *>( sipCpp ) )
sipType = sipType_QgsDataCollectionItem;
else if ( qobject_cast<QgsProjectItem *>( sipCpp ) )
sipType = sipType_QgsProjectItem;
else
sipType = 0;
SIP_END
#endif

Expand Down Expand Up @@ -571,7 +572,7 @@ class CORE_EXPORT QgsZipItem : public QgsDataCollectionItem
QStringList getZipFileList();

//! \note not available via Python bindings
static QVector<dataItem_t *> sDataItemPtr;
static QVector<dataItem_t *> sDataItemPtr SIP_SKIP;
static QStringList sProviderNames;

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

static QIcon iconZip();

Expand Down

0 comments on commit bb1bded

Please sign in to comment.