Commit 4d02144b authored by hjk's avatar hjk
Browse files

KitManager: namespaces and Qt 5 cosmetics



Change-Id: I584b24ec8ead56ea7a53921fac1f39881b2ce0a8
Reviewed-by: default avatarChristian Stenger <christian.stenger@digia.com>
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent db1c21a3
...@@ -48,24 +48,25 @@ ...@@ -48,24 +48,25 @@
#include <QSettings> #include <QSettings>
static const char KIT_DATA_KEY[] = "Profile."; using namespace Core;
static const char KIT_COUNT_KEY[] = "Profile.Count"; using namespace Utils;
static const char KIT_FILE_VERSION_KEY[] = "Version"; using namespace ProjectExplorer::Internal;
static const char KIT_DEFAULT_KEY[] = "Profile.Default";
static const char KIT_FILENAME[] = "/qtcreator/profiles.xml";
using Utils::PersistentSettingsWriter; namespace ProjectExplorer {
using Utils::PersistentSettingsReader; namespace Internal {
const char KIT_DATA_KEY[] = "Profile.";
const char KIT_COUNT_KEY[] = "Profile.Count";
const char KIT_FILE_VERSION_KEY[] = "Version";
const char KIT_DEFAULT_KEY[] = "Profile.Default";
const char KIT_FILENAME[] = "/qtcreator/profiles.xml";
static Utils::FileName settingsFileName() static FileName settingsFileName()
{ {
QFileInfo settingsLocation(Core::ICore::settings()->fileName()); QFileInfo settingsLocation(ICore::settings()->fileName());
return Utils::FileName::fromString(settingsLocation.absolutePath() + QLatin1String(KIT_FILENAME)); return FileName::fromString(settingsLocation.absolutePath() + QLatin1String(KIT_FILENAME));
} }
namespace ProjectExplorer {
namespace Internal {
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// KitManagerPrivate: // KitManagerPrivate:
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
...@@ -110,7 +111,7 @@ public: ...@@ -110,7 +111,7 @@ public:
bool m_initialized; bool m_initialized;
QList<KitInformation *> m_informationList; QList<KitInformation *> m_informationList;
QList<Kit *> m_kitList; QList<Kit *> m_kitList;
Utils::PersistentSettingsWriter *m_writer; PersistentSettingsWriter *m_writer;
}; };
KitManagerPrivate::KitManagerPrivate() : KitManagerPrivate::KitManagerPrivate() :
...@@ -132,7 +133,7 @@ KitManagerPrivate::~KitManagerPrivate() ...@@ -132,7 +133,7 @@ KitManagerPrivate::~KitManagerPrivate()
static Internal::KitManagerPrivate *d; static Internal::KitManagerPrivate *d;
static KitManager *m_instance; static KitManager *m_instance;
QObject *KitManager::instance() KitManager *KitManager::instance()
{ {
return m_instance; return m_instance;
} }
...@@ -140,19 +141,16 @@ QObject *KitManager::instance() ...@@ -140,19 +141,16 @@ QObject *KitManager::instance()
KitManager::KitManager(QObject *parent) : KitManager::KitManager(QObject *parent) :
QObject(parent) QObject(parent)
{ {
d = new Internal::KitManagerPrivate; d = new KitManagerPrivate;
QTC_CHECK(!m_instance); QTC_CHECK(!m_instance);
m_instance = this; m_instance = this;
connect(Core::ICore::instance(), SIGNAL(saveSettingsRequested()), connect(ICore::instance(), &ICore::saveSettingsRequested,
this, SLOT(saveKits())); this, &KitManager::saveKits);
connect(this, SIGNAL(kitAdded(ProjectExplorer::Kit*)), connect(this, &KitManager::kitAdded, this, &KitManager::kitsChanged);
this, SIGNAL(kitsChanged())); connect(this, &KitManager::kitRemoved, this, &KitManager::kitsChanged);
connect(this, SIGNAL(kitRemoved(ProjectExplorer::Kit*)), connect(this, &KitManager::kitUpdated, this, &KitManager::kitsChanged);
this, SIGNAL(kitsChanged()));
connect(this, SIGNAL(kitUpdated(ProjectExplorer::Kit*)),
this, SIGNAL(kitsChanged()));
} }
void KitManager::restoreKits() void KitManager::restoreKits()
...@@ -171,10 +169,10 @@ void KitManager::restoreKits() ...@@ -171,10 +169,10 @@ void KitManager::restoreKits()
QList<Kit *> kitsToCheck; QList<Kit *> kitsToCheck;
// read all kits from SDK // read all kits from SDK
QFileInfo systemSettingsFile(Core::ICore::settings(QSettings::SystemScope)->fileName()); QFileInfo systemSettingsFile(ICore::settings(QSettings::SystemScope)->fileName());
QFileInfo kitFile(systemSettingsFile.absolutePath() + QLatin1String(KIT_FILENAME)); QFileInfo kitFile(systemSettingsFile.absolutePath() + QLatin1String(KIT_FILENAME));
if (kitFile.exists()) { if (kitFile.exists()) {
KitList system = restoreKits(Utils::FileName(kitFile)); KitList system = restoreKits(FileName(kitFile));
// make sure we mark these as autodetected and run additional setup logic // make sure we mark these as autodetected and run additional setup logic
foreach (Kit *k, system.kits) { foreach (Kit *k, system.kits) {
k->setAutoDetected(true); k->setAutoDetected(true);
...@@ -190,7 +188,7 @@ void KitManager::restoreKits() ...@@ -190,7 +188,7 @@ void KitManager::restoreKits()
// read all kits from user file // read all kits from user file
KitList userKits; KitList userKits;
Utils::FileName userSettingsFile(settingsFileName()); FileName userSettingsFile(settingsFileName());
if (userSettingsFile.toFileInfo().exists()) if (userSettingsFile.toFileInfo().exists())
userKits = restoreKits(userSettingsFile); userKits = restoreKits(userSettingsFile);
foreach (Kit *k, userKits.kits) { foreach (Kit *k, userKits.kits) {
...@@ -240,7 +238,7 @@ void KitManager::restoreKits() ...@@ -240,7 +238,7 @@ void KitManager::restoreKits()
defaultKit->setUnexpandedDisplayName(tr("Desktop")); defaultKit->setUnexpandedDisplayName(tr("Desktop"));
defaultKit->setSdkProvided(false); defaultKit->setSdkProvided(false);
defaultKit->setAutoDetected(false); defaultKit->setAutoDetected(false);
defaultKit->setIconPath(Utils::FileName::fromLatin1(":///DESKTOP///")); defaultKit->setIconPath(FileName::fromLatin1(":///DESKTOP///"));
defaultKit->setup(); defaultKit->setup();
...@@ -252,14 +250,12 @@ void KitManager::restoreKits() ...@@ -252,14 +250,12 @@ void KitManager::restoreKits()
if (k) { if (k) {
setDefaultKit(k); setDefaultKit(k);
} else if (!defaultKit()) { } else if (!defaultKit()) {
k = Utils::findOr(kitsToRegister, 0, [](Kit *k) { k = Utils::findOr(kitsToRegister, 0, [](Kit *k) { return k->isValid(); });
return k->isValid();
});
if (k) if (k)
setDefaultKit(k); setDefaultKit(k);
} }
d->m_writer = new Utils::PersistentSettingsWriter(settingsFileName(), QLatin1String("QtCreatorProfiles")); d->m_writer = new PersistentSettingsWriter(settingsFileName(), QLatin1String("QtCreatorProfiles"));
d->m_initialized = true; d->m_initialized = true;
emit kitsLoaded(); emit kitsLoaded();
emit kitsChanged(); emit kitsChanged();
...@@ -293,7 +289,7 @@ void KitManager::saveKits() ...@@ -293,7 +289,7 @@ void KitManager::saveKits()
data.insert(QLatin1String(KIT_COUNT_KEY), count); data.insert(QLatin1String(KIT_COUNT_KEY), count);
data.insert(QLatin1String(KIT_DEFAULT_KEY), data.insert(QLatin1String(KIT_DEFAULT_KEY),
d->m_defaultKit ? QString::fromLatin1(d->m_defaultKit->id().name()) : QString()); d->m_defaultKit ? QString::fromLatin1(d->m_defaultKit->id().name()) : QString());
d->m_writer->save(data, Core::ICore::mainWindow()); d->m_writer->save(data, ICore::mainWindow());
} }
static bool isLoaded() static bool isLoaded()
...@@ -354,9 +350,9 @@ QString KitManager::displayNameForPlatform(const QString &platform) ...@@ -354,9 +350,9 @@ QString KitManager::displayNameForPlatform(const QString &platform)
return QString(); return QString();
} }
Core::FeatureSet KitManager::availableFeatures(const QString &platform) FeatureSet KitManager::availableFeatures(const QString &platform)
{ {
Core::FeatureSet features; FeatureSet features;
foreach (const Kit *k, kits()) { foreach (const Kit *k, kits()) {
QSet<QString> kitPlatforms = k->availablePlatforms(); QSet<QString> kitPlatforms = k->availablePlatforms();
if (kitPlatforms.isEmpty() || kitPlatforms.contains(platform)) if (kitPlatforms.isEmpty() || kitPlatforms.contains(platform))
...@@ -365,7 +361,7 @@ Core::FeatureSet KitManager::availableFeatures(const QString &platform) ...@@ -365,7 +361,7 @@ Core::FeatureSet KitManager::availableFeatures(const QString &platform)
return features; return features;
} }
KitManager::KitList KitManager::restoreKits(const Utils::FileName &fileName) KitManager::KitList KitManager::restoreKits(const FileName &fileName)
{ {
KitList result; KitList result;
...@@ -401,7 +397,7 @@ KitManager::KitList KitManager::restoreKits(const Utils::FileName &fileName) ...@@ -401,7 +397,7 @@ KitManager::KitList KitManager::restoreKits(const Utils::FileName &fileName)
qPrintable(fileName.toUserOutput()), i); qPrintable(fileName.toUserOutput()), i);
} }
} }
const Core::Id id = Core::Id::fromSetting(data.value(QLatin1String(KIT_DEFAULT_KEY))); const Id id = Id::fromSetting(data.value(QLatin1String(KIT_DEFAULT_KEY)));
if (!id.isValid()) if (!id.isValid())
return result; return result;
...@@ -428,7 +424,7 @@ QList<Kit *> KitManager::matchingKits(const KitMatcher &matcher) ...@@ -428,7 +424,7 @@ QList<Kit *> KitManager::matchingKits(const KitMatcher &matcher)
return result; return result;
} }
Kit *KitManager::find(Core::Id id) Kit *KitManager::find(Id id)
{ {
if (!id.isValid()) if (!id.isValid())
return 0; return 0;
...@@ -453,9 +449,9 @@ QList<KitInformation *> KitManager::kitInformation() ...@@ -453,9 +449,9 @@ QList<KitInformation *> KitManager::kitInformation()
return d->m_informationList; return d->m_informationList;
} }
Internal::KitManagerConfigWidget *KitManager::createConfigWidget(Kit *k) KitManagerConfigWidget *KitManager::createConfigWidget(Kit *k)
{ {
Internal::KitManagerConfigWidget *result = new Internal::KitManagerConfigWidget(k); KitManagerConfigWidget *result = new KitManagerConfigWidget(k);
foreach (KitInformation *ki, kitInformation()) foreach (KitInformation *ki, kitInformation())
result->addConfigWidget(ki->createConfigWidget(result->workingCopy())); result->addConfigWidget(ki->createConfigWidget(result->workingCopy()));
...@@ -552,7 +548,7 @@ void KitManager::addKit(Kit *k) ...@@ -552,7 +548,7 @@ void KitManager::addKit(Kit *k)
d->insertKit(k); d->insertKit(k);
} }
void KitInformation::addToEnvironment(const Kit *k, Utils::Environment &env) const void KitInformation::addToEnvironment(const Kit *k, Environment &env) const
{ {
Q_UNUSED(k); Q_UNUSED(k);
Q_UNUSED(env); Q_UNUSED(env);
...@@ -583,10 +579,10 @@ QString KitInformation::displayNameForPlatform(const Kit *k, const QString &plat ...@@ -583,10 +579,10 @@ QString KitInformation::displayNameForPlatform(const Kit *k, const QString &plat
return QString(); return QString();
} }
Core::FeatureSet KitInformation::availableFeatures(const Kit *k) const FeatureSet KitInformation::availableFeatures(const Kit *k) const
{ {
Q_UNUSED(k); Q_UNUSED(k);
return Core::FeatureSet(); return FeatureSet();
} }
bool KitInformation::resolveMacro(const Kit *kit, const QString &name, QString *ret) const bool KitInformation::resolveMacro(const Kit *kit, const QString &name, QString *ret) const
...@@ -607,17 +603,17 @@ void KitInformation::notifyAboutUpdate(Kit *k) ...@@ -607,17 +603,17 @@ void KitInformation::notifyAboutUpdate(Kit *k)
// KitFeatureProvider: // KitFeatureProvider:
// -------------------------------------------------------------------- // --------------------------------------------------------------------
Core::FeatureSet Internal::KitFeatureProvider::availableFeatures(const QString &platform) const FeatureSet KitFeatureProvider::availableFeatures(const QString &platform) const
{ {
return KitManager::availableFeatures(platform); return KitManager::availableFeatures(platform);
} }
QStringList Internal::KitFeatureProvider::availablePlatforms() const QStringList KitFeatureProvider::availablePlatforms() const
{ {
return KitManager::availablePlatforms().toList(); return KitManager::availablePlatforms().toList();
} }
QString Internal::KitFeatureProvider::displayNameForPlatform(const QString &string) const QString KitFeatureProvider::displayNameForPlatform(const QString &string) const
{ {
return KitManager::displayNameForPlatform(string); return KitManager::displayNameForPlatform(string);
} }
......
...@@ -129,7 +129,7 @@ class PROJECTEXPLORER_EXPORT KitManager : public QObject ...@@ -129,7 +129,7 @@ class PROJECTEXPLORER_EXPORT KitManager : public QObject
Q_OBJECT Q_OBJECT
public: public:
static QObject *instance(); static KitManager *instance();
~KitManager(); ~KitManager();
static QList<Kit *> kits(); static QList<Kit *> kits();
......
...@@ -86,7 +86,7 @@ KitManagerConfigWidget::KitManagerConfigWidget(Kit *k) : ...@@ -86,7 +86,7 @@ KitManagerConfigWidget::KitManagerConfigWidget(Kit *k) :
Q_ASSERT(fileSystemFriendlyNameRegexp.isValid()); Q_ASSERT(fileSystemFriendlyNameRegexp.isValid());
m_fileSystemFriendlyNameLineEdit->setValidator(new QRegularExpressionValidator(fileSystemFriendlyNameRegexp, m_fileSystemFriendlyNameLineEdit)); m_fileSystemFriendlyNameLineEdit->setValidator(new QRegularExpressionValidator(fileSystemFriendlyNameRegexp, m_fileSystemFriendlyNameLineEdit));
m_layout->addWidget(m_fileSystemFriendlyNameLineEdit, 1, WidgetColumn); m_layout->addWidget(m_fileSystemFriendlyNameLineEdit, 1, WidgetColumn);
connect(m_fileSystemFriendlyNameLineEdit, SIGNAL(textChanged(QString)), this, SLOT(setFileSystemFriendlyName())); connect(m_fileSystemFriendlyNameLineEdit, &QLineEdit::textChanged, this, &KitManagerConfigWidget::setFileSystemFriendlyName);
QWidget *inner = new QWidget; QWidget *inner = new QWidget;
inner->setLayout(m_layout); inner->setLayout(m_layout);
...@@ -108,14 +108,16 @@ KitManagerConfigWidget::KitManagerConfigWidget(Kit *k) : ...@@ -108,14 +108,16 @@ KitManagerConfigWidget::KitManagerConfigWidget(Kit *k) :
discard(); discard();
connect(m_iconButton, SIGNAL(clicked()), this, SLOT(setIcon())); connect(m_iconButton, &QAbstractButton::clicked,
connect(m_nameEdit, SIGNAL(textChanged(QString)), this, SLOT(setDisplayName())); this, &KitManagerConfigWidget::setIcon);
connect(m_nameEdit, &QLineEdit::textChanged,
this, &KitManagerConfigWidget::setDisplayName);
QObject *km = KitManager::instance(); KitManager *km = KitManager::instance();
connect(km, SIGNAL(unmanagedKitUpdated(ProjectExplorer::Kit*)), connect(km, &KitManager::unmanagedKitUpdated,
this, SLOT(workingCopyWasUpdated(ProjectExplorer::Kit*))); this, &KitManagerConfigWidget::workingCopyWasUpdated);
connect(km, SIGNAL(kitUpdated(ProjectExplorer::Kit*)), connect(km, &KitManager::kitUpdated,
this, SLOT(kitWasUpdated(ProjectExplorer::Kit*))); this, &KitManagerConfigWidget::kitWasUpdated);
} }
KitManagerConfigWidget::~KitManagerConfigWidget() KitManagerConfigWidget::~KitManagerConfigWidget()
...@@ -213,7 +215,7 @@ void KitManagerConfigWidget::addConfigWidget(KitConfigWidget *widget) ...@@ -213,7 +215,7 @@ void KitManagerConfigWidget::addConfigWidget(KitConfigWidget *widget)
action->setEnabled(!widget->isSticky()); action->setEnabled(!widget->isSticky());
widget->mainWidget()->addAction(action); widget->mainWidget()->addAction(action);
widget->mainWidget()->setContextMenuPolicy(Qt::ActionsContextMenu); widget->mainWidget()->setContextMenuPolicy(Qt::ActionsContextMenu);
connect(action, SIGNAL(toggled(bool)), this, SLOT(updateMutableState())); connect(action, &QAction::toggled, this, &KitManagerConfigWidget::updateMutableState);
m_actions << action; m_actions << action;
int row = m_layout->rowCount(); int row = m_layout->rowCount();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment