@@ -15,6 +15,9 @@ static char BASED_CODE THIS_FILE[] = __FILE__;
15
15
// CGenPropertyPage property page
16
16
IMPLEMENT_DYNAMIC (CGenPropertyPage, CPropertyPage)
17
17
18
+ // ///////////////////////////////////////////////////////////////////////////
19
+ // Constructor
20
+
18
21
CGenPropertyPage::CGenPropertyPage(const UINT nID) :
19
22
CPropertyPage(nID)
20
23
{
@@ -31,7 +34,10 @@ CGenPropertyPage::CGenPropertyPage(const UINT nID) :
31
34
m_iColumnCount = 0 ;
32
35
m_bWantTreeControl = false ;
33
36
34
- }
37
+ } // end of CGenPropertyPage::CGenPropertyPage
38
+
39
+ // ///////////////////////////////////////////////////////////////////////////
40
+ // Destructor
35
41
36
42
CGenPropertyPage::~CGenPropertyPage ()
37
43
{
@@ -40,7 +46,7 @@ CGenPropertyPage::~CGenPropertyPage()
40
46
delete [] m_strColumnHeadings;
41
47
delete [] m_iColJust;
42
48
43
- }
49
+ } // end of CGenPropertyPage::~CGenPropertyPage
44
50
45
51
void CGenPropertyPage::DoDataExchange (CDataExchange* pDX)
46
52
{
@@ -62,6 +68,9 @@ END_MESSAGE_MAP()
62
68
// CGenPropertyPage message handlers
63
69
64
70
71
+ // ///////////////////////////////////////////////////////////////////////////
72
+ // OnAddItem
73
+
65
74
void CGenPropertyPage::SetUpPage (CString strObjectType,
66
75
CObjectMap * ObjectMap,
67
76
CListCtrl * ctlList,
@@ -81,8 +90,10 @@ void CGenPropertyPage::SetUpPage (CString strObjectType,
81
90
m_iMask = iMask;
82
91
m_bWantTreeControl = bWantTreeControl;
83
92
84
- }
93
+ } // end of CGenPropertyPage::SetUpPage
85
94
95
+ // ///////////////////////////////////////////////////////////////////////////
96
+ // GetSelectedItemCount
86
97
87
98
int CGenPropertyPage::GetSelectedItemCount () const
88
99
{
@@ -115,6 +126,39 @@ int CGenPropertyPage::GetSelectedItemCount () const
115
126
116
127
} // end of CGenPropertyPage::GetSelectedItemCount
117
128
129
+ // ///////////////////////////////////////////////////////////////////////////
130
+ // GetSelectedGroupCount
131
+
132
+ int CGenPropertyPage::GetSelectedGroupCount () const
133
+ {
134
+
135
+ int iCount = 0 ;
136
+
137
+ if (m_bWantTreeControl)
138
+ {
139
+
140
+ for (HTREEITEM hGroup = m_cTreeCtrl.GetRootItem ();
141
+ hGroup;
142
+ hGroup = m_cTreeCtrl.GetNextSiblingItem (hGroup))
143
+ {
144
+
145
+ if (m_cTreeCtrl.GetItemState (hGroup, TVIS_SELECTED) & TVIS_SELECTED)
146
+ {
147
+ for (HTREEITEM hItem = m_cTreeCtrl.GetChildItem (hGroup);
148
+ hItem;
149
+ hItem = m_cTreeCtrl.GetNextSiblingItem (hItem))
150
+ iCount++;
151
+ return iCount;
152
+ } // end of group selected
153
+ } // end for each group
154
+ } // end of tree control
155
+
156
+ return 0 ;
157
+ }
158
+
159
+ // ///////////////////////////////////////////////////////////////////////////
160
+ // GetItemCount
161
+
118
162
int CGenPropertyPage::GetItemCount () const
119
163
{
120
164
@@ -569,27 +613,29 @@ void CGenPropertyPage::OnDeleteItem()
569
613
{
570
614
571
615
int iCount = GetSelectedItemCount ();
616
+ int iGroupCount = GetSelectedGroupCount ();
617
+
572
618
int nItem,
573
619
i,
574
620
iIncluded = 0 ,
575
621
iExecuting = 0 ;
576
622
577
623
578
- if (iCount == 0 )
624
+ if (( iCount + iGroupCount) == 0 )
579
625
return ;
580
626
581
627
if (App.m_bTriggerRemoveCheck )
582
628
{
583
629
// mucking around to make it plural properly
584
630
CString sName = m_strObjectType;
585
- if (iCount > 1 )
631
+ if (( iCount + iGroupCount) > 1 )
586
632
if (sName == " alias" )
587
633
sName += " es" ;
588
634
else
589
635
sName += " s" ;
590
636
591
637
if (::UMessageBox (TFormat (" Delete %i %s - are you sure?" ,
592
- iCount, sName ), MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2)
638
+ iCount + iGroupCount , sName ), MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2)
593
639
!= IDYES )
594
640
return ;
595
641
} // end of wanting to confirm
@@ -603,31 +649,28 @@ int nItem,
603
649
hGroup;
604
650
hGroup = m_cTreeCtrl.GetNextSiblingItem (hGroup))
605
651
{
652
+ bool bGroupSelected = m_cTreeCtrl.GetItemState (hGroup, TVIS_SELECTED) & TVIS_SELECTED;
653
+
654
+ // remember which we deleted
655
+ list<HTREEITEM> deletedItems;
606
656
607
657
// find selected items
608
658
for (HTREEITEM hItem = m_cTreeCtrl.GetChildItem (hGroup);
609
659
hItem;
610
660
hItem = m_cTreeCtrl.GetNextSiblingItem (hItem))
611
- {
612
- UINT iState = m_cTreeCtrl.GetItemState (hItem, TVIS_SELECTED);
613
-
614
- if (iState & TVIS_SELECTED)
615
- {
616
- CString * pstrObjectName = (CString *) m_cTreeCtrl.GetItemData (hItem);
617
-
618
- if (!DeleteOneItem (pstrObjectName, iIncluded, iExecuting))
619
- {
620
- HTREEITEM hdlParent = m_cTreeCtrl.GetParentItem (hItem);
621
- m_cTreeCtrl.DeleteItem (hItem);
622
- CheckParentHasChildren (hdlParent);
623
- }
661
+ if (bGroupSelected || m_cTreeCtrl.GetItemState (hItem, TVIS_SELECTED) & TVIS_SELECTED)
662
+ if (!DeleteOneItem ((CString *) m_cTreeCtrl.GetItemData (hItem), iIncluded, iExecuting))
663
+ deletedItems.push_back (hItem);
624
664
625
- } // end if selected
665
+ // loop doesn't work if we delete while going through it, so do it now
666
+ for (list<HTREEITEM>::const_iterator it = deletedItems.begin ();
667
+ it != deletedItems.end ();
668
+ ++it)
669
+ m_cTreeCtrl.DeleteItem (*it);
626
670
627
- } // end for each item
671
+ CheckParentHasChildren (hGroup);
628
672
629
673
} // end for each group
630
-
631
674
} // end of tree control
632
675
else
633
676
// list control ................
@@ -1296,7 +1339,7 @@ BOOL CGenPropertyPage::OnInitDialog()
1296
1339
wndpl.rcNormalPosition .left = wndpl.rcNormalPosition .right - 100 ;
1297
1340
1298
1341
1299
- m_cUseTreeViewCtrl.Create (Translate (" Tree View " ),
1342
+ m_cUseTreeViewCtrl.Create (Translate (" Tree Vie&w " ),
1300
1343
BS_CHECKBOX | BS_AUTOCHECKBOX | BS_NOTIFY | WS_VISIBLE | WS_CHILD,
1301
1344
wndpl.rcNormalPosition ,
1302
1345
this ,
@@ -1471,22 +1514,25 @@ try
1471
1514
hGroup;
1472
1515
hGroup = m_cTreeCtrl.GetNextSiblingItem (hGroup))
1473
1516
{
1517
+ bool bGroupSelected = m_cTreeCtrl.GetItemState (hGroup, TVIS_SELECTED) & TVIS_SELECTED;
1518
+
1519
+ // remember which we deleted
1520
+ list<HTREEITEM> deletedItems;
1474
1521
1475
1522
for (HTREEITEM hItem = m_cTreeCtrl.GetChildItem (hGroup);
1476
1523
hItem;
1477
1524
hItem = m_cTreeCtrl.GetNextSiblingItem (hItem))
1478
- {
1479
- UINT iState = m_cTreeCtrl.GetItemState (hItem, TVIS_SELECTED);
1480
-
1481
- if (iState & TVIS_SELECTED)
1482
- {
1525
+ if (bGroupSelected || m_cTreeCtrl.GetItemState (hItem, TVIS_SELECTED) & TVIS_SELECTED)
1483
1526
if (CopyOneItem ((CString *) m_cTreeCtrl.GetItemData (hItem), ar))
1484
- {
1485
- m_cTreeCtrl.DeleteItem (hItem);
1486
- }
1487
- } // end if selected
1527
+ deletedItems.push_back (hItem); // not there any more
1488
1528
1489
- } // end for each item
1529
+ // loop doesn't work if we delete while going through it, so do it now
1530
+ for (list<HTREEITEM>::const_iterator it = deletedItems.begin ();
1531
+ it != deletedItems.end ();
1532
+ ++it)
1533
+ m_cTreeCtrl.DeleteItem (*it);
1534
+
1535
+ CheckParentHasChildren (hGroup);
1490
1536
1491
1537
} // end for each group
1492
1538
0 commit comments