Index: src/ch/ComboDataWrapper.h =================================================================== diff -u --- src/ch/ComboDataWrapper.h (revision 0) +++ src/ch/ComboDataWrapper.h (revision 3aa1103497018be2a7494e79e03c5f4c674485be) @@ -0,0 +1,62 @@ +// ============================================================================ +// Copyright (C) 2001-2020 by Jozef Starosczyk +// ixen {at} copyhandler [dot] com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +#pragma once + +template +class ComboDataWrapper +{ +public: + ComboDataWrapper(CComboBox& rCombo, T defaultValue, T lastValue) : + m_rCombo(rCombo), + m_defaultValue(defaultValue), + m_lastValue(lastValue) + { + } + + T GetSelectedValue() const + { + int iSel = m_rCombo.GetCurSel(); + if(iSel < 0) + return m_defaultValue; + + DWORD_PTR dwData = m_rCombo.GetItemData(iSel); + if(dwData < m_lastValue) + return (T)dwData; + + return m_defaultValue; + } + + void SelectComboResult(T value) + { + for(int iIndex = 0; iIndex < m_rCombo.GetCount(); ++iIndex) + { + DWORD_PTR dwData = m_rCombo.GetItemData(iIndex); + if(dwData == value) + { + m_rCombo.SetCurSel(iIndex); + return; + } + } + } + +private: + CComboBox& m_rCombo; + T m_defaultValue; + T m_lastValue; +}; Index: src/ch/RuleEditAlreadyExistsDlg.cpp =================================================================== diff -u -rf8b6de9c28b2957db0b4e71efa11df8632e41261 -r3aa1103497018be2a7494e79e03c5f4c674485be --- src/ch/RuleEditAlreadyExistsDlg.cpp (.../RuleEditAlreadyExistsDlg.cpp) (revision f8b6de9c28b2957db0b4e71efa11df8632e41261) +++ src/ch/RuleEditAlreadyExistsDlg.cpp (.../RuleEditAlreadyExistsDlg.cpp) (revision 3aa1103497018be2a7494e79e03c5f4c674485be) @@ -1,21 +1,21 @@ -/*************************************************************************** -* Copyright (C) 2001-2020 by J�zef Starosczyk * -* ixen@copyhandler.com * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU Library General Public License * -* (version 2) as published by the Free Software Foundation; * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU Library General Public * -* License along with this program; if not, write to the * -* Free Software Foundation, Inc., * -* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * -***************************************************************************/ +// ============================================================================ +// Copyright (C) 2001-2020 by Jozef Starosczyk +// ixen {at} copyhandler [dot] com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ #include "stdafx.h" #include "ch.h" #include "RuleEditAlreadyExistsDlg.h" @@ -27,12 +27,17 @@ static char THIS_FILE[] = __FILE__; #endif +using namespace chengine; + ///////////////////////////////////////////////////////////////////////////// // FeedbackRuleEditorDlg dialog RuleEditAlreadyExistsDlg::RuleEditAlreadyExistsDlg(const chengine::FeedbackAlreadyExistsRule& rRule) : CLanguageDialog(IDD_RULE_EDIT_ALREADYEXISTS_DIALOG), - m_rule(rRule) + m_rule(rRule), + m_comboResponse(m_ctlResponse, eResult_Overwrite, eResult_Last), + m_comboDateCompare(m_ctlDateCompareType, eCmp_Equal, eCmp_Last), + m_comboSizeCompare(m_ctlSizeCompareType, eCmp_Equal, eCmp_Last) { } @@ -70,18 +75,11 @@ CLanguageDialog::OnInitDialog(); // fill the combos with data + FillCompareCombos(); + FillResponseCombo(); - // strings <, <=, ... - for(int iIndex = IDS_LT_STRING; iIndex <= IDS_DT_STRING; iIndex++) - { - const wchar_t* pszData = GetResManager().LoadString(iIndex); - m_ctlSizeCompareType.AddString(pszData); - m_ctlDateCompareType.AddString(pszData); - } - // copy data from TFileFilter to a dialog - mask m_bUseIncludeMask = m_rule.GetUseMask(); - m_ctlIncludeMask.SetCurSel(m_ctlIncludeMask.AddString(m_rule.GetCombinedMask().c_str())); for(int i = 0; i < m_astrAddMask.GetSize(); i++) { @@ -95,21 +93,15 @@ m_ctlExcludeMask.AddString(m_astrAddExcludeMask.GetAt(i)); } - // size + // size&date + m_bUseDateCompareType = m_rule.GetUseDateCompare(); + m_comboDateCompare.SelectComboResult(m_rule.GetDateCompareType()); m_bUseSizeCompareType = m_rule.GetUseSizeCompare(); - m_ctlSizeCompareType.SetCurSel(m_rule.GetSizeCompareType()); + m_comboSizeCompare.SelectComboResult(m_rule.GetSizeCompareType()); - // date - m_bUseDateCompareType = m_rule.GetUseDateCompare(); - m_ctlDateCompareType.SetCurSel(m_rule.GetDateCompareType()); - // response - for(int iIndex = IDS_FEEDBACK_RESPONSE_UNKNOWN; iIndex <= IDS_FEEDBACK_RESPONSE_RENAME; ++iIndex) - { - const wchar_t* pszData = GetResManager().LoadString(iIndex); - m_ctlResponse.AddString(pszData); - } - m_ctlResponse.SetCurSel(IDS_FEEDBACK_RESPONSE_OVERWRITE - IDS_FEEDBACK_RESPONSE_UNKNOWN); + EFeedbackResult eResult = m_rule.GetResult(); + m_comboResponse.SelectComboResult(eResult == eResult_Unknown ? eResult_Overwrite : eResult); UpdateData(FALSE); @@ -118,34 +110,57 @@ return TRUE; } -void RuleEditAlreadyExistsDlg::OnLanguageChanged() +void RuleEditAlreadyExistsDlg::FillCompareCombos() { - // selection - int iSizeCompareTypeIndex = m_ctlSizeCompareType.GetCurSel(); - int iDateCompareTypeIndex = m_ctlDateCompareType.GetCurSel(); - int iResponseIndex = m_ctlResponse.GetCurSel(); - m_ctlSizeCompareType.ResetContent(); m_ctlDateCompareType.ResetContent(); - m_ctlResponse.ResetContent(); - // strings <, <=, ... for(int iIndex = IDS_LT_STRING; iIndex <= IDS_DT_STRING; iIndex++) { const wchar_t* pszData = GetResManager().LoadString(iIndex); - m_ctlSizeCompareType.AddString(pszData); - m_ctlDateCompareType.AddString(pszData); + int iPos = m_ctlSizeCompareType.AddString(pszData); + m_ctlSizeCompareType.SetItemData(iPos, iIndex - IDS_LT_STRING); + + iPos = m_ctlDateCompareType.AddString(pszData); + m_ctlDateCompareType.SetItemData(iPos, iIndex - IDS_LT_STRING); } +} - for(int iIndex = IDS_FEEDBACK_RESPONSE_UNKNOWN; iIndex <= IDS_FEEDBACK_RESPONSE_RENAME; ++iIndex) +void RuleEditAlreadyExistsDlg::FillResponseCombo() +{ + m_ctlResponse.ResetContent(); + + std::vector vEntries = { + IDS_FEEDBACK_RESPONSE_OVERWRITE, + IDS_FEEDBACK_RESPONSE_RESUME, + IDS_FEEDBACK_RESPONSE_SKIP, + IDS_FEEDBACK_RESPONSE_CANCEL, + IDS_FEEDBACK_RESPONSE_PAUSE, + IDS_FEEDBACK_RESPONSE_RENAME + }; + for(int entry : vEntries) { - const wchar_t* pszData = GetResManager().LoadString(iIndex); - m_ctlResponse.AddString(pszData); + const wchar_t* pszData = GetResManager().LoadString(entry); + int iPos = m_ctlResponse.AddString(pszData); + m_ctlResponse.SetItemData(iPos, entry - IDS_FEEDBACK_RESPONSE_UNKNOWN); } +} - m_ctlSizeCompareType.SetCurSel(iSizeCompareTypeIndex); - m_ctlDateCompareType.SetCurSel(iDateCompareTypeIndex); - m_ctlResponse.SetCurSel(iResponseIndex); +void RuleEditAlreadyExistsDlg::OnLanguageChanged() +{ + // combo result + EFeedbackResult eResult = m_comboResponse.GetSelectedValue(); + FillResponseCombo(); + m_comboResponse.SelectComboResult(eResult); + + // size&date + ECompareType eSizeCmp = m_comboSizeCompare.GetSelectedValue(); + ECompareType eDateCmp = m_comboDateCompare.GetSelectedValue(); + + FillCompareCombos(); + + m_comboSizeCompare.SelectComboResult(eSizeCmp); + m_comboDateCompare.SelectComboResult(eDateCmp); } void RuleEditAlreadyExistsDlg::EnableControls() @@ -166,7 +181,6 @@ { UpdateData(TRUE); - // TFileFilter --> dialogu - mask CString strText; m_ctlIncludeMask.GetWindowText(strText); m_rule.SetUseMask(((m_bUseIncludeMask != 0) && !strText.IsEmpty())); @@ -178,14 +192,14 @@ // size m_rule.SetUseSizeCompare(m_bUseSizeCompareType != 0); - m_rule.SetSizeCompareType((chengine::ECompareType)m_ctlSizeCompareType.GetCurSel()); + m_rule.SetSizeCompareType(m_comboSizeCompare.GetSelectedValue()); // date m_rule.SetUseDateCompare(m_bUseDateCompareType != 0); - m_rule.SetDateCompareType((chengine::ECompareType)m_ctlDateCompareType.GetCurSel()); + m_rule.SetDateCompareType(m_comboDateCompare.GetSelectedValue()); // response - m_rule.SetResult((chengine::EFeedbackResult)m_ctlResponse.GetCurSel()); + m_rule.SetResult(m_comboResponse.GetSelectedValue()); CLanguageDialog::OnOK(); } Index: src/ch/RuleEditAlreadyExistsDlg.h =================================================================== diff -u -r1c585b955eb548cbedc7d36f1ea5af484206e7eb -r3aa1103497018be2a7494e79e03c5f4c674485be --- src/ch/RuleEditAlreadyExistsDlg.h (.../RuleEditAlreadyExistsDlg.h) (revision 1c585b955eb548cbedc7d36f1ea5af484206e7eb) +++ src/ch/RuleEditAlreadyExistsDlg.h (.../RuleEditAlreadyExistsDlg.h) (revision 3aa1103497018be2a7494e79e03c5f4c674485be) @@ -19,6 +19,7 @@ #pragma once #include "../libchengine/FeedbackAlreadyExistsRule.h" +#include "ComboDataWrapper.h" ///////////////////////////////////////////////////////////////////////////// // FeedbackRuleEditorDlg dialog @@ -36,6 +37,10 @@ void EnableControls(); BOOL OnInitDialog() override; + + void FillCompareCombos(); + void FillResponseCombo(); + void OnOK() override; void DoDataExchange(CDataExchange* pDX) override; @@ -57,4 +62,8 @@ CStringArray m_astrAddMask; CStringArray m_astrAddExcludeMask; + + ComboDataWrapper m_comboResponse; + ComboDataWrapper m_comboDateCompare; + ComboDataWrapper m_comboSizeCompare; }; Index: src/ch/RuleEditErrorDlg.cpp =================================================================== diff -u -rf8b6de9c28b2957db0b4e71efa11df8632e41261 -r3aa1103497018be2a7494e79e03c5f4c674485be --- src/ch/RuleEditErrorDlg.cpp (.../RuleEditErrorDlg.cpp) (revision f8b6de9c28b2957db0b4e71efa11df8632e41261) +++ src/ch/RuleEditErrorDlg.cpp (.../RuleEditErrorDlg.cpp) (revision 3aa1103497018be2a7494e79e03c5f4c674485be) @@ -1,21 +1,21 @@ -/*************************************************************************** -* Copyright (C) 2001-2020 by J�zef Starosczyk * -* ixen@copyhandler.com * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU Library General Public License * -* (version 2) as published by the Free Software Foundation; * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU Library General Public * -* License along with this program; if not, write to the * -* Free Software Foundation, Inc., * -* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * -***************************************************************************/ +// ============================================================================ +// Copyright (C) 2001-2020 by Jozef Starosczyk +// ixen {at} copyhandler [dot] com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ #include "stdafx.h" #include "ch.h" #include "RuleEditErrorDlg.h" @@ -27,12 +27,13 @@ static char THIS_FILE[] = __FILE__; #endif -///////////////////////////////////////////////////////////////////////////// -// FeedbackRuleEditorDlg dialog +using namespace chengine; RuleEditErrorDlg::RuleEditErrorDlg(const chengine::FeedbackErrorRule& rRule) : CLanguageDialog(IDD_RULE_EDIT_ERROR_DIALOG), - m_rule(rRule) + m_rule(rRule), + m_comboResponse(m_ctlResponse, eResult_Skip, eResult_Last), + m_comboOperationType(m_ctlOperationType, EFileError::eCheckForFreeSpace, EFileError::eOperation_Last) { } @@ -72,11 +73,8 @@ // fill the combos with data // strings <, <=, ... - for(int iIndex = IDS_OPERATION_DELETEERROR; iIndex <= IDS_OPERATION_RETRIEVEFILEINFO; iIndex++) - { - const wchar_t* pszData = GetResManager().LoadString(iIndex); - m_ctlOperationType.AddString(pszData); - } + FillOperationCombo(); + FillResponseCombo(); // copy data from TFileFilter to a dialog - mask m_bUseIncludeMask = m_rule.GetUseMask(); @@ -102,15 +100,11 @@ // date m_bUseOperationType = m_rule.GetUseErrorType(); - m_ctlOperationType.SetCurSel(m_rule.GetErrorType()); + m_comboOperationType.SelectComboResult(m_rule.GetErrorType()); - // response - for(int iIndex = IDS_FEEDBACK_RESPONSE_UNKNOWN; iIndex <= IDS_FEEDBACK_RESPONSE_RENAME; ++iIndex) - { - const wchar_t* pszData = GetResManager().LoadString(iIndex); - m_ctlResponse.AddString(pszData); - } - m_ctlResponse.SetCurSel(IDS_FEEDBACK_RESPONSE_SKIP - IDS_FEEDBACK_RESPONSE_UNKNOWN); + // result + EFeedbackResult eResult = m_rule.GetResult(); + m_comboResponse.SelectComboResult(eResult == eResult_Unknown ? eResult_Skip : eResult); UpdateData(FALSE); @@ -119,30 +113,47 @@ return TRUE; } -void RuleEditErrorDlg::OnLanguageChanged() +void RuleEditErrorDlg::FillOperationCombo() { - // selection - int iDateCompareTypeIndex = m_ctlOperationType.GetCurSel(); - int iResponseIndex = m_ctlResponse.GetCurSel(); - m_ctlOperationType.ResetContent(); - m_ctlResponse.ResetContent(); - // strings <, <=, ... for(int iIndex = IDS_OPERATION_DELETEERROR; iIndex <= IDS_OPERATION_RETRIEVEFILEINFO; iIndex++) { const wchar_t* pszData = GetResManager().LoadString(iIndex); - m_ctlOperationType.AddString(pszData); + int iPos = m_ctlOperationType.AddString(pszData); + m_ctlOperationType.SetItemData(iPos, iIndex - IDS_OPERATION_DELETEERROR); } +} - for(int iIndex = IDS_FEEDBACK_RESPONSE_UNKNOWN; iIndex <= IDS_FEEDBACK_RESPONSE_RENAME; ++iIndex) +void RuleEditErrorDlg::FillResponseCombo() +{ + m_ctlResponse.ResetContent(); + + std::vector vEntries = { + IDS_FEEDBACK_RESPONSE_SKIP, + IDS_FEEDBACK_RESPONSE_CANCEL, + IDS_FEEDBACK_RESPONSE_PAUSE, + IDS_FEEDBACK_RESPONSE_RETRY + }; + for(int entry : vEntries) { - const wchar_t* pszData = GetResManager().LoadString(iIndex); - m_ctlResponse.AddString(pszData); + const wchar_t* pszData = GetResManager().LoadString(entry); + int iPos = m_ctlResponse.AddString(pszData); + m_ctlResponse.SetItemData(iPos, entry - IDS_FEEDBACK_RESPONSE_UNKNOWN); } +} - m_ctlOperationType.SetCurSel(iDateCompareTypeIndex); - m_ctlResponse.SetCurSel(iResponseIndex); +void RuleEditErrorDlg::OnLanguageChanged() +{ + EFeedbackResult eResult = m_comboResponse.GetSelectedValue(); + FillResponseCombo(); + m_comboResponse.SelectComboResult(eResult); + + EFileError eOperation = m_comboOperationType.GetSelectedValue(); + + FillOperationCombo(); + + m_comboOperationType.SelectComboResult(eOperation); } void RuleEditErrorDlg::EnableControls() @@ -163,7 +174,6 @@ { UpdateData(TRUE); - // TFileFilter --> dialogu - mask CString strText; m_ctlIncludeMask.GetWindowText(strText); m_rule.SetUseMask(((m_bUseIncludeMask != 0) && !strText.IsEmpty())); @@ -183,10 +193,10 @@ // date m_rule.SetUseErrorType(m_bUseOperationType != 0); - m_rule.SetErrorType((chengine::EFileError)m_ctlOperationType.GetCurSel()); + m_rule.SetErrorType(m_comboOperationType.GetSelectedValue()); // response - m_rule.SetResult((chengine::EFeedbackResult)m_ctlResponse.GetCurSel()); + m_rule.SetResult(m_comboResponse.GetSelectedValue()); CLanguageDialog::OnOK(); } Index: src/ch/RuleEditErrorDlg.h =================================================================== diff -u -rf51cacae8d8461c98bbb4a498407d6aec8f94410 -r3aa1103497018be2a7494e79e03c5f4c674485be --- src/ch/RuleEditErrorDlg.h (.../RuleEditErrorDlg.h) (revision f51cacae8d8461c98bbb4a498407d6aec8f94410) +++ src/ch/RuleEditErrorDlg.h (.../RuleEditErrorDlg.h) (revision 3aa1103497018be2a7494e79e03c5f4c674485be) @@ -1,24 +1,25 @@ -/*************************************************************************** -* Copyright (C) 2001-2008 by J�zef Starosczyk * -* ixen@copyhandler.com * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU Library General Public License * -* (version 2) as published by the Free Software Foundation; * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU Library General Public * -* License along with this program; if not, write to the * -* Free Software Foundation, Inc., * -* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * -***************************************************************************/ +// ============================================================================ +// Copyright (C) 2001-2020 by Jozef Starosczyk +// ixen {at} copyhandler [dot] com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ #pragma once #include "../libchengine/FeedbackErrorRule.h" +#include "ComboDataWrapper.h" ///////////////////////////////////////////////////////////////////////////// // FeedbackRuleEditorDlg dialog @@ -36,6 +37,10 @@ void EnableControls(); BOOL OnInitDialog() override; + + void FillOperationCombo(); + + void FillResponseCombo(); void OnOK() override; void DoDataExchange(CDataExchange* pDX) override; @@ -57,4 +62,7 @@ CStringArray m_astrAddMask; CStringArray m_astrAddExcludeMask; + + ComboDataWrapper m_comboResponse; + ComboDataWrapper m_comboOperationType; }; Index: src/ch/RuleEditNotEnoughSpaceDlg.cpp =================================================================== diff -u -rf8b6de9c28b2957db0b4e71efa11df8632e41261 -r3aa1103497018be2a7494e79e03c5f4c674485be --- src/ch/RuleEditNotEnoughSpaceDlg.cpp (.../RuleEditNotEnoughSpaceDlg.cpp) (revision f8b6de9c28b2957db0b4e71efa11df8632e41261) +++ src/ch/RuleEditNotEnoughSpaceDlg.cpp (.../RuleEditNotEnoughSpaceDlg.cpp) (revision 3aa1103497018be2a7494e79e03c5f4c674485be) @@ -1,21 +1,21 @@ -/*************************************************************************** -* Copyright (C) 2001-2020 by J�zef Starosczyk * -* ixen@copyhandler.com * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU Library General Public License * -* (version 2) as published by the Free Software Foundation; * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU Library General Public * -* License along with this program; if not, write to the * -* Free Software Foundation, Inc., * -* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * -***************************************************************************/ +// ============================================================================ +// Copyright (C) 2001-2020 by Jozef Starosczyk +// ixen {at} copyhandler [dot] com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ #include "stdafx.h" #include "ch.h" #include "RuleEditNotEnoughSpaceDlg.h" @@ -27,12 +27,12 @@ static char THIS_FILE[] = __FILE__; #endif -///////////////////////////////////////////////////////////////////////////// -// FeedbackRuleEditorDlg dialog +using namespace chengine; RuleEditNotEnoughSpaceDlg::RuleEditNotEnoughSpaceDlg(const chengine::FeedbackNotEnoughSpaceRule& rRule) : CLanguageDialog(IDD_RULE_EDIT_NOTENOUGHSPACE_DIALOG), - m_rule(rRule) + m_rule(rRule), + m_comboResponse(m_ctlResponse, eResult_Ignore, eResult_Last) { } @@ -61,7 +61,8 @@ { CLanguageDialog::OnInitDialog(); - // copy data from TFileFilter to a dialog - mask + FillResponseCombo(); + m_bUseIncludeMask = m_rule.GetUseMask(); m_ctlIncludeMask.SetCurSel(m_ctlIncludeMask.AddString(m_rule.GetCombinedMask().c_str())); @@ -78,12 +79,8 @@ } // response - for(int iIndex = IDS_FEEDBACK_RESPONSE_UNKNOWN; iIndex <= IDS_FEEDBACK_RESPONSE_RENAME; ++iIndex) - { - const wchar_t* pszData = GetResManager().LoadString(iIndex); - m_ctlResponse.AddString(pszData); - } - m_ctlResponse.SetCurSel(IDS_FEEDBACK_RESPONSE_IGNORE - IDS_FEEDBACK_RESPONSE_UNKNOWN); + EFeedbackResult eResult = m_rule.GetResult(); + m_comboResponse.SelectComboResult(eResult == eResult_Unknown ? eResult_Ignore : eResult); UpdateData(FALSE); @@ -92,20 +89,30 @@ return TRUE; } -void RuleEditNotEnoughSpaceDlg::OnLanguageChanged() +void RuleEditNotEnoughSpaceDlg::FillResponseCombo() { - // selection - int iResponseIndex = m_ctlResponse.GetCurSel(); - m_ctlResponse.ResetContent(); - for(int iIndex = IDS_FEEDBACK_RESPONSE_UNKNOWN; iIndex <= IDS_FEEDBACK_RESPONSE_RENAME; ++iIndex) + std::vector vEntries = { + IDS_FEEDBACK_RESPONSE_CANCEL, + IDS_FEEDBACK_RESPONSE_PAUSE, + IDS_FEEDBACK_RESPONSE_RETRY, + IDS_FEEDBACK_RESPONSE_IGNORE + }; + for(int entry : vEntries) { - const wchar_t* pszData = GetResManager().LoadString(iIndex); - m_ctlResponse.AddString(pszData); + const wchar_t* pszData = GetResManager().LoadString(entry); + int iPos = m_ctlResponse.AddString(pszData); + m_ctlResponse.SetItemData(iPos, entry - IDS_FEEDBACK_RESPONSE_UNKNOWN); } +} - m_ctlResponse.SetCurSel(iResponseIndex); +void RuleEditNotEnoughSpaceDlg::OnLanguageChanged() +{ + // combo result + EFeedbackResult eResult = m_comboResponse.GetSelectedValue(); + FillResponseCombo(); + m_comboResponse.SelectComboResult(eResult); } void RuleEditNotEnoughSpaceDlg::EnableControls() @@ -130,7 +137,7 @@ m_rule.SetCombinedExcludeMask((PCTSTR)strText); // response - m_rule.SetResult((chengine::EFeedbackResult)m_ctlResponse.GetCurSel()); + m_rule.SetResult(m_comboResponse.GetSelectedValue()); CLanguageDialog::OnOK(); } Index: src/ch/RuleEditNotEnoughSpaceDlg.h =================================================================== diff -u -rf51cacae8d8461c98bbb4a498407d6aec8f94410 -r3aa1103497018be2a7494e79e03c5f4c674485be --- src/ch/RuleEditNotEnoughSpaceDlg.h (.../RuleEditNotEnoughSpaceDlg.h) (revision f51cacae8d8461c98bbb4a498407d6aec8f94410) +++ src/ch/RuleEditNotEnoughSpaceDlg.h (.../RuleEditNotEnoughSpaceDlg.h) (revision 3aa1103497018be2a7494e79e03c5f4c674485be) @@ -1,24 +1,25 @@ -/*************************************************************************** -* Copyright (C) 2001-2008 by J�zef Starosczyk * -* ixen@copyhandler.com * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU Library General Public License * -* (version 2) as published by the Free Software Foundation; * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU Library General Public * -* License along with this program; if not, write to the * -* Free Software Foundation, Inc., * -* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * -***************************************************************************/ +// ============================================================================ +// Copyright (C) 2001-2020 by Jozef Starosczyk +// ixen {at} copyhandler [dot] com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ #pragma once #include "../libchengine/FeedbackNotEnoughSpaceRule.h" +#include "ComboDataWrapper.h" ///////////////////////////////////////////////////////////////////////////// // FeedbackRuleEditorDlg dialog @@ -39,6 +40,8 @@ void OnOK() override; void DoDataExchange(CDataExchange* pDX) override; + void FillResponseCombo(); + DECLARE_MESSAGE_MAP() private: @@ -53,4 +56,6 @@ CStringArray m_astrAddMask; CStringArray m_astrAddExcludeMask; + + ComboDataWrapper m_comboResponse; }; Index: src/ch/ch.vc140.vcxproj =================================================================== diff -u -rf51cacae8d8461c98bbb4a498407d6aec8f94410 -r3aa1103497018be2a7494e79e03c5f4c674485be --- src/ch/ch.vc140.vcxproj (.../ch.vc140.vcxproj) (revision f51cacae8d8461c98bbb4a498407d6aec8f94410) +++ src/ch/ch.vc140.vcxproj (.../ch.vc140.vcxproj) (revision 3aa1103497018be2a7494e79e03c5f4c674485be) @@ -558,6 +558,7 @@ + Index: src/ch/ch.vc140.vcxproj.filters =================================================================== diff -u -rf51cacae8d8461c98bbb4a498407d6aec8f94410 -r3aa1103497018be2a7494e79e03c5f4c674485be --- src/ch/ch.vc140.vcxproj.filters (.../ch.vc140.vcxproj.filters) (revision f51cacae8d8461c98bbb4a498407d6aec8f94410) +++ src/ch/ch.vc140.vcxproj.filters (.../ch.vc140.vcxproj.filters) (revision 3aa1103497018be2a7494e79e03c5f4c674485be) @@ -61,6 +61,9 @@ {8c3e3738-a438-429e-8ad7-0dc13303f711} + + {706a4df6-9c2d-4ee9-aef5-b0ff6d19d94d} + @@ -267,6 +270,9 @@ Source Files\GUI\Dialogs\Feedback rule editor + + Source Files\GUI\Utils + Index: src/libchengine/ECompareType.h =================================================================== diff -u -r08717141ce5f6926116c298cbc9442094a45bb67 -r3aa1103497018be2a7494e79e03c5f4c674485be --- src/libchengine/ECompareType.h (.../ECompareType.h) (revision 08717141ce5f6926116c298cbc9442094a45bb67) +++ src/libchengine/ECompareType.h (.../ECompareType.h) (revision 3aa1103497018be2a7494e79e03c5f4c674485be) @@ -9,7 +9,9 @@ eCmp_Equal = 2, eCmp_GreaterOrEqual = 3, eCmp_Greater = 4, - eCmp_NotEqual = 5 + eCmp_NotEqual = 5, + + eCmp_Last }; template Index: src/libchengine/EFeedbackResult.h =================================================================== diff -u -r08717141ce5f6926116c298cbc9442094a45bb67 -r3aa1103497018be2a7494e79e03c5f4c674485be --- src/libchengine/EFeedbackResult.h (.../EFeedbackResult.h) (revision 08717141ce5f6926116c298cbc9442094a45bb67) +++ src/libchengine/EFeedbackResult.h (.../EFeedbackResult.h) (revision 3aa1103497018be2a7494e79e03c5f4c674485be) @@ -31,7 +31,9 @@ eResult_Pause, eResult_Retry, eResult_Ignore, - eResult_Rename + eResult_Rename, + + eResult_Last }; } Index: src/libchengine/EFileError.h =================================================================== diff -u -r08717141ce5f6926116c298cbc9442094a45bb67 -r3aa1103497018be2a7494e79e03c5f4c674485be --- src/libchengine/EFileError.h (.../EFileError.h) (revision 08717141ce5f6926116c298cbc9442094a45bb67) +++ src/libchengine/EFileError.h (.../EFileError.h) (revision 3aa1103497018be2a7494e79e03c5f4c674485be) @@ -1,23 +1,22 @@ -/*************************************************************************** -* Copyright (C) 2001-2015 by J�zef Starosczyk * -* ixen@copyhandler.com * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU Library General Public License * -* (version 2) as published by the Free Software Foundation; * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU Library General Public * -* License along with this program; if not, write to the * -* Free Software Foundation, Inc., * -* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * -***************************************************************************/ -#ifndef __EFILEERROR_H__ -#define __EFILEERROR_H__ +// ============================================================================ +// Copyright (C) 2001-2020 by Jozef Starosczyk +// ixen {at} copyhandler [dot] com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +#pragma once namespace chengine { @@ -32,8 +31,8 @@ eFastMoveError, ///< Problem occurred when tried to perform fast move operation (that does not involve copying contents) eCreateError, ///< Problem occurred when tried to create the fs object eCheckForFreeSpace, ///< Problem occurred when tried to create the fs object - eRetrieveFileInfo ///< Error while retrieving file information + eRetrieveFileInfo, ///< Error while retrieving file information + + eOperation_Last }; } - -#endif