Skip to content

Commit 4010b60

Browse files
author
jef
committed
implement #2650, #2651, #2652
git-svn-id: http://svn.osgeo.org/qgis/trunk@13311 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 58acc85 commit 4010b60

6 files changed

+19
-18
lines changed

src/app/attributetable/qgsattributetabledialog.cpp

+10-7
Original file line numberDiff line numberDiff line change
@@ -250,16 +250,19 @@ void QgsAttributeTableDialog::on_cbxShowSelectedOnly_toggled( bool theFlag )
250250

251251
void QgsAttributeTableDialog::columnBoxInit()
252252
{
253-
QgsFieldMap fieldMap = mLayer->dataProvider()->fields();
253+
QgsFieldMap fieldMap = mLayer->pendingFields();
254254
QgsFieldMap::Iterator it = fieldMap.begin();
255255

256256
for ( ; it != fieldMap.end(); ++it )
257-
mColumnBox->addItem( it.value().name() );
257+
if ( mLayer->editType( it.key() ) != QgsVectorLayer::Hidden )
258+
mColumnBox->addItem( it.value().name() );
259+
260+
mColumnBox->setCurrentIndex( mColumnBox->findText( mLayer->displayField() ) );
258261
}
259262

260263
int QgsAttributeTableDialog::columnBoxColumnId()
261264
{
262-
QgsFieldMap fieldMap = mLayer->dataProvider()->fields();
265+
QgsFieldMap fieldMap = mLayer->pendingFields();
263266
QgsFieldMap::Iterator it = fieldMap.begin();
264267

265268
for ( ; it != fieldMap.end(); ++it )
@@ -594,8 +597,8 @@ void QgsAttributeTableDialog::search()
594597

595598
QString str = mColumnBox->currentText();
596599

597-
const QgsFieldMap& flds = mLayer->dataProvider()->fields();
598-
int fldIndex = mLayer->dataProvider()->fieldNameIndex( str );
600+
const QgsFieldMap& flds = mLayer->pendingFields();
601+
int fldIndex = mLayer->fieldNameIndex( str );
599602
QVariant::Type fldType = flds[fldIndex].type();
600603
bool numeric = ( fldType == QVariant::Int || fldType == QVariant::Double );
601604

@@ -604,7 +607,7 @@ void QgsAttributeTableDialog::search()
604607
else
605608
str += " ~ '";
606609

607-
str += mQuery->displayText().replace("'", "''"); // escape quotes
610+
str += mQuery->displayText().replace( "'", "''" ); // escape quotes
608611
str += "'";
609612

610613
doSearch( str );
@@ -673,7 +676,7 @@ void QgsAttributeTableDialog::on_mAddAttribute_clicked()
673676
return;
674677
}
675678

676-
QgsAddAttrDialog dialog( mLayer->dataProvider(), this );
679+
QgsAddAttrDialog dialog( mLayer, this );
677680
if ( dialog.exec() == QDialog::Accepted )
678681
{
679682
mLayer->beginEditCommand( tr( "Attribute added" ) );

src/app/qgsaddattrdialog.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,17 @@
1616
***************************************************************************/
1717

1818
#include "qgsaddattrdialog.h"
19+
#include "qgsvectorlayer.h"
1920
#include "qgsvectordataprovider.h"
2021
#include "qgslogger.h"
2122

22-
QgsAddAttrDialog::QgsAddAttrDialog( QgsVectorDataProvider* provider, QWidget *parent, Qt::WFlags fl )
23-
: QDialog( parent, fl ), mDataProvider( provider )
23+
QgsAddAttrDialog::QgsAddAttrDialog( QgsVectorLayer *vlayer, QWidget *parent, Qt::WFlags fl )
24+
: QDialog( parent, fl )
2425
{
2526
setupUi( this );
2627

2728
//fill data types into the combo box
28-
const QList< QgsVectorDataProvider::NativeType > &typelist = mDataProvider->nativeTypes();
29+
const QList< QgsVectorDataProvider::NativeType > &typelist = vlayer->dataProvider()->nativeTypes();
2930

3031
for ( int i = 0; i < typelist.size(); i++ )
3132
{

src/app/qgsaddattrdialog.h

+2-4
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
#include "qgisgui.h"
2323
#include "qgsfield.h"
2424

25-
class QgsVectorDataProvider;
25+
class QgsVectorLayer;
2626

2727
class QgsAddAttrDialog: public QDialog, private Ui::QgsAddAttrDialogBase
2828
{
2929
Q_OBJECT
3030
public:
31-
QgsAddAttrDialog( QgsVectorDataProvider* provider,
31+
QgsAddAttrDialog( QgsVectorLayer *vlayer,
3232
QWidget *parent = 0, Qt::WFlags fl = QgisGui::ModalDialogFlags );
3333
QgsAddAttrDialog( const std::list<QString>& typelist,
3434
QWidget *parent = 0, Qt::WFlags fl = QgisGui::ModalDialogFlags );
@@ -38,8 +38,6 @@ class QgsAddAttrDialog: public QDialog, private Ui::QgsAddAttrDialogBase
3838
public slots:
3939
void on_mTypeBox_currentIndexChanged( int idx );
4040

41-
protected:
42-
QgsVectorDataProvider* mDataProvider;
4341
};
4442

4543
#endif

src/app/qgsidentifyresults.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ void QgsIdentifyResults::featureForm()
822822

823823
QgsAttributeDialog *ad = new QgsAttributeDialog( vlayer, &f );
824824

825-
if ( !vlayer->isEditable() && vlayer->actions()->size() > 0 )
825+
if ( vlayer->actions()->size() > 0 )
826826
{
827827
ad->dialog()->setContextMenuPolicy( Qt::ActionsContextMenu );
828828

@@ -841,7 +841,7 @@ void QgsIdentifyResults::featureForm()
841841
ad->dialog()->addAction( a );
842842
connect( a, SIGNAL( triggered() ), a, SLOT( execute() ) );
843843

844-
QPushButton *pb = ad->dialog()->findChild<QPushButton *>( action.name() );
844+
QAbstractButton *pb = ad->dialog()->findChild<QAbstractButton *>( action.name() );
845845
if ( pb )
846846
connect( pb, SIGNAL( clicked() ), a, SLOT( execute() ) );
847847
}

src/app/qgsvectorlayerproperties.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ void QgsVectorLayerProperties::attributeDeleted( int idx )
315315

316316
void QgsVectorLayerProperties::addAttribute()
317317
{
318-
QgsAddAttrDialog dialog( layer->dataProvider(), this );
318+
QgsAddAttrDialog dialog( layer, this );
319319
if ( dialog.exec() == QDialog::Accepted )
320320
{
321321
layer->beginEditCommand( "Attribute added" );

src/core/qgsvectorlayer.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
***************************************************************************/
2222
/* $Id$ */
2323

24-
#include <cassert>
2524
#include <cfloat>
2625
#include <cstring>
2726
#include <climits>

0 commit comments

Comments
 (0)