Skip to content
Permalink
Browse files

implement #2650, #2651, #2652

git-svn-id: http://svn.osgeo.org/qgis/trunk@13311 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed Apr 14, 2010
1 parent 58acc85 commit 4010b60ce3d80e08bf67a6e0d1ffab96625e05f8
@@ -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 )
@@ -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 );

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

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

doSearch( str );
@@ -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" ) );
@@ -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++ )
{
@@ -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 );
@@ -38,8 +38,6 @@ class QgsAddAttrDialog: public QDialog, private Ui::QgsAddAttrDialogBase
public slots:
void on_mTypeBox_currentIndexChanged( int idx );

protected:
QgsVectorDataProvider* mDataProvider;
};

#endif
@@ -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 );

@@ -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() ) );
}
@@ -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" );
@@ -21,7 +21,6 @@
***************************************************************************/
/* $Id$ */

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

0 comments on commit 4010b60

Please sign in to comment.
You can’t perform that action at this time.