Skip to content
Permalink
Browse files

allow to hide/show all columns in attribute table config

  • Loading branch information
3nids committed Jun 1, 2016
1 parent 47a301c commit f20e28d98fd626cc86977bd801ac540920464eb3
@@ -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();
};
@@ -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();
@@ -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() );
}
@@ -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 );
}
}
@@ -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
@@ -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>
@@ -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>

0 comments on commit f20e28d

Please sign in to comment.
You can’t perform that action at this time.