Bug 145822 - Dirfile datasource opens the file dialog one folder too deep
Summary: Dirfile datasource opens the file dialog one folder too deep
Status: RESOLVED FIXED
Alias: None
Product: kst
Classification: Applications
Component: general (show other bugs)
Version: 1.4.0
Platform: Compiled Sources Linux
: NOR wishlist
Target Milestone: ---
Assignee: kst
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-05-22 22:38 UTC by Andrew Walker
Modified: 2007-06-29 02:03 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Walker 2007-05-22 22:38:47 UTC
Version:           1.4.0 (using KDE KDE 3.5.1)
Installed from:    Compiled From Sources
OS:                Linux

In the first page of the data wizard and in the New Vector dialog 
(when the user has a dirfile folder selected) clicking on the folder 
button will open the file dialog inside the dirfile folder. 

It would be better if the file dialog was opened to the folder that
contains the dirfile folder. This is almost certainly what the user
wants (as they should not be looking into the strucuture of a dirfile
folder) and it removes an additional mouse click as the user is forced
to navigate back to the parent folder.
Comment 1 Andrew Walker 2007-05-24 19:02:41 UTC
This also applies to the new matrix dialog.
Comment 2 Andrew Walker 2007-06-29 02:03:22 UTC
SVN commit 681452 by arwalker:

BUG:145822 Open the file dialog at the correct level for folder based datasources

 M  +27 -0     kstdatawizard_i.cpp  
 M  +2 -0      kstdatawizard_i.h  
 M  +26 -0     kstmatrixdialog_i.cpp  
 M  +3 -1      kstmatrixdialog_i.h  
 M  +26 -0     kstvectordialog_i.cpp  
 M  +3 -1      kstvectordialog_i.h  


--- branches/work/kst/1.5/kst/src/libkstapp/kstdatawizard_i.cpp #681451:681452
@@ -26,8 +26,10 @@
 #include <qregexp.h>
 #include <qspinbox.h>
 #include <qstring.h>
+#include <qtimer.h>
 #include <qtooltip.h>
 
+#include <kfiledialog.h>
 #include <kiconloader.h>
 #include <kmessagebox.h>
 #include <knuminput.h>
@@ -81,6 +83,7 @@
   _vectors->setSorting(1);
   _vectorsToPlot->setSorting(-1);
 
+  connect(_url, SIGNAL(openFileDialog(KURLRequester *)), this, SLOT(selectFolder()));
   connect(_cycleThrough, SIGNAL(toggled(bool)), _plotNumber, SLOT(setEnabled(bool)));
   connect(_existingPlot, SIGNAL(toggled(bool)), _existingPlotName, SLOT(setEnabled(bool)));
   connect(_existingWindow, SIGNAL(toggled(bool)), _windowName, SLOT(setEnabled(bool)));
@@ -168,6 +171,30 @@
 }
 
 
+void KstDataWizard::selectingFolder()
+{
+  QString strFolder = _url->url();
+  KFileDialog *fileDlg = _url->fileDialog();
+  QFileInfo fileInfo(strFolder);
+
+  if (fileDlg) {
+    if (fileInfo.isDir()) {
+      QDir dir(strFolder);
+
+      if (dir.cdUp()) {
+        fileDlg->setURL(KURL(dir.absPath()));
+      }
+    }
+  }
+}
+
+
+void KstDataWizard::selectFolder()
+{
+  QTimer::singleShot(0, this, SLOT(selectingFolder()));
+}
+
+
 void KstDataWizard::setInput(const QString& input)
 {
   _url->setURL(input);
--- branches/work/kst/1.5/kst/src/libkstapp/kstdatawizard_i.h #681451:681452
@@ -40,6 +40,8 @@
     void loadSettings();
 
   public slots:
+    void selectFolder();
+    void selectingFolder();
     void setInput( const QString &input );
     void plotColsChanged();
     void xChanged();
--- branches/work/kst/1.5/kst/src/libkstapp/kstmatrixdialog_i.cpp #681451:681452
@@ -27,6 +27,7 @@
 
 // include files for KDE
 #include <kcombobox.h>
+#include <kfiledialog.h>
 #include <kmessagebox.h>
 #include <kurlcompletion.h>
 #include <kurlrequester.h>
@@ -66,6 +67,7 @@
   connect(_w->_doSkip, SIGNAL(clicked()), this, SLOT(updateEnables()));
 
   _w->_fileName->setMode(KFile::File | KFile::Directory | KFile::ExistingOnly);
+  connect(_w->_fileName, SIGNAL(openFileDialog(KURLRequester *)), this, SLOT(selectFolder()));
   connect(_w->_fileName, SIGNAL(textChanged(const QString&)), this, SLOT(updateCompletion()));
   connect(_w->_configure, SIGNAL(clicked()), this, SLOT(configureSource()));
   connect(_w->_readFromSource, SIGNAL(clicked()), this, SLOT(enableSource()));
@@ -98,6 +100,30 @@
 }
 
 
