Commit Graph

654 Commits

Author SHA1 Message Date
mgrojo
d447c739c0 Keep project open when a DB is closed
Although a project cannot be saved without an associated DB file, we allow
to keep the project open when the current DB file is closed. The only
action that closes the project is opening another project or closing the
application.

The window title must reflect the three situations:
- Nothing is open
- DB file is open
- Project is open with a DB file or not

See discussion in issue #2027
2019-11-09 17:44:58 +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
74befa368b Do not prompt for saving project file on close when it is just open
The project loading code modifies the isProjectModified flag due to the
changes performed. The flag has to set after all the loading is done, so
a close of the just opened project does not prompt for saving.
2019-11-03 18:37:12 +01:00
mgrojo
b30ddf98d0 Add project file name to window title
The DB file will include the full path only when it is different to the
project file path.

currentProjectFilename is cleared and set correctly in every case.

See issue #2027
2019-11-03 18:31:15 +01:00
mgrojo
f63bcbfef8 After closing an SQL tab, set focus to the new currently selected tab
Suggested in issue #2025
2019-11-03 14:36:58 +01:00
mgrojo
3577c71193 Allow closing the last tab by opening a new clean one
This allows clearing all the SQL tabs and at the same time, avoids leaving
an empty SQL tab widget.

Related to issue #2025
2019-10-31 20:44:22 +01:00
mgrojo
e2081db019 Fix problem to close the first tab using shortcut
This was introduced with implementation of #2025 and reported there.
2019-10-31 20:39:43 +01:00
mgrojo
24d4ca729b Use Ctrl+W to close a tab in SQL editor and Ctrl+F4 to close DB file
See enhancement #2025
2019-10-30 20:49:02 +01:00
mgrojo
5aeca230fc Formats conditioned to row-id values to allow free cell formatting
The conditional formatting is extended to cover free single-cell
formatting. The row-id formats have precedence over regular conditional
formats.

In the styling toolbar, when single cells are selected, row-id formats are
created or updated. When entire columns are selected, regular conditional
formats are instead. Clearing formats for entire columns, remove both. For
single cells, only corresponding row-id formats.

New row-id formats are also saved to project files and loaded.

See issue #1976
2019-10-27 01:25:04 +02:00
Martin Kleusberg
252484b486 Remove unneeded includes 2019-10-07 18:24:02 +02:00
Martin Kleusberg
be06bf2ac9 More consistent use of size_t for indexing table columns
Especially when we can remove the code for loading the binary bits of
the old project file format, this should allow us to get rid of a ton of
static_casts.
2019-10-04 17:58:42 +02:00
mgrojo
c27002c301 Added text alignment to conditional formats
Combo box for selecting the desired text alignment for a conditional
format.

The default alignment in the browser has been adjusted for numbers, which
are now aligned to the right as in spreadsheets.

Project file format updated.

See issues #1976 and #1815.
2019-09-21 23:28:35 +02:00
mgrojo
412c239366 More conditional formats: font style
The conditional format manager allows now to set the font style: bold,
italic and underline.

The project format has been updated. This is also the base for setting
other font formats without further changing the project schema.

New icons form the Silk icon set.

See issue #1976 and #1815.
2019-09-21 12:33:16 +02:00
Martin Kleusberg
80fb3707c6 Add global filter field to Browse Data tab
This adds a new field to the toolbar of the Browse Data tab which allows
filtering the current table just as the other filters. With the new
field however all columns of a row are checked and only one has to
match. This provides in effect a "global" filter which works on all
columns instead of just one.

See issues #1608 and #1662.
2019-09-16 22:36:14 +02:00
Martin Kleusberg
2958e5acba Silence some warnings and fix bug with RTL editor
This silences a couple of compiler warnings. The changes in the grammar
parser serve the same purpose: they silence at least some of the
warnings Antlr prints while generating the parser code.

In the Edit Dialog a missing break is added to a switch statement. This
seems like it actually was an unintended fallthrough for once, setting
the focus to the hex editor instead of the RTL editor.
2019-08-28 19:08:27 +02:00
Martin Kleusberg
2045a4d48f Fix a warning and a build error on macOS
See issue #1979.
2019-08-27 21:55:20 +02:00
Martin Kleusberg
ad2aa8ca88 Remove unnecessary checks and message boxes
This removes a couple of checks whether the database is opened. They
are not really necessary because the respective buttons are disabled
anyway in case no database is loaded. This was inconsistent anyway since
not all functions were checking for this. It also gets rid of a string
which translators have to deal with even though it is never going to be
displayed.
2019-08-27 21:55:19 +02:00
Martin Kleusberg
1a0786c409 Restore status bar calculations in Browse Data tab
This fixes a regression introduced in commit
3f0832f449 which lead to the calculation
of numbers like sum, average, and count in the status bar not being
displayed.
2019-08-23 16:12:32 +02:00
Martin Kleusberg
3f0832f449 Move form data and code for Browse Data tab into a separate widget class
This adds a new widget called TableBrowser which does everything the
Browse Data tab did before. All the UI data and all the code related to
this tab is moved into the new widget class. The main window now simply
uses the new widget instead of implementing all this stuff itself.

