Qnx: Code cosmetics

Change-Id: Ibc7dc07166c79d65005d88a297916c54d30168cb
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2020-09-16 13:34:30 +02:00
parent c2d49bfa5f
commit 03983a2648
7 changed files with 44 additions and 48 deletions

View File

@@ -29,6 +29,8 @@
#include <coreplugin/icore.h>
#include <utils/persistentsettings.h>
using namespace Utils;
namespace Qnx {
namespace Internal {
@@ -36,10 +38,9 @@ const QLatin1String QNXConfigDataKey("QNXConfiguration.");
const QLatin1String QNXConfigCountKey("QNXConfiguration.Count");
const QLatin1String QNXConfigsFileVersionKey("Version");
static Utils::FilePath qnxConfigSettingsFileName()
static FilePath qnxConfigSettingsFileName()
{
return Utils::FilePath::fromString(Core::ICore::userResourcePath() + QLatin1String("/qnx/")
+ QLatin1String(Constants::QNX_CONFIGS_FILENAME));
return FilePath::fromString(Core::ICore::userResourcePath() + "/qnx/qnxconfigurations.xml");
}
static QnxConfigurationManager *m_instance = nullptr;
@@ -47,8 +48,7 @@ static QnxConfigurationManager *m_instance = nullptr;
QnxConfigurationManager::QnxConfigurationManager()
{
m_instance = this;
m_writer = new Utils::PersistentSettingsWriter(qnxConfigSettingsFileName(),
QLatin1String("QnxConfigurations"));
m_writer = new PersistentSettingsWriter(qnxConfigSettingsFileName(), "QnxConfigurations");
restoreConfigurations();
connect(Core::ICore::instance(), &Core::ICore::saveSettingsRequested,
this, &QnxConfigurationManager::saveConfigs);
@@ -84,7 +84,7 @@ bool QnxConfigurationManager::addConfiguration(QnxConfiguration *config)
if (!config || !config->isValid())
return false;
foreach (QnxConfiguration *c, m_configurations) {
for (QnxConfiguration *c : qAsConst(m_configurations)) {
if (c->envFile() == config->envFile())
return false;
}
@@ -94,9 +94,9 @@ bool QnxConfigurationManager::addConfiguration(QnxConfiguration *config)
return true;
}
QnxConfiguration *QnxConfigurationManager::configurationFromEnvFile(const Utils::FilePath &envFile) const
QnxConfiguration *QnxConfigurationManager::configurationFromEnvFile(const FilePath &envFile) const
{
foreach (QnxConfiguration *c, m_configurations) {
for (QnxConfiguration *c : m_configurations) {
if (c->envFile() == envFile)
return c;
}
@@ -110,7 +110,7 @@ void QnxConfigurationManager::saveConfigs()
QVariantMap data;
data.insert(QLatin1String(QNXConfigsFileVersionKey), 1);
int count = 0;
foreach (QnxConfiguration *config, m_configurations) {
for (QnxConfiguration *config : qAsConst(m_configurations)) {
QVariantMap tmp = config->toMap();
if (tmp.isEmpty())
continue;
@@ -126,7 +126,7 @@ void QnxConfigurationManager::saveConfigs()
void QnxConfigurationManager::restoreConfigurations()
{
Utils::PersistentSettingsReader reader;
PersistentSettingsReader reader;
if (!reader.load(qnxConfigSettingsFileName()))
return;
@@ -143,5 +143,5 @@ void QnxConfigurationManager::restoreConfigurations()
}
}
}
}
} // Internal
} // Qnx

View File

@@ -30,9 +30,6 @@
namespace Qnx {
namespace Constants {
const char QNX_TARGET_KEY[] = "QNX_TARGET";
const char QNX_HOST_KEY[] = "QNX_HOST";
const char QNX_QNX_QT[] = "Qt4ProjectManager.QtVersion.QNX.QNX";
const char QNX_QNX_FEATURE[] = "QtSupport.Wizards.FeatureQNX";
@@ -41,16 +38,7 @@ const char QNX_QNX_DEPLOYCONFIGURATION_ID[] = "Qt4ProjectManager.QNX.QNXDeployCo
const char QNX_QNX_OS_TYPE[] = "QnxOsType"; // Also used for device type.
const char QNX_DEBUG_EXECUTABLE[] = "pdebug";
const char QNX_TOOLCHAIN_ID[] = "Qnx.QccToolChain";
// QNX settings constants
const char QNX_SETTINGS_ID[] = "DD.Qnx Configuration";
const char QNX_CONFIGS_FILENAME[] = "qnxconfigurations.xml";
const char QNX_DEBUGGING_GROUP[] = "Debugger.Group.Qnx";
} // namespace Constants
} // namespace Qnx

View File

@@ -71,6 +71,8 @@ using namespace Utils;
namespace Qnx {
namespace Internal {
const char QNX_DEBUG_EXECUTABLE[] = "pdebug";
static QStringList searchPaths(Kit *kit)
{
auto qtVersion = dynamic_cast<QnxQtVersion *>(QtSupport::QtKitAspect::qtVersion(kit));
@@ -107,7 +109,7 @@ public:
QStringList arguments;
if (portsGatherer->useGdbServer()) {
int pdebugPort = portsGatherer->gdbServer().port();
r.executable = FilePath::fromString(Constants::QNX_DEBUG_EXECUTABLE);
r.executable = FilePath::fromString(QNX_DEBUG_EXECUTABLE);
arguments.append(QString::number(pdebugPort));
}
if (portsGatherer->useQmlServer()) {
@@ -201,7 +203,7 @@ public:
const int pdebugPort = portsGatherer->gdbServer().port();
Runnable r;
r.executable = FilePath::fromString(Constants::QNX_DEBUG_EXECUTABLE);
r.executable = FilePath::fromString(QNX_DEBUG_EXECUTABLE);
r.commandLineArguments = QString::number(pdebugPort);
doStart(r, runControl->device());
});

View File

@@ -170,14 +170,16 @@ void QnxPlugin::extensionsInitialized()
connect(&dd->m_attachToQnxApplication, &QAction::triggered,
this, [] { QnxAttachDebugSupport::showProcessesDialog(); });
const char QNX_DEBUGGING_GROUP[] = "Debugger.Group.Qnx";
Core::ActionContainer *mstart = Core::ActionManager::actionContainer(ProjectExplorer::Constants::M_DEBUG_STARTDEBUGGING);
mstart->appendGroup(Constants::QNX_DEBUGGING_GROUP);
mstart->addSeparator(Core::Context(Core::Constants::C_GLOBAL), Constants::QNX_DEBUGGING_GROUP,
mstart->appendGroup(QNX_DEBUGGING_GROUP);
mstart->addSeparator(Core::Context(Core::Constants::C_GLOBAL), QNX_DEBUGGING_GROUP,
&dd->m_debugSeparator);
Core::Command *cmd = Core::ActionManager::registerAction
(&dd->m_attachToQnxApplication, "Debugger.AttachToQnxApplication");
mstart->addAction(cmd, Constants::QNX_DEBUGGING_GROUP);
mstart->addAction(cmd, QNX_DEBUGGING_GROUP);
connect(KitManager::instance(), &KitManager::kitsChanged,
this, [] { dd->updateDebuggerActions(); });

View File

@@ -38,11 +38,16 @@
#include <QDir>
using namespace ProjectExplorer;
using namespace Utils;
namespace Qnx {
namespace Internal {
static char SDP_PATH_KEY[] = "SDKPath";
const char SDP_PATH_KEY[] = "SDKPath";
const char QNX_TARGET_KEY[] = "QNX_TARGET";
const char QNX_HOST_KEY[] = "QNX_HOST";
const char QNX_QNX_FEATURE[] = "QtSupport.Wizards.FeatureQNX";
QnxQtVersion::QnxQtVersion() = default;
@@ -53,16 +58,16 @@ QString QnxQtVersion::description() const
.arg(QnxUtils::cpuDirShortDescription(cpuDir()));
}
QSet<Utils::Id> QnxQtVersion::availableFeatures() const
QSet<Id> QnxQtVersion::availableFeatures() const
{
QSet<Utils::Id> features = QtSupport::BaseQtVersion::availableFeatures();
features.insert(Constants::QNX_QNX_FEATURE);
QSet<Id> features = QtSupport::BaseQtVersion::availableFeatures();
features.insert(QNX_QNX_FEATURE);
features.remove(QtSupport::Constants::FEATURE_QT_CONSOLE);
features.remove(QtSupport::Constants::FEATURE_QT_WEBKIT);
return features;
}
QSet<Utils::Id> QnxQtVersion::targetDeviceTypes() const
QSet<Id> QnxQtVersion::targetDeviceTypes() const
{
return {Constants::QNX_QNX_OS_TYPE};
}
@@ -72,25 +77,25 @@ QString QnxQtVersion::qnxHost() const
if (!m_environmentUpToDate)
updateEnvironment();
foreach (const Utils::EnvironmentItem &item, m_qnxEnv) {
if (item.name == QLatin1String(Constants::QNX_HOST_KEY))
for (const EnvironmentItem &item : m_qnxEnv) {
if (item.name == QLatin1String(QNX_HOST_KEY))
return item.value;
}
return QString();
}
Utils::FilePath QnxQtVersion::qnxTarget() const
FilePath QnxQtVersion::qnxTarget() const
{
if (!m_environmentUpToDate)
updateEnvironment();
foreach (const Utils::EnvironmentItem &item, m_qnxEnv) {
if (item.name == QLatin1String(Constants::QNX_TARGET_KEY))
return Utils::FilePath::fromUserInput(item.value);
for (EnvironmentItem &item : m_qnxEnv) {
if (item.name == QNX_TARGET_KEY)
return FilePath::fromUserInput(item.value);
}
return Utils::FilePath();
return FilePath();
}
QString QnxQtVersion::cpuDir() const
@@ -114,13 +119,13 @@ void QnxQtVersion::fromMap(const QVariantMap &map)
setSdpPath(QDir::fromNativeSeparators(map.value(QLatin1String(SDP_PATH_KEY)).toString()));
}
ProjectExplorer::Abis QnxQtVersion::detectQtAbis() const
Abis QnxQtVersion::detectQtAbis() const
{
ensureMkSpecParsed();
return QnxUtils::convertAbis(BaseQtVersion::detectQtAbis());
}
void QnxQtVersion::addToEnvironment(const ProjectExplorer::Kit *k, Utils::Environment &env) const
void QnxQtVersion::addToEnvironment(const Kit *k, Environment &env) const
{
QtSupport::BaseQtVersion::addToEnvironment(k, env);
updateEnvironment();
@@ -129,12 +134,12 @@ void QnxQtVersion::addToEnvironment(const ProjectExplorer::Kit *k, Utils::Enviro
env.prependOrSetLibrarySearchPath(libraryPath().toString());
}
Utils::Environment QnxQtVersion::qmakeRunEnvironment() const
Environment QnxQtVersion::qmakeRunEnvironment() const
{
if (!sdpPath().isEmpty())
updateEnvironment();
Utils::Environment env = Utils::Environment::systemEnvironment();
Environment env = Environment::systemEnvironment();
env.modify(m_qnxEnv);
return env;
@@ -180,7 +185,7 @@ void QnxQtVersion::updateEnvironment() const
}
}
Utils::EnvironmentItems QnxQtVersion::environment() const
EnvironmentItems QnxQtVersion::environment() const
{
return QnxUtils::qnxEnvironment(sdpPath());
}

View File

@@ -26,7 +26,6 @@
#pragma once
#include "qnxconstants.h"
#include "qnxqtversion.h"
#include <qtsupport/baseqtversion.h>
#include <qtsupport/qtversionfactory.h>

View File

@@ -246,7 +246,7 @@ void QnxSettingsWidget::apply()
QnxSettingsPage::QnxSettingsPage()
{
setId(Constants::QNX_SETTINGS_ID);
setId("DD.Qnx Configuration");
setDisplayName(QnxSettingsWidget::tr("QNX"));
setCategory(ProjectExplorer::Constants::DEVICE_SETTINGS_CATEGORY);
setWidgetCreator([] { return new QnxSettingsWidget; });