|
| 1 | +/*************************************************************************** |
| 2 | + qgsrelationadddlg.cpp - QgsRelationAddDlg |
| 3 | + --------------------------------- |
| 4 | +
|
| 5 | + begin : 4.10.2013 |
| 6 | + copyright : (C) 2013 by Matthias Kuhn |
| 7 | + email : matthias@opengis.ch |
| 8 | + *************************************************************************** |
| 9 | + * * |
| 10 | + * This program is free software; you can redistribute it and/or modify * |
| 11 | + * it under the terms of the GNU General Public License as published by * |
| 12 | + * the Free Software Foundation; either version 2 of the License, or * |
| 13 | + * (at your option) any later version. * |
| 14 | + * * |
| 15 | + ***************************************************************************/ |
| 16 | + |
1 | 17 | #include "qgsrelationadddlg.h"
|
2 | 18 | #include "qgsvectorlayer.h"
|
3 | 19 |
|
| 20 | +#include <QPushButton> |
| 21 | + |
4 | 22 | QgsRelationAddDlg::QgsRelationAddDlg( QWidget *parent )
|
5 | 23 | : QDialog( parent )
|
6 | 24 | {
|
7 | 25 | setupUi( this );
|
8 | 26 |
|
9 | 27 | mTxtRelationId->setPlaceholderText( tr( "[Generated automatically]" ) );
|
| 28 | + checkDefinitionValid(); |
| 29 | + |
| 30 | + connect( mCbxReferencingLayer, SIGNAL( currentIndexChanged( int ) ), this, SLOT( checkDefinitionValid() ) ); |
| 31 | + connect( mCbxReferencingField, SIGNAL( currentIndexChanged( int ) ), this, SLOT( checkDefinitionValid() ) ); |
| 32 | + connect( mCbxReferencedLayer, SIGNAL( currentIndexChanged( int ) ), this, SLOT( checkDefinitionValid() ) ); |
| 33 | + connect( mCbxReferencedField, SIGNAL( currentIndexChanged( int ) ), this, SLOT( checkDefinitionValid() ) ); |
10 | 34 | }
|
11 | 35 |
|
12 | 36 | void QgsRelationAddDlg::addLayers( const QList< QgsVectorLayer* >& layers )
|
@@ -65,6 +89,14 @@ void QgsRelationAddDlg::on_mCbxReferencedLayer_currentIndexChanged( int index )
|
65 | 89 | loadLayerAttributes( mCbxReferencedField, mLayers[mCbxReferencedLayer->itemData( index ).toString()] );
|
66 | 90 | }
|
67 | 91 |
|
| 92 | +void QgsRelationAddDlg::checkDefinitionValid() |
| 93 | +{ |
| 94 | + mButtonBox->button( QDialogButtonBox::Ok )->setEnabled( mCbxReferencedLayer->currentIndex() != -1 |
| 95 | + && mCbxReferencedField->currentIndex() != -1 |
| 96 | + && mCbxReferencingLayer->currentIndex() != -1 |
| 97 | + && mCbxReferencingField->currentIndex() != -1 ); |
| 98 | +} |
| 99 | + |
68 | 100 | void QgsRelationAddDlg::loadLayerAttributes( QComboBox* cbx, QgsVectorLayer* layer )
|
69 | 101 | {
|
70 | 102 | cbx->clear();
|
|
0 commit comments