|
@@ -4066,24 +4066,16 @@ void __fastcall TCustomScpExplorerForm::OpenDirectory(TOperationSide Side)
|
|
|
DoOpenDirectoryDialog(odBrowse, Side);
|
|
|
}
|
|
|
//---------------------------------------------------------------------------
|
|
|
-bool __fastcall TCustomScpExplorerForm::OpenBookmark(UnicodeString Local, UnicodeString Remote)
|
|
|
+bool __fastcall TCustomScpExplorerForm::OpenBookmark(TOperationSide Side, TBookmark * Bookmark)
|
|
|
{
|
|
|
- UnicodeString Path;
|
|
|
- if (FCurrentSide == osRemote)
|
|
|
- {
|
|
|
- Path = Remote;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- Path = Local;
|
|
|
- }
|
|
|
+ UnicodeString Path = Bookmark->GetSideDirectory(Side);
|
|
|
|
|
|
bool Result = !Path.IsEmpty();
|
|
|
if (Result)
|
|
|
{
|
|
|
// While we might get here when the session is closed (from location profiles),
|
|
|
// it's not a problem as the Path setter is noop then
|
|
|
- DirView(FCurrentSide)->Path = Path;
|
|
|
+ DirView(Side)->Path = Path;
|
|
|
}
|
|
|
return Result;
|
|
|
}
|
|
@@ -4322,7 +4314,7 @@ void __fastcall TCustomScpExplorerForm::KeyDown(Word & Key, Classes::TShiftState
|
|
|
{
|
|
|
TBookmark * Bookmark = WinConfiguration->SharedBookmarks->FindByShortCut(CustomShortCut);
|
|
|
if ((Bookmark != NULL) &&
|
|
|
- OpenBookmark(Bookmark->Local, Bookmark->Remote))
|
|
|
+ OpenBookmark(FCurrentSide, Bookmark))
|
|
|
{
|
|
|
KeyProcessed(Key, Shift);
|
|
|
}
|
|
@@ -9571,3 +9563,127 @@ void __fastcall TCustomScpExplorerForm::CopyPopup(TControl * DestControl, TContr
|
|
|
static_cast<TPublicControl *>(DestControl)->OnContextPopup = static_cast<TPublicControl *>(SourceControl)->OnContextPopup;
|
|
|
}
|
|
|
//---------------------------------------------------------------------------
|
|
|
+void __fastcall TCustomScpExplorerForm::DoBookmarkClick(TOperationSide Side, TObject * Sender)
|
|
|
+{
|
|
|
+ TBookmark * Bookmark = DebugNotNull(reinterpret_cast<TBookmark *>(dynamic_cast<TTBCustomItem *>(Sender)->Tag));
|
|
|
+ OpenBookmark(Side, Bookmark);
|
|
|
+}
|
|
|
+//---------------------------------------------------------------------------
|
|
|
+void __fastcall TCustomScpExplorerForm::LocalBookmarkClick(TObject * Sender)
|
|
|
+{
|
|
|
+ DoBookmarkClick(osLocal, Sender);
|
|
|
+}
|
|
|
+//---------------------------------------------------------------------------
|
|
|
+void __fastcall TCustomScpExplorerForm::RemoteBookmarkClick(TObject * Sender)
|
|
|
+{
|
|
|
+ DoBookmarkClick(osRemote, Sender);
|
|
|
+}
|
|
|
+//---------------------------------------------------------------------------
|
|
|
+void __fastcall TCustomScpExplorerForm::CreateOpenDirMenuList(
|
|
|
+ TTBCustomItem * Menu, TOperationSide Side, TBookmarkList * BookmarkList)
|
|
|
+{
|
|
|
+ TNotifyEvent OnBookmarkClick = (Side == osLocal) ? &LocalBookmarkClick : &RemoteBookmarkClick;
|
|
|
+
|
|
|
+ if (!WinConfiguration->UseLocationProfiles)
|
|
|
+ {
|
|
|
+ std::unique_ptr<TStringList> Directories(new TStringList());
|
|
|
+ Directories->CaseSensitive = (Side == osRemote);
|
|
|
+ for (int Index = 0; Index < BookmarkList->Count; Index++)
|
|
|
+ {
|
|
|
+ TBookmark * Bookmark = BookmarkList->Bookmarks[Index];
|
|
|
+ UnicodeString Directory = Bookmark->GetSideDirectory(Side);
|
|
|
+ if (!Directory.IsEmpty() && (Directories->IndexOf(Directory) < 0))
|
|
|
+ {
|
|
|
+ std::unique_ptr<TTBCustomItem> Item(new TTBXItem(Owner));
|
|
|
+ Item->Caption = EscapeHotkey(Directory);
|
|
|
+ Item->ShortCut = Bookmark->ShortCut;
|
|
|
+ Item->OnClick = OnBookmarkClick;
|
|
|
+ Item->Tag = reinterpret_cast<int>(Bookmark);
|
|
|
+ Directories->Add(Directory);
|
|
|
+ Menu->Add(Item.release());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ std::unique_ptr<TStrings> Folders(CreateSortedStringList());
|
|
|
+ for (int Index = 0; Index < BookmarkList->Count; Index++)
|
|
|
+ {
|
|
|
+ TBookmark * Bookmark = BookmarkList->Bookmarks[Index];
|
|
|
+ if (!Bookmark->Node.IsEmpty())
|
|
|
+ {
|
|
|
+ Folders->Add(Bookmark->Node);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int Index = 0; Index < Folders->Count; Index++)
|
|
|
+ {
|
|
|
+ std::unique_ptr<TTBCustomItem> Item(new TTBXSubmenuItem(Owner));
|
|
|
+ Item->Caption = Folders->Strings[Index];
|
|
|
+ Item->ImageIndex = NonVisualDataModule->RemoteChangePathAction->ImageIndex;
|
|
|
+ Folders->Objects[Index] = Item.get();
|
|
|
+ Menu->Add(Item.release());
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int Index = 0; Index < BookmarkList->Count; Index++)
|
|
|
+ {
|
|
|
+ TBookmark * Bookmark = BookmarkList->Bookmarks[Index];
|
|
|
+ TTBCustomItem * Parent;
|
|
|
+ if (!Bookmark->Node.IsEmpty())
|
|
|
+ {
|
|
|
+ DebugAssert(Folders->IndexOf(Bookmark->Node) >= 0);
|
|
|
+ Parent = dynamic_cast<TTBCustomItem *>(Folders->Objects[Folders->IndexOf(Bookmark->Node)]);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Parent = Menu;
|
|
|
+ }
|
|
|
+ std::unique_ptr<TTBCustomItem> Item(new TTBXItem(Owner));
|
|
|
+ Item->Caption = Bookmark->Name;
|
|
|
+ Item->ShortCut = Bookmark->ShortCut;
|
|
|
+ Item->OnClick = OnBookmarkClick;
|
|
|
+ Item->Tag = reinterpret_cast<int>(Bookmark);
|
|
|
+
|
|
|
+ if (((Bookmark->Name == Bookmark->Local) || (Bookmark->Name == Bookmark->Remote)) &&
|
|
|
+ (Bookmark->Local.IsEmpty() || Bookmark->Remote.IsEmpty()))
|
|
|
+ {
|
|
|
+ // No hint for location profiles that are actually mere "bookmarks"
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ UnicodeString Hint = FORMAT(LoadStrPart(LOCATION_PROFILE_HINT, 1), (Bookmark->Name));
|
|
|
+ UnicodeString LongHint;
|
|
|
+ if (!Bookmark->Local.IsEmpty())
|
|
|
+ {
|
|
|
+ AddToList(LongHint, FORMAT(LoadStrPart(LOCATION_PROFILE_HINT, 2), (Bookmark->Local)), L"\n");
|
|
|
+ }
|
|
|
+ if (!Bookmark->Remote.IsEmpty())
|
|
|
+ {
|
|
|
+ AddToList(LongHint, FORMAT(LoadStrPart(LOCATION_PROFILE_HINT, 3), (Bookmark->Remote)), L"\n");
|
|
|
+ }
|
|
|
+ AddToList(Hint, LongHint, L"|");
|
|
|
+ Item->Hint = Hint;
|
|
|
+ }
|
|
|
+
|
|
|
+ Parent->Add(Item.release());
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+//---------------------------------------------------------------------------
|
|
|
+void __fastcall TCustomScpExplorerForm::CreateOpenDirMenu(TTBCustomItem * Menu, TOperationSide Side)
|
|
|
+{
|
|
|
+ Menu->Clear();
|
|
|
+
|
|
|
+ CreateOpenDirMenuList(Menu, Side, WinConfiguration->Bookmarks[Terminal->SessionData->SessionKey]);
|
|
|
+
|
|
|
+ AddMenuSeparator(Menu);
|
|
|
+
|
|
|
+ CreateOpenDirMenuList(Menu, Side, WinConfiguration->SharedBookmarks);
|
|
|
+
|
|
|
+ AddMenuSeparator(Menu);
|
|
|
+
|
|
|
+ std::unique_ptr<TTBCustomItem> Item(new TTBXItem(Owner));
|
|
|
+ Item->Action = (Side == osLocal) ? NonVisualDataModule->LocalAddBookmarkAction : NonVisualDataModule->RemoteAddBookmarkAction;
|
|
|
+ Menu->Add(Item.release());
|
|
|
+}
|
|
|
+//---------------------------------------------------------------------------
|