SynchronizeChecklist.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. //----------------------------------------------------------------------------
  2. #ifndef SynchronizeChecklistH
  3. #define SynchronizeChecklistH
  4. //----------------------------------------------------------------------------
  5. #include "IEListView.hpp"
  6. #include "NortonLikeListView.hpp"
  7. #include <System.Classes.hpp>
  8. #include <Vcl.ComCtrls.hpp>
  9. #include <Vcl.Controls.hpp>
  10. #include <Vcl.ExtCtrls.hpp>
  11. #include <Vcl.ImgList.hpp>
  12. #include <Vcl.Menus.hpp>
  13. #include <Vcl.StdCtrls.hpp>
  14. #include "PngImageList.hpp"
  15. //----------------------------------------------------------------------------
  16. #include <Terminal.h>
  17. #include <System.Actions.hpp>
  18. #include <Vcl.ActnList.hpp>
  19. //----------------------------------------------------------------------------
  20. class TSynchronizeChecklistDialog : public TForm
  21. {
  22. __published:
  23. TPanel * Panel;
  24. TIEListView *ListView;
  25. TStatusBar *StatusBar;
  26. TPngImageList *ActionImages;
  27. TButton *OkButton;
  28. TButton *CancelButton;
  29. TButton *CheckAllButton;
  30. TButton *UncheckAllButton;
  31. TButton *CheckButton;
  32. TButton *UncheckButton;
  33. TPopupMenu *ListViewPopupMenu;
  34. TMenuItem *CheckItem;
  35. TMenuItem *UncheckItem;
  36. TMenuItem *N1;
  37. TMenuItem *SelectAllItem;
  38. TTimer *UpdateTimer;
  39. TButton *HelpButton;
  40. TButton *CustomCommandsButton2;
  41. TActionList *ActionList;
  42. TAction *CheckAction;
  43. TAction *UncheckAction;
  44. TAction *CheckAllAction;
  45. TAction *UncheckAllAction;
  46. TAction *SelectAllAction;
  47. TAction *CustomCommandsAction;
  48. TMenuItem *N2;
  49. TButton *ReverseButton;
  50. TAction *ReverseAction;
  51. TMenuItem *ReverseItem;
  52. TPngImageList *ActionImages120;
  53. TPngImageList *ActionImages144;
  54. TPngImageList *ActionImages192;
  55. TAction *CalculateSizeAction;
  56. TMenuItem *Calculate1;
  57. TButton *CalculateSizeButton;
  58. void __fastcall HelpButtonClick(TObject * Sender);
  59. void __fastcall FormShow(TObject * Sender);
  60. void __fastcall StatusBarDrawPanel(TStatusBar *StatusBar,
  61. TStatusPanel *Panel, const TRect &Rect);
  62. void __fastcall StatusBarMouseMove(TObject *Sender, TShiftState Shift,
  63. int X, int Y);
  64. void __fastcall ListViewChange(TObject *Sender, TListItem *Item,
  65. TItemChange Change);
  66. void __fastcall ListViewChanging(TObject *Sender, TListItem *Item,
  67. TItemChange Change, bool &AllowChange);
  68. void __fastcall CheckAllActionExecute(TObject *Sender);
  69. void __fastcall CheckActionExecute(TObject *Sender);
  70. void __fastcall ListViewSelectItem(TObject *Sender, TListItem *Item,
  71. bool Selected);
  72. void __fastcall UpdateTimerTimer(TObject *Sender);
  73. void __fastcall SelectAllActionExecute(TObject *Sender);
  74. void __fastcall StatusBarMouseDown(TObject *Sender, TMouseButton Button,
  75. TShiftState Shift, int X, int Y);
  76. void __fastcall ListViewCompare(TObject *Sender, TListItem *Item1,
  77. TListItem *Item2, int Data, int &Compare);
  78. void __fastcall ListViewSecondaryColumnHeader(TCustomIEListView *Sender,
  79. int Index, int &SecondaryColumn);
  80. void __fastcall ListViewContextPopup(TObject *Sender, TPoint &MousePos,
  81. bool &Handled);
  82. void __fastcall CustomCommandsActionExecute(TObject *Sender);
  83. void __fastcall ListViewAdvancedCustomDrawSubItem(TCustomListView *Sender, TListItem *Item,
  84. int SubItem, TCustomDrawState State, TCustomDrawStage Stage, bool &DefaultDraw);
  85. void __fastcall StatusBarResize(TObject *Sender);
  86. void __fastcall UncheckActionExecute(TObject *Sender);
  87. void __fastcall UncheckAllActionExecute(TObject *Sender);
  88. void __fastcall ReverseActionExecute(TObject *Sender);
  89. void __fastcall ListViewClick(TObject *Sender);
  90. void __fastcall OkButtonClick(TObject *Sender);
  91. void __fastcall CalculateSizeActionExecute(TObject *Sender);
  92. public:
  93. __fastcall TSynchronizeChecklistDialog(
  94. TComponent * AOwner, TSynchronizeMode Mode, int Params,
  95. const UnicodeString & LocalDirectory, const UnicodeString & RemoteDirectory,
  96. TCustomCommandMenuEvent OnCustomCommandMenu, TFullSynchronizeEvent OnSynchronize,
  97. TSynchronizeChecklistCalculateSize OnSynchronizeChecklistCalculateSize, void * Token);
  98. virtual __fastcall ~TSynchronizeChecklistDialog();
  99. bool __fastcall Execute(TSynchronizeChecklist * Checklist);
  100. protected:
  101. bool FFormRestored;
  102. TSynchronizeChecklist * FChecklist;
  103. TSynchronizeMode FMode;
  104. int FParams;
  105. UnicodeString FLocalDirectory;
  106. UnicodeString FRemoteDirectory;
  107. TWndMethod FOrigListViewWindowProc;
  108. int FTotals[1 + TSynchronizeChecklist::ActionCount];
  109. int FChecked[1 + TSynchronizeChecklist::ActionCount];
  110. __int64 FCheckedSize[1 + TSynchronizeChecklist::ActionCount];
  111. TListItem * FChangingItem;
  112. bool FChangingItemChecked;
  113. bool FChangingItemIgnore;
  114. bool FChangingItemMass;
  115. UnicodeString FGeneralHint;
  116. TCustomCommandMenuEvent FOnCustomCommandMenu;
  117. TSynchronizeChecklistCalculateSize FOnSynchronizeChecklistCalculateSize;
  118. typedef std::map<const TSynchronizeChecklist::TItem *, TSynchronizeChecklist::TAction> TActions;
  119. TActions FActions;
  120. TFullSynchronizeEvent FOnSynchronize;
  121. void * FToken;
  122. bool FSynchronizing;
  123. std::unique_ptr<Exception> FException;
  124. std::map<const TSynchronizeChecklist::TItem *, TListItem *> FChecklistToListViewMap;
  125. void __fastcall UpdateControls();
  126. virtual void __fastcall CreateParams(TCreateParams & Params);
  127. void __fastcall LoadItem(TListItem * Item);
  128. void __fastcall LoadList();
  129. void __fastcall ListViewWindowProc(TMessage & Message);
  130. int __fastcall PanelAt(int X);
  131. void __fastcall CheckAll(bool Check);
  132. void __fastcall Check(bool Check);
  133. TListItem * __fastcall SelectAll(bool Select, int Action = 0,
  134. bool OnlyTheAction = true);
  135. void __fastcall UpdateStatusBarSize();
  136. int __fastcall PanelCount();
  137. inline const TSynchronizeChecklist::TItem * GetChecklistItem(TListItem * Item);
  138. TSynchronizeChecklist::TAction & GetChecklistItemAction(
  139. const TSynchronizeChecklist::TItem * ChecklistItem);
  140. void __fastcall AddSubItem(TListItem * Item, int & Index, const UnicodeString & S);
  141. TRect __fastcall GetColumnHeaderRect(int Index);
  142. virtual void __fastcall Dispatch(void * Message);
  143. void __fastcall UpdateImages();
  144. void __fastcall CMDpiChanged(TMessage & Message);
  145. bool __fastcall GetWindowParams(UnicodeString & WindowParams);
  146. void __fastcall ProcessedItem(void * Token, const TSynchronizeChecklist::TItem * ChecklistItem);
  147. void __fastcall UpdatedSynchronizationChecklistItems(const TSynchronizeChecklist::TItemList & Items);
  148. void __fastcall CountItemSize(const TSynchronizeChecklist::TItem * ChecklistItem, int Factor);
  149. void __fastcall CountItem(const TSynchronizeChecklist::TItem * ChecklistItem, int Factor);
  150. static int __fastcall CompareNumber(__int64 Value1, __int64 Value2);
  151. };
  152. //----------------------------------------------------------------------------
  153. #endif