Skip to content

Commit a5351fc

Browse files
committed
Replaced use of qgsErrorBox with QgsErrorBar
Removed some empty lines
1 parent 1075925 commit a5351fc

File tree

2 files changed

+16
-32
lines changed

2 files changed

+16
-32
lines changed

src/app/qgisapp.cpp

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6517,17 +6517,14 @@ void QgisApp::copyStyle( QgsMapLayer * sourceLayer )
65176517

65186518
layerGeometryType.appendChild(type);
65196519
rootNode.appendChild(layerGeometryType);
6520-
65216520
}
65226521

65236522
QString errorMsg;
65246523
if ( !selectionLayer->writeSymbology( rootNode, doc, errorMsg ) )
65256524
{
6526-
QMessageBox::warning( this,
6527-
tr( "Error" ),
6528-
tr( "Cannot copy style: %1" )
6529-
.arg( errorMsg ),
6530-
QMessageBox::Ok );
6525+
messageBar()->pushMessage( errorMsg,
6526+
tr( "Cannot copy style: %1" ),
6527+
QgsMessageBar::CRITICAL, messageTimeout() );
65316528
return;
65326529
}
65336530
// Copies data in text form as well, so the XML can be pasted into a text editor
@@ -6544,26 +6541,21 @@ void QgisApp::copyStyle( QgsMapLayer * sourceLayer )
65446541

65456542
void QgisApp::pasteStyle( QgsMapLayer * destinationLayer )
65466543
{
6547-
65486544
QgsMapLayer *selectionLayer = destinationLayer ? destinationLayer : activeLayer();
65496545
if ( selectionLayer )
65506546
{
6551-
65526547
if ( clipboard()->hasFormat( QGSCLIPBOARD_STYLE_MIME ) )
65536548
{
65546549
QDomDocument doc( "qgis" );
65556550
QString errorMsg;
65566551
int errorLine, errorColumn;
65576552
if ( !doc.setContent( clipboard()->data( QGSCLIPBOARD_STYLE_MIME ), false, &errorMsg, &errorLine, &errorColumn ) )
65586553
{
6559-
QMessageBox::information( this,
6560-
tr( "Error" ),
6561-
tr( "Cannot parse style: %1:%2:%3" )
6562-
.arg( errorMsg )
6563-
.arg( errorLine )
6564-
.arg( errorColumn ),
6565-
QMessageBox::Ok );
6566-
return;
6554+
6555+
messageBar()->pushMessage( errorMsg,
6556+
tr( "Cannot parse style: %1:%2:%3" ),
6557+
QgsMessageBar::CRITICAL, messageTimeout() );
6558+
return;
65676559
}
65686560

65696561
QDomElement rootNode = doc.firstChildElement( "qgis" );
@@ -6573,28 +6565,21 @@ void QgisApp::pasteStyle( QgsMapLayer * destinationLayer )
65736565
{
65746566
QgsVectorLayer *selectionVectorLayer = static_cast<QgsVectorLayer*>(selectionLayer);
65756567
int pasteLayerGeometryType = doc.elementsByTagName("layerGeometryType").item(0).toElement().text().toInt();
6576-
65776568
if ( selectionVectorLayer->geometryType() != pasteLayerGeometryType )
65786569
{
6579-
QMessageBox::information( this,
6580-
tr( "Error" ),
6581-
tr( "Cannot paste style to layers that have a different geometry type" )
6582-
.arg( errorMsg ),
6583-
QMessageBox::Ok );
6570+
messageBar()->pushMessage( tr( "Cannot paste style to layer with a different geometry type" ),
6571+
tr( "Your copied style does not match the layer you are pasting to" ),
6572+
QgsMessageBar::INFO, messageTimeout() );
65846573
return;
65856574
}
65866575
}
65876576

6588-
6589-
65906577
if ( !selectionLayer->readSymbology( rootNode, errorMsg ) )
65916578
{
6592-
QMessageBox::information( this,
6593-
tr( "Error" ),
6594-
tr( "Cannot read style: %1" )
6595-
.arg( errorMsg ),
6596-
QMessageBox::Ok );
6597-
return;
6579+
messageBar()->pushMessage( errorMsg,
6580+
tr( "Cannot read style: %1" ),
6581+
QgsMessageBar::CRITICAL, messageTimeout() );
6582+
return;
65986583
}
65996584

66006585
mLayerTreeView->refreshLayerSymbology( selectionLayer->id() );

src/app/qgisapp.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -582,14 +582,13 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
582582
void copyStyle( QgsMapLayer *sourceLayer = 0 );
583583
//! pastes style on the clipboard to the active layer
584584
/**
585-
\param destinatioLayer The layer that the clipboard will be pasted to
585+
\param destinationLayer The layer that the clipboard will be pasted to
586586
(defaults to the active layer on the legend)
587587
*/
588588
void pasteStyle( QgsMapLayer *destinationLayer = 0 );
589589

590590
//! copies features to internal clipboard
591591
void copyFeatures( QgsFeatureStore & featureStore );
592-
593592
void loadOGRSublayers( QString layertype, QString uri, QStringList list );
594593
void loadGDALSublayers( QString uri, QStringList list );
595594

0 commit comments

Comments
 (0)