955 changes: 955 additions & 0 deletions images/themes/default/mActionAllEdits.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
928 changes: 928 additions & 0 deletions images/themes/default/mActionCancelAllEdits.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
936 changes: 936 additions & 0 deletions images/themes/default/mActionCancelEdits.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
761 changes: 761 additions & 0 deletions images/themes/default/mActionRollbackAllEdits.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
769 changes: 769 additions & 0 deletions images/themes/default/mActionRollbackEdits.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed images/themes/default/mActionSaveAllEdits.png
Binary file not shown.
775 changes: 775 additions & 0 deletions images/themes/default/mActionSaveAllEdits.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
783 changes: 783 additions & 0 deletions images/themes/default/mActionSaveEdits.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
876 changes: 876 additions & 0 deletions images/themes/default/mActionToggleEditing.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/themes/default/mIconEditableEdits.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
955 changes: 955 additions & 0 deletions images/themes/gis/mActionAllEdits.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
928 changes: 928 additions & 0 deletions images/themes/gis/mActionCancelAllEdits.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
936 changes: 936 additions & 0 deletions images/themes/gis/mActionCancelEdits.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
761 changes: 761 additions & 0 deletions images/themes/gis/mActionRollbackAllEdits.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
769 changes: 769 additions & 0 deletions images/themes/gis/mActionRollbackEdits.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed images/themes/gis/mActionSaveAllEdits.png
Binary file not shown.
775 changes: 775 additions & 0 deletions images/themes/gis/mActionSaveAllEdits.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed images/themes/gis/mActionSaveEdits.png
Binary file not shown.
783 changes: 783 additions & 0 deletions images/themes/gis/mActionSaveEdits.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
876 changes: 876 additions & 0 deletions images/themes/gis/mActionToggleEditing.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/themes/gis/mIconEditableEdits.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions python/gui/qgisinterface.sip
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,19 @@ class QgisInterface : QObject
virtual QAction *actionOpenTable() = 0;
virtual QAction *actionToggleEditing() = 0;
/** @note added in 1.9 */
virtual QAction *actionAllEdits() = 0;
/** @note added in 1.9 */
virtual QAction *actionSaveEdits() = 0;
/** @note added in 1.9 */
virtual QAction *actionSaveAllEdits() = 0;
/** @note added in 1.9 */
virtual QAction *actionRollbackEdits() = 0;
/** @note added in 1.9 */
virtual QAction *actionRollbackAllEdits() = 0;
/** @note added in 1.9 */
virtual QAction *actionCancelEdits() = 0;
/** @note added in 1.9 */
virtual QAction *actionCancelAllEdits() = 0;
virtual QAction *actionLayerSaveAs() = 0;
virtual QAction *actionLayerSelectionSaveAs() = 0;
virtual QAction *actionRemoveLayer() = 0;
Expand Down Expand Up @@ -380,6 +390,12 @@ class QgisInterface : QObject
// @added in 1.6
virtual bool openFeatureForm( QgsVectorLayer *l, QgsFeature &f, bool updateFeatureOnly = false ) = 0;

/** Return vector layers in edit mode
* @param modified whether to return only layers that have been modified
* @returns list of layers in legend order, or empty list
* @note added in 1.9 */
virtual QList<QgsMapLayer *> editableLayers( bool modified = false ) const = 0;

signals:
/** Emited whenever current (selected) layer changes.
* The pointer to layer can be null if no layer is selected
Expand Down
19 changes: 19 additions & 0 deletions src/app/legend/qgslegend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1124,6 +1124,25 @@ QList<QgsMapLayer *> QgsLegend::selectedLayers( bool inDrawOrder )
return layers;
}

bool QgsLegend::selectedLayersEditable( bool modified )
{
bool hasEditable = false;
foreach ( QgsMapLayer * layer, selectedLayers() )
{
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer*>( layer );
if ( !vl )
{
continue;
}
if ( vl->isEditable() && ( !modified || ( modified && vl->isModified() ) ) )
{
hasEditable = true;
break;
}
}
return hasEditable;
}

QList<QgsLegendLayer *> QgsLegend::legendLayers()
{
if ( mUpdateDrawingOrder )
Expand Down
5 changes: 5 additions & 0 deletions src/app/legend/qgslegend.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ class QgsLegend : public QTreeWidget
* @returns list of layers, else an empty list */
QList<QgsMapLayer *> selectedLayers( bool inDrawOrder = false );

