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
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 8 deletions.
@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@blazek
Copy link
Member Author

@blazek blazek commented on 847f1c0 Feb 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@NathanW2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I'm not worried :)

@blazek
Copy link
Member Author

@blazek blazek commented on 847f1c0 Feb 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Please sign in to comment.