[QGIS Commit] r11829 - in trunk/qgis/src: app app/attributetable ui

svn_qgis at osgeo.org svn_qgis at osgeo.org
Thu Oct 22 09:39:02 EDT 2009


Author: wonder
Date: 2009-10-22 09:39:00 -0400 (Thu, 22 Oct 2009)
New Revision: 11829

Modified:
   trunk/qgis/src/app/attributetable/qgsattributetabledialog.cpp
   trunk/qgis/src/app/attributetable/qgsattributetabledialog.h
   trunk/qgis/src/app/qgsfieldcalculator.cpp
   trunk/qgis/src/ui/qgsattributetabledialog.ui
Log:
[UPDATE] Added field calculator also to attribute table to make it easier to discover.


Modified: trunk/qgis/src/app/attributetable/qgsattributetabledialog.cpp
===================================================================
--- trunk/qgis/src/app/attributetable/qgsattributetabledialog.cpp	2009-10-22 12:24:36 UTC (rev 11828)
+++ trunk/qgis/src/app/attributetable/qgsattributetabledialog.cpp	2009-10-22 13:39:00 UTC (rev 11829)
@@ -31,8 +31,8 @@
 #include "qgssearchquerybuilder.h"
 #include "qgslogger.h"
 #include "qgsmapcanvas.h"
+#include "qgsfieldcalculator.h"
 
-
 class QgsAttributeTableDock : public QDockWidget
 {
   public:
@@ -87,9 +87,12 @@
   mZoomMapToSelectedRowsButton->setIcon( getThemeIcon( "/mActionZoomToSelected.png" ) );
   mInvertSelectionButton->setIcon( getThemeIcon( "/mActionInvertSelection.png" ) );
   mToggleEditingButton->setIcon( getThemeIcon( "/mActionToggleEditing.png" ) );
+  mOpenFieldCalculator->setIcon( getThemeIcon( "/mActionCalculateField.png" ) );
   // toggle editing
+  bool canChangeAttributes = mLayer->dataProvider()->capabilities() & QgsVectorDataProvider::ChangeAttributeValues;
   mToggleEditingButton->setCheckable( true );
-  mToggleEditingButton->setEnabled( mLayer->dataProvider()->capabilities() & QgsVectorDataProvider::ChangeAttributeValues );
+  mToggleEditingButton->setEnabled( canChangeAttributes );
+  mOpenFieldCalculator->setEnabled( canChangeAttributes && mLayer->isEditable() );
 
   // info from table to application
   connect( this, SIGNAL( editingToggled( QgsMapLayer * ) ), QgisApp::instance(), SLOT( toggleEditing( QgsMapLayer * ) ) );
@@ -522,6 +525,9 @@
   mToggleEditingButton->setChecked( mLayer->isEditable() );
   mToggleEditingButton->blockSignals( false );
 
+  bool canChangeAttributes = mLayer->dataProvider()->capabilities() & QgsVectorDataProvider::ChangeAttributeValues;
+  mOpenFieldCalculator->setEnabled( canChangeAttributes && mLayer->isEditable() );
+
   // (probably reload data if user stopped editing - possible revert)
   mModel->reload( mModel->index( 0, 0 ), mModel->index( mModel->rowCount(), mModel->columnCount() ) );
 
@@ -548,3 +554,13 @@
   mModel->revert();
   mModel->reload( mModel->index( 0, 0 ), mModel->index( mModel->rowCount(), mModel->columnCount() ) );
 }
+
+void QgsAttributeTableDialog::on_mOpenFieldCalculator_clicked()
+{
+  QgsFieldCalculator calc( mLayer );
+  if ( calc.exec() )
+  {
+    // update model - a field has been added or updated
+    mModel->reload( mModel->index( 0, 0 ), mModel->index( mModel->rowCount(), mModel->columnCount() ) );
+  }
+}

Modified: trunk/qgis/src/app/attributetable/qgsattributetabledialog.h
===================================================================
--- trunk/qgis/src/app/attributetable/qgsattributetabledialog.h	2009-10-22 12:24:36 UTC (rev 11828)
+++ trunk/qgis/src/app/attributetable/qgsattributetabledialog.h	2009-10-22 13:39:00 UTC (rev 11829)
@@ -132,6 +132,10 @@
      * Starts editing mode
      */
     void startEditing();
