Skip to content
Permalink
Browse files

Remove Apply button from new spatialite layer dialog,

activate add and remove attribute buttons only when appropriate
  • Loading branch information
brushtyler committed Jan 13, 2012
1 parent b186f83 commit ca6cd81f3c2a47343b606d69652b0e3696fcc5d3
@@ -66,12 +66,8 @@ QgsNewSpatialiteLayerDialog::QgsNewSpatialiteLayerDialog( QWidget *parent, Qt::W
}
settings.endGroup();

buttonBox->button( QDialogButtonBox::Ok )->setEnabled( false );
buttonBox->button( QDialogButtonBox::Apply )->setEnabled( false );

connect( buttonBox->button( QDialogButtonBox::Apply ), SIGNAL( clicked() ), this, SLOT( apply() ) );

buttonBox->button( QDialogButtonBox::Ok )->setDefault( true );
mOkButton = buttonBox->button( QDialogButtonBox::Ok );
mOkButton->setEnabled( false );

// Set the SRID box to a default of WGS84
QgsCoordinateReferenceSystem srs;
@@ -81,6 +77,12 @@ QgsNewSpatialiteLayerDialog::QgsNewSpatialiteLayerDialog( QWidget *parent, Qt::W
leSRID->setText( srs.authid() + " - " + srs.description() );

pbnFindSRID->setEnabled( mDatabaseComboBox->count() );

connect( mNameEdit, SIGNAL( textChanged( QString ) ), this, SLOT( nameChanged( QString ) ) );
connect( mAttributeView, SIGNAL( itemSelectionChanged() ), this, SLOT( selectionChanged() ) );

mAddAttributeButton->setEnabled( false );
mRemoveAttributeButton->setEnabled( false );
}

QgsNewSpatialiteLayerDialog::~QgsNewSpatialiteLayerDialog()
@@ -154,8 +156,7 @@ void QgsNewSpatialiteLayerDialog::on_leLayerName_textChanged( QString text )
{
Q_UNUSED( text );
bool created = leLayerName->text().length() > 0 && mAttributeView->topLevelItemCount() > 0 && createDb();
buttonBox->button( QDialogButtonBox::Ok )->setEnabled( created );
buttonBox->button( QDialogButtonBox::Apply )->setEnabled( created );
mOkButton->setEnabled( created );
}

void QgsNewSpatialiteLayerDialog::on_mAddAttributeButton_clicked()
@@ -169,8 +170,7 @@ void QgsNewSpatialiteLayerDialog::on_mAddAttributeButton_clicked()
if ( mAttributeView->topLevelItemCount() > 0 && leLayerName->text().length() > 0 )
{
bool created = createDb();
buttonBox->button( QDialogButtonBox::Ok )->setEnabled( created );
buttonBox->button( QDialogButtonBox::Apply )->setEnabled( created );
mOkButton->setEnabled( created );
}
mNameEdit->clear();
}
@@ -181,8 +181,7 @@ void QgsNewSpatialiteLayerDialog::on_mRemoveAttributeButton_clicked()
delete mAttributeView->currentItem();
if ( mAttributeView->topLevelItemCount() == 0 )
{
buttonBox->button( QDialogButtonBox::Ok )->setEnabled( false );
buttonBox->button( QDialogButtonBox::Apply )->setEnabled( false );
mOkButton->setEnabled( false );
}
}

@@ -251,6 +250,16 @@ void QgsNewSpatialiteLayerDialog::on_pbnFindSRID_clicked()
delete mySelector;
}

void QgsNewSpatialiteLayerDialog::nameChanged( QString name )
{
mAddAttributeButton->setDisabled( name.isEmpty() || mAttributeView->findItems( name, Qt::MatchExactly ).size() > 0 );
}

void QgsNewSpatialiteLayerDialog::selectionChanged()
{
mRemoveAttributeButton->setDisabled( mAttributeView->selectedItems().size() == 0 );
}

bool QgsNewSpatialiteLayerDialog::createDb()
{
QString dbPath = mDatabaseComboBox->currentText();
@@ -44,23 +44,26 @@ class QgsNewSpatialiteLayerDialog: public QDialog, private Ui::QgsNewSpatialiteL
void on_pbnFindSRID_clicked();
void on_leLayerName_textChanged( QString text );
void on_toolButtonNewDatabase_clicked();
void nameChanged( QString );
void selectionChanged();

void on_buttonBox_helpRequested() { QgsContextHelp::run( metaObject()->className() ); }
void on_buttonBox_accepted();
void on_buttonBox_rejected();

bool apply();

private:
/**Returns the selected geometry type*/
QString selectedType() const;

/** Create a new database */
bool createDb();

bool apply();

static QString quotedIdentifier( QString id );
static QString quotedValue( QString value );

QPushButton *mOkButton;
int mCrsId;
};

@@ -45,7 +45,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>410</width>
<width>430</width>
<height>574</height>
</rect>
</property>
@@ -421,7 +421,7 @@
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
@@ -449,22 +449,6 @@
</tabstops>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>QgsNewSpatialiteLayerDialogBase</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>364</x>
<y>585</y>
</hint>
<hint type="destinationlabel">
<x>387</x>
<y>304</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>

0 comments on commit ca6cd81

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