Skip to content

Commit

Permalink
implement #2650, #2651, #2652
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13311 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Apr 14, 2010
1 parent ab23779 commit 5a264a2
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 18 deletions.
17 changes: 10 additions & 7 deletions src/app/attributetable/qgsattributetabledialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,16 +250,19 @@ void QgsAttributeTableDialog::on_cbxShowSelectedOnly_toggled( bool theFlag )

void QgsAttributeTableDialog::columnBoxInit()
{
QgsFieldMap fieldMap = mLayer->dataProvider()->fields();
QgsFieldMap fieldMap = mLayer->pendingFields();
QgsFieldMap::Iterator it = fieldMap.begin();

for ( ; it != fieldMap.end(); ++it )
mColumnBox->addItem( it.value().name() );
if ( mLayer->editType( it.key() ) != QgsVectorLayer::Hidden )
mColumnBox->addItem( it.value().name() );

mColumnBox->setCurrentIndex( mColumnBox->findText( mLayer->displayField() ) );
}

int QgsAttributeTableDialog::columnBoxColumnId()
{
QgsFieldMap fieldMap = mLayer->dataProvider()->fields();
QgsFieldMap fieldMap = mLayer->pendingFields();
QgsFieldMap::Iterator it = fieldMap.begin();

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

QString str = mColumnBox->currentText();

const QgsFieldMap& flds = mLayer->dataProvider()->fields();
int fldIndex = mLayer->dataProvider()->fieldNameIndex( str );
const QgsFieldMap& flds = mLayer->pendingFields();
int fldIndex = mLayer->fieldNameIndex( str );
QVariant::Type fldType = flds[fldIndex].type();
bool numeric = ( fldType == QVariant::Int || fldType == QVariant::Double );

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

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

doSearch( str );
Expand Down Expand Up @@ -673,7 +676,7 @@ void QgsAttributeTableDialog::on_mAddAttribute_clicked()
return;
}

QgsAddAttrDialog dialog( mLayer->dataProvider(), this );
QgsAddAttrDialog dialog( mLayer, this );
if ( dialog.exec() == QDialog::Accepted )
{
mLayer->beginEditCommand( tr( "Attribute added" ) );
Expand Down
7 changes: 4 additions & 3 deletions src/app/qgsaddattrdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@
***************************************************************************/

#include "qgsaddattrdialog.h"
#include "qgsvectorlayer.h"
#include "qgsvectordataprovider.h"
#include "qgslogger.h"

QgsAddAttrDialog::QgsAddAttrDialog( QgsVectorDataProvider* provider, QWidget *parent, Qt::WFlags fl )
: QDialog( parent, fl ), mDataProvider( provider )
QgsAddAttrDialog::QgsAddAttrDialog( QgsVectorLayer *vlayer, QWidget *parent, Qt::WFlags fl )
: QDialog( parent, fl )
{
setupUi( this );

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

for ( int i = 0; i < typelist.size(); i++ )
{
Expand Down
6 changes: 2 additions & 4 deletions src/app/qgsaddattrdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
#include "qgisgui.h"
#include "qgsfield.h"

class QgsVectorDataProvider;
class QgsVectorLayer;

class QgsAddAttrDialog: public QDialog, private Ui::QgsAddAttrDialogBase
{
Q_OBJECT
public:
QgsAddAttrDialog( QgsVectorDataProvider* provider,
QgsAddAttrDialog( QgsVectorLayer *vlayer,
QWidget *parent = 0, Qt::WFlags fl = QgisGui::ModalDialogFlags );
QgsAddAttrDialog( const std::list<QString>& typelist,
QWidget *parent = 0, Qt::WFlags fl = QgisGui::ModalDialogFlags );
Expand All @@ -38,8 +38,6 @@ class QgsAddAttrDialog: public QDialog, private Ui::QgsAddAttrDialogBase
public slots:
void on_mTypeBox_currentIndexChanged( int idx );

protected:
QgsVectorDataProvider* mDataProvider;
};

#endif
4 changes: 2 additions & 2 deletions src/app/qgsidentifyresults.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ void QgsIdentifyResults::featureForm()

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

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

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

QPushButton *pb = ad->dialog()->findChild<QPushButton *>( action.name() );
QAbstractButton *pb = ad->dialog()->findChild<QAbstractButton *>( action.name() );
if ( pb )
connect( pb, SIGNAL( clicked() ), a, SLOT( execute() ) );
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsvectorlayerproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ void QgsVectorLayerProperties::attributeDeleted( int idx )

void QgsVectorLayerProperties::addAttribute()
{
QgsAddAttrDialog dialog( layer->dataProvider(), this );
QgsAddAttrDialog dialog( layer, this );
if ( dialog.exec() == QDialog::Accepted )
{
layer->beginEditCommand( "Attribute added" );
Expand Down
1 change: 0 additions & 1 deletion src/core/qgsvectorlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
***************************************************************************/
/* $Id$ */

#include <cassert>
#include <cfloat>
#include <cstring>
#include <climits>
Expand Down

0 comments on commit 5a264a2

Please sign in to comment.