Skip to content
Permalink
Browse files
Replaced use of qgsErrorBox with QgsErrorBar
Removed some empty lines
  • Loading branch information
Hvitnov committed May 22, 2015
1 parent 1075925 commit a5351fc18a2660750756b270553614ee1fb7af94
Showing with 16 additions and 32 deletions.
  1. +15 −30 src/app/qgisapp.cpp
  2. +1 −2 src/app/qgisapp.h
@@ -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
@@ -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" );
@@ -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() );
@@ -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 );

0 comments on commit a5351fc

Please sign in to comment.