forked from qt-creator/qt-creator
Git: remote dialog improvements
* Add shortcuts * Add refresh button Change-Id: Idfe5c86459d654ea75fb90542eaa4d9cc1405d33 Reviewed-on: http://codereview.qt.nokia.com/220 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com>
This commit is contained in:
@@ -103,6 +103,7 @@ RemoteDialog::RemoteDialog(QWidget *parent) :
|
|||||||
connect(m_ui->addButton, SIGNAL(clicked()), this, SLOT(addRemote()));
|
connect(m_ui->addButton, SIGNAL(clicked()), this, SLOT(addRemote()));
|
||||||
connect(m_ui->fetchButton, SIGNAL(clicked()), this, SLOT(fetchFromRemote()));
|
connect(m_ui->fetchButton, SIGNAL(clicked()), this, SLOT(fetchFromRemote()));
|
||||||
connect(m_ui->removeButton, SIGNAL(clicked()), this, SLOT(removeRemote()));
|
connect(m_ui->removeButton, SIGNAL(clicked()), this, SLOT(removeRemote()));
|
||||||
|
connect(m_ui->refreshButton, SIGNAL(clicked()), this, SLOT(refreshRemotes()));
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoteDialog::~RemoteDialog()
|
RemoteDialog::~RemoteDialog()
|
||||||
@@ -126,6 +127,11 @@ void RemoteDialog::refresh(const QString &repository, bool force)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RemoteDialog::refreshRemotes()
|
||||||
|
{
|
||||||
|
refresh(m_remoteModel->workingDirectory(), true);
|
||||||
|
}
|
||||||
|
|
||||||
void RemoteDialog::addRemote()
|
void RemoteDialog::addRemote()
|
||||||
{
|
{
|
||||||
if (!m_addDialog)
|
if (!m_addDialog)
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ public:
|
|||||||
public slots:
|
public slots:
|
||||||
void refresh(const QString &repository, bool force);
|
void refresh(const QString &repository, bool force);
|
||||||
|
|
||||||
|
void refreshRemotes();
|
||||||
void addRemote();
|
void addRemote();
|
||||||
void removeRemote();
|
void removeRemote();
|
||||||
void fetchFromRemote();
|
void fetchFromRemote();
|
||||||
|
|||||||
@@ -16,14 +16,33 @@
|
|||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="infoGroupBox">
|
<widget class="QGroupBox" name="infoGroupBox">
|
||||||
<layout class="QFormLayout" name="formLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<item row="0" column="0" colspan="2">
|
<property name="topMargin">
|
||||||
|
<number>4</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>4</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
<widget class="QLabel" name="repositoryLabel">
|
<widget class="QLabel" name="repositoryLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string notr="true">Repository: Dummy</string>
|
<string notr="true">Repository: Dummy</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="refreshButton">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Re&fresh</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -33,6 +52,15 @@
|
|||||||
<string>Remotes</string>
|
<string>Remotes</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>4</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>4</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTableView" name="remoteView">
|
<widget class="QTableView" name="remoteView">
|
||||||
<property name="editTriggers">
|
<property name="editTriggers">
|
||||||
@@ -63,7 +91,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="addButton">
|
<widget class="QPushButton" name="addButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Add...</string>
|
<string>&Add...</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="autoDefault">
|
<property name="autoDefault">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
@@ -73,14 +101,14 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="fetchButton">
|
<widget class="QPushButton" name="fetchButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Fetch</string>
|
<string>F&etch</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="removeButton">
|
<widget class="QPushButton" name="removeButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Remove</string>
|
<string>&Remove</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="autoDefault">
|
<property name="autoDefault">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
|
|||||||
@@ -58,11 +58,6 @@ RemoteModel::RemoteModel(GitClient *client, QObject *parent) :
|
|||||||
m_client(client)
|
m_client(client)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
bool RemoteModel::refresh(const QString &workingDirectory, QString *errorMessage)
|
|
||||||
{
|
|
||||||
return refreshRemotes(workingDirectory, errorMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString RemoteModel::remoteName(int row) const
|
QString RemoteModel::remoteName(int row) const
|
||||||
{
|
{
|
||||||
return m_remotes.at(row).name;
|
return m_remotes.at(row).name;
|
||||||
@@ -77,11 +72,11 @@ bool RemoteModel::removeRemote(int row)
|
|||||||
{
|
{
|
||||||
QString output;
|
QString output;
|
||||||
QString error;
|
QString error;
|
||||||
bool success = runGitRemoteCommand(m_workingDirectory,
|
bool success = m_client->synchronousRemoteCmd(m_workingDirectory,
|
||||||
QStringList() << QLatin1String("rm") << remoteName(row),
|
QStringList() << QLatin1String("rm") << remoteName(row),
|
||||||
&output, &error);
|
&output, &error);
|
||||||
if (success)
|
if (success)
|
||||||
success = refreshRemotes(m_workingDirectory, &error);
|
success = refresh(m_workingDirectory, &error);
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,11 +87,11 @@ bool RemoteModel::addRemote(const QString &name, const QString &url)
|
|||||||
if (name.isEmpty() || url.isEmpty())
|
if (name.isEmpty() || url.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
bool success = runGitRemoteCommand(m_workingDirectory,
|
bool success = m_client->synchronousRemoteCmd(m_workingDirectory,
|
||||||
QStringList() << QLatin1String("add") << name << url,
|
QStringList() << QLatin1String("add") << name << url,
|
||||||
&output, &error);
|
&output, &error);
|
||||||
if (success)
|
if (success)
|
||||||
success = refreshRemotes(m_workingDirectory, &error);
|
success = refresh(m_workingDirectory, &error);
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,11 +99,11 @@ bool RemoteModel::renameRemote(const QString &oldName, const QString &newName)
|
|||||||
{
|
{
|
||||||
QString output;
|
QString output;
|
||||||
QString error;
|
QString error;
|
||||||
bool success = runGitRemoteCommand(m_workingDirectory,
|
bool success = m_client->synchronousRemoteCmd(m_workingDirectory,
|
||||||
QStringList() << QLatin1String("rename") << oldName << newName,
|
QStringList() << QLatin1String("rename") << oldName << newName,
|
||||||
&output, &error);
|
&output, &error);
|
||||||
if (success)
|
if (success)
|
||||||
success = refreshRemotes(m_workingDirectory, &error);
|
success = refresh(m_workingDirectory, &error);
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,11 +111,11 @@ bool RemoteModel::updateUrl(const QString &name, const QString &newUrl)
|
|||||||
{
|
{
|
||||||
QString output;
|
QString output;
|
||||||
QString error;
|
QString error;
|
||||||
bool success = runGitRemoteCommand(m_workingDirectory,
|
bool success = m_client->synchronousRemoteCmd(m_workingDirectory,
|
||||||
QStringList() << QLatin1String("set-url") << name << newUrl,
|
QStringList() << QLatin1String("set-url") << name << newUrl,
|
||||||
&output, &error);
|
&output, &error);
|
||||||
if (success)
|
if (success)
|
||||||
success = refreshRemotes(m_workingDirectory, &error);
|
success = refresh(m_workingDirectory, &error);
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,11 +184,6 @@ Qt::ItemFlags RemoteModel::flags(const QModelIndex &index) const
|
|||||||
return m_flags;
|
return m_flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RemoteModel::runGitRemoteCommand(const QString &workingDirectory, const QStringList &additionalArgs, QString *output, QString *errorMessage)
|
|
||||||
{
|
|
||||||
return m_client->synchronousRemoteCmd(workingDirectory, additionalArgs, output, errorMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RemoteModel::clear()
|
void RemoteModel::clear()
|
||||||
{
|
{
|
||||||
if (m_remotes.isEmpty())
|
if (m_remotes.isEmpty())
|
||||||
@@ -202,13 +192,13 @@ void RemoteModel::clear()
|
|||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RemoteModel::refreshRemotes(const QString &workingDirectory, QString *errorMessage)
|
bool RemoteModel::refresh(const QString &workingDirectory, QString *errorMessage)
|
||||||
{
|
{
|
||||||
// Run branch command with verbose.
|
// Run branch command with verbose.
|
||||||
QStringList remoteArgs;
|
QStringList remoteArgs;
|
||||||
remoteArgs << QLatin1String("-v");
|
remoteArgs << QLatin1String("-v");
|
||||||
QString output;
|
QString output;
|
||||||
if (!runGitRemoteCommand(workingDirectory, remoteArgs, &output, errorMessage))
|
if (!m_client->synchronousRemoteCmd(workingDirectory, remoteArgs, &output, errorMessage))
|
||||||
return false;
|
return false;
|
||||||
// Parse output
|
// Parse output
|
||||||
m_workingDirectory = workingDirectory;
|
m_workingDirectory = workingDirectory;
|
||||||
|
|||||||
@@ -47,8 +47,8 @@ class RemoteModel : public QAbstractTableModel {
|
|||||||
public:
|
public:
|
||||||
explicit RemoteModel(GitClient *client, QObject *parent = 0);
|
explicit RemoteModel(GitClient *client, QObject *parent = 0);
|
||||||
|
|
||||||
virtual void clear();
|
void clear();
|
||||||
virtual bool refresh(const QString &workingDirectory, QString *errorMessage);
|
bool refresh(const QString &workingDirectory, QString *errorMessage);
|
||||||
|
|
||||||
QString remoteName(int row) const;
|
QString remoteName(int row) const;
|
||||||
QString remoteUrl(int row) const;
|
QString remoteUrl(int row) const;
|
||||||
@@ -80,10 +80,6 @@ protected:
|
|||||||
};
|
};
|
||||||
typedef QList<Remote> RemoteList;
|
typedef QList<Remote> RemoteList;
|
||||||
|
|
||||||
/* Parse git output and populate m_branches. */
|
|
||||||
bool refreshRemotes(const QString &workingDirectory, QString *errorMessage);
|
|
||||||
bool runGitRemoteCommand(const QString &workingDirectory, const QStringList &additionalArgs, QString *output, QString *errorMessage);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const Qt::ItemFlags m_flags;
|
const Qt::ItemFlags m_flags;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user