Skip to content

Commit 863d256

Browse files
author
jef
committed
allow changing attributes of added and not yet commited features
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@8211 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 168d651 commit 863d256

File tree

3 files changed

+28
-15
lines changed

3 files changed

+28
-15
lines changed

src/app/qgsattributetable.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
#include "qgsvectordataprovider.h"
3333
#include "qgsvectorlayer.h"
3434

35-
#include <iostream>
3635
#include <stdlib.h>
3736

3837
QgsAttributeTable::QgsAttributeTable(QWidget * parent, const char *name):
@@ -586,14 +585,22 @@ void QgsAttributeTable::storeChangedValue(int row, int column)
586585
int id=text(row,0).toInt();
587586
QString field = horizontalHeader()->label(column);
588587

589-
// add empty map for feature if doesn't exist
590-
if (!mChangedValues.contains(id))
588+
if(id>=0)
591589
{
592-
mChangedValues.insert(id, QMap<QString, QString>());
593-
}
590+
// add empty map for feature if doesn't exist
591+
if (!mChangedValues.contains(id))
592+
{
593+
mChangedValues.insert(id, QMap<QString, QString>());
594+
}
594595

595-
mChangedValues[id].insert(field, text(row,column));
596-
mEdited=true;
596+
mChangedValues[id].insert(field, text(row,column));
597+
mEdited=true;
598+
}
599+
else
600+
{
601+
// added feature attribute changed
602+
emit featureAttributeChanged(row,column);
603+
}
597604
}
598605
}
599606

src/app/qgsattributetable.h

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,16 @@ class QgsAttributeTable:public Q3Table
104104
/** Shows all rows */
105105
void showAllRows();
106106

107-
public slots:
108-
void columnClicked(int col);
109-
void rowClicked(int row);
107+
public slots:
108+
void columnClicked(int col);
109+
void rowClicked(int row);
110110
// Called when the user requests a popup menu
111111
void popupMenu(int row, int col, const QPoint& pos);
112112
// Called when the user chooses an item on the popup menu
113113
void popupItemSelected(QAction * menuAction);
114-
protected slots:
115-
void handleChangedSelections();
114+
115+
protected slots:
116+
void handleChangedSelections();
116117
/**Writes changed values to 'mChangedValues'*/
117118
void storeChangedValue(int row, int column);
118119

@@ -156,14 +157,15 @@ class QgsAttributeTable:public Q3Table
156157
Also, mLastSelectedRows is updated*/
157158
bool checkSelectionChanges();
158159

159-
signals:
160-
160+
signals:
161161
/**Is emitted when a row was selected*/
162162
void selected(int, bool);
163163
/**Is emitted when all rows have been deselected*/
164164
void selectionRemoved(bool);
165-
/**Is emmited when a set of related selection and deselection signals have been emitted*/
165+
/**Is emitted when a set of related selection and deselection signals have been emitted*/
166166
void repaintRequested();
167+
/**Is emitted when a attribute of a added feature is changed*/
168+
void featureAttributeChanged(int row, int column);
167169

168170
private:
169171
// Data to do with providing a popup menu of actions that

src/app/qgsattributetabledisplay.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,12 @@ class QgsAttributeTableDisplay:public QDialog, private Ui::QgsAttributeTableBase
7373
void searchShowResultsChanged(int item);
7474
void on_btnHelp_clicked();
7575

76+
public slots:
77+
void changeFeatureAttribute(int row, int column);
78+
7679
signals:
7780
void deleted();
81+
7882
private:
7983
/** Set the icon theme for this dialog */
8084
void setTheme();

0 commit comments

Comments
 (0)