More refactoring

FossilOrigin-Name: e2b03b2a965ec50382ea89d374ece4a6a56b72b5
This commit is contained in:
kostas 2015-04-27 19:15:43 +00:00
parent c039be3c8c
commit 762172f124
6 changed files with 48 additions and 41 deletions

View File

@ -1,5 +1,5 @@
C Cleanups
D 2015-04-27T19:04:11.301
C More\srefactoring\n
D 2015-04-27T19:15:43.096
F .travis.yml 77966888a81c4ceee1fcc79bce842c9667ad8a35
F debian/changelog eb4304dfcb6bb66850ec740838090eb50ce1249b
F debian/compat b6abd567fa79cbe0196d093a067271361dc6ca8b
@ -184,8 +184,8 @@ F rsrc/icons/fuel.icns 81e535004b62db801a02f3e15d0a33afc9d4070b
F rsrc/icons/fuel.ico eb529ab3332a17b9302ef3e851db5b9ebce2a038
F rsrc/icons/fuel.png 40daf53b7f6bdcdd0d6aa5ef433d078ec5ea4342
F rsrc/resources.qrc 4098be128fd6c045db933d041fe8844b14643a6f
F src/Bridge.cpp 9e2881359f454238bd4d6df5f7b2a81a06c6c2db
F src/Bridge.h 9c1828df15fcec90777afe998663d13138633d57
F src/Bridge.cpp 00a460d33624258b29ad194297569c53cb10810f
F src/Bridge.h b121493715dd0bed15658b326a70af57f2252db7
F src/BrowserWidget.cpp 8b8f545cdff4a4188edc698a1b4777f5df46f056
F src/BrowserWidget.h 764d66aa9a93b890298bd0301097739cb4e16597
F src/CloneDialog.cpp 812ef7d361c16da21540b7047c9d4d5e74f18539
@ -200,8 +200,8 @@ F src/FileTableView.cpp 5ddf8c391c9a3ac449ec61fb1db837b577afeec2
F src/FileTableView.h 03e56d87c2d46411b9762b87f4d301619aaf18df
F src/LoggedProcess.cpp 2a1e5c94bc1e57c8984563e66c210e43a14dc60c
F src/LoggedProcess.h 85df7c635c807a5a0e8c4763f17a0752aaff7261
F src/MainWindow.cpp e793fdec0450d49fd3b787e4ad4693fb43d936d6
F src/MainWindow.h 559547ce7aebd17d8bbb89195807f2a4a4ab3f76
F src/MainWindow.cpp 691e536058a9360f1a0db56c153638a196941283
F src/MainWindow.h 9e4f2887690bffa9a154e7f9666f4655584256d1
F src/SettingsDialog.cpp a46cff5e5dd425e3dbdd15632abfd5829f5562b4
F src/SettingsDialog.h 4e2790f581e991c744ae9f86580f1972b8c7ff43
F src/Utils.cpp f78728e0817b1db23007ba0d2c5c26980ee7ebca
@ -215,7 +215,7 @@ F ui/CommitDialog.ui 6200f6cabdcf40a20812e811be28e0793f82516f
F ui/FileActionDialog.ui 89bb4dc2d0b8adcd41adcb11ec65f2028a09a12d
F ui/MainWindow.ui 8677f5c8bca5bf7561d5f64bfdd0cef5157c6ac7
F ui/SettingsDialog.ui 2b7c2870e0054b0f4106f495d85d02c0b814df8b
P ee4cf9240e411dfdfc7a4d2b69456fb38a2300c8
R 0cc42bee3118407cae720e60ef185e0c
P b6473fc40399a46731c8741ceed7d3432d687c5a
R 217c3c621c2a2ca89f57d3cea5717343
U kostas
Z f46004bc190ae5569498873da8760a7b
Z 2a41dd117ed487365f20972afe89eb8f

View File

@ -1 +1 @@
b6473fc40399a46731c8741ceed7d3432d687c5a
e2b03b2a965ec50382ea89d374ece4a6a56b72b5

View File

