From c3f6dff9f696d1a65080200eefad3cbc07f4407f Mon Sep 17 00:00:00 2001 From: Martin Dobias Date: Tue, 18 Oct 2011 20:36:30 -0300 Subject: [PATCH] Show full path of gdal/ogr layers as a tooltip (#4399) --- src/core/qgsbrowsermodel.cpp | 4 ++++ src/core/qgsdataitem.h | 4 ++++ src/providers/gdal/qgsgdalprovider.cpp | 3 ++- src/providers/ogr/qgsogrprovider.cpp | 1 + 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/core/qgsbrowsermodel.cpp b/src/core/qgsbrowsermodel.cpp index cfa9b45b1058..d1734380276b 100644 --- a/src/core/qgsbrowsermodel.cpp +++ b/src/core/qgsbrowsermodel.cpp @@ -134,6 +134,10 @@ QVariant QgsBrowserModel::data( const QModelIndex &index, int role ) const { return item->name(); } + else if ( role == Qt::ToolTipRole ) + { + return item->toolTip(); + } else if ( role == Qt::DecorationRole && index.column() == 0 ) { return item->icon(); diff --git a/src/core/qgsdataitem.h b/src/core/qgsdataitem.h index 700b1a9fe086..c1dd45a14c2b 100644 --- a/src/core/qgsdataitem.h +++ b/src/core/qgsdataitem.h @@ -112,6 +112,9 @@ class CORE_EXPORT QgsDataItem : public QObject void setIcon( QIcon icon ) { mIcon = icon; } + void setToolTip( QString msg ) { mToolTip = msg; } + QString toolTip() const { return mToolTip; } + protected: Type mType; @@ -120,6 +123,7 @@ class CORE_EXPORT QgsDataItem : public QObject bool mPopulated; QString mName; QString mPath; // it is also used to identify item in tree + QString mToolTip; QIcon mIcon; public slots: diff --git a/src/providers/gdal/qgsgdalprovider.cpp b/src/providers/gdal/qgsgdalprovider.cpp index c55b2c646f29..3ee411815e1b 100644 --- a/src/providers/gdal/qgsgdalprovider.cpp +++ b/src/providers/gdal/qgsgdalprovider.cpp @@ -1940,6 +1940,7 @@ QgsGdalLayerItem::QgsGdalLayerItem( QgsDataItem* parent, QString name, QString path, QString uri ) : QgsLayerItem( parent, name, path, uri, QgsLayerItem::Raster, "gdal" ) { + mToolTip = uri; } QgsGdalLayerItem::~QgsGdalLayerItem() @@ -2023,7 +2024,7 @@ QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem ) QgsDebugMsg( "GdalDataset opened " + thePath ); - QString name = info.fileName(); + QString name = info.completeBaseName(); QString uri = thePath; QgsLayerItem * item = new QgsGdalLayerItem( parentItem, name, thePath, uri ); diff --git a/src/providers/ogr/qgsogrprovider.cpp b/src/providers/ogr/qgsogrprovider.cpp index e887325db7f7..d14df230a516 100644 --- a/src/providers/ogr/qgsogrprovider.cpp +++ b/src/providers/ogr/qgsogrprovider.cpp @@ -2271,6 +2271,7 @@ QgsOgrLayerItem::QgsOgrLayerItem( QgsDataItem* parent, QString name, QString path, QString uri, LayerType layerType ) : QgsLayerItem( parent, name, path, uri, layerType, "ogr" ) { + mToolTip = uri; } QgsOgrLayerItem::~QgsOgrLayerItem()