/** Returns true if layer selection has any editable vector layers
* @param modified return true of any of layers is also modified
* @note added in 1.9 */
bool selectedLayersEditable( bool modified = false );

/*!Returns all layers loaded in QgsMapCanvas in drawing order
Else, an empty list is returned.*/
QList<QgsMapLayer *> layers();
Expand Down
10 changes: 7 additions & 3 deletions src/app/legend/qgslegendlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ void QgsLegendLayer::addToPopupMenu( QMenu& theMenu )
{
QgsMapLayer *lyr = layer();
QAction *toggleEditingAction = QgisApp::instance()->actionToggleEditing();
QAction *allEditsAction = QgisApp::instance()->actionAllEdits();

// zoom to layer extent
theMenu.addAction( QgsApplication::getThemeIcon( "/mActionZoomToLayer.png" ),
Expand Down Expand Up @@ -470,6 +471,11 @@ void QgsLegendLayer::addToPopupMenu( QMenu& theMenu )
}
}

if ( allEditsAction->isEnabled() )
{
theMenu.addAction( allEditsAction );
}

// disable duplication of memory layers
if ( vlayer->storageType() == "Memory storage" && legend()->selectedLayers().count() == 1 )
{
Expand Down Expand Up @@ -608,11 +614,9 @@ void QgsLegendLayer::updateAfterLayerModification()
{
updateAfterLayerModification( false );
}

void QgsLegendLayer::updateAfterLayerModification( bool onlyGeomChanged )
{
QgisApp::instance()->actionSaveAllEdits()->setEnabled(
QgisApp::instance()->unsavedEditableLayers().count() > 0 );

if ( onlyGeomChanged )
{
updateIcon();
Expand Down
404 changes: 299 additions & 105 deletions src/app/qgisapp.cpp

Large diffs are not rendered by default.

65 changes: 54 additions & 11 deletions src/app/qgisapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,19 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
QAction *actionPasteLayerStyle() { return mActionPasteStyle; }
QAction *actionOpenTable() { return mActionOpenTable; }
QAction *actionToggleEditing() { return mActionToggleEditing; }
/** @note added in 1.9 */
QAction *actionAllEdits() { return mActionAllEdits; }
QAction *actionSaveEdits() { return mActionSaveEdits; }
/** @note added in 1.9 */
QAction *actionSaveAllEdits() { return mActionSaveAllEdits; }
/** @note added in 1.9 */
QAction *actionRollbackEdits() { return mActionRollbackEdits; }
/** @note added in 1.9 */
QAction *actionRollbackAllEdits() { return mActionRollbackAllEdits; }
/** @note added in 1.9 */
QAction *actionCancelEdits() { return mActionCancelEdits; }
/** @note added in 1.9 */
QAction *actionCancelAllEdits() { return mActionCancelAllEdits; }
QAction *actionLayerSaveAs() { return mActionLayerSaveAs; }
QAction *actionLayerSelectionSaveAs() { return mActionLayerSelectionSaveAs; }
QAction *actionRemoveLayer() { return mActionRemoveLayer; }
Expand Down Expand Up @@ -379,10 +389,11 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
//! returns pointer to map legend
QgsLegend *legend();

/** Return vector layers with unsaved provider edits
/** Return vector layers in edit mode
* @param modified whether to return only layers that have been modified
* @returns list of layers in legend order, or empty list
* @note added in 1.9 */
QList<QgsMapLayer *> unsavedEditableLayers() const;
QList<QgsMapLayer *> editableLayers( bool modified = false ) const;

#ifdef Q_OS_WIN
//! ugly hack
Expand Down Expand Up @@ -778,19 +789,57 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
//! starts/stops editing mode of the current layer
void toggleEditing();

//! save current edits and start new transaction
//! starts/stops editing mode of a layer
bool toggleEditing( QgsMapLayer *layer, bool allowCancel = true );

//! Save edits of a layer
void saveEdits( QgsMapLayer *layer, bool leaveEditable = true );

/** Cancel edits for a layer
* @note added in 1.9 */
void cancelEdits( QgsMapLayer *layer, bool leaveEditable = true );

//! Save current edits for selected layer(s) and start new transaction(s)
void saveEdits();

/** Save all edits and start new transactions
/** Save edits for all layers and start new transactions
* @note added in 1.9 */
void saveAllEdits( bool verifyAction = true );

/** Rollback current edits for selected layer(s) and start new transaction(s)
* @note added in 1.9 */
void rollbackEdits();

/** Rollback edits for all layers and start new transactions
* @note added in 1.9 */
void saveAllEdits();
void rollbackAllEdits( bool verifyAction = true );

/** Cancel edits for selected layer(s) and toggle off editing
* @note added in 1.9 */
void cancelEdits();

/** Cancel all edits for all layers and toggle off editing
* @note added in 1.9 */
void cancelAllEdits( bool verifyAction = true );

/** Dialog for verification of action on many edits
* @note added in 1.9 */
bool verifyEditsActionDialog( QString act, QString upon );

/** Update gui actions/menus when layers are modified
* @note added in 1.9 */
void updateLayerModifiedActions();

//! change layer subset of current vector layer
void layerSubsetString();

//! map tool changed
void mapToolChanged( QgsMapTool *tool );

/** Called when some layer's editing mode was toggled on/off
* @note added in 1.9 */
void layerEditStateChanged();

/** Activates or deactivates actions depending on the current maplayer type.
Is called from the legend when the current legend item has changed*/
void activateDeactivateLayerRelatedActions( QgsMapLayer* layer );
Expand Down Expand Up @@ -851,12 +900,6 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
//! shows label settings dialog (for labeling-ng)
void labeling();

//! starts/stops editing mode of a layer
bool toggleEditing( QgsMapLayer *layer, bool allowCancel = true );

//! save edits of a layer
void saveEdits( QgsMapLayer *layer );

//! save current vector layer
void saveAsFile();
void saveSelectionAsVectorFile();
Expand Down
10 changes: 10 additions & 0 deletions src/app/qgisappinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,8 +436,13 @@ QAction *QgisAppInterface::actionCopyLayerStyle() { return qgis->actionCopyLayer
QAction *QgisAppInterface::actionPasteLayerStyle() { return qgis->actionPasteLayerStyle(); }
QAction *QgisAppInterface::actionOpenTable() { return qgis->actionOpenTable(); }
QAction *QgisAppInterface::actionToggleEditing() { return qgis->actionToggleEditing(); }
QAction *QgisAppInterface::actionAllEdits() { return qgis->actionAllEdits(); }
QAction *QgisAppInterface::actionSaveEdits() { return qgis->actionSaveEdits(); }
QAction *QgisAppInterface::actionSaveAllEdits() { return qgis->actionSaveAllEdits(); }
QAction *QgisAppInterface::actionRollbackEdits() { return qgis->actionRollbackEdits(); }
QAction *QgisAppInterface::actionRollbackAllEdits() { return qgis->actionRollbackAllEdits(); }
QAction *QgisAppInterface::actionCancelEdits() { return qgis->actionCancelEdits(); }
QAction *QgisAppInterface::actionCancelAllEdits() { return qgis->actionCancelAllEdits(); }
QAction *QgisAppInterface::actionLayerSaveAs() { return qgis->actionLayerSaveAs(); }
QAction *QgisAppInterface::actionLayerSelectionSaveAs() { return qgis->actionLayerSelectionSaveAs(); }
QAction *QgisAppInterface::actionRemoveLayer() { return qgis->actionRemoveLayer(); }
Expand Down Expand Up @@ -474,3 +479,8 @@ bool QgisAppInterface::openFeatureForm( QgsVectorLayer *vlayer, QgsFeature &f, b
QgsFeatureAction action( tr( "Attributes changed" ), f, vlayer, -1, -1, QgisApp::instance() );
return action.editFeature();
}

QList<QgsMapLayer *> QgisAppInterface::editableLayers( bool modified ) const
{
return qgis->editableLayers( modified );
}
16 changes: 16 additions & 0 deletions src/app/qgisappinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,19 @@ class QgisAppInterface : public QgisInterface
virtual QAction *actionOpenTable();
virtual QAction *actionToggleEditing();
/** @note added in 1.9 */
virtual QAction *actionAllEdits();
/** @note added in 1.9 */
virtual QAction *actionSaveEdits();
/** @note added in 1.9 */
virtual QAction *actionSaveAllEdits();
/** @note added in 1.9 */
virtual QAction *actionRollbackEdits();
/** @note added in 1.9 */
virtual QAction *actionRollbackAllEdits();
/** @note added in 1.9 */
virtual QAction *actionCancelEdits();
/** @note added in 1.9 */
virtual QAction *actionCancelAllEdits();
virtual QAction *actionLayerSaveAs();
virtual QAction *actionLayerSelectionSaveAs();
virtual QAction *actionRemoveLayer();
Expand Down Expand Up @@ -335,6 +345,12 @@ class QgisAppInterface : public QgisInterface
// @added in 1.6
virtual bool openFeatureForm( QgsVectorLayer *l, QgsFeature &f, bool updateFeatureOnly = false );

/** Return vector layers in edit mode
* @param modified whether to return only layers that have been modified
* @returns list of layers in legend order, or empty list
* @note added in 1.9 */
virtual QList<QgsMapLayer *> editableLayers( bool modified = false ) const;

signals:
void currentThemeChanged( QString );

Expand Down
16 changes: 16 additions & 0 deletions src/gui/qgisinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -392,9 +392,19 @@ class GUI_EXPORT QgisInterface : public QObject
virtual QAction *actionOpenTable() = 0;
virtual QAction *actionToggleEditing() = 0;
/** @note added in 1.9 */
virtual QAction *actionAllEdits() = 0;
/** @note added in 1.9 */
virtual QAction *actionSaveEdits() = 0;
/** @note added in 1.9 */
virtual QAction *actionSaveAllEdits() = 0;
/** @note added in 1.9 */
virtual QAction *actionRollbackEdits() = 0;
/** @note added in 1.9 */
virtual QAction *actionRollbackAllEdits() = 0;
/** @note added in 1.9 */
virtual QAction *actionCancelEdits() = 0;
/** @note added in 1.9 */
virtual QAction *actionCancelAllEdits() = 0;
virtual QAction *actionLayerSaveAs() = 0;
virtual QAction *actionLayerSelectionSaveAs() = 0;
virtual QAction *actionRemoveLayer() = 0;
Expand Down Expand Up @@ -428,6 +438,12 @@ class GUI_EXPORT QgisInterface : public QObject
// @added in 1.6
virtual bool openFeatureForm( QgsVectorLayer *l, QgsFeature &f, bool updateFeatureOnly = false ) = 0;

/** Return vector layers in edit mode
* @param modified whether to return only layers that have been modified
* @returns list of layers in legend order, or empty list
* @note added in 1.9 */
virtual QList<QgsMapLayer *> editableLayers( bool modified = false ) const = 0;

signals:
/** Emited whenever current (selected) layer changes.
* The pointer to layer can be null if no layer is selected
Expand Down
95 changes: 84 additions & 11 deletions src/ui/qgisapp.ui
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,7 @@
<addaction name="separator"/>
<addaction name="mActionOpenTable"/>
<addaction name="mActionToggleEditing"/>
<addaction name="mActionSaveEdits"/>
<addaction name="mActionSaveAllEdits"/>
<addaction name="mActionAllEdits"/>
<addaction name="separator"/>
<addaction name="mActionLayerSaveAs"/>
<addaction name="mActionLayerSelectionSaveAs"/>
Expand Down Expand Up @@ -281,9 +280,8 @@
<attribute name="toolBarBreak">
<bool>true</bool>
</attribute>
<addaction name="mActionSaveAllEdits"/>
<addaction name="mActionAllEdits"/>
<addaction name="mActionToggleEditing"/>
<addaction name="mActionSaveEdits"/>
<addaction name="mActionAddFeature"/>
<addaction name="mActionMoveFeature"/>
<addaction name="mActionNodeTool"/>
Expand Down Expand Up @@ -1215,7 +1213,7 @@
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionToggleEditing.png</normaloff>:/images/themes/default/mActionToggleEditing.png</iconset>
<normaloff>:/images/themes/default/mActionToggleEditing.svg</normaloff>:/images/themes/default/mActionToggleEditing.svg</iconset>
</property>
<property name="text">
<string>Toggle Editing</string>
Expand All @@ -1227,10 +1225,10 @@
<action name="mActionSaveEdits">
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionSaveEdits.png</normaloff>:/images/themes/default/mActionSaveEdits.png</iconset>
<normaloff>:/images/themes/default/mActionSaveEdits.svg</normaloff>:/images/themes/default/mActionSaveEdits.svg</iconset>
</property>
<property name="text">
<string>Save Edits</string>
<string>Save for Selected Layer(s)</string>
</property>
<property name="statusTip">
<string>Save edits to current layer, but continue editing</string>
Expand Down Expand Up @@ -1855,16 +1853,91 @@ Acts on currently active editable layer</string>
<action name="mActionSaveAllEdits">
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionSaveAllEdits.png</normaloff>:/images/themes/default/mActionSaveAllEdits.png</iconset>
<normaloff>:/images/themes/default/mActionSaveAllEdits.svg</normaloff>:/images/themes/default/mActionSaveAllEdits.svg</iconset>
</property>
<property name="text">
<string>Save Edits for All Layers</string>
<string>Save for All Layers</string>
</property>
<property name="toolTip">
<string>Save Edits for All Layers</string>
<string>Save for All Layers</string>
</property>
<property name="statusTip">
<string>Save edits for all layers, but continue editing</string>
<string/>
</property>
</action>
<action name="mActionRollbackAllEdits">
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionRollbackAllEdits.svg</normaloff>:/images/themes/default/mActionRollbackAllEdits.svg</iconset>
</property>
<property name="text">
<string>Rollback for All Layers</string>
</property>
<property name="toolTip">
<string>Rollback for All Layers</string>
</property>
<property name="statusTip">
<string/>
</property>
</action>
<action name="mActionCancelAllEdits">
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionCancelAllEdits.svg</normaloff>:/images/themes/default/mActionCancelAllEdits.svg</iconset>
</property>
<property name="text">
<string>Cancel for All Layers</string>
</property>
<property name="toolTip">
<string>Cancel for All Layers</string>
</property>
<property name="statusTip">
<string/>
</property>
</action>
<action name="mActionRollbackEdits">
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionRollbackEdits.svg</normaloff>:/images/themes/default/mActionRollbackEdits.svg</iconset>
</property>
<property name="text">
<string>Rollback for Selected Layer(s)</string>
</property>
<property name="toolTip">
<string>Rollback for Selected Layer(s)</string>
</property>
<property name="statusTip">
<string/>
</property>
</action>
<action name="mActionAllEdits">
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionAllEdits.svg</normaloff>:/images/themes/default/mActionAllEdits.svg</iconset>
</property>
<property name="text">
<string>Current Edits</string>
</property>
<property name="toolTip">
<string>Current Edits</string>
</property>
<property name="statusTip">
<string/>
</property>
</action>
<action name="mActionCancelEdits">
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionCancelEdits.svg</normaloff>:/images/themes/default/mActionCancelEdits.svg</iconset>
</property>
<property name="text">
<string>Cancel for Selected Layer(s)</string>
</property>
<property name="toolTip">
<string>Cancel for Selected Layer(s)</string>
</property>
<property name="statusTip">
<string/>
</property>
</action>
</widget>
Expand Down