Skip to content
Permalink
Browse files
fix #6803
  • Loading branch information
jef-n committed Dec 1, 2012
1 parent 32ca040 commit 4571b1d393c5d967f7355a18f48ea3cf7cc23405
Showing with 16 additions and 18 deletions.
  1. +9 −12 src/app/qgsfieldsproperties.cpp
  2. +3 −5 src/app/qgsfieldsproperties.h
  3. +4 −1 src/app/qgsvectorlayerproperties.cpp
@@ -193,7 +193,7 @@ QgsFieldsProperties::QgsFieldsProperties( QgsVectorLayer *layer, QWidget* parent
mToggleEditingButton->setIcon( QgsApplication::getThemeIcon( "/mActionToggleEditing.png" ) );
mCalculateFieldButton->setIcon( QgsApplication::getThemeIcon( "/mActionCalculateField.png" ) );

connect( mToggleEditingButton, SIGNAL( clicked() ), this, SLOT( toggleEditing() ) );
connect( mToggleEditingButton, SIGNAL( clicked() ), this, SIGNAL( toggleEditing() ) );
connect( mLayer, SIGNAL( editingStarted() ), this, SLOT( editingToggled() ) );
connect( mLayer, SIGNAL( editingStopped() ), this, SLOT( editingToggled() ) );
connect( mLayer, SIGNAL( attributeAdded( int ) ), this, SLOT( attributeAdded( int ) ) );
@@ -242,11 +242,6 @@ void QgsFieldsProperties::onAttributeSelectionChanged()
mAddItemButton->setEnabled( isAddPossible );
}

void QgsFieldsProperties::toggleEditing()
{
emit toggleEditing( mLayer );
}

QTreeWidgetItem *QgsFieldsProperties::loadAttributeEditorTreeItem( QgsAttributeEditorElement* const widgetDef, QTreeWidgetItem* parent )
{
QTreeWidgetItem* newWidget = 0;
@@ -303,7 +298,7 @@ void QgsFieldsProperties::loadAttributeEditorTree()

void QgsFieldsProperties::loadRows()
{
disconnect( mAttributesList, SIGNAL( cellChanged( int, int ) ), this, SLOT( on_mAttributesList_cellChanged( int, int ) ) );
disconnect( mAttributesList, SIGNAL( cellChanged( int, int ) ), this, SLOT( attributesListCellChanged( int, int ) ) );
const QgsFieldMap &fields = mLayer->pendingFields();

mAttributesList->clear();
@@ -334,7 +329,7 @@ void QgsFieldsProperties::loadRows()
setRow( row, it.key(), it.value() );

mAttributesList->resizeColumnsToContents();
connect( mAttributesList, SIGNAL( cellChanged( int, int ) ), this, SLOT( on_mAttributesList_cellChanged( int, int ) ) );
connect( mAttributesList, SIGNAL( cellChanged( int, int ) ), this, SLOT( attributesListCellChanged( int, int ) ) );
}

void QgsFieldsProperties::setRow( int row, int idx, const QgsField &field )
@@ -474,7 +469,7 @@ void QgsFieldsProperties::on_mMoveUpItem_clicked()
}
}

void QgsFieldsProperties::attributeTypeDialog( )
void QgsFieldsProperties::attributeTypeDialog()
{
QPushButton *pb = qobject_cast<QPushButton *>( sender() );
if ( !pb )
@@ -657,9 +652,12 @@ void QgsFieldsProperties::on_mDeleteAttributeButton_clicked()

void QgsFieldsProperties::updateButtons()
{
int cap = mLayer->dataProvider()->capabilities();

mToggleEditingButton->setEnabled(( cap & QgsVectorDataProvider::ChangeAttributeValues ) && !mLayer->isReadOnly() );

if ( mLayer->isEditable() )
{
int cap = mLayer->dataProvider()->capabilities();
mAddAttributeButton->setEnabled( cap & QgsVectorDataProvider::AddAttributes );
mDeleteAttributeButton->setEnabled( cap & QgsVectorDataProvider::DeleteAttributes );
mCalculateFieldButton->setEnabled( cap & ( QgsVectorDataProvider::ChangeAttributeValues | QgsVectorDataProvider::AddAttributes ) );
@@ -670,13 +668,12 @@ void QgsFieldsProperties::updateButtons()
mAddAttributeButton->setEnabled( false );
mDeleteAttributeButton->setEnabled( false );
mToggleEditingButton->setChecked( false );
mToggleEditingButton->setEnabled( false );
mCalculateFieldButton->setEnabled( false );
}
}


void QgsFieldsProperties::on_mAttributesList_cellChanged( int row, int column )
void QgsFieldsProperties::attributesListCellChanged( int row, int column )
{
if ( column == attrAliasCol && mLayer ) //only consider attribute aliases in this function
{
@@ -90,14 +90,13 @@ class QgsFieldsProperties : public QWidget, private Ui_QgsFieldsPropertiesBase
QTreeWidgetItem *loadAttributeEditorTreeItem( QgsAttributeEditorElement* const widgetDef, QTreeWidgetItem* parent );

signals:
void toggleEditing( QgsMapLayer * );
void toggleEditing();

public slots:
void on_mAddAttributeButton_clicked();
void on_mDeleteAttributeButton_clicked();
void on_mCalculateFieldButton_clicked();
void onAttributeSelectionChanged();
void on_mAttributesList_cellChanged( int row, int column );
void on_pbnSelectEditForm_clicked();
void on_mEditorLayoutComboBox_currentIndexChanged( int index );

@@ -113,10 +112,9 @@ class QgsFieldsProperties : public QWidget, private Ui_QgsFieldsPropertiesBase
void on_mMoveDownItem_clicked();
void on_mMoveUpItem_clicked();

protected slots:
/** toggle editing of layer */
void toggleEditing();
void attributesListCellChanged( int row, int column );

protected slots:
/** editing of layer was toggled */
void editingToggled();

@@ -137,12 +137,15 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
mFieldsFrame->setLayout( new QVBoxLayout( mFieldsFrame ) );
mFieldsFrame->layout()->addWidget( mFieldsPropertiesDialog );

connect( mFieldsPropertiesDialog, SIGNAL( toggleEditing() ), this, SLOT( toggleEditing() ) );
connect( this, SIGNAL( toggleEditing( QgsMapLayer* ) ), QgisApp::instance(), SLOT( toggleEditing( QgsMapLayer* ) ) );

reset();

if ( layer->dataProvider() )//enable spatial index button group if supported by provider
{
int capabilities = layer->dataProvider()->capabilities();
if ( !( capabilities&QgsVectorDataProvider::CreateSpatialIndex ) )
if ( !( capabilities & QgsVectorDataProvider::CreateSpatialIndex ) )
{
pbnIndex->setEnabled( false );
}

0 comments on commit 4571b1d

Please sign in to comment.