Renamed Repository to Workspace

Workspace member access is now via methods


FossilOrigin-Name: 2c664b7db2644e1434b5e2d9e83a103ca2093cb3
This commit is contained in:
kostas 2015-04-30 10:59:25 +00:00
parent 341e945322
commit c67746a84d
4 changed files with 101 additions and 93 deletions

View File

@ -1,5 +1,5 @@
C Cleanup C Renamed\sRepository\sto\sWorkspace\nWorkspace\smember\saccess\sis\snow\svia\smethods\n
D 2015-04-30T10:36:18.967 D 2015-04-30T10:59:25.241
F .travis.yml 77966888a81c4ceee1fcc79bce842c9667ad8a35 F .travis.yml 77966888a81c4ceee1fcc79bce842c9667ad8a35
F debian/changelog eb4304dfcb6bb66850ec740838090eb50ce1249b F debian/changelog eb4304dfcb6bb66850ec740838090eb50ce1249b
F debian/compat b6abd567fa79cbe0196d093a067271361dc6ca8b F debian/compat b6abd567fa79cbe0196d093a067271361dc6ca8b
@ -200,8 +200,8 @@ F src/FileTableView.cpp 5ddf8c391c9a3ac449ec61fb1db837b577afeec2
F src/FileTableView.h 03e56d87c2d46411b9762b87f4d301619aaf18df F src/FileTableView.h 03e56d87c2d46411b9762b87f4d301619aaf18df
F src/LoggedProcess.cpp 2a1e5c94bc1e57c8984563e66c210e43a14dc60c F src/LoggedProcess.cpp 2a1e5c94bc1e57c8984563e66c210e43a14dc60c
F src/LoggedProcess.h 85df7c635c807a5a0e8c4763f17a0752aaff7261 F src/LoggedProcess.h 85df7c635c807a5a0e8c4763f17a0752aaff7261
F src/MainWindow.cpp 939c919b6ede21771df77ff9973da7b3e39808dc F src/MainWindow.cpp f04effe7dbb5712f1214a8778ab372fef44c0e01
F src/MainWindow.h 9df3df4c1baf0f386e226b1991b2d1dbea0ecdbb F src/MainWindow.h c7c22c37b157cb8fcddb6345617a7c3fe663c903
F src/SettingsDialog.cpp a46cff5e5dd425e3dbdd15632abfd5829f5562b4 F src/SettingsDialog.cpp a46cff5e5dd425e3dbdd15632abfd5829f5562b4
F src/SettingsDialog.h 4e2790f581e991c744ae9f86580f1972b8c7ff43 F src/SettingsDialog.h 4e2790f581e991c744ae9f86580f1972b8c7ff43
F src/Utils.cpp f78728e0817b1db23007ba0d2c5c26980ee7ebca F src/Utils.cpp f78728e0817b1db23007ba0d2c5c26980ee7ebca
@ -215,7 +215,7 @@ F ui/CommitDialog.ui 6200f6cabdcf40a20812e811be28e0793f82516f
F ui/FileActionDialog.ui 89bb4dc2d0b8adcd41adcb11ec65f2028a09a12d F ui/FileActionDialog.ui 89bb4dc2d0b8adcd41adcb11ec65f2028a09a12d
F ui/MainWindow.ui 8677f5c8bca5bf7561d5f64bfdd0cef5157c6ac7 F ui/MainWindow.ui 8677f5c8bca5bf7561d5f64bfdd0cef5157c6ac7
F ui/SettingsDialog.ui 2b7c2870e0054b0f4106f495d85d02c0b814df8b F ui/SettingsDialog.ui 2b7c2870e0054b0f4106f495d85d02c0b814df8b
P 61734cf430e041d514222c71f751feead5b7faf6 P 0975c824a72cacd0d2fb5ee5d3c38c145712a0b4
R 753dd95663c89722dde887fa796bf2c1 R d87d054d9f8c171e265c82e724cde68f
U kostas U kostas
Z f5ff6cd15d239d70f6502ce6d67686d0 Z 5be810239a33cadc87f4c7d50c02c8a6

View File

@ -1 +1 @@
0975c824a72cacd0d2fb5ee5d3c38c145712a0b4 2c664b7db2644e1434b5e2d9e83a103ca2093cb3