I mainly see three benefits from this change:
1) The main window class becomes smaller and starts looking less like a
master class which manages all of the application. This should make it
easier for new developers to find their way around the code.
2) A better separation of the table browser and the remaining main
window makes it clearer which class class is responsible for what. Again
this makes it easier to maintain the code when it grows.
3) If we ever want to have split views, multiple Browse Data tabs, or
something similar this is an absolute prerequisite.

This commit obviously changes a lot of code. So be prepared for
unintended changes and consider doing some extra testing.

See issue #1972.
2019-08-21 20:47:27 +02:00
Martin Kleusberg
7f051f8926 Some progress towards less usage of SIGNAL and SLOT macros
This is in no way complete but since it is a routine task and I got
bored of it I am going to stop here.
2019-08-21 11:58:31 +02:00
mgrojo
b37b444e04 Remove no longer needed call to processEvents
After cf631a0222 this call is no longer
needed to work around the problem described in #1649.

See discussion in issue #1943.
2019-08-18 15:16:04 +02:00
Martin Kleusberg
cf631a0222 Make updating of database structure always happen in the main thread
Make sure the updating of the database structure always happens in the
main thread so it is in sync with the GUI updates. This way we know for
sure that the list of tables has been completely updated before we try
to (re-)select a table in the Browse Data tab after the DB structure
changed.

See issue #1701.
2019-08-18 14:09:12 +02:00
Martin Kleusberg
f515c0473c Better naming of duplicated SQL tabs
See issue #1964.
2019-08-18 13:45:53 +02:00
mgrojo
aae2d4dea5 Restore current table and applied filters from project
Restoring the current table and applied filters from project was not
working due to some interference with other applied changes.

Now it is done at the end of the load project function and after having
processed events. applyBrowseTableSettings is also called, otherwise
filters are applied but not visible in their input boxes.

See issue #1573
2019-08-17 20:48:00 +02:00
mgrojo
fefbe37c29 Prompt user for options after dropping files
If no DB is open, DB4S tries to open the dropped file as formerly.
Otherwise, the user is prompted for the action:
- Open Database or Project
- Attach Database...
- Import CSV file(s)...

See issue #1883
2019-08-17 14:05:14 +02:00
Martin Kleusberg
6f81e89ec1 Add context menu and Duplicate tab feature to Execute SQL tabs
Add a new right click context menu to the tab bar of the Execute SQL tab
in the main window. This menu contains actions for renaming and closing
tabs. Especially the renaming feature was hard to find before.

Add a third, new action to the context menu for duplicating the tab.
Duplicating opens a new tan and copies the title and SQL text from the
selected tab.

See issue #1964.
2019-08-15 16:24:35 +02:00
mgrojo
732cda89fd Button for clearing the sorting columns
A new button in the "Browse Data" toolbar for clearing the sorting columns
and returning to the default table order.

New icon created as a composition of icons from the Silk icon set.

See issue  #1761
2019-08-15 15:43:13 +02:00
Martin Kleusberg
99c7523849 Fix warning when browsing views
When browsing a view we were constructing a query which looked like
this because the rowid column was empty:
SELECT "",* FROM "view_name";
This worked because there isn't really any rowid column for views anyway
and SQLite was interpreting the first bit as an empty string literal.
However using double quotes for string literals triggers a warning in
the error log. This commit aims to avoid this warning.
2019-08-10 11:51:12 +02:00
mgrojo
32efd8f19f Avoid flickering while sorting or filtering
Flickering was produced in the table header, due to the fact that the
the filter boxes were displayed first at the rightmost side while the
table is reset and then they are repainted when the rows appear, in order
to leave space to the vertical header with the row numbers.

Setting the minimum width of the vertical header to the current width
before any filtering or sorting avoids the issue. The minimum width is
set to the default when changing the current table.

See issues #1763 and #1941
2019-08-04 01:11:13 +02:00
mgrojo
bef856ef45 Fixes some problems reported by Coverity
- Unchecked dynamic_cast
- Uninitialized scalar field
- Uninitialized pointer field
- Big parameter passed by value
2019-08-02 17:19:28 +02:00
Martin Kleusberg
335999e4bd Remember read-only flag for recent files list
When opening a file in read-only mode, remember that read-only flag when
adding it to the list of recently opened files. The next time it is
opened it will be again in read-only mode.

