Commit Graph

2245 Commits

Author SHA1 Message Date
Martin Kleusberg
d17bd9176e Merge branch 'GortiZ6-master' 2018-01-13 16:48:09 +01:00
Giuseppe Zizza
a993c19853 File Extension management interface (#659)
[NEW] Add new interface and functionality to manage database file
extension. (Implements feature request #659)
2018-01-13 16:43:24 +01:00
Martin Kleusberg
58ab9cc1b7 Check for pseudo-PKs when determining whether the model is editable 2018-01-13 16:29:17 +01:00
Manuel
512b694114 Fix crash when Tab is pressed at the last cell of a view's grid (#1289)
The crash is avoided if the table model is not editable, since insertRows
checks that. A table model for a DB view should be not editable, so this
fix avoids the crash and possibly other possible misbehaviours.
2018-01-13 16:27:19 +01:00
mgrojo
b2fbf45012 Plot: detect dates with time, pure dates and times data types
Three different date/time data types are detected and appropriately
displayed in the axis:
- DateTime: "yyyy-MM-dd\nhh:mm:ss"
- Date: "yyyy-MM-dd"
- Time: "hh:mm:ss"
2018-01-11 21:07:06 +01:00
mgrojo
ce2b33ab6d Use the correct function for checking the count of plotted items
Now that the plot may contain graphs and curves, the plottableCount()
function must be used instead of graphCount() for checking whether the plot
has any plotted items.

This had the effect reported in issue #821 of breaking the enable check for
the fetch-all button.
2018-01-08 23:30:55 +01:00
mgrojo
b08960f504 Plot: Respect the "Order by" clause when plotting
The tables/queries sorted by X are drawn using QCPGraph as before.

Since QCPGraph does automatically sort by X, we change to QCPCurve that
requires a third data vector to reflect the order. We get that from the
current row order.

In the case of curves, only None and Line is supported as line style.

Since the order is now important for the plot, it is automatically updated
whenever the user sorts by another column in the browsed table.

This addresses issue #821 and indirectly fixes the problem of incorrect
point->row selection link when the table is not sorted by X, reported in
issue #838.
2018-01-07 14:54:29 +01:00
mgrojo
b99edacc9f Automatic completion of SQL keywords in upper case
Added a new setting for completing the SQL keywords in upper case (default
being true).

Scintilla setAutoCompletionCaseSensitivity is set to false. Otherwise the
completion is only done in lowercase when both case versions are added,
or if only upper case version is added, writing lower case letters does
not use the upper case version of the word in the completion list. This
change doesn't have apparently any downside, since SQL is actually case
insensitive.

Consequently the list of keywords is only added in one of the two letter
case versions, depending on the new setting value.

The new preference check-box is only enabled when the auto-complete
check-box is checked.

See issues #1238 and #1287.
2018-01-06 21:53:15 +01:00
mgrojo
cb98e29a7c Allow deleting and duplicating a selection of rows
Before bbac655499 it was possible to delete
a set of selected rows. This makes it possible again by only selecting the
row if it is not already inside the selected rows. See issue #1283.

Additionally and for coherence, the "Duplicate record" from the context
menu is also made to apply to the list of selected rows. See issue #1090
2018-01-05 20:51:36 +01:00
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