File tree 1 file changed +15
-2
lines changed
1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change 69
69
#include " qgsvectordataprovider.h"
70
70
#include " qgsvectoroverlay.h"
71
71
#include " qgslogger.h"
72
+ #include " qgsmaplayerregistry.h"
72
73
73
74
#ifdef Q_WS_X11
74
75
#include " qgsclipper.h"
@@ -2181,12 +2182,24 @@ bool QgsVectorLayer::setDataProvider( QString const & provider )
2181
2182
if ( mProviderKey == " postgres" )
2182
2183
{
2183
2184
QgsDebugMsg ( " Beautifying layer name " + name () );
2185
+
2184
2186
// adjust the display name for postgres layers
2185
- QRegExp reg ( " \" [^\" ]+\"\\ .\" ([^\" ]+)\" " );
2187
+ QRegExp reg ( " \" [^\" ]+\"\\ .\" ([^\" ]+)\" \\ (([^)]+) \\ ) " );
2186
2188
reg.indexIn ( name () );
2187
2189
QStringList stuff = reg.capturedTexts ();
2188
2190
QString lName = stuff[1 ];
2189
- if ( lName.length () == 0 ) // fallback
2191
+ if ( lName.length () == 3 )
2192
+ {
2193
+ const QMap<QString, QgsMapLayer*> &layers = QgsMapLayerRegistry::instance ()->mapLayers ();
2194
+
2195
+ QMap<QString, QgsMapLayer*>::const_iterator it;
2196
+ for ( it = layers.constBegin (); it != layers.constEnd () && ( *it )->name () != lName; it++ )
2197
+ ;
2198
+
2199
+ if ( it != layers.constEnd () )
2200
+ lName += " ." + stuff[2 ];
2201
+ }
2202
+ else if ( lName.length () == 0 ) // fallback
2190
2203
lName = name ();
2191
2204
setLayerName ( lName );
2192
2205
QgsDebugMsg ( " Beautifying layer name " + name () );
You can’t perform that action at this time.
0 commit comments