Skip to content

Commit

Permalink
use default button action instead of adding a new one (relation refer…
Browse files Browse the repository at this point in the history
…ence and editor widgets)
  • Loading branch information
3nids committed Oct 15, 2014
1 parent 4ea5c80 commit 69fc9bb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 33 deletions.
29 changes: 14 additions & 15 deletions src/gui/editorwidgets/qgsrelationreferencewidget.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -78,10 +78,8 @@ QgsRelationReferenceWidget::QgsRelationReferenceWidget( QWidget* parent )


// open form button // open form button
mOpenFormButton = new QToolButton( this ); mOpenFormButton = new QToolButton( this );
mOpenFormAction = new QAction( QgsApplication::getThemeIcon( "/mActionPropertyItem.png" ), tr( "Open related feature form" ), this ); mOpenFormButton->setIcon( QgsApplication::getThemeIcon( "/mActionPropertyItem.png" ) );
mOpenFormButton->addAction( mOpenFormAction ); mOpenFormButton->setText( tr( "Open related feature form" ) );
mOpenFormButton->setDefaultAction( mOpenFormAction );
connect( mOpenFormButton, SIGNAL( triggered( QAction* ) ), this, SLOT( openForm() ) );
editLayout->addWidget( mOpenFormButton ); editLayout->addWidget( mOpenFormButton );


// highlight button // highlight button
Expand All @@ -94,24 +92,19 @@ QgsRelationReferenceWidget::QgsRelationReferenceWidget( QWidget* parent )
mHighlightFeatureButton->addAction( mScaleHighlightFeatureAction ); mHighlightFeatureButton->addAction( mScaleHighlightFeatureAction );
mHighlightFeatureButton->addAction( mPanHighlightFeatureAction ); mHighlightFeatureButton->addAction( mPanHighlightFeatureAction );
mHighlightFeatureButton->setDefaultAction( mHighlightFeatureAction ); mHighlightFeatureButton->setDefaultAction( mHighlightFeatureAction );
connect( mHighlightFeatureButton, SIGNAL( triggered( QAction* ) ), this, SLOT( highlightActionTriggered( QAction* ) ) );
editLayout->addWidget( mHighlightFeatureButton ); editLayout->addWidget( mHighlightFeatureButton );


// map identification button // map identification button
mMapIdentificationButton = new QToolButton( this ); mMapIdentificationButton = new QToolButton( this );
mMapIdentificationAction = new QAction( QgsApplication::getThemeIcon( "/mActionMapIdentification.svg" ), tr( "Select on map" ), this ); mMapIdentificationButton->setIcon( QgsApplication::getThemeIcon( "/mActionMapIdentification.svg" ) );
mMapIdentificationAction->setCheckable( true ); mMapIdentificationButton->setText( tr( "Select on map" ) );
mMapIdentificationButton->addAction( mMapIdentificationAction ); mMapIdentificationButton->setCheckable( true );
mMapIdentificationButton->setDefaultAction( mMapIdentificationAction );
connect( mMapIdentificationButton, SIGNAL( triggered( QAction* ) ), this, SLOT( mapIdentification() ) );
editLayout->addWidget( mMapIdentificationButton ); editLayout->addWidget( mMapIdentificationButton );


// remove foreign key button // remove foreign key button
mRemoveFKButton = new QToolButton( this ); mRemoveFKButton = new QToolButton( this );
mRemoveFKAction = new QAction( QgsApplication::getThemeIcon( "/mActionRemove.svg" ), tr( "No selection" ), this ); mRemoveFKButton->setIcon( QgsApplication::getThemeIcon( "/mActionRemove.svg" ) );
mRemoveFKButton->addAction( mRemoveFKAction ); mRemoveFKButton->setText( tr( "No selection" ) );
mRemoveFKButton->setDefaultAction( mRemoveFKAction );
connect( mRemoveFKButton, SIGNAL( triggered( QAction* ) ), this, SLOT( deleteForeignKey() ) );
editLayout->addWidget( mRemoveFKButton ); editLayout->addWidget( mRemoveFKButton );


// spacer // spacer
Expand Down Expand Up @@ -142,6 +135,12 @@ QgsRelationReferenceWidget::QgsRelationReferenceWidget( QWidget* parent )
mHighlightFeatureButton->hide(); mHighlightFeatureButton->hide();
mAttributeEditorFrame->hide(); mAttributeEditorFrame->hide();
mInvalidLabel->hide(); mInvalidLabel->hide();

// connect buttons
connect( mOpenFormButton, SIGNAL( clicked() ), this, SLOT( openForm() ) );
connect( mHighlightFeatureButton, SIGNAL( triggered( QAction* ) ), this, SLOT( highlightActionTriggered( QAction* ) ) );
connect( mMapIdentificationButton, SIGNAL( clicked() ), this, SLOT( mapIdentification() ) );
connect( mRemoveFKButton, SIGNAL( clicked() ), this, SLOT( deleteForeignKey() ) );
} }


QgsRelationReferenceWidget::~QgsRelationReferenceWidget() QgsRelationReferenceWidget::~QgsRelationReferenceWidget()
Expand Down Expand Up @@ -331,7 +330,7 @@ void QgsRelationReferenceWidget::setEditorContext( QgsAttributeEditorContext con
if ( mMapTool ) if ( mMapTool )
delete mMapTool; delete mMapTool;
mMapTool = new QgsMapToolIdentifyFeature( mCanvas ); mMapTool = new QgsMapToolIdentifyFeature( mCanvas );
mMapTool->setAction( mMapIdentificationAction ); mMapTool->setAction( mMapIdentificationButton->defaultAction() );
} }


