summaryrefslogtreecommitdiff
path: root/src/plugins/bazaar/bazaarsettings.cpp
diff options
context:
space:
mode:
authorcerf <delorme.hugues@gmail.com>2011-09-14 09:13:44 +0000
committerTobias Hunger <tobias.hunger@nokia.com>2011-09-14 13:22:30 +0200
commit10b667ad588ddb85c858fe30e042e75bbea040a9 (patch)
tree04f580a851a5e8dc8051f2b65fcb620fbe65a057 /src/plugins/bazaar/bazaarsettings.cpp
parenta67d8205b19784b1b8237b7d4ecd1c13ca09c547 (diff)
downloadqt-creator-10b667ad588ddb85c858fe30e042e75bbea040a9.tar.gz
vcsbase: add mechanism to ease management of VCS settings
Management of VCS settings was rather laborious (see BazaarSettings, GitSettings, ...). To overcome this, the base class VCSBaseClientSettings is now equipped with a mechanism factorizing redundant code for VCS settings, like operator=(), operator==(), writeSettings(), ... Heir classes of VCSBaseClientSettings only need to declare the settings (key + default value). Bazaar and Mercurial plugins are impacted. Change-Id: I7e4093a6d9476f3c8954f4d104f1b26ac185beb9 Merge-request: 2204 Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com> Reviewed-on: http://codereview.qt-project.org/4889 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Diffstat (limited to 'src/plugins/bazaar/bazaarsettings.cpp')
-rw-r--r--src/plugins/bazaar/bazaarsettings.cpp85
1 files changed, 17 insertions, 68 deletions
diff --git a/src/plugins/bazaar/bazaarsettings.cpp b/src/plugins/bazaar/bazaarsettings.cpp
index bede461bc5..1b2ab233b5 100644
--- a/src/plugins/bazaar/bazaarsettings.cpp
+++ b/src/plugins/bazaar/bazaarsettings.cpp
@@ -38,81 +38,30 @@
namespace Bazaar {
namespace Internal {
-const QLatin1String diffIgnoreWhiteSpaceKey("diffIgnoreWhiteSpace");
-const QLatin1String diffIgnoreBlankLinesKey("diffIgnoreBlankLines");
-const QLatin1String logVerboseKey("logVerbose");
-const QLatin1String logForwardKey("logForward");
-const QLatin1String logIncludeMergesKey("logIncludeMerges");
-const QLatin1String logFormatKey("logFormat");
+const QLatin1String BazaarSettings::diffIgnoreWhiteSpaceKey("diffIgnoreWhiteSpace");
+const QLatin1String BazaarSettings::diffIgnoreBlankLinesKey("diffIgnoreBlankLines");
+const QLatin1String BazaarSettings::logVerboseKey("logVerbose");
+const QLatin1String BazaarSettings::logForwardKey("logForward");
+const QLatin1String BazaarSettings::logIncludeMergesKey("logIncludeMerges");
+const QLatin1String BazaarSettings::logFormatKey("logFormat");
-BazaarSettings::BazaarSettings() :
- diffIgnoreWhiteSpace(false),
- diffIgnoreBlankLines(false),
- logVerbose(false),
- logForward(false),
- logIncludeMerges(false),
- logFormat(QLatin1String("long"))
+BazaarSettings::BazaarSettings()
{
setSettingsGroup(QLatin1String(Constants::BAZAAR));
- setDefaultBinary(QLatin1String(Constants::BAZAARDEFAULT));
-}
-
-BazaarSettings& BazaarSettings::operator=(const BazaarSettings& other)
-{
- VCSBase::VCSBaseClientSettings::operator=(other);
- if (this != &other) {
- diffIgnoreWhiteSpace = other.diffIgnoreWhiteSpace;
- diffIgnoreBlankLines = other.diffIgnoreBlankLines;
- logVerbose = other.logVerbose;
- logForward = other.logForward;
- logIncludeMerges = other.logIncludeMerges;
- logFormat = other.logFormat;
- }
- return *this;
+ // Override default binary path
+ declareKey(binaryPathKey, QLatin1String(Constants::BAZAARDEFAULT));
+ declareKey(diffIgnoreWhiteSpaceKey, false);
+ declareKey(diffIgnoreBlankLinesKey, false);
+ declareKey(logVerboseKey, false);
+ declareKey(logForwardKey, false);
+ declareKey(logIncludeMergesKey, false);
+ declareKey(logFormatKey, QLatin1String("long"));
}
bool BazaarSettings::sameUserId(const BazaarSettings& other) const
{
- return userName() == other.userName() && email() == other.email();
-}
-
-void BazaarSettings::writeSettings(QSettings *settings) const
-{
- VCSBaseClientSettings::writeSettings(settings);
- settings->beginGroup(settingsGroup());
- settings->setValue(diffIgnoreWhiteSpaceKey, diffIgnoreWhiteSpace);
- settings->setValue(diffIgnoreBlankLinesKey, diffIgnoreBlankLines);
- settings->setValue(logVerboseKey, logVerbose);
- settings->setValue(logForwardKey, logForward);
- settings->setValue(logIncludeMergesKey, logIncludeMerges);
- settings->setValue(logFormatKey, logFormat);
- settings->endGroup();
-}
-
-void BazaarSettings::readSettings(const QSettings *settings)
-{
- VCSBaseClientSettings::readSettings(settings);
- const QString keyRoot = settingsGroup() + QLatin1Char('/');
- diffIgnoreWhiteSpace = settings->value(keyRoot + diffIgnoreWhiteSpaceKey, false).toBool();
- diffIgnoreBlankLines = settings->value(keyRoot + diffIgnoreBlankLinesKey, false).toBool();
- logVerbose = settings->value(keyRoot + logVerboseKey, false).toBool();
- logForward = settings->value(keyRoot + logForwardKey, false).toBool();
- logIncludeMerges = settings->value(keyRoot + logIncludeMergesKey, false).toBool();
- logFormat = settings->value(keyRoot + logFormatKey, QLatin1String("long")).toString();
-}
-
-bool BazaarSettings::equals(const VCSBaseClientSettings &rhs) const
-{
- const BazaarSettings *bzrRhs = dynamic_cast<const BazaarSettings *>(&rhs);
- if (bzrRhs == 0)
- return false;
- return VCSBaseClientSettings::equals(rhs)
- && diffIgnoreWhiteSpace == bzrRhs->diffIgnoreWhiteSpace
- && diffIgnoreBlankLines == bzrRhs->diffIgnoreBlankLines
- && logVerbose == bzrRhs->logVerbose
- && logForward == bzrRhs->logForward
- && logIncludeMerges == bzrRhs->logIncludeMerges
- && logFormat == bzrRhs->logFormat;
+ return stringValue(userNameKey) == other.stringValue(userNameKey) &&
+ stringValue(userEmailKey) == other.stringValue(userEmailKey);
}
} // namespace Internal