Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to autosize all columns by default when opening an attribute table #58547

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/app/options/qgsoptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti
cbxCheckVersion->setChecked( mSettings->value( QStringLiteral( "/qgis/checkVersion" ), true ).toBool() );
cbxCheckVersion->setVisible( mSettings->value( QStringLiteral( "/qgis/allowVersionCheck" ), true ).toBool() );
cbxAttributeTableDocked->setChecked( mSettings->value( QStringLiteral( "/qgis/dockAttributeTable" ), false ).toBool() );
cbxAutosizeAttributeTable->setChecked( QgsSettingsRegistryCore::settingsAutosizeAttributeTable->value() );

mComboCopyFeatureFormat->addItem( tr( "Plain Text, No Geometry" ), QgsClipboard::AttributesOnly );
mComboCopyFeatureFormat->addItem( tr( "Plain Text, WKT Geometry" ), QgsClipboard::AttributesWithWKT );
Expand Down Expand Up @@ -1613,6 +1614,7 @@ void QgsOptions::saveOptions()

mSettings->setValue( QStringLiteral( "/qgis/checkVersion" ), cbxCheckVersion->isChecked() );
mSettings->setValue( QStringLiteral( "/qgis/dockAttributeTable" ), cbxAttributeTableDocked->isChecked() );
QgsSettingsRegistryCore::settingsAutosizeAttributeTable->setValue( cbxAutosizeAttributeTable->isChecked() );
mSettings->setEnumValue( QStringLiteral( "/qgis/attributeTableBehavior" ), ( QgsAttributeTableFilterModel::FilterMode )cmbAttrTableBehavior->currentData().toInt() );
mSettings->setValue( QStringLiteral( "/qgis/attributeTableView" ), mAttrTableViewComboBox->currentData() );
mSettings->setValue( QStringLiteral( "/qgis/attributeTableRowCache" ), spinBoxAttrTableRowCache->value() );
Expand Down
6 changes: 6 additions & 0 deletions src/app/qgsattributetabledialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#include "qgsdockablewidgethelper.h"
#include "qgsactionmenu.h"
#include "qgsdockwidget.h"
#include "qgssettingsregistrycore.h"