+void KstMatrixDialogI::selectingFolder()
+{
+  QString strFolder = _w->_fileName->url();
+  KFileDialog *fileDlg = _w->_fileName->fileDialog();
+  QFileInfo fileInfo(strFolder);
+
+  if (fileDlg) {
+    if (fileInfo.isDir()) {
+      QDir dir(strFolder);
+
+      if (dir.cdUp()) {
+        fileDlg->setURL(KURL(dir.absPath()));
+      }
+    }
+  }
+}
+
+
+void KstMatrixDialogI::selectFolder()
+{
+  QTimer::singleShot(0, this, SLOT(selectingFolder()));
+}
+
+
 void KstMatrixDialogI::updateWindow() {
 }
 
--- branches/work/kst/1.5/kst/src/libkstapp/kstmatrixdialog_i.h #681451:681452
@@ -36,8 +36,10 @@
   protected:
     QString editTitle() { return tr("Edit Matrix"); }
     QString newTitle() { return tr("New Matrix"); }
- 
+
   public slots:
+    void selectFolder();
+    void selectingFolder();
     void update();
     void updateWindow();
     void updateCompletion();
--- branches/work/kst/1.5/kst/src/libkstapp/kstvectordialog_i.cpp #681451:681452
@@ -26,6 +26,7 @@
 #include <qvbox.h>
 
 #include <kdialogbase.h>
+#include <kfiledialog.h>
 #include <klineedit.h>
 #include <klocale.h>
 #include <kmessagebox.h>
@@ -68,6 +69,7 @@
   _w->FileName->completionObject()->setDir(QDir::currentDirPath());
 
   _w->FileName->setMode(KFile::File | KFile::Directory | KFile::ExistingOnly);
+  connect(_w->FileName, SIGNAL(openFileDialog(KURLRequester *)), this, SLOT(selectFolder()));
   connect(_w->FileName, SIGNAL(textChanged(const QString&)), this, SLOT(updateCompletion()));
   connect(_w->_configure, SIGNAL(clicked()), this, SLOT(configureSource()));
   connect(_w->_readFromSource, SIGNAL(clicked()), this, SLOT(enableSource()));
@@ -98,6 +100,30 @@
 }
 
 
+void KstVectorDialogI::selectingFolder()
+{
+  QString strFolder = _w->FileName->url();
+  KFileDialog *fileDlg = _w->FileName->fileDialog();
+  QFileInfo fileInfo(strFolder);
+
+  if (fileDlg) {
+    if (fileInfo.isDir()) {
+      QDir dir(strFolder);
+
+      if (dir.cdUp()) {
+        fileDlg->setURL(KURL(dir.absPath()));
+      }
+    }
+  }
+}
+
+
+void KstVectorDialogI::selectFolder()
+{
+  QTimer::singleShot(0, this, SLOT(selectingFolder()));
+}
+
+
 void KstVectorDialogI::testURL() {
   _inTest = true;
   updateCompletion();
--- branches/work/kst/1.5/kst/src/libkstapp/kstvectordialog_i.h #681451:681452
@@ -34,8 +34,10 @@
   protected:
     QString editTitle() { return tr("Edit Vector"); }
     QString newTitle() { return tr("New Vector"); }
- 
+
   public slots:
+    void selectFolder();
+    void selectingFolder();
     bool newObject();
     bool editObject();
     void populateEditMultiple();