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

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sun Sep 7 04:59:28 EDT 2008


Author: jef
Date: 2008-09-07 04:59:28 -0400 (Sun, 07 Sep 2008)
New Revision: 9276

Modified:
   trunk/qgis/src/app/qgsattributedialog.cpp
   trunk/qgis/src/app/qgsattributedialog.h
   trunk/qgis/src/app/qgsvectorlayerproperties.cpp
   trunk/qgis/src/core/qgsvectorlayer.h
Log:
add file selection to attribute dialog

Modified: trunk/qgis/src/app/qgsattributedialog.cpp
===================================================================
--- trunk/qgis/src/app/qgsattributedialog.cpp	2008-09-07 07:54:07 UTC (rev 9275)
+++ trunk/qgis/src/app/qgsattributedialog.cpp	2008-09-07 08:59:28 UTC (rev 9276)
@@ -35,6 +35,9 @@
 #include <QSlider>
 #include <QSpinBox>
 #include <QDoubleSpinBox>
+#include <QPushButton>
+#include <QHBoxLayout>
+#include <QFileDialog>
 
 QgsAttributeDialog::QgsAttributeDialog( QgsVectorLayer *vl, QgsFeature *thepFeature )
     : QDialog(),
@@ -245,6 +248,22 @@
         myWidget = le;
       }
       break;
+
+      case QgsVectorLayer::FileName:
+      {
+        QLineEdit *le = new QLineEdit( myFieldValue.toString() );
+
+        QPushButton *pb = new QPushButton( tr("...") );
+        connect(pb, SIGNAL(clicked()), this, SLOT(selectFileName()));
+
+        QHBoxLayout *hbl = new QHBoxLayout();
+        hbl->addWidget(le);
+        hbl->addWidget(pb);
+
+        myWidget = new QWidget;
+        myWidget->setLayout(hbl);
+      }
+      break;
     }
 
     if ( myFieldType == QVariant::Int )
@@ -274,6 +293,27 @@
   saveGeometry();
 }
 
+void QgsAttributeDialog::selectFileName()
+{
+  QPushButton *pb = dynamic_cast<QPushButton *>( sender() );
+  if(!pb)
+    return;
+
+  QWidget *hbox = dynamic_cast<QWidget *>( pb->parent() );
+  if(!hbox)
+    return;
+
+  QLineEdit *le = hbox->findChild<QLineEdit *>();
+  if(!le)
+    return;
+
+  QString fileName = QFileDialog::getOpenFileName(0 , tr("Select a file"));
+  if(fileName.isNull())
+    return;
+
+  le->setText(fileName);
+}
+
 void QgsAttributeDialog::accept()
 {
   //write the new values back to the feature
@@ -328,6 +368,12 @@
       myFieldValue = QString::number( dsb->value() );
     }
 
+    le = mpWidgets.value( myIndex )->findChild<QLineEdit *>("lineEdit");
+    if(le)
+    {
+      myFieldValue = le->text();
+    }
+
     switch ( theField.type() )
     {
       case QVariant::Int:

Modified: trunk/qgis/src/app/qgsattributedialog.h
===================================================================
--- trunk/qgis/src/app/qgsattributedialog.h	2008-09-07 07:54:07 UTC (rev 9275)
+++ trunk/qgis/src/app/qgsattributedialog.h	2008-09-07 08:59:28 UTC (rev 9276)
@@ -50,6 +50,9 @@
      */
     void restoreGeometry();
 
+  public slots:
+    void selectFileName();
+
   private:
     QString mSettingsPath;
     QList<QWidget *> mpWidgets;

Modified: trunk/qgis/src/app/qgsvectorlayerproperties.cpp
===================================================================
--- trunk/qgis/src/app/qgsvectorlayerproperties.cpp	2008-09-07 07:54:07 UTC (rev 9275)
+++ trunk/qgis/src/app/qgsvectorlayerproperties.cpp	2008-09-07 08:59:28 UTC (rev 9276)
@@ -168,6 +168,7 @@
   cb->addItem( tr( "classification" ), QgsVectorLayer::Classification );
   cb->addItem( tr( "range (editable)" ), QgsVectorLayer::EditRange );
   cb->addItem( tr( "range (slider)" ), QgsVectorLayer::SliderRange );
+  cb->addItem( tr( "file name" ), QgsVectorLayer::FileName );
   cb->setSizeAdjustPolicy( QComboBox::AdjustToContentsOnFirstShow );
   cb->setCurrentIndex( layer->editType( idx ) );
 

Modified: trunk/qgis/src/core/qgsvectorlayer.h
===================================================================
--- trunk/qgis/src/core/qgsvectorlayer.h	2008-09-07 07:54:07 UTC (rev 9275)
+++ trunk/qgis/src/core/qgsvectorlayer.h	2008-09-07 08:59:28 UTC (rev 9276)
@@ -67,7 +67,8 @@
       ValueMap,
       Classification,
       EditRange,
-      SliderRange
+      SliderRange,
+      FileName
     };
 
     struct RangeData



More information about the QGIS-commit mailing list