2009-11-02 18:50:06 +01:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
|
|
|
|
** Copyright (c) 2009 Brian McGillion
|
|
|
|
|
**
|
|
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
|
|
|
**
|
|
|
|
|
** 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
|
|
|
|
|
** contact the sales department at http://qt.nokia.com/contact.
|
|
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
2009-09-15 13:03:13 +03:00
|
|
|
#include "mercurialsettings.h"
|
|
|
|
|
#include "constants.h"
|
|
|
|
|
|
|
|
|
|
#include <QtCore/QSettings>
|
|
|
|
|
|
|
|
|
|
using namespace Mercurial::Internal;
|
|
|
|
|
|
2009-11-06 12:32:38 +01:00
|
|
|
enum { timeOutDefaultSeconds = 30 };
|
|
|
|
|
|
|
|
|
|
MercurialSettings::MercurialSettings() :
|
|
|
|
|
m_binary(QLatin1String(Constants::MERCURIALDEFAULT)),
|
|
|
|
|
m_logCount(0),
|
|
|
|
|
m_timeoutSeconds(timeOutDefaultSeconds),
|
|
|
|
|
m_prompt(true)
|
2009-09-15 13:03:13 +03:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-03 16:38:39 +01:00
|
|
|
QString MercurialSettings::binary() const
|
2009-09-15 13:03:13 +03:00
|
|
|
{
|
2009-11-06 12:32:38 +01:00
|
|
|
return m_binary;
|
2009-09-15 13:03:13 +03:00
|
|
|
}
|
|
|
|
|
|
2009-11-06 12:32:38 +01:00
|
|
|
void MercurialSettings::setBinary(const QString &b)
|
2009-09-15 13:03:13 +03:00
|
|
|
{
|
2009-11-06 12:32:38 +01:00
|
|
|
m_binary = b;
|
2009-09-15 13:03:13 +03:00
|
|
|
}
|
|
|
|
|
|
2009-11-03 16:38:39 +01:00
|
|
|
QStringList MercurialSettings::standardArguments() const
|
2009-09-15 13:03:13 +03:00
|
|
|
{
|
2009-11-06 12:32:38 +01:00
|
|
|
return m_standardArguments;
|
2009-09-15 13:03:13 +03:00
|
|
|
}
|
|
|
|
|
|
2009-11-03 16:38:39 +01:00
|
|
|
QString MercurialSettings::userName() const
|
2009-09-15 13:03:13 +03:00
|
|
|
{
|
2009-11-06 12:32:38 +01:00
|
|
|
return m_user;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MercurialSettings::setUserName(const QString &u)
|
|
|
|
|
{
|
|
|
|
|
m_user = u;
|
2009-09-15 13:03:13 +03:00
|
|
|
}
|
|
|
|
|
|
2009-11-03 16:38:39 +01:00
|
|
|
QString MercurialSettings::email() const
|
2009-09-15 13:03:13 +03:00
|
|
|
{
|
2009-11-06 12:32:38 +01:00
|
|
|
return m_mail;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MercurialSettings::setEmail(const QString &m)
|
|
|
|
|
{
|
|
|
|
|
m_mail = m;
|
2009-09-15 13:03:13 +03:00
|
|
|
}
|
|
|
|
|
|
2009-11-03 16:38:39 +01:00
|
|
|
int MercurialSettings::logCount() const
|
2009-09-15 13:03:13 +03:00
|
|
|
{
|
|
|
|
|
return m_logCount;
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-06 12:32:38 +01:00
|
|
|
void MercurialSettings::setLogCount(int l)
|
|
|
|
|
{
|
|
|
|
|
m_logCount = l;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int MercurialSettings::timeoutMilliSeconds() const
|
2009-09-15 13:03:13 +03:00
|
|
|
{
|
|
|
|
|
//return timeout is in Ms
|
2009-11-06 12:32:38 +01:00
|
|
|
return m_timeoutSeconds * 1000;
|
2009-09-15 13:03:13 +03:00
|
|
|
}
|
|
|
|
|
|
2009-11-03 16:38:39 +01:00
|
|
|
int MercurialSettings::timeoutSeconds() const
|
2009-09-15 13:03:13 +03:00
|
|
|
{
|
|
|
|
|
//return timeout in seconds (as the user specifies on the options page
|
2009-11-06 12:32:38 +01:00
|
|
|
return m_timeoutSeconds;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MercurialSettings::setTimeoutSeconds(int s)
|
|
|
|
|
{
|
|
|
|
|
m_timeoutSeconds = s;
|
2009-09-15 13:03:13 +03:00
|
|
|
}
|
|
|
|
|
|
2009-11-03 16:38:39 +01:00
|
|
|
bool MercurialSettings::prompt() const
|
2009-09-15 13:03:13 +03:00
|
|
|
{
|
|
|
|
|
return m_prompt;
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-06 12:32:38 +01:00
|
|
|
void MercurialSettings::setPrompt(bool b)
|
|
|
|
|
{
|
|
|
|
|
m_prompt = b;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MercurialSettings::writeSettings(QSettings *settings) const
|
|
|
|
|
{
|
|
|
|
|
settings->beginGroup(QLatin1String("Mercurial"));
|
|
|
|
|
settings->setValue(QLatin1String(Constants::MERCURIALPATH), m_binary);
|
|
|
|
|
settings->setValue(QLatin1String(Constants::MERCURIALUSERNAME), m_user);
|
|
|
|
|
settings->setValue(QLatin1String(Constants::MERCURIALEMAIL), m_mail);
|
|
|
|
|
settings->setValue(QLatin1String(Constants::MERCURIALLOGCOUNT), m_logCount);
|
|
|
|
|
settings->setValue(QLatin1String(Constants::MERCURIALTIMEOUT), m_timeoutSeconds);
|
|
|
|
|
settings->setValue(QLatin1String(Constants::MERCURIALPROMPTSUBMIT), m_prompt);
|
|
|
|
|
settings->endGroup();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MercurialSettings::readSettings(const QSettings *settings)
|
|
|
|
|
{
|
|
|
|
|
const QString keyRoot = QLatin1String("Mercurial/");
|
|
|
|
|
m_binary = settings->value(keyRoot + QLatin1String(Constants::MERCURIALPATH),
|
|
|
|
|
QLatin1String(Constants::MERCURIALDEFAULT)).toString();
|
|
|
|
|
m_user = settings->value(keyRoot + QLatin1String(Constants::MERCURIALUSERNAME), QString()).toString();
|
|
|
|
|
m_mail = settings->value(keyRoot + QLatin1String(Constants::MERCURIALEMAIL), QString()).toString();
|
|
|
|
|
m_logCount = settings->value(keyRoot + QLatin1String(Constants::MERCURIALLOGCOUNT), 0).toInt();
|
|
|
|
|
m_timeoutSeconds = settings->value(keyRoot + QLatin1String(Constants::MERCURIALTIMEOUT), timeOutDefaultSeconds).toInt();
|
|
|
|
|
m_prompt = settings->value(keyRoot + QLatin1String(Constants::MERCURIALPROMPTSUBMIT), true).toBool();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MercurialSettings::equals(const MercurialSettings &rhs) const
|
|
|
|
|
{
|
|
|
|
|
return m_binary == rhs.m_binary && m_standardArguments == rhs.m_standardArguments
|
|
|
|
|
&& m_user == rhs.m_user && m_mail == rhs.m_mail
|
|
|
|
|
&& m_logCount == rhs.m_logCount && m_timeoutSeconds == rhs.m_timeoutSeconds
|
|
|
|
|
&& m_prompt == rhs.m_prompt;
|
2009-09-15 13:03:13 +03:00
|
|
|
}
|