Commit Graph

90 Commits

Author SHA1 Message Date
Manuel
d343a55286 Merge pull request #1473 from sqlitebrowser/filter_strings
Support for operator filters for strings
2018-08-08 14:39:02 +02:00
mgrojo
b37df2cf62 Only enable filter actions when Extended Table has filter lines
When the filter lines have not been generated for a Extended Table
(currently the case for Execute SQL tables), the filter actions make no
sense, so they are disabled.

See issue #1469
2018-07-13 00:25:11 +02:00
mgrojo
4c9f55660b Support for operator filters for strings
This adds support for all operators when applied to string values.
Formerly they were always treated as a Containing (LIKE) operator, but
after the implementation of bbe2e33ea4 the
lack of these operators were more visible and, at least, the omission of
<> seems a bug. But the omission of the others may also be a limitation.

For easing the return to the old behaviour, the Containing filter option
now takes into account the necessity of escaping the value when it starts
by one of the operator characters.

For operators applied to strings the behaviour is documented by Sqlite3
here: https://www.sqlite.org/datatype3.html#collating_sequences

See related issue #1463.
2018-07-12 22:48:49 +02:00
mgrojo
bbe2e33ea4 Issue #1463: give assistance to users in using the filters
Added contextual menus in filter line box and cells for assisting in using
filters and for discovering existing filters.

The menu in the filter line adds "What's This" option and helper options
that add the operator and a selected placeholder (?) for easy editing.
Special options for NULL and empty strings are also added. Those work
directly.

The menu in the cells works as the current "Use as Filter" but for
different operators. In this case, only the range operator is incomplete.

