New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy rows + header to ClipBoard #1058

Closed
sky5walk opened this Issue Jul 20, 2017 · 21 comments

Comments

Projects
None yet
5 participants
@sky5walk
Copy link

sky5walk commented Jul 20, 2017

Details for the issue

A quick/useful feature I miss from spreadsheets and other db browsers is copying rows of a table into the clipboard along with the header line for that selection.

Please add a 'copy special' or 'copy with headers' menu pick.

I then paste the clipboard contents into various tools like plotting or calculators that use the header info for labeling and assignments.

Useful extra information

This would save the extra steps of clicking export to csv and copying the resulting file to clipboard, when I am browsing and filtering as the name of this app is called :)

I'm opening this issue because:

  • DB4S is crashing
  • DB4S has a bug
  • DB4S needs a feature
  • DB4S has another problem

I'm using DB4S on:

  • Windows: ( _version:_10 Pro x64 ___ )
  • Linux: ( distro: ___ )
  • Mac OS: ( version: ___ )
  • Other: ___

I'm using DB4S version:

  • 3.9.1
  • 3.9.0
  • Other: latest nightly build, 3.9.99

I have also:

@justinclift

This comment has been minimized.

Copy link
Member

justinclift commented Jul 20, 2017

Yep, good idea. 😄

@beRto-

This comment has been minimized.

Copy link

beRto- commented Sep 21, 2017

I came hear looking for this exact same thing! I would also really appreciate this feature being added!

mgrojo added a commit that referenced this issue Nov 4, 2017

Copy rows + header to clipboard
A new option in the context menu of the table widget is added for copying
to clipboard the content of the selected cells prepended with the
appropiate column names.

See issue #1058
@mgrojo

This comment has been minimized.

Copy link
Contributor

mgrojo commented Nov 11, 2017

@sky5walk and @beRto-, the current nightly builds should have the functionality you wanted. Could you test it and consider closing this issue or commenting further some detail?

@beRto-

This comment has been minimized.

Copy link

beRto- commented Nov 12, 2017

@mgrojo - It worked well for me. Thanks for adding this!

I downloaded the nightly Version 3.10.99 (Nov 11 2017) and found that after highlighting content, I could right-click to "Copy with Headers". So this solves the base functionality, which is a big plus!

If I may make a couple of further suggestions:

  1. enable a keyboard shortcut for this, like maybe "CTRL+H" copies with headers. (Although maybe there is already a way to define custom keyboard shortcuts? - sorry, I am not familiar enough.)
  2. or if above suggestion is not preferable, maybe put a checkbox in Preferences so that the user can choose to have Copy with Header the default action on CTRL+C (and use the right click menu in rarer case when they want to copy without headers)?

mgrojo added a commit that referenced this issue Nov 12, 2017

New shortcut for Copy with Headers and some self-documented shortcuts
Ctrl+H invokes the Copy with Headersers action in the Extended Table Widget
as suggested in #1058.

The following options in context menu display now their shortcuts:
Set to Null, Copy, Copy with Headers and Paste.

Some other shortcuts are now displayed in the corresponding tooltips.
@mgrojo

This comment has been minimized.

Copy link
Contributor

mgrojo commented Nov 12, 2017

@beRto- Thanks for the feedback. I've added "Ctrl+H" as shortcut for "Copy with Headers". I'll close now this issue.

@mgrojo mgrojo closed this Nov 12, 2017

@sky5walk

This comment has been minimized.

Copy link
Author

sky5walk commented Nov 15, 2017

Thanks for the new feature! :)
Followup question --> Why are all entries returned in double quotes?
"xx"[TAB]"yy"[TAB]"1234"[CR][LF]
Is this to allow a TAB character within the data?
Could you add an option to drop all double quotes and just return contents [TAB] or [Comma] delimited?

Thanks

@sky5walk

This comment has been minimized.

Copy link
Author

sky5walk commented Nov 15, 2017

I'm trying to mimic the CSV export functionality in a quicker action and on smaller selections.

@justinclift justinclift reopened this Nov 15, 2017

@mgrojo

This comment has been minimized.

Copy link
Contributor

mgrojo commented Nov 18, 2017

@sky5walk that is the current behavior for the regular copy and I've just followed that way. This seems perfect for pasting into spreadsheets or inside the application (although in this case pasting the header makes no sense).

I'm not sure whether the way to go is adding options to the copy. What if the export to CSV had the possibility for choosing the current selection additionally to the list of tables?

Another interesting functionality would be that the copy to clipboard be a table in rich format, so it pastes as a table in other applications, like text processors.

I noticed also that pasting back the data from Librecalc pastes an image in the cells, this is not what I expected.

I'll take a look to all of this.

@mgrojo mgrojo self-assigned this Nov 18, 2017

@sky5walk

This comment has been minimized.

Copy link
Author

sky5walk commented Nov 18, 2017

As a compromise for copy and paste cells, why not follow the datatypes of the columns selected?
Meaning, if I copy a row with 3 columns of "Text, Real, Text", then the clipboard would be:
"TEXTCOL1", "REALCOL2", "TEXTCOL3"[CR][LF]
"sometext",1234,"moretext"[CR][LF] --<-- note the numeric data has no double quotes.

mgrojo added a commit that referenced this issue Nov 18, 2017

Clipboard improvements: HTML and avoid pasting image from LibreCalc
Both "Copy" and "Copy with Headers" write in HTML and text format to the
system clipboard, when the selection includes more than one cell. This lets
the pasting application choose the most appropriate format.

Images have now no precedence over text when requesting the clipboard
content, so pasting from applications like LibreCalc, that set both formats
in the clipboard, works as expected, instead of pasting an image of the
copied text.

