Skip to content
Snippets Groups Projects
Commit c54575e6 authored by Tobias Hunger's avatar Tobias Hunger
Browse files

Git: remote dialog improvements

 * Add shortcuts
 * Add refresh button

Change-Id: Idfe5c86459d654ea75fb90542eaa4d9cc1405d33
Reviewed-on: http://codereview.qt.nokia.com/220


Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarTobias Hunger <tobias.hunger@nokia.com>
parent 4a7a1214
No related branches found
No related tags found
No related merge requests found
......@@ -103,6 +103,7 @@ RemoteDialog::RemoteDialog(QWidget *parent) :
connect(m_ui->addButton, SIGNAL(clicked()), this, SLOT(addRemote()));
connect(m_ui->fetchButton, SIGNAL(clicked()), this, SLOT(fetchFromRemote()));
connect(m_ui->removeButton, SIGNAL(clicked()), this, SLOT(removeRemote()));
connect(m_ui->refreshButton, SIGNAL(clicked()), this, SLOT(refreshRemotes()));
}
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()
{
if (!m_addDialog)
......
......@@ -80,6 +80,7 @@ public:
public slots:
void refresh(const QString &repository, bool force);
void refreshRemotes();
void addRemote();
void removeRemote();
void fetchFromRemote();
......
......@@ -16,14 +16,33 @@
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QGroupBox" name="infoGroupBox">
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="topMargin">
<number>4</number>
</property>
<property name="bottomMargin">
<number>4</number>
</property>
<item>
<widget class="QLabel" name="repositoryLabel">
<property name="text">
<string notr="true">Repository: Dummy</string>
</property>
</widget>
</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&amp;fresh</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
......@@ -33,6 +52,15 @@
<string>Remotes</string>
</property>
<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>
<widget class="QTableView" name="remoteView">
<property name="editTriggers">
......@@ -63,7 +91,7 @@
<item>
<widget class="QPushButton" name="addButton">
<property name="text">
<string>Add...</string>
<string>&amp;Add...</string>
</property>
<property name="autoDefault">
<bool>false</bool>
......@@ -73,14 +101,14 @@
<item>
<widget class="QPushButton" name="fetchButton">
<property name="text">
<string>Fetch</string>
<string>F&amp;etch</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="removeButton">
<property name="text">
<string>Remove</string>
<string>&amp;Remove</string>
</property>
<property name="autoDefault">
<bool>false</bool>
......
......@@ -58,11 +58,6 @@ RemoteModel::RemoteModel(GitClient *client, QObject *parent) :
m_client(client)
{ }
bool RemoteModel::refresh(const QString &workingDirectory, QString *errorMessage)
{
return refreshRemotes(workingDirectory, errorMessage);
}
QString RemoteModel::remoteName(int row) const
{
return m_remotes.at(row).name;
......@@ -77,11 +72,11 @@ bool RemoteModel::removeRemote(int row)
{
QString output;
QString error;
bool success = runGitRemoteCommand(m_workingDirectory,
QStringList() << QLatin1String("rm") << remoteName(row),
&output, &error);
bool success = m_client->synchronousRemoteCmd(m_workingDirectory,
QStringList() << QLatin1String("rm") << remoteName(row),
&output, &error);
if (success)
success = refreshRemotes(m_workingDirectory, &error);
success = refresh(m_workingDirectory, &error);
return success;
}
......@@ -92,11 +87,11 @@ bool RemoteModel::addRemote(const QString &name, const QString &url)
if (name.isEmpty() || url.isEmpty())
return false;
bool success = runGitRemoteCommand(m_workingDirectory,
QStringList() << QLatin1String("add") << name << url,
&output, &error);
bool success = m_client->synchronousRemoteCmd(m_workingDirectory,
QStringList() << QLatin1String("add") << name << url,
&output, &error);
if (success)
success = refreshRemotes(m_workingDirectory, &error);
success = refresh(m_workingDirectory, &error);
return success;
}
......@@ -104,11 +99,11 @@ bool RemoteModel::renameRemote(const QString &oldName, const QString &newName)
{
QString output;
QString error;
bool success = runGitRemoteCommand(m_workingDirectory,
QStringList() << QLatin1String("rename") << oldName << newName,
&output, &error);
bool success = m_client->synchronousRemoteCmd(m_workingDirectory,
QStringList() << QLatin1String("rename") << oldName << newName,
&output, &error);
if (success)
success = refreshRemotes(m_workingDirectory, &error);
success = refresh(m_workingDirectory, &error);
return success;
}
......@@ -116,11 +111,11 @@ bool RemoteModel::updateUrl(const QString &name, const QString &newUrl)
{
QString output;
QString error;
bool success = runGitRemoteCommand(m_workingDirectory,
QStringList() << QLatin1String("set-url") << name << newUrl,
&output, &error);
bool success = m_client->synchronousRemoteCmd(m_workingDirectory,
QStringList() << QLatin1String("set-url") << name << newUrl,
&output, &error);
if (success)
success = refreshRemotes(m_workingDirectory, &error);
success = refresh(m_workingDirectory, &error);
return success;
}
......@@ -189,11 +184,6 @@ Qt::ItemFlags RemoteModel::flags(const QModelIndex &index) const
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()
{
if (m_remotes.isEmpty())
......@@ -202,13 +192,13 @@ void RemoteModel::clear()
reset();
}
bool RemoteModel::refreshRemotes(const QString &workingDirectory, QString *errorMessage)
bool RemoteModel::refresh(const QString &workingDirectory, QString *errorMessage)
{
// Run branch command with verbose.
QStringList remoteArgs;
remoteArgs << QLatin1String("-v");
QString output;
if (!runGitRemoteCommand(workingDirectory, remoteArgs, &output, errorMessage))
if (!m_client->synchronousRemoteCmd(workingDirectory, remoteArgs, &output, errorMessage))
return false;
// Parse output
m_workingDirectory = workingDirectory;
......
......@@ -47,8 +47,8 @@ class RemoteModel : public QAbstractTableModel {
public:
explicit RemoteModel(GitClient *client, QObject *parent = 0);
virtual void clear();
virtual bool refresh(const QString &workingDirectory, QString *errorMessage);
void clear();
bool refresh(const QString &workingDirectory, QString *errorMessage);
QString remoteName(int row) const;
QString remoteUrl(int row) const;
......@@ -80,10 +80,6 @@ protected:
};
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:
const Qt::ItemFlags m_flags;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment