subversionsettings.cpp 4.22 KB
Newer Older
1
/**************************************************************************
con's avatar
con committed
2 3 4
**
** This file is part of Qt Creator
**
hjk's avatar
hjk committed
5
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
con's avatar
con committed
6
**
Eike Ziller's avatar
Eike Ziller committed
7
** Contact: http://www.qt-project.org/
con's avatar
con committed
8
**
9
**
10
** GNU Lesser General Public License Usage
11
**
hjk's avatar
hjk committed
12 13 14 15 16 17
** 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.
18
**
con's avatar
con committed
19
** In addition, as a special exception, Nokia gives you certain additional
hjk's avatar
hjk committed
20
** rights. These rights are described in the Nokia Qt LGPL Exception
con's avatar
con committed
21 22
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
23 24 25 26 27
** 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.
**
con's avatar
con committed
28
**
29
**************************************************************************/
hjk's avatar
hjk committed
30

con's avatar
con committed
31 32
#include "subversionsettings.h"

33 34
#include <utils/environment.h>

35
#include <QSettings>
con's avatar
con committed
36

37 38 39 40 41
static const char groupC[] = "Subversion";
static const char commandKeyC[] = "Command";
static const char userKeyC[] = "User";
static const char passwordKeyC[] = "Password";
static const char authenticationKeyC[] = "Authentication";
con's avatar
con committed
42

43 44 45 46
static const char promptToSubmitKeyC[] = "PromptForSubmit";
static const char timeOutKeyC[] = "TimeOut";
static const char spaceIgnorantAnnotationKeyC[] = "SpaceIgnorantAnnotation";
static const char logCountKeyC[] = "LogCount";
47

48
enum { defaultTimeOutS = 30, defaultLogCount = 1000 };
con's avatar
con committed
49 50 51 52 53 54 55 56 57 58 59

static QString defaultCommand()
{
    QString rc;
    rc = QLatin1String("svn");
#if defined(Q_OS_WIN32)
    rc.append(QLatin1String(".exe"));
#endif
    return rc;
}

hjk's avatar
hjk committed
60
using namespace Subversion::Internal;
con's avatar
con committed
61 62 63

SubversionSettings::SubversionSettings() :
    svnCommand(defaultCommand()),
64
    useAuthentication(false),
65
    logCount(defaultLogCount),
66
    timeOutS(defaultTimeOutS),
67 68
    promptToSubmit(true),
    spaceIgnorantAnnotation(true)
con's avatar
con committed
69 70 71 72 73 74 75
{
}

void SubversionSettings::fromSettings(QSettings *settings)
{
    settings->beginGroup(QLatin1String(groupC));
    svnCommand = settings->value(QLatin1String(commandKeyC), defaultCommand()).toString();
76
    svnBinaryPath = Utils::Environment::systemEnvironment().searchInPath(svnCommand);
con's avatar
con committed
77 78 79
    useAuthentication = settings->value(QLatin1String(authenticationKeyC), QVariant(false)).toBool();
    user = settings->value(QLatin1String(userKeyC), QString()).toString();
    password =  settings->value(QLatin1String(passwordKeyC), QString()).toString();
80
    timeOutS = settings->value(QLatin1String(timeOutKeyC), defaultTimeOutS).toInt();
81
    promptToSubmit = settings->value(QLatin1String(promptToSubmitKeyC), true).toBool();
82
    spaceIgnorantAnnotation = settings->value(QLatin1String(spaceIgnorantAnnotationKeyC), true).toBool();
83
    logCount = settings->value(QLatin1String(logCountKeyC), int(defaultLogCount)).toInt();
con's avatar
con committed
84 85 86 87 88 89 90 91 92 93
    settings->endGroup();
}

void SubversionSettings::toSettings(QSettings *settings) const
{
    settings->beginGroup(QLatin1String(groupC));
    settings->setValue(QLatin1String(commandKeyC), svnCommand);
    settings->setValue(QLatin1String(authenticationKeyC), QVariant(useAuthentication));
    settings->setValue(QLatin1String(userKeyC), user);
    settings->setValue(QLatin1String(passwordKeyC), password);
94
    settings->setValue(QLatin1String(promptToSubmitKeyC), promptToSubmit);
95
    settings->setValue(QLatin1String(timeOutKeyC), timeOutS);
96
    settings->setValue(QLatin1String(spaceIgnorantAnnotationKeyC), spaceIgnorantAnnotation);
97
    settings->setValue(QLatin1String(logCountKeyC), logCount);
con's avatar
con committed
98 99 100 101 102 103 104 105
    settings->endGroup();
}

bool SubversionSettings::equals(const SubversionSettings &s) const
{
    return svnCommand        == s.svnCommand
        && useAuthentication == s.useAuthentication
        && user              == s.user
106
        && password          == s.password
107
        && logCount          == s.logCount
108
        && timeOutS          == s.timeOutS
109 110
        && promptToSubmit    == s.promptToSubmit
        && spaceIgnorantAnnotation == s.spaceIgnorantAnnotation;
con's avatar
con committed
111
}