@ -18,7 +18,6 @@ static const QRegExp REGEX_STASH("\\s*(\\d+):\\s+\\[(.*)\\] on (\\d+)-(\\d+)-(
#define FOSSIL_CHECKOUT1 "_FOSSIL_"
#define FOSSIL_CHECKOUT2 ".fslckout"
#define FOSSIL_EXT "fossil"
#define PATH_SEP "/"
///////////////////////////////////////////////////////////////////////////////
@ -39,7 +38,7 @@ private:
};
//------------------------------------------------------------------------------
Bridge::RepoStatus Bridge::getRepoStatus()
RepoStatus Bridge::getRepoStatus()
{
QStringList res;
int exit_code = EXIT_FAILURE;
@ -782,8 +781,8 @@ bool Bridge::isWorkspace(const QString &path)
QFileInfo fi(path);
QString wkspace = path;
wkspace = fi.absoluteDir().absolutePath();
QString checkout_file1 = wkspace + PATH_SEP + FOSSIL_CHECKOUT1;
QString checkout_file2 = wkspace + PATH_SEP + FOSSIL_CHECKOUT2;
QString checkout_file1 = wkspace + PATH_SEPARATOR + FOSSIL_CHECKOUT1;
QString checkout_file2 = wkspace + PATH_SEPARATOR + FOSSIL_CHECKOUT2;
return (QFileInfo(checkout_file1).exists() || QFileInfo(checkout_file2).exists());
}

View File

