Sfoglia il codice sorgente

Removing drop checks that were never needed + Better handling of drag&drop of/over default transfer settings entry

Source commit: c51c7d41b249414b3028d9fbda451360686d0290
Martin Prikryl 7 anni fa
parent
commit
0caed3a048
3 ha cambiato i file con 29 aggiunte e 22 eliminazioni
  1. 27 21
      source/forms/Preferences.cpp
  2. 1 1
      source/forms/Preferences.dfm
  3. 1 0
      source/forms/Preferences.h

+ 27 - 21
source/forms/Preferences.cpp

@@ -1723,18 +1723,11 @@ const TCopyParamType * TPreferencesDialog::GetCopyParam(int Index)
 //---------------------------------------------------------------------------
 void __fastcall TPreferencesDialog::CopyParamMove(int Source, int Dest)
 {
-  if (Source >= 1 && Source < (1 + FCopyParamList->Count) &&
-      Dest >= 0 && Dest < (1 + FCopyParamList->Count))
-  {
-    if (Dest == 0)
-    {
-      Dest = 1;
-    }
-    FCopyParamList->Move(Source - 1, Dest - 1);
-    CopyParamListView->ItemIndex = Dest;
-    UpdateCopyParamListView();
-    UpdateControls();
-  }
+  DebugAssert((Source > 0) && (Dest > 0));
+  FCopyParamList->Move(Source - 1, Dest - 1);
+  CopyParamListView->ItemIndex = Dest;
+  UpdateCopyParamListView();
+  UpdateControls();
 }
 //---------------------------------------------------------------------------
 void __fastcall TPreferencesDialog::CopyParamListViewDragDrop(
@@ -1742,13 +1735,30 @@ void __fastcall TPreferencesDialog::CopyParamListViewDragDrop(
 {
   if (Source == CopyParamListView)
   {
-    if (AllowListViewDrag(Sender, X, Y))
+    if ((FListViewDragSource > 0) &&
+        AllowListViewDrag(Sender, X, Y) &&
+        (FListViewDragDest > 0))
     {
       CopyParamMove(FListViewDragSource, FListViewDragDest);
     }
   }
 }
 //---------------------------------------------------------------------------
+void __fastcall TPreferencesDialog::CopyParamListViewDragOver(
+  TObject * Sender, TObject * Source, int X, int Y, TDragState State, bool & Accept)
+{
+  ListViewDragOver(Sender, Source, X, Y, State, Accept);
+
+  if (Source == Sender)
+  {
+    int Dest = PointToListViewIndex(Sender, X, Y);
+    if ((FListViewDragSource == 0) || (Dest == 0))
+    {
+      Accept = false;
+    }
+  }
+}
+//---------------------------------------------------------------------------
 void __fastcall TPreferencesDialog::UpDownCopyParamButtonClick(TObject * Sender)
 {
   CopyParamMove(CopyParamListView->ItemIndex,
@@ -1849,14 +1859,10 @@ void __fastcall TPreferencesDialog::CopyParamListViewKeyDown(
 //---------------------------------------------------------------------------
 void __fastcall TPreferencesDialog::EditorMove(int Source, int Dest)
 {
-  if (Source >= 0 && Source < FEditorList->Count &&
-      Dest >= 0 && Dest < FEditorList->Count)
-  {
-    FEditorList->Move(Source, Dest);
-    EditorListView3->ItemIndex = Dest;
-    UpdateEditorListView();
-    UpdateControls();
-  }
+  FEditorList->Move(Source, Dest);
+  EditorListView3->ItemIndex = Dest;
+  UpdateEditorListView();
+  UpdateControls();
 }
 //---------------------------------------------------------------------------
 void __fastcall TPreferencesDialog::EditorListView3DragDrop(TObject * Sender,

+ 1 - 1
source/forms/Preferences.dfm

@@ -2299,7 +2299,7 @@ object PreferencesDialog: TPreferencesDialog
             OnDblClick = CopyParamListViewDblClick
             OnEndDrag = ListViewEndDrag
             OnDragDrop = CopyParamListViewDragDrop
-            OnDragOver = ListViewDragOver
+            OnDragOver = CopyParamListViewDragOver
             OnKeyDown = CopyParamListViewKeyDown
             OnSelectItem = ListViewSelectItem
             OnStartDrag = ListViewStartDrag

+ 1 - 0
source/forms/Preferences.h

@@ -417,6 +417,7 @@ __published:
   void __fastcall CustomIniFileStorageEditExit(TObject *Sender);
   void __fastcall CustomIniFileStorageEditAfterDialog(TObject *Sender, UnicodeString &Name, bool &Action);
   void __fastcall CustomIniFileStorageButtonClick(TObject *Sender);
+  void __fastcall CopyParamListViewDragOver(TObject *Sender, TObject *Source, int X, int Y, TDragState State, bool &Accept);
 
 private:
   TPreferencesMode FPreferencesMode;