View Issue Details

IDProjectCategoryView StatusLast Update
0015851LazarusIDEpublic2010-03-30 10:15
ReporterFlávio Etrusco Assigned ToPaul Ishenin  
PrioritynormalSeverityminorReproducibilityN/A
Status closedResolutionfixed 
Product Version0.9.29 (SVN) 
Fixed in Version0.9.29 (SVN) 
Summary0015851: [patch] Fix Search Results dialog DblClick behavior and implement Copy to Clipboard
DescriptionAttached patch fix double-click behavior of "Search Results" dialog (dialog uses MsgViewConfig settings but invert the behavior) and a PopupMenu with add "Copy to Clipboard" commands.
TagsNo tags attached.
Fixed in Revision23809
LazTarget-
Widgetset
Attached Files

Activities

2010-02-26 17:36

 

SearchResults_r23798.patch (5,696 bytes)   
# HG changeset patch
# User etrusco <flavio.etrusco@gmail.com>
# Date 1267192746 10800
# Branch trunk
# Node ID 1bab351dcf88db3c84956a5f897e35c380b0a597
# Parent  3f1722e726cd6b3f3c9267eeb5a93023d9394da7
[mq]: searchview_popup

diff --git a/ide/lazarusidestrconsts.pas b/ide/lazarusidestrconsts.pas
--- a/ide/lazarusidestrconsts.pas
+++ b/ide/lazarusidestrconsts.pas
@@ -280,6 +280,9 @@ resourcestring
   lisCopyAllMessagesToClipboard = 'Copy all messages to clipboard';
   lisCopyAllAndHiddenMessagesToClipboard = 'Copy all and hidden messages '
                                            +'to clipboard';
+  lisCopyItemToClipboard = 'Copy item to clipboard';
+  lisCopySelectedItemToClipboard = 'Copy selected items to clipboard';
+  lisCopyAllItemsToClipboard = 'Copy all items to clipboard';
   lisSaveAllMessagesToFile = 'Save all messages to file';
   lisMVDocking = 'Docking';
   lisMenuViewSearchResults = 'Search Results';
diff --git a/ide/searchresultview.lfm b/ide/searchresultview.lfm
--- a/ide/searchresultview.lfm
+++ b/ide/searchresultview.lfm
@@ -254,4 +254,20 @@ object SearchResultsView: TSearchResults
       0000000000000000000000000000
     }
   end
+  object popList: TPopupMenu
+    left = 190
+    top = 133
+    object mniCopyItem: TMenuItem
+      Caption = 'Copy Item'
+      OnClick = mniCopyItemClick
+    end
+    object mniCopyAll: TMenuItem
+      Caption = 'Copy All'
+      OnClick = mniCopyAllClick
+    end
+    object mniCopySelected: TMenuItem
+      Caption = 'Copy Selected'
+      OnClick = mniCopySelectedClick
+    end
+  end
 end
diff --git a/ide/searchresultview.pp b/ide/searchresultview.pp
--- a/ide/searchresultview.pp
+++ b/ide/searchresultview.pp
@@ -38,9 +38,9 @@ interface
 
 uses
   Classes, SysUtils, LCLProc, Forms, Controls, Graphics, Dialogs,
-  ComCtrls, ExtCtrls, StdCtrls, Buttons, LCLType, LCLIntf,
+  ComCtrls, ExtCtrls, StdCtrls, Buttons, LCLType, LCLIntf, Menus,
   IDEOptionDefs, LazarusIDEStrConsts, EnvironmentOpts, EditorOptions, InputHistory,
-  IDEProcs, FindInFilesDlg, Project, MainIntf;
+  IDEProcs, FindInFilesDlg, Project, MainIntf, Clipbrd;
 
 type
   { TLazSearchMatchPos }
@@ -129,6 +129,10 @@ type
   { TSearchResultsView }
 
   TSearchResultsView = class(TForm)
+    mniCopySelected: TMenuItem;
+    mniCopyAll: TMenuItem;
+    mniCopyItem: TMenuItem;
+    popList: TPopupMenu;
     SearchInListEdit: TEdit;
     ImageList: TImageList;
     ResultsNoteBook: TNotebook;
