Commit Graph

2236 Commits

Author SHA1 Message Date
mgrojo
bbac655499 Select the pointed table row when right clicking on the vertical header
This makes sense from the user point of view, since it remarks that the
options from the menu applies to that row. This change will also fix the
different behaviour of the "Delete record" and "Duplicate record" in the
context menu. See issue #1283
2018-01-05 18:26:34 +01:00
Martin Kleusberg
35b8ac7771 Revert "Fix removing comments from SQL when there are quoted strings"
This reverts commit eae0730e3e.
2018-01-05 18:22:15 +01:00
Martin Kleusberg
652637232d Add tests 2018-01-05 18:20:28 +01:00
Martin Kleusberg
743e7985c2 Add support for conflict clauses to the grammar parser
Add support for parsing and generating CREATE statements with an ON
CONFLICT clause for their primary key.
2018-01-05 17:35:26 +01:00
Martin Kleusberg
29fa332f97 Fix bug introduced in eae0730e3e 2018-01-05 17:24:23 +01:00
Martin Kleusberg
eae0730e3e Fix removing comments from SQL when there are quoted strings
In the code for removing comments from SQL statements we have to make
sure to only match the '--' characters when they are not inside a quoted
string or identifier. This works fine and as expected for single quotes.
However, for double quotes it doesn't. This is fixed by this commit.

See issue #1270.
2018-01-05 16:45:50 +01:00
Martin Kleusberg
7d2931baa2 Add a --read-only command line option
Add a new command line option -R / --read-only for opening a database in
read-only mode.

See issue #1265.
2018-01-05 16:27:23 +01:00
Martin Kleusberg
5f702db0e0 Don't set modified flag for database when attaching/detaching database
Don't set the modified flag of the main database if we're attaching or
detaching another database since these actions don't alter the original
database.