@ -8,6 +8,8 @@ class QStringList;
typedef QMap<QString, QString> stashmap_t;
#define PATH_SEPARATOR "/"
enum RunFlags
{
RUNFLAGS_NONE = 0<<0,
@ -17,6 +19,13 @@ enum RunFlags
RUNFLAGS_DETACHED = 1<<2
};
enum RepoStatus
{
REPO_OK,
REPO_NOT_FOUND,
REPO_OLD_SCHEMA
};
class Bridge : public QObject
{
public:
@ -50,12 +59,6 @@ public:
bool runFossilRaw(const QStringList &args, QStringList *output, int *exitCode, int runFlags);
static bool isWorkspace(const QString &path);
enum RepoStatus
{
REPO_OK,
REPO_NOT_FOUND,
REPO_OLD_SCHEMA
};
RepoStatus getRepoStatus();

View File

@ -25,12 +25,12 @@
#include "Utils.h"
#include "LoggedProcess.h"
#define PATH_SEP "/"
#ifndef BRIDGE_ENABLED
static const unsigned char UTF8_BOM[] = { 0xEF, 0xBB, 0xBF };
// 19: [5c46757d4b9765] on 2012-04-22 04:41:15
static const QRegExp REGEX_STASH("\\s*(\\d+):\\s+\\[(.*)\\] on (\\d+)-(\\d+)-(\\d+) (\\d+):(\\d+):(\\d+)", Qt::CaseInsensitive);
#endif
//-----------------------------------------------------------------------------
enum
@ -317,8 +317,8 @@ bool MainWindow::openWorkspace(const QString &path)
if(fi.isFile())
{
wkspace = fi.absoluteDir().absolutePath();
QString checkout_file1 = wkspace + PATH_SEP + FOSSIL_CHECKOUT1;
QString checkout_file2 = wkspace + PATH_SEP + FOSSIL_CHECKOUT2;
QString checkout_file1 = wkspace + PATH_SEPARATOR + FOSSIL_CHECKOUT1;
QString checkout_file2 = wkspace + PATH_SEPARATOR + FOSSIL_CHECKOUT2;
if(!(QFileInfo(checkout_file1).exists() || QFileInfo(checkout_file2).exists()) )
{
@ -492,8 +492,13 @@ void MainWindow::on_actionNewRepository_triggered()
//------------------------------------------------------------------------------
void MainWindow::on_actionCloseRepository_triggered()
{
#ifndef BRIDGE_ENABLED
if(getRepoStatus()!=REPO_OK)
return;
#else
if(bridge.getRepoStatus()!=REPO_OK)
return;
#endif
if(QMessageBox::Yes !=DialogQuery(this, tr("Close Workspace"), tr("Are you sure you want to close this workspace?")))
return;
@ -581,7 +586,6 @@ void MainWindow::rebuildRecent()
recentWorkspaceActs[i]->setData(workspaceHistory[i]);
recentWorkspaceActs[i]->setVisible(true);
}
}
//------------------------------------------------------------------------------
@ -613,7 +617,7 @@ bool MainWindow::scanDirectory(QFileInfoList &entries, const QString& dirPath, c
QFileInfo info = list[i];
QString filepath = info.filePath();
QString rel_path = filepath;
rel_path.remove(baseDir+PATH_SEP);
rel_path.remove(baseDir+PATH_SEPARATOR);
// Skip ignored files
if(!ignoreSpec.isEmpty() && QDir::match(ignoreSpec, rel_path))
@ -661,7 +665,11 @@ bool MainWindow::refresh()
QString title = "Fuel";
// Load repository info
#ifndef BRIDGE_ENABLED
RepoStatus st = getRepoStatus();
#else
RepoStatus st = bridge.getRepoStatus();
#endif
if(st==REPO_NOT_FOUND)
{
@ -1018,7 +1026,7 @@ void MainWindow::updateFileView()
//------------------------------------------------------------------------------
#ifndef BRIDGE_ENABLED
MainWindow::RepoStatus MainWindow::getRepoStatus()
RepoStatus MainWindow::getRepoStatus()
{
QStringList res;
int exit_code = EXIT_FAILURE;
@ -1059,11 +1067,13 @@ MainWindow::RepoStatus MainWindow::getRepoStatus()
return run_ok ? REPO_OK : REPO_NOT_FOUND;
}
#else
#if 0
MainWindow::RepoStatus MainWindow::getRepoStatus()
{
return (MainWindow::RepoStatus) bridge.getRepoStatus();
}
#endif
#endif
//------------------------------------------------------------------------------
void MainWindow::updateStashView()
{
@ -2479,7 +2489,7 @@ void MainWindow::on_actionOpenFolder_triggered()
void MainWindow::on_treeView_doubleClicked(const QModelIndex &index)
{
QString target = repoDirModel.data(index, REPODIRMODEL_ROLE_PATH).toString();
target = getCurrentWorkspace() + PATH_SEP + target;
target = getCurrentWorkspace() + PATH_SEPARATOR + target;
QUrl url = QUrl::fromLocalFile(target);
QDesktopServices::openUrl(url);
@ -2504,7 +2514,7 @@ void MainWindow::on_actionRenameFolder_triggered()
return;
}
int dir_start = old_path.lastIndexOf(PATH_SEP);
int dir_start = old_path.lastIndexOf(PATH_SEPARATOR);
if(dir_start==-1)
dir_start = 0;
else
@ -2550,7 +2560,7 @@ void MainWindow::on_actionRenameFolder_triggered()
files_to_move.append(r);
QString new_dir = new_path + r->getPath().mid(old_path.length());
new_paths.append(new_dir);
QString new_file_path = new_dir + PATH_SEP + r->getFilename();
QString new_file_path = new_dir + PATH_SEPARATOR + r->getFilename();
operations.append(r->getFilePath() + " -> " + new_file_path);
}
@ -2570,7 +2580,7 @@ void MainWindow::on_actionRenameFolder_triggered()
for(int i=0; i<files_to_move.length(); ++i)
{
RepoFile *r = files_to_move[i];
const QString &new_file_path = new_paths[i] + PATH_SEP + r->getFilename();
const QString &new_file_path = new_paths[i] + PATH_SEPARATOR + r->getFilename();
#ifndef BRIDGE_ENABLED
if(!runFossil(QStringList() << "mv" << QuotePath(r->getFilePath()) << QuotePath(new_file_path)))
@ -2589,7 +2599,7 @@ void MainWindow::on_actionRenameFolder_triggered()
// First ensure that the target directories exist, and if not make them
for(int i=0; i<files_to_move.length(); ++i)
{
QString target_path = QDir::cleanPath(getCurrentWorkspace() + PATH_SEP + new_paths[i] + PATH_SEP);
QString target_path = QDir::cleanPath(getCurrentWorkspace() + PATH_SEPARATOR + new_paths[i] + PATH_SEPARATOR);
QDir target(target_path);
if(target.exists())
@ -2599,7 +2609,7 @@ void MainWindow::on_actionRenameFolder_triggered()
Q_ASSERT(wkdir.exists());
log(tr("Creating folder '%0'").arg(target_path)+"\n");
if(!wkdir.mkpath(new_paths[i] + PATH_SEP + "."))
if(!wkdir.mkpath(new_paths[i] + PATH_SEPARATOR + "."))
{
QMessageBox::critical(this, tr("Error"), tr("Cannot make target folder '%0'").arg(target_path));
goto _exit;
@ -2610,7 +2620,7 @@ void MainWindow::on_actionRenameFolder_triggered()
for(int i=0; i<files_to_move.length(); ++i)
{
RepoFile *r = files_to_move[i];
QString new_file_path = new_paths[i] + PATH_SEP + r->getFilename();
QString new_file_path = new_paths[i] + PATH_SEPARATOR + r->getFilename();
if(QFile::exists(new_file_path))
{

View File

@ -168,14 +168,9 @@ private:
void setBusy(bool busy);
virtual QMenu *createPopupMenu();
enum RepoStatus
{
REPO_OK,
REPO_NOT_FOUND,
REPO_OLD_SCHEMA
};
#ifndef BRIDGE_ENABLED
RepoStatus getRepoStatus();
#endif
enum ViewMode
{