@@ -142,6 +146,9 @@ type
     procedure ClosePageButtonClick(Sender: TObject);
     procedure Form1Create(Sender: TObject);
     procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
+    procedure mniCopyAllClick(Sender: TObject);
+    procedure mniCopyItemClick(Sender: TObject);
+    procedure mniCopySelectedClick(Sender: TObject);
     procedure TreeViewKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
     procedure ResultsNoteBookClosetabclicked(Sender: TObject);
     procedure SearchAgainButtonClick(Sender: TObject);
@@ -225,6 +232,22 @@ begin
   Result := True;
 end;
   
+function GetTreeSelectedItemsAsText(ATreeView: TCustomTreeView): string;
+var
+  sl: TStringList;
+  node: TTreeNode;
+begin
+  sl:=TStringList.Create;
+  node := ATreeView.GetFirstMultiSelected;
+  while assigned(node) do
+  begin
+    sl.Add(node.Text);
+    node := node.GetNextMultiSelected;
+  end;
+  Result:=sl.Text;
+  sl.Free;
+end;
+
 procedure TSearchResultsView.Form1Create(Sender: TObject);
 var
   ALayout: TIDEWindowLayout;
@@ -251,6 +274,10 @@ begin
   fOnSelectionChanged:= nil;
   ShowHint:= True;
   fMouseOverIndex:= -1;
+
+  mniCopyItem.Caption := lisCopyItemToClipboard;
+  mniCopySelected.Caption := lisCopySelectedItemToClipboard;
+  mniCopyAll.Caption := lisCopyAllItemsToClipboard;
 end;//Create
 
 procedure TSearchResultsView.FormKeyDown(Sender: TObject; var Key: Word; 
@@ -263,6 +290,32 @@ begin
   end;  
 end;
 
+procedure TSearchResultsView.mniCopyAllClick(Sender: TObject);
+var
+  sl: TStrings;
+begin
+  sl := (popList.PopupComponent as TLazSearchResultTV).ItemsAsStrings;
+  Clipboard.AsText := sl.Text;
+  sl.Free;
+end;
+
+procedure TSearchResultsView.mniCopyItemClick(Sender: TObject);
+var
+  tv: TCustomTreeView;
+  node: TTreeNode;
+begin
+  tv := popList.PopupComponent as TCustomTreeView;
+  with tv.ScreenToClient(popList.PopupPoint) do
+    node := tv.GetNodeAt(X, Y);
+  if node <> nil then
+    Clipboard.AsText := node.Text;
+end;
+
+procedure TSearchResultsView.mniCopySelectedClick(Sender: TObject);
+begin
+  Clipboard.AsText := GetTreeSelectedItemsAsText(popList.PopupComponent as TCustomTreeView);
+end;
+
 procedure TSearchResultsView.ClosePageButtonClick(Sender: TObject);
 begin
   ClosePage(ResultsNoteBook.PageIndex);
@@ -770,6 +823,8 @@ begin
             OnMouseWheel:= @LazTVMouseWheel;
             ShowHint:= true;
             RowSelect := True;
+            Options := Options + [tvoAllowMultiselect];
+            PopupMenu := popList;
             NewTreeView.Canvas.Brush.Color:= clWhite;
           end;//with
         end;//if
@@ -889,14 +944,14 @@ end;//TreeViewDrawItem
 
 procedure TSearchResultsView.TreeViewClicked(Sender: TObject);
 begin
-  if EnvironmentOptions.MsgViewDblClickJumps then exit;
+  if not EnvironmentOptions.MsgViewDblClickJumps then exit;
   if Assigned(fOnSelectionChanged) then
     fOnSelectionChanged(Self)
 end;//TreeViewClicked
 
 procedure TSearchResultsView.TreeViewDoubleClicked(Sender: TObject);
 begin
-  if not EnvironmentOptions.MsgViewDblClickJumps then exit;
+  if EnvironmentOptions.MsgViewDblClickJumps then exit;
   if Assigned(fOnSelectionChanged) then
     fOnSelectionChanged(Self)
 end;//TreeViewDoubleClicked
SearchResults_r23798.patch (5,696 bytes)   

Flávio Etrusco

2010-02-26 17:37

developer   ~0034811

Last edited: 2010-02-27 14:44

Oops: forgot to mention that is enables MultiSelect too.
Opps2: of course my patch is bogus regarding Click/DblClick. Please the relevant (two) lines, or I can provide an updated patch.

2010-03-01 05:25

 

SearchResults_r23798_svn.patch (5,655 bytes)   
Index: ide/lazarusidestrconsts.pas
===================================================================
--- ide/lazarusidestrconsts.pas	(revision 23798)
+++ ide/lazarusidestrconsts.pas	(working copy)
@@ -280,6 +280,9 @@ resourcestring
   lisCopyAllMessagesToClipboard = 'Copy all messages to clipboard';
   lisCopyAllAndHiddenMessagesToClipboard = 'Copy all and hidden messages '
                                            +'to clipboard';
+  lisCopyItemToClipboard = 'Copy item to clipboard';
+  lisCopySelectedItemToClipboard = 'Copy selected items to clipboard';
+  lisCopyAllItemsToClipboard = 'Copy all items to clipboard';
   lisSaveAllMessagesToFile = 'Save all messages to file';
   lisMVDocking = 'Docking';
   lisMenuViewSearchResults = 'Search Results';
Index: ide/searchresultview.lfm
===================================================================
--- ide/searchresultview.lfm	(revision 23798)
+++ ide/searchresultview.lfm	(working copy)
@@ -254,4 +254,20 @@ object SearchResultsView: TSearchResults
       0000000000000000000000000000
     }
   end
