Skip to content

Commit

Permalink
PMR Workspaces window: improved the synchronisation with PMR in case …
Browse files Browse the repository at this point in the history
…the Internet connection drops (closes #1566).
  • Loading branch information
agarny committed Mar 16, 2018
2 parents 623575b + 26604d1 commit 357dce2
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 18 deletions.
1 change: 1 addition & 0 deletions doc/downloads/index.js
Expand Up @@ -38,6 +38,7 @@ var jsonData = { "versions": [
],
"changes": [
{ "change": "<strong>PMR support:</strong> now provide a more meaningful error message when something goes wrong (see issue <a href=\"https://github.com/opencor/opencor/issues/1558\">#1558</a>). Fixed a problem with folders being potentially incorrectly tracked (see issue <a href=\"https://github.com/opencor/opencor/issues/1559\">#1559</a>)." },
{ "change": "<strong>PMR Workspaces window:</strong> improved the synchronisation with PMR in case the Internet connection drops (see issue <a href=\"https://github.com/opencor/opencor/issues/1566\">#1566</a>)." },
{ "change": "<strong>Simulation Experiment view:</strong> fixed a small regression problem with nothing being shown when running a simulation and then asking for a graph to be plotted (see issue <a href=\"https://github.com/opencor/opencor/issues/1560\">#1560</a>)." },
{ "change": "<strong>Third-party libraries:</strong> upgraded <a href=\"https://libgit2.github.com/\">libgit2</a> to version 0.26.3 (see issue <a href=\"https://github.com/opencor/opencor/issues/1557\">#1557</a>)." }
]
Expand Down
Expand Up @@ -27,6 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "pmrsupport.h"
#include "pmrsupportpreferenceswidget.h"
#include "pmrwebservice.h"
#include "pmrworkspace.h"
#include "pmrworkspacemanager.h"
#include "pmrworkspaceswindowsynchronizedialog.h"
#include "pmrworkspaceswindowwidget.h"
Expand Down Expand Up @@ -1195,13 +1196,18 @@ void PmrWorkspacesWindowWidget::showCustomContextMenu() const
tr("View the current workspace on the computer"):
tr("View the current workspaces on the computer"));

PMRSupport::PmrWorkspace *workspace = currentItem()->workspace();
PMRSupport::PmrWorkspace::WorkspaceStatus workspaceStatus = workspace->gitWorkspaceStatus();

mViewWorkspaceInPmrAction->setEnabled(items.count());
mViewWorkspaceOncomputerAction->setEnabled(nbOfWorkspacePaths && (nbOfWorkspacePaths == workspaces.count()));
mCopyWorkspaceUrlAction->setEnabled(oneWorkspaceUrl);
mCopyWorkspacePathAction->setEnabled(oneWorkspacePath);
mMakeLocalWorkspaceCopyAction->setEnabled(oneItem && !nbOfWorkspacePaths);
mSynchronizeWorkspaceAction->setEnabled( oneWorkspacePath
&& (currentItem()->workspace()->gitWorkspaceStatus() & PMRSupport::PmrWorkspace::StatusUnstaged));
&& ( ( workspace->isOwned()
&& (workspaceStatus & PMRSupport::PmrWorkspace::StatusAhead))
|| (workspaceStatus & PMRSupport::PmrWorkspace::StatusUnstaged)));
mAboutWorkspaceAction->setEnabled(oneWorkspaceUrl);

mContextMenu->exec(QCursor::pos());
Expand Down Expand Up @@ -1420,31 +1426,38 @@ void PmrWorkspacesWindowWidget::synchronizeWorkspace()
tr("An <a href=\"opencor://openPreferencesDialog/PMRSupport\">email</a> must be set before you can synchronise with PMR."));
} else {
// Synchronise the current workspace, which involves letting the user
// decide which files should be staged, commit those files, pull things
// from PMR and, if we own the workspace, push things to PMR before
// refreshing our workspace
// decide which files should be staged (if they are not already staged),
// commit those files, pull things from PMR and, if we own the
// workspace, push things to PMR before refreshing our workspace
// Note: if we come here and the Internet connection is down, then we
// will be able to do everything except pushing things to PMR,
// which means that we will be 'ahead', hence we need to check our
// current state...

QSettings settings;
PMRSupport::PmrWorkspace *workspace = currentItem()->workspace();

settings.beginGroup(mSettingsGroup);
settings.beginGroup("PmrWorkspacesWindowSynchronizeDialog");
PMRSupport::PmrWorkspace *workspace = currentItem()->workspace();
PmrWorkspacesWindowSynchronizeDialog synchronizeDialog(mSettingsGroup, workspace, mTimer, Core::mainWindow());
if (workspace->gitWorkspaceStatus() & PMRSupport::PmrWorkspace::StatusUnstaged) {
QSettings settings;

synchronizeDialog.exec(&settings);
settings.beginGroup(mSettingsGroup);
settings.beginGroup("PmrWorkspacesWindowSynchronizeDialog");
PmrWorkspacesWindowSynchronizeDialog synchronizeDialog(mSettingsGroup, workspace, mTimer, Core::mainWindow());

if (synchronizeDialog.result() == QMessageBox::Ok) {
QStringList fileNames = synchronizeDialog.fileNames();
synchronizeDialog.exec(&settings);

for (int i = 0, iMax = fileNames.count(); i < iMax; ++i)
workspace->stageFile(fileNames[i], true);
if (synchronizeDialog.result() == QMessageBox::Ok) {
QStringList fileNames = synchronizeDialog.fileNames();

workspace->commit(synchronizeDialog.message());
for (int i = 0, iMax = fileNames.count(); i < iMax; ++i)
workspace->stageFile(fileNames[i], true);

mPmrWebService->requestWorkspaceSynchronize(currentItem()->workspace(), workspace->isOwned());
}
workspace->commit(synchronizeDialog.message());
}
settings.endGroup();
settings.endGroup();
settings.endGroup();
}

mPmrWebService->requestWorkspaceSynchronize(workspace, workspace->isOwned());
}
}

Expand Down

0 comments on commit 357dce2

Please sign in to comment.