src: Fixed issues with relative paths

This commit is contained in:
Eberhard Graether
2017-02-13 22:45:59 +01:00
parent 1d133492ed
commit be82e2a24e
3 changed files with 17 additions and 0 deletions
+5
View File
@@ -191,6 +191,11 @@ FilePath FilePath::relativeTo(const FilePath& other) const
r /= *itA;
}
if (r.empty())
{
r = "./";
}
return r;
}
@@ -270,12 +270,17 @@ void QtDirectoryListBox::setStringList(const std::vector<std::string>& list)
{
clear();
FilePath root = m_relativeRootDirectory;
m_relativeRootDirectory = FilePath();
for (const std::string& str : list)
{
QtListItemWidget* widget = addListBoxItem();
widget->setText(QString::fromStdString(str));
}
m_relativeRootDirectory = root;
QTimer::singleShot(1, this, SLOT(resize()));
}
+7
View File
@@ -99,6 +99,13 @@ public:
TS_ASSERT_EQUALS(pathA.relativeTo(pathB).str(), "../a.cpp");
}
void test_file_path_relative_to_same_directory()
{
FilePath pathA("data/FilePathTestSuite/test");
TS_ASSERT_EQUALS(pathA.relativeTo(pathA).str(), "./");
}
void test_file_path_file_name()
{
FilePath path("data/FilePathTestSuite/abc.h");