|
267 | 267 | #include "qgsvectorlayerutils.h"
|
268 | 268 | #include "qgshelp.h"
|
269 | 269 | #include "qgsvectorfilewritertask.h"
|
| 270 | +#include "qgsnewnamedialog.h" |
270 | 271 |
|
271 | 272 | #include "qgssublayersdialog.h"
|
272 | 273 | #include "ogr/qgsopenvectorlayerdialog.h"
|
@@ -3163,6 +3164,7 @@ QgsMapCanvas *QgisApp::createNewMapCanvas( const QString &name, bool isFloating,
|
3163 | 3164 | mapCanvas->freeze( false );
|
3164 | 3165 | markDirty();
|
3165 | 3166 | connect( mapCanvasWidget, &QgsMapCanvasDockWidget::closed, this, &QgisApp::markDirty );
|
| 3167 | + connect( mapCanvasWidget, &QgsMapCanvasDockWidget::renameTriggered, this, &QgisApp::renameView ); |
3166 | 3168 | return mapCanvas;
|
3167 | 3169 | }
|
3168 | 3170 |
|
@@ -11173,6 +11175,37 @@ void QgisApp::refreshActionFeatureAction()
|
11173 | 11175 | mActionFeatureAction->setEnabled( layerHasActions );
|
11174 | 11176 | }
|
11175 | 11177 |
|
| 11178 | +void QgisApp::renameView() |
| 11179 | +{ |
| 11180 | + QgsMapCanvasDockWidget *view = qobject_cast< QgsMapCanvasDockWidget * >( sender() ); |
| 11181 | + if ( !view ) |
| 11182 | + return; |
| 11183 | + |
| 11184 | + // calculate existing names |
| 11185 | + QStringList names; |
| 11186 | + Q_FOREACH ( QgsMapCanvas *c, mapCanvases() ) |
| 11187 | + { |
| 11188 | + if ( c == view->mapCanvas() ) |
| 11189 | + continue; |
| 11190 | + |
| 11191 | + names << c->objectName(); |
| 11192 | + } |
| 11193 | + |
| 11194 | + QString currentName = view->mapCanvas()->objectName(); |
| 11195 | + |
| 11196 | + QgsNewNameDialog renameDlg( currentName, currentName, QStringList(), names, QRegExp(), Qt::CaseSensitive, this ); |
| 11197 | + renameDlg.setWindowTitle( tr( "Map Views" ) ); |
| 11198 | + //renameDlg.setHintString( tr( "Name of the new view" ) ); |
| 11199 | + renameDlg.setOverwriteEnabled( false ); |
| 11200 | + renameDlg.setConflictingNameWarning( tr( "A view with this name already exists" ) ); |
| 11201 | + if ( renameDlg.exec() || renameDlg.name().isEmpty() ) |
| 11202 | + { |
| 11203 | + QString newName = renameDlg.name(); |
| 11204 | + view->setWindowTitle( newName ); |
| 11205 | + view->mapCanvas()->setObjectName( newName ); |
| 11206 | + } |
| 11207 | +} |
| 11208 | + |
11176 | 11209 | /////////////////////////////////////////////////////////////////
|
11177 | 11210 | //
|
11178 | 11211 | //
|
|
0 commit comments