소스 검색

Path/Drive drop down works for other panel even in local-local mode

Source commit: 58216bf6440152d6612366e17ebe169f383f4144
Martin Prikryl 5 년 전
부모
커밋
2c28ac9b74
5개의 변경된 파일145개의 추가작업 그리고 34개의 파일을 삭제
  1. 26 8
      source/forms/CustomScpExplorer.cpp
  2. 4 0
      source/forms/CustomScpExplorer.h
  3. 104 24
      source/forms/ScpCommander.cpp
  4. 1 1
      source/forms/ScpCommander.dfm
  5. 10 1
      source/forms/ScpCommander.h

+ 26 - 8
source/forms/CustomScpExplorer.cpp

@@ -8705,7 +8705,7 @@ void __fastcall TCustomScpExplorerForm::UpdateControls()
     RemoteDirView->DarkMode = WinConfiguration->UseDarkTheme();
     RemoteDriveView->DarkMode = RemoteDirView->DarkMode;
 
-    reinterpret_cast<TTBCustomItem *>(GetComponent(fcRemotePathComboBox))->Enabled = HasTerminal;
+    reinterpret_cast<TTBCustomItem *>(GetComponent(fcRemotePathComboBox))->Enabled = HasTerminal || IsLocalBrowserMode();
   }
 }
 //---------------------------------------------------------------------------
@@ -9605,9 +9605,8 @@ void __fastcall TCustomScpExplorerForm::UpdateRemotePathComboBox(bool TextOnly)
   }
 }
 //---------------------------------------------------------------------------
