Skip to content

Commit f98b4ef

Browse files
committedMar 8, 2016
[FEATURE] Add setting for default attribute dialog view
Options for table view, form view and remember last view
1 parent 8d3e3a4 commit f98b4ef

File tree

4 files changed

+110
-113
lines changed

4 files changed

+110
-113
lines changed
 

‎src/app/qgsattributetabledialog.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,13 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *theLayer, QWid
238238
mUpdateExpressionText->setLayer( mLayer );
239239
mUpdateExpressionText->setLeftHandButtonStyle( true );
240240

241-
mMainView->setView( QgsDualView::AttributeTable );
241+
int initialView = settings.value( "/qgis/attributeTableView", QgsDualView::AttributeTable ).toInt();
242+
if ( initialView < 0 )
243+
{
244+
initialView = settings.value( "/qgis/attributeTableLastView", QgsDualView::AttributeTable ).toInt();
245+
}
246+
mMainView->setView( static_cast< QgsDualView::ViewMode >( initialView ) );
247+
mMainViewButtonGroup->button( initialView )->setChecked( true );
242248

243249
editingToggled();
244250
}
@@ -642,6 +648,9 @@ void QgsAttributeTableDialog::on_mDeleteSelectedButton_clicked()
642648
void QgsAttributeTableDialog::on_mMainView_currentChanged( int viewMode )
643649
{
644650
mMainViewButtonGroup->button( viewMode )->click();
651+
652+
QSettings s;
653+
s.setValue( "/qgis/attributeTableLastView", static_cast< int >( viewMode ) );
645654
}
646655

647656
void QgsAttributeTableDialog::on_mToggleEditingButton_toggled()

‎src/app/qgsoptions.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "qgsscaleutils.h"
3131
#include "qgsnetworkaccessmanager.h"
3232
#include "qgsproject.h"
33+
#include "qgsdualview.h"
3334

3435
#include "qgsattributetablefiltermodel.h"
3536
#include "qgsrasterformatsaveoptionswidget.h"
@@ -336,6 +337,11 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl ) :
336337
cmbAttrTableBehaviour->addItem( tr( "Show features visible on map" ), QgsAttributeTableFilterModel::ShowVisible );
337338
cmbAttrTableBehaviour->setCurrentIndex( cmbAttrTableBehaviour->findData( mSettings->value( "/qgis/attributeTableBehaviour", QgsAttributeTableFilterModel::ShowAll ).toInt() ) );
338339

340+
mAttrTableViewComboBox->clear();
341+
mAttrTableViewComboBox->addItem( tr( "Remember last view" ), -1 );
342+
mAttrTableViewComboBox->addItem( tr( "Table view" ), QgsDualView::AttributeTable );
343+
mAttrTableViewComboBox->addItem( tr( "Form view" ), QgsDualView::AttributeEditor );
344+
mAttrTableViewComboBox->setCurrentIndex( mAttrTableViewComboBox->findData( mSettings->value( "/qgis/attributeTableView", QgsDualView::AttributeTable ).toInt() ) );
339345

