Changeset View
Changeset View
Standalone View
Standalone View
src/fileTree.cpp
Show All 15 Lines | |||||
16 | * GNU General Public License for more details. | 16 | * GNU General Public License for more details. | ||
17 | * | 17 | * | ||
18 | * You should have received a copy of the GNU General Public License | 18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
20 | ***********************************************************************/ | 20 | ***********************************************************************/ | ||
21 | 21 | | |||
22 | #include "fileTree.h" | 22 | #include "fileTree.h" | ||
23 | 23 | | |||
24 | #include <QDir> | ||||
24 | #include <QUrl> | 25 | #include <QUrl> | ||
25 | 26 | | |||
26 | QString | 27 | QString | ||
27 | File::fullPath(const Folder *root /*= 0*/) const | 28 | File::fullPath(const Folder *root /*= 0*/) const | ||
28 | { | 29 | { | ||
29 | QString path; | 30 | QString path; | ||
30 | 31 | | |||
31 | if (root == this) | 32 | if (root == this) | ||
32 | root = nullptr; //prevent returning empty string when there is something we could return | 33 | root = nullptr; //prevent returning empty string when there is something we could return | ||
33 | 34 | | |||
34 | for (const Folder *d = (Folder*)this; d != root && d; d = d->parent()) | 35 | for (const Folder *d = (Folder*)this; d != root && d; d = d->parent()) | ||
35 | path.prepend(d->name()); | 36 | path.prepend(d->name()); | ||
36 | 37 | | |||
38 | // Use QUrl to sanitize the path for display and then run it throuh | ||||
39 | // QDir to make sure we use native path seprators. | ||||
37 | const QUrl url = QUrl::fromLocalFile(path); | 40 | const QUrl url = QUrl::fromLocalFile(path); | ||
38 | return url.toDisplayString(QUrl::PreferLocalFile | QUrl::StripTrailingSlash); | 41 | const QString cleanPath = url.toDisplayString(QUrl::PreferLocalFile | QUrl::NormalizePathSegments); | ||
42 | return url.isLocalFile() ? QDir::toNativeSeparators(cleanPath) : cleanPath; | ||||
39 | } | 43 | } |