-void __fastcall TCustomScpExplorerForm::RemotePathComboBoxAdjustImageIndex(
-  TTBXComboBoxItem * Sender, const UnicodeString /*AText*/, int AIndex,
-  int & ImageIndex)
+void __fastcall TCustomScpExplorerForm::DoRemotePathComboBoxAdjustImageIndex(
+  TTBXComboBoxItem * Sender, const UnicodeString DebugUsedArg(AText), int AIndex, int & ImageIndex)
 {
   if (AIndex < 0)
   {
@@ -9616,11 +9615,21 @@ void __fastcall TCustomScpExplorerForm::RemotePathComboBoxAdjustImageIndex(
   ImageIndex = (AIndex < Sender->Strings->Count - 1 ? StdDirIcon : StdDirSelIcon);
 }
 //---------------------------------------------------------------------------
+void __fastcall TCustomScpExplorerForm::RemotePathComboBoxAdjustImageIndex(
+  TTBXComboBoxItem * Sender, const UnicodeString AText, int AIndex,
+  int & ImageIndex)
+{
+  DoRemotePathComboBoxAdjustImageIndex(Sender, AText, AIndex, ImageIndex);
+}
+//---------------------------------------------------------------------------
 void __fastcall TCustomScpExplorerForm::RemotePathComboBoxDrawItem(
   TTBXCustomList * /*Sender*/, TCanvas * /*ACanvas*/, TRect & ARect, int AIndex,
   int /*AHoverIndex*/, bool & /*DrawDefault*/)
 {
-  ARect.Left += (10 * AIndex);
+  if (!IsLocalBrowserMode())
+  {
+    ARect.Left += (10 * AIndex);
+  }
 }
 //---------------------------------------------------------------------------
 void __fastcall TCustomScpExplorerForm::RemotePathComboBoxMeasureWidth(
@@ -9629,8 +9638,7 @@ void __fastcall TCustomScpExplorerForm::RemotePathComboBoxMeasureWidth(
   AWidth += (10 * AIndex);
 }
 //---------------------------------------------------------------------------
-void __fastcall TCustomScpExplorerForm::RemotePathComboBoxItemClick(
-  TObject * Sender)
+void __fastcall TCustomScpExplorerForm::DoRemotePathComboBoxItemClick(TObject * Sender)
 {
   TTBXComboBoxItem * RemotePathComboBox = dynamic_cast<TTBXComboBoxItem*>(Sender);
 
@@ -9653,13 +9661,23 @@ void __fastcall TCustomScpExplorerForm::RemotePathComboBoxItemClick(
   }
 }
 //---------------------------------------------------------------------------
-void __fastcall TCustomScpExplorerForm::RemotePathComboBoxCancel(TObject * Sender)
+void __fastcall TCustomScpExplorerForm::RemotePathComboBoxItemClick(TObject * Sender)
+{
+  DoRemotePathComboBoxItemClick(Sender);
+}
+//---------------------------------------------------------------------------
+void __fastcall TCustomScpExplorerForm::DoRemotePathComboBoxCancel(TObject * Sender)
 {
   DebugAssert(Sender == GetComponent(fcRemotePathComboBox));
   DebugUsedParam(Sender);
   UpdateRemotePathComboBox(true);
 }
 //---------------------------------------------------------------------------
+void __fastcall TCustomScpExplorerForm::RemotePathComboBoxCancel(TObject * Sender)
+{
+  DoRemotePathComboBoxCancel(Sender);
+}
+//---------------------------------------------------------------------------
 void __fastcall TCustomScpExplorerForm::DirViewEditing(
   TObject * Sender, TListItem * Item, bool & /*AllowEdit*/)
 {

+ 4 - 0
source/forms/CustomScpExplorer.h

@@ -710,6 +710,10 @@ protected:
   bool __fastcall IsActiveTerminal(TTerminal * Terminal);
   void __fastcall UpdateRowSelect(TCustomDirView * DirView);
   void __fastcall MakeFocusedItemVisible(TCustomDirView * DirView);
+  virtual void __fastcall DoRemotePathComboBoxAdjustImageIndex(
+    TTBXComboBoxItem * Sender, const UnicodeString AText, int AIndex, int & ImageIndex);
+  virtual void __fastcall DoRemotePathComboBoxCancel(TObject * Sender);
+  virtual void __fastcall DoRemotePathComboBoxItemClick(TObject * Sender);
 
 public:
   virtual __fastcall ~TCustomScpExplorerForm();

+ 104 - 24
source/forms/ScpCommander.cpp

@@ -1018,7 +1018,6 @@ void __fastcall TScpCommanderForm::ChangePath(TOperationSide Side)
 {
   DebugAssert((Side == osLocal) || (Side == osRemote));
   TTBXComboBoxItem * PathComboBox;
-  // TODO
   if (Side == osLocal)
   {
     PathComboBox = LocalPathComboBox;
@@ -2048,7 +2047,6 @@ void __fastcall TScpCommanderForm::UpdateImages()
 //---------------------------------------------------------------------------
 void __fastcall TScpCommanderForm::LocalPathComboUpdateDrives()
 {
-  // TODO
   FLocalSpecialPaths = 0;
   TStrings* Strings = LocalPathComboBox->Strings;
   Strings->BeginUpdate();
@@ -2087,21 +2085,25 @@ void __fastcall TScpCommanderForm::LocalPathComboUpdateDrives()
   {
     Strings->EndUpdate();
   }
+
+  if (IsLocalBrowserMode())
+  {
+    UpdateRemotePathComboBox(false);
+  }
 }
 //---------------------------------------------------------------------------
-void __fastcall TScpCommanderForm::LocalPathComboUpdate()
+void __fastcall TScpCommanderForm::LocalPathComboUpdate(TCustomDirView * ADirView, TTBXComboBoxItem * PathComboBox)
 {
-  // TODO_OTHER_LOCAL
   // this may get called even after destructor finishes
   // (e.g. from SetDockAllowDrag invoked [indirectly] from StoreParams)
   if (FLocalPathComboBoxPaths != NULL)
   {
-    DebugAssert(FLocalPathComboBoxPaths->Count == LocalPathComboBox->Strings->Count);
+    DebugAssert(FLocalPathComboBoxPaths->Count == PathComboBox->Strings->Count);
 
     int Index = 0;
     while ((Index < FLocalPathComboBoxPaths->Count) &&
            !SamePaths(FLocalPathComboBoxPaths->Strings[Index],
-             LocalDirView->Path.SubString(1, FLocalPathComboBoxPaths->Strings[Index].Length())))
+             ADirView->Path.SubString(1, FLocalPathComboBoxPaths->Strings[Index].Length())))
     {
       Index++;
     }
@@ -2109,14 +2111,14 @@ void __fastcall TScpCommanderForm::LocalPathComboUpdate()
     // what to do if not?
     if (Index < FLocalPathComboBoxPaths->Count)
     {
-      LocalPathComboBox->ItemIndex = Index;
+      PathComboBox->ItemIndex = Index;
     }
   }
 }
 //---------------------------------------------------------------------------
-void __fastcall TScpCommanderForm::LocalDirViewPathChange(TCustomDirView * Sender)
+void __fastcall TScpCommanderForm::DoLocalDirViewPathChange(TCustomDirView * Sender, TTBXComboBoxItem * PathComboBox)
 {
-  LocalPathComboUpdate();
+  LocalPathComboUpdate(Sender, PathComboBox);
   ResetIncrementalSearch();
   if (IsUncPath(Sender->Path))
   {
@@ -2124,25 +2126,30 @@ void __fastcall TScpCommanderForm::LocalDirViewPathChange(TCustomDirView * Sende
   }
 }
 //---------------------------------------------------------------------------
+void __fastcall TScpCommanderForm::LocalDirViewPathChange(TCustomDirView * Sender)
+{
+  DoLocalDirViewPathChange(Sender, LocalPathComboBox);
+}
+//---------------------------------------------------------------------------
 void __fastcall TScpCommanderForm::LocalPathComboBoxCancel(TObject * /*Sender*/)
 {
-  LocalPathComboUpdate();
+  LocalPathComboUpdate(LocalDirView, LocalPathComboBox);
 }
 //---------------------------------------------------------------------------
-void __fastcall TScpCommanderForm::LocalPathComboBoxAdjustImageIndex(
-  TTBXComboBoxItem * /*Sender*/, const UnicodeString AText, int AIndex,
-  int & ImageIndex)
+void __fastcall TScpCommanderForm::DoLocalPathComboBoxAdjustImageIndex(
+  TTBXComboBoxItem * Sender, const UnicodeString AText, int AIndex, int & ImageIndex)
 {
   // this may get called even before constructor starts
   // (e.g. from FixControlsPlacement)
   if (FLocalPathComboBoxPaths != NULL)
   {
-    DebugAssert(FLocalPathComboBoxPaths->Count == LocalPathComboBox->Strings->Count);
+    TTBXComboBoxItem * PathComboBox = DebugNotNull(dynamic_cast<TTBXComboBoxItem *>(Sender));
+    DebugAssert(FLocalPathComboBoxPaths->Count == PathComboBox->Strings->Count);
     DebugAssert(AIndex < FLocalPathComboBoxPaths->Count);
 
     if (AIndex < 0)
     {
-      AIndex = LocalPathComboBox->ItemIndex;
+      AIndex = PathComboBox->ItemIndex;
     }
 
     if (AIndex >= 0)
@@ -2152,22 +2159,34 @@ void __fastcall TScpCommanderForm::LocalPathComboBoxAdjustImageIndex(
   }
 }
 //---------------------------------------------------------------------------
-void __fastcall TScpCommanderForm::LocalPathComboBoxItemClick(TObject * /*Sender*/)
+void __fastcall TScpCommanderForm::LocalPathComboBoxAdjustImageIndex(
+  TTBXComboBoxItem * Sender, const UnicodeString AText, int AIndex,
+  int & ImageIndex)
+{
+  DoLocalPathComboBoxAdjustImageIndex(Sender, AText, AIndex, ImageIndex);
+}
+//---------------------------------------------------------------------------
+void __fastcall TScpCommanderForm::DoLocalPathComboBoxItemClick(TDirView * ADirView, TTBXComboBoxItem * PathComboBox)
 {
-  DebugAssert(FLocalPathComboBoxPaths->Count == LocalPathComboBox->Strings->Count);
-  DebugAssert((LocalPathComboBox->ItemIndex >= 0) && (LocalPathComboBox->ItemIndex < FLocalPathComboBoxPaths->Count));
+  DebugAssert(FLocalPathComboBoxPaths->Count == PathComboBox->Strings->Count);
+  DebugAssert((PathComboBox->ItemIndex >= 0) && (PathComboBox->ItemIndex < FLocalPathComboBoxPaths->Count));
 
-  UnicodeString Path = FLocalPathComboBoxPaths->Strings[LocalPathComboBox->ItemIndex];
-  if (LocalPathComboBox->ItemIndex >= FLocalSpecialPaths)
+  UnicodeString Path = FLocalPathComboBoxPaths->Strings[PathComboBox->ItemIndex];
+  if (PathComboBox->ItemIndex >= FLocalSpecialPaths)
   {
-    LocalDirView->ExecuteDrive(DriveInfo->GetDriveKey(Path));
+    ADirView->ExecuteDrive(DriveInfo->GetDriveKey(Path));
   }
   else
   {
-    LocalDirView->Path = Path;
+    ADirView->Path = Path;
   }
 }
 //---------------------------------------------------------------------------
+void __fastcall TScpCommanderForm::LocalPathComboBoxItemClick(TObject *)
+{
+  DoLocalPathComboBoxItemClick(LocalDirView, LocalPathComboBox);
+}
+//---------------------------------------------------------------------------
 void __fastcall TScpCommanderForm::ToolbarItemResize(TTBXCustomDropDownItem * Item, int Width)
 {
   TCustomScpExplorerForm::ToolbarItemResize(Item, Width);
@@ -2240,9 +2259,12 @@ void __fastcall TScpCommanderForm::CommandLineComboEditWndProc(TMessage & Messag
 //---------------------------------------------------------------------------
 void __fastcall TScpCommanderForm::LocalDriveViewRefreshDrives(TObject * /*Sender*/)
 {
-  // TODO_OTHER_LOCAL
   LocalPathComboUpdateDrives();
-  LocalPathComboUpdate();
+  LocalPathComboUpdate(LocalDirView, LocalPathComboBox);
+  if (IsLocalBrowserMode())
+  {
+    LocalPathComboUpdate(OtherLocalDirView, RemotePathComboBox);
+  }
 }
 //---------------------------------------------------------------------------
 void __fastcall TScpCommanderForm::HomeDirectory(TOperationSide Side)
@@ -2475,3 +2497,61 @@ void __fastcall TScpCommanderForm::OtherLocalDriveViewEnter(TObject *)
   SideEnter(osOther);
 }
 //---------------------------------------------------------------------------
+void __fastcall TScpCommanderForm::DoRemotePathComboBoxAdjustImageIndex(
+  TTBXComboBoxItem * Sender, const UnicodeString AText, int AIndex, int & ImageIndex)
+{
+  if (!IsLocalBrowserMode())
+  {
+    TCustomScpExplorerForm::DoRemotePathComboBoxAdjustImageIndex(Sender, AText, AIndex, ImageIndex);
+  }
+  else
+  {
+    DoLocalPathComboBoxAdjustImageIndex(Sender, AText, AIndex, ImageIndex);
+  }
+}
+//---------------------------------------------------------------------------
+void __fastcall TScpCommanderForm::DoRemotePathComboBoxCancel(TObject * Sender)
+{
+  if (!IsLocalBrowserMode())
+  {
+    TCustomScpExplorerForm::DoRemotePathComboBoxCancel(Sender);
+  }
+  else
+  {
+    LocalPathComboUpdate(OtherLocalDirView, RemotePathComboBox);
+  }
+}
+//---------------------------------------------------------------------------
+void __fastcall TScpCommanderForm::OtherLocalDirViewPathChange(TCustomDirView * Sender)
+{
+  DebugAssert(IsLocalBrowserMode());
+  DoLocalDirViewPathChange(Sender, RemotePathComboBox);
+}
+//---------------------------------------------------------------------------
+void __fastcall TScpCommanderForm::DoRemotePathComboBoxItemClick(TObject * Sender)
+{
+  if (!IsLocalBrowserMode())
+  {
+    TCustomScpExplorerForm::DoRemotePathComboBoxItemClick(Sender);
+  }
+  else
+  {
+    DoLocalPathComboBoxItemClick(OtherLocalDirView, RemotePathComboBox);
+  }
+}
+//---------------------------------------------------------------------------
+void __fastcall TScpCommanderForm::UpdateRemotePathComboBox(bool TextOnly)
+{
+  if (!IsLocalBrowserMode())
+  {
+    TCustomScpExplorerForm::UpdateRemotePathComboBox(TextOnly);
+  }
+  else
+  {
+    if (!TextOnly)
+    {
+      RemotePathComboBox->Strings->Assign(LocalPathComboBox->Strings);
+    }
+    LocalPathComboUpdate(OtherLocalDirView, RemotePathComboBox);
+  }
+}

+ 1 - 1
source/forms/ScpCommander.dfm

@@ -1159,7 +1159,7 @@ inherited ScpCommanderForm: TScpCommanderForm
         OnContextPopup = OtherLocalDirViewContextPopup
         OnHistoryChange = DirViewHistoryChange
         OnHistoryGo = DirViewHistoryGo
-        OnPathChange = LocalDirViewPathChange
+        OnPathChange = OtherLocalDirViewPathChange
         OnBusy = DirViewBusy
         OnChangeFocus = DirViewChangeFocus
       end

+ 10 - 1
source/forms/ScpCommander.h

@@ -501,6 +501,7 @@ __published:
   void __fastcall OtherLocalDriveViewEnter(TObject *Sender);
   void __fastcall OtherLocalDirViewContextPopup(TObject *Sender, TPoint &MousePos, bool &Handled);
   void __fastcall OtherLocalDirViewUpdateStatusBar(TObject *Sender, const TStatusFileInfo &FileInfo);
+  void __fastcall OtherLocalDirViewPathChange(TCustomDirView *Sender);
 
 private:
   bool FConstructed;
@@ -595,7 +596,7 @@ protected:
   void __fastcall CreateLocalDirectory(const UnicodeString & Path);
   void __fastcall CreateRemoteDirectory(const UnicodeString & Path);
   void __fastcall LocalPathComboUpdateDrives();
-  void __fastcall LocalPathComboUpdate();
+  void __fastcall LocalPathComboUpdate(TCustomDirView * ADirView, TTBXComboBoxItem * PathComboBox);
   virtual void __fastcall ToolbarItemResize(TTBXCustomDropDownItem * Item, int Width);
   void __fastcall DoOpenBookmark(UnicodeString Local, UnicodeString Remote);
   virtual bool __fastcall OpenBookmark(TOperationSide Side, TBookmark * Bookmark);
@@ -611,6 +612,14 @@ protected:
   virtual void __fastcall ThemeChanged();
   virtual bool IsLocalBrowserMode();
   void __fastcall DoPathLabelPathClick(TOperationSide Side, const UnicodeString & Path);
+  virtual void __fastcall DoRemotePathComboBoxAdjustImageIndex(
+    TTBXComboBoxItem * Sender, const UnicodeString AText, int AIndex, int & ImageIndex);
+  virtual void __fastcall DoRemotePathComboBoxCancel(TObject * Sender);
+  void __fastcall DoLocalDirViewPathChange(TCustomDirView * Sender, TTBXComboBoxItem * PathComboBox);
+  void __fastcall DoLocalPathComboBoxAdjustImageIndex(TTBXComboBoxItem * Sender, const UnicodeString AText, int AIndex, int & ImageIndex);
+  void __fastcall DoLocalPathComboBoxItemClick(TDirView * ADirView, TTBXComboBoxItem * PathComboBox);
+  virtual void __fastcall DoRemotePathComboBoxItemClick(TObject * Sender);
+  virtual void __fastcall UpdateRemotePathComboBox(bool TextOnly);
 
 public:
   __fastcall TScpCommanderForm(TComponent* Owner);