Newer
Older
/****************************************************************************
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
** 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "gitconstants.h"
#include "gitplugin.h"
#include "gitsubmiteditor.h"
#include "gitversioncontrol.h"
#include <vcsbase/submitfilemodel.h>
#include <coreplugin/vcsmanager.h>
#include <coreplugin/id.h>
#include <coreplugin/iversioncontrol.h>
#include <utils/synchronousprocess.h>
#include <vcsbase/vcsbaseeditorparameterwidget.h>
#include <vcsbase/vcsbaseoutputwindow.h>
#include <vcsbase/vcsbaseplugin.h>
#include <QSignalMapper>
#include <QToolButton>
#include <QTextCodec>
static const char GIT_DIRECTORY[] = ".git";
namespace Git {
namespace Internal {
class BaseGitDiffArgumentsWidget : public VcsBase::VcsBaseEditorParameterWidget
BaseGitDiffArgumentsWidget(GitClient *client, const QString &directory,
QTC_ASSERT(!directory.isEmpty(), return);
QTC_ASSERT(m_client, return);
m_patienceButton = addToggleButton(QLatin1String("--patience"), tr("Patience"),
tr("Use the patience algorithm for calculating the differences."));
mapSetting(m_patienceButton, client->settings()->boolPointer(GitSettings::diffPatienceKey));
m_ignoreWSButton = addToggleButton(QLatin1String("--ignore-space-change"), tr("Ignore Whitespace"),
tr("Ignore whitespace only changes."));
mapSetting(m_ignoreWSButton, m_client->settings()->boolPointer(GitSettings::ignoreSpaceChangesInDiffKey));
QString m_workingDirectory;
GitClient *m_client;
QToolButton *m_patienceButton;
QToolButton *m_ignoreWSButton;
};
class GitCommitDiffArgumentsWidget : public BaseGitDiffArgumentsWidget
{
GitCommitDiffArgumentsWidget(Git::Internal::GitClient *client, const QString &directory,
const QStringList &args, const QStringList &unstaged,
const QStringList &staged) :
BaseGitDiffArgumentsWidget(client, directory, args),
m_unstagedFileNames(unstaged),
m_stagedFileNames(staged)
{ }
m_client->diff(m_workingDirectory, arguments(), m_unstagedFileNames, m_stagedFileNames);
}
private:
const QStringList m_unstagedFileNames;
const QStringList m_stagedFileNames;
};
class GitFileDiffArgumentsWidget : public BaseGitDiffArgumentsWidget
{
GitFileDiffArgumentsWidget(Git::Internal::GitClient *client, const QString &directory,
const QStringList &args, const QString &file) :
BaseGitDiffArgumentsWidget(client, directory, args),
m_client->diff(m_workingDirectory, arguments(), m_fileName);
}
private:
const QString m_fileName;
};
class GitBranchDiffArgumentsWidget : public BaseGitDiffArgumentsWidget
{
GitBranchDiffArgumentsWidget(Git::Internal::GitClient *client, const QString &directory,
const QStringList &args, const QString &branch) :
BaseGitDiffArgumentsWidget(client, directory, args),
m_client->diffBranch(m_workingDirectory, arguments(), m_branchName);
}
private:
const QString m_branchName;
};
class GitShowArgumentsWidget : public BaseGitDiffArgumentsWidget
GitShowArgumentsWidget(Git::Internal::GitClient *client,
const QString &directory,
const QStringList &args,
const QString &id) :
BaseGitDiffArgumentsWidget(client, directory, args),
m_client(client),
m_workingDirectory(directory),
QList<ComboBoxItem> prettyChoices;
prettyChoices << ComboBoxItem(tr("oneline"), QLatin1String("oneline"))
<< ComboBoxItem(tr("short"), QLatin1String("short"))
<< ComboBoxItem(tr("medium"), QLatin1String("medium"))
<< ComboBoxItem(tr("full"), QLatin1String("full"))
<< ComboBoxItem(tr("fuller"), QLatin1String("fuller"))
<< ComboBoxItem(tr("email"), QLatin1String("email"))
<< ComboBoxItem(tr("raw"), QLatin1String("raw"));
mapSetting(addComboBox(QLatin1String("--pretty"), prettyChoices),
m_client->settings()->intPointer(GitSettings::showPrettyFormatKey));
m_client->show(m_workingDirectory, m_id, arguments());
Loading
Loading full blame...