forked from qt-creator/qt-creator
Utils: Use more views in Id setup
Since this means that StringBuilder expressions are not usable as arguments anymore, use .withSuffix() more extensively. This makes this "unusual" construction also a bit better findable. No measurable performance gain or loss in either direction. Change-Id: I04508e77764455bd9d3a21eda63bc6de01508e4b Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
#include "floatingdockcontainer.h"
|
#include "floatingdockcontainer.h"
|
||||||
|
|
||||||
#include <QAbstractButton>
|
#include <QAbstractButton>
|
||||||
|
#include <QCoreApplication>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
@@ -82,7 +82,7 @@ static QHash<quintptr, StringHolder> stringFromId;
|
|||||||
static IdCache idFromString;
|
static IdCache idFromString;
|
||||||
static QReadWriteLock s_cacheMutex;
|
static QReadWriteLock s_cacheMutex;
|
||||||
|
|
||||||
static quintptr theId(const char *str, int n = 0)
|
static quintptr theId(const char *str, int n)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(str && *str, return 0);
|
QTC_ASSERT(str && *str, return 0);
|
||||||
StringHolder sh(str, n);
|
StringHolder sh(str, n);
|
||||||
@@ -107,11 +107,6 @@ static quintptr theId(const char *str, int n = 0)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static quintptr theId(const QByteArray &ba)
|
|
||||||
{
|
|
||||||
return theId(ba.constData(), ba.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn Utils::Id::Id(quintptr uid)
|
\fn Utils::Id::Id(quintptr uid)
|
||||||
\internal
|
\internal
|
||||||
@@ -181,11 +176,12 @@ Key Id::toKey() const
|
|||||||
\sa toString(), fromSetting()
|
\sa toString(), fromSetting()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Id Id::fromString(const QString &name)
|
Id Id::fromString(const QStringView name)
|
||||||
{
|
{
|
||||||
if (name.isEmpty())
|
if (name.isEmpty())
|
||||||
return Id();
|
return Id();
|
||||||
return Id(theId(name.toUtf8()));
|
const QByteArray ba = name.toUtf8();
|
||||||
|
return Id(theId(ba.data(), ba.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -199,9 +195,9 @@ Id Id::fromString(const QString &name)
|
|||||||
\sa toString(), fromSetting()
|
\sa toString(), fromSetting()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Id Id::fromName(const QByteArray &name)
|
Id Id::fromName(const QByteArrayView name)
|
||||||
{
|
{
|
||||||
return Id(theId(name));
|
return Id(theId(name.data(), name.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -228,7 +224,7 @@ Id Id::fromSetting(const QVariant &variant)
|
|||||||
const QByteArray ba = variant.toString().toUtf8();
|
const QByteArray ba = variant.toString().toUtf8();
|
||||||
if (ba.isEmpty())
|
if (ba.isEmpty())
|
||||||
return Id();
|
return Id();
|
||||||
return Id(theId(ba));
|
return Id(theId(ba.data(), ba.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
QSet<Id> Id::fromStringList(const QStringList &list)
|
QSet<Id> Id::fromStringList(const QStringList &list)
|
||||||
@@ -252,7 +248,7 @@ QStringList Id::toStringList(const QSet<Id> &ids)
|
|||||||
Id Id::withSuffix(int suffix) const
|
Id Id::withSuffix(int suffix) const
|
||||||
{
|
{
|
||||||
const QByteArray ba = name() + QByteArray::number(suffix);
|
const QByteArray ba = name() + QByteArray::number(suffix);
|
||||||
return Id(ba.constData());
|
return Id(theId(ba.data(), ba.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -262,17 +258,17 @@ Id Id::withSuffix(int suffix) const
|
|||||||
Id Id::withSuffix(const char *suffix) const
|
Id Id::withSuffix(const char *suffix) const
|
||||||
{
|
{
|
||||||
const QByteArray ba = name() + suffix;
|
const QByteArray ba = name() + suffix;
|
||||||
return Id(ba.constData());
|
return Id(theId(ba.data(), ba.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\overload
|
\overload
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Id Id::withSuffix(const QString &suffix) const
|
Id Id::withSuffix(const QStringView suffix) const
|
||||||
{
|
{
|
||||||
const QByteArray ba = name() + suffix.toUtf8();
|
const QByteArray ba = name() + suffix.toUtf8();
|
||||||
return Id(ba.constData());
|
return Id(theId(ba.data(), ba.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -286,10 +282,9 @@ Id Id::withSuffix(const QString &suffix) const
|
|||||||
Id Id::withPrefix(const char *prefix) const
|
Id Id::withPrefix(const char *prefix) const
|
||||||
{
|
{
|
||||||
const QByteArray ba = prefix + name();
|
const QByteArray ba = prefix + name();
|
||||||
return Id(ba.constData());
|
return Id(theId(ba.data(), ba.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Id::operator==(const char *name) const
|
bool Id::operator==(const char *name) const
|
||||||
{
|
{
|
||||||
QReadLocker lock(&s_cacheMutex);
|
QReadLocker lock(&s_cacheMutex);
|
||||||
|
@@ -29,7 +29,7 @@ public:
|
|||||||
|
|
||||||
Id withSuffix(int suffix) const;
|
Id withSuffix(int suffix) const;
|
||||||
Id withSuffix(const char *suffix) const;
|
Id withSuffix(const char *suffix) const;
|
||||||
Id withSuffix(const QString &suffix) const;
|
Id withSuffix(const QStringView suffix) const;
|
||||||
Id withPrefix(const char *prefix) const;
|
Id withPrefix(const char *prefix) const;
|
||||||
|
|
||||||
QByteArray name() const;
|
QByteArray name() const;
|
||||||
@@ -47,8 +47,8 @@ public:
|
|||||||
bool alphabeticallyBefore(Id other) const;
|
bool alphabeticallyBefore(Id other) const;
|
||||||
|
|
||||||
quintptr uniqueIdentifier() const { return m_id; } // Avoid.
|
quintptr uniqueIdentifier() const { return m_id; } // Avoid.
|
||||||
static Id fromString(const QString &str); // FIXME: avoid.
|
static Id fromString(const QStringView str); // FIXME: avoid.
|
||||||
static Id fromName(const QByteArray &ba); // FIXME: avoid.
|
static Id fromName(const QByteArrayView ba); // FIXME: avoid.
|
||||||
static Id fromSetting(const QVariant &variant); // Good to use.
|
static Id fromSetting(const QVariant &variant); // Good to use.
|
||||||
|
|
||||||
static QSet<Id> fromStringList(const QStringList &list);
|
static QSet<Id> fromStringList(const QStringList &list);
|
||||||
|
@@ -441,12 +441,12 @@ AndroidDeviceInfo AndroidDevice::androidDeviceInfoFromIDevice(const IDevice *dev
|
|||||||
Id AndroidDevice::idFromDeviceInfo(const AndroidDeviceInfo &info)
|
Id AndroidDevice::idFromDeviceInfo(const AndroidDeviceInfo &info)
|
||||||
{
|
{
|
||||||
const QString id = (info.type == IDevice::Hardware ? info.serialNumber : info.avdName);
|
const QString id = (info.type == IDevice::Hardware ? info.serialNumber : info.avdName);
|
||||||
return Id(Constants::ANDROID_DEVICE_ID).withSuffix(':' + id);
|
return Id(Constants::ANDROID_DEVICE_ID).withSuffix(':').withSuffix(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
Id AndroidDevice::idFromAvdInfo(const CreateAvdInfo &info)
|
Id AndroidDevice::idFromAvdInfo(const CreateAvdInfo &info)
|
||||||
{
|
{
|
||||||
return Id(Constants::ANDROID_DEVICE_ID).withSuffix(':' + info.name);
|
return Id(Constants::ANDROID_DEVICE_ID).withSuffix(':').withSuffix(info.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList AndroidDevice::supportedAbis() const
|
QStringList AndroidDevice::supportedAbis() const
|
||||||
@@ -650,10 +650,10 @@ static void handleDevicesListChange(const QString &serialNumber)
|
|||||||
|
|
||||||
if (isEmulator) {
|
if (isEmulator) {
|
||||||
const QString avdName = emulatorName(serial);
|
const QString avdName = emulatorName(serial);
|
||||||
const Id avdId = Id(Constants::ANDROID_DEVICE_ID).withSuffix(':' + avdName);
|
const Id avdId = Id(Constants::ANDROID_DEVICE_ID).withSuffix(':').withSuffix(avdName);
|
||||||
devMgr->setDeviceState(avdId, state);
|
devMgr->setDeviceState(avdId, state);
|
||||||
} else {
|
} else {
|
||||||
const Id id = Id(Constants::ANDROID_DEVICE_ID).withSuffix(':' + serial);
|
const Id id = Id(Constants::ANDROID_DEVICE_ID).withSuffix(':').withSuffix(serial);
|
||||||
QString displayName = AndroidConfig::getProductModel(serial);
|
QString displayName = AndroidConfig::getProductModel(serial);
|
||||||
// Check if the device is connected via WiFi. A sample serial of such devices can be
|
// Check if the device is connected via WiFi. A sample serial of such devices can be
|
||||||
// like: "192.168.1.190:5555"
|
// like: "192.168.1.190:5555"
|
||||||
|
@@ -75,8 +75,9 @@ void DeviceDetector::handleDeviceEvent(QdbDeviceTracker::DeviceEventType eventTy
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Utils::Id deviceId = Constants::QdbHardwareDevicePrefix.withSuffix(':' + serial);
|
const Utils::Id deviceId =
|
||||||
const auto messagePrefix = Tr::tr("Device \"%1\" %2").arg(serial);
|
Utils::Id(Constants::QdbHardwareDevicePrefix).withSuffix(':').withSuffix(serial);
|
||||||
|
const QString messagePrefix = Tr::tr("Device \"%1\" %2").arg(serial);
|
||||||
DeviceManager * const dm = DeviceManager::instance();
|
DeviceManager * const dm = DeviceManager::instance();
|
||||||
|
|
||||||
if (eventType == QdbDeviceTracker::NewDevice) {
|
if (eventType == QdbDeviceTracker::NewDevice) {
|
||||||
|
@@ -16,7 +16,7 @@ const char QdbDeployConfigurationId[] = "Qt4ProjectManager.Qdb.QdbDeployConfigur
|
|||||||
const char QdbStopApplicationStepId[] = "Qdb.StopApplicationStep";
|
const char QdbStopApplicationStepId[] = "Qdb.StopApplicationStep";
|
||||||
const char QdbMakeDefaultAppStepId[] = "Qdb.MakeDefaultAppStep";
|
const char QdbMakeDefaultAppStepId[] = "Qdb.MakeDefaultAppStep";
|
||||||
|
|
||||||
const Utils::Id QdbHardwareDevicePrefix = "QdbHardwareDevice";
|
const char QdbHardwareDevicePrefix[] = "QdbHardwareDevice";
|
||||||
const char AppcontrollerFilepath[] = "/usr/bin/appcontroller";
|
const char AppcontrollerFilepath[] = "/usr/bin/appcontroller";
|
||||||
|
|
||||||
} // namespace Constants
|
} // namespace Constants
|
||||||
|
@@ -97,7 +97,7 @@ ProcessProgress::ProcessProgress(Process *process)
|
|||||||
d->m_futureInterface.reportStarted();
|
d->m_futureInterface.reportStarted();
|
||||||
|
|
||||||
const QString name = d->displayName();
|
const QString name = d->displayName();
|
||||||
const auto id = Id::fromString(name + ".action");
|
const Id id = Id::fromString(name).withSuffix(".action");
|
||||||
if (d->m_parser) {
|
if (d->m_parser) {
|
||||||
d->m_futureProgress = ProgressManager::addTask(d->m_futureInterface.future(), name, id);
|
d->m_futureProgress = ProgressManager::addTask(d->m_futureInterface.future(), name, id);
|
||||||
} else {
|
} else {
|
||||||
|
@@ -120,7 +120,7 @@ TaskProgress::TaskProgress(TaskTree *taskTree)
|
|||||||
d->m_futureInterface.reportStarted();
|
d->m_futureInterface.reportStarted();
|
||||||
d->advanceProgress(0);
|
d->advanceProgress(0);
|
||||||
|
|
||||||
const Id id = d->m_id.isValid() ? d->m_id : Id::fromString(d->m_displayName + ".action");
|
const Id id = d->m_id.isValid() ? d->m_id : Id::fromString(d->m_displayName).withSuffix(".action");
|
||||||
d->m_futureProgress = ProgressManager::addTask(d->m_futureInterface.future(),
|
d->m_futureProgress = ProgressManager::addTask(d->m_futureInterface.future(),
|
||||||
d->m_displayName, id);
|
d->m_displayName, id);
|
||||||
d->m_futureProgress->setKeepOnFinish(d->m_keep);
|
d->m_futureProgress->setKeepOnFinish(d->m_keep);
|
||||||
|
@@ -133,7 +133,7 @@ void GitLabCloneDialog::updateUi()
|
|||||||
void GitLabCloneDialog::cloneProject()
|
void GitLabCloneDialog::cloneProject()
|
||||||
{
|
{
|
||||||
VersionControlBase *vc = static_cast<VersionControlBase *>(
|
VersionControlBase *vc = static_cast<VersionControlBase *>(
|
||||||
Core::VcsManager::versionControl(Id::fromString("G.Git")));
|
Core::VcsManager::versionControl(Id("G.Git")));
|
||||||
QTC_ASSERT(vc, return);
|
QTC_ASSERT(vc, return);
|
||||||
const QStringList extraArgs = m_submodulesCB->isChecked() ? QStringList{ "--recursive" }
|
const QStringList extraArgs = m_submodulesCB->isChecked() ? QStringList{ "--recursive" }
|
||||||
: QStringList{};
|
: QStringList{};
|
||||||
|
@@ -204,7 +204,7 @@ void addFetchModule()
|
|||||||
}
|
}
|
||||||
|
|
||||||
Utils::InfoBarEntry entry{
|
Utils::InfoBarEntry entry{
|
||||||
Utils::Id::fromString("Fetch" + pluginName),
|
Utils::Id("Fetch").withSuffix(pluginName),
|
||||||
Tr::tr("Allow the extension \"%1\" to fetch data from the internet?")
|
Tr::tr("Allow the extension \"%1\" to fetch data from the internet?")
|
||||||
.arg(pluginName)};
|
.arg(pluginName)};
|
||||||
entry.setDetailsWidgetCreator([pluginName, url] {
|
entry.setDetailsWidgetCreator([pluginName, url] {
|
||||||
@@ -221,16 +221,16 @@ void addFetchModule()
|
|||||||
});
|
});
|
||||||
entry.addCustomButton(Tr::tr("Always Allow"), [mod, pluginName, fetch]() {
|
entry.addCustomButton(Tr::tr("Always Allow"), [mod, pluginName, fetch]() {
|
||||||
mod->setAllowedToFetch(pluginName, Module::IsAllowed::Yes);
|
mod->setAllowedToFetch(pluginName, Module::IsAllowed::Yes);
|
||||||
Core::ICore::infoBar()->removeInfo(Utils::Id::fromString("Fetch" + pluginName));
|
Core::ICore::infoBar()->removeInfo(Utils::Id("Fetch").withSuffix(pluginName));
|
||||||
fetch();
|
fetch();
|
||||||
});
|
});
|
||||||
entry.addCustomButton(Tr::tr("Allow Once"), [pluginName, fetch]() {
|
entry.addCustomButton(Tr::tr("Allow Once"), [pluginName, fetch]() {
|
||||||
Core::ICore::infoBar()->removeInfo(Utils::Id::fromString("Fetch" + pluginName));
|
Core::ICore::infoBar()->removeInfo(Utils::Id("Fetch").withSuffix(pluginName));
|
||||||
fetch();
|
fetch();
|
||||||
});
|
});
|
||||||
|
|
||||||
entry.setCancelButtonInfo(Tr::tr("Deny"), [mod, notAllowed, pluginName]() {
|
entry.setCancelButtonInfo(Tr::tr("Deny"), [mod, notAllowed, pluginName]() {
|
||||||
Core::ICore::infoBar()->removeInfo(Utils::Id::fromString("Fetch" + pluginName));
|
Core::ICore::infoBar()->removeInfo(Utils::Id("Fetch").withSuffix(pluginName));
|
||||||
mod->setAllowedToFetch(pluginName, Module::IsAllowed::No);
|
mod->setAllowedToFetch(pluginName, Module::IsAllowed::No);
|
||||||
notAllowed();
|
notAllowed();
|
||||||
});
|
});
|
||||||
|
@@ -351,8 +351,9 @@ void addInstallModule()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Utils::Id infoBarId = Utils::Id::fromString(
|
const Utils::Id infoBarId = Utils::Id("Install")
|
||||||
"Install" + pluginSpec->name + QString::number(qHash(installOptionsList)));
|
.withSuffix(pluginSpec->name)
|
||||||
|
.withSuffix(QString::number(qHash(installOptionsList)));
|
||||||
|
|
||||||
InfoBarEntry entry(infoBarId, msg, InfoBarEntry::GlobalSuppression::Enabled);
|
InfoBarEntry entry(infoBarId, msg, InfoBarEntry::GlobalSuppression::Enabled);
|
||||||
|
|
||||||
|
@@ -159,7 +159,7 @@ static JsonWizardFactory::Generator parseGenerator(const QVariant &value, QStrin
|
|||||||
*errorMessage = Tr::tr("Generator has no typeId set.");
|
*errorMessage = Tr::tr("Generator has no typeId set.");
|
||||||
return gen;
|
return gen;
|
||||||
}
|
}
|
||||||
Id typeId = Id::fromString(QLatin1String(Constants::GENERATOR_ID_PREFIX) + strVal);
|
Id typeId = Id(Constants::GENERATOR_ID_PREFIX).withSuffix(strVal);
|
||||||
JsonWizardGeneratorFactory *factory
|
JsonWizardGeneratorFactory *factory
|
||||||
= findOr(generatorFactories(), nullptr, [typeId](JsonWizardGeneratorFactory *f) { return f->canCreate(typeId); });
|
= findOr(generatorFactories(), nullptr, [typeId](JsonWizardGeneratorFactory *f) { return f->canCreate(typeId); });
|
||||||
if (!factory) {
|
if (!factory) {
|
||||||
@@ -326,7 +326,7 @@ std::pair<int, QStringList> JsonWizardFactory::screenSizeInfoFromPage(const QStr
|
|||||||
* pages[i] is the page of type `pageType` and data[j] is the data item with name ScreenFactor
|
* pages[i] is the page of type `pageType` and data[j] is the data item with name ScreenFactor
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const Utils::Id id = Utils::Id::fromString(Constants::PAGE_ID_PREFIX + pageType);
|
const Utils::Id id = Utils::Id(Constants::PAGE_ID_PREFIX).withSuffix(pageType);
|
||||||
|
|
||||||
const auto it = std::find_if(std::cbegin(m_pages), std::cend(m_pages), [&id](const Page &page) {
|
const auto it = std::find_if(std::cbegin(m_pages), std::cend(m_pages), [&id](const Page &page) {
|
||||||
return page.typeId == id;
|
return page.typeId == id;
|
||||||
@@ -393,7 +393,7 @@ JsonWizardFactory::Page JsonWizardFactory::parsePage(const QVariant &value, QStr
|
|||||||
*errorMessage = Tr::tr("Page has no typeId set.");
|
*errorMessage = Tr::tr("Page has no typeId set.");
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
Id typeId = Id::fromString(QLatin1String(Constants::PAGE_ID_PREFIX) + strVal);
|
Id typeId = Id(Constants::PAGE_ID_PREFIX).withSuffix(strVal);
|
||||||
|
|
||||||
JsonWizardPageFactory *factory
|
JsonWizardPageFactory *factory
|
||||||
= Utils::findOr(pageFactories(), nullptr, [typeId](JsonWizardPageFactory *f) { return f->canCreate(typeId); });
|
= Utils::findOr(pageFactories(), nullptr, [typeId](JsonWizardPageFactory *f) { return f->canCreate(typeId); });
|
||||||
|
@@ -259,13 +259,14 @@ bool JsonWizardGenerator::allDone(const JsonWizard *wizard, JsonWizard::Generato
|
|||||||
|
|
||||||
void JsonWizardGeneratorFactory::setTypeIdsSuffixes(const QStringList &suffixes)
|
void JsonWizardGeneratorFactory::setTypeIdsSuffixes(const QStringList &suffixes)
|
||||||
{
|
{
|
||||||
m_typeIds = Utils::transform(suffixes, [](QString suffix)
|
m_typeIds = Utils::transform(suffixes, [](QString suffix) {
|
||||||
{ return Id::fromString(QString::fromLatin1(Constants::GENERATOR_ID_PREFIX) + suffix); });
|
return Id(Constants::GENERATOR_ID_PREFIX).withSuffix(suffix);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void JsonWizardGeneratorFactory::setTypeIdsSuffix(const QString &suffix)
|
void JsonWizardGeneratorFactory::setTypeIdsSuffix(const QString &suffix)
|
||||||
{
|
{
|
||||||
setTypeIdsSuffixes(QStringList() << suffix);
|
setTypeIdsSuffixes({suffix});
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ProjectExplorer
|
} // namespace ProjectExplorer
|
||||||
|
@@ -9,19 +9,16 @@
|
|||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
// JsonWizardPageFactory:
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
|
|
||||||
void JsonWizardPageFactory::setTypeIdsSuffixes(const QStringList &suffixes)
|
void JsonWizardPageFactory::setTypeIdsSuffixes(const QStringList &suffixes)
|
||||||
{
|
{
|
||||||
m_typeIds = Utils::transform(suffixes, [](const QString &suffix) {
|
m_typeIds = Utils::transform(suffixes, [](const QString &suffix) {
|
||||||
return Utils::Id::fromString(QString::fromLatin1(Constants::PAGE_ID_PREFIX) + suffix);});
|
return Utils::Id(Constants::PAGE_ID_PREFIX).withSuffix(suffix);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void JsonWizardPageFactory::setTypeIdsSuffix(const QString &suffix)
|
void JsonWizardPageFactory::setTypeIdsSuffix(const QString &suffix)
|
||||||
{
|
{
|
||||||
setTypeIdsSuffixes(QStringList() << suffix);
|
setTypeIdsSuffixes({suffix});
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ProjectExplorer
|
} // namespace ProjectExplorer
|
||||||
|
@@ -38,7 +38,7 @@ static Utils::Id fullId(Utils::Id id)
|
|||||||
const QString idStr = id.toString();
|
const QString idStr = id.toString();
|
||||||
QTC_ASSERT(!idStr.startsWith(prefix), return Utils::Id::fromString(idStr));
|
QTC_ASSERT(!idStr.startsWith(prefix), return Utils::Id::fromString(idStr));
|
||||||
|
|
||||||
return Utils::Id::fromString(prefix + idStr);
|
return Utils::Id::fromString(prefix).withSuffix(idStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool hasOtherUsers(Utils::Id id, const QVariant &v, Kit *k)
|
static bool hasOtherUsers(Utils::Id id, const QVariant &v, Kit *k)
|
||||||
|
@@ -26,21 +26,21 @@
|
|||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
|
||||||
const QLatin1StringView FOLDER_MIMETYPE{"inode/directory"};
|
|
||||||
const QLatin1StringView WORKSPACE_MIMETYPE{"text/x-workspace-project"};
|
|
||||||
const QLatin1StringView WORKSPACE_PROJECT_ID{"ProjectExplorer.WorkspaceProject"};
|
|
||||||
const QLatin1StringView WORKSPACE_PROJECT_RUNCONFIG_ID{"WorkspaceProject.RunConfiguration:"};
|
|
||||||
|
|
||||||
const QLatin1StringView PROJECT_NAME_KEY{"project.name"};
|
|
||||||
const QLatin1StringView FILES_EXCLUDE_KEY{"files.exclude"};
|
|
||||||
const QLatin1StringView EXCLUDE_ACTION_ID{"ProjectExplorer.ExcludeFromWorkspace"};
|
|
||||||
const QLatin1StringView RESCAN_ACTION_ID{"ProjectExplorer.RescanWorkspace"};
|
|
||||||
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
|
|
||||||
|
const QLatin1StringView FOLDER_MIMETYPE{"inode/directory"};
|
||||||
|
const QLatin1StringView WORKSPACE_MIMETYPE{"text/x-workspace-project"};
|
||||||
|
const char WORKSPACE_PROJECT_ID[] = "ProjectExplorer.WorkspaceProject";
|
||||||
|
const char WORKSPACE_PROJECT_RUNCONFIG_ID[] = "WorkspaceProject.RunConfiguration:";
|
||||||
|
|
||||||
|
const QLatin1StringView PROJECT_NAME_KEY{"project.name"};
|
||||||
|
const QLatin1StringView FILES_EXCLUDE_KEY{"files.exclude"};
|
||||||
|
const char EXCLUDE_ACTION_ID[] = "ProjectExplorer.ExcludeFromWorkspace";
|
||||||
|
const char RESCAN_ACTION_ID[] = "ProjectExplorer.RescanWorkspace";
|
||||||
|
|
||||||
const expected_str<QJsonObject> projectDefinition(const Project *project)
|
const expected_str<QJsonObject> projectDefinition(const Project *project)
|
||||||
{
|
{
|
||||||
if (auto fileContents = project->projectFilePath().fileContents())
|
if (auto fileContents = project->projectFilePath().fileContents())
|
||||||
@@ -231,8 +231,8 @@ public:
|
|||||||
WorkspaceProjectRunConfigurationFactory()
|
WorkspaceProjectRunConfigurationFactory()
|
||||||
{
|
{
|
||||||
registerRunConfiguration<WorkspaceRunConfiguration>(
|
registerRunConfiguration<WorkspaceRunConfiguration>(
|
||||||
Id::fromString(WORKSPACE_PROJECT_RUNCONFIG_ID));
|
Id(WORKSPACE_PROJECT_RUNCONFIG_ID));
|
||||||
addSupportedProjectType(Id::fromString(WORKSPACE_PROJECT_ID));
|
addSupportedProjectType(WORKSPACE_PROJECT_ID);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -243,7 +243,7 @@ public:
|
|||||||
{
|
{
|
||||||
setProduct<SimpleTargetRunner>();
|
setProduct<SimpleTargetRunner>();
|
||||||
addSupportedRunMode(Constants::NORMAL_RUN_MODE);
|
addSupportedRunMode(Constants::NORMAL_RUN_MODE);
|
||||||
addSupportedRunConfig(Id::fromString(WORKSPACE_PROJECT_RUNCONFIG_ID));
|
addSupportedRunConfig(WORKSPACE_PROJECT_RUNCONFIG_ID);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -268,7 +268,7 @@ public:
|
|||||||
registerBuildConfiguration<WorkspaceBuildConfiguration>
|
registerBuildConfiguration<WorkspaceBuildConfiguration>
|
||||||
("WorkspaceProject.BuildConfiguration");
|
("WorkspaceProject.BuildConfiguration");
|
||||||
|
|
||||||
setSupportedProjectType(Id::fromString(WORKSPACE_PROJECT_ID));
|
setSupportedProjectType(WORKSPACE_PROJECT_ID);
|
||||||
|
|
||||||
setBuildGenerator([](const Kit *, const FilePath &projectPath, bool forSetup) {
|
setBuildGenerator([](const Kit *, const FilePath &projectPath, bool forSetup) {
|
||||||
BuildInfo info;
|
BuildInfo info;
|
||||||
@@ -298,7 +298,7 @@ public:
|
|||||||
projectFilePath().writeFileContents(QJsonDocument(projectJson).toJson());
|
projectFilePath().writeFileContents(QJsonDocument(projectJson).toJson());
|
||||||
}
|
}
|
||||||
|
|
||||||
setId(Id::fromString(WORKSPACE_PROJECT_ID));
|
setId(WORKSPACE_PROJECT_ID);
|
||||||
setDisplayName(projectDirectory().fileName());
|
setDisplayName(projectDirectory().fileName());
|
||||||
setBuildSystemCreator<WorkspaceBuildSystem>();
|
setBuildSystemCreator<WorkspaceBuildSystem>();
|
||||||
}
|
}
|
||||||
@@ -347,8 +347,8 @@ void setupWorkspaceProject(QObject *guard)
|
|||||||
ProjectManager::registerProjectType<WorkspaceProject>(WORKSPACE_MIMETYPE);
|
ProjectManager::registerProjectType<WorkspaceProject>(WORKSPACE_MIMETYPE);
|
||||||
|
|
||||||
QAction *excludeAction = nullptr;
|
QAction *excludeAction = nullptr;
|
||||||
ActionBuilder(guard, Id::fromString(EXCLUDE_ACTION_ID))
|
ActionBuilder(guard, EXCLUDE_ACTION_ID)
|
||||||
.setContext(Id::fromString(WORKSPACE_PROJECT_ID))
|
.setContext(WORKSPACE_PROJECT_ID)
|
||||||
.setText(Tr::tr("Exclude from Project"))
|
.setText(Tr::tr("Exclude from Project"))
|
||||||
.addToContainer(Constants::M_FOLDERCONTEXT, Constants::G_FOLDER_OTHER)
|
.addToContainer(Constants::M_FOLDERCONTEXT, Constants::G_FOLDER_OTHER)
|
||||||
.addToContainer(Constants::M_FILECONTEXT, Constants::G_FILE_OTHER)
|
.addToContainer(Constants::M_FILECONTEXT, Constants::G_FILE_OTHER)
|
||||||
@@ -363,8 +363,8 @@ void setupWorkspaceProject(QObject *guard)
|
|||||||
});
|
});
|
||||||
|
|
||||||
QAction *rescanAction = nullptr;
|
QAction *rescanAction = nullptr;
|
||||||
ActionBuilder(guard, Id::fromString(RESCAN_ACTION_ID))
|
ActionBuilder(guard, RESCAN_ACTION_ID)
|
||||||
.setContext(Id::fromString(WORKSPACE_PROJECT_ID))
|
.setContext(WORKSPACE_PROJECT_ID)
|
||||||
.setText(Tr::tr("Rescan Workspace"))
|
.setText(Tr::tr("Rescan Workspace"))
|
||||||
.addToContainer(Constants::M_PROJECTCONTEXT, Constants::G_PROJECT_REBUILD)
|
.addToContainer(Constants::M_PROJECTCONTEXT, Constants::G_PROJECT_REBUILD)
|
||||||
.bindContextAction(&rescanAction)
|
.bindContextAction(&rescanAction)
|
||||||
|
@@ -347,7 +347,7 @@ void DesignModeWidget::setup()
|
|||||||
|
|
||||||
// Create menu action
|
// Create menu action
|
||||||
auto command = Core::ActionManager::registerAction(dockWidget->toggleViewAction(),
|
auto command = Core::ActionManager::registerAction(dockWidget->toggleViewAction(),
|
||||||
actionToggle.withSuffix(uniqueId + "Widget"),
|
actionToggle.withSuffix(uniqueId).withSuffix("Widget"),
|
||||||
designContext);
|
designContext);
|
||||||
command->setAttribute(Core::Command::CA_Hide);
|
command->setAttribute(Core::Command::CA_Hide);
|
||||||
viewCommands.append(command);
|
viewCommands.append(command);
|
||||||
@@ -368,8 +368,7 @@ void DesignModeWidget::setup()
|
|||||||
|
|
||||||
// Create menu action
|
// Create menu action
|
||||||
auto command = Core::ActionManager::registerAction(dockWidget->toggleViewAction(),
|
auto command = Core::ActionManager::registerAction(dockWidget->toggleViewAction(),
|
||||||
actionToggle.withSuffix(
|
actionToggle.withSuffix(widgetInfo.uniqueId).withSuffix("Widget"),
|
||||||
widgetInfo.uniqueId + "Widget"),
|
|
||||||
designContext);
|
designContext);
|
||||||
command->setAttribute(Core::Command::CA_Hide);
|
command->setAttribute(Core::Command::CA_Hide);
|
||||||
viewCommands.append(command);
|
viewCommands.append(command);
|
||||||
|
@@ -225,7 +225,7 @@ static QSet<Id> versionedIds(const QByteArray &prefix, int major, int minor)
|
|||||||
if (major < 0)
|
if (major < 0)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
const QByteArray majorStr = QString::number(major).toLatin1();
|
const QByteArray majorStr = QByteArray::number(major);
|
||||||
const QByteArray featureMajor = prefix + majorStr;
|
const QByteArray featureMajor = prefix + majorStr;
|
||||||
const QByteArray featureDotMajor = prefix + '.' + majorStr;
|
const QByteArray featureDotMajor = prefix + '.' + majorStr;
|
||||||
|
|
||||||
@@ -233,9 +233,8 @@ static QSet<Id> versionedIds(const QByteArray &prefix, int major, int minor)
|
|||||||
result.insert(Id::fromName(featureDotMajor));
|
result.insert(Id::fromName(featureDotMajor));
|
||||||
|
|
||||||
for (int i = 0; i <= minor; ++i) {
|
for (int i = 0; i <= minor; ++i) {
|
||||||
const QByteArray minorStr = QString::number(i).toLatin1();
|
result.insert(Id::fromName(featureMajor).withSuffix('.').withSuffix(i));
|
||||||
result.insert(Id::fromName(featureMajor + '.' + minorStr));
|
result.insert(Id::fromName(featureDotMajor).withSuffix('.').withSuffix(i));
|
||||||
result.insert(Id::fromName(featureDotMajor + '.' + minorStr));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Terrible hack. Get rid of using version numbers as tags!
|
// FIXME: Terrible hack. Get rid of using version numbers as tags!
|
||||||
|
Reference in New Issue
Block a user