Fix: NULL data are correctly indicated in the Cell Info footer when loading
data from the database. Previously, the automatic trigger of
editModeChanged when setting the text in the widget was causing the change
to Text data type. Now the modified flag of the widget is taken into
account.
Fix: NULL values could not be overwritten with empty strings, since the
old vs. new check was incorrectly returning false as the conversion to
string was discarding the NULL information.
Improvement: NULL values are visually indicated using the placeholder as
already done in the Add Record dialog. The italic style is applied to both
cases now for better indication and coherence to the browse data widget.
Known problem: when the cell is changed from a JSON cell to a NULL cell
and the automatic switch is on, the NULL information and visual indication
are still lost.
This commit refactors vast parts of the sqlitetypes.h interface. Its
main goals are: less code, easier code, a more modern interface, reduced
likelihood for strange errors and more flexibility for future
extensions.
The main reason why the sqlitetypes.h functions were working so well in
DB4S was not because they were that stable but because they were
extremely interlinked with the rest of the code. This is fine because we
do not plan to ship them as a separate library. But it makes it hard to
find the obvious spot to fix an issue or to put a new function. It can
always be done in the sqlitetypes function or in the rest of the DB4S
code because it is just not clear what the interface between the two
should look like. This is supposed to be improved by this commit. One
main thing here is to make ownership of objects a bit clearer.
In theory the new code should be faster too but that difference will be
neglectable from a user POV.
This commit also fixes a hidden bug which caused all table constraints
to be removed in the Edit Table dialog when a single field was removed
from the table.
This is all still WIP and more work is needed to be done here.
* Issue #530: constraints on table prevents new record being added
This adds a new dialog for adding records to a table. The current approach
is broken for several cases where foreign keys and check constraints are
impeding the insertion of an empty record. With the dialog, the user can
inspect the constraints (tooltip) and type of fields and add values
consistent with the requirements. The data is only inserted when the user
presses the Save button.
The dialog is modelled after the Edit Table or Edit Index dialog. An upper
frame allows entering the data using widgets. The lower frame previews the
SQL statement that will be used.
The old approach for adding records is still accessible pressing Tab on
the last cell of the table.
* Fix build problem introduced in previous commit on this branch
* Dialog as fallback for failure after empty row insertion and read only text
The insertion of an empty row is always tried. When it fails due to
constraints and foreign keys, the Add Record Dialog is open so the user
can enter values for the new record considering the constraints.
When the table has not constraints, or the row insertion provides valid
values, the user is still able to insert rows using the simple approach.
SQL preview in dialog is now read-only.
* Visual improvements for the Add Record dialog
QLineEdit as item delegate for the value, so it is more visible that we
are supposed to edit the value.
Remove last end-of-line in tool-tip.
* Improvements in the "Add Record" dialog
Display of NULL values using DisplayRole (no focus) or place holder text
(when focus).
Set value to NULL through a context menu and shortcut in the value line
edit.
Take text type affinity into account for quoting or not entered numbers.
New isType and affinity functions in sqlitetypes.
Clarify wording of constraints in tooltip for value. Added the same tooltip
for the type.
Escape quotes inside string values.
Removed unused parameters warnings.
Other wording or code improvements based on the pull-request review: #1477.
* User access to the Add Record dialog
The Add Record dialog is now accessible for the user. The New Record button
is converted to a QToolButton and a new pop-up menu is added to it for
invoking the in-line table insertion (New Record) or the Add Record dialog
(Insert Values...). What's This information for the button updated.