Commit Graph

57 Commits

Author SHA1 Message Date
mgrojo 9a70af7973 Evaluation mode in the Edit Database Cell editor
Entered expressions are evaluated using SQLite and the result is saved in
the cell.

The SQL Evaluation mode reuses the class used for the "Execute SQL" editor
so syntax highlighting and call-tips are supported.

See issue #2387
2020-11-27 17:44:35 +01:00
Martin Kleusberg d0978ef462 Move image viewer from EditDialog into a separate class
This does not change any look or functionality but is only a preparation
towards adding more features to the image viewer.

See issue #2029.
2020-06-03 11:09:31 +02:00
Martin Kleusberg 61544e8905 Fix some warnings 2020-06-03 10:20:56 +02:00
mgrojo a085d99b64 Enhancement: save to temporary file, open external application and reload
A new button has been added in "Edit DB Cell" dock, which saves the cell
data to a temporary file with extension according to detected data and
opens default external application for the file type. It then asks user to
reload the data in a dialog when they have finished editing the data. It
can be also used for viewing if the user cancels the reload.

See related issues #1791 and #1746
2019-12-23 12:35:13 +01:00
mgrojo 604ec0578b Open URL or filename: relative filenames are based on DB path and refactor
When opening a relative filename from "Edit DB Cell" or Table Browser the
relative paths are interpreted from the DB file location. This allows
portability of DB and linked files to a new location.

Refactoring so the open URL code is centralised in MainWindow and a status
message is displayed with error or opening notification.

See issue #1597
2019-12-22 22:02:57 +01:00
mgrojo 34c15538b2 Action to select a file to be inserted as a reference
The "Import file" in the Edit Dialog dock is converted to a menu (after
long click) with a new action for selecting a file to be imported as a
reference in the cell. Then this filename reference can be used to open
the file using the default application with the present "Open in
Application" action. (In Linux, paths containing non-US-ASCII are known
not to work. This seems a bug in Qt QUrl class).

New icon composed from our document-open.png and link.png from Silk icon
set.

Related issue #1597
2019-12-22 18:37:56 +01:00
mgrojo 8e8a3aa216 Undocking Database Cell Editor was clearing input
See issue #2062
2019-12-15 18:58:01 +01:00
Martin Kleusberg ba1270cedb Clean up the code and make some more minor optimisations
This also includes replacing some more Qt containers by their STL
counterparts.
2019-11-06 20:25:18 +01:00
mgrojo 5e965b1a20 Restore QTextEdit widget for RTL text in the Cell Editor
This restores the Qt text widget that was replaced by a QScintilla one in
45c1e2abfd

QScintilla does not support right-to-left scripts like Arabic, so QTextEdit
is still needed for these languages. Since the QScintilla editor has other
advantages already explained, it is preserved for general text edition.

RTL texts are detected when data is loaded and the Qt editor is
automatically selected. This is done both when loading data from the cell
and when interactively typing RTL characters in the Cell Editor.

All these changes can be undone if a new QScintilla editor supports RTL
texts.

