Refactored Workspace common types into WorkspaceCommon.h
FossilOrigin-Name: f31360bcda14a4137f5aee56ed916c161bcee18d
This commit is contained in:
parent
2c50fb54c6
commit
214a2f8deb
3
fuel.pro
3
fuel.pro
@ -88,7 +88,8 @@ HEADERS += src/MainWindow.h \
|
||||
src/SearchBox.h \
|
||||
src/AppSettings.h \
|
||||
src/RemoteDialog.h \
|
||||
src/AboutDialog.h
|
||||
src/AboutDialog.h \
|
||||
src/WorkspaceCommon.h
|
||||
|
||||
FORMS += ui/MainWindow.ui \
|
||||
ui/CommitDialog.ui \
|
||||
|
23
manifest
23
manifest
@ -1,5 +1,5 @@
|
||||
C Merged\sinto\strunk
|
||||
D 2015-09-16T12:11:53.084
|
||||
C Refactored\sWorkspace\scommon\stypes\sinto\sWorkspaceCommon.h
|
||||
D 2015-09-16T14:28:38.636
|
||||
F .fossil-settings/manifest a09a968bf05a50058f3ad50132730b719bc39e76
|
||||
F .travis.yml 77966888a81c4ceee1fcc79bce842c9667ad8a35
|
||||
F debian/changelog eb4304dfcb6bb66850ec740838090eb50ce1249b
|
||||
@ -38,7 +38,7 @@ F ext/qtkeychain/qkeychain_export.h d756528188ef9bf3c4461ecc80048f06c362b54b
|
||||
F ext/qtkeychain/testclient.cpp cb1290a9584b627306a7bfdf1c02a8bbae503f5f
|
||||
F ext/qtkeychain/translations/qtkeychain_de.ts 0a70c8205c066c30ed8172f0670942de1fc5eede
|
||||
F ext/qtkeychain/translations/qtkeychain_ro.ts f16939382fd1a047b0692426bc82847347f14b32
|
||||
F fuel.pro 02635c6a5eaa1aadf47f87260dec2cf7698a913c
|
||||
F fuel.pro 4a7c8eeb7491317db76b492ace3d52311462bf38
|
||||
F intl/convert.bat cd29f0a22e002f84adeda3b310379cc4c5a01651 x
|
||||
F intl/convert.sh ac6edc8d99b575601cf9c6b85b18c9e25875b6e0 x
|
||||
F intl/de_DE.ts e2faceab920ac60c97bbc6fba038e261d51fc741
|
||||
@ -228,13 +228,13 @@ F src/FileActionDialog.cpp fcaebf9986f789b3440d5390b3458ad5f86fe0c8
|
||||
F src/FileActionDialog.h 15db1650b3a13d70bc338371e4c033c66e3b79ce
|
||||
F src/FileTableView.cpp 5ddf8c391c9a3ac449ec61fb1db837b577afeec2
|
||||
F src/FileTableView.h 03e56d87c2d46411b9762b87f4d301619aaf18df
|
||||
F src/Fossil.cpp a4e59b0f1af20f96d037f78bb66931be783298dc
|
||||
F src/Fossil.h 7695ace9412a26c5498a4ebe69ab261f6d598d81
|
||||
F src/Fossil.cpp 3033cd4744df2db2e334e746b1cae52a7073ef62
|
||||
F src/Fossil.h 429639f3d32853ff72a35a30000c84988e015aa4
|
||||
F src/FslSettingsDialog.cpp e00907d493fba469e48a008aecda88426350b5ac
|
||||
F src/FslSettingsDialog.h 92a292d43022289f9f626050cd07392dd72f1676
|
||||
F src/LoggedProcess.cpp 2a1e5c94bc1e57c8984563e66c210e43a14dc60c
|
||||
F src/LoggedProcess.h 85df7c635c807a5a0e8c4763f17a0752aaff7261
|
||||
F src/MainWindow.cpp be50d276b0cba6234b1699f92f9f5aa9b9e4fc00
|
||||
F src/MainWindow.cpp 3b6206d0661ab27bb0caa8f973600398993be4ae
|
||||
F src/MainWindow.h ae25aef04587cd46aa113397db0de1e776091efe
|
||||
F src/RemoteDialog.cpp 1a57a15465f689057d5354a29ad3015e54582343
|
||||
F src/RemoteDialog.h 5e0438c2bd7c79b1bb44bfbd58c2181b544a9e5d
|
||||
@ -246,8 +246,9 @@ F src/SettingsDialog.cpp fa0c70eaf0fa7edb15de302d041cdb552fe523d5
|
||||
F src/SettingsDialog.h 81158a26ce9ea9fd95c6c5cdd3c24a9b87b00e8d
|
||||
F src/Utils.cpp abdc1525d08448f09833a310c26491351256d5a5
|
||||
F src/Utils.h d8cda8bc809f75895bd340109dd8086f43ed83b0
|
||||
F src/Workspace.cpp 88ec8258920d7d450c3bb6110085fb07b30ee01a
|
||||
F src/Workspace.h a0ae8f0a2c32da3a8b51a74fa68b0b09167d79c5
|
||||
F src/Workspace.cpp 64cdbe639ff11deefc45e70003d41577e3bca2db
|
||||
F src/Workspace.h 3853740e1276704df6fc73647e28f604dd73fb7b
|
||||
F src/WorkspaceCommon.h 45f6ca5e1e480bfb7a5f8779ea43f94716251168
|
||||
F src/main.cpp d8c65ea5e54102e4989fef9fd8cfd4f13ef8a8f0
|
||||
F tools/git-push.sh 62cc58434cae5b7bcd6bd9d4cce8b08739f31cd7 x
|
||||
F tools/pack.sh d7f38a498c4e9327fecd6a6e5ac27be270d43008 x
|
||||
@ -261,7 +262,7 @@ F ui/MainWindow.ui ad04643d071fe513b46ef413749a493909a90ad1
|
||||
F ui/RemoteDialog.ui 424b2d4a3d0162f84fdccf6af02c1cfce07a06f5
|
||||
F ui/RevisionDialog.ui 27c3b98c665fec014a50cbf3352c0627f75e68cd
|
||||
F ui/SettingsDialog.ui 2e1b6ce7a49100088c5649292c1319e62e0302e1
|
||||
P 2bf7ce4ecb34c22232c7e7db37bb82372093e8b1 9f7b11b9ab0c210395f8aade55e8de0a3d212ae6
|
||||
R df9c2a0c645caa667bac12461134ac87
|
||||
P d3b7048058577931d592aae6c0d9f5949c6f835e
|
||||
R ca2a9dfe83e73f1e22d22d8250fd010d
|
||||
U Kostas
|
||||
Z 14e70702d6214e727095dd6f79a6b751
|
||||
Z 503a295085b91fe20b173dae622aea71
|
||||
|
@ -1 +1 @@
|
||||
d3b7048058577931d592aae6c0d9f5949c6f835e
|
||||
f31360bcda14a4137f5aee56ed916c161bcee18d
|
@ -26,7 +26,7 @@ void Fossil::Init(UICallback *callback, const QString &exePath)
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
Fossil::WorkspaceState Fossil::getWorkspaceState()
|
||||
WorkspaceState Fossil::getWorkspaceState()
|
||||
{
|
||||
QStringList res;
|
||||
int exit_code = EXIT_FAILURE;
|
||||
|
@ -7,18 +7,11 @@ class QStringList;
|
||||
#include <QUrl>
|
||||
#include "LoggedProcess.h"
|
||||
#include "Utils.h"
|
||||
|
||||
typedef QMap<QString, QString> stashmap_t;
|
||||
#include "WorkspaceCommon.h"
|
||||
|
||||
class Fossil
|
||||
{
|
||||
public:
|
||||
enum WorkspaceState
|
||||
{
|
||||
WORKSPACE_STATE_OK,
|
||||
WORKSPACE_STATE_NOTFOUND,
|
||||
WORKSPACE_STATE_OLDSCHEMA
|
||||
};
|
||||
|
||||
Fossil();
|
||||
void Init(UICallback *callback, const QString &exePath);
|
||||
|
@ -533,7 +533,7 @@ void MainWindow::on_actionNewRepository_triggered()
|
||||
//------------------------------------------------------------------------------
|
||||
void MainWindow::on_actionCloseRepository_triggered()
|
||||
{
|
||||
if(getWorkspace().getState()!=Fossil::WORKSPACE_STATE_OK)
|
||||
if(getWorkspace().getState()!=WORKSPACE_STATE_OK)
|
||||
return;
|
||||
|
||||
if(QMessageBox::Yes !=DialogQuery(this, tr("Close Workspace"), tr("Are you sure you want to close this workspace?")))
|
||||
@ -693,15 +693,15 @@ bool MainWindow::scanWorkspace()
|
||||
bool valid = true;
|
||||
|
||||
// Load repository info
|
||||
Fossil::WorkspaceState st = getWorkspace().getState();
|
||||
WorkspaceState st = getWorkspace().getState();
|
||||
QString status;
|
||||
|
||||
if(st==Fossil::WORKSPACE_STATE_NOTFOUND)
|
||||
if(st==WORKSPACE_STATE_NOTFOUND)
|
||||
{
|
||||
status = tr("No workspace detected.");
|
||||
valid = false;
|
||||
}
|
||||
else if(st==Fossil::WORKSPACE_STATE_OLDSCHEMA)
|
||||
else if(st==WORKSPACE_STATE_OLDSCHEMA)
|
||||
{
|
||||
status = tr("Old repository schema detected. Consider running 'fossil rebuild'");
|
||||
valid = false;
|
||||
@ -1010,7 +1010,7 @@ void MainWindow::updateFileView()
|
||||
const QString &search_text = searchBox->text();
|
||||
|
||||
size_t item_id=0;
|
||||
for(Workspace::filemap_t::iterator it = getWorkspace().getFiles().begin(); it!=getWorkspace().getFiles().end(); ++it)
|
||||
for(filemap_t::iterator it = getWorkspace().getFiles().begin(); it!=getWorkspace().getFiles().end(); ++it)
|
||||
{
|
||||
const WorkspaceFile &e = *it.value();
|
||||
const QString &path = e.getPath();
|
||||
@ -1323,7 +1323,7 @@ void MainWindow::getSelectionPaths(stringset_t &paths)
|
||||
// Select all workspace files that match the includeMask
|
||||
void MainWindow::getAllFilenames(QStringList &filenames, int includeMask)
|
||||
{
|
||||
for(Workspace::filemap_t::iterator it=getWorkspace().getFiles().begin(); it!=getWorkspace().getFiles().end(); ++it)
|
||||
for(filemap_t::iterator it=getWorkspace().getFiles().begin(); it!=getWorkspace().getFiles().end(); ++it)
|
||||
{
|
||||
const WorkspaceFile &e = *(*it);
|
||||
|
||||
@ -1347,7 +1347,7 @@ void MainWindow::getDirViewSelection(QStringList &filenames, int includeMask, bo
|
||||
}
|
||||
|
||||
// Select the actual files form the selected directories
|
||||
for(Workspace::filemap_t::iterator it=getWorkspace().getFiles().begin(); it!=getWorkspace().getFiles().end(); ++it)
|
||||
for(filemap_t::iterator it=getWorkspace().getFiles().begin(); it!=getWorkspace().getFiles().end(); ++it)
|
||||
{
|
||||
const WorkspaceFile &e = *(*it);
|
||||
|
||||
@ -1403,7 +1403,7 @@ void MainWindow::getFileViewSelection(QStringList &filenames, int includeMask, b
|
||||
|
||||
QVariant data = getWorkspace().getFileModel().data(mi, Qt::UserRole+1);
|
||||
QString filename = data.toString();
|
||||
Workspace::filemap_t::iterator e_it = getWorkspace().getFiles().find(filename);
|
||||
filemap_t::iterator e_it = getWorkspace().getFiles().find(filename);
|
||||
Q_ASSERT(e_it!=getWorkspace().getFiles().end());
|
||||
const WorkspaceFile &e = *e_it.value();
|
||||
|
||||
@ -2034,7 +2034,7 @@ void MainWindow::on_actionRenameFolder_triggered()
|
||||
}
|
||||
|
||||
// Collect the files to be moved
|
||||
Workspace::filelist_t files_to_move;
|
||||
filelist_t files_to_move;
|
||||
QStringList new_paths;
|
||||
QStringList operations;
|
||||
foreach(WorkspaceFile *r, getWorkspace().getFiles())
|
||||
|
@ -274,7 +274,7 @@ void Workspace::scanWorkspace(bool scanLocal, bool scanIgnored, bool scanModifie
|
||||
else
|
||||
add_missing = true;
|
||||
|
||||
Workspace::filemap_t::iterator it = getFiles().find(fname);
|
||||
filemap_t::iterator it = getFiles().find(fname);
|
||||
|
||||
WorkspaceFile *rf = 0;
|
||||
if(add_missing && it==getFiles().end())
|
||||
|
111
src/Workspace.h
111
src/Workspace.h
@ -8,113 +8,9 @@
|
||||
#include <QMap>
|
||||
#include <QSettings>
|
||||
#include "Utils.h"
|
||||
#include "WorkspaceCommon.h"
|
||||
#include "Fossil.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// WorkspaceFile
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
struct WorkspaceFile
|
||||
{
|
||||
enum Type
|
||||
{
|
||||
TYPE_UNKNOWN = 1<<0,
|
||||
TYPE_UNCHANGED = 1<<1,
|
||||
TYPE_EDITTED = 1<<2,
|
||||
TYPE_ADDED = 1<<3,
|
||||
TYPE_DELETED = 1<<4,
|
||||
TYPE_MISSING = 1<<5,
|
||||
TYPE_RENAMED = 1<<6,
|
||||
TYPE_CONFLICTED = 1<<7,
|
||||
TYPE_MERGED = 1<<8,
|
||||
TYPE_MODIFIED = TYPE_EDITTED|TYPE_ADDED|TYPE_DELETED|TYPE_MISSING|TYPE_RENAMED|TYPE_CONFLICTED|TYPE_MERGED,
|
||||
TYPE_REPO = TYPE_UNCHANGED|TYPE_MODIFIED,
|
||||
TYPE_ALL = TYPE_UNKNOWN|TYPE_REPO
|
||||
};
|
||||
|
||||
WorkspaceFile(const QFileInfo &info, Type type, const QString &repoPath)
|
||||
{
|
||||
FileInfo = info;
|
||||
FileType = type;
|
||||
FilePath = getRelativeFilename(repoPath);
|
||||
Path = FileInfo.absolutePath();
|
||||
|
||||
// Strip the workspace path from the path
|
||||
Q_ASSERT(Path.indexOf(repoPath)==0);
|
||||
Path = Path.mid(repoPath.length()+1);
|
||||
}
|
||||
|
||||
bool isType(Type t) const
|
||||
{
|
||||
return FileType == t;
|
||||
}
|
||||
|
||||
void setType(Type t)
|
||||
{
|
||||
FileType = t;
|
||||
}
|
||||
|
||||
Type getType() const
|
||||
{
|
||||
return FileType;
|
||||
}
|
||||
|
||||
QFileInfo getFileInfo() const
|
||||
{
|
||||
return FileInfo;
|
||||
}
|
||||
|
||||
const QString &getFilePath() const
|
||||
{
|
||||
return FilePath;
|
||||
}
|
||||
|
||||
QString getFilename() const
|
||||
{
|
||||
return FileInfo.fileName();
|
||||
}
|
||||
|
||||
const QString &getPath() const
|
||||
{
|
||||
return Path;
|
||||
}
|
||||
|
||||
QString getRelativeFilename(const QString &path)
|
||||
{
|
||||
QString abs_base_dir = QDir(path).absolutePath();
|
||||
|
||||
QString relative = FileInfo.absoluteFilePath();
|
||||
int index = relative.indexOf(abs_base_dir);
|
||||
if(index<0)
|
||||
return QString("");
|
||||
|
||||
return relative.right(relative.length() - abs_base_dir.length()-1);
|
||||
}
|
||||
|
||||
private:
|
||||
QFileInfo FileInfo;
|
||||
Type FileType;
|
||||
QString FilePath;
|
||||
QString Path;
|
||||
};
|
||||
|
||||
class Remote
|
||||
{
|
||||
public:
|
||||
Remote(const QString &_name, const QUrl &_url, bool _isDefault=false)
|
||||
: name(_name), url(_url), isDefault(_isDefault)
|
||||
{
|
||||
}
|
||||
|
||||
QString name;
|
||||
QUrl url;
|
||||
bool isDefault;
|
||||
|
||||
};
|
||||
|
||||
typedef QMap<QUrl, Remote> remote_map_t;
|
||||
typedef QMap<QString, WorkspaceFile::Type> pathstate_map_t;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Workspace
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@ -124,9 +20,6 @@ public:
|
||||
Workspace();
|
||||
~Workspace();
|
||||
|
||||
typedef QList<WorkspaceFile*> filelist_t;
|
||||
typedef QMap<QString, WorkspaceFile*> filemap_t;
|
||||
|
||||
void clearState();
|
||||
|
||||
Fossil & fossil() { return bridge; }
|
||||
@ -176,7 +69,7 @@ public:
|
||||
return fossil().createRepository(repositoryPath);
|
||||
}
|
||||
|
||||
Fossil::WorkspaceState getState()
|
||||
WorkspaceState getState()
|
||||
{
|
||||
return fossil().getWorkspaceState();
|
||||
}
|
||||
|
129
src/WorkspaceCommon.h
Normal file
129
src/WorkspaceCommon.h
Normal file
@ -0,0 +1,129 @@
|
||||
#ifndef WORKSPACECOMMON_H
|
||||
#define WORKSPACECOMMON_H
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
#include <QSet>
|
||||
#include <QMap>
|
||||
#include <QUrl>
|
||||
#include "Utils.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// WorkspaceState
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
enum WorkspaceState
|
||||
{
|
||||
WORKSPACE_STATE_OK,
|
||||
WORKSPACE_STATE_NOTFOUND,
|
||||
WORKSPACE_STATE_OLDSCHEMA
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// WorkspaceFile
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
struct WorkspaceFile
|
||||
{
|
||||
enum Type
|
||||
{
|
||||
TYPE_UNKNOWN = 1<<0,
|
||||
TYPE_UNCHANGED = 1<<1,
|
||||
TYPE_EDITTED = 1<<2,
|
||||
TYPE_ADDED = 1<<3,
|
||||
TYPE_DELETED = 1<<4,
|
||||
TYPE_MISSING = 1<<5,
|
||||
TYPE_RENAMED = 1<<6,
|
||||
TYPE_CONFLICTED = 1<<7,
|
||||
TYPE_MERGED = 1<<8,
|
||||
TYPE_MODIFIED = TYPE_EDITTED|TYPE_ADDED|TYPE_DELETED|TYPE_MISSING|TYPE_RENAMED|TYPE_CONFLICTED|TYPE_MERGED,
|
||||
TYPE_REPO = TYPE_UNCHANGED|TYPE_MODIFIED,
|
||||
TYPE_ALL = TYPE_UNKNOWN|TYPE_REPO
|
||||
};
|
||||
|
||||
WorkspaceFile(const QFileInfo &info, Type type, const QString &repoPath)
|
||||
{
|
||||
FileInfo = info;
|
||||
FileType = type;
|
||||
FilePath = getRelativeFilename(repoPath);
|
||||
Path = FileInfo.absolutePath();
|
||||
|
||||
// Strip the workspace path from the path
|
||||
Q_ASSERT(Path.indexOf(repoPath)==0);
|
||||
Path = Path.mid(repoPath.length()+1);
|
||||
}
|
||||
|
||||
bool isType(Type t) const
|
||||
{
|
||||
return FileType == t;
|
||||
}
|
||||
|
||||
void setType(Type t)
|
||||
{
|
||||
FileType = t;
|
||||
}
|
||||
|
||||
Type getType() const
|
||||
{
|
||||
return FileType;
|
||||
}
|
||||
|
||||
QFileInfo getFileInfo() const
|
||||
{
|
||||
return FileInfo;
|
||||
}
|
||||
|
||||
const QString &getFilePath() const
|
||||
{
|
||||
return FilePath;
|
||||
}
|
||||
|
||||
QString getFilename() const
|
||||
{
|
||||
return FileInfo.fileName();
|
||||
}
|
||||
|
||||
const QString &getPath() const
|
||||
{
|
||||
return Path;
|
||||
}
|
||||
|
||||
QString getRelativeFilename(const QString &path)
|
||||
{
|
||||
QString abs_base_dir = QDir(path).absolutePath();
|
||||
|
||||
QString relative = FileInfo.absoluteFilePath();
|
||||
int index = relative.indexOf(abs_base_dir);
|
||||
if(index<0)
|
||||
return QString("");
|
||||
|
||||
return relative.right(relative.length() - abs_base_dir.length()-1);
|
||||
}
|
||||
|
||||
private:
|
||||
QFileInfo FileInfo;
|
||||
Type FileType;
|
||||
QString FilePath;
|
||||
QString Path;
|
||||
};
|
||||
|
||||
class Remote
|
||||
{
|
||||
public:
|
||||
Remote(const QString &_name, const QUrl &_url, bool _isDefault=false)
|
||||
: name(_name), url(_url), isDefault(_isDefault)
|
||||
{
|
||||
}
|
||||
|
||||
QString name;
|
||||
QUrl url;
|
||||
bool isDefault;
|
||||
|
||||
};
|
||||
|
||||
typedef QMap<QUrl, Remote> remote_map_t;
|
||||
typedef QMap<QString, WorkspaceFile::Type> pathstate_map_t;
|
||||
typedef QList<WorkspaceFile*> filelist_t;
|
||||
typedef QMap<QString, WorkspaceFile*> filemap_t;
|
||||
typedef QMap<QString, QString> stashmap_t;
|
||||
|
||||
|
||||
#endif // WORKSPACECOMMON_H
|
Loading…
x
Reference in New Issue
Block a user