Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 654dace
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 10 deletions.
10 changes: 9 additions & 1 deletion out/locale/en/LC_MESSAGES/default.po
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion source/exportgrid.pas
Expand Up @@ -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);
Expand Down
11 changes: 11 additions & 0 deletions source/main.dfm
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
38 changes: 30 additions & 8 deletions source/main.pas
Expand Up @@ -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);
Expand Down Expand Up @@ -1046,6 +1048,7 @@ TMainForm = class(TForm)
FPreferencesDialog: Toptionsform;
FCreateDatabaseDialog: TCreateDatabaseForm;
FGridEditFunctionMode: Boolean;
FClipboardHasNull: Boolean;
FTimeZoneOffset: Integer;
FGridCopying: Boolean;
FGridPasting: Boolean;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 654dace

Please sign in to comment.