Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fixed browser add favourite path
  • Loading branch information
blazek committed Jan 20, 2015
1 parent 74e2abd commit 752f530
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/core/qgsdataitem.cpp
Expand Up @@ -190,6 +190,11 @@ QgsDataItem::~QgsDataItem()
}
}

QString QgsDataItem::pathComponent( const QString &string )
{
return QString( string ).replace( QRegExp( "[\\\\/]" ), "|" );
}

void QgsDataItem::deleteLater()
{
QgsDebugMsg( "path = " + path() );
Expand Down Expand Up @@ -1074,8 +1079,7 @@ QVector<QgsDataItem*> QgsFavouritesItem::createChildren()

foreach ( QString favDir, favDirs )
{
QString pathName = favDir;
pathName.replace( QRegExp( "[\\\\/]" ), "|" );
QString pathName = pathComponent( favDir );
QgsDataItem *item = new QgsDirectoryItem( this, favDir, favDir, mPath + "/" + pathName );
if ( item )
{
Expand All @@ -1094,7 +1098,10 @@ void QgsFavouritesItem::addDirectory( QString favDir )
settings.setValue( "/browser/favourites", favDirs );

if ( state() == Populated )
addChildItem( new QgsDirectoryItem( this, favDir, favDir ), true );
{
QString pathName = pathComponent( favDir );
addChildItem( new QgsDirectoryItem( this, favDir, favDir, mPath + "/" + pathName ), true );
}
}

void QgsFavouritesItem::removeDirectory( QgsDirectoryItem *item )
Expand Down
2 changes: 2 additions & 0 deletions src/core/qgsdataitem.h
Expand Up @@ -146,6 +146,8 @@ class CORE_EXPORT QgsDataItem : public QObject
QString name() const { return mName; }
QString path() const { return mPath; }
void setPath( const QString &path ) { mPath = path; }
//! Create path component replacing path separators
static QString pathComponent( const QString &component );

// Because QIcon (QPixmap) must not be used in outside the GUI thread, it is
// not possible to set mIcon in constructor. Either use mIconName/setIconName()
Expand Down

0 comments on commit 752f530

Please sign in to comment.