Skip to content
Permalink
Browse files
group favourites in top-level item (when there are 5 or more favourit…
…es) and add favourites icon

Signed-off-by: Tim Sutton <tim@linfiniti.com>
  • Loading branch information
etiennesky authored and timlinux committed Mar 31, 2012
1 parent 6768e6a commit 785f9ae0ccb4a079a0a3184418695ee524a61470
@@ -160,6 +160,7 @@
<file>themes/default/mIconDbSchema.png</file>
<file>themes/default/mIconDelete.png</file>
<file>themes/default/mIconEditable.png</file>
<file>themes/default/mIconFavourites.png</file>
<file>themes/default/mIconFirst.png</file>
<file>themes/default/mIconGeometryLayer.png</file>
<file>themes/default/mIconLast.png</file>
Binary file not shown.
@@ -37,11 +37,29 @@ void QgsBrowserModel::addRootItems()
// add favourite directories
QSettings settings;
QStringList favDirs = settings.value( "/browser/favourites", QVariant() ).toStringList();
foreach( QString favDir, favDirs )
// if there are 5 or more items, create a "Favourites" Root item
// perhaps this should be the default?
if ( favDirs.count() >= 5 )
{
QgsDirectoryItem *item = new QgsDirectoryItem( NULL, favDir, favDir );
connectItem( item );
mRootItems << item;
QgsFavouritesItem *item = new QgsFavouritesItem( NULL, tr( "Favourites" ), "" );
if ( item )
{
connectItem( item );
mRootItems << item;
}
}
else
{
foreach( QString favDir, favDirs )
{
item = new QgsDirectoryItem( NULL, favDir, favDir );
if ( item )
{
item->setIcon( QgsFavouritesItem::iconFavourites() );
mRootItems << item;
connectItem( item );
}
}
}

foreach( QFileInfo drive, QDir::drives() )
@@ -122,6 +122,17 @@ const QIcon &QgsDataCollectionItem::iconDir()
return icon;
}

const QIcon &QgsFavouritesItem::iconFavourites()
{
static QIcon icon;

if ( icon.isNull() )
icon = QIcon( getThemePixmap( "/mIconFavourites.png" ) );
// this icon added by ET, modfied mIconNew and set colour to that of folder icon

return icon;
}

QgsDataItem::QgsDataItem( QgsDataItem::Type type, QgsDataItem* parent, QString name, QString path )
: QObject( parent ), mType( type ), mParent( parent ), mPopulated( false ), mName( name ), mPath( path )
{
@@ -627,3 +638,34 @@ QgsErrorItem::QgsErrorItem( QgsDataItem* parent, QString error, QString path )
QgsErrorItem::~QgsErrorItem()
{
}

QgsFavouritesItem::QgsFavouritesItem( QgsDataItem* parent, QString name, QString path )
: QgsDataCollectionItem( parent, name, path )
{
mType = Collection; //favourites?
mIcon = iconFavourites();
}

QgsFavouritesItem::~QgsFavouritesItem()
{
}

QVector<QgsDataItem*> QgsFavouritesItem::createChildren( )
{
QVector<QgsDataItem*> children;
QgsDataItem* item;

QSettings settings;
QStringList favDirs = settings.value( "/browser/favourites", QVariant() ).toStringList();

foreach( QString favDir, favDirs )
{
item = new QgsDirectoryItem( this, favDir, favDir );
if ( item )
{
children.append( item );
}
}

return children;
}
@@ -272,5 +272,17 @@ class QgsDirectoryParamWidget : public QTreeWidget
void showHideColumn();
};

/** Contains various Favourites directories */
class CORE_EXPORT QgsFavouritesItem : public QgsDataCollectionItem
{
Q_OBJECT
public:
QgsFavouritesItem( QgsDataItem* parent, QString name, QString path );
~QgsFavouritesItem();

QVector<QgsDataItem*> createChildren();
static const QIcon &iconFavourites();
};

#endif // QGSDATAITEM_H

0 comments on commit 785f9ae

Please sign in to comment.