Mercurial > octave-libgccjit
comparison libgui/src/dialog.cc @ 18607:40dce9423baa gui-release
uigetdir: return correct path name (Bug #42004)
* libgui/src/dialog.cc
(FileDialog::accept): When in dir mode, get the full path name from the selected file.
author | John Donoghue <john.donoghue@ieee.org> |
---|---|
date | Sun, 30 Mar 2014 20:18:18 -0400 |
parents | 187f3a3429e1 |
children |
comparison
equal
deleted
inserted
replaced
18604:400f48e9e8cb | 18607:40dce9423baa |
---|---|
483 QString path; | 483 QString path; |
484 int idx = 1; | 484 int idx = 1; |
485 | 485 |
486 string_result = selectedFiles (); | 486 string_result = selectedFiles (); |
487 | 487 |
488 if (testOption (QFileDialog::ShowDirsOnly) == true && | |
489 string_result.size () > 0) | |
490 { | |
491 path = string_result[0]; | |
492 } | |
493 else | |
494 { | |
495 path = directory ().absolutePath (); | |
496 } | |
497 | |
488 // Matlab expects just the file name, whereas the file dialog gave us | 498 // Matlab expects just the file name, whereas the file dialog gave us |
489 // pull path names, so fix it. | 499 // full path names, so fix it. |
490 | 500 |
491 for (int i = 0; i < string_result.size (); i++) | 501 for (int i = 0; i < string_result.size (); i++) |
492 string_result[i] = QFileInfo (string_result[i]).fileName (); | 502 string_result[i] = QFileInfo (string_result[i]).fileName (); |
493 | |
494 path = directory ().absolutePath (); | |
495 | 503 |
496 // if not showing only dirs, add end slash for the path component | 504 // if not showing only dirs, add end slash for the path component |
497 if (testOption (QFileDialog::ShowDirsOnly) == false) | 505 if (testOption (QFileDialog::ShowDirsOnly) == false) |
498 path = path + "/"; | 506 path = path + "/"; |
499 else | |
500 { | |
501 // if name was provided in uigetdir, add to path | |
502 if (string_result.size() > 0) | |
503 path = path + "/" + string_result[0]; | |
504 } | |
505 | 507 |
506 // convert to native slashes | 508 // convert to native slashes |
507 path = QDir::toNativeSeparators (path); | 509 path = QDir::toNativeSeparators (path); |
508 | 510 |
509 QStringList name_filters = nameFilters (); | 511 QStringList name_filters = nameFilters (); |