20#include "moc_qgsorganizetablecolumnsdialog.cpp"
39 : QDialog( parent, flags )
56 const auto constColumns = mConfig.
columns();
59 QListWidgetItem *item =
nullptr;
62 item =
new QListWidgetItem( tr(
"[Action Widget]" ), mFieldsList );
67 const int idx = fields.
lookupField( columnConfig.name );
72 item->setCheckState( columnConfig.hidden ? Qt::Unchecked : Qt::Checked );
73 item->setData( Qt::UserRole, QVariant::fromValue( columnConfig ) );
77 if ( !vl || mConfig.
columns().count() < 5 )
79 mShowAllButton->hide();
80 mHideAllButton->hide();
81 mToggleSelectionButton->hide();
94 QVector<QgsAttributeTableConfig::ColumnConfig> columns;
95 columns.reserve( mFieldsList->count() );
97 for (
int i = 0; i < mFieldsList->count() ; i++ )
99 const QListWidgetItem *item = mFieldsList->item( i );
102 columnConfig.
hidden = item->checkState() == Qt::Unchecked;
104 columns.append( columnConfig );
114 for (
int i = 0; i < mFieldsList->count() ; i++ )
116 mFieldsList->item( i )->setCheckState( Qt::Checked );
122 for (
int i = 0; i < mFieldsList->count() ; i++ )
124 mFieldsList->item( i )->setCheckState( Qt::Unchecked );
130 for ( QListWidgetItem *item : mFieldsList->selectedItems() )
132 item->setCheckState( item->checkState() == Qt::Checked ? Qt::Unchecked : Qt::Checked );
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
This is a container for configuration of the attribute table.
@ Action
This column represents an action widget.
QVector< QgsAttributeTableConfig::ColumnConfig > columns() const
Gets the list with all columns and their configuration.
void update(const QgsFields &fields)
Update the configuration with the given fields.
void setColumns(const QVector< QgsAttributeTableConfig::ColumnConfig > &columns)
Set the list of columns visible in the attribute table.
Container of fields for a vector layer.
Q_INVOKABLE int lookupField(const QString &fieldName) const
Looks up field's index from the field name.
QIcon iconForField(int fieldIdx, bool considerOrigin=false) const
Returns an icon corresponding to a field index, based on the field's type and source.
static void enableAutoGeometryRestore(QWidget *widget, const QString &key=QString())
Register the widget to allow its position to be automatically saved and restored when open and closed...
Dialog for organising (hiding and reordering) columns in the attributes table.
void toggleSelection()
Toggle the check state of selected fields to hide or show them in the attribute table.
void showAll()
showAll checks all the fields to show them all in the attribute table
QgsOrganizeTableColumnsDialog(const QgsVectorLayer *vl, const QgsAttributeTableConfig &config, QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::Window)
Constructor.
void hideAll()
hideAll unchecks all the fields to hide them all in the attribute table
QgsAttributeTableConfig config() const
Gets the updated configuration.
Represents a vector layer which manages a vector based data sets.
QString attributeDisplayName(int index) const
Convenience function that returns the attribute alias if defined or the field name else.
Defines the configuration of a column in the attribute table.
bool hidden
Flag that controls if the column is hidden.