+  object popList: TPopupMenu
+    left = 190
+    top = 133
+    object mniCopyItem: TMenuItem
+      Caption = 'Copy Item'
+      OnClick = mniCopyItemClick
+    end
+    object mniCopyAll: TMenuItem
+      Caption = 'Copy All'
+      OnClick = mniCopyAllClick
+    end
+    object mniCopySelected: TMenuItem
+      Caption = 'Copy Selected'
+      OnClick = mniCopySelectedClick
+    end
+  end
 end
Index: ide/searchresultview.pp
===================================================================
--- ide/searchresultview.pp	(revision 23798)
+++ ide/searchresultview.pp	(working copy)
@@ -38,9 +38,9 @@ interface
 
 uses
   Classes, SysUtils, LCLProc, Forms, Controls, Graphics, Dialogs,
-  ComCtrls, ExtCtrls, StdCtrls, Buttons, LCLType, LCLIntf,
+  ComCtrls, ExtCtrls, StdCtrls, Buttons, LCLType, LCLIntf, Menus,
   IDEOptionDefs, LazarusIDEStrConsts, EnvironmentOpts, EditorOptions, InputHistory,
-  IDEProcs, FindInFilesDlg, Project, MainIntf;
+  IDEProcs, FindInFilesDlg, Project, MainIntf, Clipbrd;
 
 type
   { TLazSearchMatchPos }
@@ -129,6 +129,10 @@ type
   { TSearchResultsView }
 
   TSearchResultsView = class(TForm)
+    mniCopySelected: TMenuItem;
+    mniCopyAll: TMenuItem;
+    mniCopyItem: TMenuItem;
+    popList: TPopupMenu;
     SearchInListEdit: TEdit;
     ImageList: TImageList;
     ResultsNoteBook: TNotebook;
@@ -142,6 +146,9 @@ type
     procedure ClosePageButtonClick(Sender: TObject);
     procedure Form1Create(Sender: TObject);
     procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
+    procedure mniCopyAllClick(Sender: TObject);
+    procedure mniCopyItemClick(Sender: TObject);
+    procedure mniCopySelectedClick(Sender: TObject);
     procedure TreeViewKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
     procedure ResultsNoteBookClosetabclicked(Sender: TObject);
     procedure SearchAgainButtonClick(Sender: TObject);
@@ -225,6 +232,22 @@ begin
   Result := True;
 end;
   
+function GetTreeSelectedItemsAsText(ATreeView: TCustomTreeView): string;
+var
+  sl: TStringList;
+  node: TTreeNode;
+begin
+  sl:=TStringList.Create;
+  node := ATreeView.GetFirstMultiSelected;
+  while assigned(node) do
+  begin
+    sl.Add(node.Text);
+    node := node.GetNextMultiSelected;
+  end;
+  Result:=sl.Text;
+  sl.Free;
+end;
+
 procedure TSearchResultsView.Form1Create(Sender: TObject);
 var
   ALayout: TIDEWindowLayout;
