Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[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 f98b4ef
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 113 deletions.
11 changes: 10 additions & 1 deletion src/app/qgsattributetabledialog.cpp
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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()
Expand Down
7 changes: 7 additions & 0 deletions src/app/qgsoptions.cpp
Expand Up @@ -30,6 +30,7 @@
#include "qgsscaleutils.h"
#include "qgsnetworkaccessmanager.h"
#include "qgsproject.h"
#include "qgsdualview.h"

#include "qgsattributetablefiltermodel.h"
#include "qgsrasterformatsaveoptionswidget.h"
Expand Down Expand Up @@ -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" ) );
Expand Down Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions src/gui/attributetable/qgsdualview.cpp
Expand Up @@ -31,6 +31,7 @@
#include <QMenu>
#include <QMessageBox>
#include <QProgressDialog>
#include <QSettings>

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

3 comments on commit f98b4ef

@nirvn
Copy link
Contributor

@nirvn nirvn commented on f98b4ef Mar 8, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@andreasneumann
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.