Initial work on remote management
FossilOrigin-Name: 13d3a5222dfe24a33a72efffff0ecb0b5bfefe73
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include "FileActionDialog.h"
|
||||
#include "CloneDialog.h"
|
||||
#include "RevisionDialog.h"
|
||||
#include "RemoteDialog.h"
|
||||
#include "Utils.h"
|
||||
|
||||
#define REVISION_LATEST "Latest revision"
|
||||
@@ -58,7 +59,7 @@ struct WorkspaceItem
|
||||
TYPE_TAGS,
|
||||
TYPE_TAG,
|
||||
TYPE_REMOTES,
|
||||
TYPE_SETTINGS
|
||||
TYPE_REMOTE,
|
||||
};
|
||||
|
||||
WorkspaceItem()
|
||||
@@ -174,6 +175,10 @@ MainWindow::MainWindow(Settings &_settings, QWidget *parent, QString *workspaceP
|
||||
menuBranches->addAction(ui->actionMergeBranch);
|
||||
menuBranches->addAction(ui->actionUpdate);
|
||||
|
||||
// RemotesMenu
|
||||
menuRemotes = new QMenu(this);
|
||||
menuRemotes->addAction(ui->actionEditRemote);
|
||||
|
||||
// Recent Workspaces
|
||||
// Locate a sequence of two separator actions in file menu
|
||||
QList<QAction*> file_actions = ui->menuFile->actions();
|
||||
@@ -800,20 +805,19 @@ void MainWindow::updateWorkspaceView()
|
||||
stashes->appendRow(stash);
|
||||
}
|
||||
|
||||
#if 0
|
||||
#if 1
|
||||
// Remotes
|
||||
QStandardItem *remotes = new QStandardItem(getInternalIcon(":icons/icon-item-remote"), tr("Remotes"));
|
||||
remotes->setData(WorkspaceItem(WorkspaceItem::TYPE_REMOTES, ""), ROLE_WORKSPACE_ITEM);
|
||||
remotes->setEditable(false);
|
||||
getWorkspace().getTreeModel().appendRow(remotes);
|
||||
#endif
|
||||
{
|
||||
QStandardItem *default_url = new QStandardItem(getInternalIcon(":icons/icon-item-remote"), tr("Default"));
|
||||
QString url = settings.GetFossilValue(FOSSIL_SETTING_REMOTE_URL).toString();
|
||||
default_url->setData(WorkspaceItem(WorkspaceItem::TYPE_REMOTE, url), ROLE_WORKSPACE_ITEM);
|
||||
remotes->appendRow(default_url);
|
||||
}
|
||||
|
||||
#if 0 // Unimplemented for now
|
||||
// Settings
|
||||
QStandardItem *settings = new QStandardItem(getInternalIcon(":icons/icon-action-settings"), tr("Settings"));
|
||||
settings->setData(WorkspaceItem(WorkspaceItem::TYPE_SETTINGS, ""), ROLE_WORKSPACE_ITEM);
|
||||
settings->setEditable(false);
|
||||
getWorkspace().getTreeModel().appendRow(settings);
|
||||
#endif
|
||||
|
||||
// Expand previously selected nodes
|
||||
@@ -1233,9 +1237,26 @@ void MainWindow::getSelectionStashes(QStringList &stashNames)
|
||||
QString name = mi.model()->data(mi, Qt::DisplayRole).toString();
|
||||
stashNames.append(name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void MainWindow::getSelectionRemotes(QStringList &remoteUrls)
|
||||
{
|
||||
QModelIndexList selection = ui->workspaceTreeView->selectionModel()->selectedIndexes();
|
||||
|
||||
foreach(const QModelIndex &mi, selection)
|
||||
{
|
||||
QVariant data = mi.model()->data(mi, ROLE_WORKSPACE_ITEM);
|
||||
Q_ASSERT(data.isValid());
|
||||
WorkspaceItem tv = data.value<WorkspaceItem>();
|
||||
|
||||
if(tv.Type != WorkspaceItem::TYPE_REMOTE)
|
||||
continue;
|
||||
|
||||
QString url = tv.Value;
|
||||
remoteUrls.append(url);
|
||||
}
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
bool MainWindow::diffFile(const QString &repoFile)
|
||||
{
|
||||
@@ -2187,6 +2208,8 @@ void MainWindow::on_workspaceTreeView_customContextMenuRequested(const QPoint &)
|
||||
menu = menuTags;
|
||||
else if (tv.Type == WorkspaceItem::TYPE_BRANCH || tv.Type == WorkspaceItem::TYPE_BRANCHES)
|
||||
menu = menuBranches;
|
||||
else if (tv.Type == WorkspaceItem::TYPE_REMOTE)
|
||||
menu = menuRemotes;
|
||||
|
||||
if(menu)
|
||||
{
|
||||
@@ -2477,3 +2500,17 @@ void MainWindow::onSearch()
|
||||
searchBox->setFocus();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void MainWindow::on_actionEditRemote_triggered()
|
||||
{
|
||||
QStringList remotes;
|
||||
getSelectionRemotes(remotes);
|
||||
|
||||
if(remotes.empty())
|
||||
return;
|
||||
|
||||
QUrl url(remotes.first());
|
||||
|
||||
if(!RemoteDialog::run(this, url))
|
||||
return;
|
||||
}
|
||||
|
@@ -40,6 +40,7 @@ private:
|
||||
void getDirViewSelection(QStringList &filenames, int includeMask=WorkspaceFile::TYPE_ALL, bool allIfEmpty=false);
|
||||
void getSelectionStashes(QStringList &stashNames);
|
||||
void getSelectionPaths(stringset_t &paths);
|
||||
void getSelectionRemotes(QStringList& remoteUrls);
|
||||
void getAllFilenames(QStringList &filenames, int includeMask=WorkspaceFile::TYPE_ALL);
|
||||
bool startUI();
|
||||
void stopUI();
|
||||
@@ -124,6 +125,7 @@ private slots:
|
||||
void on_actionDeleteTag_triggered();
|
||||
void on_actionCreateBranch_triggered();
|
||||
void on_actionMergeBranch_triggered();
|
||||
void on_actionEditRemote_triggered();
|
||||
|
||||
private:
|
||||
class MainWinUICallback : public UICallback
|
||||
@@ -171,6 +173,7 @@ private:
|
||||
QMenu *menuStashes;
|
||||
QMenu *menuTags;
|
||||
QMenu *menuBranches;
|
||||
QMenu *menuRemotes;
|
||||
|
||||
bool operationAborted;
|
||||
stringset_t selectedDirs; // The directory selected in the tree
|
||||
|
90
src/RemoteDialog.cpp
Normal file
90
src/RemoteDialog.cpp
Normal file
@@ -0,0 +1,90 @@
|
||||
#include "RemoteDialog.h"
|
||||
#include "ui_RemoteDialog.h"
|
||||
#include <QFileDialog>
|
||||
#include <QDir>
|
||||
#include <QMessageBox>
|
||||
#include <QClipboard>
|
||||
#include <QUrl>
|
||||
#include "Utils.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
RemoteDialog::RemoteDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::RemoteDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
RemoteDialog::~RemoteDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool RemoteDialog::run(QWidget *parent, QUrl &url)
|
||||
{
|
||||
RemoteDialog dlg(parent);
|
||||
|
||||
// Set URL components
|
||||
if(!url.isEmpty())
|
||||
{
|
||||
QString qq = url.toString(QUrl::PrettyDecoded|QUrl::RemoveUserInfo);
|
||||
dlg.ui->lineURL->setText(qq);
|
||||
dlg.ui->lineUserName->setText(url.userName());
|
||||
dlg.ui->linePassword->setText(url.password());
|
||||
}
|
||||
|
||||
if(dlg.exec() != QDialog::Accepted)
|
||||
return false;
|
||||
|
||||
QString urltext = dlg.ui->lineURL->text();
|
||||
|
||||
url = QUrl::fromUserInput(urltext);
|
||||
if(url.isEmpty() || !url.isValid())
|
||||
{
|
||||
QMessageBox::critical(parent, tr("Error"), tr("Invalid URL."), QMessageBox::Ok );
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!dlg.ui->lineUserName->text().trimmed().isEmpty())
|
||||
url.setUserName(dlg.ui->lineUserName->text());
|
||||
|
||||
if(!dlg.ui->linePassword->text().trimmed().isEmpty())
|
||||
url.setPassword(dlg.ui->linePassword->text());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void RemoteDialog::GetRepositoryPath(QString &pathResult)
|
||||
{
|
||||
QString filter(tr("Fossil Repository") + QString(" (*." FOSSIL_EXT ")"));
|
||||
|
||||
pathResult = QFileDialog::getSaveFileName(
|
||||
this,
|
||||
tr("Select Fossil Repository"),
|
||||
QDir::toNativeSeparators(pathResult),
|
||||
filter,
|
||||
&filter,
|
||||
QFileDialog::DontConfirmOverwrite);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void RemoteDialog::on_btnSelectSourceRepo_clicked()
|
||||
{
|
||||
QString path = ui->lineURL->text();
|
||||
GetRepositoryPath(path);
|
||||
|
||||
if(path.trimmed().isEmpty())
|
||||
return;
|
||||
|
||||
if(!QFile::exists(path))
|
||||
{
|
||||
QMessageBox::critical(this, tr("Error"), tr("Invalid Repository File."), QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
|
||||
ui->lineURL->setText(QDir::toNativeSeparators(path));
|
||||
}
|
||||
|
29
src/RemoteDialog.h
Normal file
29
src/RemoteDialog.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#ifndef REMOTEDIALOG_H
|
||||
#define REMOTEDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class RemoteDialog;
|
||||
}
|
||||
|
||||
class RemoteDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit RemoteDialog(QWidget *parent = 0);
|
||||
~RemoteDialog();
|
||||
|
||||
static bool run(QWidget *parent, class QUrl &url);
|
||||
|
||||
private slots:
|
||||
void on_btnSelectSourceRepo_clicked();
|
||||
|
||||
private:
|
||||
void GetRepositoryPath(QString &pathResult);
|
||||
|
||||
Ui::RemoteDialog *ui;
|
||||
};
|
||||
|
||||
#endif // REMOTEDIALOG_H
|
Reference in New Issue
Block a user