Skip to content
Permalink
Browse files

Add field calc to main app window

  • Loading branch information
NathanW2 committed May 15, 2013
1 parent 4b76600 commit 1bfa7e9636d89f780ca06177b3aebc7dab2b2dbb
@@ -427,6 +427,7 @@ class QgisInterface : QObject
/** @note added in 1.9 */
virtual QAction *actionPasteLayerStyle() = 0;
virtual QAction *actionOpenTable() = 0;
virtual QAction *actionOpenFieldCalculator() = 0;
virtual QAction *actionToggleEditing() = 0;
/** @note added in 1.9 */
virtual QAction *actionSaveActiveLayerEdits() = 0;
@@ -129,6 +129,7 @@
#include "qgsexpressionselectiondialog.h"
#include "qgsfeature.h"
#include "qgsformannotationitem.h"
#include "qgsfieldcalculator.h"
#include "qgshtmlannotationitem.h"
#include "qgsgenericprojectionselector.h"
#include "qgsgpsinformationwidget.h"
@@ -981,6 +982,7 @@ void QgisApp::createActions()
connect( mActionAddWcsLayer, SIGNAL( triggered() ), this, SLOT( addWcsLayer() ) );
connect( mActionAddWfsLayer, SIGNAL( triggered() ), this, SLOT( addWfsLayer() ) );
connect( mActionOpenTable, SIGNAL( triggered() ), this, SLOT( attributeTable() ) );
connect( mActionOpenFieldCalc, SIGNAL( triggered() ), this, SLOT( fieldCalculator() ) );
connect( mActionToggleEditing, SIGNAL( triggered() ), this, SLOT( toggleEditing() ) );
connect( mActionSaveLayerEdits, SIGNAL( triggered() ), this, SLOT( saveActiveLayerEdits() ) );
connect( mActionSaveEdits, SIGNAL( triggered() ), this, SLOT( saveEdits() ) );
@@ -1738,6 +1740,7 @@ void QgisApp::setTheme( QString theThemeName )
mActionDeselectAll->setIcon( QgsApplication::getThemeIcon( "/mActionDeselectAll.png" ) );
mActionSelectByExpression->setIcon( QgsApplication::getThemeIcon( "/mIconExpressionSelect.svg" ) );
mActionOpenTable->setIcon( QgsApplication::getThemeIcon( "/mActionOpenTable.png" ) );
mActionOpenFieldCalc->setIcon( QgsApplication::getThemeIcon( "/mActionCalculateField.png" ) );
mActionMeasure->setIcon( QgsApplication::getThemeIcon( "/mActionMeasure.png" ) );
mActionMeasureArea->setIcon( QgsApplication::getThemeIcon( "/mActionMeasureArea.png" ) );
mActionMeasureAngle->setIcon( QgsApplication::getThemeIcon( "/mActionMeasureAngle.png" ) );
@@ -4244,6 +4247,26 @@ void QgisApp::labeling()
activateDeactivateLayerRelatedActions( layer );
}

void QgisApp::fieldCalculator()
{
if ( mMapCanvas && mMapCanvas->isDrawing() )
{
return;
}

QgsVectorLayer *myLayer = qobject_cast<QgsVectorLayer *>( activeLayer() );
if ( !myLayer )
{
return;
}

QgsFieldCalculator calc( myLayer );
if ( calc.exec() )
{
mMapCanvas->refresh();
}
}

void QgisApp::attributeTable()
{
if ( mMapCanvas && mMapCanvas->isDrawing() )
@@ -7828,6 +7851,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
mActionSelectRadius->setEnabled( false );
mActionIdentify->setEnabled( QSettings().value( "/Map/identifyMode", 0 ).toInt() != 0 );
mActionOpenTable->setEnabled( false );
mActionOpenFieldCalc->setEnabled( false );
mActionToggleEditing->setEnabled( false );
mActionToggleEditing->setChecked( false );
mActionSaveLayerEdits->setEnabled( false );
@@ -8057,6 +8081,14 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
}
}

bool canChangeAttributes = dprovider->capabilities() & QgsVectorDataProvider::ChangeAttributeValues;
bool canDeleteFeatures = dprovider->capabilities() & QgsVectorDataProvider::DeleteFeatures;
bool canAddAttributes = dprovider->capabilities() & QgsVectorDataProvider::AddAttributes;
bool canDeleteAttributes = dprovider->capabilities() & QgsVectorDataProvider::DeleteAttributes;
bool canAddFeatures = dprovider->capabilities() & QgsVectorDataProvider::AddFeatures;

