[QGIS Commit] r13079 - trunk/qgis/src/app

svn_qgis at osgeo.org svn_qgis at osgeo.org
Fri Mar 19 08:45:02 EDT 2010


Author: jef
Date: 2010-03-19 08:45:01 -0400 (Fri, 19 Mar 2010)
New Revision: 13079

Modified:
   trunk/qgis/src/app/qgsnewvectorlayerdialog.cpp
   trunk/qgis/src/app/qgsnewvectorlayerdialog.h
Log:
add sanity checks to new vector dialog and some cleanups

Modified: trunk/qgis/src/app/qgsnewvectorlayerdialog.cpp
===================================================================
--- trunk/qgis/src/app/qgsnewvectorlayerdialog.cpp	2010-03-19 12:41:06 UTC (rev 13078)
+++ trunk/qgis/src/app/qgsnewvectorlayerdialog.cpp	2010-03-19 12:45:01 UTC (rev 13079)
@@ -57,6 +57,12 @@
 
   mCrsId = srs.srsid();
   leSpatialRefSys->setText( srs.toProj4() );
+
+  connect( mNameEdit, SIGNAL( textChanged( QString ) ), this, SLOT( nameChanged( QString ) ) );
+  connect( mAttributeView, SIGNAL( itemSelectionChanged() ), this, SLOT( selectionChanged() ) );
+
+  mAddAttributeButton->setEnabled( false );
+  mRemoveAttributeButton->setEnabled( false );
 }
 
 QgsNewVectorLayerDialog::~QgsNewVectorLayerDialog()
@@ -69,23 +75,24 @@
   switch ( index )
   {
     case 0: // Text data
+      if ( mWidth->text().toInt() < 1 || mWidth->text().toInt() > 255 )
+        mWidth->setText( "80" );
+      mPrecision->setEnabled( false );
       mWidth->setValidator( new QIntValidator( 1, 255, this ) );
-      mPrecision->setEnabled( false );
       break;
 
     case 1: // Whole number
-      if ( mWidth->text().toInt() > 10 )
+      if ( mWidth->text().toInt() < 1 || mWidth->text().toInt() > 10 )
         mWidth->setText( "10" );
       mPrecision->setEnabled( false );
       mWidth->setValidator( new QIntValidator( 1, 10, this ) );
       break;
 
     case 2: // Decimal number
-      if ( mWidth->text().toInt() > 20 )
+      if ( mWidth->text().toInt() < 1 || mWidth->text().toInt() > 20 )
         mWidth->setText( "20" );
-      mPrecision->setEnabled( false );
+      mPrecision->setEnabled( true );
       mWidth->setValidator( new QIntValidator( 1, 20, this ) );
-      mPrecision->setEnabled( true );
       break;
 
     default:
@@ -176,3 +183,13 @@
   QString myType = mFileFormatComboBox->itemData( mFileFormatComboBox->currentIndex(), Qt::UserRole ).toString();
   return myType;
 }
+
+void QgsNewVectorLayerDialog::nameChanged( QString name )
+{
+  mAddAttributeButton->setDisabled( name.isEmpty() || mAttributeView->findItems( name, Qt::MatchExactly ).size() > 0 );
+}
+
+void QgsNewVectorLayerDialog::selectionChanged()
+{
+  mRemoveAttributeButton->setDisabled( mAttributeView->selectedItems().size() == 0 );
+}

Modified: trunk/qgis/src/app/qgsnewvectorlayerdialog.h
===================================================================
--- trunk/qgis/src/app/qgsnewvectorlayerdialog.h	2010-03-19 12:41:06 UTC (rev 13078)
+++ trunk/qgis/src/app/qgsnewvectorlayerdialog.h	2010-03-19 12:45:01 UTC (rev 13079)
@@ -46,6 +46,8 @@
     void on_mTypeBox_currentIndexChanged( int index );
     void on_pbnChangeSpatialRefSys_clicked();
     void on_buttonBox_helpRequested() { QgsContextHelp::run( metaObject()->className() ); }
+    void nameChanged( QString );
+    void selectionChanged();
 
   private:
     QPushButton *mOkButton;



More information about the QGIS-commit mailing list