[QGIS Commit] r13311 - in trunk/qgis/src: app app/attributetable core

svn_qgis at osgeo.org svn_qgis at osgeo.org
Wed Apr 14 12:50:56 EDT 2010


Author: jef
Date: 2010-04-14 12:50:56 -0400 (Wed, 14 Apr 2010)
New Revision: 13311

Modified:
   trunk/qgis/src/app/attributetable/qgsattributetabledialog.cpp
   trunk/qgis/src/app/qgsaddattrdialog.cpp
   trunk/qgis/src/app/qgsaddattrdialog.h
   trunk/qgis/src/app/qgsidentifyresults.cpp
   trunk/qgis/src/app/qgsvectorlayerproperties.cpp
   trunk/qgis/src/core/qgsvectorlayer.cpp
Log:
implement #2650, #2651, #2652

Modified: trunk/qgis/src/app/attributetable/qgsattributetabledialog.cpp
===================================================================
--- trunk/qgis/src/app/attributetable/qgsattributetabledialog.cpp	2010-04-14 16:47:16 UTC (rev 13310)
+++ trunk/qgis/src/app/attributetable/qgsattributetabledialog.cpp	2010-04-14 16:50:56 UTC (rev 13311)
@@ -250,16 +250,19 @@
 
 void QgsAttributeTableDialog::columnBoxInit()
 {
-  QgsFieldMap fieldMap = mLayer->dataProvider()->fields();
+  QgsFieldMap fieldMap = mLayer->pendingFields();
   QgsFieldMap::Iterator it = fieldMap.begin();
 
   for ( ; it != fieldMap.end(); ++it )
-    mColumnBox->addItem( it.value().name() );
+    if ( mLayer->editType( it.key() ) != QgsVectorLayer::Hidden )
+      mColumnBox->addItem( it.value().name() );
+
+  mColumnBox->setCurrentIndex( mColumnBox->findText( mLayer->displayField() ) );
 }
 
 int QgsAttributeTableDialog::columnBoxColumnId()
 {
-  QgsFieldMap fieldMap = mLayer->dataProvider()->fields();
+  QgsFieldMap fieldMap = mLayer->pendingFields();
   QgsFieldMap::Iterator it = fieldMap.begin();
 
   for ( ; it != fieldMap.end(); ++it )
@@ -594,8 +597,8 @@
 
   QString str = mColumnBox->currentText();
 
-  const QgsFieldMap& flds = mLayer->dataProvider()->fields();
-  int fldIndex = mLayer->dataProvider()->fieldNameIndex( str );
+  const QgsFieldMap& flds = mLayer->pendingFields();
+  int fldIndex = mLayer->fieldNameIndex( str );
   QVariant::Type fldType = flds[fldIndex].type();
   bool numeric = ( fldType == QVariant::Int || fldType == QVariant::Double );
 
@@ -604,7 +607,7 @@
   else
     str += " ~ '";
 
-  str += mQuery->displayText().replace("'", "''"); // escape quotes
+  str += mQuery->displayText().replace( "'", "''" ); // escape quotes
   str += "'";
 
   doSearch( str );
@@ -673,7 +676,7 @@
     return;
   }
 