See comments in issue #1793
2019-07-11 22:10:24 +02:00
Scott Furry d54b820fb2 Shadowed Variable Warnings (#1864)
Compile with ALL_WARNINGS using GCC 8.2.1.
Encountered approximately dozen warnings with this pattern:

    [path to sqlitebrowser root]/src/[somesourcefile]:line:cursor: warning: declaration
	of ‘data’ shadows a member of ‘ClassName’ [-Wshadow]
            OtherDataType data = ....line of code at line given above...
                          ^~~~
    In file included from /usr/include/qt5/QtWidgets/qdialog.h:44,
                     from /usr/include/qt5/QtWidgets/QDialog:1,
                     ...other sources in project
    /usr/include/qt5/QtWidgets/qwidget.h:733:18: note: shadowed declaration is here
         QWidgetData *data;
                      ^~~~

It appears there is a variable named 'data' within Qt global scope. Using 'data`
as a variable name, even one limited in scope to small lamda expressions, causes
compiler some grief.

Commit resolves the warnings in affected files. No problems apparent during execution.
Requires CSV stress-testing.
2019-05-07 22:09:21 +02:00
Martin Kleusberg f821fbb1a8 Silence a couple of warnings 2019-04-29 19:14:10 +02:00
mgrojo 29bfcc4922 Add option for word wrapping in Edit Database Cell
A new option, in the toolbar of the Edit Database Cell, is added for
setting word wrapping for the text editor modes. It is now independent of
the SQL preference. The configuration reading the editor/wrap_lines setting
is moved to the particular SQL editor class.

Added icon from the Silk icon set.

See issue #1796
2019-03-17 19:23:02 +01:00
mgrojo 45c1e2abfd Drop the QTextEdit widget in the Edit Database Cell dock
Use the QScintilla widget for all the text modes of the Edit Database Cell
dock. All the features are believed to be preserved.

- The plain text mode is materialised removing the lexer.

- Null values are indicated now in the margin instead of using a
placeholder. The same pattern is also used for the Image and BLOB data
cases when the editor is switched to a text mode. In the dark mode, the
line number margin matches now the style-sheet and instead of the
configurable editor colours.

- Read-only state in the editor is hinted by the caret not blinking, but
the text is still selectable by keyboard or mouse.

Features and fixes added by using this widget:

- Find/Replace dialog for the plain text editor. See issue #1746
- The QScintilla widget does not strip CR characters. See issue #1793
- Line numbers and visible caret line in the text mode.
2019-03-10 01:01:07 +01:00
mgrojo 3eebffd7c6 Detect XML data starting with a declaration
Checking for "<?xml" at the beginning of a text is a quick and simple test
that will detect most of the XML cases.

This fills an obvious gap in #1537.
2019-02-09 20:01:22 +01:00
Martin Kleusberg fb1eba1391 Remove some virtuals and add some overrides
In our case this is more a question of code style.
2018-10-09 20:28:22 +02:00
mgr a90d1b24d3 Special copy for the binary editor including addresses, hex and ASCII #1485
Added a new copy action to the binary editor context menu for copying the
selected text as seen by the user, instead of the stream of hexadecimal
digits copied by default by qhexedit.

In order to support copying from the context menu, qhexedit has been
modified for not resetting the selection when the left mouse button is
pressed. This will be converted to a pull request to qhexedit afterwards.

See related issue #1485
2018-09-30 23:51:49 +02:00
mgr 1c06066258 Printing support #1525: print images in Editor Dialog and menu in hex
Added support for printing images in the Editor Dialog. A new action added
that can be activated through the context menu or shortcut for printing.

The same approach is applied to the hex editor, which also lacked a
context menu. Consequently the specific shortcut can be deleted.
2018-09-30 23:21:49 +02:00
mgr 8b94eabd9d Printing support #1525: shortcuts for the hex and text editors
Print shortcuts are added in the context of the text and hex editors of
the Edit Database Cell dock.
2018-09-30 01:01:56 +02:00
mgr dd3417e1c4 Automatic switching of the editor mode according to data type #1537
A new checkable button and associated setting is added for automatically
switching the editor mode in the Edit Database Cell dock in accordance to
the loaded data. The switch is done after loading data from cell, after
importing new data to the cell and when checking the button.

If the button is unchecked the behaviour is as formerly.

Since XML is not currently detected, the mode only changes to XML when SVG
is supplied.

Default value is true, since the new behaviour is considered more useful
for the general case.
2018-09-21 20:48:16 +02:00
mgrojo 7c9fe7039c Merge branch 'master' into xml_cell_edit
# Conflicts:
#	src/EditDialog.cpp
#	src/ExtendedScintilla.cpp
2018-01-27 19:01:08 +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
mgrojo a0e0fc98ae XML mode for the cell editor
The new editor mode shares the same Scintilla widget as the JSON mode.
The JsonTextEdit class has been generalised. Future modes supported by
Scintilla could be added with the current pattern. As a consequence, the
EditMode is not always equal to the current stacked widget.

Some code in EditDialog has been refactored, so it is easier to understand
and modified with so many modes. textNullSet has been replaced by the use
of dataType as Null.

SVG is promoted to a new recognised data type, so it can be edited in the
XML mode.

The XML data is formatted and validated following the pattern established
by the JSON mode.

New modules are needed by the XML mode: the Qt XML module and some new
Scintilla files required by the HTML/XML lexer.

The indent_compact was incorrectly named in Setting::getDefaultValue.

See issue #1253.
2017-12-23 22:19:17 +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 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 189f19695a JSON validation before applying data to cell
A warning dialog is popped-up for confirming application of
invalid JSON data. Parse error is shown in the dialog.

*.json added to import filter.

See issue #1173
2017-11-24 00:27:48 +01:00
mgrojo 67c5ed963e Compact and indent on JSON cell editor
New setting for enabling the following feature:
when JSON data is loaded in the JSON cell editor, the text is
indented. Before JSON data written back into the cell, the text
is compacted.

See issue #1173

Minor adjustment in preference label: removed ":" for consistency.
2017-11-23 00:39:17 +01:00
mgrojo c832d8a58c JSON mode for cell editor
Support for JSON in the Database Cell editor using the QScintilla library.

The lexJSON has been added to the compilation.

See issue #1173
2017-11-18 14:57:36 +01:00
Martin Kleusberg ee32b3e4e1 Use nullptr where possible 2017-10-30 21:20:02 +01:00
Martin Kleusberg 3a70b412e8 Turn some slots into normal functions
They aren't used for signal processing at the moment and don't look like
they can be used for that easily.
2017-10-30 13:15:43 +01:00
Martin Kleusberg d5e4fe9f66 Clean up code 2017-10-07 18:00:48 +02:00
Martin Kleusberg f62d78ce15 Apply changed font settings to edit dock without restart
See issue #894.
2016-12-19 19:43:28 +01:00
Vladislav Tronko fabb460abf Remove redundant virtual keywords 2016-08-19 14:39:50 +03:00
Vladislav Tronko 345a75118a Enable Apply button when changes are made in editor 2016-08-19 13:57:39 +03:00
Vladislav Tronko f4590da1d8 Slight changes on editing permissions 2016-08-19 13:22:58 +03:00
Justin Clift 47b1224bc2 Ugly workarounds :) for various small bugs in the Edit Cell
Fixes #726, and also a few other small issues at the same time
2016-08-13 16:34:07 +01:00
Vladislav Tronko ad10e8016c Polished cell editor widget 2016-08-13 01:56:14 +03:00
Justin Clift b835ae800b Reimplement data loading and handling for the Edit Cell
This uses a somewhat different approach to the previous
one.  It now selectively stores the data into either
the text *or* hex widget buffer, and only copies the
data between them when the edit mode is changed.

