From bd9f43f16ac5b5dbcf5090fdec1587abfad5c396 Mon Sep 17 00:00:00 2001 From: jef Date: Wed, 12 Mar 2008 20:43:20 +0000 Subject: [PATCH] allow changing attributes of added and not yet commited features git-svn-id: http://svn.osgeo.org/qgis/trunk@8211 c8812cc2-4d05-0410-92ff-de0c093fc19c --- src/app/qgsattributetable.cpp | 21 ++++++++++++++------- src/app/qgsattributetable.h | 18 ++++++++++-------- src/app/qgsattributetabledisplay.h | 4 ++++ 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/src/app/qgsattributetable.cpp b/src/app/qgsattributetable.cpp index 3d20de369cc2..693bdbe9fd70 100644 --- a/src/app/qgsattributetable.cpp +++ b/src/app/qgsattributetable.cpp @@ -32,7 +32,6 @@ #include "qgsvectordataprovider.h" #include "qgsvectorlayer.h" -#include #include QgsAttributeTable::QgsAttributeTable(QWidget * parent, const char *name): @@ -586,14 +585,22 @@ void QgsAttributeTable::storeChangedValue(int row, int column) int id=text(row,0).toInt(); QString field = horizontalHeader()->label(column); - // add empty map for feature if doesn't exist - if (!mChangedValues.contains(id)) + if(id>=0) { - mChangedValues.insert(id, QMap()); - } + // add empty map for feature if doesn't exist + if (!mChangedValues.contains(id)) + { + mChangedValues.insert(id, QMap()); + } - mChangedValues[id].insert(field, text(row,column)); - mEdited=true; + mChangedValues[id].insert(field, text(row,column)); + mEdited=true; + } + else + { + // added feature attribute changed + emit featureAttributeChanged(row,column); + } } } diff --git a/src/app/qgsattributetable.h b/src/app/qgsattributetable.h index 649e10ad49c0..9f4d0d6aa11c 100644 --- a/src/app/qgsattributetable.h +++ b/src/app/qgsattributetable.h @@ -104,15 +104,16 @@ class QgsAttributeTable:public Q3Table /** Shows all rows */ void showAllRows(); - public slots: - void columnClicked(int col); - void rowClicked(int row); + public slots: + void columnClicked(int col); + void rowClicked(int row); // Called when the user requests a popup menu void popupMenu(int row, int col, const QPoint& pos); // Called when the user chooses an item on the popup menu void popupItemSelected(QAction * menuAction); - protected slots: - void handleChangedSelections(); + + protected slots: + void handleChangedSelections(); /**Writes changed values to 'mChangedValues'*/ void storeChangedValue(int row, int column); @@ -156,14 +157,15 @@ class QgsAttributeTable:public Q3Table Also, mLastSelectedRows is updated*/ bool checkSelectionChanges(); -signals: - + signals: /**Is emitted when a row was selected*/ void selected(int, bool); /**Is emitted when all rows have been deselected*/ void selectionRemoved(bool); - /**Is emmited when a set of related selection and deselection signals have been emitted*/ + /**Is emitted when a set of related selection and deselection signals have been emitted*/ void repaintRequested(); + /**Is emitted when a attribute of a added feature is changed*/ + void featureAttributeChanged(int row, int column); private: // Data to do with providing a popup menu of actions that diff --git a/src/app/qgsattributetabledisplay.h b/src/app/qgsattributetabledisplay.h index 9269c3ce57ef..d4666e6f4f33 100644 --- a/src/app/qgsattributetabledisplay.h +++ b/src/app/qgsattributetabledisplay.h @@ -73,8 +73,12 @@ class QgsAttributeTableDisplay:public QDialog, private Ui::QgsAttributeTableBase void searchShowResultsChanged(int item); void on_btnHelp_clicked(); + public slots: + void changeFeatureAttribute(int row, int column); + signals: void deleted(); + private: /** Set the icon theme for this dialog */ void setTheme();