-  QgsAddAttrDialog dialog( mLayer->dataProvider(), this );
+  QgsAddAttrDialog dialog( mLayer, this );
   if ( dialog.exec() == QDialog::Accepted )
   {
     mLayer->beginEditCommand( tr( "Attribute added" ) );

Modified: trunk/qgis/src/app/qgsaddattrdialog.cpp
===================================================================
--- trunk/qgis/src/app/qgsaddattrdialog.cpp	2010-04-14 16:47:16 UTC (rev 13310)
+++ trunk/qgis/src/app/qgsaddattrdialog.cpp	2010-04-14 16:50:56 UTC (rev 13311)
@@ -16,16 +16,17 @@
  ***************************************************************************/
 
 #include "qgsaddattrdialog.h"
+#include "qgsvectorlayer.h"
 #include "qgsvectordataprovider.h"
 #include "qgslogger.h"
 
-QgsAddAttrDialog::QgsAddAttrDialog( QgsVectorDataProvider* provider, QWidget *parent, Qt::WFlags fl )
-    : QDialog( parent, fl ), mDataProvider( provider )
+QgsAddAttrDialog::QgsAddAttrDialog( QgsVectorLayer *vlayer, QWidget *parent, Qt::WFlags fl )
+    : QDialog( parent, fl )
 {
   setupUi( this );
 
   //fill data types into the combo box
-  const QList< QgsVectorDataProvider::NativeType > &typelist = mDataProvider->nativeTypes();
+  const QList< QgsVectorDataProvider::NativeType > &typelist = vlayer->dataProvider()->nativeTypes();
 
   for ( int i = 0; i < typelist.size(); i++ )
   {

Modified: trunk/qgis/src/app/qgsaddattrdialog.h
===================================================================
--- trunk/qgis/src/app/qgsaddattrdialog.h	2010-04-14 16:47:16 UTC (rev 13310)
+++ trunk/qgis/src/app/qgsaddattrdialog.h	2010-04-14 16:50:56 UTC (rev 13311)
@@ -22,13 +22,13 @@
 #include "qgisgui.h"
 #include "qgsfield.h"
 
-class QgsVectorDataProvider;
+class QgsVectorLayer;
 
 class QgsAddAttrDialog: public QDialog, private Ui::QgsAddAttrDialogBase
 {
     Q_OBJECT
   public:
-    QgsAddAttrDialog( QgsVectorDataProvider* provider,
+    QgsAddAttrDialog( QgsVectorLayer *vlayer,
                       QWidget *parent = 0, Qt::WFlags fl = QgisGui::ModalDialogFlags );
     QgsAddAttrDialog( const std::list<QString>& typelist,
                       QWidget *parent = 0, Qt::WFlags fl = QgisGui::ModalDialogFlags );
@@ -38,8 +38,6 @@
   public slots:
     void on_mTypeBox_currentIndexChanged( int idx );
 
-  protected:
-    QgsVectorDataProvider* mDataProvider;
 };
 
 #endif

Modified: trunk/qgis/src/app/qgsidentifyresults.cpp
===================================================================
--- trunk/qgis/src/app/qgsidentifyresults.cpp	2010-04-14 16:47:16 UTC (rev 13310)
+++ trunk/qgis/src/app/qgsidentifyresults.cpp	2010-04-14 16:50:56 UTC (rev 13311)
@@ -822,7 +822,7 @@
 
   QgsAttributeDialog *ad = new QgsAttributeDialog( vlayer, &f );
 
-  if ( !vlayer->isEditable() && vlayer->actions()->size() > 0 )
+  if ( vlayer->actions()->size() > 0 )
   {
     ad->dialog()->setContextMenuPolicy( Qt::ActionsContextMenu );
 
@@ -841,7 +841,7 @@
       ad->dialog()->addAction( a );
       connect( a, SIGNAL( triggered() ), a, SLOT( execute() ) );
 
-      QPushButton *pb = ad->dialog()->findChild<QPushButton *>( action.name() );
+      QAbstractButton *pb = ad->dialog()->findChild<QAbstractButton *>( action.name() );
       if ( pb )
         connect( pb, SIGNAL( clicked() ), a, SLOT( execute() ) );
     }

Modified: trunk/qgis/src/app/qgsvectorlayerproperties.cpp
===================================================================
--- trunk/qgis/src/app/qgsvectorlayerproperties.cpp	2010-04-14 16:47:16 UTC (rev 13310)
+++ trunk/qgis/src/app/qgsvectorlayerproperties.cpp	2010-04-14 16:50:56 UTC (rev 13311)
@@ -315,7 +315,7 @@
 
 void QgsVectorLayerProperties::addAttribute()
 {
-  QgsAddAttrDialog dialog( layer->dataProvider(), this );
+  QgsAddAttrDialog dialog( layer, this );
   if ( dialog.exec() == QDialog::Accepted )
   {
     layer->beginEditCommand( "Attribute added" );

Modified: trunk/qgis/src/core/qgsvectorlayer.cpp
===================================================================
--- trunk/qgis/src/core/qgsvectorlayer.cpp	2010-04-14 16:47:16 UTC (rev 13310)
+++ trunk/qgis/src/core/qgsvectorlayer.cpp	2010-04-14 16:50:56 UTC (rev 13311)
@@ -21,7 +21,6 @@
  ***************************************************************************/
 /*  $Id$ */
 
-#include <cassert>
 #include <cfloat>
 #include <cstring>
 #include <climits>



More information about the QGIS-commit mailing list