Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
add "Organize Columns" button to the attribute table toolbar to allow
unhiding columns if all of them were hidden by accident (fix #23397)
  • Loading branch information
alexbruy authored and nyalldawson committed Mar 20, 2020
1 parent 6d2817b commit 892d06c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/app/qgsattributetabledialog.cpp
Expand Up @@ -58,6 +58,7 @@
#include "qgsproxyprogresstask.h"
#include "qgsstoredexpressionmanager.h"
#include "qgsdialog.h"
#include "qgsorganizetablecolumnsdialog.h"

QgsExpressionContext QgsAttributeTableDialog::createExpressionContext() const
{
Expand Down Expand Up @@ -109,6 +110,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 @@ -1107,6 +1109,21 @@ void QgsAttributeTableDialog::filterQueryAccepted()
filterQueryChanged( mFilterQuery->text() );
}

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()
{
mMainView->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
10 changes: 10 additions & 0 deletions src/ui/qgsattributetabledialog.ui
Expand Up @@ -275,6 +275,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 @@ -662,6 +663,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>
<action name="mActionStoredFilterExpressions">
<property name="icon">
<iconset resource="../../images/images.qrc">
Expand Down

0 comments on commit 892d06c

Please sign in to comment.