mActionOpenFieldCalc->setEnabled(( canChangeAttributes || canAddAttributes ) && vlayer->isEditable() );

return;
}
else
@@ -8066,6 +8098,8 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
mActionRedo->setEnabled( false );
}



mActionLayerSubsetString->setEnabled( false );
}//end vector layer block
/*************Raster layers*************/
@@ -8100,6 +8134,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
mActionSelectRadius->setEnabled( false );
mActionZoomActualSize->setEnabled( true );
mActionOpenTable->setEnabled( false );
mActionOpenFieldCalc->setEnabled( false );
mActionToggleEditing->setEnabled( false );
mActionToggleEditing->setChecked( false );
mActionSaveLayerEdits->setEnabled( false );
@@ -301,6 +301,7 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
/** @note added in 1.9 */
QAction *actionPasteLayerStyle() { return mActionPasteStyle; }
QAction *actionOpenTable() { return mActionOpenTable; }
QAction *actionOpenFieldCalculator() { return mActionOpenFieldCalc; }
QAction *actionToggleEditing() { return mActionToggleEditing; }
/** @note added in 1.9 */
QAction *actionSaveActiveLayerEdits() { return mActionSaveLayerEdits; }
@@ -448,6 +449,8 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
//! show the attribute table for the currently selected layer
void attributeTable();

void fieldCalculator();

//! mark project dirty
void markDirty();

@@ -516,6 +516,7 @@ QAction *QgisAppInterface::actionAddWmsLayer() { return qgis->actionAddWmsLayer(
QAction *QgisAppInterface::actionCopyLayerStyle() { return qgis->actionCopyLayerStyle(); }
QAction *QgisAppInterface::actionPasteLayerStyle() { return qgis->actionPasteLayerStyle(); }
QAction *QgisAppInterface::actionOpenTable() { return qgis->actionOpenTable(); }
QAction *QgisAppInterface::actionOpenFieldCalculator() { return qgis->actionOpenFieldCalculator(); }
QAction *QgisAppInterface::actionToggleEditing() { return qgis->actionToggleEditing(); }
QAction *QgisAppInterface::actionSaveActiveLayerEdits() { return qgis->actionSaveActiveLayerEdits(); }
QAction *QgisAppInterface::actionAllEdits() { return qgis->actionAllEdits(); }
@@ -372,6 +372,7 @@ class QgisAppInterface : public QgisInterface
/** @note added in 1.9 */
virtual QAction *actionPasteLayerStyle();
virtual QAction *actionOpenTable();
virtual QAction *actionOpenFieldCalculator();
virtual QAction *actionToggleEditing();
/** @note added in 1.9 */
virtual QAction *actionSaveActiveLayerEdits();
@@ -476,6 +476,7 @@ class GUI_EXPORT QgisInterface : public QObject
/** @note added in 1.9 */
virtual QAction *actionPasteLayerStyle() = 0;
virtual QAction *actionOpenTable() = 0;
virtual QAction *actionOpenFieldCalculator() = 0;
virtual QAction *actionToggleEditing() = 0;
/** @note added in 1.9 */
virtual QAction *actionSaveActiveLayerEdits() = 0;
@@ -373,6 +373,7 @@
<addaction name="mActionDeselectAll"/>
<addaction name="mActionSelectByExpression"/>
<addaction name="mActionOpenTable"/>
<addaction name="mActionOpenFieldCalc"/>
<addaction name="mActionMapTips"/>
<addaction name="mActionNewBookmark"/>
<addaction name="mActionShowBookmarks"/>
@@ -2074,6 +2075,18 @@ Acts on currently active editable layer</string>
<string>Need Support?</string>
</property>
</action>
<action name="mActionOpenFieldCalc">
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionCalculateField.png</normaloff>:/images/themes/default/mActionCalculateField.png</iconset>
</property>
<property name="text">
<string>Open Field Calculator</string>
</property>
<property name="toolTip">
<string>Open Field Calculator</string>
</property>
</action>
</widget>
<resources>
<include location="../../images/images.qrc"/>

0 comments on commit 1bfa7e9

Please sign in to comment.
You can’t perform that action at this time.