Skip to content

Commit

Permalink
Add skip all option to merge attributes dialog (fix #6958)
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Oct 19, 2015
1 parent 0bda18b commit 23dd501
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/app/qgisapp.cpp
Expand Up @@ -6142,6 +6142,8 @@ void QgisApp::mergeAttributesOfSelectedFeatures()

//merge the attributes together
QgsMergeAttributesDialog d( featureList, vl, mapCanvas() );
//intialise dialog with all columns set to skip
d.setAllToSkip();
if ( d.exec() == QDialog::Rejected )
{
return;
Expand Down
14 changes: 14 additions & 0 deletions src/app/qgsmergeattributesdialog.cpp
Expand Up @@ -53,6 +53,8 @@ QgsMergeAttributesDialog::QgsMergeAttributesDialog( const QgsFeatureList &featur

QSettings settings;
restoreGeometry( settings.value( "/Windows/MergeAttributes/geometry" ).toByteArray() );

connect( mSkipAllButton, SIGNAL( clicked() ), this, SLOT( setAllToSkip() ) );
}

QgsMergeAttributesDialog::QgsMergeAttributesDialog()
Expand Down Expand Up @@ -636,3 +638,15 @@ QSet<int> QgsMergeAttributesDialog::skippedAttributeIndexes() const

return skipped;
}

void QgsMergeAttributesDialog::setAllToSkip()
{
for ( int i = 0; i < mTableWidget->columnCount(); ++i )
{
QComboBox* currentComboBox = qobject_cast<QComboBox *>( mTableWidget->cellWidget( 0, i ) );
if ( currentComboBox )
{
currentComboBox->setCurrentIndex( currentComboBox->findData( "skip" ) );
}
}
}
7 changes: 7 additions & 0 deletions src/app/qgsmergeattributesdialog.h
Expand Up @@ -35,13 +35,20 @@ class APP_EXPORT QgsMergeAttributesDialog: public QDialog, private Ui::QgsMergeA
public:
QgsMergeAttributesDialog( const QgsFeatureList& features, QgsVectorLayer* vl, QgsMapCanvas* canvas, QWidget * parent = 0, Qt::WindowFlags f = 0 );
~QgsMergeAttributesDialog();

QgsAttributes mergedAttributes() const;

/** Returns a list of attribute indexes which should be skipped when merging (eg, attributes
* which have been set to "skip"
*/
QSet<int> skippedAttributeIndexes() const;

public slots:

/** Resets all columns to "skip"
*/
void setAllToSkip();

private slots:
void comboValueChanged( const QString & text );
void selectedRowChanged();
Expand Down
50 changes: 47 additions & 3 deletions src/ui/qgsmergeattributesdialogbase.ui
Expand Up @@ -57,7 +57,7 @@
</item>
</layout>
</item>
<item row="2" column="0">
<item row="3" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="mRemoveFeatureFromSelectionButton">
Expand Down Expand Up @@ -91,7 +91,7 @@
</item>
</layout>
</item>
<item row="3" column="0">
<item row="4" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
Expand All @@ -101,15 +101,59 @@
</property>
</widget>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QPushButton" name="mSkipAllButton">
<property name="toolTip">
<string>Resets all fields to &quot;Skip&quot;</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionSelectPan.png</normaloff>:/images/themes/default/mActionSelectPan.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="mRemoveFeatureFromSelectionLabel_2">
<property name="text">
<string>Skip all fields</string>
</property>
<property name="buddy">
<cstring>mRemoveFeatureFromSelectionButton</cstring>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>98</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<tabstops>
<tabstop>mTableWidget</tabstop>
<tabstop>mFromSelectedPushButton</tabstop>
<tabstop>mSkipAllButton</tabstop>
<tabstop>mRemoveFeatureFromSelectionButton</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources/>
<resources>
<include location="../../images/images.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
Expand Down

0 comments on commit 23dd501

Please sign in to comment.