Skip to content
Permalink
Browse files

Small cleanup in data items

  • Loading branch information
wonder-sk committed Aug 2, 2016
1 parent 517f4e1 commit 2482a6bbd037b530e2b4c7dbae6a2f3bdd507f24
@@ -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
@@ -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
@@ -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 );
@@ -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:
@@ -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 )
@@ -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*>();
@@ -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;
}
@@ -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;
}

@@ -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 )
@@ -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 )
@@ -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
@@ -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; }
@@ -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
@@ -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:
@@ -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 );

@@ -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 )
{
@@ -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;
@@ -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 )
{
@@ -19,7 +19,6 @@
#include "qgsdataitem.h"
#include "qgsogrprovider.h"

Q_NOWARN_DEPRECATED_PUSH
class QgsOgrLayerItem : public QgsLayerItem
{
Q_OBJECT
@@ -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
{

0 comments on commit 2482a6b

Please sign in to comment.
You can’t perform that action at this time.