|
24 | 24 | #include "qgsfieldcombobox.h" |
25 | 25 |
|
26 | 26 | #include <QStandardItemModel> |
| 27 | +#include <QPushButton> |
27 | 28 |
|
28 | 29 | QgsJoinDialog::QgsJoinDialog( QgsVectorLayer* layer, QList<QgsMapLayer*> alreadyJoinedLayers, QWidget * parent, Qt::WindowFlags f ) |
29 | 30 | : QDialog( parent, f ) |
@@ -53,6 +54,12 @@ QgsJoinDialog::QgsJoinDialog( QgsVectorLayer* layer, QList<QgsMapLayer*> already |
53 | 54 | mJoinFieldComboBox->setLayer( joinLayer ); |
54 | 55 | joinedLayerChanged( joinLayer ); |
55 | 56 | } |
| 57 | + |
| 58 | + connect( mJoinLayerComboBox, SIGNAL( layerChanged( QgsMapLayer* ) ), this, SLOT( checkDefinitionValid() ) ); |
| 59 | + connect( mJoinFieldComboBox, SIGNAL( fieldChanged( QString ) ), this, SLOT( checkDefinitionValid() ) ); |
| 60 | + connect( mTargetFieldComboBox, SIGNAL( fieldChanged( QString ) ), this, SLOT( checkDefinitionValid() ) ); |
| 61 | + |
| 62 | + checkDefinitionValid(); |
56 | 63 | } |
57 | 64 |
|
58 | 65 | QgsJoinDialog::~QgsJoinDialog() |
@@ -98,7 +105,8 @@ void QgsJoinDialog::setJoinInfo( const QgsVectorJoinInfo& joinInfo ) |
98 | 105 | QgsVectorJoinInfo QgsJoinDialog::joinInfo() const |
99 | 106 | { |
100 | 107 | QgsVectorJoinInfo info; |
101 | | - info.joinLayerId = mJoinLayerComboBox->currentLayer()->id(); |
| 108 | + if ( mJoinLayerComboBox->currentLayer() ) |
| 109 | + info.joinLayerId = mJoinLayerComboBox->currentLayer()->id(); |
102 | 110 | info.joinFieldName = mJoinFieldComboBox->currentField(); |
103 | 111 | info.targetFieldName = mTargetFieldComboBox->currentField(); |
104 | 112 | info.memoryCache = mCacheInMemoryCheckBox->isChecked(); |
@@ -173,3 +181,10 @@ void QgsJoinDialog::joinedLayerChanged( QgsMapLayer* layer ) |
173 | 181 | mCustomPrefix->setText( layer->name() + '_' ); |
174 | 182 | } |
175 | 183 | } |
| 184 | + |
| 185 | +void QgsJoinDialog::checkDefinitionValid() |
| 186 | +{ |
| 187 | + buttonBox->button( QDialogButtonBox::Ok )->setEnabled( mJoinLayerComboBox->currentIndex() != -1 |
| 188 | + && mJoinFieldComboBox->currentIndex() != -1 |
| 189 | + && mTargetFieldComboBox->currentIndex() != -1 ); |
| 190 | +} |
0 commit comments