+    /**
+     * Opens field calculator dialog
+     */
+    void on_mOpenFieldCalculator_clicked();
 
   signals:
     /**

Modified: trunk/qgis/src/app/qgsfieldcalculator.cpp
===================================================================
--- trunk/qgis/src/app/qgsfieldcalculator.cpp	2009-10-22 12:24:36 UTC (rev 11828)
+++ trunk/qgis/src/app/qgsfieldcalculator.cpp	2009-10-22 13:39:00 UTC (rev 11829)
@@ -130,6 +130,8 @@
     bool onlySelected = ( mOnlyUpdateSelectedCheckBox->checkState() == Qt::Checked );
     QgsFeatureIds selectedIds = mVectorLayer->selectedFeaturesIds();
 
+    // block layerModified signals (that would trigger table update)
+    mVectorLayer->blockSignals( true );
 
     mVectorLayer->select( mVectorLayer->pendingAllAttributesList(), QgsRectangle(), false, false );
     while ( mVectorLayer->nextFeature( feature ) )
@@ -157,6 +159,10 @@
         mVectorLayer->changeAttributeValue( feature.id(), attributeId, value.string(), false );
       }
 
+      // stop blocking layerModified signals and make sure that one layerModified signal is emitted
+      mVectorLayer->blockSignals( true );
+      mVectorLayer->setModified( true, false );
+
     }
 
     if ( !calculationSuccess )

Modified: trunk/qgis/src/ui/qgsattributetabledialog.ui
===================================================================
--- trunk/qgis/src/ui/qgsattributetabledialog.ui	2009-10-22 12:24:36 UTC (rev 11828)
+++ trunk/qgis/src/ui/qgsattributetabledialog.ui	2009-10-22 13:39:00 UTC (rev 11829)
@@ -1,7 +1,8 @@
-<ui version="4.0" >
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
  <class>QgsAttributeTableDialog</class>
- <widget class="QDialog" name="QgsAttributeTableDialog" >
-  <property name="geometry" >
+ <widget class="QDialog" name="QgsAttributeTableDialog">
+  <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
@@ -9,229 +10,246 @@
     <height>570</height>
    </rect>
   </property>
-  <property name="windowTitle" >
+  <property name="windowTitle">
    <string>Attribute Table</string>
   </property>
-  <layout class="QGridLayout" >
-   <property name="leftMargin" >
-    <number>0</number>
+  <layout class="QGridLayout">
+   <property name="horizontalSpacing">
+    <number>2</number>
    </property>
-   <property name="topMargin" >
+   <property name="verticalSpacing">
     <number>0</number>
    </property>
-   <property name="rightMargin" >
+   <property name="margin">
     <number>0</number>
    </property>
-   <property name="bottomMargin" >
-    <number>0</number>
-   </property>
-   <property name="horizontalSpacing" >
-    <number>2</number>
-   </property>
-   <property name="verticalSpacing" >
-    <number>0</number>
-   </property>
-   <item row="0" column="0" >
-    <widget class="QgsAttributeTableView" name="mView" >
-     <property name="alternatingRowColors" >
+   <item row="0" column="0">
+    <widget class="QgsAttributeTableView" name="mView">
+     <property name="alternatingRowColors">
       <bool>true</bool>
      </property>
     </widget>
    </item>
-   <item row="1" column="0" >
-    <layout class="QHBoxLayout" >
+   <item row="1" column="0">
+    <layout class="QHBoxLayout">
      <item>
-      <widget class="QToolButton" name="mRemoveSelectionButton" >
-       <property name="toolTip" >
+      <widget class="QToolButton" name="mRemoveSelectionButton">
+       <property name="toolTip">
         <string>Unselect all</string>
        </property>
-       <property name="text" >
+       <property name="text">
         <string/>
        </property>
-       <property name="icon" >
-        <iconset>../../images/themes/default/mActionUnselectAttributes.png</iconset>
+       <property name="icon">
+        <iconset>
+         <normaloff>../../images/themes/default/mActionUnselectAttributes.png</normaloff>../../images/themes/default/mActionUnselectAttributes.png</iconset>
        </property>
-       <property name="iconSize" >
+       <property name="iconSize">
         <size>
          <width>18</width>
          <height>18</height>
         </size>
        </property>
-       <property name="shortcut" >
+       <property name="shortcut">
         <string/>
        </property>
       </widget>
      </item>
      <item>
-      <widget class="QToolButton" name="mSelectedToTopButton" >
-       <property name="toolTip" >
+      <widget class="QToolButton" name="mSelectedToTopButton">
+       <property name="toolTip">
         <string>Move selection to top</string>
        </property>
-       <property name="text" >
+       <property name="text">
         <string/>
        </property>
-       <property name="icon" >
-        <iconset>../../images/themes/default/mActionSelectedToTop.png</iconset>
+       <property name="icon">
+        <iconset>
+         <normaloff>../../images/themes/default/mActionSelectedToTop.png</normaloff>../../images/themes/default/mActionSelectedToTop.png</iconset>
        </property>
-       <property name="iconSize" >
+       <property name="iconSize">
         <size>
          <width>18</width>
          <height>18</height>
         </size>
        </property>
-       <property name="shortcut" >
+       <property name="shortcut">
         <string>Ctrl+T</string>
        </property>
       </widget>
      </item>
      <item>
-      <widget class="QToolButton" name="mInvertSelectionButton" >
-       <property name="toolTip" >
+      <widget class="QToolButton" name="mInvertSelectionButton">
+       <property name="toolTip">
         <string>Invert selection</string>
        </property>
-       <property name="text" >
+       <property name="text">
         <string/>
        </property>
-       <property name="icon" >
-        <iconset>../../images/themes/default/mActionInvertSelection.png</iconset>
+       <property name="icon">
+        <iconset>
+         <normaloff>../../images/themes/default/mActionInvertSelection.png</normaloff>../../images/themes/default/mActionInvertSelection.png</iconset>
        </property>
-       <property name="iconSize" >
+       <property name="iconSize">
         <size>
          <width>18</width>
          <height>18</height>
         </size>
        </property>
-       <property name="shortcut" >
+       <property name="shortcut">
         <string>Ctrl+S</string>
        </property>
       </widget>
      </item>
      <item>
-      <widget class="QToolButton" name="mCopySelectedRowsButton" >
-       <property name="toolTip" >
+      <widget class="QToolButton" name="mCopySelectedRowsButton">
+       <property name="toolTip">
         <string>Copy selected rows to clipboard (Ctrl+C)</string>
        </property>
-       <property name="whatsThis" >
+       <property name="whatsThis">
         <string>Copies the selected rows to the clipboard</string>
        </property>
-       <property name="text" >
+       <property name="text">
         <string/>
        </property>
-       <property name="icon" >
-        <iconset>../../images/themes/default/mActionEditCopy.png</iconset>
+       <property name="icon">
+        <iconset>
+         <normaloff>../../images/themes/default/mActionEditCopy.png</normaloff>../../images/themes/default/mActionEditCopy.png</iconset>
        </property>
-       <property name="iconSize" >
+       <property name="iconSize">
         <size>
          <width>18</width>
          <height>18</height>
         </size>
        </property>
-       <property name="shortcut" >
+       <property name="shortcut">
         <string>Ctrl+C</string>
        </property>
       </widget>
      </item>
      <item>
-      <widget class="QToolButton" name="mZoomMapToSelectedRowsButton" >
-       <property name="toolTip" >
+      <widget class="QToolButton" name="mZoomMapToSelectedRowsButton">
+       <property name="toolTip">
         <string>Zoom map to the selected rows (Ctrl-J)</string>
        </property>
-       <property name="whatsThis" >
+       <property name="whatsThis">
         <string>Zoom map to the selected rows</string>
        </property>
-       <property name="text" >
+       <property name="text">
         <string/>
        </property>
-       <property name="icon" >
-        <iconset>../../images/themes/default/mActionZoomToSelected.png</iconset>
+       <property name="icon">
+        <iconset>
+         <normaloff>../../images/themes/default/mActionZoomToSelected.png</normaloff>../../images/themes/default/mActionZoomToSelected.png</iconset>
        </property>
-       <property name="iconSize" >
+       <property name="iconSize">
         <size>
          <width>18</width>
          <height>18</height>
         </size>
        </property>
-       <property name="shortcut" >
+       <property name="shortcut">
         <string>Ctrl+J</string>
        </property>
       </widget>
      </item>
      <item>
-      <widget class="QToolButton" name="mToggleEditingButton" >
-       <property name="toolTip" >
+      <widget class="QToolButton" name="mToggleEditingButton">
+       <property name="toolTip">
         <string>Toggle editing mode</string>
        </property>
-       <property name="whatsThis" >
+       <property name="whatsThis">
         <string>Click to toggle table editing</string>
        </property>
-       <property name="text" >
+       <property name="text">
         <string/>
        </property>
-       <property name="icon" >
-        <iconset>../../images/themes/default/mActionToggleEditing.png</iconset>
+       <property name="icon">
+        <iconset>
+         <normaloff>../../images/themes/default/mActionToggleEditing.png</normaloff>../../images/themes/default/mActionToggleEditing.png</iconset>
        </property>
-       <property name="iconSize" >
+       <property name="iconSize">
         <size>
          <width>18</width>
          <height>18</height>
         </size>
        </property>
-       <property name="checkable" >
+       <property name="checkable">
         <bool>true</bool>
        </property>
       </widget>
      </item>
      <item>
-      <widget class="QLabel" name="searchFor" >
-       <property name="text" >
+      <widget class="QToolButton" name="mOpenFieldCalculator">
+       <property name="toolTip">
+        <string>Open field calculator</string>
+       </property>
+       <property name="text">
+        <string/>
+       </property>
+       <property name="icon">
+        <iconset>
+         <normaloff>../../images/themes/default/mActionCalculateField.png</normaloff>../../images/themes/default/mActionCalculateField.png</iconset>
+       </property>
+       <property name="iconSize">
+        <size>
+         <width>18</width>
+         <height>18</height>
+        </size>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QLabel" name="searchFor">
+       <property name="text">
         <string>Look for</string>
        </property>
       </widget>
      </item>
      <item>
-      <widget class="QLineEdit" name="query" />
+      <widget class="QLineEdit" name="query"/>
      </item>
      <item>
-      <widget class="QLabel" name="searchIn" >
-       <property name="text" >
+      <widget class="QLabel" name="searchIn">
+       <property name="text">
         <string>in</string>
        </property>
       </widget>
      </item>
      <item>
-      <widget class="QComboBox" name="columnBox" />
+      <widget class="QComboBox" name="columnBox"/>
      </item>
      <item>
-      <widget class="QPushButton" name="searchButton" >
-       <property name="text" >
+      <widget class="QPushButton" name="searchButton">
+       <property name="text">
         <string>&amp;Search</string>
        </property>
       </widget>
      </item>
     </layout>
    </item>
-   <item row="2" column="0" >
-    <layout class="QHBoxLayout" >
+   <item row="2" column="0">
+    <layout class="QHBoxLayout">
      <item>
-      <widget class="QCheckBox" name="cbxShowSelectedOnly" >
-       <property name="text" >
+      <widget class="QCheckBox" name="cbxShowSelectedOnly">
+       <property name="text">
         <string>Show selected records only</string>
        </property>
       </widget>
      </item>
      <item>
-      <widget class="QCheckBox" name="cbxSearchSelectedOnly" >
-       <property name="text" >
+      <widget class="QCheckBox" name="cbxSearchSelectedOnly">
+       <property name="text">
         <string>Search selected records only</string>
        </property>
       </widget>
      </item>
      <item>
       <spacer>
-       <property name="orientation" >
+       <property name="orientation">
         <enum>Qt::Horizontal</enum>
        </property>
-       <property name="sizeHint" >
+       <property name="sizeHint" stdset="0">
         <size>
          <width>40</width>
          <height>20</height>
@@ -240,18 +258,18 @@
       </spacer>
      </item>
      <item>
-      <widget class="QLabel" name="label" >
-       <property name="text" >
+      <widget class="QLabel" name="label">
+       <property name="text">
         <string>Advanced search</string>
        </property>
       </widget>
      </item>
      <item>
-      <widget class="QToolButton" name="mAdvancedSearchButton" >
-       <property name="text" >
+      <widget class="QToolButton" name="mAdvancedSearchButton">
+       <property name="text">
         <string>...</string>
        </property>
-       <property name="iconSize" >
+       <property name="iconSize">
         <size>
          <width>12</width>
          <height>12</height>



More information about the QGIS-commit mailing list