Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Small cleanup in data items
  • Loading branch information
wonder-sk committed Aug 2, 2016
1 parent 517f4e1 commit 2482a6b
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 96 deletions.
3 changes: 3 additions & 0 deletions doc/api_break.dox
Expand Up @@ -190,6 +190,9 @@ instead.</li>

<ul>
<li>supportedCRS() has been renamed to supportedCrs()</li>
<li>isPopulated() has been removed. Use state() instead.</li>
<li>capabilities() has been removed. Use capabilities2() instead (TODO: rename back to capabilities()).</li>
<li>emitBeginInsertItems(), emitEndInsertItems(), emitBeginRemoveItems(), emitEndRemoveItems(), emitDataChanged(), emitStateChanged() have been removed.</li>
</ul>

\subsection qgis_api_break_3_0_QgsDiagramLayerSettings QgsDiagramLayerSettings
Expand Down
13 changes: 1 addition & 12 deletions python/core/qgsdataitem.sip
Expand Up @@ -93,9 +93,6 @@ class QgsDataItem : QObject
*/
virtual void setState( State state );

//! @deprecated in 2.8, use state()
bool isPopulated() /Deprecated/;

/** 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
Expand Down Expand Up @@ -150,9 +147,7 @@ class QgsDataItem : QObject
// This will _write_ selected crs in data source
virtual bool setCrs( QgsCoordinateReferenceSystem crs );

//! @deprecated since 2.8, returned type this will changed to Capabilities
virtual Capability capabilities() /Deprecated/;

// ### QGIS 3 - rename to capabilities()
virtual Capabilities capabilities2() const;

virtual void setCapabilities( const Capabilities& capabilities );
Expand Down Expand Up @@ -226,13 +221,7 @@ class QgsDataItem : QObject

virtual void refresh();

void emitBeginInsertItems( QgsDataItem* parent, int first, int last );
void emitEndInsertItems();
void emitBeginRemoveItems( QgsDataItem* parent, int first, int last );
void emitEndRemoveItems();
void emitDataChanged( QgsDataItem* item );
void emitDataChanged();
void emitStateChanged( QgsDataItem* item, QgsDataItem::State oldState );
virtual void childrenCreated();

signals:
Expand Down
54 changes: 6 additions & 48 deletions src/core/qgsdataitem.cpp
Expand Up @@ -212,7 +212,6 @@ QgsDataItem::QgsDataItem( QgsDataItem::Type type, QgsDataItem* parent, const QSt
, mCapabilities( NoCapabilities )
, mParent( parent )
, mState( NotPopulated )
, mPopulated( false )
, mName( name )
, mPath( path )
, mDeferredDelete( false )
Expand Down Expand Up @@ -311,41 +310,11 @@ QIcon QgsDataItem::icon()
return mIconMap.value( mIconName );
}

void QgsDataItem::emitBeginInsertItems( QgsDataItem* parent, int first, int last )
{
emit beginInsertItems( parent, first, last );
}
void QgsDataItem::emitEndInsertItems()
{
emit endInsertItems();
}
void QgsDataItem::emitBeginRemoveItems( QgsDataItem* parent, int first, int last )
{
emit beginRemoveItems( parent, first, last );
}
void QgsDataItem::emitEndRemoveItems()
{
emit endRemoveItems();
}

void QgsDataItem::emitDataChanged( QgsDataItem* item )
{
emit dataChanged( item );
}

void QgsDataItem::emitDataChanged()
{
emit dataChanged( this );
}

void QgsDataItem::emitStateChanged( QgsDataItem* item, QgsDataItem::State oldState )
{
if ( !item )
return;
QgsDebugMsgLevel( QString( "item %1 state changed %2 -> %3" ).arg( item->path() ).arg( oldState ).arg( item->state() ), 2 );
emit stateChanged( item, oldState );
}

QVector<QgsDataItem*> QgsDataItem::createChildren()
{
return QVector<QgsDataItem*>();
Expand Down Expand Up @@ -531,17 +500,17 @@ void QgsDataItem::setParent( QgsDataItem* parent )
if ( parent )
{
connect( this, SIGNAL( beginInsertItems( QgsDataItem*, int, int ) ),
parent, SLOT( emitBeginInsertItems( QgsDataItem*, int, int ) ) );
parent, SIGNAL( beginInsertItems( QgsDataItem*, int, int ) ) );
connect( this, SIGNAL( endInsertItems() ),
parent, SLOT( emitEndInsertItems() ) );
parent, SIGNAL( endInsertItems() ) );
connect( this, SIGNAL( beginRemoveItems( QgsDataItem*, int, int ) ),
parent, SLOT( emitBeginRemoveItems( QgsDataItem*, int, int ) ) );
parent, SIGNAL( beginRemoveItems( QgsDataItem*, int, int ) ) );
connect( this, SIGNAL( endRemoveItems() ),
parent, SLOT( emitEndRemoveItems() ) );
parent, SIGNAL( endRemoveItems() ) );
connect( this, SIGNAL( dataChanged( QgsDataItem* ) ),
parent, SLOT( emitDataChanged( QgsDataItem* ) ) );
parent, SIGNAL( dataChanged( QgsDataItem* ) ) );
connect( this, SIGNAL( stateChanged( QgsDataItem*, QgsDataItem::State ) ),
parent, SLOT( emitStateChanged( QgsDataItem*, QgsDataItem::State ) ) );
parent, SIGNAL( stateChanged( QgsDataItem*, QgsDataItem::State ) ) );
}
mParent = parent;
}
Expand Down Expand Up @@ -634,10 +603,6 @@ bool QgsDataItem::equal( const QgsDataItem *other )

QgsDataItem::State QgsDataItem::state() const
{
// for backward compatibility (if subclass set mPopulated directly)
// TODO: remove in 3.0
if ( mPopulated )
return Populated;
return mState;
}

Expand All @@ -664,9 +629,6 @@ void QgsDataItem::setState( State state )
}

mState = state;
// for backward compatibility (if subclass access mPopulated directly)
// TODO: remove in 3.0
mPopulated = state == Populated;

emit stateChanged( this, oldState );
if ( state == Populated )
Expand Down Expand Up @@ -755,10 +717,6 @@ QgsDataCollectionItem::~QgsDataCollectionItem()
}

//-----------------------------------------------------------------------
// QVector<QgsDataProvider*> QgsDirectoryItem::mProviders = QVector<QgsDataProvider*>();
Q_NOWARN_DEPRECATED_PUSH
QVector<QLibrary*> QgsDirectoryItem::mLibraries = QVector<QLibrary*>();
Q_NOWARN_DEPRECATED_POP

QgsDirectoryItem::QgsDirectoryItem( QgsDataItem* parent, const QString& name, const QString& path )
: QgsDataCollectionItem( parent, name, path )
Expand Down
20 changes: 1 addition & 19 deletions src/core/qgsdataitem.h
Expand Up @@ -119,9 +119,6 @@ class CORE_EXPORT QgsDataItem : public QObject
*/
virtual void setState( State state );

