Index: src/ch/RuleEditDlg.cpp =================================================================== diff -u -r2953244da57929fcf864b3b5da9a643979fd9b36 -r931355150221601949c1e8e3efc9e1621d337189 --- src/ch/RuleEditDlg.cpp (.../RuleEditDlg.cpp) (revision 2953244da57929fcf864b3b5da9a643979fd9b36) +++ src/ch/RuleEditDlg.cpp (.../RuleEditDlg.cpp) (revision 931355150221601949c1e8e3efc9e1621d337189) @@ -23,6 +23,8 @@ #include "RuleEditAlreadyExistsDlg.h" #include "RuleEditErrorDlg.h" #include "RuleEditNotEnoughSpaceDlg.h" +#include +#include #ifdef _DEBUG #define new DEBUG_NEW @@ -33,6 +35,74 @@ using namespace string; using namespace chengine; +namespace +{ + template + void OnUpButton(RuleEditDlg* pDlg, CListCtrl& ctlList, RuleList& ruleList, std::function reloadList) + { + POSITION pos = ctlList.GetFirstSelectedItemPosition(); + if(pos == nullptr) + return; + + int iItem = ctlList.GetNextSelectedItem(pos); + if(iItem < 1) + return; + + // store current item + auto rRule = ruleList.GetAt(iItem); + + // remove current item + ctlList.DeleteItem(iItem); + ruleList.RemoveAt(iItem); + + // re-insert it at the right position + ruleList.InsertAt(iItem - 1, rRule); + reloadList(pDlg); + + ctlList.SetItemState(iItem - 1, LVIS_SELECTED, LVIS_SELECTED); + } + + template + void OnDownButton(RuleEditDlg* pDlg, CListCtrl& ctlList, RuleList& ruleList, std::function reloadList) + { + POSITION pos = ctlList.GetFirstSelectedItemPosition(); + if(pos == nullptr) + return; + + int iItem = ctlList.GetNextSelectedItem(pos); + if(iItem < 0 || iItem + 1 >= ctlList.GetItemCount()) + return; + + // store current item + auto rRule = ruleList.GetAt(iItem); + + // remove current item + ctlList.DeleteItem(iItem); + ruleList.RemoveAt(iItem); + + // re-insert it at the right position + ruleList.InsertAt(iItem + 1, rRule); + reloadList(pDlg); + + ctlList.SetItemState(iItem + 1, LVIS_SELECTED, LVIS_SELECTED); + } + + template + void OnRemoveButton(CListCtrl& ctlList, RuleList& ruleList) + { + POSITION pos = ctlList.GetFirstSelectedItemPosition(); + if(pos == nullptr) + return; + + int iItem = ctlList.GetNextSelectedItem(pos); + if(iItem < 0) + return; + + ctlList.DeleteItem(iItem); + ruleList.RemoveAt(iItem); + } +} + RuleEditDlg::RuleEditDlg(const FeedbackRules& rRules) : ictranslate::CLanguageDialog(IDD_RULE_EDIT_ALL_DIALOG), m_rules(rRules) @@ -53,14 +123,20 @@ ON_BN_CLICKED(IDC_ALREADY_EXISTS_CHANGE_BUTTON, OnAlreadyExistsChangeButton) ON_BN_CLICKED(IDC_ALREADY_EXISTS_ADD_BUTTON, OnAlreadyExistsAddButton) ON_BN_CLICKED(IDC_ALREADY_EXISTS_REMOVE_BUTTON, OnAlreadyExistsRemoveButton) + ON_BN_CLICKED(IDC_ALREADY_EXISTS_UP_BUTTON, OnAlreadyExistsUpButton) + ON_BN_CLICKED(IDC_ALREADY_EXISTS_DOWN_BUTTON, OnAlreadyExistsDownButton) ON_BN_CLICKED(IDC_FILE_ERROR_CHANGE_BUTTON, OnErrorChangeButton) ON_BN_CLICKED(IDC_FILE_ERROR_ADD_BUTTON, OnErrorAddButton) ON_BN_CLICKED(IDC_FILE_ERROR_REMOVE_BUTTON, OnErrorRemoveButton) + ON_BN_CLICKED(IDC_FILE_ERROR_UP_BUTTON, OnErrorUpButton) + ON_BN_CLICKED(IDC_FILE_ERROR_DOWN_BUTTON, OnErrorDownButton) ON_BN_CLICKED(IDC_NOT_ENOUGH_SPACE_CHANGE_BUTTON, OnNotEnoughSpaceChangeButton) ON_BN_CLICKED(IDC_NOT_ENOUGH_SPACE_ADD_BUTTON, OnNotEnoughSpaceAddButton) ON_BN_CLICKED(IDC_NOT_ENOUGH_SPACE_REMOVE_BUTTON, OnNotEnoughSpaceRemoveButton) + ON_BN_CLICKED(IDC_NOT_ENOUGH_SPACE_UP_BUTTON, OnNotEnoughSpaceUpButton) + ON_BN_CLICKED(IDC_NOT_ENOUGH_SPACE_DOWN_BUTTON, OnNotEnoughSpaceDownButton) ON_NOTIFY(NM_DBLCLK, IDC_FILE_ALREADY_EXISTS_RULES_LIST, OnDblclkAlreadyExistsList) ON_NOTIFY(NM_DBLCLK, IDC_FILE_ERROR_RULES_LIST, OnDblclkErrorList) @@ -82,18 +158,24 @@ AddResizableControl(IDC_ALREADY_EXISTS_CHANGE_BUTTON, 1.0, 0.34, 0.0, 0.0); AddResizableControl(IDC_ALREADY_EXISTS_ADD_BUTTON, 1.0, 0.34, 0.0, 0.0); AddResizableControl(IDC_ALREADY_EXISTS_REMOVE_BUTTON, 1.0, 0.34, 0.0, 0.0); + AddResizableControl(IDC_ALREADY_EXISTS_UP_BUTTON, 0.0, 0.34, 0.0, 0.0); + AddResizableControl(IDC_ALREADY_EXISTS_DOWN_BUTTON, 0.0, 0.34, 0.0, 0.0); AddResizableControl(IDC_FILE_ERROR_RULES_STATIC, 0.0, 0.34, 1.0, 0.0); AddResizableControl(IDC_FILE_ERROR_RULES_LIST, 0.0, 0.34, 1.0, 0.33); AddResizableControl(IDC_FILE_ERROR_CHANGE_BUTTON, 1.0, 0.67, 0.0, 0.0); AddResizableControl(IDC_FILE_ERROR_ADD_BUTTON, 1.0, 0.67, 0.0, 0.0); AddResizableControl(IDC_FILE_ERROR_REMOVE_BUTTON, 1.0, 0.67, 0.0, 0.0); + AddResizableControl(IDC_FILE_ERROR_UP_BUTTON, 0.0, 0.67, 0.0, 0.0); + AddResizableControl(IDC_FILE_ERROR_DOWN_BUTTON, 0.0, 0.67, 0.0, 0.0); AddResizableControl(IDC_NOT_ENOUGH_SPACE_STATIC, 0.0, 0.67, 1.0, 0.0); AddResizableControl(IDC_NOT_ENOUGH_SPACE_RULES_LIST, 0.0, 0.67, 1.0, 0.33); AddResizableControl(IDC_NOT_ENOUGH_SPACE_CHANGE_BUTTON, 1.0, 1.0, 0.0, 0.0); AddResizableControl(IDC_NOT_ENOUGH_SPACE_ADD_BUTTON, 1.0, 1.0, 0.0, 0.0); AddResizableControl(IDC_NOT_ENOUGH_SPACE_REMOVE_BUTTON, 1.0, 1.0, 0.0, 0.0); + AddResizableControl(IDC_NOT_ENOUGH_SPACE_UP_BUTTON, 0.0, 1.0, 0.0, 0.0); + AddResizableControl(IDC_NOT_ENOUGH_SPACE_DOWN_BUTTON, 0.0, 1.0, 0.0, 0.0); AddResizableControl(IDOK, 1.0, 1.0, 0.0, 0.0); AddResizableControl(IDCANCEL, 1.0, 1.0, 0.0, 0.0); @@ -112,6 +194,10 @@ InitErrorColumns(); InitNotEnoughSpaceColumns(); + FillAlreadyExistsList(); + FillErrorList(); + FillNotEnoughSpaceList(); + UpdateData(FALSE); return TRUE; @@ -564,21 +650,17 @@ void RuleEditDlg::OnAlreadyExistsRemoveButton() { - FeedbackAlreadyExistsRuleList& rRules = m_rules.GetAlreadyExistsRules(); + OnRemoveButton(m_ctlAlreadyExistsRulesList, m_rules.GetAlreadyExistsRules()); +} - while(true) - { - POSITION pos = m_ctlAlreadyExistsRulesList.GetFirstSelectedItemPosition(); - if(pos == nullptr) - break; +void RuleEditDlg::OnAlreadyExistsUpButton() +{ + OnUpButton(this, m_ctlAlreadyExistsRulesList, m_rules.GetAlreadyExistsRules(), &RuleEditDlg::FillAlreadyExistsList); +} - int iItem = m_ctlAlreadyExistsRulesList.GetNextSelectedItem(pos); - if(iItem < 0) - return; - - m_ctlAlreadyExistsRulesList.DeleteItem(iItem); - rRules.RemoveAt(iItem); - } +void RuleEditDlg::OnAlreadyExistsDownButton() +{ + OnDownButton(this, m_ctlAlreadyExistsRulesList, m_rules.GetAlreadyExistsRules(), &RuleEditDlg::FillAlreadyExistsList); } void RuleEditDlg::OnDblclkErrorList(NMHDR* /*pNMHDR*/, LRESULT* pResult) @@ -627,21 +709,17 @@ void RuleEditDlg::OnErrorRemoveButton() { - FeedbackErrorRuleList& rRules = m_rules.GetErrorRules(); + OnRemoveButton(m_ctlErrorRulesList, m_rules.GetErrorRules()); +} - while(true) - { - POSITION pos = m_ctlErrorRulesList.GetFirstSelectedItemPosition(); - if(pos == nullptr) - break; +void RuleEditDlg::OnErrorUpButton() +{ + OnUpButton(this, m_ctlErrorRulesList, m_rules.GetErrorRules(), &RuleEditDlg::FillErrorList); +} - int iItem = m_ctlErrorRulesList.GetNextSelectedItem(pos); - if(iItem < 0) - return; - - m_ctlErrorRulesList.DeleteItem(iItem); - rRules.RemoveAt(iItem); - } +void RuleEditDlg::OnErrorDownButton() +{ + OnDownButton(this, m_ctlErrorRulesList, m_rules.GetErrorRules(), &RuleEditDlg::FillErrorList); } void RuleEditDlg::OnDblclkNotEnoughSpaceList(NMHDR* /*pNMHDR*/, LRESULT* pResult) @@ -690,19 +768,15 @@ void RuleEditDlg::OnNotEnoughSpaceRemoveButton() { - FeedbackNotEnoughSpaceRuleList& rRules = m_rules.GetNotEnoughSpaceRules(); + OnRemoveButton(m_ctlNotEnoughSpaceRulesList, m_rules.GetNotEnoughSpaceRules()); +} - while(true) - { - POSITION pos = m_ctlNotEnoughSpaceRulesList.GetFirstSelectedItemPosition(); - if(pos == nullptr) - break; +void RuleEditDlg::OnNotEnoughSpaceUpButton() +{ + OnUpButton(this, m_ctlNotEnoughSpaceRulesList, m_rules.GetNotEnoughSpaceRules(), &RuleEditDlg::FillNotEnoughSpaceList); +} - int iItem = m_ctlNotEnoughSpaceRulesList.GetNextSelectedItem(pos); - if(iItem < 0) - return; - - m_ctlNotEnoughSpaceRulesList.DeleteItem(iItem); - rRules.RemoveAt(iItem); - } +void RuleEditDlg::OnNotEnoughSpaceDownButton() +{ + OnDownButton(this, m_ctlNotEnoughSpaceRulesList, m_rules.GetNotEnoughSpaceRules(), &RuleEditDlg::FillNotEnoughSpaceList); } Index: src/ch/RuleEditDlg.h =================================================================== diff -u -re6f64ea0eecaf86dfa1a42c80604d227b69be768 -r931355150221601949c1e8e3efc9e1621d337189 --- src/ch/RuleEditDlg.h (.../RuleEditDlg.h) (revision e6f64ea0eecaf86dfa1a42c80604d227b69be768) +++ src/ch/RuleEditDlg.h (.../RuleEditDlg.h) (revision 931355150221601949c1e8e3efc9e1621d337189) @@ -1,21 +1,21 @@ -/*************************************************************************** -* 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 "CDragDropListCtrl.h" @@ -34,7 +34,7 @@ chengine::FeedbackRules GetRules() const { return m_rules; } protected: - void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support + void DoDataExchange(CDataExchange* pDX) override; void OnLanguageChanged() override; @@ -59,16 +59,22 @@ afx_msg void OnAlreadyExistsChangeButton(); afx_msg void OnAlreadyExistsAddButton(); afx_msg void OnAlreadyExistsRemoveButton(); + afx_msg void OnAlreadyExistsUpButton(); + afx_msg void OnAlreadyExistsDownButton(); afx_msg void OnDblclkErrorList(NMHDR* pNMHDR, LRESULT* pResult); afx_msg void OnErrorChangeButton(); afx_msg void OnErrorAddButton(); afx_msg void OnErrorRemoveButton(); + afx_msg void OnErrorUpButton(); + afx_msg void OnErrorDownButton(); afx_msg void OnDblclkNotEnoughSpaceList(NMHDR* pNMHDR, LRESULT* pResult); afx_msg void OnNotEnoughSpaceChangeButton(); afx_msg void OnNotEnoughSpaceAddButton(); afx_msg void OnNotEnoughSpaceRemoveButton(); + afx_msg void OnNotEnoughSpaceUpButton(); + afx_msg void OnNotEnoughSpaceDownButton(); DECLARE_MESSAGE_MAP() Index: src/ch/ch.rc =================================================================== diff -u -ref2f46d0fc21e0006c7d11b12f94049f4546476e -r931355150221601949c1e8e3efc9e1621d337189 --- src/ch/ch.rc (.../ch.rc) (revision ef2f46d0fc21e0006c7d11b12f94049f4546476e) +++ src/ch/ch.rc (.../ch.rc) (revision 931355150221601949c1e8e3efc9e1621d337189) @@ -514,24 +514,30 @@ CAPTION "Feedback rules editor" FONT 8, "Tahoma", 0, 0, 0x1 BEGIN - CONTROL "List2",IDC_FILE_ALREADY_EXISTS_RULES_LIST,"SysListView32",LVS_REPORT | WS_BORDER | WS_TABSTOP,7,18,337,65 - PUSHBUTTON "&OK",IDOK,239,320,50,14 - PUSHBUTTON "&Cancel",IDCANCEL,294,320,50,14 - CONTROL "",IDC_BOTTOM_BAR_STATIC,"Static",SS_ETCHEDHORZ,8,313,336,1 + CONTROL "",IDC_FILE_ALREADY_EXISTS_RULES_LIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | WS_BORDER | WS_TABSTOP,7,18,337,65 + PUSHBUTTON "Move up",IDC_ALREADY_EXISTS_UP_BUTTON,7,87,50,14 + PUSHBUTTON "Move down",IDC_ALREADY_EXISTS_DOWN_BUTTON,62,87,50,14 PUSHBUTTON "Change...",IDC_ALREADY_EXISTS_CHANGE_BUTTON,184,87,50,14 - PUSHBUTTON "Remove",IDC_ALREADY_EXISTS_REMOVE_BUTTON,294,87,50,14 - LTEXT "File already exists rules:",IDC_FILE_ALREADY_EXISTS_STATIC,7,7,337,8 - CONTROL "",IDC_FILE_ERROR_RULES_LIST,"SysListView32",LVS_REPORT | WS_BORDER | WS_TABSTOP,7,119,337,65 - LTEXT "File error rules:",IDC_FILE_ERROR_RULES_STATIC,7,108,337,8 - CONTROL "",IDC_NOT_ENOUGH_SPACE_RULES_LIST,"SysListView32",LVS_REPORT | WS_BORDER | WS_TABSTOP,7,223,337,65 - LTEXT "Not enough space rules:",IDC_NOT_ENOUGH_SPACE_STATIC,7,212,337,8 PUSHBUTTON "Add...",IDC_ALREADY_EXISTS_ADD_BUTTON,239,87,50,14 + PUSHBUTTON "Remove",IDC_ALREADY_EXISTS_REMOVE_BUTTON,294,87,50,14 + CONTROL "",IDC_FILE_ERROR_RULES_LIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | WS_BORDER | WS_TABSTOP,7,119,337,65 + PUSHBUTTON "Move up",IDC_FILE_ERROR_UP_BUTTON,7,188,50,14 + PUSHBUTTON "Move down",IDC_FILE_ERROR_DOWN_BUTTON,62,188,50,14 PUSHBUTTON "Change...",IDC_FILE_ERROR_CHANGE_BUTTON,184,188,50,14 - PUSHBUTTON "Remove",IDC_FILE_ERROR_REMOVE_BUTTON,294,188,50,14 PUSHBUTTON "Add...",IDC_FILE_ERROR_ADD_BUTTON,239,188,50,14 + PUSHBUTTON "Remove",IDC_FILE_ERROR_REMOVE_BUTTON,294,188,50,14 + CONTROL "",IDC_NOT_ENOUGH_SPACE_RULES_LIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | WS_BORDER | WS_TABSTOP,7,223,337,65 + PUSHBUTTON "Move up",IDC_NOT_ENOUGH_SPACE_UP_BUTTON,7,292,50,14 + PUSHBUTTON "Move down",IDC_NOT_ENOUGH_SPACE_DOWN_BUTTON,62,292,50,14 PUSHBUTTON "Change...",IDC_NOT_ENOUGH_SPACE_CHANGE_BUTTON,184,292,50,14 - PUSHBUTTON "Remove",IDC_NOT_ENOUGH_SPACE_REMOVE_BUTTON,294,292,50,14 PUSHBUTTON "Add...",IDC_NOT_ENOUGH_SPACE_ADD_BUTTON,239,292,50,14 + PUSHBUTTON "Remove",IDC_NOT_ENOUGH_SPACE_REMOVE_BUTTON,294,292,50,14 + PUSHBUTTON "&OK",IDOK,239,320,50,14 + PUSHBUTTON "&Cancel",IDCANCEL,294,320,50,14 + CONTROL "",IDC_BOTTOM_BAR_STATIC,"Static",SS_ETCHEDHORZ,8,313,336,1 + LTEXT "File already exists rules:",IDC_FILE_ALREADY_EXISTS_STATIC,7,7,337,8 + LTEXT "File error rules:",IDC_FILE_ERROR_RULES_STATIC,7,108,337,8 + LTEXT "Not enough space rules:",IDC_NOT_ENOUGH_SPACE_STATIC,7,212,337,8 END Index: src/ch/resource.h =================================================================== diff -u -ref2f46d0fc21e0006c7d11b12f94049f4546476e -r931355150221601949c1e8e3efc9e1621d337189 --- src/ch/resource.h (.../resource.h) (revision ef2f46d0fc21e0006c7d11b12f94049f4546476e) +++ src/ch/resource.h (.../resource.h) (revision 931355150221601949c1e8e3efc9e1621d337189) @@ -429,11 +429,18 @@ #define IDC_NOT_ENOUGH_SPACE_ADD_BUTTON 1400 #define IDC_BOTTOM_BAR_STATIC 1401 #define IDC_INCLUDE_MASK_CHECK 1402 +#define IDC_ALREADY_EXISTS_UP_BUTTON 1402 #define IDC_INCLUDE_MASK_COMBO 1403 +#define IDC_ALREADY_EXISTS_DOWN_BUTTON 1403 #define IDC_EXCLUDE_MASK_CHECK 1404 +#define IDC_FILE_ERROR_UP_BUTTON 1404 #define IDC_EXCLUDE_MASK_COMBO 1405 +#define IDC_FILE_ERROR_DOWN_BUTTON 1405 #define IDC_FILTER_BY_SIZE_CHECK 1406 +#define IDC_NOT_ENOUGH_SPACE_UP_BUTTON 1406 #define IDC_FILTER_BY_SIZE_COMBO 1407 +#define IDC_FILE_ERROR_DOWN_BUTTON2 1407 +#define IDC_NOT_ENOUGH_SPACE_DOWN_BUTTON 1407 #define IDC_FILTER_BY_DATE_CHECK 1408 #define IDC_FILTER_BY_DATE_COMBO 1409 #define IDC_RESPONSE_STATIC 1410