2009-03-19 17:40:01 +01:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2010-03-05 11:25:49 +01:00
|
|
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
2009-03-19 17:40:01 +01:00
|
|
|
**
|
2009-06-17 00:01:27 +10:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2009-03-19 17:40:01 +01:00
|
|
|
**
|
|
|
|
|
** Commercial Usage
|
|
|
|
|
**
|
|
|
|
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
|
|
|
** accordance with the Qt Commercial License Agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Nokia.
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
|
**
|
|
|
|
|
** If you are unsure which license is appropriate for your use, please
|
2009-08-14 09:30:56 +02:00
|
|
|
** contact the sales department at http://qt.nokia.com/contact.
|
2009-03-19 17:40:01 +01:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
2010-04-12 16:34:21 +02:00
|
|
|
#include "commonvcssettings.h"
|
2009-03-19 17:40:01 +01:00
|
|
|
|
|
|
|
|
#include <QtCore/QSettings>
|
|
|
|
|
#include <QtCore/QDebug>
|
|
|
|
|
|
2010-05-21 17:46:00 +02:00
|
|
|
static const char settingsGroupC[] = "VCS";
|
|
|
|
|
static const char nickNameMailMapKeyC[] = "NickNameMailMap";
|
|
|
|
|
static const char nickNameFieldListFileKeyC[] = "NickNameFieldListFile";
|
|
|
|
|
static const char submitMessageCheckScriptKeyC[] = "SubmitMessageCheckScript";
|
|
|
|
|
static const char lineWrapKeyC[] = "LineWrap";
|
|
|
|
|
static const char lineWrapWidthKeyC[] = "LineWrapWidth";
|
|
|
|
|
static const char sshPasswordPromptKeyC[] = "SshPasswordPrompt";
|
2009-03-20 14:20:28 +01:00
|
|
|
|
|
|
|
|
static const int lineWrapWidthDefault = 72;
|
|
|
|
|
static const bool lineWrapDefault = true;
|
2009-03-19 17:40:01 +01:00
|
|
|
|
2010-05-21 17:46:00 +02:00
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
|
static const char sshPasswordPromptDefaultC[] = "win-ssh-askpass";
|
|
|
|
|
#else
|
|
|
|
|
static const char sshPasswordPromptDefaultC[] = "ssh-askpass";
|
|
|
|
|
#endif
|
|
|
|
|
|
2009-03-19 17:40:01 +01:00
|
|
|
namespace VCSBase {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2010-04-12 16:34:21 +02:00
|
|
|
CommonVcsSettings::CommonVcsSettings() :
|
2010-05-21 17:46:00 +02:00
|
|
|
sshPasswordPrompt(QLatin1String(sshPasswordPromptDefaultC)),
|
2009-03-20 14:20:28 +01:00
|
|
|
lineWrap(lineWrapDefault),
|
|
|
|
|
lineWrapWidth(lineWrapWidthDefault)
|
2009-03-19 17:40:01 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-12 16:34:21 +02:00
|
|
|
void CommonVcsSettings::toSettings(QSettings *s) const
|
2009-03-19 17:40:01 +01:00
|
|
|
{
|
|
|
|
|
s->beginGroup(QLatin1String(settingsGroupC));
|
|
|
|
|
s->setValue(QLatin1String(nickNameMailMapKeyC), nickNameMailMap);
|
|
|
|
|
s->setValue(QLatin1String(nickNameFieldListFileKeyC), nickNameFieldListFile);
|
|
|
|
|
s->setValue(QLatin1String(submitMessageCheckScriptKeyC), submitMessageCheckScript);
|
2009-03-20 14:20:28 +01:00
|
|
|
s->setValue(QLatin1String(lineWrapKeyC), lineWrap);
|
|
|
|
|
s->setValue(QLatin1String(lineWrapWidthKeyC), lineWrapWidth);
|
2010-05-21 17:46:00 +02:00
|
|
|
s->setValue(QLatin1String(sshPasswordPromptKeyC), sshPasswordPrompt);
|
2009-03-19 17:40:01 +01:00
|
|
|
s->endGroup();
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-12 16:34:21 +02:00
|
|
|
void CommonVcsSettings::fromSettings(QSettings *s)
|
2009-03-19 17:40:01 +01:00
|
|
|
{
|
|
|
|
|
s->beginGroup(QLatin1String(settingsGroupC));
|
|
|
|
|
nickNameMailMap = s->value(QLatin1String(nickNameMailMapKeyC), QString()).toString();
|
|
|
|
|
nickNameFieldListFile = s->value(QLatin1String(nickNameFieldListFileKeyC), QString()).toString();
|
|
|
|
|
submitMessageCheckScript = s->value(QLatin1String(submitMessageCheckScriptKeyC), QString()).toString();
|
2009-03-20 14:20:28 +01:00
|
|
|
lineWrap = s->value(QLatin1String(lineWrapKeyC), lineWrapDefault).toBool();
|
|
|
|
|
lineWrapWidth = s->value(QLatin1String(lineWrapWidthKeyC), lineWrapWidthDefault).toInt();
|
2010-05-21 17:46:00 +02:00
|
|
|
sshPasswordPrompt = s->value(QLatin1String(sshPasswordPromptKeyC), QLatin1String(sshPasswordPromptDefaultC)).toString();
|
2009-03-19 17:40:01 +01:00
|
|
|
s->endGroup();
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-12 16:34:21 +02:00
|
|
|
bool CommonVcsSettings::equals(const CommonVcsSettings &rhs) const
|
2009-03-19 17:40:01 +01:00
|
|
|
{
|
2009-06-19 16:34:38 +02:00
|
|
|
return lineWrap == rhs.lineWrap
|
2009-03-20 14:20:28 +01:00
|
|
|
&& lineWrapWidth == rhs.lineWrapWidth
|
2009-03-19 17:40:01 +01:00
|
|
|
&& nickNameMailMap == rhs.nickNameMailMap
|
|
|
|
|
&& nickNameFieldListFile == rhs.nickNameFieldListFile
|
2010-05-21 17:46:00 +02:00
|
|
|
&& submitMessageCheckScript == rhs.submitMessageCheckScript
|
|
|
|
|
&& sshPasswordPrompt == rhs.sshPasswordPrompt;
|
2009-03-19 17:40:01 +01:00
|
|
|
}
|
|
|
|
|
|
2010-04-12 16:34:21 +02:00
|
|
|
QDebug operator<<(QDebug d,const CommonVcsSettings& s)
|
2009-03-20 14:20:28 +01:00
|
|
|
{
|
2009-06-19 16:34:38 +02:00
|
|
|
d.nospace() << " lineWrap=" << s.lineWrap
|
2009-03-20 14:20:28 +01:00
|
|
|
<< " lineWrapWidth=" << s.lineWrapWidth
|
|
|
|
|
<< " nickNameMailMap='" << s.nickNameMailMap
|
|
|
|
|
<< "' nickNameFieldListFile='" << s.nickNameFieldListFile
|
2010-05-21 17:46:00 +02:00
|
|
|
<< "'submitMessageCheckScript='" << s.submitMessageCheckScript
|
|
|
|
|
<< "'sshPasswordPrompt='" << s.sshPasswordPrompt
|
|
|
|
|
<< "'\n";
|
2009-03-20 14:20:28 +01:00
|
|
|
return d;
|
|
|
|
|
}
|
2010-04-12 16:34:21 +02:00
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace VCSBase
|