Skip to content

Commit

Permalink
Merge pull request #33918 from alexbruy/organize-columns
Browse files Browse the repository at this point in the history
add "Organize Columns" button to the attribute table toolbar (fix #23397)
  • Loading branch information
rouault committed Mar 11, 2020
2 parents 912ffde + a64808b commit 399dc62
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/app/qgsattributetabledialog.cpp
Expand Up @@ -54,6 +54,7 @@
#include "qgsguiutils.h"
#include "qgsproxyprogresstask.h"
#include "qgisapp.h"
#include "qgsorganizetablecolumnsdialog.h"

QgsExpressionContext QgsAttributeTableDialog::createExpressionContext() const
{
Expand Down Expand Up @@ -105,6 +106,7 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *layer, QgsAttr
connect( mActionSelectedToTop, &QAction::toggled, this, &QgsAttributeTableDialog::mActionSelectedToTop_toggled );
connect( mActionAddAttribute, &QAction::triggered, this, &QgsAttributeTableDialog::mActionAddAttribute_triggered );
connect( mActionRemoveAttribute, &QAction::triggered, this, &QgsAttributeTableDialog::mActionRemoveAttribute_triggered );
connect( mActionOrganizeColumns, &QAction::triggered, this, &QgsAttributeTableDialog::mActionOrganizeColumns_triggered );
connect( mActionOpenFieldCalculator, &QAction::triggered, this, &QgsAttributeTableDialog::mActionOpenFieldCalculator_triggered );
connect( mActionDeleteSelected, &QAction::triggered, this, &QgsAttributeTableDialog::mActionDeleteSelected_triggered );
connect( mMainView, &QgsDualView::currentChanged, this, &QgsAttributeTableDialog::mMainView_currentChanged );
Expand Down Expand Up @@ -835,6 +837,20 @@ void QgsAttributeTableDialog::mActionRemoveAttribute_triggered()
}
}

void QgsAttributeTableDialog::mActionOrganizeColumns_triggered()
{
if ( !mLayer )
{
return;
}

QgsOrganizeTableColumnsDialog dlg( mLayer, mLayer->attributeTableConfig(), this );
if ( dlg.exec() == QDialog::Accepted )
{
QgsAttributeTableConfig config = dlg.config();
mMainView->setAttributeTableConfig( config );
}
}

void QgsAttributeTableDialog::openConditionalStyles()
{
Expand Down
5 changes: 5 additions & 0 deletions src/app/qgsattributetabledialog.h
Expand Up @@ -153,6 +153,11 @@ class APP_EXPORT QgsAttributeTableDialog : public QDialog, private Ui::QgsAttrib
*/
void mActionDeleteSelected_triggered();

/**
* Opens organize columns dialog
*/
void mActionOrganizeColumns_triggered();

/**
* Called when the current index changes in the main view
* i.e. when the view mode is switched from table to form view
Expand Down
12 changes: 11 additions & 1 deletion src/ui/qgsattributetabledialog.ui
Expand Up @@ -71,7 +71,7 @@
</widget>
</item>
<item>
<widget class="QgsFieldExpressionWidget" name="mUpdateExpressionText">
<widget class="QgsFieldExpressionWidget" name="mUpdateExpressionText" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
Expand Down Expand Up @@ -208,6 +208,7 @@
<addaction name="separator"/>
<addaction name="mActionAddAttribute"/>
<addaction name="mActionRemoveAttribute"/>
<addaction name="mActionOrganizeColumns"/>
<addaction name="mActionOpenFieldCalculator"/>
<addaction name="separator"/>
<addaction name="mActionSetStyles"/>
Expand Down Expand Up @@ -534,6 +535,15 @@
<string>Dock Attribute Table</string>
</property>
</action>
<action name="mActionOrganizeColumns">
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionEditTable.svg</normaloff>:/images/themes/default/mActionEditTable.svg</iconset>
</property>
<property name="text">
<string>Organize Columns</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
Expand Down

0 comments on commit 399dc62

Please sign in to comment.