//! @deprecated in 2.8, use state()
Q_DECL_DEPRECATED bool isPopulated() { return state() == Populated; }

/** 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
Expand Down Expand Up @@ -177,9 +174,7 @@ class CORE_EXPORT QgsDataItem : public QObject
virtual bool setCrs( QgsCoordinateReferenceSystem crs )
{ Q_UNUSED( crs ); return false; }

//! @deprecated since 2.8, returned type this will changed to Capabilities
Q_DECL_DEPRECATED virtual Capability capabilities() { return NoCapabilities; }

// ### QGIS 3 - rename to capabilities()
virtual Capabilities capabilities2() const { return mCapabilities; }

virtual void setCapabilities( const Capabilities& capabilities ) { mCapabilities = capabilities; }
Expand Down Expand Up @@ -239,8 +234,6 @@ class CORE_EXPORT QgsDataItem : public QObject
QgsDataItem* mParent;
QVector<QgsDataItem*> mChildren; // easier to have it always
State mState;
//! @deprecated since 2.8, use mState
bool mPopulated;
QString mName;
// Path is slash ('/') separated chain of item identifiers which are usually item names, but may be differen if it is
// necessary to distinguish paths of two providers to the same source (e.g GRASS location and standard directory have the same
Expand Down Expand Up @@ -271,13 +264,7 @@ class CORE_EXPORT QgsDataItem : public QObject

virtual void refresh();

void emitBeginInsertItems( QgsDataItem* parent, int first, int last );
void emitEndInsertItems();
void emitBeginRemoveItems( QgsDataItem* parent, int first, int last );
void emitEndRemoveItems();
void emitDataChanged( QgsDataItem* item );
void emitDataChanged();
void emitStateChanged( QgsDataItem* item, QgsDataItem::State oldState );
virtual void childrenCreated();

signals:
Expand Down Expand Up @@ -432,11 +419,6 @@ class CORE_EXPORT QgsDirectoryItem : public QgsDataCollectionItem
virtual QIcon icon() override;
virtual QWidget *paramWidget() override;

/* static QVector<QgsDataProvider*> mProviders; */
//! @note not available via python bindings
//! @note deprecated since 2.10 - use QgsDataItemProviderRegistry
Q_DECL_DEPRECATED static QVector<QLibrary*> mLibraries;

