Skip to content

Commit

Permalink
Replaced use of qgsErrorBox with QgsErrorBar
Browse files Browse the repository at this point in the history
Removed some empty lines
  • Loading branch information
Hvitnov committed May 22, 2015
1 parent 1075925 commit a5351fc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 32 deletions.
45 changes: 15 additions & 30 deletions src/app/qgisapp.cpp
Expand Up @@ -6517,17 +6517,14 @@ void QgisApp::copyStyle( QgsMapLayer * sourceLayer )

layerGeometryType.appendChild(type);
rootNode.appendChild(layerGeometryType);

}

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

void QgisApp::pasteStyle( QgsMapLayer * destinationLayer )
{

QgsMapLayer *selectionLayer = destinationLayer ? destinationLayer : activeLayer();
if ( selectionLayer )
{

if ( clipboard()->hasFormat( QGSCLIPBOARD_STYLE_MIME ) )
{
QDomDocument doc( "qgis" );
QString errorMsg;
int errorLine, errorColumn;
if ( !doc.setContent( clipboard()->data( QGSCLIPBOARD_STYLE_MIME ), false, &errorMsg, &errorLine, &errorColumn ) )
{
QMessageBox::information( this,
tr( "Error" ),
tr( "Cannot parse style: %1:%2:%3" )
.arg( errorMsg )
.arg( errorLine )
.arg( errorColumn ),
QMessageBox::Ok );
return;

messageBar()->pushMessage( errorMsg,
tr( "Cannot parse style: %1:%2:%3" ),
QgsMessageBar::CRITICAL, messageTimeout() );
return;
}

QDomElement rootNode = doc.firstChildElement( "qgis" );
Expand All @@ -6573,28 +6565,21 @@ void QgisApp::pasteStyle( QgsMapLayer * destinationLayer )
{
QgsVectorLayer *selectionVectorLayer = static_cast<QgsVectorLayer*>(selectionLayer);
int pasteLayerGeometryType = doc.elementsByTagName("layerGeometryType").item(0).toElement().text().toInt();

if ( selectionVectorLayer->geometryType() != pasteLayerGeometryType )
{
QMessageBox::information( this,
tr( "Error" ),
tr( "Cannot paste style to layers that have a different geometry type" )
.arg( errorMsg ),
QMessageBox::Ok );
messageBar()->pushMessage( tr( "Cannot paste style to layer with a different geometry type" ),
tr( "Your copied style does not match the layer you are pasting to" ),
QgsMessageBar::INFO, messageTimeout() );
return;
}
}



if ( !selectionLayer->readSymbology( rootNode, errorMsg ) )
{
QMessageBox::information( this,
tr( "Error" ),
tr( "Cannot read style: %1" )
.arg( errorMsg ),
QMessageBox::Ok );
return;
messageBar()->pushMessage( errorMsg,
tr( "Cannot read style: %1" ),
QgsMessageBar::CRITICAL, messageTimeout() );
return;
}

mLayerTreeView->refreshLayerSymbology( selectionLayer->id() );
Expand Down
3 changes: 1 addition & 2 deletions src/app/qgisapp.h
Expand Up @@ -582,14 +582,13 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
void copyStyle( QgsMapLayer *sourceLayer = 0 );
//! pastes style on the clipboard to the active layer
/**
\param destinatioLayer The layer that the clipboard will be pasted to
\param destinationLayer The layer that the clipboard will be pasted to
(defaults to the active layer on the legend)
*/
void pasteStyle( QgsMapLayer *destinationLayer = 0 );

//! copies features to internal clipboard
void copyFeatures( QgsFeatureStore & featureStore );

void loadOGRSublayers( QString layertype, QString uri, QStringList list );
void loadGDALSublayers( QString uri, QStringList list );

Expand Down

0 comments on commit a5351fc

Please sign in to comment.