View File

@ -85,7 +85,7 @@ MainWindow::MainWindow(Settings &_settings, QWidget *parent, QString *workspaceP
separator->setSeparator(true); separator->setSeparator(true);
// TableView // TableView
ui->tableView->setModel(&getRepo().repoFileModel); ui->tableView->setModel(&getRepo().getFileModel());
ui->tableView->addAction(ui->actionDiff); ui->tableView->addAction(ui->actionDiff);
ui->tableView->addAction(ui->actionHistory); ui->tableView->addAction(ui->actionHistory);
@ -103,8 +103,8 @@ MainWindow::MainWindow(Settings &_settings, QWidget *parent, QString *workspaceP
QStringList header; QStringList header;
header << tr("Status") << tr("File") << tr("Extension") << tr("Modified") << tr("Path"); header << tr("Status") << tr("File") << tr("Extension") << tr("Modified") << tr("Path");
getRepo().repoFileModel.setHorizontalHeaderLabels(header); getRepo().getFileModel().setHorizontalHeaderLabels(header);
getRepo().repoFileModel.horizontalHeaderItem(COLUMN_STATUS)->setTextAlignment(Qt::AlignCenter); getRepo().getFileModel().horizontalHeaderItem(COLUMN_STATUS)->setTextAlignment(Qt::AlignCenter);
// Needed on OSX as the preset value from the GUI editor is not always reflected // Needed on OSX as the preset value from the GUI editor is not always reflected
ui->tableView->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft); ui->tableView->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft);
@ -116,7 +116,7 @@ MainWindow::MainWindow(Settings &_settings, QWidget *parent, QString *workspaceP
ui->tableView->horizontalHeader()->setStretchLastSection(true); ui->tableView->horizontalHeader()->setStretchLastSection(true);
// TreeView // TreeView
ui->treeView->setModel(&getRepo().repoDirModel); ui->treeView->setModel(&getRepo().getDirModel());
connect( ui->treeView->selectionModel(), connect( ui->treeView->selectionModel(),
SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ), SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
SLOT( onTreeViewSelectionChanged(const QItemSelection &, const QItemSelection &) ), SLOT( onTreeViewSelectionChanged(const QItemSelection &, const QItemSelection &) ),
@ -132,7 +132,7 @@ MainWindow::MainWindow(Settings &_settings, QWidget *parent, QString *workspaceP
ui->treeView->addAction(ui->actionOpenFolder); ui->treeView->addAction(ui->actionOpenFolder);
// StashView // StashView
ui->tableViewStash->setModel(&getRepo().repoStashModel); ui->tableViewStash->setModel(&getRepo().getStashModel());
ui->tableViewStash->addAction(ui->actionApplyStash); ui->tableViewStash->addAction(ui->actionApplyStash);
ui->tableViewStash->addAction(ui->actionDiffStash); ui->tableViewStash->addAction(ui->actionDiffStash);
ui->tableViewStash->addAction(ui->actionDeleteStash); ui->tableViewStash->addAction(ui->actionDeleteStash);
@ -210,7 +210,7 @@ MainWindow::~MainWindow()
updateSettings(); updateSettings();
// Dispose RepoFiles // Dispose RepoFiles
for(Repository::filemap_t::iterator it = getRepo().workspaceFiles.begin(); it!=getRepo().workspaceFiles.end(); ++it) for(Workspace::filemap_t::iterator it = getRepo().getFiles().begin(); it!=getRepo().getFiles().end(); ++it)
delete *it; delete *it;
delete ui; delete ui;
@ -487,7 +487,7 @@ void MainWindow::onOpenRecent()
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool Repository::scanDirectory(QFileInfoList &entries, const QString& dirPath, const QString &baseDir, const QString ignoreSpec, const bool &abort, Bridge::UICallback &uiCallback) bool Workspace::scanDirectory(QFileInfoList &entries, const QString& dirPath, const QString &baseDir, const QString ignoreSpec, const bool &abort, Bridge::UICallback &uiCallback)
{ {
QDir dir(dirPath); QDir dir(dirPath);
@ -556,8 +556,8 @@ bool MainWindow::refresh()
{ {
setStatus(tr("No workspace detected.")); setStatus(tr("No workspace detected."));
enableActions(false); enableActions(false);
getRepo().repoFileModel.removeRows(0, getRepo().repoFileModel.rowCount()); getRepo().getFileModel().removeRows(0, getRepo().getFileModel().rowCount());
getRepo().repoDirModel.clear(); getRepo().getDirModel().clear();
setWindowTitle(title); setWindowTitle(title);
return false; return false;
} }
@ -565,8 +565,8 @@ bool MainWindow::refresh()
{ {
setStatus(tr("Old repository schema detected. Consider running 'fossil rebuild'")); setStatus(tr("Old repository schema detected. Consider running 'fossil rebuild'"));
enableActions(false); enableActions(false);
getRepo().repoFileModel.removeRows(0, getRepo().repoFileModel.rowCount()); getRepo().getFileModel().removeRows(0, getRepo().getFileModel().rowCount());
getRepo().repoDirModel.clear(); getRepo().getDirModel().clear();
setWindowTitle(title); setWindowTitle(title);
return true; return true;
} }
@ -584,7 +584,7 @@ bool MainWindow::refresh()
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void Repository::scanWorkspace(bool scanLocal, bool scanIgnored, bool scanModified, bool scanUnchanged, const QString &ignoreGlob, Bridge::UICallback &uiCallback, bool &operationAborted) void Workspace::scanWorkspace(bool scanLocal, bool scanIgnored, bool scanModified, bool scanUnchanged, const QString &ignoreGlob, Bridge::UICallback &uiCallback, bool &operationAborted)
{ {
// Scan all workspace files // Scan all workspace files
QFileInfoList all_files; QFileInfoList all_files;
@ -601,11 +601,11 @@ void Repository::scanWorkspace(bool scanLocal, bool scanIgnored, bool scanModifi
bool scan_files = scanLocal; bool scan_files = scanLocal;
// Dispose RepoFiles // Dispose RepoFiles
for(Repository::filemap_t::iterator it = workspaceFiles.begin(); it!=workspaceFiles.end(); ++it) for(Workspace::filemap_t::iterator it = getFiles().begin(); it!=getFiles().end(); ++it)
delete *it; delete *it;
workspaceFiles.clear(); getFiles().clear();
pathSet.clear(); getPaths().clear();
operationAborted = false; operationAborted = false;
@ -636,8 +636,8 @@ void Repository::scanWorkspace(bool scanLocal, bool scanIgnored, bool scanModifi
continue; continue;
RepoFile *rf = new RepoFile(*it, RepoFile::TYPE_UNKNOWN, wkdir); RepoFile *rf = new RepoFile(*it, RepoFile::TYPE_UNKNOWN, wkdir);
workspaceFiles.insert(rf->getFilePath(), rf); getFiles().insert(rf->getFilePath(), rf);
pathSet.insert(rf->getPath()); getPaths().insert(rf->getPath());
} }
} }
uiCallback.endProcess(); uiCallback.endProcess();
@ -685,37 +685,37 @@ void Repository::scanWorkspace(bool scanLocal, bool scanIgnored, bool scanModifi
if( ((type & RepoFile::TYPE_MODIFIED) && !scanModified) || if( ((type & RepoFile::TYPE_MODIFIED) && !scanModified) ||
((type & RepoFile::TYPE_UNCHANGED) && !scanUnchanged)) ((type & RepoFile::TYPE_UNCHANGED) && !scanUnchanged))
{ {
workspaceFiles.remove(fname); getFiles().remove(fname);
continue; continue;
} }
else else
add_missing = true; add_missing = true;
Repository::filemap_t::iterator it = workspaceFiles.find(fname); Workspace::filemap_t::iterator it = getFiles().find(fname);
RepoFile *rf = 0; RepoFile *rf = 0;
if(add_missing && it==workspaceFiles.end()) if(add_missing && it==getFiles().end())
{ {
QFileInfo info(wkdir+QDir::separator()+fname); QFileInfo info(wkdir+QDir::separator()+fname);
rf = new RepoFile(info, type, wkdir); rf = new RepoFile(info, type, wkdir);
workspaceFiles.insert(rf->getFilePath(), rf); getFiles().insert(rf->getFilePath(), rf);
} }
if(!rf) if(!rf)
{ {
it = workspaceFiles.find(fname); it = getFiles().find(fname);
Q_ASSERT(it!=workspaceFiles.end()); Q_ASSERT(it!=getFiles().end());
rf = *it; rf = *it;
} }
rf->setType(type); rf->setType(type);
QString path = rf->getPath(); QString path = rf->getPath();
pathSet.insert(path); getPaths().insert(path);
} }
// Load the stash // Load the stash
fossil().stashList(stashMap); fossil().stashList(getStashes());
_done: _done:
uiCallback.endProcess(); uiCallback.endProcess();
} }
@ -780,18 +780,18 @@ static void addPathToTree(QStandardItem &root, const QString &path)
void MainWindow::updateDirView() void MainWindow::updateDirView()
{ {
// Directory View // Directory View
getRepo().repoDirModel.clear(); getRepo().getDirModel().clear();
QStringList header; QStringList header;
header << tr("Folders"); header << tr("Folders");
getRepo().repoDirModel.setHorizontalHeaderLabels(header); getRepo().getDirModel().setHorizontalHeaderLabels(header);
QStandardItem *root = new QStandardItem(QIcon(":icons/icons/My Documents-01.png"), fossil().getProjectName()); QStandardItem *root = new QStandardItem(QIcon(":icons/icons/My Documents-01.png"), fossil().getProjectName());
root->setData(""); // Empty Path root->setData(""); // Empty Path
root->setEditable(false); root->setEditable(false);
getRepo().repoDirModel.appendRow(root); getRepo().getDirModel().appendRow(root);
for(stringset_t::iterator it = getRepo().pathSet.begin(); it!=getRepo().pathSet.end(); ++it) for(stringset_t::iterator it = getRepo().getPaths().begin(); it!=getRepo().getPaths().end(); ++it)
{ {
const QString &dir = *it; const QString &dir = *it;
if(dir.isEmpty()) if(dir.isEmpty())
@ -807,7 +807,7 @@ void MainWindow::updateDirView()
void MainWindow::updateFileView() void MainWindow::updateFileView()
{ {
// Clear content except headers // Clear content except headers
getRepo().repoFileModel.removeRows(0, getRepo().repoFileModel.rowCount()); getRepo().getFileModel().removeRows(0, getRepo().getFileModel().rowCount());
struct { RepoFile::EntryType type; QString text; const char *icon; } struct { RepoFile::EntryType type; QString text; const char *icon; }
stats[] = stats[] =
@ -823,16 +823,16 @@ void MainWindow::updateFileView()
QFileIconProvider icon_provider; QFileIconProvider icon_provider;
bool display_path = viewMode==VIEWMODE_LIST || getRepo().selectedDirs.count() > 1; bool display_path = viewMode==VIEWMODE_LIST || selectedDirs.count() > 1;
size_t item_id=0; size_t item_id=0;
for(Repository::filemap_t::iterator it = getRepo().workspaceFiles.begin(); it!=getRepo().workspaceFiles.end(); ++it) for(Workspace::filemap_t::iterator it = getRepo().getFiles().begin(); it!=getRepo().getFiles().end(); ++it)
{ {
const RepoFile &e = *it.value(); const RepoFile &e = *it.value();
QString path = e.getPath(); QString path = e.getPath();
// In Tree mode, filter all items not included in the current dir // In Tree mode, filter all items not included in the current dir
if(viewMode==VIEWMODE_TREE && !getRepo().selectedDirs.contains(path)) if(viewMode==VIEWMODE_TREE && !selectedDirs.contains(path))
continue; continue;
// Status Column // Status Column
@ -851,13 +851,13 @@ void MainWindow::updateFileView()
QStandardItem *status = new QStandardItem(QIcon(status_icon_path), status_text); QStandardItem *status = new QStandardItem(QIcon(status_icon_path), status_text);
status->setToolTip(status_text); status->setToolTip(status_text);
getRepo().repoFileModel.setItem(item_id, COLUMN_STATUS, status); getRepo().getFileModel().setItem(item_id, COLUMN_STATUS, status);
QFileInfo finfo = e.getFileInfo(); QFileInfo finfo = e.getFileInfo();
QIcon icon = icon_provider.icon(finfo); QIcon icon = icon_provider.icon(finfo);
QStandardItem *filename_item = 0; QStandardItem *filename_item = 0;
getRepo().repoFileModel.setItem(item_id, COLUMN_PATH, new QStandardItem(path)); getRepo().getFileModel().setItem(item_id, COLUMN_PATH, new QStandardItem(path));
if(display_path) if(display_path)
filename_item = new QStandardItem(icon, QDir::toNativeSeparators(e.getFilePath())); filename_item = new QStandardItem(icon, QDir::toNativeSeparators(e.getFilePath()));
@ -867,10 +867,10 @@ void MainWindow::updateFileView()
Q_ASSERT(filename_item); Q_ASSERT(filename_item);
// Keep the path in the user data // Keep the path in the user data
filename_item->setData(e.getFilePath()); filename_item->setData(e.getFilePath());
getRepo().repoFileModel.setItem(item_id, COLUMN_FILENAME, filename_item); getRepo().getFileModel().setItem(item_id, COLUMN_FILENAME, filename_item);
getRepo().repoFileModel.setItem(item_id, COLUMN_EXTENSION, new QStandardItem(finfo.suffix())); getRepo().getFileModel().setItem(item_id, COLUMN_EXTENSION, new QStandardItem(finfo.suffix()));
getRepo().repoFileModel.setItem(item_id, COLUMN_MODIFIED, new QStandardItem(finfo.lastModified().toString(Qt::SystemLocaleShortDate))); getRepo().getFileModel().setItem(item_id, COLUMN_MODIFIED, new QStandardItem(finfo.lastModified().toString(Qt::SystemLocaleShortDate)));
++item_id; ++item_id;
} }
@ -881,17 +881,17 @@ void MainWindow::updateFileView()
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void MainWindow::updateStashView() void MainWindow::updateStashView()
{ {
getRepo().repoStashModel.clear(); getRepo().getStashModel().clear();
QStringList header; QStringList header;
header << tr("Stashes"); header << tr("Stashes");
getRepo().repoStashModel.setHorizontalHeaderLabels(header); getRepo().getStashModel().setHorizontalHeaderLabels(header);
for(stashmap_t::iterator it=getRepo().stashMap.begin(); it!=getRepo().stashMap.end(); ++it) for(stashmap_t::iterator it=getRepo().getStashes().begin(); it!=getRepo().getStashes().end(); ++it)
{ {
QStandardItem *item = new QStandardItem(it.key()); QStandardItem *item = new QStandardItem(it.key());
item->setToolTip(it.key()); item->setToolTip(it.key());
getRepo().repoStashModel.appendRow(item); getRepo().getStashModel().appendRow(item);
} }
ui->tableViewStash->resizeColumnsToContents(); ui->tableViewStash->resizeColumnsToContents();
ui->tableViewStash->resizeRowsToContents(); ui->tableViewStash->resizeRowsToContents();
@ -945,7 +945,7 @@ void MainWindow::applySettings()
store->endArray(); store->endArray();
store->beginReadArray("FileColumns"); store->beginReadArray("FileColumns");
for(int i=0; i<getRepo().repoFileModel.columnCount(); ++i) for(int i=0; i<getRepo().getFileModel().columnCount(); ++i)
{ {
store->setArrayIndex(i); store->setArrayIndex(i);
if(store->contains("Width")) if(store->contains("Width"))
@ -1019,8 +1019,8 @@ void MainWindow::updateSettings()
} }
store->endArray(); store->endArray();
store->beginWriteArray("FileColumns", getRepo().repoFileModel.columnCount()); store->beginWriteArray("FileColumns", getRepo().getFileModel().columnCount());
for(int i=0; i<getRepo().repoFileModel.columnCount(); ++i) for(int i=0; i<getRepo().getFileModel().columnCount(); ++i)
{ {
store->setArrayIndex(i); store->setArrayIndex(i);
store->setValue("Width", ui->tableView->columnWidth(i)); store->setValue("Width", ui->tableView->columnWidth(i));
@ -1086,7 +1086,7 @@ void MainWindow::getSelectionPaths(stringset_t &paths)
for(QModelIndexList::iterator mi_it = selection.begin(); mi_it!=selection.end(); ++mi_it) for(QModelIndexList::iterator mi_it = selection.begin(); mi_it!=selection.end(); ++mi_it)
{ {
const QModelIndex &mi = *mi_it; const QModelIndex &mi = *mi_it;
QVariant data = getRepo().repoDirModel.data(mi, REPODIRMODEL_ROLE_PATH); QVariant data = getRepo().getDirModel().data(mi, REPODIRMODEL_ROLE_PATH);
paths.insert(data.toString()); paths.insert(data.toString());
} }
} }
@ -1094,7 +1094,7 @@ void MainWindow::getSelectionPaths(stringset_t &paths)
// Select all workspace files that match the includeMask // Select all workspace files that match the includeMask
void MainWindow::getAllFilenames(QStringList &filenames, int includeMask) void MainWindow::getAllFilenames(QStringList &filenames, int includeMask)
{ {
for(Repository::filemap_t::iterator it=getRepo().workspaceFiles.begin(); it!=getRepo().workspaceFiles.end(); ++it) for(Workspace::filemap_t::iterator it=getRepo().getFiles().begin(); it!=getRepo().getFiles().end(); ++it)
{ {
const RepoFile &e = *(*it); const RepoFile &e = *(*it);
@ -1118,7 +1118,7 @@ void MainWindow::getDirViewSelection(QStringList &filenames, int includeMask, bo
} }
// Select the actual files form the selected directories // Select the actual files form the selected directories
for(Repository::filemap_t::iterator it=getRepo().workspaceFiles.begin(); it!=getRepo().workspaceFiles.end(); ++it) for(Workspace::filemap_t::iterator it=getRepo().getFiles().begin(); it!=getRepo().getFiles().end(); ++it)
{ {
const RepoFile &e = *(*it); const RepoFile &e = *(*it);
@ -1172,10 +1172,10 @@ void MainWindow::getFileViewSelection(QStringList &filenames, int includeMask, b
if(mi.column()!=COLUMN_FILENAME) if(mi.column()!=COLUMN_FILENAME)
continue; continue;
QVariant data = getRepo().repoFileModel.data(mi, Qt::UserRole+1); QVariant data = getRepo().getFileModel().data(mi, Qt::UserRole+1);
QString filename = data.toString(); QString filename = data.toString();
Repository::filemap_t::iterator e_it = getRepo().workspaceFiles.find(filename); Workspace::filemap_t::iterator e_it = getRepo().getFiles().find(filename);
Q_ASSERT(e_it!=getRepo().workspaceFiles.end()); Q_ASSERT(e_it!=getRepo().getFiles().end());
const RepoFile &e = *e_it.value(); const RepoFile &e = *e_it.value();
// Skip unwanted files // Skip unwanted files
@ -1202,7 +1202,7 @@ void MainWindow::getStashViewSelection(QStringList &stashNames, bool allIfEmpty)
if(mi.column()!=0) if(mi.column()!=0)
continue; continue;
QString name = getRepo().repoStashModel.data(mi).toString(); QString name = getRepo().getStashModel().data(mi).toString();
stashNames.append(name); stashNames.append(name);
} }
} }
@ -1701,13 +1701,13 @@ void MainWindow::onTreeViewSelectionChanged(const QItemSelection &/*selected*/,
if(num_selected==0) if(num_selected==0)
return; return;
getRepo().selectedDirs.clear(); selectedDirs.clear();
for(int i=0; i<num_selected; ++i) for(int i=0; i<num_selected; ++i)
{ {
QModelIndex index = selection.at(i); QModelIndex index = selection.at(i);
QString dir = getRepo().repoDirModel.data(index, REPODIRMODEL_ROLE_PATH).toString(); QString dir = getRepo().getDirModel().data(index, REPODIRMODEL_ROLE_PATH).toString();
getRepo().selectedDirs.insert(dir); selectedDirs.insert(dir);
} }
updateFileView(); updateFileView();
@ -1728,7 +1728,7 @@ void MainWindow::on_actionOpenFolder_triggered()
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void MainWindow::on_treeView_doubleClicked(const QModelIndex &index) void MainWindow::on_treeView_doubleClicked(const QModelIndex &index)
{ {
QString target = getRepo().repoDirModel.data(index, REPODIRMODEL_ROLE_PATH).toString(); QString target = getRepo().getDirModel().data(index, REPODIRMODEL_ROLE_PATH).toString();
target = getCurrentWorkspace() + PATH_SEPARATOR + target; target = getCurrentWorkspace() + PATH_SEPARATOR + target;
QUrl url = QUrl::fromLocalFile(target); QUrl url = QUrl::fromLocalFile(target);
@ -1782,17 +1782,17 @@ void MainWindow::on_actionRenameFolder_triggered()
QString new_path = old_path.left(dir_start) + new_name; QString new_path = old_path.left(dir_start) + new_name;
if(getRepo().pathSet.contains(new_path)) if(getRepo().getPaths().contains(new_path))
{ {
QMessageBox::critical(this, tr("Error"), tr("Cannot rename folder.")+"\n" +tr("This folder exists already.")); QMessageBox::critical(this, tr("Error"), tr("Cannot rename folder.")+"\n" +tr("This folder exists already."));
return; return;
} }
// Collect the files to be moved // Collect the files to be moved
Repository::filelist_t files_to_move; Workspace::filelist_t files_to_move;
QStringList new_paths; QStringList new_paths;
QStringList operations; QStringList operations;
foreach(RepoFile *r, getRepo().workspaceFiles) foreach(RepoFile *r, getRepo().getFiles())
{ {
if(r->getPath().indexOf(old_path)!=0) if(r->getPath().indexOf(old_path)!=0)
continue; continue;
@ -1935,7 +1935,7 @@ void MainWindow::on_actionNewStash_triggered()
} }
// Check that this stash does not exist // Check that this stash does not exist
for(stashmap_t::iterator it=getRepo().stashMap.begin(); it!=getRepo().stashMap.end(); ++it) for(stashmap_t::iterator it=getRepo().getStashes().begin(); it!=getRepo().getStashes().end(); ++it)
{ {
if(stash_name == it.key()) if(stash_name == it.key())
{ {
@ -1963,8 +1963,8 @@ void MainWindow::on_actionApplyStash_triggered()
// Apply stashes // Apply stashes
for(QStringList::iterator it=stashes.begin(); it!=stashes.end(); ++it) for(QStringList::iterator it=stashes.begin(); it!=stashes.end(); ++it)
{ {
stashmap_t::iterator id_it = getRepo().stashMap.find(*it); stashmap_t::iterator id_it = getRepo().getStashes().find(*it);
Q_ASSERT(id_it!=getRepo().stashMap.end()); Q_ASSERT(id_it!=getRepo().getStashes().end());
if(!fossil().stashApply(*id_it)) if(!fossil().stashApply(*id_it))
{ {
@ -1976,8 +1976,8 @@ void MainWindow::on_actionApplyStash_triggered()
// Delete stashes // Delete stashes
for(QStringList::iterator it=stashes.begin(); delete_stashes && it!=stashes.end(); ++it) for(QStringList::iterator it=stashes.begin(); delete_stashes && it!=stashes.end(); ++it)
{ {
stashmap_t::iterator id_it = getRepo().stashMap.find(*it); stashmap_t::iterator id_it = getRepo().getStashes().find(*it);
Q_ASSERT(id_it!=getRepo().stashMap.end()); Q_ASSERT(id_it!=getRepo().getStashes().end());
if(!fossil().stashDrop(*id_it)) if(!fossil().stashDrop(*id_it))
{ {
@ -2004,8 +2004,8 @@ void MainWindow::on_actionDeleteStash_triggered()
// Delete stashes // Delete stashes
for(QStringList::iterator it=stashes.begin(); it!=stashes.end(); ++it) for(QStringList::iterator it=stashes.begin(); it!=stashes.end(); ++it)
{ {
stashmap_t::iterator id_it = getRepo().stashMap.find(*it); stashmap_t::iterator id_it = getRepo().getStashes().find(*it);
Q_ASSERT(id_it!=getRepo().stashMap.end()); Q_ASSERT(id_it!=getRepo().getStashes().end());
if(!fossil().stashDrop(*id_it)) if(!fossil().stashDrop(*id_it))
{ {
@ -2026,8 +2026,8 @@ void MainWindow::on_actionDiffStash_triggered()
if(stashes.length() != 1) if(stashes.length() != 1)
return; return;
stashmap_t::iterator id_it = getRepo().stashMap.find(*stashes.begin()); stashmap_t::iterator id_it = getRepo().getStashes().find(*stashes.begin());
Q_ASSERT(id_it!=getRepo().stashMap.end()); Q_ASSERT(id_it!=getRepo().getStashes().end());
// Run diff // Run diff
fossil().stashDiff(*id_it); fossil().stashDiff(*id_it);

View File

@ -105,26 +105,34 @@ private:
typedef QSet<QString> stringset_t; typedef QSet<QString> stringset_t;
class Repository class Workspace
{ {
public: public:
QStandardItemModel repoFileModel;
QStandardItemModel repoDirModel;
QStandardItemModel repoStashModel;
// Repository State
typedef QList<RepoFile*> filelist_t; typedef QList<RepoFile*> filelist_t;
typedef QMap<QString, RepoFile*> filemap_t; typedef QMap<QString, RepoFile*> filemap_t;
filemap_t workspaceFiles;
stringset_t pathSet;
stashmap_t stashMap;
stringset_t selectedDirs; // The directory selected in the tree
Bridge bridge;
Bridge & fossil() { return bridge; } Bridge & fossil() { return bridge; }
const Bridge & fossil() const { return bridge; } const Bridge & fossil() const { return bridge; }
static bool scanDirectory(QFileInfoList &entries, const QString& dirPath, const QString &baseDir, const QString ignoreSpec, const bool& abort, Bridge::UICallback &uiCallback); static bool scanDirectory(QFileInfoList &entries, const QString& dirPath, const QString &baseDir, const QString ignoreSpec, const bool& abort, Bridge::UICallback &uiCallback);
void scanWorkspace(bool scanLocal, bool scanIgnored, bool scanModified, bool scanUnchanged, const QString &ignoreGlob, Bridge::UICallback &uiCallback, bool &operationAborted); void scanWorkspace(bool scanLocal, bool scanIgnored, bool scanModified, bool scanUnchanged, const QString &ignoreGlob, Bridge::UICallback &uiCallback, bool &operationAborted);
QStandardItemModel &getFileModel() { return repoFileModel; }
QStandardItemModel &getDirModel() { return repoDirModel; }
QStandardItemModel &getStashModel() { return repoStashModel; }
filemap_t &getFiles() { return workspaceFiles; }
stringset_t &getPaths() { return pathSet; }
stashmap_t &getStashes() { return stashMap; }
private:
Bridge bridge;
filemap_t workspaceFiles;
stringset_t pathSet;
stashmap_t stashMap;
QStandardItemModel repoFileModel;
QStandardItemModel repoDirModel;
QStandardItemModel repoStashModel;
}; };
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
@ -163,7 +171,6 @@ private:
void rebuildRecent(); void rebuildRecent();
bool openWorkspace(const QString &path); bool openWorkspace(const QString &path);
void loadFossilSettings(); void loadFossilSettings();
QString getFossilPath();
QString getFossilHttpAddress(); QString getFossilHttpAddress();
void updateDirView(); void updateDirView();
void updateFileView(); void updateFileView();
@ -266,12 +273,13 @@ private:
class QProgressBar *progressBar; class QProgressBar *progressBar;
class QShortcut *abortShortcut; class QShortcut *abortShortcut;
bool operationAborted; bool operationAborted;
stringset_t selectedDirs; // The directory selected in the tree
Repository repo; Workspace repo;
Repository & getRepo() { return repo; } Workspace & getRepo() { return repo; }
Bridge & fossil() { return repo.bridge; } Bridge & fossil() { return repo.fossil(); }
const Bridge & fossil() const { return repo.bridge; } const Bridge & fossil() const { return repo.fossil(); }
Settings &settings; Settings &settings;
QStringList workspaceHistory; QStringList workspaceHistory;