/** Check if the given path is hidden from the browser model */
static bool hiddenPath( QString path );

Expand Down
6 changes: 0 additions & 6 deletions src/providers/gdal/qgsgdaldataitems.cpp
Expand Up @@ -53,12 +53,6 @@ QgsGdalLayerItem::~QgsGdalLayerItem()
{
}

Q_NOWARN_DEPRECATED_PUSH
QgsLayerItem::Capability QgsGdalLayerItem::capabilities()
{
return mCapabilities & SetCrs ? SetCrs : NoCapabilities;
}
Q_NOWARN_DEPRECATED_POP

bool QgsGdalLayerItem::setCrs( QgsCoordinateReferenceSystem crs )
{
Expand Down
2 changes: 0 additions & 2 deletions src/providers/gdal/qgsgdaldataitems.h
Expand Up @@ -34,8 +34,6 @@ class QgsGdalLayerItem : public QgsLayerItem

bool setCrs( QgsCoordinateReferenceSystem crs ) override;

Q_DECL_DEPRECATED Capability capabilities() override;

QVector<QgsDataItem*> createChildren() override;

QString layerName() const override;
Expand Down
6 changes: 0 additions & 6 deletions src/providers/ogr/qgsogrdataitems.cpp
Expand Up @@ -59,12 +59,6 @@ QgsOgrLayerItem::~QgsOgrLayerItem()
{
}

Q_NOWARN_DEPRECATED_PUSH
QgsLayerItem::Capability QgsOgrLayerItem::capabilities()
{
return mCapabilities & SetCrs ? SetCrs : NoCapabilities;
}
Q_NOWARN_DEPRECATED_POP

bool QgsOgrLayerItem::setCrs( QgsCoordinateReferenceSystem crs )
{
Expand Down
4 changes: 1 addition & 3 deletions src/providers/ogr/qgsogrdataitems.h
Expand Up @@ -19,7 +19,6 @@
#include "qgsdataitem.h"
#include "qgsogrprovider.h"

Q_NOWARN_DEPRECATED_PUSH
class QgsOgrLayerItem : public QgsLayerItem
{
Q_OBJECT
Expand All @@ -29,10 +28,9 @@ class QgsOgrLayerItem : public QgsLayerItem

bool setCrs( QgsCoordinateReferenceSystem crs ) override;

Q_DECL_DEPRECATED Capability capabilities() override;
QString layerName() const override;
};
Q_NOWARN_DEPRECATED_POP


class QgsOgrDataCollectionItem : public QgsDataCollectionItem
{
Expand Down

0 comments on commit 2482a6b

Please sign in to comment.