Skip to content
Permalink
Browse files

use default button action instead of adding a new one (relation refer…

…ence and editor widgets)
  • Loading branch information
3nids committed Oct 15, 2014
1 parent 4ea5c80 commit 69fc9bbb8776c9863f2d6e05328eb3eedd6539a3
@@ -78,10 +78,8 @@ QgsRelationReferenceWidget::QgsRelationReferenceWidget( QWidget* parent )

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

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

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

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

// spacer
@@ -142,6 +135,12 @@ QgsRelationReferenceWidget::QgsRelationReferenceWidget( QWidget* parent )
mHighlightFeatureButton->hide();
mAttributeEditorFrame->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()
@@ -331,7 +330,7 @@ void QgsRelationReferenceWidget::setEditorContext( QgsAttributeEditorContext con
if ( mMapTool )
delete mMapTool;
mMapTool = new QgsMapToolIdentifyFeature( mCanvas );
mMapTool->setAction( mMapIdentificationAction );
mMapTool->setAction( mMapIdentificationButton->defaultAction() );
}

void QgsRelationReferenceWidget::setEmbedForm( bool display )
@@ -145,9 +145,6 @@ class GUI_EXPORT QgsRelationReferenceWidget : public QWidget
QAction* mHighlightFeatureAction;
QAction* mScaleHighlightFeatureAction;
QAction* mPanHighlightFeatureAction;
QAction* mOpenFormAction;
QAction* mMapIdentificationAction;
QAction* mRemoveFKAction;
QComboBox* mComboBox;
QgsCollapsibleGroupBox* mAttributeEditorFrame;
QVBoxLayout* mAttributeEditorLayout;
@@ -45,35 +45,30 @@ QgsRelationEditorWidget::QgsRelationEditorWidget( QWidget* parent )
buttonLayout->setContentsMargins( 0, 0, 0, 0 );
// toogle editing
mToggleEditingButton = new QToolButton( this );
QAction* toggleEditingAction = new QAction( QgsApplication::getThemeIcon( "/mActionToggleEditing.svg" ), tr( "Toggle editing" ), this );
mToggleEditingButton->addAction( toggleEditingAction );
mToggleEditingButton->setDefaultAction( toggleEditingAction );
mToggleEditingButton->setIcon( QgsApplication::getThemeIcon( "/mActionToggleEditing.svg" ) );
mToggleEditingButton->setText( tr( "Toggle editing" ) );
mToggleEditingButton->setEnabled( false );
mToggleEditingButton->setCheckable( true );
buttonLayout->addWidget( mToggleEditingButton );
// add feature
mAddFeatureButton = new QToolButton( this );
QAction* addFeatureAction = new QAction( QgsApplication::getThemeIcon( "/mActionAdd.svg" ), tr( "Add feature" ), this );
mAddFeatureButton->addAction( addFeatureAction );
mAddFeatureButton->setDefaultAction( addFeatureAction );
mAddFeatureButton->setIcon( QgsApplication::getThemeIcon( "/mActionAdd.svg" ) );
mAddFeatureButton->setText( tr( "Add feature" ) );
buttonLayout->addWidget( mAddFeatureButton );
// delete feature
mDeleteFeatureButton = new QToolButton( this );
QAction* deleteFeatureAction = new QAction( QgsApplication::getThemeIcon( "/mActionRemove.svg" ), tr( "Delete feature" ), this );
mDeleteFeatureButton->addAction( deleteFeatureAction );
mDeleteFeatureButton->setDefaultAction( deleteFeatureAction );
mDeleteFeatureButton->setIcon( QgsApplication::getThemeIcon( "/mActionRemove.svg" ) );
mDeleteFeatureButton->setText( tr( "Delete feature" ) );
buttonLayout->addWidget( mDeleteFeatureButton );
// link feature
mLinkFeatureButton = new QToolButton( this );
QAction* linkFeatureAction = new QAction( QgsApplication::getThemeIcon( "/mActionLink.svg" ), tr( "Link feature" ), this );
mLinkFeatureButton->addAction( linkFeatureAction );
mLinkFeatureButton->setDefaultAction( linkFeatureAction );
mLinkFeatureButton->setIcon( QgsApplication::getThemeIcon( "/mActionLink.svg" ) );
mLinkFeatureButton->setText( tr( "Link feature" ) );
buttonLayout->addWidget( mLinkFeatureButton );
// unlink feature
mUnlinkFeatureButton = new QToolButton( this );
QAction* unlinkFeatureAction = new QAction( QgsApplication::getThemeIcon( "/mActionUnlink.svg" ), tr( "Unlink feature" ), this );
mUnlinkFeatureButton->addAction( unlinkFeatureAction );
mUnlinkFeatureButton->setDefaultAction( unlinkFeatureAction );
mUnlinkFeatureButton->setIcon( QgsApplication::getThemeIcon( "/mActionUnlink.svg" ) );
mUnlinkFeatureButton->setText( tr( "Unlink feature" ) );
buttonLayout->addWidget( mUnlinkFeatureButton );
// spacer
buttonLayout->addItem( new QSpacerItem( 0, 0, QSizePolicy::Expanding ) );

0 comments on commit 69fc9bb

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