Copying and pasting inside the DB4S should not be affected, since the
application requests the text format and uses the internal buffer when
necessary (binary data included).

Related issue: #1058
@mgrojo

This comment has been minimized.

Copy link
Contributor

mgrojo commented Nov 18, 2017

@sky5walk and @beRto- I have added copying to clipboard both in text (quoted format as before) and HTML (unquoted as expected). This improves pasting to spreadsheets and word processors (Thunderbird refuses the HTML version, though). I've only tested with Linux and the clipboard is usually a source of problems for portability. Could you or someone test it in Windows and Mac OS with the next nightly build? Specially with Excel, which according to sources, likes to open new rows for cells with broken lines. Thanks.

@sky5walk, the text format is used in the application for internal copy/paste. I think your suggestion wouldn't break anything, but I'd prefer not modifying the text version. Gives the HTML version good results for you?

mgrojo added a commit that referenced this issue Nov 18, 2017

Usability improvements for Extended Table Widget and SQL
results pane

Copy for multi-line text data surrounds the text with the
<pre> tag in the HTML version for avoiding line white-space
adjustments in the pasted text. See #1058

Do not use binary data in the "Use as Filter" option.

Indicate the existence of an error in the background of the
SQL results frame. The error-indicators is reused for
disabling this functionality.

When nothing is shown, a placeholder text hints the
objective of the results pane.

The preference label for the font size of this pane is
modified for consistency (SQL Log is another widget).
@sky5walk

This comment has been minimized.

Copy link
Author

sky5walk commented Nov 23, 2017

Thanks, I checked the 171124 nightly and my copies to clipboard in either mode, [Ctrl+C] or [Ctrl+H], return the same. There are double quotes surrounding my numeric data. How to enable the HTML mode? Is that user select or algorithmic?

@sky5walk

This comment has been minimized.

Copy link
Author

sky5walk commented Nov 24, 2017

Maybe I am misunderstanding the HTML mode?
Currently, I have to modify my own apps' parsers when scanning clipboard data to key on the header to specify numeric or text. Because all clipboard columns are now double-quoted, I have to convert values to numeric for each cell, atof(),etc. I'm not sure the algorithm MS Excel uses, but that is bloated and slow for sure. If the double quotes only surround text or just not there, I save this step.

@mgrojo

This comment has been minimized.

Copy link
Contributor

mgrojo commented Nov 24, 2017

@sky5walk the clipboard can store data in different formats. We are now copying to clipboard in HTML and plain text formats at the same time, so there is no option for HTML mode. Both modes are available and it's the duty of the receiving application to select the desired format. I guess your application is getting the text format, and, as you've already mentioned, parsing that will be more difficult than the plain text version.

@mgrojo

This comment has been minimized.

Copy link
Contributor

mgrojo commented Nov 24, 2017

But changing the text version in DB4S is risky because it is the format used inside the application for copying and pasting in the DB tables. In any case, your suggestion deserves a new issue. Hopefully, it might get attention form MKleusberg or other more experienced DB4S developer so he can give his insight about that change.

@sky5walk

This comment has been minimized.

Copy link
Author

sky5walk commented Nov 25, 2017

Ok, let me summarize this way.
Is it risky to follow the cut/paste behavior of MS Excel?
Why add double quotes around each cell's contents?

@mgrojo

This comment has been minimized.

Copy link
Contributor

mgrojo commented Nov 25, 2017

The internal copy/paste inside the application uses the quotes to differentiate NULL values from empty strings and maybe for other objectives. I don't know this code very much, maybe @MKleusberg can give a better explanation.

There is a workaround for getting the data without quotes. It is using Excel as an intermediary, since it understand the quoted data, but copies the data without quotes. Then you can paste in your application. I hope this helps.

mgrojo added a commit that referenced this issue Nov 25, 2017

Find/Replace dialog for SQL editors and logs
A classic Find/Replace dialog including all the options provided
by the QScintilla editor. Additionally a "Replace All" and a
Find All" button are implemented. This complements issue #191

New shortcut in main window for opening the find/replace dialog
connected to the focused widget. Standard for Replace is Ctrl+H.
Consequently the shortcut for Copy with Headers is changed to
Ctrl+Shift+C (see issue #1058).

For SQL text widgets not embedded in the main window, the standard
shortcut cannot be enabled, otherwise it conflicts with the main
window. Therefore the shortcut Ctrl+Shift+H is enabled for all the
SQL widgets as fallback. A better solution would be desirable.
@sky5walk

This comment has been minimized.

Copy link
Author

sky5walk commented Nov 26, 2017

Yes, [Ctrl+H] is better left for Replace. [Ctrl+Shift+C] is fine.

@sky5walk

This comment has been minimized.

Copy link
Author

sky5walk commented Nov 26, 2017

mgrojo

"There is a workaround for getting the data without quotes. It is using Excel as an intermediary, since it understand the quoted data, but copies the data without quotes. Then you can paste in your application."

I do not need this workaround since I code my own parser. But, I have to make a special case only for DB Browser for SQLite? Even copying table data from a web page does not add these double quotes around every cell?

@beRto-

This comment has been minimized.

Copy link

beRto- commented Nov 29, 2017

@MKleusberg

This comment has been minimized.

Copy link
Member

MKleusberg commented Nov 29, 2017

@beRto- is probably right 😄 So here's the new issue: #1244. I'll have a look at the code and update that issue later.

Can we close this one then?

@sky5walk

This comment has been minimized.

Copy link
Author

sky5walk commented Nov 29, 2017

Yes, this issue can be closed, now that you spawned the double-quoting issue.
Thanks for the feature!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment