Newer
Older
/**************************************************************************
** GNU Lesser General Public License Usage
** 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, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** 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.
**
** If you have questions regarding the use of this file, please contact
**************************************************************************/
#include "gitcommand.h"
#include "gitconstants.h"
#include "gitplugin.h"
#include "gitsubmiteditor.h"
#include "gitversioncontrol.h"
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/icore.h>
#include <coreplugin/messagemanager.h>
#include <coreplugin/progressmanager/progressmanager.h>
#include <coreplugin/filemanager.h>
#include <coreplugin/iversioncontrol.h>
#include <utils/synchronousprocess.h>

Tuomas Puranen
committed
#include <utils/environment.h>
#include <vcsbase/vcsbaseoutputwindow.h>
#include <vcsbase/vcsbaseplugin.h>
#include <QtCore/QTime>
#include <QtCore/QFileInfo>
#include <QtCore/QDir>
#include <QtCore/QSignalMapper>
#include <QtGui/QComboBox>
#include <QtGui/QMainWindow> // for msg box parent
static const char kGitDirectoryC[] = ".git";
static const char kBranchIndicatorC[] = "# On branch";
namespace Git {
namespace Internal {
BaseGitArgumentsWidget::BaseGitArgumentsWidget(GitSettings *settings,
Git::Internal::GitClient *client,
const QString &directory,
const QStringList &args) :
QWidget(0),
m_client(client),
m_workingDirectory(directory),
m_diffArgs(args),
m_settings(settings)
{
Q_ASSERT(settings);
Q_ASSERT(client);
}
class BaseGitDiffArgumentsWidget : public Git::Internal::BaseGitArgumentsWidget
{
public:
BaseGitDiffArgumentsWidget(Git::Internal::GitSettings *settings,
Git::Internal::GitClient *client,
const QString &directory,
const QStringList &args) :
BaseGitArgumentsWidget(settings, client, directory, args),
m_patience(new QToolButton),
m_ignoreSpaces(new QToolButton)
layout->setSpacing(2);
m_patience->setToolTip(tr("Use the patience algorithm for calculating the differences."));
m_patience->setText(tr("Patience"));
layout->addWidget(m_patience);
m_patience->setCheckable(true);
m_patience->setChecked(m_settings->diffPatience);
connect(m_patience, SIGNAL(toggled(bool)), this, SLOT(testForArgumentsChanged()));
m_ignoreSpaces->setToolTip(tr("Ignore whitespace only changes."));
m_ignoreSpaces->setText(tr("Ignore Whitespace"));
layout->addWidget(m_ignoreSpaces);
m_ignoreSpaces->setCheckable(true);
m_ignoreSpaces->setChecked(m_settings->ignoreSpaceChangesInDiff);
connect(m_ignoreSpaces, SIGNAL(toggled(bool)), this, SLOT(testForArgumentsChanged()));
}
QStringList arguments() const
{
QStringList args;
foreach (const QString &arg, m_diffArgs) {
if (arg == QLatin1String("--patience")
|| arg == QLatin1String("--ignore-space-change"))
continue;
args.append(arg);
}
if (m_patience->isChecked() && m_patience->isVisible())
args.prepend(QLatin1String("--patience"));
if (m_ignoreSpaces->isChecked() && m_ignoreSpaces->isVisible())
args.prepend(QLatin1String("--ignore-space-change"));
return args;
}
void testForArgumentsChanged() {
m_settings->diffPatience = m_patience->isChecked();
m_settings->ignoreSpaceChangesInDiff = m_ignoreSpaces->isChecked();
QStringList newArguments = arguments();
if (newArguments == m_diffArgs)
return;
m_diffArgs = newArguments;
redoCommand();
}
QToolButton *m_patience;
QToolButton *m_ignoreSpaces;
};
class GitCommitDiffArgumentsWidget : public BaseGitDiffArgumentsWidget
{
public:
GitCommitDiffArgumentsWidget(Git::Internal::GitSettings *settings,
Git::Internal::GitClient *client, const QString &directory,
const QStringList &args, const QStringList &unstaged,
const QStringList &staged) :
BaseGitDiffArgumentsWidget(settings, client, directory, args),
m_unstagedFileNames(unstaged),
m_stagedFileNames(staged)
{ }
void redoCommand()
{
m_client->diff(m_workingDirectory, m_diffArgs, m_unstagedFileNames, m_stagedFileNames);
}
private:
const QStringList m_unstagedFileNames;
const QStringList m_stagedFileNames;
};
class GitFileDiffArgumentsWidget : public BaseGitDiffArgumentsWidget
{
public:
GitFileDiffArgumentsWidget(Git::Internal::GitSettings *settings,
Git::Internal::GitClient *client, const QString &directory,
const QStringList &args, const QString &file) :
BaseGitDiffArgumentsWidget(settings, client, directory, args),
m_fileName(file)
{ }
void redoCommand()
{
m_client->diff(m_workingDirectory, m_diffArgs, m_fileName);
}
Loading
Loading full blame...