Clone
ixen
committed
on 12 Nov 20
Added basic implementation of two remaining rule edit editors.
src/ch/RuleEditDlg.cpp (+5 -12)
4 4 *                                                                         *
5 5 *   This program is free software; you can redistribute it and/or modify  *
6 6 *   it under the terms of the GNU Library General Public License          *
7 7 *   (version 2) as published by the Free Software Foundation;             *
8 8 *                                                                         *
9 9 *   This program is distributed in the hope that it will be useful,       *
10 10 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
11 11 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
12 12 *   GNU General Public License for more details.                          *
13 13 *                                                                         *
14 14 *   You should have received a copy of the GNU Library General Public     *
15 15 *   License along with this program; if not, write to the                 *
16 16 *   Free Software Foundation, Inc.,                                       *
17 17 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
18 18 ***************************************************************************/
19 19 #include "stdafx.h"
20 20 #include "resource.h"
21 21 #include "RuleEditDlg.h"
22 22 #include "ch.h"
23 23 #include "RuleEditAlreadyExistsDlg.h"
  24 #include "RuleEditErrorDlg.h"
  25 #include "RuleEditNotEnoughSpaceDlg.h"
24 26
25 27 #ifdef _DEBUG
26 28 #define new DEBUG_NEW
27 29 #undef THIS_FILE
28 30 static char THIS_FILE[] = __FILE__;
29 31 #endif
30 32
31 33 using namespace string;
32 34 using namespace chengine;
33 35
34 36 RuleEditDlg::RuleEditDlg(const FeedbackRules& rRules) :
35 37         ictranslate::CLanguageDialog(IDD_RULE_EDIT_ALL_DIALOG),
36 38         m_rules(rRules)
37 39 {
38 40 }
39 41
40 42 void RuleEditDlg::DoDataExchange(CDataExchange* pDX)
41 43 {
42 44         CLanguageDialog::DoDataExchange(pDX);
43 45
 
577 579 }
578 580
579 581 void RuleEditDlg::OnDblclkErrorList(NMHDR* /*pNMHDR*/, LRESULT* pResult)
580 582 {
581 583         OnErrorChangeButton();
582 584         *pResult = 0;
583 585 }
584 586
585 587 void RuleEditDlg::OnErrorChangeButton()
586 588 {
587 589         POSITION pos = m_ctlErrorRulesList.GetFirstSelectedItemPosition();
588 590         if(pos != nullptr)
589 591         {
590 592                 FeedbackErrorRuleList& rRules = m_rules.GetErrorRules();
591 593
592 594                 int iItem = m_ctlErrorRulesList.GetNextSelectedItem(pos);
593 595                 if(iItem < 0)
594 596                         return;
595 597
596 598                 auto& rRule = rRules.GetAt(iItem);
597                   rRule;
598 599
599   /*
600 600                 RuleEditErrorDlg dlg(rRule);
601 601                 if(dlg.DoModal() == IDOK)
602 602                 {
603 603                         // delete old element
604 604                         m_ctlErrorRulesList.DeleteItem(iItem);
605 605
606 606                         rRule = dlg.GetRule();
607 607                         AddErrorRule(rRule, iItem);
608 608                 }
609   */
610 609         }
611 610 }
612 611
613 612 void RuleEditDlg::OnErrorAddButton()
614 613 {
615 614         FeedbackErrorRule newRule;
616 615
617   /*
618 616         RuleEditErrorDlg dlg(newRule);
619 617         if(dlg.DoModal() == IDOK)
620 618         {
621 619                 const auto& rRule = dlg.GetRule();
622 620                 m_rules.GetErrorRules().Add(rRule);
623 621                 AddErrorRule(rRule, -1);
624 622         }
625   */
626 623 }
627 624
628 625 void RuleEditDlg::OnErrorRemoveButton()
629 626 {
630 627         FeedbackErrorRuleList& rRules = m_rules.GetErrorRules();
631 628
632 629         while(true)
633 630         {
634 631                 POSITION pos = m_ctlErrorRulesList.GetFirstSelectedItemPosition();
635 632                 if(pos == nullptr)
636 633                         break;
637 634
638 635                 int iItem = m_ctlErrorRulesList.GetNextSelectedItem(pos);
639 636                 if(iItem < 0)
640 637                         return;
641 638
642 639                 m_ctlErrorRulesList.DeleteItem(iItem);
643 640                 rRules.RemoveAt(iItem);
644 641         }
645 642 }
646 643
647 644 void RuleEditDlg::OnDblclkNotEnoughSpaceList(NMHDR* /*pNMHDR*/, LRESULT* pResult)
648 645 {
649 646         OnNotEnoughSpaceChangeButton();
650 647         *pResult = 0;
651 648 }
652 649
653 650 void RuleEditDlg::OnNotEnoughSpaceChangeButton()
654 651 {
655 652         POSITION pos = m_ctlNotEnoughSpaceRulesList.GetFirstSelectedItemPosition();
656 653         if(pos != nullptr)
657 654         {
658                   FeedbackErrorRuleList& rRules = m_rules.GetErrorRules();
  655                 FeedbackNotEnoughSpaceRuleList& rRules = m_rules.GetNotEnoughSpaceRules();
659 656
660 657                 int iItem = m_ctlNotEnoughSpaceRulesList.GetNextSelectedItem(pos);
661 658                 if(iItem < 0)
662 659                         return;
663 660
664 661                 auto& rRule = rRules.GetAt(iItem);
665                   rRule;
666   /*
  662
667 663                 RuleEditNotEnoughSpaceDlg dlg(rRule);
668 664                 if(dlg.DoModal() == IDOK)
669 665                 {
670 666                         // delete old element
671 667                         m_ctlNotEnoughSpaceRulesList.DeleteItem(iItem);
672 668
673 669                         rRule = dlg.GetRule();
674 670                         AddNotEnoughSpaceRule(rRule, iItem);
675 671                 }
676   */
677 672         }
678 673 }
679 674
680 675 void RuleEditDlg::OnNotEnoughSpaceAddButton()
681 676 {
682           FeedbackErrorRule newRule;
  677         FeedbackNotEnoughSpaceRule newRule;
683 678
684   /*
685 679         RuleEditNotEnoughSpaceDlg dlg(newRule);
686 680         if(dlg.DoModal() == IDOK)
687 681         {
688 682                 const auto& rRule = dlg.GetRule();
689 683                 m_rules.GetNotEnoughSpaceRules().Add(rRule);
690 684                 AddNotEnoughSpaceRule(rRule, -1);
691 685         }
692   */
693 686 }
694 687
695 688 void RuleEditDlg::OnNotEnoughSpaceRemoveButton()
696 689 {
697 690         FeedbackNotEnoughSpaceRuleList& rRules = m_rules.GetNotEnoughSpaceRules();
698 691
699 692         while(true)
700 693         {
701 694                 POSITION pos = m_ctlNotEnoughSpaceRulesList.GetFirstSelectedItemPosition();
702 695                 if(pos == nullptr)
703 696                         break;
704 697
705 698                 int iItem = m_ctlNotEnoughSpaceRulesList.GetNextSelectedItem(pos);
706 699                 if(iItem < 0)
707 700                         return;
708 701
709 702                 m_ctlNotEnoughSpaceRulesList.DeleteItem(iItem);
710 703                 rRules.RemoveAt(iItem);
711 704         }
712 705 }