340346
spinBoxAttrTableRowCache->setValue( mSettings->value( "/qgis/attributeTableRowCache", 10000 ).toInt() );
341347
spinBoxAttrTableRowCache->setSpecialValueText( tr( "All" ) );
@@ -1135,6 +1141,7 @@ void QgsOptions::saveOptions()
11351141
mSettings->setValue( "/qgis/checkVersion", cbxCheckVersion->isChecked() );
11361142
mSettings->setValue( "/qgis/dockAttributeTable", cbxAttributeTableDocked->isChecked() );
11371143
mSettings->setValue( "/qgis/attributeTableBehaviour", cmbAttrTableBehaviour->itemData( cmbAttrTableBehaviour->currentIndex() ) );
1144+
mSettings->setValue( "/qgis/attributeTableView", mAttrTableViewComboBox->itemData( mAttrTableViewComboBox->currentIndex() ) );
11381145
mSettings->setValue( "/qgis/attributeTableRowCache", spinBoxAttrTableRowCache->value() );
11391146
mSettings->setValue( "/qgis/promptForRasterSublayers", cmbPromptRasterSublayers->currentIndex() );
11401147
mSettings->setValue( "/qgis/scanItemsInBrowser2",

‎src/gui/attributetable/qgsdualview.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <QMenu>
3232
#include <QMessageBox>
3333
#include <QProgressDialog>
34+
#include <QSettings>
3435

3536
QgsDualView::QgsDualView( QWidget* parent )
3637
: QStackedWidget( parent )

‎src/ui/qgsoptionsbase.ui

Lines changed: 92 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,8 @@
337337
<rect>
338338
<x>0</x>
339339
<y>0</y>
340-
<width>618</width>
341-
<height>582</height>
340+
<width>723</width>
341+
<height>670</height>
342342
</rect>
343343
</property>
344344
<layout class="QVBoxLayout" name="verticalLayout_28">
@@ -1010,8 +1010,8 @@
10101010
<rect>
10111011
<x>0</x>
10121012
<y>0</y>
1013-
<width>713</width>
1014-
<height>826</height>
1013+
<width>663</width>
1014+
<height>862</height>
10151015
</rect>
10161016
</property>
10171017
<layout class="QVBoxLayout" name="verticalLayout_22">
@@ -1394,8 +1394,8 @@
13941394
<rect>
13951395
<x>0</x>
13961396
<y>0</y>
1397-
<width>713</width>
1398-
<height>601</height>
1397+
<width>601</width>
1398+
<height>720</height>
13991399
</rect>
14001400
</property>
14011401
<layout class="QVBoxLayout" name="verticalLayout_27">
@@ -1404,88 +1404,65 @@
14041404
<property name="title">
14051405
<string>Feature attributes and table</string>
14061406
</property>
1407-
<layout class="QVBoxLayout" name="verticalLayout_23">
1408-
<item>
1407+
<layout class="QGridLayout" name="gridLayout_19">
1408+
<item row="0" column="0" colspan="2">
14091409
<widget class="QCheckBox" name="cbxAttributeTableDocked">
14101410
<property name="text">
14111411
<string>Open attribute table in a dock window (QGIS restart required)</string>
14121412
</property>
14131413
</widget>
14141414
</item>
1415-
<item>
1415+
<item row="1" column="0" colspan="2">
14161416
<widget class="QCheckBox" name="cbxCopyWKTGeomFromTable">
14171417
<property name="text">
14181418
<string>Copy geometry in WKT representation from attribute table</string>
14191419
</property>
14201420
</widget>
14211421
</item>
1422-
<item>
1423-
<layout class="QHBoxLayout" name="horizontalLayout_5">
1424-
<item>
1425-
<widget class="QLabel" name="textLabel1_7">
1426-
<property name="sizePolicy">
1427-
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
1428-
<horstretch>0</horstretch>
1429-
<verstretch>0</verstretch>
1430-
</sizepolicy>
1431-
</property>
1432-
<property name="text">
1433-
<string>Attribute table behaviour</string>
1434-
</property>
1435-
</widget>
1436-
</item>
1437-
<item>
1438-
<spacer name="horizontalSpacer_4">
1439-
<property name="orientation">
1440-
<enum>Qt::Horizontal</enum>
1441-
</property>
1442-
<property name="sizeHint" stdset="0">
1443-
<size>
1444-
<width>40</width>
1445-
<height>20</height>
1446-
</size>
1447-
</property>
1448-
</spacer>
1449-
</item>
1422+
<item row="3" column="1">
1423+
<widget class="QComboBox" name="cmbAttrTableBehaviour">
14501424
<item>
1451-
<widget class="QComboBox" name="cmbAttrTableBehaviour">
1452-
<item>
1453-
<property name="text">
1454-
<string/>
1455-
</property>
1456-
</item>
1457-
</widget>
1425+
<property name="text">
1426+
<string/>
1427+
</property>
14581428
</item>
1459-
</layout>
1429+
</widget>
14601430
</item>
1461-
<item>
1431+
<item row="3" column="0">
1432+
<widget class="QLabel" name="textLabel1_7">
1433+
<property name="sizePolicy">
1434+
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
1435+
<horstretch>0</horstretch>
1436+
<verstretch>0</verstretch>
1437+
</sizepolicy>
1438+
</property>
1439+
<property name="text">
1440+
<string>Attribute table behaviour</string>
1441+
</property>
1442+
</widget>
1443+
</item>
1444+
<item row="6" column="0">
1445+
<widget class="QLabel" name="label_14">
1446+
<property name="text">
1447+
<string>Representation for NULL values</string>
1448+
</property>
1449+
</widget>
1450+
</item>
1451+
<item row="5" column="0">
1452+
<widget class="QLabel" name="textLabel1_12">
1453+
<property name="sizePolicy">
1454+
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
1455+
<horstretch>0</horstretch>
1456+
<verstretch>0</verstretch>
1457+
</sizepolicy>
1458+
</property>
1459+
<property name="text">
1460+
<string>Attribute table row cache</string>
1461+
</property>
1462+
</widget>
1463+
</item>
1464+
<item row="5" column="1">
14621465
<layout class="QHBoxLayout" name="horizontalLayout_10">
1463-
<item>
1464-
<widget class="QLabel" name="textLabel1_12">
1465-
<property name="sizePolicy">
1466-
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
1467-
<horstretch>0</horstretch>
1468-
<verstretch>0</verstretch>
1469-
</sizepolicy>
1470-
</property>
1471-
<property name="text">
1472-
<string>Attribute table row cache</string>
1473-
</property>
1474-
</widget>
1475-
</item>
1476-
<item>
1477-
<spacer name="horizontalSpacer_8">
1478-
<property name="orientation">
1479-
<enum>Qt::Horizontal</enum>
1480-
</property>
1481-
<property name="sizeHint" stdset="0">
1482-
<size>
1483-
<width>40</width>
1484-
<height>20</height>
1485-
</size>
1486-
</property>
1487-
</spacer>
1488-
</item>
14891466
<item>
14901467
<widget class="QSpinBox" name="spinBoxAttrTableRowCache">
14911468
<property name="minimum">
@@ -1502,19 +1479,8 @@
15021479
</property>
15031480
</widget>
15041481
</item>
1505-
</layout>
1506-
</item>
1507-
<item>
1508-
<layout class="QHBoxLayout" name="horizontalLayout_6">
1509-
<item>
1510-
<widget class="QLabel" name="label_14">
1511-
<property name="text">
1512-
<string>Representation for NULL values</string>
1513-
</property>
1514-
</widget>
1515-
</item>
15161482
<item>
1517-
<spacer name="horizontalSpacer_3">
1483+
<spacer name="horizontalSpacer_8">
15181484
<property name="orientation">
15191485
<enum>Qt::Horizontal</enum>
15201486
</property>
@@ -1526,11 +1492,21 @@
15261492
</property>
15271493
</spacer>
15281494
</item>
1529-
<item>
1530-
<widget class="QLineEdit" name="leNullValue"/>
1531-
</item>
15321495
</layout>
15331496
</item>
1497+
<item row="4" column="0">
1498+
<widget class="QLabel" name="label_46">
1499+
<property name="text">
1500+
<string>Default view</string>
1501+
</property>
1502+
</widget>
1503+
</item>
1504+
<item row="6" column="1">
1505+
<widget class="QLineEdit" name="leNullValue"/>
1506+
</item>
1507+
<item row="4" column="1">
1508+
<widget class="QComboBox" name="mAttrTableViewComboBox"/>
1509+
</item>
15341510
</layout>
15351511
</widget>
15361512
</item>
@@ -1681,7 +1657,7 @@
16811657
<item>
16821658
<widget class="QgsCollapsibleGroupBox" name="groupBox_28">
16831659
<property name="title">
1684-
<string>Hidden Browser Path</string>
1660+
<string>Hidden browser paths</string>
16851661
</property>
16861662
<layout class="QGridLayout" name="_15">
16871663
<item row="0" column="0">
@@ -1773,8 +1749,8 @@
17731749
<rect>
17741750
<x>0</x>
17751751
<y>0</y>
1776-
<width>713</width>
1777-
<height>675</height>
1752+
<width>747</width>
1753+
<height>802</height>
17781754
</rect>
17791755
</property>
17801756
<layout class="QVBoxLayout" name="verticalLayout_29">
@@ -2493,8 +2469,8 @@
24932469
<rect>
24942470
<x>0</x>
24952471
<y>0</y>
2496-
<width>730</width>
2497-
<height>582</height>
2472+
<width>617</width>
2473+
<height>578</height>
24982474
</rect>
24992475
</property>
25002476
<layout class="QHBoxLayout" name="horizontalLayout_46">
@@ -2598,8 +2574,8 @@
25982574
<rect>
25992575
<x>0</x>
26002576
<y>0</y>
2601-
<width>618</width>
2602-
<height>582</height>
2577+
<width>617</width>
2578+
<height>578</height>
26032579
</rect>
26042580
</property>
26052581
<layout class="QVBoxLayout" name="verticalLayout_25">
@@ -2936,8 +2912,8 @@
29362912
<rect>
29372913
<x>0</x>
29382914
<y>0</y>
2939-
<width>618</width>
2940-
<height>582</height>
2915+
<width>650</width>
2916+
<height>645</height>
29412917
</rect>
29422918
</property>
29432919
<layout class="QVBoxLayout" name="verticalLayout_30">
@@ -3398,8 +3374,8 @@
33983374
<rect>
33993375
<x>0</x>
34003376
<y>0</y>
3401-
<width>618</width>
3402-
<height>582</height>
3377+
<width>617</width>
3378+
<height>578</height>
34033379
</rect>
34043380
</property>
34053381
<layout class="QVBoxLayout" name="verticalLayout_39">
@@ -3653,8 +3629,8 @@
36533629
<rect>
36543630
<x>0</x>
36553631
<y>0</y>
3656-
<width>618</width>
3657-
<height>582</height>
3632+
<width>601</width>
3633+
<height>668</height>
36583634
</rect>
36593635
</property>
36603636
<layout class="QVBoxLayout" name="verticalLayout_31">
@@ -4198,8 +4174,8 @@
41984174
<rect>
41994175
<x>0</x>
42004176
<y>0</y>
4201-
<width>618</width>
4202-
<height>582</height>
4177+
<width>617</width>
4178+
<height>578</height>
42034179
</rect>
42044180
</property>
42054181
<layout class="QVBoxLayout" name="verticalLayout_6">
@@ -4338,7 +4314,7 @@
43384314
<x>0</x>
43394315
<y>0</y>
43404316
<width>601</width>
4341-
<height>595</height>
4317+
<height>647</height>
43424318
</rect>
43434319
</property>
43444320
<layout class="QGridLayout" name="gridLayout_15">
@@ -4583,8 +4559,8 @@
45834559
<rect>
45844560
<x>0</x>
45854561
<y>0</y>
4586-
<width>618</width>
4587-
<height>582</height>
4562+
<width>617</width>
4563+
<height>578</height>
45884564
</rect>
45894565
</property>
45904566
<layout class="QVBoxLayout" name="verticalLayout_32">
@@ -4693,7 +4669,7 @@
46934669
<x>0</x>
46944670
<y>0</y>
46954671
<width>601</width>
4696-
<height>634</height>
4672+
<height>740</height>
46974673
</rect>
46984674
</property>
46994675
<layout class="QVBoxLayout" name="verticalLayout_33">
@@ -5171,18 +5147,18 @@
51715147
</widget>
51725148
<layoutdefault spacing="6" margin="11"/>
51735149
<customwidgets>
5174-
<customwidget>
5175-
<class>QgsCollapsibleGroupBox</class>
5176-
<extends>QGroupBox</extends>
5177-
<header>qgscollapsiblegroupbox.h</header>
5178-
<container>1</container>
5179-
</customwidget>
51805150
<customwidget>
51815151
<class>QgsColorButtonV2</class>
51825152
<extends>QToolButton</extends>
51835153
<header>qgscolorbuttonv2.h</header>
51845154
<container>1</container>
51855155
</customwidget>
5156+
<customwidget>
5157+
<class>QgsCollapsibleGroupBox</class>
5158+
<extends>QGroupBox</extends>
5159+
<header>qgscollapsiblegroupbox.h</header>
5160+
<container>1</container>
5161+
</customwidget>
51865162
<customwidget>
51875163
<class>QgsColorSchemeList</class>
51885164
<extends>QWidget</extends>
@@ -5267,6 +5243,7 @@
52675243
<tabstop>cbxAttributeTableDocked</tabstop>
52685244
<tabstop>cbxCopyWKTGeomFromTable</tabstop>
52695245
<tabstop>cmbAttrTableBehaviour</tabstop>
5246+
<tabstop>mAttrTableViewComboBox</tabstop>
52705247
<tabstop>spinBoxAttrTableRowCache</tabstop>
52715248
<tabstop>leNullValue</tabstop>
52725249
<tabstop>cmbScanItemsInBrowser</tabstop>
@@ -5346,6 +5323,9 @@
53465323
<tabstop>mOffsetXSpinBox</tabstop>
53475324
<tabstop>mOffsetYSpinBox</tabstop>
53485325
<tabstop>mSnapToleranceSpinBox</tabstop>
5326+
<tabstop>mBtnAddTemplatePath</tabstop>
5327+
<tabstop>mBtnRemoveTemplatePath</tabstop>
5328+
<tabstop>mListComposerTemplatePaths</tabstop>
53495329
<tabstop>mOptionsScrollArea_07</tabstop>
53505330
<tabstop>chkDisableAttributeValuesDlg</tabstop>
53515331
<tabstop>chkReuseLastValues</tabstop>

0 commit comments

Comments
 (0)
Failed to load comments.