See issue #1249.
2018-01-05 16:07:18 +01:00
Oscar Cowdery Lack
14da8dcf98 Remove hardcoded styles from hyperlinks (#1286)
These hardcoded styles are unnecessary, as Qt will automatically
add styling to hyperlinks that matches the system theme.
2018-01-05 15:56:37 +01:00
Justin Clift
12ad5e5b68 Add SQLCipher to the Ubuntu build instructions 2018-01-05 00:41:27 +00:00
mgrojo
6f5e507556 Right click on vertical header to delete the selected record(s)
The text is got from the "Delete record" button, so the text is updated to
"Delete records" when appropriate.

See feature request #1283
2018-01-04 21:48:19 +01:00
mgrojo
1be61dbb4f Removed unused QDebug include sentences
Last one was accidentally left by commit feda408161
2018-01-04 21:05:24 +01:00
mgrojo
feda408161 Fix wrong BOM detection in startsWithBom and fix BOM checks containing 0
The same fix for BOM detection in startsWithBom as already applied in
c9c848e995 for removeBom, otherwise binary
data is considered text.

Fixed also check for "\x00\x00\xFE\xFF" and "\xFF\xFE\x00\x00", that are
the problematic BOMs since they contain the null character.
2018-01-02 21:13:52 +01:00
Martin Kleusberg
c9c848e995 Fix wrong BOM detection
This fixes a bug introduced in 27c657902e.
In that commit we are checking if a string starts with a Unicode BOM and
remove the BOM if necessary. Apparently though Qt's startsWith()
function doesn't work as exected here, so it's changed to a manual
comparison in this commit which seems to work fine.

The first person who can explain that behaviour to me gets a free beer
if we meet in person.

See issue #1279.
See issue #1282.
2018-01-02 18:15:38 +01:00
Martin Kleusberg
117af5aeeb Put full cell data into INSERT statements when dragging tables
In the Structure tab you can drag & drop entire tables. This copies the
CREATE statement of the table along with the INSERT statements for the
table data. However, for the table data we would use the data as shown
in the table view cells, i.e. 'NULL' for NULL values or truncated data
for very long strings. This is at least partly improved by this commit.
It doesn't treat NULL or BLOB values 100% correctly but fixes the
truncation problem and at least makes the issues in the other cases a
bit more obvious.
2018-01-01 20:11:26 +01:00
Manuel
106e57eedc Allow users to drag and drop fields from DB Schema dock to editor (#1250)
* Allow users to drag and drop fields from DB Schema dock to editor

This is the first attempt to provide the functionality described in #119.

Drag in the dock is enabled (it was only enabled in the Database Structure
tab). Then the fields are enabled for dragging and finally the MIME data
exported for the drag and drop is tailored for exporting only the escaped
field identifier.

This may interfere to other uses of drag&drop in the Database Structure.

* Allow the user to drag individual items from the DB Schema dock

By allowing extended selections of individual items in the dock version,
we let users select what they want to drag and drop. When dragging a list
of items from the Name column, a list of escaped identifiers with commas is
exported, making easier the composition of SELECT and other statements.

In this way, every item name can be dropped, without loosing the ability
of exporting the SQL statement for the item. It will just depend on which
column is selected.

For the DB Structure tab, the original behaviour of single row selection
is maintained. In that case, only the SQL column is exported, as before.

See issue #119.
2018-01-01 20:07:52 +01:00
Martin Kleusberg
27c657902e Improve handling of BOMs in table cells
Detect some Unicode BOMs and always treat data starting with a BOM as
text. We might need to fine-tune this later but it should be an
improvement already.

In the Edit Dialog remove the BOM from the text editor but keep it in
the hex editor. Also add it back to the text when saving changes in text
mode. This way the BOM is out of the way for text edits but is not lost
either when editing a cell.
2018-01-01 17:20:50 +01:00
Martin Kleusberg
8f0312487f Fix cmake build 2018-01-01 15:17:22 +01:00
Martin Kleusberg
5562119563 Move check for binary data into separate function
There are two places in the code where we check for binary data in
database cells. This commit takes the code and moves it into a separate
function so it's easier to improve the situation in both function
simultaneously.
2017-12-31 15:25:01 +01:00
mgrojo
7ce7f0c05b Use current encoding for the binary check and being able to reset encoding
The current table encoding is used in the binary check, so text encoded in
8-bit encodings is properly recognised as text in the table widget.

Make it possible to reset the encoding used in the way suggested to the
user: "Leave the field empty for using the database encoding". Currently it
was rejecting it with the message: "This encoding is either not valid or
not supported."

See issue #1279
2017-12-31 12:59:29 +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
8896ecca40 Refactoring and find/replace dialog in the JSON editor.
SQL and JSON text editor classes have been refactored. A new parent class
for both editors have been added for the common logic implementable without
depending on the specific lexer.

The only visible effect of this change should be that the JSON editor
(issue #1173) now has the same find/replace dialog as the SQL editor.

This prepares for the implementation of the XML editor (issue #1253).
2017-12-16 00:09:47 +01:00
mgrojo
de260d32c5 Always open the find/replace dialog with Ctrl+H and option in context menu
The shortcut is constrained to the Widget context so it does not conflict
with other SqlTextEdit widgets in the application. Now all SqlTextEdit
widgets are able of opening the dialog with the same shortcut and behave
in the same way (do not block the parent window).

The find/replace dialog can now be discovered by the user in the context
menu at the SqlTextEdit widgets.
2017-12-15 21:15:39 +01:00
mgrojo
cb9712769e libs: Update qcustomplot to version 2.0.0 released on 04.09.17
Let's see if this fixes the problem about disappearing points while
zooming reported at issue #838.
2017-12-15 18:39:08 +01:00
mgrojo
05559d4727 Avoid inheriting the style sheet in child widgets
Avoid inheriting the style sheet in child widgets by naming the widget
type where it is set.

This had the effect, reported in issue #838, of setting an unwanted style
in child widgets, like the tool-tip of the "Load all data" button, the
tool-tip of the SQL results pane or the context menu of the search-bar
edit line.
2017-12-15 17:58:28 +01:00
mgrojo
982a88b5e2 Avoid crash performing the correct check to know if the plot has graphs
This crash was introduced in 6d3228a0e3. It
happened when no previous settings were saved for the plot.

Additionally the plot interaction are set once for the plot widget.

This was reported at issue #838.
2017-12-14 23:38:33 +01:00
mgrojo
6d3228a0e3 Visual warning when plotting if not all data has been fetched
Warn user if not all data has been fetched and hint about the button for
loading all the data. The attention to this button is attracted changing
its background to a reddish colour and showing a warning in its tool-tip,
which is automatically shown for its default duration.

Default message is simplified and the button is only enabled when it is
useful (users of non-big databases would never be distracted about the
fetching mechanism).

Since this button is also useful for resetting the zoom and axis range,
it is also enabled if the user performs one of these interactions over the
plot.

See discussion at issue #838.
2017-12-13 23:05:56 +01:00
mgrojo
e34d36085d Copy plot to clipboard
New context menu and shortcut (context restricted to widget) for copying
the current plot to the clipboard as a pixmap.
2017-12-13 00:14:27 +01:00
mgrojo
d2200de4b0 Avoid warning in setPointSize when Preferences are opened
The warning was introduced in 387449b751
because the initial value in the UI is 0.

See issue #1263.
2017-12-12 00:17:19 +01:00
mgrojo
387449b751 Preview for the Data Browser font in Preferences
The 'Displayed text' boxes preview now the Data Browser font that the user
sets in the corresponding widgets.

See issue #1263
2017-12-12 00:08:22 +01:00
mgrojo
bfb607c4b7 Crash when running query with columns selected for plot
The model was still changing when the plot was being drawn. Now the plot
waits for the fetching to be finished.

See issue #1262
2017-12-11 23:57:25 +01:00
mgrojo
7ac93e34ed Allow user to set the BLOB text. Preview for field display in Preferences
A new setting allows the user to set the text for BLOB data in the cell.

The existing line-edit for setting the NULL text and the new one for BLOB
are updated with the cell background and foreground colors, providing a
preview of the desired changes. An additional preview-only box is added for
the regular fields.

See issue #1263

Settings in Database tab are left-aligned for consistency to other tabs.
See comment in #1173.
2017-12-11 22:00:03 +01:00
mgrojo
4a9f1a2a50 Avoid two calls to dittoRecord in 'Duplicate record' called from shortcut
This was mistakenly introduced in 7ed1b1db05

The unwanted effect was two new duplicate records inserted.

Additionally the shortcut is made self-documented for the user in the
corresponding context menu.
2017-12-11 00:48:55 +01:00
mgrojo
7ed1b1db05 Do not ignore error when inserting rows in 'Duplicate record'
That avoids overwriting existing record as reported in issue #1255.

This doesn't improve the underlying situation, that is inserting empty rows
before duplicating the content. But it is safer to not ignore the error in
the initial row insertion.
2017-12-10 15:34:05 +01:00
mgrojo
5807c0be6b Allow zooming and dragging only in one orientation
By selecting the axis or the labels associated to the axis,the user can
restrict the subsequent zoom or drag operation to that orientation.

The possible user interactions are documented in the Whats's This
information.

See issue #1258
2017-12-08 20:12:07 +01:00
mgrojo
232130bc60 Indent/Compact setting moved to Cell Editor
Removed the related check box in the Preferences Dialog. A new checkable
tool-button with icon from the Silk collection. When checked, the
indent-on-loading and compact-on-saving feature is enabled. When widget
is destroyed, the setting value is saved from this button state.

Currently it is only usable in the JSON mode, but could be reused in XML
and any other future modes.

See issue #1173.

Some tooltips in the Edit Dialog have been corrected, since it is not only
used for text.
2017-12-08 17:50:15 +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
409d02f9ea plot: Remove axis labels when there is no plot
See issue #950.
2017-12-07 16:14:15 +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
mgrojo
05149150a5 Disable 'Attach Database' when appropiate. Better 'Choose...' messages
Disable 'Attach Database' when no database is opened.
Added to the function that enables and disable actions depending on
database state. See issue #1254

Display more specific 'Choose a file...' messages in two places. See issue
#331.
2017-12-06 19:26:59 +01:00
mgrojo
a4728ff5f6 Fixed inconsistencies in new toolbar buttons
Restored menu entries for 'Open Project' and 'Save Project'. They were
accidentally removed in 8fbf44bffe

Set the status-tip to all the toolbar buttons for consistency. This
displays a message in the status bar when hovering over the toolbar button,
and (depending on platform), when the menu entry is the current. Set to the
the same text than the tool-tip following previous example.

Both tips for 'Close Database' were added.
2017-12-06 18:08:37 +01:00
mgrojo
678079a77a Cell editor fixes and improvements
Valid JSON is detected as a new first-class data type. See issue #1173.

Text data length is always calculated in characters and not in bytes (UTF-8
gives different results).

Text in read-only mode is also selectable by keyboard and the caret is
visible. See issue #1123
2017-12-06 00:01:09 +01:00
mgrojo
8fbf44bffe New toolbars, new action icons and toolbar style preference
Two new application toolbars: Extra DB (attach, close database) and Project
(Open, Save). Can be disabled and moved as usual.

Icons for Close Database and Attach Database actions, which lacked ones.

Different icon for the dock configuration, so they are visually
distinguishable from the toolbar configurations.

New preference for the toolbar style, with default value: text besides icon
as before. But in order for the style to change, the value in UI must be
ToolButtonIconOnly.

Needed new icons from famfamfam.com's Silk collection.

See related issue #331
2017-12-04 22:49:48 +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