Additionally, unneeded copy operations are minimised
where possible to reduce overall slowdown.:
2016-08-09 13:04:32 +01:00
Iulian Onofrei b5da4ed640 Add binary data size to the edit dock 2016-08-03 20:24:17 +03:00
Justin Clift 89baf3464d Adjust the layout of the Edit Cell as per #673 (#679) 2016-07-27 20:41:01 +01:00
Justin Clift f881f95ea9 Rationalise the Edit Cell dock and Windows code into one
Prior to this PR, we've had the Edit Cell be available both in a "dock"
and "window" mode.  Both at the same time. (!)

The "dock" mode already had tear off window functionality and was more
complete, whereas the "window" mode was buggy and didn't really add
anything new.

This PR removes the "window" version of the dock, and cleans up the
handling of "dock" mode, so there's just one Edit Cell dock now.  It
can be torn off and used as a window, docked to the main UI (by double
clicking its title bar), and toggled on/off with Ctrl-E (Cmd-E on OSX).
2016-07-21 22:55:13 +01:00
gimKondo 54cea17f3a set selected data type on imported by Edit database cell
Data type isn't decided by column type, but cell's type.
And, 2 bugs is fixed.
1. prevention in-place editing data
2. the lack of tr() on text literal
2016-01-18 15:56:57 +00:00
Martin Kleusberg 540b12a57a EditDialog: Allow opening dialog/updating dock in read-only mode for views
See #441.
2015-12-21 11:22:43 +01:00
Martin Kleusberg 0e17990583 EditDialog: Better behaviour when pressing escape key in dock mode
See issue #441.
2015-12-20 12:15:13 +01:00
Martin Kleusberg 672b6f693b EditDialog: Make edit dock more keyboard friendly to use
See #440, #441.
2015-12-19 14:05:45 +01:00
Martin Kleusberg f26df79961 Add edit cell dock to main window
Add a new option for replacing the edit data dialog by an edit data dock
widget which is added to the main window and remains visible. This might
be interesting for people who otherwise would have to open the edit
dialog many times by doing tons of double clicks.
2015-12-15 22:29:15 +01:00
Martin Kleusberg 1788678732 EditDialog: Set position to center of parent dialog when opening dialog
See issues #342 and #394.
2015-08-18 23:12:48 +02:00
Martin Kleusberg ba75bd16fe Use common format for all include guards and avoid leading underscores
Use a common format for all include guards, make sure each header file
has one and make sure it's named after the file name.

And as a random extra in this commit: Make sure the gen_version.h file
generated by cmake ends with a line break.

Closes #59.
2014-07-31 21:32:58 +02:00
Peinthor Rene 1bac11348f include cleanup 2013-09-19 22:55:35 +02:00
Martin Kleusberg 2165e544a2 Move all settings logic to the preferences dialog
Read and write the settings only from the preferences dialog.

Remove all the copies of some settings which were stored in nearly every
dialog class individually.

Simplify the settings dialog code by removing all those not really
needed slots.
2013-03-17 16:09:28 +01:00
Martin Kleusberg 57f4d996ca EditDialog: Don't update the DB when no changes were made
Even when clicking the OK button don't write to the database when no
changes were made.
2013-03-17 13:07:57 +01:00