Permalink
Browse files

Create a new menu item for copying rows to clipboard, and assign Ctr+…

  • Loading branch information...
ansgarbecker committed Mar 7, 2017
1 parent 47458f5 commit 654dace6887a567ea621f7ac693f077927142477
Showing with 51 additions and 10 deletions.
  1. +9 −1 out/locale/en/LC_MESSAGES/default.po
  2. +1 −1 source/exportgrid.pas
  3. +11 −0 source/main.dfm
  4. +30 −8 source/main.pas
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: HeidiSQL\n"
"POT-Creation-Date: 2012-11-05 21:40\n"
"PO-Revision-Date: 2017-03-06 20:22+0100\n"
"PO-Revision-Date: 2017-03-07 21:07+0100\n"
"Last-Translator: Ansgar Becker <anse@heidisql.com>\n"
"Language-Team: English (http://www.transifex.com/projects/p/heidisql/"
"language/en/)\n"
@@ -3354,6 +3354,14 @@ msgstr "Remove column"
msgid "Copy selected columns"
msgstr "Copy selected columns"
#. grid export
msgid "Copy selected rows"
msgstr "Copy selected rows"
#. grid export
msgid "Copy selected rows in custom format"
msgstr "Copy selected rows in custom format"
#. frmTableEditor..popupColumns..menuPasteColumns..Caption
#: table_editor.dfm:803
msgid "Paste columns"
View
@@ -113,7 +113,7 @@ procedure TfrmExportGrid.FormCreate(Sender: TObject);
grpFormat.Items.Clear;
for FormatDesc in FFormatToDescription do
grpFormat.Items.Add(FormatDesc);
FHiddenCopyMode := (Owner = MainForm.actCopy) or (Owner = MainForm.actCut);
FHiddenCopyMode := Owner = MainForm.actCopyRows;
if FHiddenCopyMode then begin
grpFormat.ItemIndex := AppSettings.ReadInt(asGridExportClpFormat);
View
@@ -2883,6 +2883,14 @@ object MainForm: TMainForm
ShortCut = 16437
OnExecute = actGotoTabNumberExecute
end
object actCopyRows: TAction
Category = 'Various'
Caption = 'Copy selected rows'
Hint = 'Copy selected rows in custom format'
ImageIndex = 155
ShortCut = 24643
OnExecute = actCopyOrCutExecute
end
end
object menuConnections: TPopupMenu
AutoHotkeys = maManual
@@ -9446,6 +9454,9 @@ object MainForm: TMainForm
object Copy3: TMenuItem
Action = actCopy
end
object Copyselectedrows1: TMenuItem
Action = actCopyRows
end
object Paste2: TMenuItem
Action = actPaste
end
View
@@ -639,6 +639,8 @@ TMainForm = class(TForm)
actGotoTab41: TMenuItem;
actGotoTab51: TMenuItem;
ToolButton11: TToolButton;
actCopyRows: TAction;
Copyselectedrows1: TMenuItem;
procedure actCreateDBObjectExecute(Sender: TObject);
procedure menuConnectionsPopup(Sender: TObject);
procedure actExitApplicationExecute(Sender: TObject);
@@ -1046,6 +1048,7 @@ TMainForm = class(TForm)
FPreferencesDialog: Toptionsform;
FCreateDatabaseDialog: TCreateDatabaseForm;
FGridEditFunctionMode: Boolean;
FClipboardHasNull: Boolean;
FTimeZoneOffset: Integer;
FGridCopying: Boolean;
FGridPasting: Boolean;
@@ -8713,6 +8716,7 @@ procedure TMainForm.AnyGridNewText(Sender: TBaseVirtualTree; Node: PVirtualNode;
Results: TDBQuery;
RowNum: PInt64;
Timestamp: Int64;
IsNull: Boolean;
begin
Results := GridResult(Sender);
RowNum := Sender.GetNodeData(Node);
@@ -8726,7 +8730,8 @@ procedure TMainForm.AnyGridNewText(Sender: TBaseVirtualTree; Node: PVirtualNode;
end else
NewText := NewText;
end;
Results.SetCol(Column, NewText, False, FGridEditFunctionMode);
IsNull := FGridPasting and FClipboardHasNull;
Results.SetCol(Column, NewText, IsNull, FGridEditFunctionMode);
except
on E:EDatabaseError do
ErrorDialog(E.Message);
@@ -9613,18 +9618,22 @@ procedure TMainForm.actCopyOrCutExecute(Sender: TObject);
Combo: TCustomComboBox;
Grid: TVirtualStringTree;
SynMemo: TSynMemo;
Success, DoCut: Boolean;
Success, DoCut, DoCopyRows: Boolean;
IsResultGrid: Boolean;
ClpFormat: Word;
ClpData: THandle;
APalette: HPalette;
Exporter: TSynExporterRTF;
Results: TDBQuery;
RowNum: PInt64;
ExportDialog: TfrmExportGrid;
begin
// Copy text from a focused control to clipboard
Success := False;
Control := Screen.ActiveControl;
DoCut := Sender = actCut;
DoCopyRows := Sender = actCopyRows;
FClipboardHasNull := False;
SendingControl := (Sender as TAction).ActionComponent;
Screen.Cursor := crHourglass;
try
@@ -9652,12 +9661,25 @@ procedure TMainForm.actCopyOrCutExecute(Sender: TObject);
IsResultGrid := Grid = ActiveGrid;
FGridCopying := True;
if IsResultGrid then begin
ExportDialog := TfrmExportGrid.Create(Sender as TAction);
ExportDialog.Grid := Grid;
ExportDialog.btnOK.Click;
ExportDialog.Free;
if DoCut then
Grid.Text[Grid.FocusedNode, Grid.FocusedColumn] := '';
if DoCopyRows then begin
ExportDialog := TfrmExportGrid.Create(Sender as TAction);
ExportDialog.Grid := Grid;
ExportDialog.btnOK.Click;
ExportDialog.Free;
end else begin
// Handle NULL values in grids, see issue #3171
AnyGridEnsureFullRow(Grid, Grid.FocusedNode);
Results := GridResult(Grid);
RowNum := Grid.GetNodeData(Grid.FocusedNode);
Results.RecNo := RowNum^;
if Results.IsNull(Grid.FocusedColumn) then begin
Clipboard.AsText := '';
FClipboardHasNull := True;
end else
Clipboard.AsText := Grid.Text[Grid.FocusedNode, Grid.FocusedColumn];
if DoCut then
Grid.Text[Grid.FocusedNode, Grid.FocusedColumn] := '';
end;
end else
Clipboard.AsText := Grid.Text[Grid.FocusedNode, Grid.FocusedColumn];
FGridCopying := False;

0 comments on commit 654dace

Please sign in to comment.