Currently, not all the operators make sense for strings because we take
them as LIKE filters. At least the Not Equal filter (<>) should work, but
the other would also make sense. This will be addressed in future commits.
2018-07-08 14:29:52 +02:00
mgrojo
6b78b13871 Improvements for "Copy as SQL" feature (PR #1422)
- Set the line terminator according to operating system (text and SQL
versions).

- Quote identifiers using the user preference and string literals as 'SQL
standard'.

- Support BLOB literals for any kind of binary data and avoid converting
any kind of image to PNG in the process of setting the BLOB literal in SQL.
2018-07-07 20:36:25 +02:00
Manuel
cff07955df Merge pull request #1422 from GortiZ6/sql_export
As said by the author GortiZ6:
> I've added the ability to copy fields from tables in SQL format.
> I found much robust and easier copy data in SQL from one DB to another so that if the number of columns differs or if I want to build a single SQL file to share several fields from several table with someone I can do it.
2018-07-07 18:31:27 +02:00
Giuseppe Zizza
3d2e8205a0 [CHG] Converted to HEX from Base64 the image SQL export
[CHG] Using sqlb::escapeIdentifier() for table quotation to uniform with the rest of the code
2018-06-12 13:44:18 +02:00
Martin Kleusberg
3da520cdd1 Clean up multi threading patch, fix build and some bugs
Make strings translatable, remove some more debug code, fix tests,
reduce size of patch slightly, remove weird tooltip, don't crash when
closing database, simplify code, fix filters, don't link agains pthread
on Windows.
2018-06-08 22:46:47 +02:00
Martin Kleusberg
51dbe72e23 Multi-threading patch
This was done by Michael Krause.
https://lists.sqlitebrowser.org/pipermail/db4s-dev/2018-February/000305.html

In this commit I only fixed two compiler warnings, some whitespace
issues and removed some debug messages.
2018-06-08 22:46:47 +02:00
Giuseppe Zizza
18be12e9e9 [CHG] Removed unnecessary duplicated functions 2018-06-08 15:26:08 +02:00
Giuseppe Zizza
4c211ed95a [NEW] Aggiunta possibilita` di copiare le righe della tabella in SQL per facilitarne l'import 2018-06-08 14:43:48 +02:00
GortiZ
e7752d7398 KUbuntu 14.04 support restored (#1298)
* - [NEW] Add new interface and functionality to manage database file extension. (Implements feature request #659)

* - [FIX] Fixed CMake file to src.pro

* - Applied changes requested by mgrojo to uniform code with sqlitebrowser standards
- Add "history" when closing editor window, but reopen before closing preferences
- Revert some changes done by QtCreator

* Refuse from previous commit

* Additional changes requested by MKleusberg:
- [CHG] Always add "All files (*)" to filters
- [FIX] Removed unused include

* merged from master

* Merge sqlitebrowser master

* [FIX] Fixed compatibility to compile on KUbuntu 14.04 with Qt 5.2.1

* [FIX] Fix Qt version for QOpenGLWidget support on previous commit

* [CHG] Uniformed QT_VERSION_CHECK style
[CHG] Reverted macOS check on Mainwindow for OpenGL context creation
2018-05-20 15:56:01 +02:00
Martin Kleusberg
4ab2bee2ac When selecting an entire row and deleting it, remove the record
When selecting an entire row or multiple entire rows in the table view
and hitting the delete key, delete the records and not just the cell
contents.

See issue #1391.
2018-05-20 13:22:13 +02:00
mgrojo
65c670acc0 Do not escape single cell data in clipboard copy
For single cell without-headers copy it is better to not escape the text
since there isn't any gain in trying to escape quotes, end-of-lines or
tabs. Escaping should only be done for table like data for compatibility
to spreadsheets applications.

See issue #1244.
2018-02-14 23:19:53 +01:00
mgrojo
33801d5285 Synchronize PlotDock with 'Execute SQL' table. Continuation of PR #1271
Make use of signals to connect the selection in plot to the associated
table widget. Every time that the plot is updated from the Main Window
the table widget associated to the table or query is connected to the plot
and the previous widget is disconnected. This allows the selection of the
correct table widget.

Line selection methods moved to the Extended Table Widget to be used as
slots for this connection.

The destroyed signal is also connected for resetting the plot. This fixes
a crash that already existed before this PR, when closing a SQL tab while
the plot is still associated to the table results model.
2018-01-16 00:37:42 +01:00
Martin Kleusberg
a98cd8e8f9 Avoid accidental truncation of cell data
For table cells with text larger than 32768 characters, the data gets
truncated. If the user doesn't notice this somehow and hits the Escape
key the truncated data is written back to the database resulting in a
possible data loss.

This problem is fixed by this commit in two ways:
1) The maximum length of the editor widgets is increased to the maximum
value making this problem much more unlikely.
2) If the user is still hitting this value, i.e. the text is truncated
anyway, the widget is put into read only mode and no data is written
back to the database.

See issue #1281.
2017-12-31 12:47:44 +01:00
Martin Kleusberg
e7a810913f Don't copy binary data to text type clipboard
Don't copy images or other binary data to the text MIME type of the
system clipboard. They are still copied into the internal buffer and
into the HTML MIME type though. We don't copy them into the text-only
clipboard because that doesn't really work well. Neither the original
binary data nor a "BLOB" string nor the BASE64 encoded data seem to be a
safe bet, so we just omit these cells.
2017-12-22 19:15:41 +01:00
Manuel
c753e56d62 Always copy data to clipboard and to internal buffer. Embedded image support (#1257)
At the time of pasting, use the generator and date meta tags in the HTML
version for knowing whether our data in the system clipboard has been
overwritten. If not, the internal buffer has better data, so we use it.

Since the binary data is not excluded in the system clipboard, images
are also included embedded in the HTML table. Other binary data are encoded
as base64 strings.
2017-12-22 18:43:58 +01:00
mgrojo
a41394ad4a Fix copy in internal buffer
There was an omission of the last_row update in
968b8d55f0

That had an effect of converting all copied selections to one column.
2017-12-07 21:13:06 +01:00
mgrojo
2e881659a5 Fix crash and blocking condition while removing hidden columns at copy
It uses QMutableListIterator for removing while iterating and it can also
be made forwards, sot it is clearer.

This fixes #1256 in my environment.
2017-12-07 18:31:54 +01:00
Martin Kleusberg
968b8d55f0 Fix possible crash when copying data into the internal copy-paste buffer
This fixes a crash which happens if you copy a range which contains at
least one cell of binary data and which has a hidden column in the
middle of it.
2017-12-07 14:08:46 +01:00
Martin Kleusberg
298d8c22c0 Fix NULL check in copy-paste code
Fix a bug introduced by commit ebd96c6a03.
Thanks for @mgrojo for pointing this out.
2017-12-07 13:38:36 +01:00
mgrojo
4a0f6f790d Valid HTML clipboard content
Copied HTML now passes validation from https://validator.w3.org/check

Thunderbird accepts now our HTML version of the copied data.

Added a meta generator key. See discussion in issue #1244
<meta name="generator" content="DB Browser for SQLite">
2017-12-06 23:04:40 +01:00
Martin Kleusberg
5707b3139f Fix quoting of data copied to clipboard in one more occasion 2017-12-04 13:56:57 +01:00
Martin Kleusberg
a9e04080e9 Clean up the code for pasting clipboard contents
We have two different sources when pasting data into a table view: the
system clipboard and the internal copy-paste buffer. Both work slightly
different but most code is duplicated between them. This commit cleans
up the pasting code by merging the two code paths into a single one.
This does not only reduce the amount of duplicated code but also enables
some features for both sources that were only available for one of the
sources. This includes duplicating data by copying from a single cell to
multiple cells and the message box asking for confirmation when the
source and destination ranges do not match. These features were only
available for the system clipboard before and should now work for both
sources.
2017-12-04 13:26:08 +01:00
Martin Kleusberg
ebd96c6a03 Add helper function for escaping strings which are copied into clipboard
Introduce a helper function for escaping special characters and for
adding quotes when copying data into the system clipboard.
2017-12-04 13:03:56 +01:00
Martin Kleusberg
316860a709 Make sure to properly clear the system clipboard when copying data
When copying binary data or similar using the internal copy-paste buffer
we need to clear the system clipboard first in order to avoid confusion
between the two paste sources. Just calling clear() on the clipboard
doesn't seem to work on my system, so this commit manually sets the
clipboard text to a null string.
2017-12-04 12:55:29 +01:00
Martin Kleusberg
47b07490de Share internal copy-paste buffer between different table views
Use a shared internal copy-paste buffer for all table views in the
application instead of having one buffer per view. This is not only less
confusing because it more closely resembles the behaviour of the system
clipboard but it also allows copying BLOB data from a Execute SQL result
view to a Browse Data table.
2017-12-04 12:47:37 +01:00
Martin Kleusberg
9db70e0750 Don't paste NULL value when pasting from empty clipboard
When the clipboard is empty and trying to paste from it we would set the
selected field to NULL. This is fixed by this commit, so that nothing
happens.
2017-12-04 12:44:35 +01:00
Martin Kleusberg
b3a0c574e8 Don't treat trailing line break as NULL value when pasting from clipboard
When copying cells from a spreadsheet application an extra line break is
appended to the clipboard text. This commit adds some extra code to our
parser to remove this line break. Without this we would paste a single
NULL value into an additional line.

See issue #1244.
2017-12-04 12:38:25 +01:00
Martin Kleusberg
2b1004602f Don't copy data from hidden columns to clipboard
Copying data from hidden columns is not only confusing but does also
break some common use cases. This commit makes sure that we're not
copying any data from hidden columns. That means the only way to get the
old behaviour now is to unhide all columns, including the rowid column.

See issue #1094.
2017-12-04 12:10:22 +01:00
mgrojo
aa2aa137f2 Quote only data with end-of-lines, tabs or double-quotes
Headers are also quoted if they contain end-of-lines or tabs.

See #1244
2017-12-01 23:58:06 +01:00
mgrojo
dcc0c32c39 Avoid adding an empty row in the clipboard data
This part from 3aef8adc9a is undone, because
it adds an empty row in the clipboard data. The whole loop can be rethought
later, if necessary.
2017-11-30 22:48:45 +01:00
Martin Kleusberg
b1e42d08c6 Avoid some warnings 2017-11-29 22:22:05 +01:00
Martin Kleusberg
3aef8adc9a Clean up copy & paste code
Also add some TODO comments in preparation for #1244.
2017-11-29 22:17:22 +01:00
mgrojo
42d2feb99b Actually change the shortcut for Copy with Headers to Ctrl+Shift+C
The change in commit 82665e3f09 only
affected the label in the context menu.
2017-11-26 14:21:20 +01:00
mgrojo
82665e3f09 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.
2017-11-25 21:39:41 +01:00
Martin Kleusberg
0d7ca9b5be Support pasting single value into multiple cells
This adds support for pasting a single value into all selected cells in
the Browse Data tab in order to mimic the behaviour of standard
spreadsheet application more closely.
2017-11-23 17:03:57 +01:00
SourceTrigger
0a995423fa Source trigger patch file drop (#1236)
* Add Signal if File dropped

* Check if Index is valid

Send Signal and return if Index is invalid and File was dropped

* Connect Dropsignal to fileopen
2017-11-20 21:05:47 +01:00
mgrojo
24a573dc68 Minor icon changes
New icons in resources from our icon set: Silk from
famfamfam.com

Icon for close. Applied to the find bar (see issue #191).

New icon for special copy. Applied to the "Copy with
Headers" option.

Removed the execution permission from some icon files.
2017-11-19 14:59:55 +01:00
mgrojo
87e1b9bc7c 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).
2017-11-19 00:57:42 +01:00
mgrojo
e60e9ffc75 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
2017-11-18 21:39:54 +01:00
Martin Kleusberg
d0771cb4bd Fix possible crashes when using context menu in Browse Data tab
Deactivate all menu actions in the context menu in the Browse Data tab
if no database file is opened. Without a database the read-only actions
were still enabled and would lead to a crash.

See issue #1228.
2017-11-17 13:20:08 +01:00
mgr
9ce4b232ba 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.
2017-11-12 19:26:39 +01:00
mgr
a03a901051 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
2017-11-04 19:53:36 +01:00
mgr
c017a2d800 Add support for the special case for empty strings (issue #1189) in the "Use as Filter" option. 2017-11-01 13:25:10 +01:00
Martin Kleusberg
9f17176bf6 Simplify code
Does anybody know why this was the way it was?
2017-10-30 13:19:52 +01:00
Martin Kleusberg
3bd2dc3bc1 Replace 'foreach' by range-based for loop from C++11 2017-10-30 13:10:08 +01:00
mgrojo
5cef432159 New option in the context menu for using the value as filter (#1182)
* Added an option in the context menu for using the currently selected cell
as filter in this column. This allows quick filtering by selected values.

* Changes to pull request #1182 requested by @MKleusberg: get internal cell data and check for the NULL special case.
2017-10-21 22:24:43 +02:00
Martin Kleusberg
ea1659e1d0 Support schemata other than main in the Browse Data tab
Similar to commit 44eb2d4f99 this commit
makes use of the backend code improvements introduced in commit
532fcd3f6b.

It adds support for database schemata other than "main" to the Browse
Data tab. With this it's possible again to browse and edit data of
temporary tables using the Browse Data tab. This time, however, they are
separated logically from "main" tables. So handling temporary tables
should be a lot less error prone now, plus it's easier to tell for the
user what tables goes in what schema.

This commit changes the project file format. There is some code included
which allows loading of project files in the old format. However,
project files generated using versions after this commit can't be loaded
by older versions of DB4S.
2017-09-04 12:27:52 +02:00