From c67746a84d649ce0479d698198126ef2995839b2 Mon Sep 17 00:00:00 2001 From: kostas Date: Thu, 30 Apr 2015 10:59:25 +0000 Subject: [PATCH] Renamed Repository to Workspace Workspace member access is now via methods FossilOrigin-Name: 2c664b7db2644e1434b5e2d9e83a103ca2093cb3 --- manifest | 14 ++--- manifest.uuid | 2 +- src/MainWindow.cpp | 136 ++++++++++++++++++++++----------------------- src/MainWindow.h | 42 ++++++++------ 4 files changed, 101 insertions(+), 93 deletions(-) diff --git a/manifest b/manifest index 1d70504..987de87 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Cleanup -D 2015-04-30T10:36:18.967 +C Renamed\sRepository\sto\sWorkspace\nWorkspace\smember\saccess\sis\snow\svia\smethods\n +D 2015-04-30T10:59:25.241 F .travis.yml 77966888a81c4ceee1fcc79bce842c9667ad8a35 F debian/changelog eb4304dfcb6bb66850ec740838090eb50ce1249b F debian/compat b6abd567fa79cbe0196d093a067271361dc6ca8b @@ -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 939c919b6ede21771df77ff9973da7b3e39808dc -F src/MainWindow.h 9df3df4c1baf0f386e226b1991b2d1dbea0ecdbb +F src/MainWindow.cpp f04effe7dbb5712f1214a8778ab372fef44c0e01 +F src/MainWindow.h c7c22c37b157cb8fcddb6345617a7c3fe663c903 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 61734cf430e041d514222c71f751feead5b7faf6 -R 753dd95663c89722dde887fa796bf2c1 +P 0975c824a72cacd0d2fb5ee5d3c38c145712a0b4 +R d87d054d9f8c171e265c82e724cde68f U kostas -Z f5ff6cd15d239d70f6502ce6d67686d0 +Z 5be810239a33cadc87f4c7d50c02c8a6 diff --git a/manifest.uuid b/manifest.uuid index 6718dfc..ce37cb7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0975c824a72cacd0d2fb5ee5d3c38c145712a0b4 \ No newline at end of file +2c664b7db2644e1434b5e2d9e83a103ca2093cb3 \ No newline at end of file diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 0545283..9954408 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -85,7 +85,7 @@ MainWindow::MainWindow(Settings &_settings, QWidget *parent, QString *workspaceP separator->setSeparator(true); // TableView - ui->tableView->setModel(&getRepo().repoFileModel); + ui->tableView->setModel(&getRepo().getFileModel()); ui->tableView->addAction(ui->actionDiff); ui->tableView->addAction(ui->actionHistory); @@ -103,8 +103,8 @@ MainWindow::MainWindow(Settings &_settings, QWidget *parent, QString *workspaceP QStringList header; header << tr("Status") << tr("File") << tr("Extension") << tr("Modified") << tr("Path"); - getRepo().repoFileModel.setHorizontalHeaderLabels(header); - getRepo().repoFileModel.horizontalHeaderItem(COLUMN_STATUS)->setTextAlignment(Qt::AlignCenter); + getRepo().getFileModel().setHorizontalHeaderLabels(header); + getRepo().getFileModel().horizontalHeaderItem(COLUMN_STATUS)->setTextAlignment(Qt::AlignCenter); // Needed on OSX as the preset value from the GUI editor is not always reflected ui->tableView->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft); @@ -116,7 +116,7 @@ MainWindow::MainWindow(Settings &_settings, QWidget *parent, QString *workspaceP ui->tableView->horizontalHeader()->setStretchLastSection(true); // TreeView - ui->treeView->setModel(&getRepo().repoDirModel); + ui->treeView->setModel(&getRepo().getDirModel()); connect( ui->treeView->selectionModel(), SIGNAL( selectionChanged(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); // StashView - ui->tableViewStash->setModel(&getRepo().repoStashModel); + ui->tableViewStash->setModel(&getRepo().getStashModel()); ui->tableViewStash->addAction(ui->actionApplyStash); ui->tableViewStash->addAction(ui->actionDiffStash); ui->tableViewStash->addAction(ui->actionDeleteStash); @@ -210,7 +210,7 @@ MainWindow::~MainWindow() updateSettings(); // 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 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); @@ -556,8 +556,8 @@ bool MainWindow::refresh() { setStatus(tr("No workspace detected.")); enableActions(false); - getRepo().repoFileModel.removeRows(0, getRepo().repoFileModel.rowCount()); - getRepo().repoDirModel.clear(); + getRepo().getFileModel().removeRows(0, getRepo().getFileModel().rowCount()); + getRepo().getDirModel().clear(); setWindowTitle(title); return false; } @@ -565,8 +565,8 @@ bool MainWindow::refresh() { setStatus(tr("Old repository schema detected. Consider running 'fossil rebuild'")); enableActions(false); - getRepo().repoFileModel.removeRows(0, getRepo().repoFileModel.rowCount()); - getRepo().repoDirModel.clear(); + getRepo().getFileModel().removeRows(0, getRepo().getFileModel().rowCount()); + getRepo().getDirModel().clear(); setWindowTitle(title); 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 QFileInfoList all_files; @@ -601,11 +601,11 @@ void Repository::scanWorkspace(bool scanLocal, bool scanIgnored, bool scanModifi bool scan_files = scanLocal; // 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; - workspaceFiles.clear(); - pathSet.clear(); + getFiles().clear(); + getPaths().clear(); operationAborted = false; @@ -636,8 +636,8 @@ void Repository::scanWorkspace(bool scanLocal, bool scanIgnored, bool scanModifi continue; RepoFile *rf = new RepoFile(*it, RepoFile::TYPE_UNKNOWN, wkdir); - workspaceFiles.insert(rf->getFilePath(), rf); - pathSet.insert(rf->getPath()); + getFiles().insert(rf->getFilePath(), rf); + getPaths().insert(rf->getPath()); } } uiCallback.endProcess(); @@ -685,37 +685,37 @@ void Repository::scanWorkspace(bool scanLocal, bool scanIgnored, bool scanModifi if( ((type & RepoFile::TYPE_MODIFIED) && !scanModified) || ((type & RepoFile::TYPE_UNCHANGED) && !scanUnchanged)) { - workspaceFiles.remove(fname); + getFiles().remove(fname); continue; } else add_missing = true; - Repository::filemap_t::iterator it = workspaceFiles.find(fname); + Workspace::filemap_t::iterator it = getFiles().find(fname); RepoFile *rf = 0; - if(add_missing && it==workspaceFiles.end()) + if(add_missing && it==getFiles().end()) { QFileInfo info(wkdir+QDir::separator()+fname); rf = new RepoFile(info, type, wkdir); - workspaceFiles.insert(rf->getFilePath(), rf); + getFiles().insert(rf->getFilePath(), rf); } if(!rf) { - it = workspaceFiles.find(fname); - Q_ASSERT(it!=workspaceFiles.end()); + it = getFiles().find(fname); + Q_ASSERT(it!=getFiles().end()); rf = *it; } rf->setType(type); QString path = rf->getPath(); - pathSet.insert(path); + getPaths().insert(path); } // Load the stash - fossil().stashList(stashMap); + fossil().stashList(getStashes()); _done: uiCallback.endProcess(); } @@ -780,18 +780,18 @@ static void addPathToTree(QStandardItem &root, const QString &path) void MainWindow::updateDirView() { // Directory View - getRepo().repoDirModel.clear(); + getRepo().getDirModel().clear(); QStringList header; header << tr("Folders"); - getRepo().repoDirModel.setHorizontalHeaderLabels(header); + getRepo().getDirModel().setHorizontalHeaderLabels(header); QStandardItem *root = new QStandardItem(QIcon(":icons/icons/My Documents-01.png"), fossil().getProjectName()); root->setData(""); // Empty Path root->setEditable(false); - getRepo().repoDirModel.appendRow(root); - for(stringset_t::iterator it = getRepo().pathSet.begin(); it!=getRepo().pathSet.end(); ++it) + getRepo().getDirModel().appendRow(root); + for(stringset_t::iterator it = getRepo().getPaths().begin(); it!=getRepo().getPaths().end(); ++it) { const QString &dir = *it; if(dir.isEmpty()) @@ -807,7 +807,7 @@ void MainWindow::updateDirView() void MainWindow::updateFileView() { // 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; } stats[] = @@ -823,16 +823,16 @@ void MainWindow::updateFileView() 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; - 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(); QString path = e.getPath(); // 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; // Status Column @@ -851,13 +851,13 @@ void MainWindow::updateFileView() QStandardItem *status = new QStandardItem(QIcon(status_icon_path), 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(); QIcon icon = icon_provider.icon(finfo); 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) filename_item = new QStandardItem(icon, QDir::toNativeSeparators(e.getFilePath())); @@ -867,10 +867,10 @@ void MainWindow::updateFileView() Q_ASSERT(filename_item); // Keep the path in the user data 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().repoFileModel.setItem(item_id, COLUMN_MODIFIED, new QStandardItem(finfo.lastModified().toString(Qt::SystemLocaleShortDate))); + getRepo().getFileModel().setItem(item_id, COLUMN_EXTENSION, new QStandardItem(finfo.suffix())); + getRepo().getFileModel().setItem(item_id, COLUMN_MODIFIED, new QStandardItem(finfo.lastModified().toString(Qt::SystemLocaleShortDate))); ++item_id; } @@ -881,17 +881,17 @@ void MainWindow::updateFileView() //------------------------------------------------------------------------------ void MainWindow::updateStashView() { - getRepo().repoStashModel.clear(); + getRepo().getStashModel().clear(); QStringList header; 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()); item->setToolTip(it.key()); - getRepo().repoStashModel.appendRow(item); + getRepo().getStashModel().appendRow(item); } ui->tableViewStash->resizeColumnsToContents(); ui->tableViewStash->resizeRowsToContents(); @@ -945,7 +945,7 @@ void MainWindow::applySettings() store->endArray(); store->beginReadArray("FileColumns"); - for(int i=0; isetArrayIndex(i); if(store->contains("Width")) @@ -1019,8 +1019,8 @@ void MainWindow::updateSettings() } store->endArray(); - store->beginWriteArray("FileColumns", getRepo().repoFileModel.columnCount()); - for(int i=0; ibeginWriteArray("FileColumns", getRepo().getFileModel().columnCount()); + for(int i=0; isetArrayIndex(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) { 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()); } } @@ -1094,7 +1094,7 @@ void MainWindow::getSelectionPaths(stringset_t &paths) // Select all workspace files that match the 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); @@ -1118,7 +1118,7 @@ void MainWindow::getDirViewSelection(QStringList &filenames, int includeMask, bo } // 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); @@ -1172,10 +1172,10 @@ void MainWindow::getFileViewSelection(QStringList &filenames, int includeMask, b if(mi.column()!=COLUMN_FILENAME) continue; - QVariant data = getRepo().repoFileModel.data(mi, Qt::UserRole+1); + QVariant data = getRepo().getFileModel().data(mi, Qt::UserRole+1); QString filename = data.toString(); - Repository::filemap_t::iterator e_it = getRepo().workspaceFiles.find(filename); - Q_ASSERT(e_it!=getRepo().workspaceFiles.end()); + Workspace::filemap_t::iterator e_it = getRepo().getFiles().find(filename); + Q_ASSERT(e_it!=getRepo().getFiles().end()); const RepoFile &e = *e_it.value(); // Skip unwanted files @@ -1202,7 +1202,7 @@ void MainWindow::getStashViewSelection(QStringList &stashNames, bool allIfEmpty) if(mi.column()!=0) continue; - QString name = getRepo().repoStashModel.data(mi).toString(); + QString name = getRepo().getStashModel().data(mi).toString(); stashNames.append(name); } } @@ -1701,13 +1701,13 @@ void MainWindow::onTreeViewSelectionChanged(const QItemSelection &/*selected*/, if(num_selected==0) return; - getRepo().selectedDirs.clear(); + selectedDirs.clear(); for(int i=0; igetPath().indexOf(old_path)!=0) continue; @@ -1935,7 +1935,7 @@ void MainWindow::on_actionNewStash_triggered() } // 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()) { @@ -1963,8 +1963,8 @@ void MainWindow::on_actionApplyStash_triggered() // Apply stashes for(QStringList::iterator it=stashes.begin(); it!=stashes.end(); ++it) { - stashmap_t::iterator id_it = getRepo().stashMap.find(*it); - Q_ASSERT(id_it!=getRepo().stashMap.end()); + stashmap_t::iterator id_it = getRepo().getStashes().find(*it); + Q_ASSERT(id_it!=getRepo().getStashes().end()); if(!fossil().stashApply(*id_it)) { @@ -1976,8 +1976,8 @@ void MainWindow::on_actionApplyStash_triggered() // Delete stashes for(QStringList::iterator it=stashes.begin(); delete_stashes && it!=stashes.end(); ++it) { - stashmap_t::iterator id_it = getRepo().stashMap.find(*it); - Q_ASSERT(id_it!=getRepo().stashMap.end()); + stashmap_t::iterator id_it = getRepo().getStashes().find(*it); + Q_ASSERT(id_it!=getRepo().getStashes().end()); if(!fossil().stashDrop(*id_it)) { @@ -2004,8 +2004,8 @@ void MainWindow::on_actionDeleteStash_triggered() // Delete stashes for(QStringList::iterator it=stashes.begin(); it!=stashes.end(); ++it) { - stashmap_t::iterator id_it = getRepo().stashMap.find(*it); - Q_ASSERT(id_it!=getRepo().stashMap.end()); + stashmap_t::iterator id_it = getRepo().getStashes().find(*it); + Q_ASSERT(id_it!=getRepo().getStashes().end()); if(!fossil().stashDrop(*id_it)) { @@ -2026,8 +2026,8 @@ void MainWindow::on_actionDiffStash_triggered() if(stashes.length() != 1) return; - stashmap_t::iterator id_it = getRepo().stashMap.find(*stashes.begin()); - Q_ASSERT(id_it!=getRepo().stashMap.end()); + stashmap_t::iterator id_it = getRepo().getStashes().find(*stashes.begin()); + Q_ASSERT(id_it!=getRepo().getStashes().end()); // Run diff fossil().stashDiff(*id_it); diff --git a/src/MainWindow.h b/src/MainWindow.h index 0d83202..9e48e56 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -105,26 +105,34 @@ private: typedef QSet stringset_t; -class Repository +class Workspace { public: - QStandardItemModel repoFileModel; - QStandardItemModel repoDirModel; - QStandardItemModel repoStashModel; - // Repository State typedef QList filelist_t; typedef QMap 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; } 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); - void scanWorkspace(bool scanLocal, bool scanIgnored, bool scanModified, bool scanUnchanged, const QString &ignoreGlob, Bridge::UICallback &uiCallback, bool &operationAborted); + 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); + + 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(); bool openWorkspace(const QString &path); void loadFossilSettings(); - QString getFossilPath(); QString getFossilHttpAddress(); void updateDirView(); void updateFileView(); @@ -266,12 +273,13 @@ private: class QProgressBar *progressBar; class QShortcut *abortShortcut; bool operationAborted; + stringset_t selectedDirs; // The directory selected in the tree - Repository repo; - Repository & getRepo() { return repo; } + Workspace repo; + Workspace & getRepo() { return repo; } - Bridge & fossil() { return repo.bridge; } - const Bridge & fossil() const { return repo.bridge; } + Bridge & fossil() { return repo.fossil(); } + const Bridge & fossil() const { return repo.fossil(); } Settings &settings; QStringList workspaceHistory;