src: Fixed issues with relative paths
This commit is contained in:
@@ -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()));
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user