@@ -251,6 +274,10 @@ begin
   fOnSelectionChanged:= nil;
   ShowHint:= True;
   fMouseOverIndex:= -1;
+
+  mniCopyItem.Caption := lisCopyItemToClipboard;
+  mniCopySelected.Caption := lisCopySelectedItemToClipboard;
+  mniCopyAll.Caption := lisCopyAllItemsToClipboard;
 end;//Create
 
 procedure TSearchResultsView.FormKeyDown(Sender: TObject; var Key: Word; 
@@ -263,6 +290,32 @@ begin
   end;  
 end;
 
+procedure TSearchResultsView.mniCopyAllClick(Sender: TObject);
+var
+  sl: TStrings;
+begin
+  sl := (popList.PopupComponent as TLazSearchResultTV).ItemsAsStrings;
+  Clipboard.AsText := sl.Text;
+  sl.Free;
+end;
+
+procedure TSearchResultsView.mniCopyItemClick(Sender: TObject);
+var
+  tv: TCustomTreeView;
+  node: TTreeNode;
+begin
+  tv := popList.PopupComponent as TCustomTreeView;
+  with tv.ScreenToClient(popList.PopupPoint) do
+    node := tv.GetNodeAt(X, Y);
+  if node <> nil then
+    Clipboard.AsText := node.Text;
+end;
+
+procedure TSearchResultsView.mniCopySelectedClick(Sender: TObject);
+begin
+  Clipboard.AsText := GetTreeSelectedItemsAsText(popList.PopupComponent as TCustomTreeView);
+end;
+
 procedure TSearchResultsView.ClosePageButtonClick(Sender: TObject);
 begin
   ClosePage(ResultsNoteBook.PageIndex);
@@ -770,6 +823,8 @@ begin
             OnMouseWheel:= @LazTVMouseWheel;
             ShowHint:= true;
             RowSelect := True;
+            Options := Options + [tvoAllowMultiselect];
+            PopupMenu := popList;
             NewTreeView.Canvas.Brush.Color:= clWhite;
           end;//with
         end;//if
@@ -889,14 +944,14 @@ end;//TreeViewDrawItem
 
 procedure TSearchResultsView.TreeViewClicked(Sender: TObject);
 begin
-  if EnvironmentOptions.MsgViewDblClickJumps then exit;
+  if not EnvironmentOptions.MsgViewDblClickJumps then exit;
   if Assigned(fOnSelectionChanged) then
     fOnSelectionChanged(Self)
 end;//TreeViewClicked
 
 procedure TSearchResultsView.TreeViewDoubleClicked(Sender: TObject);
 begin
-  if not EnvironmentOptions.MsgViewDblClickJumps then exit;
+  if EnvironmentOptions.MsgViewDblClickJumps then exit;
   if Assigned(fOnSelectionChanged) then
     fOnSelectionChanged(Self)
 end;//TreeViewDoubleClicked
SearchResults_r23798_svn.patch (5,655 bytes)   

Paul Ishenin

2010-03-01 05:30

manager   ~0034861

Thanks, applied. Please close if ok.

Issue History

Date Modified Username Field Change
2010-02-26 17:36 Flávio Etrusco New Issue
2010-02-26 17:36 Flávio Etrusco File Added: SearchResults_r23798.patch
2010-02-26 17:37 Flávio Etrusco Note Added: 0034811
2010-02-27 14:44 Flávio Etrusco Note Edited: 0034811
2010-03-01 05:25 Paul Ishenin File Added: SearchResults_r23798_svn.patch
2010-03-01 05:30 Paul Ishenin Fixed in Revision => 23809
2010-03-01 05:30 Paul Ishenin LazTarget => -
2010-03-01 05:30 Paul Ishenin Status new => resolved
2010-03-01 05:30 Paul Ishenin Fixed in Version => 0.9.29 (SVN)
2010-03-01 05:30 Paul Ishenin Resolution open => fixed
2010-03-01 05:30 Paul Ishenin Assigned To => Paul Ishenin
2010-03-01 05:30 Paul Ishenin Note Added: 0034861
2010-03-30 10:15 Flávio Etrusco Status resolved => closed