QgsExpressionContext QgsAttributeTableDialog::createExpressionContext() const
{
Expand Down Expand Up @@ -410,6 +411,11 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *layer, QgsAttr
mMainView->setView( static_cast< QgsDualView::ViewMode >( initialView ) );
mMainViewButtonGroup->button( initialView )->setChecked( true );

if ( QgsSettingsRegistryCore::settingsAutosizeAttributeTable->value() )
{
mMainView->tableView()->resizeColumnsToContents();
}

connect( mActionToggleMultiEdit, &QAction::toggled, mMainView, &QgsDualView::setMultiEditEnabled );
connect( mActionSearchForm, &QAction::toggled, mMainView, &QgsDualView::toggleSearchMode );
updateMultiEditButtonState();
Expand Down
2 changes: 2 additions & 0 deletions src/core/settings/qgssettingsregistrycore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ const QgsSettingsEntryString *QgsSettingsRegistryCore::settingsNetworkCacheDirec

const QgsSettingsEntryInteger64 *QgsSettingsRegistryCore::settingsNetworkCacheSize = new QgsSettingsEntryInteger64( QStringLiteral( "size-bytes" ), QgsSettingsTree::sTreeNetworkCache, 0, QStringLiteral( "Network disk cache size in bytes (0 = automatic size)" ) );

const QgsSettingsEntryBool *QgsSettingsRegistryCore::settingsAutosizeAttributeTable = new QgsSettingsEntryBool( QStringLiteral( "autosize-attribute-table" ), QgsSettingsTree::sTreeAttributeTable, false );

QgsSettingsRegistryCore::QgsSettingsRegistryCore()
: QgsSettingsRegistry()
{
Expand Down
3 changes: 3 additions & 0 deletions src/core/settings/qgssettingsregistrycore.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ class CORE_EXPORT QgsSettingsRegistryCore : public QgsSettingsRegistry
//! Settings entry network cache directory
static const QgsSettingsEntryInteger64 *settingsNetworkCacheSize;

//! Settings entry autosize columns by default when opening attribute table
static const QgsSettingsEntryBool *settingsAutosizeAttributeTable;

private:
friend class QgsApplication;

Expand Down
1 change: 1 addition & 0 deletions src/core/settings/qgssettingstree.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class CORE_EXPORT QgsSettingsTree
static inline QgsSettingsTreeNode *sTreeMeasure = treeRoot()->createChildNode( QStringLiteral( "measure" ) );
static inline QgsSettingsTreeNode *sTreeAnnotations = treeRoot()->createChildNode( QStringLiteral( "annotations" ) );
static inline QgsSettingsTreeNode *sTreeNetworkCache = treeRoot()->createChildNode( QStringLiteral( "cache" ) );
static inline QgsSettingsTreeNode *sTreeAttributeTable = treeRoot()->createChildNode( QStringLiteral( "attribute-table" ) );

#endif

Expand Down
137 changes: 71 additions & 66 deletions src/ui/qgsoptionsbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
<item>
<widget class="QStackedWidget" name="mOptionsStackedWidget">
<property name="currentIndex">
<number>0</number>
<number>4</number>
</property>
<widget class="QWidget" name="mOptionsPageGeneral">
<layout class="QVBoxLayout" name="verticalLayout_3">
Expand Down Expand Up @@ -971,8 +971,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>578</width>
<height>1069</height>
<width>843</width>
<height>1068</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_22">
Expand Down Expand Up @@ -1331,10 +1331,10 @@
<property name="title">
<string>Current environment variables (read-only - bold indicates modified at startup)</string>
</property>
<property name="collapsed" stdset="0">
<property name="collapsed">
<bool>false</bool>
</property>
<property name="saveCollapsedState" stdset="0">
<property name="saveCollapsedState">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8">
Expand Down Expand Up @@ -1510,8 +1510,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>611</width>
<height>465</height>
<width>857</width>
<height>685</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_15">
Expand All @@ -1534,7 +1534,7 @@
</property>
<layout class="QGridLayout" name="gridLayout_14" columnstretch="0,1">
<item row="0" column="1">
<widget class="QgsProjectionSelectionWidget" name="leLayerGlobalCrs" native="true">
<widget class="QgsProjectionSelectionWidget" name="leLayerGlobalCrs">
<property name="enabled">
<bool>true</bool>
</property>
Expand Down Expand Up @@ -1640,7 +1640,7 @@
</widget>
</item>
<item row="2" column="1">
<widget class="QgsProjectionSelectionWidget" name="leProjectGlobalCrs" native="true">
<widget class="QgsProjectionSelectionWidget" name="leProjectGlobalCrs">
<property name="minimumSize">
<size>
<width>0</width>
Expand Down Expand Up @@ -1754,8 +1754,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>596</width>
<height>105</height>
<width>857</width>
<height>685</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_47">
Expand Down Expand Up @@ -1837,8 +1837,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>637</width>
<height>744</height>
<width>843</width>
<height>772</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_27">
Expand All @@ -1860,14 +1860,10 @@
<string>Feature Attributes and Table</string>
</property>
<layout class="QGridLayout" name="gridLayout_19">
<item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="cbxAttributeTableDocked">
<property name="text">
<string>Open attribute table as docked window</string>
</property>
</widget>
<item row="7" column="1">
<widget class="QLineEdit" name="leNullValue"/>
</item>
<item row="3" column="1">
<item row="4" column="1">
<widget class="QComboBox" name="cmbAttrTableBehavior">
<item>
<property name="text">
Expand All @@ -1876,7 +1872,34 @@
</item>
</widget>
</item>
<item row="3" column="0">
<item row="5" column="0">
<widget class="QLabel" name="label_46">
<property name="text">
<string>Default view</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="mComboCopyFeatureFormat"/>
</item>
<item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="cbxAttributeTableDocked">
<property name="text">
<string>Open attribute table as docked window</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QComboBox" name="mAttrTableViewComboBox"/>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_14">
<property name="text">
<string>Representation for NULL values</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="textLabel1_7">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
Expand All @@ -1890,19 +1913,6 @@
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_14">
<property name="text">
<string>Representation for NULL values</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="mAttrTableViewComboBox"/>
</item>
<item row="6" column="1">
<widget class="QLineEdit" name="leNullValue"/>
</item>
<item row="5" column="0">
<widget class="QLabel" name="textLabel1_12">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
Expand All @@ -1915,7 +1925,7 @@
</property>
</widget>
</item>
<item row="5" column="1">
<item row="6" column="1">
<widget class="QgsSpinBox" name="spinBoxAttrTableRowCache">
<property name="minimum">
<number>0</number>
Expand All @@ -1931,20 +1941,17 @@
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="mComboCopyFeatureFormat"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_46">
<item row="3" column="0">
<widget class="QLabel" name="label_48">
<property name="text">
<string>Default view</string>
<string>Copy features as</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_48">
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="cbxAutosizeAttributeTable">
<property name="text">
<string>Copy features as</string>
<string>Autosize all columns by default when opening attribute table</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -2441,7 +2448,7 @@
<x>0</x>
<y>0</y>
<width>508</width>
<height>482</height>
<height>487</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_25">
Expand Down Expand Up @@ -2680,7 +2687,7 @@
<property name="value">
<double>0.100000000000000</double>
</property>
<property name="showClearButton" stdset="0">
<property name="showClearButton">
<bool>true</bool>
</property>
</widget>
Expand Down Expand Up @@ -2718,7 +2725,7 @@
<property name="value">
<double>20.000000000000000</double>
</property>
<property name="showClearButton" stdset="0">
<property name="showClearButton">
<bool>true</bool>
</property>
</widget>
Expand Down Expand Up @@ -2824,7 +2831,7 @@
<x>0</x>
<y>0</y>
<width>622</width>
<height>923</height>
<height>925</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_30">
Expand Down Expand Up @@ -3222,7 +3229,7 @@
<property name="title">
<string>Coordinate and Bearing Display</string>
</property>
<property name="syncGroup" stdset="0">
<property name="syncGroup">
<string notr="true">projgeneral</string>
</property>
<layout class="QGridLayout" name="gridLayout_30" columnstretch="0,0,3,6">
Expand Down Expand Up @@ -3320,7 +3327,7 @@ The bigger the number, the faster zooming with the mouse wheel will be.</string>
<property name="value">
<number>200</number>
</property>
<property name="showClearButton" stdset="0">
<property name="showClearButton">
<bool>true</bool>
</property>
</widget>
Expand Down Expand Up @@ -3487,8 +3494,8 @@ The bigger the number, the faster zooming with the mouse wheel will be.</string>
<rect>
<x>0</x>
<y>0</y>
<width>843</width>
<height>1031</height>
<width>575</width>
<height>1038</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_31">
Expand Down Expand Up @@ -4393,8 +4400,8 @@ The bigger the number, the faster zooming with the mouse wheel will be.</string>
<rect>
<x>0</x>
<y>0</y>
<width>482</width>
<height>539</height>
<width>476</width>
<height>542</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_39">
Expand Down Expand Up @@ -4878,6 +4885,9 @@ The bigger the number, the faster zooming with the mouse wheel will be.</string>
<property name="toolTip">
<string>Specify the cache size in megabytes. Clear the value to enable smart cache size, which sets the maximum cache size based on available space.</string>
</property>
<property name="specialValueText">
<string>Smart cache size</string>
</property>
<property name="suffix">
<string> MB</string>
</property>
Expand All @@ -4890,14 +4900,11 @@ The bigger the number, the faster zooming with the mouse wheel will be.</string>
<property name="singleStep">
<number>100</number>
</property>
<property name="clearValue">
<number>0</number>
</property>
<property name="showClearButton" stdset="0">
<property name="showClearButton">
<bool>true</bool>
</property>
<property name="specialValueText">
<string>Smart cache size</string>
<property name="clearValue">
<bool>false</bool>
</property>
</widget>
</item>
Expand Down Expand Up @@ -4971,10 +4978,10 @@ The bigger the number, the faster zooming with the mouse wheel will be.</string>
<property name="checkable">
<bool>true</bool>
</property>
<property name="collapsed" stdset="0">
<property name="collapsed">
<bool>false</bool>
</property>
<property name="saveCollapsedState" stdset="0">
<property name="saveCollapsedState">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_1">
Expand Down Expand Up @@ -5235,11 +5242,8 @@ The bigger the number, the faster zooming with the mouse wheel will be.</string>
<widget class="QTextBrowser" name="mGPUInfoTextBrowser">
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;meta charset=&quot;utf-8&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
hr { height: 1px; border-width: 0; }
li.unchecked::marker { content: &quot;\2610&quot;; }
li.checked::marker { content: &quot;\2612&quot;; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Noto Sans'; font-size:10pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
Expand Down Expand Up @@ -5635,6 +5639,7 @@ li.checked::marker { content: &quot;\2612&quot;; }
</tabstops>
<resources>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
</resources>
<connections/>
<buttongroups>
Expand Down
Loading