14 changes: 13 additions & 1 deletion python/core/qgsmaplayerregistry.sip
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class QgsMapLayerRegistry : QObject
@see addMapLayers
@note Use addMapLayers if adding more than one layer at a time
*/
QgsMapLayer *addMapLayer( QgsMapLayer * theMapLayer /Transfer/, bool theEmitSignal = true ) /Deprecated/;
QgsMapLayer *addMapLayer( QgsMapLayer * theMapLayer /Transfer/, bool theEmitSignal = true );

/** Remove a set of layers from qgis
@note As a side-effect QgsProject is made dirty.
Expand All @@ -63,6 +63,18 @@ class QgsMapLayerRegistry : QObject
*/
void removeMapLayers( QStringList theLayerIds, bool theEmitSignal = true );

/** Remove a layer from qgis
@note As a side-effect QgsProject is made dirty.
Any canvases using the affected layers will need to remove them

If theEmitSignal is true (by default), a layersRemoved( QStringList theLayerIds )
signal will be emitted indicating to any listeners that the layers are being removed.

The layer being removed is deleted as well as the registry
table entry.
*/
void removeMapLayer( const QString& theLayerId, bool theEmitSignal = true );

/** Remove all registered layers
@note raises removedAll()
As a side-effect QgsProject is made dirty.
Expand Down
15 changes: 15 additions & 0 deletions src/app/openstreetmap/qgsosmexportdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@

#include "qgsosmdatabase.h"

#include "qgsdatasourceuri.h"
#include "qgsmaplayerregistry.h"
#include "qgsvectorlayer.h"

#include <QApplication>
#include <QFileDialog>
#include <QMessageBox>
Expand Down Expand Up @@ -148,6 +152,17 @@ void QgsOSMExportDialog::onOK()

bool res = mDatabase->exportSpatiaLite( type, editLayerName->text(), tagKeys );

// load the layer into canvas if that was requested
if ( chkLoadWhenFinished->isChecked() )
{
QgsDataSourceURI uri;
uri.setDatabase( editDbFileName->text() );
uri.setDataSource( QString(), editLayerName->text(), "geometry" );
QgsVectorLayer* vlayer = new QgsVectorLayer( uri.uri(), editLayerName->text(), "spatialite" );
if ( vlayer->isValid() )
QgsMapLayerRegistry::instance()->addMapLayer( vlayer );
}

QApplication::restoreOverrideCursor();
buttonBox->setEnabled( true );

Expand Down
44 changes: 5 additions & 39 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,16 +530,6 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
mSaveRollbackInProgress = false;
activateDeactivateLayerRelatedActions( NULL );

QAction* actionOSMDownload = new QAction( tr( "Download data" ), this );
connect( actionOSMDownload, SIGNAL( triggered() ), this, SLOT( osmDownloadDialog() ) );
QAction* actionOSMImport = new QAction( tr( "Import topology from XML" ), this );
connect( actionOSMImport, SIGNAL( triggered() ), this, SLOT( osmImportDialog() ) );
QAction* actionOSMExport = new QAction( tr( "Export topology to SpatiaLite" ), this );
connect( actionOSMExport, SIGNAL( triggered() ), this, SLOT( osmExportDialog() ) );
addPluginToVectorMenu( "OpenStreetMap", actionOSMDownload );
addPluginToVectorMenu( "OpenStreetMap", actionOSMImport );
addPluginToVectorMenu( "OpenStreetMap", actionOSMExport );

addDockWidget( Qt::LeftDockWidgetArea, mUndoWidget );
mUndoWidget->hide();

Expand Down Expand Up @@ -1061,6 +1051,11 @@ void QgisApp::createActions()
connect( mActionLocalCumulativeCutStretch, SIGNAL( triggered() ), this, SLOT( localCumulativeCutStretch() ) );
connect( mActionFullCumulativeCutStretch, SIGNAL( triggered() ), this, SLOT( fullCumulativeCutStretch() ) );

// Vector Menu Items
connect( mActionOSMDownload, SIGNAL( triggered() ), this, SLOT( osmDownloadDialog() ) );
connect( mActionOSMImport, SIGNAL( triggered() ), this, SLOT( osmImportDialog() ) );
connect( mActionOSMExport, SIGNAL( triggered() ), this, SLOT( osmExportDialog() ) );

// Help Menu Items

#ifdef Q_WS_MAC
Expand Down Expand Up @@ -1312,10 +1307,6 @@ void QgisApp::createMenus()
// don't add it yet, wait for a plugin
mDatabaseMenu = new QMenu( tr( "&Database" ), menuBar() );
mDatabaseMenu->setObjectName( "mDatabaseMenu" );
// Vector Menu
// don't add it yet, wait for a plugin
mVectorMenu = new QMenu( tr( "Vect&or" ), menuBar() );
mVectorMenu->setObjectName( "mVectorMenu" );
// Web Menu
// don't add it yet, wait for a plugin
mWebMenu = new QMenu( tr( "&Web" ), menuBar() );
Expand Down Expand Up @@ -7101,31 +7092,6 @@ void QgisApp::addPluginToVectorMenu( QString name, QAction* action )
{
QMenu* menu = getVectorMenu( name );
menu->addAction( action );

// add the Vector menu to the menuBar if not added yet
if ( mVectorMenu->actions().count() != 1 )
return;

QAction* before = NULL;
QList<QAction*> actions = menuBar()->actions();
for ( int i = 0; i < actions.count(); i++ )
{
if ( actions.at( i )->menu() == mVectorMenu )
return;

// goes before Raster menu, which is already in qgisapp.ui
if ( actions.at( i )->menu() == mRasterMenu )
{
before = actions.at( i );
break;
}
}

if ( before )
menuBar()->insertMenu( before, mVectorMenu );
else
// fallback insert
menuBar()->insertMenu( firstRightStandardMenu()->menuAction(), mVectorMenu );
}

void QgisApp::addPluginToWebMenu( QString name, QAction* action )
Expand Down
2 changes: 0 additions & 2 deletions src/app/qgisapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -1257,8 +1257,6 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
QMenu * mPopupMenu;
//! Top level database menu
QMenu *mDatabaseMenu;
//! Top level vector menu
QMenu *mVectorMenu;
//! Top level web menu
QMenu *mWebMenu;
//! Popup menu for the map overview tools
Expand Down
6 changes: 6 additions & 0 deletions src/core/qgsmaplayerregistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ void QgsMapLayerRegistry::removeMapLayers( QStringList theLayerIds,
emit layersWillBeRemoved( theLayerIds );
}

void QgsMapLayerRegistry::removeMapLayer( const QString& theLayerId, bool theEmitSignal )
{
removeMapLayers( QStringList( theLayerId ), theEmitSignal );
}


void QgsMapLayerRegistry::removeAllMapLayers()
{
// moved before physically removing the layers
Expand Down
16 changes: 14 additions & 2 deletions src/core/qgsmaplayerregistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ class CORE_EXPORT QgsMapLayerRegistry : public QObject
/** Add a layer to the map of loaded layers
@returns NULL if unable to add layer, otherwise pointer to newly added layer
@see addMapLayers
@note addMapLayers is prefered and must be used if adding more than one layer at a time
@note Use addMapLayers if adding more than one layer at a time
*/
Q_DECL_DEPRECATED QgsMapLayer *addMapLayer( QgsMapLayer * theMapLayer, bool theEmitSignal = true );
QgsMapLayer *addMapLayer( QgsMapLayer * theMapLayer, bool theEmitSignal = true );

