diff --git a/src/plugins/clangtools/clangtoolspreconfiguredsessiontests.cpp b/src/plugins/clangtools/clangtoolspreconfiguredsessiontests.cpp index 6c1c0d1386b..ff35479f8d7 100644 --- a/src/plugins/clangtools/clangtoolspreconfiguredsessiontests.cpp +++ b/src/plugins/clangtools/clangtoolspreconfiguredsessiontests.cpp @@ -31,6 +31,7 @@ using namespace CppEditor; using namespace ProjectExplorer; +using namespace Utils; static bool processEventsUntil(const std::function condition, int timeOutInMs = 30000) { @@ -51,7 +52,7 @@ static bool processEventsUntil(const std::function condition, int timeOu class WaitForParsedProjects : public QObject { public: - WaitForParsedProjects(const QStringList &projects) + WaitForParsedProjects(const FilePaths &projects) : m_projectsToWaitFor(projects) { connect(SessionManager::instance(), @@ -61,7 +62,7 @@ public: void onProjectFinishedParsing(ProjectExplorer::Project *project) { - m_projectsToWaitFor.removeOne(project->projectFilePath().toString()); + m_projectsToWaitFor.removeOne(project->projectFilePath()); } bool wait() @@ -70,7 +71,7 @@ public: } private: - QStringList m_projectsToWaitFor; + FilePaths m_projectsToWaitFor; }; namespace ClangTools { @@ -86,7 +87,7 @@ void PreconfiguredSessionTests::initTestCase() QSKIP("Session must not be already active."); // Load session - const QStringList projects = SessionManager::projectsForSessionName(preconfiguredSessionName); + const FilePaths projects = SessionManager::projectsForSessionName(preconfiguredSessionName); WaitForParsedProjects waitForParsedProjects(projects); QVERIFY(SessionManager::loadSession(preconfiguredSessionName)); QVERIFY(waitForParsedProjects.wait()); diff --git a/src/plugins/projectexplorer/projectwelcomepage.cpp b/src/plugins/projectexplorer/projectwelcomepage.cpp index 9b07748fc2e..2eff1b585c8 100644 --- a/src/plugins/projectexplorer/projectwelcomepage.cpp +++ b/src/plugins/projectexplorer/projectwelcomepage.cpp @@ -322,12 +322,11 @@ public: if (expanded) { painter->setPen(textColor); painter->setFont(sizedFont(12, option.widget)); - const QStringList projects = SessionManager::projectsForSessionName(sessionName); + const FilePaths projects = SessionManager::projectsForSessionName(sessionName); int yy = firstBase + SESSION_LINE_HEIGHT - 3; QFontMetrics fm(option.widget->font()); - for (const QString &project : projects) { + for (const FilePath &projectPath : projects) { // Project name. - FilePath projectPath = FilePath::fromString(project); QString completeBase = projectPath.completeBaseName(); painter->setPen(textColor); painter->drawText(x1, yy, fm.elidedText(completeBase, Qt::ElideMiddle, textSpace)); @@ -375,7 +374,7 @@ public: int h = SESSION_LINE_HEIGHT; QString sessionName = idx.data(Qt::DisplayRole).toString(); if (m_expandedSessions.contains(sessionName)) { - QStringList projects = SessionManager::projectsForSessionName(sessionName); + const FilePaths projects = SessionManager::projectsForSessionName(sessionName); h += projects.size() * 40 + LINK_HEIGHT - 6; } return QSize(380, h + ItemGap); diff --git a/src/plugins/projectexplorer/session.cpp b/src/plugins/projectexplorer/session.cpp index 1c8f057f701..064f086f85a 100644 --- a/src/plugins/projectexplorer/session.cpp +++ b/src/plugins/projectexplorer/session.cpp @@ -1179,17 +1179,18 @@ void SessionManagerPrivate::sessionLoadingProgress() QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents); } -QStringList SessionManager::projectsForSessionName(const QString &session) +FilePaths SessionManager::projectsForSessionName(const QString &session) { const FilePath fileName = sessionNameToFileName(session); PersistentSettingsReader reader; if (fileName.exists()) { if (!reader.load(fileName)) { qWarning() << "Could not restore session" << fileName.toUserOutput(); - return QStringList(); + return {}; } } - return reader.restoreValue(QLatin1String("ProjectList")).toStringList(); + return transform(reader.restoreValue(QLatin1String("ProjectList")).toStringList(), + &FilePath::fromUserInput); } #ifdef WITH_TESTS diff --git a/src/plugins/projectexplorer/session.h b/src/plugins/projectexplorer/session.h index d0f7fd91d2b..66df2e672ed 100644 --- a/src/plugins/projectexplorer/session.h +++ b/src/plugins/projectexplorer/session.h @@ -99,7 +99,7 @@ public: static Project *projectForFile(const Utils::FilePath &fileName); static Project *projectWithProjectFilePath(const Utils::FilePath &filePath); - static QStringList projectsForSessionName(const QString &session); + static Utils::FilePaths projectsForSessionName(const QString &session); static void reportProjectLoadingProgress(); static bool loadingSession(); diff --git a/src/plugins/projectexplorer/sessionmodel.cpp b/src/plugins/projectexplorer/sessionmodel.cpp index 771d8a44785..ceb05cb8630 100644 --- a/src/plugins/projectexplorer/sessionmodel.cpp +++ b/src/plugins/projectexplorer/sessionmodel.cpp @@ -74,18 +74,14 @@ int SessionModel::rowCount(const QModelIndex &) const return m_sortedSessions.count(); } -QStringList pathsToBaseNames(const QStringList &paths) +QStringList pathsToBaseNames(const FilePaths &paths) { - return Utils::transform(paths, [](const QString &path) { - return QFileInfo(path).completeBaseName(); - }); + return Utils::transform(paths, &FilePath::completeBaseName); } -QStringList pathsWithTildeHomePath(const QStringList &paths) +QStringList pathsWithTildeHomePath(const FilePaths &paths) { - return Utils::transform(paths, [](const QString &path) { - return FilePath::fromString(path).withTildeHomePath(); - }); + return Utils::transform(paths, &FilePath::withTildeHomePath); } QVariant SessionModel::data(const QModelIndex &index, int role) const