[QGIS Commit] r9386 - in trunk/external_plugins/cdp2/src: gui ui

svn_qgis at osgeo.org svn_qgis at osgeo.org
Tue Sep 23 08:58:08 EDT 2008


Author: timlinux
Date: 2008-09-23 08:58:08 -0400 (Tue, 23 Sep 2008)
New Revision: 9386

Modified:
   trunk/external_plugins/cdp2/src/gui/climatedataprocessorgui.cpp
   trunk/external_plugins/cdp2/src/gui/climatedataprocessorgui.h
   trunk/external_plugins/cdp2/src/ui/climatedataprocessorguibase.ui
Log:
Added generic methods for getting a file and a dir

Modified: trunk/external_plugins/cdp2/src/gui/climatedataprocessorgui.cpp
===================================================================
--- trunk/external_plugins/cdp2/src/gui/climatedataprocessorgui.cpp	2008-09-23 12:38:39 UTC (rev 9385)
+++ trunk/external_plugins/cdp2/src/gui/climatedataprocessorgui.cpp	2008-09-23 12:58:08 UTC (rev 9386)
@@ -50,35 +50,25 @@
   done(1);
 }
 
-void ClimateDataProcessorGui::on_pbnSelectFile_clicked()
+QString ClimateDataProcessorGui::getFileName(QString theDefaultFile, QString theMessage)
 {
-  /**
-  QSettings mySettings;
-  QString myBaseDir = mySettings.value("climateconverter/inputLayersDirectory","/tmp").toString(); //initial dir
-  QStringList myFileNameQStringList = QFileDialog::getOpenFileNames(
-                                        this,
-                                        "Select one or more files",
-                                        myBaseDir, //initial dir
-                                        "Climate Climate Data (*.asc *.mea *.dat)"  //filters to select
-                                      );
-  lstInputFiles->addItems(myFileNameQStringList);
-  QFileInfo myFileInfo(myFileNameQStringList.at(0));
-  QString myBaseString = myFileInfo.dir().path()+QString("/");
-  mySettings.setValue("climateconverter/inputLayersDirectory",myBaseString);
-  */
+  QString myFileName = QFileDialog::getOpenFileName(
+      this,
+      theMessage , //caption
+      QFileInfo(theDefaultFile).absolutePath(), //initial dir
+      "Climate Climate Data (*.asc *.mea *.dat)"  //filters to select
+    );
+  return (myFileName);
 }
 
-void ClimateDataProcessorGui::on_pbnSelectDir_clicked()
+QString ClimateDataProcessorGui::getDirName(QString theDefaultDir, QString theMessage)
 {
-  /**
-  QString myDir = QFileDialog::getExistingDirectory(
-                    this,
-                    "Choose a directory",
-                    mLastDir);
-
-  mLastDir = myDir;
-  leOutputDir->setText(myDir);
-  */
+  QString myFileName = QFileDialog::getExistingDirectory(
+      this,
+      theMessage , //caption
+      theDefaultDir //initial dir
+    );
+  return (myFileName);
 }
 
 void ClimateDataProcessorGui::on_pbnProcess_clicked()
@@ -146,7 +136,12 @@
 
 void ClimateDataProcessorGui::on_pbnMeanTemp_clicked()
 {
-  leMeanTemp->setText("hello world");
+  QString myFileName = 
+    getFileName(leMeanTemp->text(), tr("Choose the mean temp file"));
+  if (!myFileName.isEmpty())
+  {
+    leMeanTemp->setText(myFileName);
+  }
 }
 void ClimateDataProcessorGui::on_pbnMinTemp_clicked()
 {

Modified: trunk/external_plugins/cdp2/src/gui/climatedataprocessorgui.h
===================================================================
--- trunk/external_plugins/cdp2/src/gui/climatedataprocessorgui.h	2008-09-23 12:38:39 UTC (rev 9385)
+++ trunk/external_plugins/cdp2/src/gui/climatedataprocessorgui.h	2008-09-23 12:58:08 UTC (rev 9386)
@@ -69,8 +69,23 @@
   *
   */
   void accept();
-  void on_pbnSelectFile_clicked();
-  void on_pbnSelectDir_clicked();
+  
+  /** Helper method to generically get a file name.
+   * @param theDefaultFile - default file used as a basis for path location
+   * @param theMessage - a prompt message to use when asking for the file name
+   * @return QString - containing the users selected filename or empty 
+   *                  if the user cancelled.
+   */
+  QString getFileName(QString theDefaultFile, QString theMessage);
+
+  /** Helper method to generically get a directory.
+   * @param theDefaultFile - default file used as a basis for path location
+   * @param theMessage - a prompt message to use when asking for the dir
+   * @return QString - containing the users selected dir or empty 
+   *                  if the user cancelled.
+   */
+  QString getDirName(QString theDefaultDir, QString theMessage);
+
   /** Runs when process button is pressed.
   * Does not close the form afterwards.
   */

Modified: trunk/external_plugins/cdp2/src/ui/climatedataprocessorguibase.ui
===================================================================
--- trunk/external_plugins/cdp2/src/ui/climatedataprocessorguibase.ui	2008-09-23 12:38:39 UTC (rev 9385)
+++ trunk/external_plugins/cdp2/src/ui/climatedataprocessorguibase.ui	2008-09-23 12:58:08 UTC (rev 9386)
@@ -349,20 +349,63 @@
  <layoutdefault spacing="6" margin="11" />
  <tabstops>
   <tabstop>leMeanTemp</tabstop>
+  <tabstop>pbnMeanTemp</tabstop>
   <tabstop>leMinTemp</tabstop>
+  <tabstop>pbnMinTemp</tabstop>
   <tabstop>leMaxTemp</tabstop>
+  <tabstop>pbnMaxTemp</tabstop>
   <tabstop>leDiurnalTemp</tabstop>
+  <tabstop>pbnDiurnalTemp</tabstop>
   <tabstop>leMeanPrecipitation</tabstop>
+  <tabstop>pbnMeanPrecipitation</tabstop>
   <tabstop>leFrostDays</tabstop>
+  <tabstop>pbnFrostDays</tabstop>
   <tabstop>leTotalSolarRadiation</tabstop>
+  <tabstop>pbnTotalSolarRad</tabstop>
+  <tabstop>lstVariablesToCalc</tabstop>
   <tabstop>cbxSelectAllVars</tabstop>
   <tabstop>cboOutputFormat</tabstop>
   <tabstop>leOutputPath</tabstop>
+  <tabstop>pbnOutputPath</tabstop>
   <tabstop>cbxSwitchMeridian</tabstop>
   <tabstop>cbxPseudoColour</tabstop>
+  <tabstop>buttonBox</tabstop>
  </tabstops>
  <resources>
   <include location="../resources/resources.qrc" />
  </resources>
- <connections/>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>ClimateDataProcessorGuiBase</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel" >
+     <x>444</x>
+     <y>668</y>
+    </hint>
+    <hint type="destinationlabel" >
+     <x>582</x>
+     <y>621</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>rejected()</signal>
+   <receiver>ClimateDataProcessorGuiBase</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel" >
+     <x>538</x>
+     <y>677</y>
+    </hint>
+    <hint type="destinationlabel" >
+     <x>582</x>
+     <y>663</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
 </ui>



More information about the QGIS-commit mailing list