/** Remove a set of layers from qgis
@note As a side-effect QgsProject is made dirty.
Expand All @@ -86,6 +86,18 @@ class CORE_EXPORT QgsMapLayerRegistry : public QObject
*/
void removeMapLayers( QStringList theLayerIds, bool theEmitSignal = true );

/** Remove a layer from qgis
@note As a side-effect QgsProject is made dirty.
Any canvases using the affected layers will need to remove them
If theEmitSignal is true (by default), a layersRemoved( QStringList theLayerIds )
signal will be emitted indicating to any listeners that the layers are being removed.
The layer being removed is deleted as well as the registry
table entry.
*/
void removeMapLayer( const QString& theLayerId, bool theEmitSignal = true );

/** Remove all registered layers
@note raises removedAll()
As a side-effect QgsProject is made dirty.
Expand Down
38 changes: 34 additions & 4 deletions src/ui/qgisapp.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1052</width>
<height>489</height>
<width>1050</width>
<height>487</height>
</rect>
</property>
<widget class="QWidget" name="centralwidget"/>
Expand All @@ -16,8 +16,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1052</width>
<height>24</height>
<width>1050</width>
<height>23</height>
</rect>
</property>
<widget class="QMenu" name="mEditMenu">
Expand Down Expand Up @@ -224,12 +224,27 @@
</property>
<addaction name="mActionShowRasterCalculator"/>
</widget>
<widget class="QMenu" name="mVectorMenu">
<property name="title">
<string>Vect&amp;or</string>
</property>
<widget class="QMenu" name="menuOpenStreetMap">
<property name="title">
<string>&amp;OpenStreetMap</string>
</property>
<addaction name="mActionOSMDownload"/>
<addaction name="mActionOSMImport"/>
<addaction name="mActionOSMExport"/>
</widget>
<addaction name="menuOpenStreetMap"/>
</widget>
<addaction name="mFileMenu"/>
<addaction name="mEditMenu"/>
<addaction name="mViewMenu"/>
<addaction name="mLayerMenu"/>
<addaction name="mSettingsMenu"/>
<addaction name="mPluginMenu"/>
<addaction name="mVectorMenu"/>
<addaction name="mRasterMenu"/>
<addaction name="mHelpMenu"/>
</widget>
Expand Down Expand Up @@ -1984,6 +1999,21 @@ Acts on currently active editable layer</string>
<string>Rotate Feature(s)</string>
</property>
</action>
<action name="mActionOSMDownload">
<property name="text">
<string>&amp;Download data</string>
</property>
</action>
<action name="mActionOSMImport">
<property name="text">
<string>&amp;Import topology from XML</string>
</property>
</action>
<action name="mActionOSMExport">
<property name="text">
<string>&amp;Export topology to SpatiaLite</string>
</property>
</action>
</widget>
<resources>
<include location="../../images/images.qrc"/>
Expand Down
15 changes: 13 additions & 2 deletions src/ui/qgsosmexportdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>458</width>
<height>436</height>
<width>456</width>
<height>434</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -118,6 +118,16 @@
</layout>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkLoadWhenFinished">
<property name="text">
<string>&amp;Load into canvas when finished</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
Expand Down Expand Up @@ -150,6 +160,7 @@
<tabstop>editLayerName</tabstop>
<tabstop>btnLoadTags</tabstop>
<tabstop>viewTags</tabstop>
<tabstop>chkLoadWhenFinished</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources/>
Expand Down