Skip to content

Commit

Permalink
allow to hide/show all columns in attribute table config
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Jun 1, 2016
1 parent 47a301c commit f20e28d
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 7 deletions.
11 changes: 11 additions & 0 deletions python/gui/attributetable/qgsorganizetablecolumnsdialog.sip
Expand Up @@ -23,4 +23,15 @@ class QgsOrganizeTableColumnsDialog : QDialog
* Get the updated configuration
*/
QgsAttributeTableConfig config() const;

public slots:
/**
* showAll checks all the fields to show them all in the attribute table
*/
void showAll();

/**
* hideAll unchecks all the fields to hide them all in the attribute table
*/
void hideAll();
};
27 changes: 27 additions & 0 deletions src/gui/attributetable/qgsorganizetablecolumnsdialog.cpp
Expand Up @@ -45,6 +45,10 @@ QgsOrganizeTableColumnsDialog::QgsOrganizeTableColumnsDialog( const QgsVectorLay
: QDialog( parent, flags )
{
setupUi( this );

connect( mShowAllButton, SIGNAL( clicked( bool ) ), this, SLOT( showAll() ) );
connect( mHideAllButton, SIGNAL( clicked( bool ) ), this, SLOT( hideAll() ) );

if ( vl )
{
mConfig = vl->attributeTableConfig();
Expand Down Expand Up @@ -86,6 +90,13 @@ QgsOrganizeTableColumnsDialog::QgsOrganizeTableColumnsDialog( const QgsVectorLay
}
}

if ( !vl || mConfig.columns().count() < 7 )
{
mShowAllButton->hide();
mHideAllButton->hide();
}


QSettings settings;
restoreGeometry( settings.value( "/Windows/QgsOrganizeTableColumnsDialog/geometry" ).toByteArray() );
}
Expand Down Expand Up @@ -114,3 +125,19 @@ QgsAttributeTableConfig QgsOrganizeTableColumnsDialog::config() const
config.setColumns( columns );
return config;
}

void QgsOrganizeTableColumnsDialog::showAll()
{
for ( int i = 0 ; i < mFieldsList->count() ; i++ )
{
mFieldsList->item( i )->setCheckState( Qt::Checked );
}
}

void QgsOrganizeTableColumnsDialog::hideAll()
{
for ( int i = 0 ; i < mFieldsList->count() ; i++ )
{
mFieldsList->item( i )->setCheckState( Qt::Unchecked );
}
}
12 changes: 12 additions & 0 deletions src/gui/attributetable/qgsorganizetablecolumnsdialog.h
Expand Up @@ -48,8 +48,20 @@ class GUI_EXPORT QgsOrganizeTableColumnsDialog : public QDialog, private Ui::Qgs
*/
QgsAttributeTableConfig config() const;

public slots:
/**
* showAll checks all the fields to show them all in the attribute table
*/
void showAll();

/**
* hideAll unchecks all the fields to hide them all in the attribute table
*/
void hideAll();

private:
QgsAttributeTableConfig mConfig;

};

#endif
41 changes: 34 additions & 7 deletions src/ui/qgsorganizetablecolumnsdialog.ui
Expand Up @@ -13,8 +13,25 @@
<property name="windowTitle">
<string>Filter table column</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="3">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="mShowAllButton">
<property name="text">
<string>select all</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="4">
<widget class="QListWidget" name="mFieldsList">
<property name="dragDropMode">
<enum>QAbstractItemView::DragDrop</enum>
Expand All @@ -24,15 +41,25 @@
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<item row="2" column="1">
<widget class="QPushButton" name="mHideAllButton">
<property name="text">
<string>unselect all</string>
</property>
</widget>
</item>
<item row="2" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</widget>
</spacer>
</item>
</layout>
</widget>
Expand Down

0 comments on commit f20e28d

Please sign in to comment.