summaryrefslogtreecommitdiff
path: root/ui/guiStatusHandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ui/guiStatusHandler.cpp')
-rw-r--r--ui/guiStatusHandler.cpp230
1 files changed, 82 insertions, 148 deletions
diff --git a/ui/guiStatusHandler.cpp b/ui/guiStatusHandler.cpp
index 7929c122..280328da 100644
--- a/ui/guiStatusHandler.cpp
+++ b/ui/guiStatusHandler.cpp
@@ -1,8 +1,8 @@
#include "guiStatusHandler.h"
-#include "../library/customButton.h"
#include "smallDialogs.h"
-#include "../library/globalFunctions.h"
+#include "../shared/globalFunctions.h"
#include "mainDialog.h"
+#include <wx/wupdlock.h>
CompareStatusHandler::CompareStatusHandler(MainDialog* dlg) :
@@ -10,47 +10,10 @@ CompareStatusHandler::CompareStatusHandler(MainDialog* dlg) :
ignoreErrors(false),
currentProcess(StatusHandler::PROCESS_NONE)
{
+ wxWindowUpdateLocker dummy(mainDialog); //avoid display distortion
+
//prevent user input during "compare", do not disable maindialog since abort-button would also be disabled
- //it's not nice, but works
- mainDialog->m_notebookBottomLeft->Disable();
- mainDialog->m_radioBtnSizeDate->Disable();
- mainDialog->m_radioBtnContent->Disable();
- mainDialog->m_bpButtonFilter->Disable();
- mainDialog->m_hyperlinkCfgFilter->Disable();
- mainDialog->m_checkBoxHideFilt->Disable();
- mainDialog->m_bpButtonSyncConfig->Disable();
- mainDialog->m_buttonStartSync->Disable();
- mainDialog->m_dirPickerLeft->Disable();
- mainDialog->m_dirPickerRight->Disable();
- mainDialog->m_bpButtonSwapSides->Disable();
- mainDialog->m_bpButtonLeftOnly->Disable();
- mainDialog->m_bpButtonLeftNewer->Disable();
- mainDialog->m_bpButtonEqual->Disable();
- mainDialog->m_bpButtonDifferent->Disable();
- mainDialog->m_bpButtonRightNewer->Disable();
- mainDialog->m_bpButtonRightOnly->Disable();
- mainDialog->m_panelLeft->Disable();
- mainDialog->m_panelMiddle->Disable();
- mainDialog->m_panelRight->Disable();
- mainDialog->m_panelTopLeft->Disable();
- mainDialog->m_panelTopMiddle->Disable();
- mainDialog->m_panelTopRight->Disable();
- mainDialog->m_bpButtonSave->Disable();
- mainDialog->m_bpButtonLoad->Disable();
- mainDialog->m_choiceHistory->Disable();
- mainDialog->m_bpButton10->Disable();
- mainDialog->m_bpButton14->Disable();
- mainDialog->m_scrolledWindowFolderPairs->Disable();
- mainDialog->m_menubar1->EnableTop(0, false);
- mainDialog->m_menubar1->EnableTop(1, false);
- mainDialog->m_menubar1->EnableTop(2, false);
-
- //show abort button
- mainDialog->m_buttonAbort->Enable();
- mainDialog->m_buttonAbort->Show();
- mainDialog->m_buttonCompare->Disable();
- mainDialog->m_buttonCompare->Hide();
- mainDialog->m_buttonAbort->SetFocus();
+ mainDialog->disableAllElements();
//display status panel during compare
mainDialog->compareStatus->init(); //clear old values
@@ -59,65 +22,34 @@ CompareStatusHandler::CompareStatusHandler(MainDialog* dlg) :
mainDialog->bSizer1->Layout(); //both sizers need to recalculate!
mainDialog->bSizer6->Layout(); //adapt layout for wxBitmapWithImage
mainDialog->Refresh();
+
+ //register abort button
+ mainDialog->m_buttonAbort->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CompareStatusHandler::OnAbortCompare ), NULL, this );
}
CompareStatusHandler::~CompareStatusHandler()
{
- //ATTENTION don't call wxAPP->Yield()! at this point in time there is a mismatch between
- //gridDataView and currentGridData!! avoid grid repaint at all costs!!
+ //ATTENTION: wxAPP->Yield() is called! at this point in time there is a mismatch between
+ //gridDataView and currentGridData!! make sure gridDataView does NOT access currentGridData!!
- //just DON'T: updateUiNow(); //ui update before enabling buttons again: prevent strange behaviour of delayed button clicks
+ updateUiNow(); //ui update before enabling buttons again: prevent strange behaviour of delayed button clicks
//reenable complete main dialog
- mainDialog->m_notebookBottomLeft->Enable();
- mainDialog->m_radioBtnSizeDate->Enable();
- mainDialog->m_radioBtnContent->Enable();
- mainDialog->m_bpButtonFilter->Enable();
- mainDialog->m_hyperlinkCfgFilter->Enable();
- mainDialog->m_checkBoxHideFilt->Enable();
- mainDialog->m_bpButtonSyncConfig->Enable();
- mainDialog->m_buttonStartSync->Enable();
- mainDialog->m_dirPickerLeft->Enable();
- mainDialog->m_dirPickerRight->Enable();
- mainDialog->m_bpButtonSwapSides->Enable();
- mainDialog->m_bpButtonLeftOnly->Enable();
- mainDialog->m_bpButtonLeftNewer->Enable();
- mainDialog->m_bpButtonEqual->Enable();
- mainDialog->m_bpButtonDifferent->Enable();
- mainDialog->m_bpButtonRightNewer->Enable();
- mainDialog->m_bpButtonRightOnly->Enable();
- mainDialog->m_panelLeft->Enable();
- mainDialog->m_panelMiddle->Enable();
- mainDialog->m_panelRight->Enable();
- mainDialog->m_panelTopLeft->Enable();
- mainDialog->m_panelTopMiddle->Enable();
- mainDialog->m_panelTopRight->Enable();
- mainDialog->m_bpButtonSave->Enable();
- mainDialog->m_bpButtonLoad->Enable();
- mainDialog->m_choiceHistory->Enable();
- mainDialog->m_bpButton10->Enable();
- mainDialog->m_bpButton14->Enable();
- mainDialog->m_scrolledWindowFolderPairs->Enable();
- mainDialog->m_menubar1->EnableTop(0, true);
- mainDialog->m_menubar1->EnableTop(1, true);
- mainDialog->m_menubar1->EnableTop(2, true);
+ mainDialog->enableAllElements();
if (abortIsRequested())
mainDialog->pushStatusInformation(_("Operation aborted!"));
- mainDialog->m_buttonAbort->Disable();
- mainDialog->m_buttonAbort->Hide();
- mainDialog->m_buttonCompare->Enable(); //enable compare button
- mainDialog->m_buttonCompare->Show();
-
//hide status panel from main window
mainDialog->compareStatus->Hide();
mainDialog->bSizer6->Layout(); //adapt layout for wxBitmapWithImage
-
mainDialog->Layout();
mainDialog->Refresh();
+
+ //de-register abort button
+ mainDialog->m_buttonAbort->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CompareStatusHandler::OnAbortCompare ), NULL, this );
}
@@ -167,7 +99,7 @@ void CompareStatusHandler::updateProcessedData(int objectsProcessed, wxLongLong
}
-ErrorHandler::Response CompareStatusHandler::reportError(const Zstring& text)
+ErrorHandler::Response CompareStatusHandler::reportError(const wxString& message)
{
if (ignoreErrors)
return ErrorHandler::IGNORE_ERROR;
@@ -175,7 +107,7 @@ ErrorHandler::Response CompareStatusHandler::reportError(const Zstring& text)
mainDialog->compareStatus->updateStatusPanelNow();
bool ignoreNextErrors = false;
- wxString errorMessage = wxString(text.c_str()) + wxT("\n\n") + _("Ignore this error, retry or abort?");
+ const wxString errorMessage = message + wxT("\n\n\n") + _("Ignore this error, retry or abort?");
ErrorDlg* errorDlg = new ErrorDlg(mainDialog,
ErrorDlg::BUTTON_IGNORE | ErrorDlg::BUTTON_RETRY | ErrorDlg::BUTTON_ABORT,
errorMessage, ignoreNextErrors);
@@ -198,22 +130,22 @@ ErrorHandler::Response CompareStatusHandler::reportError(const Zstring& text)
}
-void CompareStatusHandler::reportFatalError(const Zstring& errorMessage)
+void CompareStatusHandler::reportFatalError(const wxString& errorMessage)
{
mainDialog->compareStatus->updateStatusPanelNow();
bool dummy = false;
ErrorDlg* errorDlg = new ErrorDlg(mainDialog,
ErrorDlg::BUTTON_ABORT,
- errorMessage.c_str(), dummy);
+ errorMessage, dummy);
errorDlg->ShowModal();
abortThisProcess();
}
-void CompareStatusHandler::reportWarning(const Zstring& warningMessage, bool& dontShowAgain)
+void CompareStatusHandler::reportWarning(const wxString& warningMessage, bool& warningActive)
{
- if (ignoreErrors) //if errors are ignored, then warnings should also
+ if (!warningActive || ignoreErrors) //if errors are ignored, then warnings should also
return;
mainDialog->compareStatus->updateStatusPanelNow();
@@ -222,19 +154,18 @@ void CompareStatusHandler::reportWarning(const Zstring& warningMessage, bool& do
bool dontWarnAgain = false;
WarningDlg* warningDlg = new WarningDlg(mainDialog,
WarningDlg::BUTTON_IGNORE | WarningDlg::BUTTON_ABORT,
- warningMessage.c_str(),
+ warningMessage,
dontWarnAgain);
- switch (warningDlg->ShowModal())
+ switch (static_cast<WarningDlg::Response>(warningDlg->ShowModal()))
{
case WarningDlg::BUTTON_ABORT:
abortThisProcess();
+ break;
case WarningDlg::BUTTON_IGNORE:
- dontShowAgain = dontWarnAgain;
- return;
+ warningActive = !dontWarnAgain;
+ break;
}
-
- assert(false);
}
@@ -245,6 +176,12 @@ void CompareStatusHandler::forceUiRefresh()
}
+void CompareStatusHandler::OnAbortCompare(wxCommandEvent& event)
+{
+ requestAbortion();
+}
+
+
void CompareStatusHandler::abortThisProcess()
{
requestAbortion();
@@ -265,23 +202,24 @@ SyncStatusHandler::SyncStatusHandler(wxWindow* dlg, bool ignoreAllErrors) :
SyncStatusHandler::~SyncStatusHandler()
{
//print the results list
- unsigned int failedItems = unhandledErrors.GetCount();
wxString result;
- if (failedItems)
+ if (errorLog.messageCount() > 0)
{
- result = wxString(_("Warning: Synchronization failed for %x item(s):")) + wxT("\n\n");
- result.Replace(wxT("%x"), globalFunctions::numberToWxString(failedItems), false);
-
- for (unsigned int j = 0; j < failedItems; ++j)
- { //remove linebreaks
- wxString errorMessage = unhandledErrors[j];
- for (wxString::iterator i = errorMessage.begin(); i != errorMessage.end(); ++i)
- if (*i == wxChar('\n'))
- *i = wxChar(' ');
+ if (errorLog.errorsTotal() > 0)
+ {
+ wxString header(_("Warning: Synchronization failed for %x item(s):"));
+ header.Replace(wxT("%x"), globalFunctions::numberToWxString(errorLog.errorsTotal()), false);
+ result += header + wxT("\n\n");
+ }
- result += errorMessage + wxT("\n");
+ const std::vector<wxString>& messages = errorLog.getFormattedMessages();
+ for (std::vector<wxString>::const_iterator i = messages.begin(); i != messages.end(); ++i)
+ {
+ result += *i;
+ result += wxChar('\n');
}
- result+= wxT("\n");
+
+ result += wxT("\n");
}
//notify to syncStatusFrame that current process has ended
@@ -291,7 +229,7 @@ SyncStatusHandler::~SyncStatusHandler()
syncStatusFrame->setStatusText_NoUpdate(result.c_str());
syncStatusFrame->processHasFinished(SyncStatus::ABORTED); //enable okay and close events
}
- else if (failedItems)
+ else if (errorLog.errorsTotal() > 0)
{
result+= wxString(_("Synchronization completed with errors!")) + wxT(" ") + _("You may try to synchronize remaining items again (WITHOUT having to re-compare)!");
syncStatusFrame->setStatusText_NoUpdate(result.c_str());
@@ -337,14 +275,11 @@ void SyncStatusHandler::updateProcessedData(int objectsProcessed, wxLongLong dat
}
-ErrorHandler::Response SyncStatusHandler::reportError(const Zstring& text)
+ErrorHandler::Response SyncStatusHandler::reportError(const wxString& errorMessage)
{
- //add current time before error message
- wxString errorWithTime = wxString(wxT("[")) + wxDateTime::Now().FormatTime() + wxT("] ") + text.c_str();
-
if (ignoreErrors)
{
- unhandledErrors.Add(errorWithTime);
+ errorLog.logError(errorMessage);
return ErrorHandler::IGNORE_ERROR;
}
@@ -353,66 +288,65 @@ ErrorHandler::Response SyncStatusHandler::reportError(const Zstring& text)
bool ignoreNextErrors = false;
ErrorDlg* errorDlg = new ErrorDlg(syncStatusFrame,
ErrorDlg::BUTTON_IGNORE | ErrorDlg::BUTTON_RETRY | ErrorDlg::BUTTON_ABORT,
- wxString(text) + wxT("\n\n") + _("Ignore this error, retry or abort synchronization?"),
+ errorMessage + wxT("\n\n\n") + _("Ignore this error, retry or abort synchronization?"),
ignoreNextErrors);
- int rv = errorDlg->ShowModal();
- switch (rv)
+ switch (static_cast<ErrorDlg::ReturnCodes>(errorDlg->ShowModal()))
{
case ErrorDlg::BUTTON_IGNORE:
ignoreErrors = ignoreNextErrors;
- unhandledErrors.Add(errorWithTime);
+ errorLog.logError(errorMessage);
return ErrorHandler::IGNORE_ERROR;
case ErrorDlg::BUTTON_RETRY:
return ErrorHandler::RETRY;
case ErrorDlg::BUTTON_ABORT:
- unhandledErrors.Add(errorWithTime);
+ errorLog.logError(errorMessage);
abortThisProcess();
}
assert (false);
- unhandledErrors.Add(errorWithTime);
+ errorLog.logError(errorMessage);
return ErrorHandler::IGNORE_ERROR;
}
-void SyncStatusHandler::reportFatalError(const Zstring& errorMessage)
-{ //add current time before error message
- wxString errorWithTime = wxString(wxT("[")) + wxDateTime::Now().FormatTime() + wxT("] ") + errorMessage.c_str();
-
- unhandledErrors.Add(errorWithTime);
+void SyncStatusHandler::reportFatalError(const wxString& errorMessage)
+{
+ errorLog.logError(errorMessage);
abortThisProcess();
}
-void SyncStatusHandler::reportWarning(const Zstring& warningMessage, bool& dontShowAgain)
-{ //add current time before warning message
- wxString warningWithTime = wxString(wxT("[")) + wxDateTime::Now().FormatTime() + wxT("] ") + warningMessage.c_str();
-
- if (ignoreErrors) //if errors are ignored, then warnings should also
- return; //no unhandled error situation!
-
- syncStatusFrame->updateStatusDialogNow();
+void SyncStatusHandler::reportWarning(const wxString& warningMessage, bool& warningActive)
+{
+ errorLog.logWarning(warningMessage);
- //show popup and ask user how to handle warning
- bool dontWarnAgain = false;
- WarningDlg* warningDlg = new WarningDlg(syncStatusFrame,
- WarningDlg::BUTTON_IGNORE | WarningDlg::BUTTON_ABORT,
- warningMessage.c_str(),
- dontWarnAgain);
- switch (warningDlg->ShowModal())
- {
- case WarningDlg::BUTTON_IGNORE: //no unhandled error situation!
- dontShowAgain = dontWarnAgain;
+ if (ignoreErrors || !warningActive) //if errors are ignored, then warnings should also
return;
+ else
+ {
+ syncStatusFrame->updateStatusDialogNow();
+
+ //show popup and ask user how to handle warning
+ bool dontWarnAgain = false;
+ WarningDlg* warningDlg = new WarningDlg(syncStatusFrame,
+ WarningDlg::BUTTON_IGNORE | WarningDlg::BUTTON_ABORT,
+ warningMessage,
+ dontWarnAgain);
+ switch (static_cast<WarningDlg::Response>(warningDlg->ShowModal()))
+ {
+ case WarningDlg::BUTTON_IGNORE: //no unhandled error situation!
+ warningActive = !dontWarnAgain;
+ return;
+
+ case WarningDlg::BUTTON_ABORT:
+ abortThisProcess();
+ return;
+ }
- case WarningDlg::BUTTON_ABORT:
- unhandledErrors.Add(warningWithTime);
- abortThisProcess();
+ assert(false);
}
-
- assert(false);
}
bgstack15