void QgsRelationReferenceWidget::setEmbedForm( bool display ) void QgsRelationReferenceWidget::setEmbedForm( bool display )
Expand Down
3 changes: 0 additions & 3 deletions src/gui/editorwidgets/qgsrelationreferencewidget.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -145,9 +145,6 @@ class GUI_EXPORT QgsRelationReferenceWidget : public QWidget
QAction* mHighlightFeatureAction; QAction* mHighlightFeatureAction;
QAction* mScaleHighlightFeatureAction; QAction* mScaleHighlightFeatureAction;
QAction* mPanHighlightFeatureAction; QAction* mPanHighlightFeatureAction;
QAction* mOpenFormAction;
QAction* mMapIdentificationAction;
QAction* mRemoveFKAction;
QComboBox* mComboBox; QComboBox* mComboBox;
QgsCollapsibleGroupBox* mAttributeEditorFrame; QgsCollapsibleGroupBox* mAttributeEditorFrame;
QVBoxLayout* mAttributeEditorLayout; QVBoxLayout* mAttributeEditorLayout;
Expand Down
25 changes: 10 additions & 15 deletions src/gui/qgsrelationeditorwidget.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -45,35 +45,30 @@ QgsRelationEditorWidget::QgsRelationEditorWidget( QWidget* parent )
buttonLayout->setContentsMargins( 0, 0, 0, 0 ); buttonLayout->setContentsMargins( 0, 0, 0, 0 );
// toogle editing // toogle editing
mToggleEditingButton = new QToolButton( this ); mToggleEditingButton = new QToolButton( this );
QAction* toggleEditingAction = new QAction( QgsApplication::getThemeIcon( "/mActionToggleEditing.svg" ), tr( "Toggle editing" ), this ); mToggleEditingButton->setIcon( QgsApplication::getThemeIcon( "/mActionToggleEditing.svg" ) );
mToggleEditingButton->addAction( toggleEditingAction ); mToggleEditingButton->setText( tr( "Toggle editing" ) );
mToggleEditingButton->setDefaultAction( toggleEditingAction );
mToggleEditingButton->setEnabled( false ); mToggleEditingButton->setEnabled( false );
mToggleEditingButton->setCheckable( true ); mToggleEditingButton->setCheckable( true );
buttonLayout->addWidget( mToggleEditingButton ); buttonLayout->addWidget( mToggleEditingButton );
// add feature // add feature
mAddFeatureButton = new QToolButton( this ); mAddFeatureButton = new QToolButton( this );
QAction* addFeatureAction = new QAction( QgsApplication::getThemeIcon( "/mActionAdd.svg" ), tr( "Add feature" ), this ); mAddFeatureButton->setIcon( QgsApplication::getThemeIcon( "/mActionAdd.svg" ) );
mAddFeatureButton->addAction( addFeatureAction ); mAddFeatureButton->setText( tr( "Add feature" ) );
mAddFeatureButton->setDefaultAction( addFeatureAction );
buttonLayout->addWidget( mAddFeatureButton ); buttonLayout->addWidget( mAddFeatureButton );
// delete feature // delete feature
mDeleteFeatureButton = new QToolButton( this ); mDeleteFeatureButton = new QToolButton( this );
QAction* deleteFeatureAction = new QAction( QgsApplication::getThemeIcon( "/mActionRemove.svg" ), tr( "Delete feature" ), this ); mDeleteFeatureButton->setIcon( QgsApplication::getThemeIcon( "/mActionRemove.svg" ) );
mDeleteFeatureButton->addAction( deleteFeatureAction ); mDeleteFeatureButton->setText( tr( "Delete feature" ) );
mDeleteFeatureButton->setDefaultAction( deleteFeatureAction );
buttonLayout->addWidget( mDeleteFeatureButton ); buttonLayout->addWidget( mDeleteFeatureButton );
// link feature // link feature
mLinkFeatureButton = new QToolButton( this ); mLinkFeatureButton = new QToolButton( this );
QAction* linkFeatureAction = new QAction( QgsApplication::getThemeIcon( "/mActionLink.svg" ), tr( "Link feature" ), this ); mLinkFeatureButton->setIcon( QgsApplication::getThemeIcon( "/mActionLink.svg" ) );
mLinkFeatureButton->addAction( linkFeatureAction ); mLinkFeatureButton->setText( tr( "Link feature" ) );
mLinkFeatureButton->setDefaultAction( linkFeatureAction );
buttonLayout->addWidget( mLinkFeatureButton ); buttonLayout->addWidget( mLinkFeatureButton );
// unlink feature // unlink feature
mUnlinkFeatureButton = new QToolButton( this ); mUnlinkFeatureButton = new QToolButton( this );
QAction* unlinkFeatureAction = new QAction( QgsApplication::getThemeIcon( "/mActionUnlink.svg" ), tr( "Unlink feature" ), this ); mUnlinkFeatureButton->setIcon( QgsApplication::getThemeIcon( "/mActionUnlink.svg" ) );
mUnlinkFeatureButton->addAction( unlinkFeatureAction ); mUnlinkFeatureButton->setText( tr( "Unlink feature" ) );
mUnlinkFeatureButton->setDefaultAction( unlinkFeatureAction );
buttonLayout->addWidget( mUnlinkFeatureButton ); buttonLayout->addWidget( mUnlinkFeatureButton );
// spacer // spacer
buttonLayout->addItem( new QSpacerItem( 0, 0, QSizePolicy::Expanding ) ); buttonLayout->addItem( new QSpacerItem( 0, 0, QSizePolicy::Expanding ) );
Expand Down

0 comments on commit 69fc9bb

Please sign in to comment.