Refactored openRepository
FossilOrigin-Name: 02a7b672e1d634b703ee5f30258153c3f4610886
This commit is contained in:
@ -7,6 +7,7 @@
|
||||
#include <QMessageBox>
|
||||
#include <QDir>
|
||||
#include <QTemporaryFile>
|
||||
#include "Utils.h"
|
||||
|
||||
static const unsigned char UTF8_BOM[] = { 0xEF, 0xBB, 0xBF };
|
||||
|
||||
@ -52,6 +53,25 @@ Bridge::RepoStatus Bridge::getRepoStatus()
|
||||
|
||||
return run_ok ? REPO_OK : REPO_NOT_FOUND;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool Bridge::openRepository(const QString& repositoryPath, const QString& workspacePath)
|
||||
{
|
||||
QFileInfo fi(repositoryPath);
|
||||
|
||||
if(!QDir::setCurrent(workspacePath) || !fi.isFile())
|
||||
return false;
|
||||
|
||||
QString abspath = fi.absoluteFilePath();
|
||||
setCurrentWorkspace(workspacePath);
|
||||
setRepositoryFile(abspath);
|
||||
|
||||
if(!runFossil(QStringList() << "open" << QuotePath(abspath)))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
static QString ParseFossilQuery(QString line)
|
||||
{
|
||||
|
@ -20,9 +20,6 @@ public:
|
||||
}
|
||||
|
||||
|
||||
bool runFossil(const QStringList &args, QStringList *output, int runFlags);
|
||||
bool runFossilRaw(const QStringList &args, QStringList *output, int *exitCode, int runFlags);
|
||||
|
||||
enum RunFlags
|
||||
{
|
||||
RUNFLAGS_NONE = 0<<0,
|
||||
@ -45,6 +42,8 @@ public:
|
||||
currentWorkspace = workspace;
|
||||
}
|
||||
|
||||
bool runFossil(const QStringList &args, QStringList *output=0, int runFlags=RUNFLAGS_NONE);
|
||||
bool runFossilRaw(const QStringList &args, QStringList *output, int *exitCode, int runFlags);
|
||||
|
||||
static bool isWorkspace(const QString &path);
|
||||
enum RepoStatus
|
||||
@ -83,6 +82,8 @@ public:
|
||||
}
|
||||
|
||||
|
||||
bool openRepository(const QString &repositoryPath, const QString& workspacePath);
|
||||
|
||||
bool uiRunning() const;
|
||||
bool startUI(const QString &httpPort);
|
||||
void stopUI();
|
||||
|
@ -55,21 +55,6 @@ enum
|
||||
REPODIRMODEL_ROLE_PATH = Qt::UserRole+1
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
static QString QuotePath(const QString &path)
|
||||
{
|
||||
return path;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
static QStringList QuotePaths(const QStringList &paths)
|
||||
{
|
||||
QStringList res;
|
||||
for(int i=0; i<paths.size(); ++i)
|
||||
res.append(QuotePath(paths[i]));
|
||||
return res;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
typedef QMap<QString, QString> QStringMap;
|
||||
static QStringMap MakeKeyValues(QStringList lines)
|
||||
@ -347,14 +332,15 @@ bool MainWindow::openWorkspace(const QString &path)
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifndef BRIDGE_ENABLED
|
||||
// Ok open the fossil
|
||||
setCurrentWorkspace(wkspace);
|
||||
if(!QDir::setCurrent(wkspace))
|
||||
{
|
||||
QMessageBox::critical(this, tr("Error"), tr("Could not change current directory"), QMessageBox::Ok );
|
||||
return false;
|
||||
}
|
||||
|
||||
setCurrentWorkspace(wkspace);
|
||||
setRepositoryFile(fi.absoluteFilePath());
|
||||
|
||||
if(!runFossil(QStringList() << "open" << QuotePath(getRepositoryFile())))
|
||||
@ -362,6 +348,13 @@ bool MainWindow::openWorkspace(const QString &path)
|
||||
QMessageBox::critical(this, tr("Error"), tr("Could not open repository."), QMessageBox::Ok );
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
if(!bridge.openRepository(fi.absoluteFilePath(), wkspace))
|
||||
{
|
||||
QMessageBox::critical(this, tr("Error"), tr("Could not open repository."), QMessageBox::Ok );
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -14,6 +14,21 @@ QMessageBox::StandardButton DialogQuery(QWidget *parent, const QString &title, c
|
||||
return res;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
QString QuotePath(const QString &path)
|
||||
{
|
||||
return path;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
QStringList QuotePaths(const QStringList &paths)
|
||||
{
|
||||
QStringList res;
|
||||
for(int i=0; i<paths.size(); ++i)
|
||||
res.append(QuotePath(paths[i]));
|
||||
return res;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
#if 0 // Unused
|
||||
#include <QInputDialog>
|
||||
@ -158,7 +173,7 @@ bool ShowExplorerMenu(HWND hwnd, const QString &path, const QPoint &qpoint)
|
||||
// IShellFolder interface.
|
||||
//
|
||||
bool bResult = false;
|
||||
|
||||
|
||||
LPMALLOC pMalloc;
|
||||
if (!SUCCEEDED (SHGetMalloc (&pMalloc)))
|
||||
return bResult;
|
||||
|
@ -5,6 +5,9 @@
|
||||
#include <QMessageBox>
|
||||
|
||||
QMessageBox::StandardButton DialogQuery(QWidget *parent, const QString &title, const QString &query, QMessageBox::StandardButtons buttons = QMessageBox::Yes|QMessageBox::No);
|
||||
QString QuotePath(const QString &path);
|
||||
QStringList QuotePaths(const QStringList &paths);
|
||||
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
bool ShowExplorerMenu(HWND hwnd, const QString &path, const QPoint &qpoint);
|
||||
|
Reference in New Issue
Block a user