Skip to content

Commit

Permalink
fix #6803
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Dec 1, 2012
1 parent 32ca040 commit 4571b1d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
21 changes: 9 additions & 12 deletions src/app/qgsfieldsproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ) );
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -474,7 +469,7 @@ void QgsFieldsProperties::on_mMoveUpItem_clicked()
}
}

void QgsFieldsProperties::attributeTypeDialog( )
void QgsFieldsProperties::attributeTypeDialog()
{
QPushButton *pb = qobject_cast<QPushButton *>( sender() );
if ( !pb )
Expand Down Expand Up @@ -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 ) );
Expand All @@ -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
{
Expand Down
8 changes: 3 additions & 5 deletions src/app/qgsfieldsproperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand All @@ -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();

Expand Down
5 changes: 4 additions & 1 deletion src/app/qgsvectorlayerproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
Expand Down

0 comments on commit 4571b1d

Please sign in to comment.