Commit 4d02144b authored by hjk's avatar hjk

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 @@
#include <QSettings>
static const char KIT_DATA_KEY[] = "Profile.";
static const char KIT_COUNT_KEY[] = "Profile.Count";
static const char KIT_FILE_VERSION_KEY[] = "Version";
static const char KIT_DEFAULT_KEY[] = "Profile.Default";
static const char KIT_FILENAME[] = "/qtcreator/profiles.xml";
using namespace Core;
using namespace Utils;
using namespace ProjectExplorer::Internal;
using Utils::PersistentSettingsWriter;
using Utils::PersistentSettingsReader;
namespace ProjectExplorer {
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());
return Utils::FileName::fromString(settingsLocation.absolutePath() + QLatin1String(KIT_FILENAME));
QFileInfo settingsLocation(ICore::settings()->fileName());
return FileName::fromString(settingsLocation.absolutePath() + QLatin1String(KIT_FILENAME));
}
namespace ProjectExplorer {
namespace Internal {
// --------------------------------------------------------------------------
// KitManagerPrivate:
// --------------------------------------------------------------------------
......@@ -110,7 +111,7 @@ public:
bool m_initialized;
QList<KitInformation *> m_informationList;
QList<Kit *> m_kitList;
Utils::PersistentSettingsWriter *m_writer;
PersistentSettingsWriter *m_writer;
};
KitManagerPrivate::KitManagerPrivate() :
......@@ -132,7 +133,7 @@ KitManagerPrivate::~KitManagerPrivate()
static Internal::KitManagerPrivate *d;
static KitManager *m_instance;
QObject *KitManager::instance()
KitManager *KitManager::instance()
{
return m_instance;
}
......@@ -140,19 +141,16 @@ QObject *KitManager::instance()
KitManager::KitManager(QObject *parent) :
QObject(parent)
{
d = new Internal::KitManagerPrivate;
d = new KitManagerPrivate;
QTC_CHECK(!m_instance);
m_instance = this;
connect(Core::ICore::instance(), SIGNAL(saveSettingsRequested()),
this, SLOT(saveKits()));
connect(ICore::instance(), &ICore::saveSettingsRequested,
this, &KitManager::saveKits);
connect(this, SIGNAL(kitAdded(ProjectExplorer::Kit*)),
this, SIGNAL(kitsChanged()));
connect(this, SIGNAL(kitRemoved(ProjectExplorer::Kit*)),
this, SIGNAL(kitsChanged()));
connect(this, SIGNAL(kitUpdated(ProjectExplorer::Kit*)),
this, SIGNAL(kitsChanged()));
connect(this, &KitManager::kitAdded, this, &KitManager::kitsChanged);
connect(this, &KitManager::kitRemoved, this, &KitManager::kitsChanged);
connect(this, &KitManager::kitUpdated, this, &KitManager::kitsChanged);
}
void KitManager::restoreKits()
......@@ -171,10 +169,10 @@ void KitManager::restoreKits()
QList<Kit *> kitsToCheck;
// 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));
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
foreach (Kit *k, system.kits) {
k->setAutoDetected(true);
......@@ -190,7 +188,7 @@ void KitManager::restoreKits()
// read all kits from user file
KitList userKits;
Utils::FileName userSettingsFile(settingsFileName());
FileName userSettingsFile(settingsFileName());
if (userSettingsFile.toFileInfo().exists())
userKits = restoreKits(userSettingsFile);
foreach (Kit *k, userKits.kits) {
......@@ -240,7 +238,7 @@ void KitManager::restoreKits()
defaultKit->setUnexpandedDisplayName(tr("Desktop"));
defaultKit->setSdkProvided(false);
defaultKit->setAutoDetected(false);
defaultKit->setIconPath(Utils::FileName::fromLatin1(":///DESKTOP///"));
defaultKit->setIconPath(FileName::fromLatin1(":///DESKTOP///"));
defaultKit->setup();
......@@ -252,14 +250,12 @@ void KitManager::restoreKits()
if (k) {
setDefaultKit(k);
} else if (!defaultKit()) {
k = Utils::findOr(kitsToRegister, 0, [](Kit *k) {
return k->isValid();
});
k = Utils::findOr(kitsToRegister, 0, [](Kit *k) { return k->isValid(); });
if (k)
setDefaultKit(k);
}
d->m_writer = new Utils::PersistentSettingsWriter(settingsFileName(), QLatin1String("QtCreatorProfiles"));
d->m_writer = new PersistentSettingsWriter(settingsFileName(), QLatin1String("QtCreatorProfiles"));
d->m_initialized = true;
emit kitsLoaded();
emit kitsChanged();
......@@ -293,7 +289,7 @@ void KitManager::saveKits()
data.insert(QLatin1String(KIT_COUNT_KEY), count);
data.insert(QLatin1String(KIT_DEFAULT_KEY),
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()
......@@ -354,9 +350,9 @@ QString KitManager::displayNameForPlatform(const QString &platform)
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()) {
QSet<QString> kitPlatforms = k->availablePlatforms();
if (kitPlatforms.isEmpty() || kitPlatforms.contains(platform))
......@@ -365,7 +361,7 @@ Core::FeatureSet KitManager::availableFeatures(const QString &platform)
return features;
}
KitManager::KitList KitManager::restoreKits(const Utils::FileName &fileName)
KitManager::KitList KitManager::restoreKits(const FileName &fileName)
{
KitList result;
......@@ -401,7 +397,7 @@ KitManager::KitList KitManager::restoreKits(const Utils::FileName &fileName)
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())
return result;
......@@ -428,7 +424,7 @@ QList<Kit *> KitManager::matchingKits(const KitMatcher &matcher)
return result;
}
Kit *KitManager::find(Core::Id id)
Kit *KitManager::find(Id id)
{
if (!id.isValid())
return 0;
......@@ -453,9 +449,9 @@ QList<KitInformation *> KitManager::kitInformation()
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())
result->addConfigWidget(ki->createConfigWidget(result->workingCopy()));
......@@ -552,7 +548,7 @@ void KitManager::addKit(Kit *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(env);
......@@ -583,10 +579,10 @@ QString KitInformation::displayNameForPlatform(const Kit *k, const QString &plat
return QString();
}
Core::FeatureSet KitInformation::availableFeatures(const Kit *k) const
FeatureSet KitInformation::availableFeatures(const Kit *k) const
{
Q_UNUSED(k);
return Core::FeatureSet();
return FeatureSet();
}
bool KitInformation::resolveMacro(const Kit *kit, const QString &name, QString *ret) const
......@@ -607,17 +603,17 @@ void KitInformation::notifyAboutUpdate(Kit *k)
// KitFeatureProvider:
// --------------------------------------------------------------------
Core::FeatureSet Internal::KitFeatureProvider::availableFeatures(const QString &platform) const
FeatureSet KitFeatureProvider::availableFeatures(const QString &platform) const
{
return KitManager::availableFeatures(platform);
}
QStringList Internal::KitFeatureProvider::availablePlatforms() const
QStringList KitFeatureProvider::availablePlatforms() const
{
return KitManager::availablePlatforms().toList();
}
QString Internal::KitFeatureProvider::displayNameForPlatform(const QString &string) const
QString KitFeatureProvider::displayNameForPlatform(const QString &string) const
{
return KitManager::displayNameForPlatform(string);
}
......
......@@ -129,7 +129,7 @@ class PROJECTEXPLORER_EXPORT KitManager : public QObject
Q_OBJECT
public:
static QObject *instance();
static KitManager *instance();
~KitManager();
static QList<Kit *> kits();
......
......@@ -86,7 +86,7 @@ KitManagerConfigWidget::KitManagerConfigWidget(Kit *k) :
Q_ASSERT(fileSystemFriendlyNameRegexp.isValid());
m_fileSystemFriendlyNameLineEdit->setValidator(new QRegularExpressionValidator(fileSystemFriendlyNameRegexp, m_fileSystemFriendlyNameLineEdit));
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;
inner->setLayout(m_layout);
......@@ -108,14 +108,16 @@ KitManagerConfigWidget::KitManagerConfigWidget(Kit *k) :
discard();
connect(m_iconButton, SIGNAL(clicked()), this, SLOT(setIcon()));
connect(m_nameEdit, SIGNAL(textChanged(QString)), this, SLOT(setDisplayName()));
connect(m_iconButton, &QAbstractButton::clicked,
this, &KitManagerConfigWidget::setIcon);
connect(m_nameEdit, &QLineEdit::textChanged,
this, &KitManagerConfigWidget::setDisplayName);
QObject *km = KitManager::instance();
connect(km, SIGNAL(unmanagedKitUpdated(ProjectExplorer::Kit*)),
this, SLOT(workingCopyWasUpdated(ProjectExplorer::Kit*)));
connect(km, SIGNAL(kitUpdated(ProjectExplorer::Kit*)),
this, SLOT(kitWasUpdated(ProjectExplorer::Kit*)));
KitManager *km = KitManager::instance();
connect(km, &KitManager::unmanagedKitUpdated,
this, &KitManagerConfigWidget::workingCopyWasUpdated);
connect(km, &KitManager::kitUpdated,
this, &KitManagerConfigWidget::kitWasUpdated);
}
KitManagerConfigWidget::~KitManagerConfigWidget()
......@@ -213,7 +215,7 @@ void KitManagerConfigWidget::addConfigWidget(KitConfigWidget *widget)
action->setEnabled(!widget->isSticky());
widget->mainWidget()->addAction(action);
widget->mainWidget()->setContextMenuPolicy(Qt::ActionsContextMenu);
connect(action, SIGNAL(toggled(bool)), this, SLOT(updateMutableState()));
connect(action, &QAction::toggled, this, &KitManagerConfigWidget::updateMutableState);
m_actions << action;
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