Skip to content

Commit

Permalink
add "Organize Columns" button to the attribute table toolbar to allow
Browse files Browse the repository at this point in the history
unhiding columns if all of them were hidden by accident (fix #23397)
  • Loading branch information
alexbruy committed Jan 20, 2020
1 parent d39b6ac commit a64808b
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 @@ -154,6 +154,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 a64808b

Please sign in to comment.