aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorAlessandro Portale <[email protected]>2022-04-27 15:23:43 +0200
committerAlessandro Portale <[email protected]>2022-05-19 18:21:31 +0000
commit6511bcdd72dbd08e906b225b6063b25372a7b136 (patch)
tree578dc09a32e5a148d3ec1da3378dabb217f93b73 /src/plugins
parent0a8dbaf153b5eadea45a56a11bbc73f5bc6c7503 (diff)
ProjectExplorer: Introduce type-aliases for a "recent projects" entries
The code base has too many repetitions of "QPair<QString, QString>" and for QLists of that. Also we might want to change one QString to FilePath, at some point. Change-Id: I4bd3ebe0f81aa77a6a380a96986d27f64522b4c5 Reviewed-by: hjk <[email protected]> Reviewed-by: Qt CI Bot <[email protected]>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/projectexplorer/projectexplorer.cpp20
-rw-r--r--src/plugins/projectexplorer/projectexplorer.h5
-rw-r--r--src/plugins/projectexplorer/projectwelcomepage.cpp4
-rw-r--r--src/plugins/studiowelcome/studiowelcomeplugin.cpp4
4 files changed, 18 insertions, 15 deletions
diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp
index b141d95a5d1..5ae835a7cca 100644
--- a/src/plugins/projectexplorer/projectexplorer.cpp
+++ b/src/plugins/projectexplorer/projectexplorer.cpp
@@ -536,7 +536,7 @@ public:
void checkForShutdown();
void timerEvent(QTimerEvent *) override;
- QList<QPair<QString, QString> > recentProjects() const;
+ RecentProjectsEntries recentProjects() const;
void extendFolderNavigationWidgetFactory();
@@ -622,7 +622,7 @@ public:
int m_shutdownWatchDogId = -1;
QHash<QString, std::function<Project *(const FilePath &)>> m_projectCreators;
- QList<QPair<QString, QString> > m_recentProjects; // pair of filename, displayname
+ RecentProjectsEntries m_recentProjects; // pair of filename, displayname
static const int m_maxRecentProjects = 25;
QString m_lastOpenDirectory;
@@ -2406,7 +2406,7 @@ void ProjectExplorerPluginPrivate::savePersistentSettings()
QStringList fileNames;
QStringList displayNames;
- QList<QPair<QString, QString> >::const_iterator it, end;
+ RecentProjectsEntries::const_iterator it, end;
end = dd->m_recentProjects.constEnd();
for (it = dd->m_recentProjects.constBegin(); it != end; ++it) {
fileNames << (*it).first;
@@ -2831,9 +2831,9 @@ void ProjectExplorerPluginPrivate::buildQueueFinished(bool success)
doUpdateRunActions();
}
-QList<QPair<QString, QString> > ProjectExplorerPluginPrivate::recentProjects() const
+RecentProjectsEntries ProjectExplorerPluginPrivate::recentProjects() const
{
- return Utils::filtered(dd->m_recentProjects, [](const QPair<QString, QString> &p) {
+ return Utils::filtered(dd->m_recentProjects, [](const RecentProjectsEntry &p) {
return QFileInfo(p.first).isFile();
});
}
@@ -3418,7 +3418,7 @@ void ProjectExplorerPluginPrivate::addToRecentProjects(const QString &fileName,
return;
QString prettyFileName(QDir::toNativeSeparators(fileName));
- QList<QPair<QString, QString> >::iterator it;
+ RecentProjectsEntries::iterator it;
for (it = m_recentProjects.begin(); it != m_recentProjects.end();)
if ((*it).first == prettyFileName)
it = m_recentProjects.erase(it);
@@ -3447,13 +3447,13 @@ void ProjectExplorerPluginPrivate::updateUnloadProjectMenu()
void ProjectExplorerPluginPrivate::updateRecentProjectMenu()
{
- using StringPairListConstIterator = QList<QPair<QString, QString> >::const_iterator;
+ using StringPairListConstIterator = RecentProjectsEntries::const_iterator;
ActionContainer *aci = ActionManager::actionContainer(Constants::M_RECENTPROJECTS);
QMenu *menu = aci->menu();
menu->clear();
int acceleratorKey = 1;
- auto projects = recentProjects();
+ const RecentProjectsEntries projects = recentProjects();
//projects (ignore sessions, they used to be in this list)
const StringPairListConstIterator end = projects.constEnd();
for (StringPairListConstIterator it = projects.constBegin(); it != end; ++it, ++acceleratorKey) {
@@ -3502,7 +3502,7 @@ void ProjectExplorerPluginPrivate::removeFromRecentProjects(const QString &fileN
const QString &displayName)
{
QTC_ASSERT(!fileName.isEmpty() && !displayName.isEmpty(), return);
- QTC_CHECK(m_recentProjects.removeOne(QPair<QString, QString>(fileName, displayName)));
+ QTC_CHECK(m_recentProjects.removeOne(RecentProjectsEntry(fileName, displayName)));
}
void ProjectExplorerPluginPrivate::invalidateProject(Project *project)
@@ -4352,7 +4352,7 @@ OutputWindow *ProjectExplorerPlugin::buildSystemOutput()
return dd->m_proWindow->buildSystemOutput();
}
-QList<QPair<QString, QString> > ProjectExplorerPlugin::recentProjects()
+RecentProjectsEntries ProjectExplorerPlugin::recentProjects()
{
return dd->recentProjects();
}
diff --git a/src/plugins/projectexplorer/projectexplorer.h b/src/plugins/projectexplorer/projectexplorer.h
index 41f4ed30412..0b2ad59d04b 100644
--- a/src/plugins/projectexplorer/projectexplorer.h
+++ b/src/plugins/projectexplorer/projectexplorer.h
@@ -64,6 +64,9 @@ class MiniProjectTargetSelector;
class ProjectExplorerSettings;
}
+using RecentProjectsEntry = QPair<QString, QString>;
+using RecentProjectsEntries = QList<RecentProjectsEntry>;
+
class PROJECTEXPLORER_EXPORT ProjectExplorerPlugin : public ExtensionSystem::IPlugin
{
Q_OBJECT
@@ -154,7 +157,7 @@ public:
static void renameFile(Node *node, const QString &newFilePath);
static QStringList projectFilePatterns();
static bool isProjectFile(const Utils::FilePath &filePath);
- static QList<QPair<QString, QString> > recentProjects();
+ static RecentProjectsEntries recentProjects();
static bool canRunStartupProject(Utils::Id runMode, QString *whyNot = nullptr);
static void runProject(Project *pro, Utils::Id, const bool forceSkipDeploy = false);
diff --git a/src/plugins/projectexplorer/projectwelcomepage.cpp b/src/plugins/projectexplorer/projectwelcomepage.cpp
index 2382103d910..2e1dd3c1527 100644
--- a/src/plugins/projectexplorer/projectwelcomepage.cpp
+++ b/src/plugins/projectexplorer/projectwelcomepage.cpp
@@ -83,10 +83,10 @@ int ProjectModel::rowCount(const QModelIndex &) const
QVariant ProjectModel::data(const QModelIndex &index, int role) const
{
- const QList<QPair<QString, QString> > recentProjects = ProjectExplorerPlugin::recentProjects();
+ const RecentProjectsEntries recentProjects = ProjectExplorerPlugin::recentProjects();
if (recentProjects.count() <= index.row())
return {};
- QPair<QString, QString> data = recentProjects.at(index.row());
+ RecentProjectsEntry data = recentProjects.at(index.row());
switch (role) {
case Qt::DisplayRole:
return data.second;
diff --git a/src/plugins/studiowelcome/studiowelcomeplugin.cpp b/src/plugins/studiowelcome/studiowelcomeplugin.cpp
index 246ba554188..67ef39249fe 100644
--- a/src/plugins/studiowelcome/studiowelcomeplugin.cpp
+++ b/src/plugins/studiowelcome/studiowelcomeplugin.cpp
@@ -392,8 +392,8 @@ static QString tags(const QString &projectFilePath)
QVariant ProjectModel::data(const QModelIndex &index, int role) const
{
- QPair<QString, QString> data = ProjectExplorer::ProjectExplorerPlugin::recentProjects().at(
- index.row());
+ const ProjectExplorer::RecentProjectsEntry data =
+ ProjectExplorer::ProjectExplorerPlugin::recentProjects().at(index.row());
switch (role) {
case Qt::DisplayRole:
return data.second;