SynchronizeChecklist.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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. TAction *CalculateSizeAllAction;
  59. TAction *MoveAction;
  60. TButton *MoveButton;
  61. TMenuItem *MoveItem;
  62. TAction *CheckDirectoryAction;
  63. TAction *UncheckDirectoryAction;
  64. TMenuItem *N3;
  65. TMenuItem *CheckAllFilesinThisDirectory1;
  66. TMenuItem *UncheckAllActionsinThisDirectory1;
  67. void __fastcall HelpButtonClick(TObject * Sender);
  68. void __fastcall FormShow(TObject * Sender);
  69. void __fastcall StatusBarDrawPanel(TStatusBar *StatusBar,
  70. TStatusPanel *Panel, const TRect &Rect);
  71. void __fastcall StatusBarMouseMove(TObject *Sender, TShiftState Shift,
  72. int X, int Y);
  73. void __fastcall ListViewChange(TObject *Sender, TListItem *Item,
  74. TItemChange Change);
  75. void __fastcall ListViewChanging(TObject *Sender, TListItem *Item,
  76. TItemChange Change, bool &AllowChange);
  77. void __fastcall CheckAllActionExecute(TObject *Sender);
  78. void __fastcall CheckActionExecute(TObject *Sender);
  79. void __fastcall ListViewSelectItem(TObject *Sender, TListItem *Item,
  80. bool Selected);
  81. void __fastcall UpdateTimerTimer(TObject *Sender);
  82. void __fastcall SelectAllActionExecute(TObject *Sender);
  83. void __fastcall StatusBarMouseDown(TObject *Sender, TMouseButton Button,
  84. TShiftState Shift, int X, int Y);
  85. void __fastcall ListViewCompare(TObject *Sender, TListItem *Item1,
  86. TListItem *Item2, int Data, int &Compare);
  87. void __fastcall ListViewSecondaryColumnHeader(TCustomIEListView *Sender,
  88. int Index, int &SecondaryColumn);
  89. void __fastcall ListViewContextPopup(TObject *Sender, TPoint &MousePos,
  90. bool &Handled);
  91. void __fastcall CustomCommandsActionExecute(TObject *Sender);
  92. void __fastcall ListViewAdvancedCustomDrawSubItem(TCustomListView *Sender, TListItem *Item,
  93. int SubItem, TCustomDrawState State, TCustomDrawStage Stage, bool &DefaultDraw);
  94. void __fastcall StatusBarResize(TObject *Sender);
  95. void __fastcall UncheckActionExecute(TObject *Sender);
  96. void __fastcall UncheckAllActionExecute(TObject *Sender);
  97. void __fastcall ReverseActionExecute(TObject *Sender);
  98. void __fastcall ListViewClick(TObject *Sender);
  99. void __fastcall OkButtonClick(TObject *Sender);
  100. void __fastcall CalculateSizeActionExecute(TObject *Sender);
  101. void __fastcall CalculateSizeAllActionExecute(TObject *Sender);
  102. void __fastcall MoveActionExecute(TObject *Sender);
  103. void __fastcall CheckDirectoryActionExecute(TObject *Sender);
  104. void __fastcall UncheckDirectoryActionExecute(TObject *Sender);
  105. public:
  106. __fastcall TSynchronizeChecklistDialog(
  107. TComponent * AOwner, TSynchronizeMode Mode, int Params,
  108. const UnicodeString & LocalDirectory, const UnicodeString & RemoteDirectory,
  109. TCustomCommandMenuEvent OnCustomCommandMenu, TFullSynchronizeEvent OnSynchronize,
  110. TSynchronizeChecklistCalculateSize OnSynchronizeChecklistCalculateSize, TSynchronizeMoveEvent OnSynchronizeMove,
  111. void * Token);
  112. virtual __fastcall ~TSynchronizeChecklistDialog();
  113. bool __fastcall Execute(TSynchronizeChecklist * Checklist);
  114. protected:
  115. bool FFormRestored;
  116. TSynchronizeChecklist * FChecklist;
  117. TSynchronizeMode FMode;
  118. int FParams;
  119. UnicodeString FLocalDirectory;
  120. UnicodeString FRemoteDirectory;
  121. TWndMethod FOrigListViewWindowProc;
  122. int FTotals[1 + TSynchronizeChecklist::ActionCount];
  123. int FChecked[1 + TSynchronizeChecklist::ActionCount];
  124. __int64 FCheckedSize[1 + TSynchronizeChecklist::ActionCount];
  125. TListItem * FChangingItem;
  126. bool FChangingItemChecked;
  127. bool FChangingItemIgnore;
  128. bool FChangingItemMass;
  129. UnicodeString FGeneralHint;
  130. TCustomCommandMenuEvent FOnCustomCommandMenu;
  131. TSynchronizeChecklistCalculateSize FOnSynchronizeChecklistCalculateSize;
  132. TSynchronizeMoveEvent FOnSynchronizeMove;
  133. typedef std::map<const TSynchronizeChecklist::TItem *, TSynchronizeChecklist::TAction> TActions;
  134. TActions FActions;
  135. TFullSynchronizeEvent FOnSynchronize;
  136. void * FToken;
  137. bool FSynchronizing;
  138. std::unique_ptr<Exception> FException;
  139. std::map<const TSynchronizeChecklist::TItem *, TListItem *> FChecklistToListViewMap;
  140. void __fastcall UpdateControls();
  141. void __fastcall UpdateCaption();
  142. virtual void __fastcall CreateParams(TCreateParams & Params);
  143. void __fastcall LoadItem(TListItem * Item);
  144. void __fastcall LoadList();
  145. void __fastcall ListViewWindowProc(TMessage & Message);
  146. int __fastcall PanelAt(int X);
  147. void __fastcall CheckAll(bool Check);
  148. void __fastcall Check(bool Check);
  149. TListItem * __fastcall SelectAll(bool Select, int Action = 0,
  150. bool OnlyTheAction = true);
  151. void __fastcall UpdateStatusBarSize();
  152. int __fastcall PanelCount();
  153. inline const TSynchronizeChecklist::TItem * GetChecklistItem(TListItem * Item);
  154. TSynchronizeChecklist::TAction & GetChecklistItemAction(
  155. const TSynchronizeChecklist::TItem * ChecklistItem);
  156. void __fastcall AddSubItem(TListItem * Item, int & Index, const UnicodeString & S);
  157. TRect __fastcall GetColumnHeaderRect(int Index);
  158. virtual void __fastcall Dispatch(void * Message);
  159. void __fastcall UpdateImages();
  160. void __fastcall CMDpiChanged(TMessage & Message);
  161. bool __fastcall GetWindowParams(UnicodeString & WindowParams);
  162. void __fastcall ProcessedItem(void * Token, const TSynchronizeChecklist::TItem * ChecklistItem);
  163. void __fastcall UpdatedSynchronizationChecklistItems(const TSynchronizeChecklist::TItemList & Items);
  164. void __fastcall CountItemSize(const TSynchronizeChecklist::TItem * ChecklistItem, int Factor);
  165. void __fastcall CountItem(const TSynchronizeChecklist::TItem * ChecklistItem, int Factor);
  166. void __fastcall CountItemTotal(const TSynchronizeChecklist::TItem * ChecklistItem, int Factor);
  167. typedef std::pair<const TSynchronizeChecklist::TItem *, const TSynchronizeChecklist::TItem *> TSynchronizeMoveItems;
  168. TSynchronizeMoveItems __fastcall GetMoveItems();
  169. void __fastcall DeleteItem(TListItem * Item);
  170. void __fastcall CheckDirectory(bool Check);
  171. static int __fastcall CompareNumber(__int64 Value1, __int64 Value2);
  172. };
  173. //----------------------------------------------------------------------------
  174. #endif