2009-07-15 12:28:40 +02:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2012-01-26 18:33:46 +01:00
|
|
|
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
2009-07-15 12:28:40 +02:00
|
|
|
**
|
2012-07-19 12:26:56 +02:00
|
|
|
** Contact: http://www.qt-project.org/
|
2009-07-15 12:28:40 +02:00
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** 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.
|
2009-07-15 12:28:40 +02:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2009-07-15 12:28:40 +02:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "cvssettings.h"
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QSettings>
|
|
|
|
|
#include <QTextStream>
|
2009-07-15 12:28:40 +02:00
|
|
|
|
2011-05-10 15:19:38 +02:00
|
|
|
static const char groupC[] = "CVS";
|
|
|
|
|
static const char commandKeyC[] = "Command";
|
|
|
|
|
static const char rootC[] = "Root";
|
|
|
|
|
static const char promptToSubmitKeyC[] = "PromptForSubmit";
|
|
|
|
|
static const char diffOptionsKeyC[] = "DiffOptions";
|
|
|
|
|
static const char describeByCommitIdKeyC[] = "DescribeByCommitId";
|
|
|
|
|
static const char defaultDiffOptions[] = "-du";
|
|
|
|
|
static const char timeOutKeyC[] = "TimeOut";
|
2009-12-14 12:45:45 +01:00
|
|
|
|
|
|
|
|
enum { defaultTimeOutS = 30 };
|
2009-07-15 12:28:40 +02:00
|
|
|
|
|
|
|
|
static QString defaultCommand()
|
|
|
|
|
{
|
|
|
|
|
QString rc;
|
|
|
|
|
rc = QLatin1String("cvs");
|
|
|
|
|
#if defined(Q_OS_WIN32)
|
|
|
|
|
rc.append(QLatin1String(".exe"));
|
|
|
|
|
#endif
|
|
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-07 16:55:09 +01:00
|
|
|
namespace Cvs {
|
2010-04-12 16:34:21 +02:00
|
|
|
namespace Internal {
|
2009-07-15 12:28:40 +02:00
|
|
|
|
2012-01-07 16:55:09 +01:00
|
|
|
CvsSettings::CvsSettings() :
|
2009-07-15 12:28:40 +02:00
|
|
|
cvsCommand(defaultCommand()),
|
|
|
|
|
cvsDiffOptions(QLatin1String(defaultDiffOptions)),
|
2009-12-14 12:45:45 +01:00
|
|
|
timeOutS(defaultTimeOutS),
|
2009-07-15 12:28:40 +02:00
|
|
|
promptToSubmit(true),
|
|
|
|
|
describeByCommitId(true)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-07 16:55:09 +01:00
|
|
|
void CvsSettings::fromSettings(QSettings *settings)
|
2009-07-15 12:28:40 +02:00
|
|
|
{
|
|
|
|
|
settings->beginGroup(QLatin1String(groupC));
|
|
|
|
|
cvsCommand = settings->value(QLatin1String(commandKeyC), defaultCommand()).toString();
|
|
|
|
|
promptToSubmit = settings->value(QLatin1String(promptToSubmitKeyC), true).toBool();
|
|
|
|
|
cvsRoot = settings->value(QLatin1String(rootC), QString()).toString();
|
|
|
|
|
cvsDiffOptions = settings->value(QLatin1String(diffOptionsKeyC), QLatin1String(defaultDiffOptions)).toString();
|
|
|
|
|
describeByCommitId = settings->value(QLatin1String(describeByCommitIdKeyC), true).toBool();
|
2009-12-14 12:45:45 +01:00
|
|
|
timeOutS = settings->value(QLatin1String(timeOutKeyC), defaultTimeOutS).toInt();
|
2009-07-15 12:28:40 +02:00
|
|
|
settings->endGroup();
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-07 16:55:09 +01:00
|
|
|
void CvsSettings::toSettings(QSettings *settings) const
|
2009-07-15 12:28:40 +02:00
|
|
|
{
|
|
|
|
|
settings->beginGroup(QLatin1String(groupC));
|
|
|
|
|
settings->setValue(QLatin1String(commandKeyC), cvsCommand);
|
|
|
|
|
settings->setValue(QLatin1String(promptToSubmitKeyC), promptToSubmit);
|
|
|
|
|
settings->setValue(QLatin1String(rootC), cvsRoot);
|
|
|
|
|
settings->setValue(QLatin1String(diffOptionsKeyC), cvsDiffOptions);
|
2009-12-14 12:45:45 +01:00
|
|
|
settings->setValue(QLatin1String(timeOutKeyC), timeOutS);
|
2009-07-15 12:28:40 +02:00
|
|
|
settings->setValue(QLatin1String(describeByCommitIdKeyC), describeByCommitId);
|
|
|
|
|
settings->endGroup();
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-07 16:55:09 +01:00
|
|
|
bool CvsSettings::equals(const CvsSettings &s) const
|
2009-07-15 12:28:40 +02:00
|
|
|
{
|
2011-09-01 14:10:00 +00:00
|
|
|
return promptToSubmit == s.promptToSubmit
|
2009-07-15 12:28:40 +02:00
|
|
|
&& describeByCommitId == s.describeByCommitId
|
|
|
|
|
&& cvsCommand == s.cvsCommand
|
|
|
|
|
&& cvsRoot == s.cvsRoot
|
2009-12-14 12:45:45 +01:00
|
|
|
&& timeOutS == s.timeOutS
|
2009-07-15 12:28:40 +02:00
|
|
|
&& cvsDiffOptions == s.cvsDiffOptions;
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-07 16:55:09 +01:00
|
|
|
QStringList CvsSettings::addOptions(const QStringList &args) const
|
2009-07-15 12:28:40 +02:00
|
|
|
{
|
|
|
|
|
if (cvsRoot.isEmpty())
|
|
|
|
|
return args;
|
|
|
|
|
|
|
|
|
|
QStringList rc;
|
|
|
|
|
rc.push_back(QLatin1String("-d"));
|
|
|
|
|
rc.push_back(cvsRoot);
|
|
|
|
|
rc.append(args);
|
|
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-12 16:34:21 +02:00
|
|
|
} // namespace Internal
|
2012-01-07 16:55:09 +01:00
|
|
|
} // namespace Cvs
|