OpenDirectory.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  1. //---------------------------------------------------------------------
  2. #include <FormsPCH.h>
  3. #pragma hdrstop
  4. #include <RemoteFiles.h>
  5. #include "OpenDirectory.h"
  6. //---------------------------------------------------------------------
  7. #pragma link "HistoryComboBox"
  8. #pragma resource "*.dfm"
  9. //---------------------------------------------------------------------
  10. bool __fastcall DoOpenDirectoryDialog(TOpenDirectoryMode Mode, TOperationSide Side,
  11. UnicodeString & Directory, TStrings * Directories, TTerminal * Terminal,
  12. bool AllowSwitch)
  13. {
  14. bool Result;
  15. TOpenDirectoryDialog * Dialog = new TOpenDirectoryDialog(Application);
  16. try
  17. {
  18. Dialog->Mode = Mode;
  19. Dialog->OperationSide = Side;
  20. Dialog->Directory = Directory;
  21. Dialog->Directories = Directories;
  22. Dialog->Terminal = Terminal;
  23. Dialog->AllowSwitch = AllowSwitch;
  24. Result = Dialog->Execute();
  25. if (Result)
  26. {
  27. Directory = Dialog->Directory;
  28. }
  29. }
  30. __finally
  31. {
  32. delete Dialog;
  33. }
  34. return Result;
  35. }
  36. //---------------------------------------------------------------------
  37. __fastcall TOpenDirectoryDialog::TOpenDirectoryDialog(TComponent * AOwner):
  38. TForm(AOwner)
  39. {
  40. UseSystemSettings(this);
  41. FOperationSide = osCurrent;
  42. OperationSide = osLocal;
  43. FBookmarkDragDest = -1;
  44. FTerminal = NULL;
  45. FSessionBookmarkList = new TBookmarkList();
  46. FSharedBookmarkList = new TBookmarkList();
  47. FSessionScrollOnDragOver = new TListBoxScrollOnDragOver(SessionBookmarksList, true);
  48. FSharedScrollOnDragOver = new TListBoxScrollOnDragOver(SharedBookmarksList, true);
  49. FixComboBoxResizeBug(LocalDirectoryEdit);
  50. FixComboBoxResizeBug(RemoteDirectoryEdit);
  51. LoadDialogImage(Image, L"Open folder");
  52. }
  53. //---------------------------------------------------------------------
  54. __fastcall TOpenDirectoryDialog::~TOpenDirectoryDialog()
  55. {
  56. SAFE_DESTROY(FSessionScrollOnDragOver);
  57. SAFE_DESTROY(FSharedScrollOnDragOver);
  58. SAFE_DESTROY(FSessionBookmarkList);
  59. SAFE_DESTROY(FSharedBookmarkList);
  60. }
  61. //---------------------------------------------------------------------
  62. void __fastcall TOpenDirectoryDialog::SetOperationSide(TOperationSide value)
  63. {
  64. if (OperationSide != value)
  65. {
  66. UnicodeString ADirectory = Directory;
  67. FOperationSide = value;
  68. Directory = ADirectory;
  69. RemoteDirectoryEdit->Visible = False;
  70. LocalDirectoryEdit->Visible = False;
  71. CurrentEdit->Visible = True;
  72. EditLabel->FocusControl = CurrentEdit;
  73. UpdateControls();
  74. }
  75. }
  76. //---------------------------------------------------------------------------
  77. void __fastcall TOpenDirectoryDialog::SetDirectory(UnicodeString value)
  78. {
  79. if (OperationSide == osRemote)
  80. {
  81. RemoteDirectoryEdit->Text = value;
  82. }
  83. else
  84. {
  85. LocalDirectoryEdit->Text = value;
  86. }
  87. DirectoryEditChange(NULL);
  88. }
  89. //---------------------------------------------------------------------------
  90. UnicodeString __fastcall TOpenDirectoryDialog::GetDirectory()
  91. {
  92. if (OperationSide == osRemote)
  93. return UnixExcludeTrailingBackslash(RemoteDirectoryEdit->Text);
  94. else
  95. return ExcludeTrailingBackslash(LocalDirectoryEdit->Text);
  96. }
  97. //---------------------------------------------------------------------------
  98. TWinControl * __fastcall TOpenDirectoryDialog::GetCurrentEdit()
  99. {
  100. if (OperationSide == osRemote) return RemoteDirectoryEdit;
  101. else return LocalDirectoryEdit;
  102. }
  103. //---------------------------------------------------------------------------
  104. void __fastcall TOpenDirectoryDialog::ControlChange(TObject * /*Sender*/)
  105. {
  106. UpdateControls();
  107. }
  108. //---------------------------------------------------------------------------
  109. void __fastcall TOpenDirectoryDialog::UpdateBookmarkControls(
  110. TButton * AddBookmarkButton, TButton * RemoveBookmarkButton,
  111. TButton * ShortCutBookmarkButton,
  112. TButton * UpBookmarkButton, TButton * DownBookmarkButton,
  113. TListBox * BookmarksList, bool ListBoxUpdate)
  114. {
  115. EnableControl(AddBookmarkButton,
  116. !Directory.IsEmpty() && (FindBookmark(BookmarksList, Directory) < 0));
  117. EnableControl(RemoveBookmarkButton, BookmarksList->ItemIndex >= 0);
  118. if (ShortCutBookmarkButton != NULL)
  119. {
  120. EnableControl(ShortCutBookmarkButton, BookmarksList->ItemIndex >= 0);
  121. }
  122. EnableControl(UpBookmarkButton, BookmarksList->ItemIndex > 0);
  123. EnableControl(DownBookmarkButton, BookmarksList->ItemIndex >= 0 &&
  124. BookmarksList->ItemIndex < BookmarksList->Items->Count-1);
  125. if (ListBoxUpdate)
  126. {
  127. int MaxWidth = 0;
  128. for (int i = 0; i < BookmarksList->Items->Count; i++)
  129. {
  130. int Width = BookmarksList->Canvas->TextExtent(BookmarksList->Items->Strings[i]).cx;
  131. if (Width > MaxWidth)
  132. {
  133. MaxWidth = Width;
  134. }
  135. }
  136. BookmarksList->ScrollWidth = MaxWidth;
  137. MaxWidth += ScaleByTextHeight(this, 6);
  138. if (BookmarksList->Items->Count > BookmarksList->ClientHeight / BookmarksList->ItemHeight)
  139. {
  140. MaxWidth += GetSystemMetricsForControl(this, SM_CXVSCROLL);
  141. }
  142. if (MaxWidth > BookmarksList->Width)
  143. {
  144. int CWidth = ClientWidth + (MaxWidth - BookmarksList->Width);
  145. ClientWidth = Min(CWidth, ScaleByTextHeight(this, 700));
  146. }
  147. }
  148. }
  149. //---------------------------------------------------------------------------
  150. void __fastcall TOpenDirectoryDialog::UpdateControls(bool ListBoxUpdate)
  151. {
  152. EnableControl(OKBtn, !Directory.IsEmpty());
  153. LocalDirectoryBrowseButton->Visible = (OperationSide == osLocal);
  154. SwitchButton->Visible = AllowSwitch;
  155. SessionBookmarksSheet->TabVisible = (Terminal != NULL);
  156. UpdateBookmarkControls(AddSessionBookmarkButton, RemoveSessionBookmarkButton,
  157. NULL, UpSessionBookmarkButton, DownSessionBookmarkButton,
  158. SessionBookmarksList, ListBoxUpdate);
  159. UpdateBookmarkControls(AddSharedBookmarkButton, RemoveSharedBookmarkButton,
  160. ShortCutSharedBookmarkButton, UpSharedBookmarkButton, DownSharedBookmarkButton,
  161. SharedBookmarksList, ListBoxUpdate);
  162. }
  163. //---------------------------------------------------------------------------
  164. void __fastcall TOpenDirectoryDialog::SetDirectories(TStrings * value)
  165. {
  166. dynamic_cast<TCustomComboBox*>(CurrentEdit)->Items = value;
  167. }
  168. //---------------------------------------------------------------------------
  169. TStrings * __fastcall TOpenDirectoryDialog::GetDirectories()
  170. {
  171. return RemoteDirectoryEdit->Items;
  172. }
  173. //---------------------------------------------------------------------------
  174. UnicodeString __fastcall TOpenDirectoryDialog::BookmarkDirectory(TBookmark * Bookmark)
  175. {
  176. return Bookmark->GetSideDirectory(OperationSide);
  177. }
  178. //---------------------------------------------------------------------------
  179. UnicodeString __fastcall TOpenDirectoryDialog::BookmarkText(TBookmark * Bookmark)
  180. {
  181. UnicodeString Result = BookmarkDirectory(Bookmark);
  182. if (!Result.IsEmpty() && (Bookmark->ShortCut != 0))
  183. {
  184. Result = FORMAT(L"%s (%s)", (Result, ShortCutToText(Bookmark->ShortCut)));
  185. }
  186. return Result;
  187. }
  188. //---------------------------------------------------------------------------
  189. TBookmark * __fastcall TOpenDirectoryDialog::GetBookmark(TListBox * BookmarksList, int Index)
  190. {
  191. return dynamic_cast<TBookmark *>(BookmarksList->Items->Objects[Index]);
  192. }
  193. //---------------------------------------------------------------------------
  194. void __fastcall TOpenDirectoryDialog::LoadBookmarks(TListBox * ListBox,
  195. TBookmarkList * BookmarkList, TBookmarkList * Source)
  196. {
  197. if (Source != NULL)
  198. {
  199. BookmarkList->Assign(Source);
  200. }
  201. else
  202. {
  203. BookmarkList->Clear();
  204. }
  205. Configuration->Usage->SetMax(L"MaxBookmarks", BookmarkList->Count);
  206. ListBox->Items->Clear();
  207. for (int i = 0; i < BookmarkList->Count; i++)
  208. {
  209. TBookmark * Bookmark = BookmarkList->Bookmarks[i];
  210. UnicodeString Directory = BookmarkDirectory(Bookmark);
  211. if (!Directory.IsEmpty() && (FindBookmark(ListBox, Directory) < 0))
  212. {
  213. UnicodeString Text = BookmarkText(Bookmark);
  214. ListBox->Items->AddObject(Text, Bookmark);
  215. }
  216. }
  217. }
  218. //---------------------------------------------------------------------------
  219. bool __fastcall TOpenDirectoryDialog::Execute()
  220. {
  221. bool Result;
  222. UnicodeString SessionKey;
  223. if (Terminal)
  224. {
  225. // cache session key, in case terminal is closed while the window is open
  226. SessionKey = Terminal->SessionData->SessionKey;
  227. LoadBookmarks(SessionBookmarksList, FSessionBookmarkList, WinConfiguration->Bookmarks[SessionKey]);
  228. }
  229. LoadBookmarks(SharedBookmarksList, FSharedBookmarkList, WinConfiguration->SharedBookmarks);
  230. TTabSheet * Page =
  231. (Terminal == NULL) || WinConfiguration->UseSharedBookmarks ? SharedBookmarksSheet : SessionBookmarksSheet;
  232. PageControl->ActivePage = Page;
  233. DirectoryEditChange(NULL);
  234. if (Mode == odAddBookmark)
  235. {
  236. AddAsBookmark(PageControl->ActivePage);
  237. }
  238. FBookmarkSelected = false;
  239. Result = (ShowModal() == DefaultResult(this));
  240. WinConfiguration->SharedBookmarks = FSharedBookmarkList;
  241. if (Terminal != NULL)
  242. {
  243. WinConfiguration->Bookmarks[SessionKey] = FSessionBookmarkList;
  244. // Do not remember that shared page was selected,
  245. // if it was selected implicitly because there's no site page.
  246. WinConfiguration->UseSharedBookmarks = (PageControl->ActivePage == SharedBookmarksSheet);
  247. }
  248. if (Result)
  249. {
  250. if (FBookmarkSelected)
  251. {
  252. Configuration->Usage->Inc(L"OpenedBookmark");
  253. }
  254. else
  255. {
  256. Configuration->Usage->Inc(L"OpenedPath");
  257. }
  258. }
  259. return Result;
  260. }
  261. //---------------------------------------------------------------------------
  262. template<typename T>
  263. T * GetBookmarkObject(TObject * Sender, T * SessionObject, T * SharedObject)
  264. {
  265. TControl * Control = dynamic_cast<TControl *>(Sender);
  266. DebugAssert(Control != NULL);
  267. switch (abs(Control->Tag))
  268. {
  269. case 1: return SessionObject;
  270. case 2: return SharedObject;
  271. default: DebugFail(); return NULL;
  272. }
  273. }
  274. //---------------------------------------------------------------------------
  275. TBookmarkList * TOpenDirectoryDialog::GetBookmarkList(TObject * Sender)
  276. {
  277. return GetBookmarkObject(Sender, FSessionBookmarkList, FSharedBookmarkList);
  278. }
  279. //---------------------------------------------------------------------------
  280. TListBox * TOpenDirectoryDialog::GetBookmarksList(TObject * Sender)
  281. {
  282. return GetBookmarkObject(Sender, SessionBookmarksList, SharedBookmarksList);
  283. }
  284. //---------------------------------------------------------------------------
  285. TListBoxScrollOnDragOver * TOpenDirectoryDialog::GetScrollOnDragOver(TObject * Sender)
  286. {
  287. return GetBookmarkObject(Sender, FSessionScrollOnDragOver, FSharedScrollOnDragOver);
  288. }
  289. //---------------------------------------------------------------------------
  290. void __fastcall TOpenDirectoryDialog::AddAsBookmark(TObject * Sender)
  291. {
  292. TBookmarkList * BookmarkList = GetBookmarkList(Sender);
  293. TListBox * BookmarksList = GetBookmarksList(Sender);
  294. if (Directory.IsEmpty() || (FindBookmark(BookmarksList, Directory) >= 0))
  295. {
  296. return;
  297. }
  298. TBookmark * Bookmark = new TBookmark;
  299. if (OperationSide == osRemote)
  300. {
  301. RemoteDirectoryEdit->SelectAll();
  302. Bookmark->Remote = Directory;
  303. }
  304. else
  305. {
  306. LocalDirectoryEdit->SelectAll();
  307. Bookmark->Local = Directory;
  308. }
  309. Bookmark->Name = Directory;
  310. // would always be equal to Directory atm,
  311. // as only difference can be a shorcut, which is not set
  312. UnicodeString Text = BookmarkText(Bookmark);
  313. if (BookmarksList->ItemIndex >= 0)
  314. {
  315. int PrevItemIndex = BookmarksList->ItemIndex;
  316. BookmarkList->InsertBefore(
  317. GetBookmark(BookmarksList, BookmarksList->ItemIndex), Bookmark);
  318. BookmarksList->Items->InsertObject(BookmarksList->ItemIndex, Text, Bookmark);
  319. BookmarksList->ItemIndex = PrevItemIndex;
  320. }
  321. else
  322. {
  323. BookmarkList->Add(Bookmark);
  324. BookmarksList->Items->AddObject(Text, Bookmark);
  325. BookmarksList->ItemIndex = BookmarksList->Items->Count-1;
  326. }
  327. UpdateControls(true);
  328. }
  329. //---------------------------------------------------------------------------
  330. void __fastcall TOpenDirectoryDialog::AddBookmarkButtonClick(TObject * Sender)
  331. {
  332. AddAsBookmark(Sender);
  333. }
  334. //---------------------------------------------------------------------------
  335. void __fastcall TOpenDirectoryDialog::RemoveBookmark(TObject * Sender)
  336. {
  337. TBookmarkList * BookmarkList = GetBookmarkList(Sender);
  338. TListBox * BookmarksList = GetBookmarksList(Sender);
  339. int PrevItemIndex = BookmarksList->ItemIndex;
  340. TBookmark * Bookmark = GetBookmark(BookmarksList, PrevItemIndex);
  341. DebugAssert(Bookmark != NULL);
  342. BookmarkList->Delete(Bookmark);
  343. BookmarksList->Items->Delete(PrevItemIndex);
  344. if (PrevItemIndex < BookmarksList->Items->Count)
  345. {
  346. BookmarksList->ItemIndex = PrevItemIndex;
  347. }
  348. else
  349. {
  350. BookmarksList->ItemIndex = BookmarksList->Items->Count-1;
  351. }
  352. UpdateControls(true);
  353. BookmarkSelected(Sender);
  354. }
  355. //---------------------------------------------------------------------------
  356. void __fastcall TOpenDirectoryDialog::RemoveBookmarkButtonClick(TObject * Sender)
  357. {
  358. RemoveBookmark(Sender);
  359. }
  360. //---------------------------------------------------------------------------
  361. Integer __fastcall TOpenDirectoryDialog::FindBookmark(TListBox * BookmarksList, const UnicodeString Bookmark)
  362. {
  363. if (OperationSide == osRemote)
  364. {
  365. for (int Index = 0; Index < BookmarksList->Items->Count; Index++)
  366. {
  367. TBookmark * ABookmark = GetBookmark(BookmarksList, Index);
  368. if (AnsiCompareStr(BookmarkDirectory(ABookmark), Bookmark) == 0)
  369. {
  370. return Index;
  371. }
  372. }
  373. }
  374. else
  375. {
  376. for (int Index = 0; Index < BookmarksList->Items->Count; Index++)
  377. {
  378. TBookmark * ABookmark = GetBookmark(BookmarksList, Index);
  379. if (AnsiCompareText(BookmarkDirectory(ABookmark), Bookmark) == 0)
  380. {
  381. return Index;
  382. }
  383. }
  384. }
  385. return -1;
  386. }
  387. //---------------------------------------------------------------------------
  388. void __fastcall TOpenDirectoryDialog::BookmarkSelected(TObject * Sender)
  389. {
  390. TListBox * BookmarksList = GetBookmarksList(Sender);
  391. if (BookmarksList->ItemIndex >= 0)
  392. {
  393. Directory = BookmarkDirectory(GetBookmark(BookmarksList, BookmarksList->ItemIndex));
  394. }
  395. UpdateControls();
  396. FBookmarkSelected = true;
  397. }
  398. //---------------------------------------------------------------------------
  399. void __fastcall TOpenDirectoryDialog::BookmarksListClick(TObject * Sender)
  400. {
  401. BookmarkSelected(Sender);
  402. }
  403. //---------------------------------------------------------------------------
  404. void __fastcall TOpenDirectoryDialog::BookmarkMove(TObject * Sender,
  405. int Source, int Dest)
  406. {
  407. TBookmarkList * BookmarkList = GetBookmarkList(Sender);
  408. TListBox * BookmarksList = GetBookmarksList(Sender);
  409. if (Source >= 0 && Source < BookmarksList->Items->Count &&
  410. Dest >= 0 && Dest < BookmarksList->Items->Count)
  411. {
  412. BookmarkList->MoveTo(
  413. GetBookmark(BookmarksList, Dest),
  414. GetBookmark(BookmarksList, Source),
  415. Source > Dest);
  416. BookmarksList->Items->Move(Source, Dest);
  417. BookmarksList->ItemIndex = Dest;
  418. BookmarksList->SetFocus();
  419. UpdateControls();
  420. }
  421. }
  422. //---------------------------------------------------------------------------
  423. void __fastcall TOpenDirectoryDialog::BookmarkButtonClick(TObject * Sender)
  424. {
  425. TControl * Control = dynamic_cast<TControl *>(Sender);
  426. BookmarkMove(Sender,
  427. GetBookmarksList(Sender)->ItemIndex,
  428. GetBookmarksList(Sender)->ItemIndex + (Control->Tag / abs(Control->Tag)));
  429. UpdateControls();
  430. }
  431. //---------------------------------------------------------------------------
  432. bool __fastcall TOpenDirectoryDialog::AllowBookmarkDrag(TObject * Sender, int X, int Y)
  433. {
  434. FBookmarkDragDest = GetBookmarksList(Sender)->ItemAtPos(TPoint(X, Y), true);
  435. return (FBookmarkDragDest >= 0) && (FBookmarkDragDest != FBookmarkDragSource);
  436. }
  437. //---------------------------------------------------------------------------
  438. void __fastcall TOpenDirectoryDialog::BookmarksListStartDrag(
  439. TObject * Sender , TDragObject *& /*DragObject*/)
  440. {
  441. FBookmarkDragSource = GetBookmarksList(Sender)->ItemIndex;
  442. FBookmarkDragDest = -1;
  443. GetScrollOnDragOver(Sender)->StartDrag();
  444. }
  445. //---------------------------------------------------------------------------
  446. void __fastcall TOpenDirectoryDialog::BookmarksListDragOver(
  447. TObject * Sender, TObject *Source, int X, int Y, TDragState /*State*/,
  448. bool &Accept)
  449. {
  450. if (Source == GetBookmarksList(Sender))
  451. {
  452. Accept = AllowBookmarkDrag(Sender, X, Y);
  453. GetScrollOnDragOver(Sender)->DragOver(TPoint(X, Y));
  454. }
  455. }
  456. //---------------------------------------------------------------------------
  457. void __fastcall TOpenDirectoryDialog::BookmarksListDragDrop(
  458. TObject * Sender, TObject *Source, int X, int Y)
  459. {
  460. if (Source == GetBookmarksList(Sender))
  461. {
  462. if (AllowBookmarkDrag(Sender, X, Y))
  463. {
  464. BookmarkMove(Sender, FBookmarkDragSource, FBookmarkDragDest);
  465. }
  466. }
  467. }
  468. //---------------------------------------------------------------------------
  469. void __fastcall TOpenDirectoryDialog::SelectBookmark(TListBox * BookmarksList)
  470. {
  471. int ItemIndex = FindBookmark(BookmarksList, Directory);
  472. if (ItemIndex >= 0)
  473. {
  474. BookmarksList->ItemIndex = ItemIndex;
  475. }
  476. }
  477. //---------------------------------------------------------------------------
  478. void __fastcall TOpenDirectoryDialog::DirectoryEditChange(TObject * /*Sender*/)
  479. {
  480. SelectBookmark(SessionBookmarksList);
  481. SelectBookmark(SharedBookmarksList);
  482. UpdateControls();
  483. FBookmarkSelected = false;
  484. }
  485. //---------------------------------------------------------------------------
  486. void __fastcall TOpenDirectoryDialog::BookmarksListDblClick(TObject * Sender)
  487. {
  488. if (GetBookmarksList(Sender)->ItemIndex >= 0)
  489. {
  490. ModalResult = DefaultResult(this);
  491. }
  492. }
  493. //---------------------------------------------------------------------------
  494. void __fastcall TOpenDirectoryDialog::SetMode(TOpenDirectoryMode value)
  495. {
  496. FMode = value;
  497. Caption = LoadStr(Mode == odBrowse ?
  498. OPEN_DIRECTORY_BROWSE_CAPTION : OPEN_DIRECTORY_ADD_BOOMARK_ACTION );
  499. }
  500. //---------------------------------------------------------------------------
  501. void __fastcall TOpenDirectoryDialog::FormShow(TObject * /*Sender*/)
  502. {
  503. InstallPathWordBreakProc(LocalDirectoryEdit);
  504. InstallPathWordBreakProc(RemoteDirectoryEdit);
  505. UpdateControls(true);
  506. if (Mode == odBrowse)
  507. {
  508. ActiveControl = CurrentEdit;
  509. }
  510. else
  511. {
  512. ActiveControl = GetBookmarksList(PageControl->ActivePage);
  513. }
  514. }
  515. //---------------------------------------------------------------------------
  516. void __fastcall TOpenDirectoryDialog::BookmarksListKeyDown(TObject * Sender,
  517. WORD & Key, TShiftState /*Shift*/)
  518. {
  519. if ((GetBookmarksList(Sender)->ItemIndex >= 0) && (Key == VK_DELETE))
  520. {
  521. RemoveBookmark(Sender);
  522. }
  523. }
  524. //---------------------------------------------------------------------------
  525. void __fastcall TOpenDirectoryDialog::LocalDirectoryBrowseButtonClick(
  526. TObject * /*Sender*/)
  527. {
  528. SelectDirectoryForEdit(LocalDirectoryEdit);
  529. }
  530. //---------------------------------------------------------------------------
  531. void __fastcall TOpenDirectoryDialog::SwitchButtonClick(TObject * /*Sender*/)
  532. {
  533. WinConfiguration->UseLocationProfiles = true;
  534. }
  535. //---------------------------------------------------------------------------
  536. void __fastcall TOpenDirectoryDialog::HelpButtonClick(TObject * /*Sender*/)
  537. {
  538. FormHelp(this);
  539. }
  540. //---------------------------------------------------------------------------
  541. void __fastcall TOpenDirectoryDialog::BookmarksListEndDrag(TObject * Sender,
  542. TObject * /*Target*/, int /*X*/, int /*Y*/)
  543. {
  544. GetScrollOnDragOver(Sender)->EndDrag();
  545. }
  546. //---------------------------------------------------------------------------
  547. void __fastcall TOpenDirectoryDialog::ShortCutBookmarkButtonClick(
  548. TObject * Sender)
  549. {
  550. TBookmarkList * BookmarkList = GetBookmarkList(Sender);
  551. TListBox * BookmarksList = GetBookmarksList(Sender);
  552. int Index = BookmarksList->ItemIndex;
  553. TBookmark * Bookmark = GetBookmark(BookmarksList, Index);
  554. DebugAssert(Bookmark != NULL);
  555. TShortCuts ShortCuts;
  556. WinConfiguration->CustomCommandShortCuts(ShortCuts);
  557. BookmarkList->ShortCuts(ShortCuts);
  558. TShortCut ShortCut = Bookmark->ShortCut;
  559. if (DoShortCutDialog(ShortCut, ShortCuts, HelpKeyword))
  560. {
  561. Bookmark->ShortCut = ShortCut;
  562. BookmarksList->Items->Strings[Index] = BookmarkText(Bookmark);
  563. UpdateControls(true);
  564. }
  565. }
  566. //---------------------------------------------------------------------------
  567. void __fastcall TOpenDirectoryDialog::PageControlChange(TObject * /*Sender*/)
  568. {
  569. BookmarkSelected(GetBookmarksList(PageControl->ActivePage));
  570. }
  571. //---------------------------------------------------------------------------