Skip to content
Permalink
Browse files

browser favourites: add items for providers

  • Loading branch information
blazek committed Feb 22, 2016
1 parent 138be4a commit 847f1c076f36a0e0d690b5f75d36834cc51e6b63
Showing with 37 additions and 8 deletions.
  1. +34 −8 src/core/qgsdataitem.cpp
  2. +3 −0 src/core/qgsdataitem.h
@@ -1139,12 +1139,7 @@ QVector<QgsDataItem*> QgsFavouritesItem::createChildren()

Q_FOREACH ( const QString& favDir, favDirs )
{
QString pathName = pathComponent( favDir );
QgsDataItem *item = new QgsDirectoryItem( this, favDir, favDir, mPath + '/' + pathName );
if ( item )
{
children.append( item );
}
children << createChildren( favDir );
}

return children;
@@ -1159,8 +1154,11 @@ void QgsFavouritesItem::addDirectory( const QString& favDir )

if ( state() == Populated )
{
QString pathName = pathComponent( favDir );
addChildItem( new QgsDirectoryItem( this, favDir, favDir, mPath + '/' + pathName ), true );
QVector<QgsDataItem*> items = createChildren( favDir );
Q_FOREACH ( QgsDataItem* item, items )
{
addChildItem( item, true );
}
}
}

@@ -1185,6 +1183,34 @@ void QgsFavouritesItem::removeDirectory( QgsDirectoryItem *item )
deleteChildItem( mChildren.at( idx ) );
}

QVector<QgsDataItem*> QgsFavouritesItem::createChildren( const QString& favDir )
{
QVector<QgsDataItem*> children;
QString pathName = pathComponent( favDir );
Q_FOREACH ( QgsDataItemProvider* provider, QgsDataItemProviderRegistry::instance()->providers() )
{
int capabilities = provider->capabilities();

if ( capabilities & QgsDataProvider::Dir )
{
QgsDataItem * item = provider->createDataItem( favDir, this );
if ( item )
{
children.append( item );
}
}
}
if ( children.isEmpty() )
{
QgsDataItem *item = new QgsDirectoryItem( this, favDir, favDir, mPath + '/' + pathName );
if ( item )
{
children.append( item );
}
}
return children;
}

//-----------------------------------------------------------------------
QStringList QgsZipItem::mProviderNames = QStringList();
QVector<dataItem_t *> QgsZipItem::mDataItemPtr = QVector<dataItem_t*>();
@@ -507,6 +507,9 @@ class CORE_EXPORT QgsFavouritesItem : public QgsDataCollectionItem
void removeDirectory( QgsDirectoryItem *item );

static const QIcon &iconFavourites();

private:
QVector<QgsDataItem*> createChildren( const QString& favDir );
};

/** A zip file: contains layers, using GDAL/OGR VSIFILE mechanism */

5 comments on commit 847f1c0

@NathanW2

This comment has been minimized.

Copy link
Member

@NathanW2 NathanW2 replied Feb 22, 2016

Didn't think we were out of feature freeze :P

@blazek

This comment has been minimized.

Copy link
Member Author

@blazek blazek replied Feb 22, 2016

Isn't that a bug fix? If you think that it is a feature just revert it.

@NathanW2

This comment has been minimized.

Copy link
Member

@NathanW2 NathanW2 replied Feb 22, 2016

Oh I'm not worried :)

@blazek

This comment has been minimized.

Copy link
Member Author

@blazek blazek replied Feb 22, 2016

The browser was not showing in favourites the item which was added and which can be recognized by a provider. Of course, it can introduce another bug, but the browser is under frequent testing I believe.

@NathanW2

This comment has been minimized.

Copy link
Member

@NathanW2 NathanW2 replied Feb 22, 2016

Ok I misread the fix as something else. Sorry. I was just being a smart ass late at night :)

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