return (myOperations.count() > 0) && (myOperations.last() != NULL);
}
+int XGUI_OperationMgr::operationsCount() const
+{
+ return myOperations.count();
+}
+
bool XGUI_OperationMgr::startOperation(ModuleBase_Operation* theOperation)
{
if (!canStartOperation(theOperation))
connect(theOperation, SIGNAL(stopped()), this, SLOT(onOperationStopped()));
connect(theOperation, SIGNAL(started()), this, SIGNAL(operationStarted()));
+ connect(theOperation, SIGNAL(resumed()), this, SIGNAL(operationResumed()));
theOperation->start();
return true;
}
-void XGUI_OperationMgr::resumeOperation(ModuleBase_Operation* theOperation)
+bool XGUI_OperationMgr::abortOperation()
{
- connect(theOperation, SIGNAL(stopped()), this, SLOT(onOperationStopped()));
- connect(theOperation, SIGNAL(started()), this, SIGNAL(operationStarted()));
+ ModuleBase_Operation* aCurrentOp = currentOperation();
+ if (!aCurrentOp || !canStopOperation())
+ return false;
+
+ aCurrentOp->abort();
+ return true;
+}
+void XGUI_OperationMgr::resumeOperation(ModuleBase_Operation* theOperation)
+{
theOperation->resume();
}
{
bool aCanStart = true;
ModuleBase_Operation* aCurrentOp = currentOperation();
- if (aCurrentOp && !theOperation->isGranted())
+ if (aCurrentOp && !theOperation->isGranted(aCurrentOp))
{
- int anAnswer = QMessageBox::question(0, tr("Operation launch"),
- tr("Previous operation is not finished and will be aborted"),
- QMessageBox::Ok, QMessageBox::Cancel);
- if (anAnswer == QMessageBox::Ok) {
+ if (canStopOperation()) {
aCurrentOp->abort();
} else {
aCanStart = false;
return aCanStart;
}
+bool XGUI_OperationMgr::canStopOperation()
+{
+ int anAnswer = QMessageBox::question(0, tr("Operation launch"),
+ tr("Previous operation is not finished and will be aborted"),
+ QMessageBox::Ok, QMessageBox::Cancel);
+ return anAnswer == QMessageBox::Ok;
+}
+
+void XGUI_OperationMgr::onCommitOperation()
+{
+ ModuleBase_Operation* anOperation = currentOperation();
+ if (anOperation)
+ anOperation->commit();
+}
+
+void XGUI_OperationMgr::onAbortOperation()
+{
+ ModuleBase_Operation* anOperation = currentOperation();
+ if (anOperation)
+ anOperation->abort();
+}
+
void XGUI_OperationMgr::onOperationStopped()
{
ModuleBase_Operation* aSenderOperation = dynamic_cast<ModuleBase_Operation*>(sender());