Fixed workspace remote storage
Added Delete Remote action Double-cliking a remote triggers a remote editing FossilOrigin-Name: 6c042af93ec30f09386497c176b9c0736ac47690
This commit is contained in:
@@ -181,6 +181,7 @@ MainWindow::MainWindow(Settings &_settings, QWidget *parent, QString *workspaceP
|
||||
menuRemotes->addAction(ui->actionPullRemote);
|
||||
menuRemotes->addAction(separator);
|
||||
menuRemotes->addAction(ui->actionAddRemote);
|
||||
menuRemotes->addAction(ui->actionDeleteRemote);
|
||||
menuRemotes->addAction(ui->actionEditRemote);
|
||||
menuRemotes->addAction(ui->actionSetDefaultRemote);
|
||||
|
||||
@@ -958,6 +959,7 @@ void MainWindow::on_actionClearLog_triggered()
|
||||
void MainWindow::applySettings()
|
||||
{
|
||||
QSettings *store = settings.GetStore();
|
||||
QString active_workspace;
|
||||
|
||||
int num_wks = store->beginReadArray("Workspaces");
|
||||
for(int i=0; i<num_wks; ++i)
|
||||
@@ -972,7 +974,7 @@ void MainWindow::applySettings()
|
||||
addWorkspaceHistory(wk);
|
||||
|
||||
if(store->contains("Active") && store->value("Active").toBool())
|
||||
setCurrentWorkspace(wk);
|
||||
active_workspace = wk;
|
||||
}
|
||||
store->endArray();
|
||||
|
||||
@@ -1027,7 +1029,10 @@ void MainWindow::applySettings()
|
||||
ui->actionViewAsFolders->setChecked(!store->value("ViewAsList").toBool());
|
||||
viewMode = store->value("ViewAsList").toBool()? VIEWMODE_LIST : VIEWMODE_TREE;
|
||||
}
|
||||
//ui->workspaceTreeView->setVisible(viewMode == VIEWMODE_TREE);
|
||||
|
||||
// Set the workspace after loading the settings, since it may trigger a remote info storage
|
||||
if(!active_workspace.isEmpty())
|
||||
setCurrentWorkspace(active_workspace);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -1759,13 +1764,16 @@ void MainWindow::on_workspaceTreeView_doubleClicked(const QModelIndex &index)
|
||||
Q_ASSERT(data.isValid());
|
||||
WorkspaceItem tv = data.value<WorkspaceItem>();
|
||||
|
||||
if(tv.Type!=WorkspaceItem::TYPE_FOLDER && tv.Type!=WorkspaceItem::TYPE_WORKSPACE)
|
||||
return;
|
||||
|
||||
QString target = getCurrentWorkspace() + PATH_SEPARATOR + tv.Value;
|
||||
|
||||
QUrl url = QUrl::fromLocalFile(target);
|
||||
QDesktopServices::openUrl(url);
|
||||
if(tv.Type==WorkspaceItem::TYPE_FOLDER || tv.Type==WorkspaceItem::TYPE_WORKSPACE)
|
||||
{
|
||||
QString target = getCurrentWorkspace() + PATH_SEPARATOR + tv.Value;
|
||||
QUrl url = QUrl::fromLocalFile(target);
|
||||
QDesktopServices::openUrl(url);
|
||||
}
|
||||
else if(tv.Type==WorkspaceItem::TYPE_REMOTE)
|
||||
{
|
||||
on_actionEditRemote_triggered();
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -2595,7 +2603,29 @@ void MainWindow::on_actionAddRemote_triggered()
|
||||
QMessageBox::critical(this, tr("Error"), tr("Could not store information to keychain."), QMessageBox::Ok );
|
||||
}
|
||||
|
||||
url.setPassword("");
|
||||
url.setUserName("");
|
||||
|
||||
getWorkspace().addRemote(url, name);
|
||||
updateWorkspaceView();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void MainWindow::on_actionDeleteRemote_triggered()
|
||||
{
|
||||
QStringList remotes;
|
||||
getSelectionRemotes(remotes);
|
||||
if(remotes.empty())
|
||||
return;
|
||||
|
||||
QUrl url(remotes.first());
|
||||
|
||||
Remote *remote = getWorkspace().findRemote(url);
|
||||
Q_ASSERT(remote);
|
||||
|
||||
if(QMessageBox::Yes != DialogQuery(this, tr("Delete Remote"), tr("Are you sure want to delete the remote '%0' ?").arg(remote->name)))
|
||||
return;
|
||||
|
||||
getWorkspace().removeRemote(url);
|
||||
updateWorkspaceView();
|
||||
}
|
||||
|
@@ -130,6 +130,7 @@ private slots:
|
||||
void on_actionEditRemote_triggered();
|
||||
void on_actionSetDefaultRemote_triggered();
|
||||
void on_actionAddRemote_triggered();
|
||||
void on_actionDeleteRemote_triggered();
|
||||
|
||||
private:
|
||||
class MainWinUICallback : public UICallback
|
||||
|
@@ -4,7 +4,7 @@
|
||||
#include <QFileDialog>
|
||||
#include <QEventLoop>
|
||||
#include "ext/qtkeychain/keychain.h"
|
||||
#define KEYCHAIN_ROOT "Fuel-SCM"
|
||||
#include <QCryptographicHash>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
QMessageBox::StandardButton DialogQuery(QWidget *parent, const QString &title, const QString &query, QMessageBox::StandardButtons buttons)
|
||||
@@ -444,3 +444,13 @@ bool KeychainDelete(QObject* parent, const QUrl& url)
|
||||
|
||||
return job.error() == QKeychain::NoError;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
QString HashString(const QString& str)
|
||||
{
|
||||
QCryptographicHash hash(QCryptographicHash::Sha1);
|
||||
const QByteArray ba(str.toUtf8());
|
||||
hash.addData(ba.data(), ba.size());
|
||||
QString str_out(hash.result().toHex());
|
||||
return str_out;
|
||||
}
|
||||
|
@@ -25,6 +25,7 @@ void BuildNameToModelIndex(name_modelindex_map_t &map, const QStandardItemM
|
||||
bool KeychainSet(QObject* parent, const QUrl& url);
|
||||
bool KeychainGet(QObject* parent, QUrl& url);
|
||||
bool KeychainDelete(QObject* parent, const QUrl& url);
|
||||
QString HashString(const QString &str);
|
||||
|
||||
|
||||
typedef QMap<QString, QString> QStringMap;
|
||||
|
@@ -36,7 +36,9 @@ void Workspace::storeWorkspace(QSettings &store)
|
||||
return;
|
||||
|
||||
store.beginGroup("Remotes");
|
||||
store.beginWriteArray(QDir::toNativeSeparators(workspace));
|
||||
QString workspace_hash = HashString(QDir::toNativeSeparators(workspace));
|
||||
|
||||
store.beginWriteArray(workspace_hash);
|
||||
int index = 0;
|
||||
for(remote_map_t::iterator it=remotes.begin(); it!=remotes.end(); ++it, ++index)
|
||||
{
|
||||
@@ -75,13 +77,18 @@ bool Workspace::switchWorkspace(const QString& workspace, QSettings &store)
|
||||
fossil().setCurrentWorkspace(new_workspace);
|
||||
|
||||
// Load Remotes
|
||||
QString workspace_hash = HashString(QDir::toNativeSeparators(new_workspace));
|
||||
|
||||
QString gr = store.group();
|
||||
|
||||
store.beginGroup("Remotes");
|
||||
int num_remotes = store.beginReadArray(QDir::toNativeSeparators(new_workspace));
|
||||
gr = store.group();
|
||||
int num_remotes = store.beginReadArray(workspace_hash);
|
||||
for(int i=0; i<num_remotes; ++i)
|
||||
{
|
||||
store.setArrayIndex(i);
|
||||
|
||||
QString name = store.value("name").toString();
|
||||
QString name = store.value("Name").toString();
|
||||
QUrl url = store.value("Url").toUrl();
|
||||
bool def = store.value("Default", false).toBool();
|
||||
addRemote(url, name);
|
||||
|
Reference in New Issue
Block a user