The way this is implemented (by adding a "[ro]" to the start of the path
to indicate when to open in read-only mode) was chosen in order to be
fully backwards compatible with the previous data format for the file
list.

See issue #1913.
2019-07-26 16:22:28 +02:00
Martin Kleusberg
97d77d557b Fix build for Qt version < 5.6
This fixes 8a4e363483.
2019-07-26 15:34:01 +02:00
Martin Kleusberg
8a4e363483 Add "Browse Table" action to the context menu of the DB Structure dock
Add a "Browse Table" action to the right-click menu of the table and
view items in the Database Structure dock.

See issue #1943.
2019-07-26 14:51:26 +02:00
Martin Kleusberg
6cfac1b0f1 Fix right click action "Browse Table" for tables with whitespace
Fix a crash when using the "Browse Table" action in the right click menu
in the Database Structure tab. It crashed whenever the table name or the
schema name started or ended with a space character.
2019-07-26 14:26:00 +02:00
mgrojo
9fe529752b Allow to change sort order for any column in the multi-column sort list
A second Ctrl+Click over an already added column changes the direction of
any column.

Before this change, the effect was only applied to the last selected column
and a second Ctrl+Click on the other columns triggered a requery without
having changed anything.

This was mentioned in PR #1810. See also issue #1761.
2019-07-13 17:42:50 +02:00
Martin Kleusberg
237b1fd9b8 Simplify code 2019-06-28 13:25:46 +02:00
Scott Furry
cf05e7a462 Centralize File Filter and Resolve End CSV Import Message
Matter came up WRT #1880. In reviewing, several other instances
were found where same file filter as a string literal was repreated.
This commit centralizes	these file filters to one location. Filters
are declared `static const` to prevent accidental modification.

Also applied is a fix to #1881. QMessage at end of Import CSV is removed.
2019-05-29 15:54:27 +02:00
mgrojo
512f7eeeab Save splitter sizes of the Execute SQL areas to disk under request
Saving cannot be done in the class destructor, since it seems that the
sizes have already change in that moment. Now they are saved under request
of the Main Window at the same time when the Main Window state is saved.

See issue #1889.
2019-05-19 13:45:56 +02:00
mgrojo
30d0b183a5 Fix crash when opening project file
When opening a project file the following exception is raised in
src/sqlitedb.h:208

terminate called after throwing an instance of 'std::out_of_range'
  what():  map::at

This is related to 64a596a887
2019-05-12 00:15:35 +02:00
Scott Furry
f877f8a10c Resolve Github Issue #1867 - Spurious Empty Filename message.
Problem traced to QFile::exist() producing message when passed an empty QString.
Fix is to test QString length before any QFile::exist() usage with that string.
2019-05-07 22:14:13 +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
64a596a887 Use even less Qt containers 2019-05-06 18:50:05 +02:00
Martin Kleusberg
40aff11086 Use even less Qt containers 2019-05-03 15:04:15 +02:00
Martin Kleusberg
b803e3c49f Use more STL containers instead of Qt containers 2019-05-02 17:02:59 +02:00
Martin Kleusberg
e16537dd9a Use emplace_back some more 2019-05-02 12:05:27 +02:00
Martin Kleusberg
f821fbb1a8 Silence a couple of warnings 2019-04-29 19:14:10 +02:00
Martin Kleusberg
15c23bb0d3 Use some more SQL containers instead of their Qt equivalents 2019-04-29 18:11:19 +02:00
Martin Kleusberg
f59a2453a2 Fix some warning and other code style changes 2019-04-26 14:48:24 +02:00
Scott Furry
5c1cf8a0a8 Resolve sign conversion warnings - prefetch preference
Resolve warnings that occur when building w/ ALL_WARNINGS enabled. Source tree
examined to enusre prefetch size is handled as type std::size_t. Also, tree was
modified correcting handling of the chunkSize variable in sqlitetablemodel that
uses the prefetch preference setting.

Also, some minor editing of sources was taken to improve readability
as well as consistency.
2019-04-25 15:51:25 +02:00
mgrojo
cb3ac2aa2a Prompt to save changes in project when closing DB or application
The following changes set the project as modified in order to ask to save
changes in project file when closing DB or application:

The main database file and any attached database file.
* PRAGMA values
* Show Row Id option
* Encoding
* Unlock View Primary Key option
* Sort columns and sort directions
* Column widths
* Applied Filters
* Display Formats
* Hidden columns

See issue #1706
2019-04-06 20:15:05 +02:00