Skip to content
Permalink
Browse files

[FEATURE] Add setting for default attribute dialog view

Options for table view, form view and remember last view
  • Loading branch information
nyalldawson committed Mar 8, 2016
1 parent 8d3e3a4 commit f98b4ef635694b817e2f097b88ae70fc026d5f1b
Showing with 110 additions and 113 deletions.
  1. +10 −1 src/app/qgsattributetabledialog.cpp
  2. +7 −0 src/app/qgsoptions.cpp
  3. +1 −0 src/gui/attributetable/qgsdualview.cpp
  4. +92 −112 src/ui/qgsoptionsbase.ui
@@ -238,7 +238,13 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *theLayer, QWid
mUpdateExpressionText->setLayer( mLayer );
mUpdateExpressionText->setLeftHandButtonStyle( true );

mMainView->setView( QgsDualView::AttributeTable );
int initialView = settings.value( "/qgis/attributeTableView", QgsDualView::AttributeTable ).toInt();
if ( initialView < 0 )
{
initialView = settings.value( "/qgis/attributeTableLastView", QgsDualView::AttributeTable ).toInt();
}
mMainView->setView( static_cast< QgsDualView::ViewMode >( initialView ) );
mMainViewButtonGroup->button( initialView )->setChecked( true );

editingToggled();
}
@@ -642,6 +648,9 @@ void QgsAttributeTableDialog::on_mDeleteSelectedButton_clicked()
void QgsAttributeTableDialog::on_mMainView_currentChanged( int viewMode )
{
mMainViewButtonGroup->button( viewMode )->click();

QSettings s;
s.setValue( "/qgis/attributeTableLastView", static_cast< int >( viewMode ) );
}

void QgsAttributeTableDialog::on_mToggleEditingButton_toggled()
@@ -30,6 +30,7 @@
#include "qgsscaleutils.h"
#include "qgsnetworkaccessmanager.h"
#include "qgsproject.h"
#include "qgsdualview.h"

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

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

spinBoxAttrTableRowCache->setValue( mSettings->value( "/qgis/attributeTableRowCache", 10000 ).toInt() );
spinBoxAttrTableRowCache->setSpecialValueText( tr( "All" ) );
@@ -1135,6 +1141,7 @@ void QgsOptions::saveOptions()
mSettings->setValue( "/qgis/checkVersion", cbxCheckVersion->isChecked() );
mSettings->setValue( "/qgis/dockAttributeTable", cbxAttributeTableDocked->isChecked() );
mSettings->setValue( "/qgis/attributeTableBehaviour", cmbAttrTableBehaviour->itemData( cmbAttrTableBehaviour->currentIndex() ) );
mSettings->setValue( "/qgis/attributeTableView", mAttrTableViewComboBox->itemData( mAttrTableViewComboBox->currentIndex() ) );
mSettings->setValue( "/qgis/attributeTableRowCache", spinBoxAttrTableRowCache->value() );
mSettings->setValue( "/qgis/promptForRasterSublayers", cmbPromptRasterSublayers->currentIndex() );
mSettings->setValue( "/qgis/scanItemsInBrowser2",
@@ -31,6 +31,7 @@
#include <QMenu>
#include <QMessageBox>
#include <QProgressDialog>
#include <QSettings>

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

3 comments on commit f98b4ef

@nirvn

This comment has been minimized.

Copy link
Contributor

@nirvn nirvn replied Mar 8, 2016

@nyalldawson great; IMO, the default should be set to "remember last view".

@andreasneumann

This comment has been minimized.

Copy link
Member

@andreasneumann andreasneumann replied Mar 10, 2016

Hi Nyall, Thanks for this improvement!

So this is a global option. I think it would make sense to allow a per-layer override setting in the layer properties fields tab.

For some layers the table view per default makes more sense, for others the form view.

What do you think?

Thanks,
Andreas

@andreasneumann

This comment has been minimized.

Copy link
Member

@andreasneumann andreasneumann replied Mar 10, 2016

I also think that the context menu of the layer "Open attribute table" should be replaced by "Open attribute table or form" - as depending on the setting it may directly open the attribute form instead of the table.

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