Skip to content

Commit 1c4e9c6

Browse files
committed
GUI: Show native path separators.
Show native path separators in project file-dialog. Convert paths to internal separators when reading from project file and when reading from the dialog. Convert to native separators when adding to the dialog (for the user).
1 parent 2a76d5c commit 1c4e9c6

2 files changed

Lines changed: 32 additions & 11 deletions

File tree

gui/projectfile.cpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <QXmlStreamReader>
2222
#include <QXmlStreamWriter>
2323
#include <QFile>
24+
#include <QDir>
2425
#include "projectfile.h"
2526

2627
static const char ProjectElementName[] = "project";
@@ -124,7 +125,12 @@ bool ProjectFile::Read(const QString &filename)
124125

125126
QStringList ProjectFile::GetIncludeDirs() const
126127
{
127-
return mIncludeDirs;
128+
QStringList dirs;
129+
foreach(QString path, mIncludeDirs)
130+
{
131+
dirs << QDir::fromNativeSeparators(path);
132+
}
133+
return dirs;
128134
}
129135

130136
QStringList ProjectFile::GetDefines() const
@@ -134,12 +140,22 @@ QStringList ProjectFile::GetDefines() const
134140

135141
QStringList ProjectFile::GetCheckPaths() const
136142
{
137-
return mPaths;
143+
QStringList paths;
144+
foreach(QString path, mPaths)
145+
{
146+
paths << QDir::fromNativeSeparators(path);
147+
}
148+
return paths;
138149
}
139150

140151
QStringList ProjectFile::GetIgnoredPaths() const
141152
{
142-
return mIgnoredPaths;
153+
QStringList paths;
154+
foreach(QString path, mIgnoredPaths)
155+
{
156+
paths << QDir::fromNativeSeparators(path);
157+
}
158+
return paths;
143159
}
144160

145161
void ProjectFile::ReadRootPath(QXmlStreamReader &reader)

gui/projectfiledialog.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ void ProjectFileDialog::AddIncludeDir(const QString &dir)
5353
if (dir.isNull() || dir.isEmpty())
5454
return;
5555

56-
QListWidgetItem *item = new QListWidgetItem(dir);
56+
const QString newdir = QDir::toNativeSeparators(dir);
57+
QListWidgetItem *item = new QListWidgetItem(newdir);
5758
item->setFlags(item->flags() | Qt::ItemIsEditable);
5859
mUI.mListIncludeDirs->addItem(item);
5960
}
@@ -63,7 +64,8 @@ void ProjectFileDialog::AddPath(const QString &path)
6364
if (path.isNull() || path.isEmpty())
6465
return;
6566

66-
QListWidgetItem *item = new QListWidgetItem(path);
67+
const QString newpath = QDir::toNativeSeparators(path);
68+
QListWidgetItem *item = new QListWidgetItem(newpath);
6769
item->setFlags(item->flags() | Qt::ItemIsEditable);
6870
mUI.mListPaths->addItem(item);
6971
}
@@ -73,7 +75,8 @@ void ProjectFileDialog::AddIgnorePath(const QString &path)
7375
if (path.isNull() || path.isEmpty())
7476
return;
7577

76-
QListWidgetItem *item = new QListWidgetItem(path);
78+
const QString newpath = QDir::toNativeSeparators(path);
79+
QListWidgetItem *item = new QListWidgetItem(newpath);
7780
item->setFlags(item->flags() | Qt::ItemIsEditable);
7881
mUI.mListIgnoredPaths->addItem(item);
7982
}
@@ -82,6 +85,7 @@ QString ProjectFileDialog::GetRootPath() const
8285
{
8386
QString root = mUI.mEditProjectRoot->text();
8487
root = root.trimmed();
88+
root = QDir::fromNativeSeparators(root);
8589
return root;
8690
}
8791

@@ -92,9 +96,9 @@ QStringList ProjectFileDialog::GetIncludePaths() const
9296
for (int i = 0; i < count; i++)
9397
{
9498
QListWidgetItem *item = mUI.mListIncludeDirs->item(i);
95-
includePaths << item->text();
99+
includePaths << QDir::fromNativeSeparators((item->text());
96100
}
97-
return includePaths;
101+
return includePaths;
98102
}
99103

100104
QStringList ProjectFileDialog::GetDefines() const
@@ -119,7 +123,7 @@ QStringList ProjectFileDialog::GetPaths() const
119123
for (int i = 0; i < count; i++)
120124
{
121125
QListWidgetItem *item = mUI.mListPaths->item(i);
122-
paths << item->text();
126+
paths << QDir::fromNativeSeparators(item->text());
123127
}
124128
return paths;
125129
}
@@ -131,14 +135,15 @@ QStringList ProjectFileDialog::GetIgnorePaths() const
131135
for (int i = 0; i < count; i++)
132136
{
133137
QListWidgetItem *item = mUI.mListIgnoredPaths->item(i);
134-
paths << item->text();
138+
paths << QDir::fromNativeSeparators(item->text());
135139
}
136140
return paths;
137141
}
138142

139143
void ProjectFileDialog::SetRootPath(const QString &root)
140144
{
141-
mUI.mEditProjectRoot->setText(root);
145+
QString newroot = QDir::toNativeSeparators(root);
146+
mUI.mEditProjectRoot->setText(newroot);
142147
}
143148

144149
void ProjectFileDialog::SetIncludepaths(const QStringList &includes)

0 commit comments

Comments
 (0)