Commit Graph

448 Commits

Author SHA1 Message Date
Martin Kleusberg
012ad9217a Fix drag & drop of tables onto the structure view
When dragging and dropping a table from one instance of the application
to the other, the tree structure representing the database was broken.
We would show the 'Browsables' and 'All' nodes at the top level instead
of the child nodes of the 'All' node. This happened because after
dropping a table, we would reload the database structure and rebuild the
tree structure but didn't notify the tree view in the main window about
the update. This is fixed by this commit, so the main window's widgets
are always notified about the new tree structure.

See issue #1288.
2018-01-15 23:10:23 +01:00
Manuel
dbbd268fa2 Merge pull request #1271 from FabianInostroza/plot_table_sync
Synchronize PlotDock with 'Execute SQL' table.
2018-01-15 20:53:54 +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
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
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
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
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
Fabián Inostroza
25381a57d9 Use Tabs enum for tab identification. 2017-12-18 17:02:27 -03:00
Fabián Inostroza
9185b34922 Synchronize PlotDock with 'Execute SQL' table. 2017-12-16 13:47:37 -03: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
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
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
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
mgrojo
bbe460c349 Improvements in the new "Save filter as view" functionality
The query used in sqlitetablemodel does not rename the columns, instead
it applies the display formats in the WHERE part. In this way the saved
view has the original column names.

Changes in Button "Save filter as view": more information in tooltip and it
is disabled when no database is open.

See discussion in PR #1246
2017-12-02 16:09:55 +01:00
mgrojo
cc61e47279 Prevent crash with "Save SQL file as" when no SQL tab is open
The same check performed in MainWindow::saveSqlFile() is applied here.

See issue #1248
2017-12-02 14:57:00 +01:00
mgrojo
5a8d6bbf62 Avoid crash when starting without a database and activating the find frame
See issue #1248
2017-12-02 00:16:31 +01:00
mgrojo
882fc8d3d3 Merge pull request #1246 from sqlitebrowser/save_filter_as_view
Save current filter, sort column and display formats as a new view
2017-12-01 21:51:47 +01:00
mgrojo
5da3d14ee3 Fixed issues from @MKleusber's review
New view name validated with isNull().

Text in information box reworded.

Column names are preserved in the new view, except for the ones with
display formats, for which an underline is appended in order to fix the
reported filtering defect.
2017-12-01 19:28:57 +01:00
Martin Kleusberg
e79c5db308 Manually set the keyboard shortcut for the Find/Replace dialog to Ctrl+H
Make sure the keyboard shortcut for the Find & Replace dialog is always
set to Ctrl+H instead of using Qt's QKeySequence::Replace. At least on
KDE desktops but probably on other systems too it break the Ctrl+R
shortcut which is used for refresh and SQL execution.
2017-12-01 13:52:02 +01:00
mgrojo
e5f7456863 Save current filter, sort column and display formats as a new view
A new button is added to the Browse Data tab for saving the current display
of the table (current filter, sort column and display formats) as a new
view. This allows (specially for non advanced users) the creation of simple
views. It can be seen, either as a way of storing the current
filtering or as an easy way of creating views.

This reuses the query set in sqlitetablemodel, but the column aliases when
a display format is used has been changed from col%1 to the original column
names, i.e. format(`orig`) AS `orig`.
2017-11-30 20:41:21 +01:00
mgrojo
c9bf5f87cb Find/Replace dialog improvements
Find/Replace dialog does not block the main window.

Dialog reused, so checks changed by user are preserved.

The selection of the last occurrence in Find All and Replace All
is cleared, so all the occurrences have the same appearance.
2017-11-26 01:19:33 +01:00
mgrojo
82665e3f09 Find/Replace dialog for SQL editors and logs
A classic Find/Replace dialog including all the options provided
by the QScintilla editor. Additionally a "Replace All" and a
Find All" button are implemented. This complements issue #191

New shortcut in main window for opening the find/replace dialog
connected to the focused widget. Standard for Replace is Ctrl+H.
Consequently the shortcut for Copy with Headers is changed to
Ctrl+Shift+C (see issue #1058).

For SQL text widgets not embedded in the main window, the standard
shortcut cannot be enabled, otherwise it conflicts with the main
window. Therefore the shortcut Ctrl+Shift+H is enabled for all the
SQL widgets as fallback. A better solution would be desirable.
2017-11-25 21:39:41 +01:00
SourceTrigger
0a995423fa Source trigger patch file drop (#1236)
* Add Signal if File dropped

* Check if Index is valid

Send Signal and return if Index is invalid and File was dropped

* Connect Dropsignal to fileopen
2017-11-20 21:05:47 +01:00
SourceTrigger
de2131daea Improve 4k/5k resolution rendering speed on macOS/OSX (#1233)
Initialize OpenGL rendering on macOS by add a hidden QOpenGLWidget.
2017-11-20 14:44:37 +00:00
mgrojo
a457d29fe2 Fix one case for the error visual hint in the SQL results pane 2017-11-19 01:11:20 +01:00
mgrojo
87e1b9bc7c Usability improvements for Extended Table Widget and SQL
results pane

Copy for multi-line text data surrounds the text with the
<pre> tag in the HTML version for avoiding line white-space
adjustments in the pasted text. See #1058

Do not use binary data in the "Use as Filter" option.

Indicate the existence of an error in the background of the
SQL results frame. The error-indicators is reused for
disabling this functionality.

When nothing is shown, a placeholder text hints the
objective of the results pane.

The preference label for the font size of this pane is
modified for consistency (SQL Log is another widget).
2017-11-19 00:57:42 +01:00
Martin Kleusberg
5fbf5ca1b2 Change label of "Delete record" button to reflect number of records
Change the label of the "Delete record" button in the Browse Data tab to
"Delete records" when multiple records are selected.

See issue #856.
2017-11-17 23:46:13 +01:00
mgr
ccc332c1bb Merge branch 'master' of https://github.com/sqlitebrowser/sqlitebrowser 2017-11-17 22:57:54 +01:00
mgr
e242fc84ee Search bar improvements
New button and key sequence (ESC) to close the search bar.

Clear selection (by not avoiding the search) when the text to search is
deleted, as expected by @pamtbaau at #1220.
2017-11-17 22:56:15 +01:00
Martin Kleusberg
011f7edd1f Remove unused variable 2017-11-17 12:33:52 +01:00
mgr
e8e5671588 Range of plot points can be selected in graph and in table
The user is now able of selecting a range of contiguous points in any of
the graphs of the plot, through rectangle selection or click in single
point. This selection triggers automatically the selection of the
corresponding lines in the browsed table. In this way the user can analyse
the plot in detail.

Two other minor improvements: spelling error fixed and the dummy column in
the plot selection table has now transparent foreground (intends to avoid
wondering of the user about what functionality provides this column).
2017-11-11 23:10:11 +01:00
Martin Kleusberg
0c30659b6a Apply find bar visibility to all SQL tabs
If multiple SQL tabs are opened, show or hide the find bar for all of
them when changing the check state of the button. Also apply the find
bar state to newly opened SQL tabs.

This also fixes a crash which would happen if you click the Find button
prior to opening any SQL tabs, i.e. before opening the first database
file.
2017-11-11 19:31:33 +01:00
mgr
5b6cdf231e Execute SQL tab: Add search bar for SQL code #191
The find operations in QScintilla are used for implementing a find frame
in the SQL Editor of the main window. A checkable tool button is added
in the SQL Editor toolbar for showing and hiding this frame.

There are check boxes for Whole Words, Case Sensitive and Regular
Expressions. The QScintilla facilities in the findFirst method are used
for the implementation.
2017-11-11 19:31:33 +01:00
Martin Kleusberg
69dc78da3a Fix regression introduced in 955848f957
This fixes a regression which recently was introduced by commit
955848f957. Because the status message was
overwritten by a version without the returned row count, you would never
see the intended status message when running SELECT statements in the
Execute SQL tab.

See issue #1211.
2017-11-02 22:24:55 +01:00
Martin Kleusberg
ee32b3e4e1 Use nullptr where possible 2017-10-30 21:20:02 +01:00
Martin Kleusberg
1ca92cdde3 Use our Settings class everywhere
Don't use the QSettings class directly. This keeps the code more
consistent and makes it a bit easier to read. It also means that all
parts of the code profit from the settings cache that we have
implemented in the Settings class.
2017-10-30 13:37:34 +01:00
Martin Kleusberg
3bd2dc3bc1 Replace 'foreach' by range-based for loop from C++11 2017-10-30 13:10:08 +01:00
Martin Kleusberg
18b781495c Simplify code 2017-10-27 18:36:39 +02:00
Martin Kleusberg
955848f957 Improve detection of query vs. modify statements in Execute SQL tab
This should improve the detection of read-only query statements vs.
modifiying statements in the Execute SQL tab. The idea is to stop
looking for the SELECT keyword at the beginning of the statement and
instead fully rely on whether SQLite returns any data for this
statement.

See issue #1185.
2017-10-27 18:36:39 +02:00
Martin Kleusberg
b9595b9b7e Remove the valid flag from the SqliteTableModel class
Remove the valid flag from the SqliteTableModel class and remove its
usage in the Execute SQL tab of the main window. I believe this hasn't
been used for some time now because the main sources of error should
really be noticed before the query is even handed over to the model.
Additionally the valid flag wasn't as realible either anymore because of
the multi-threaded execution of the model queries.
2017-10-27 18:36:39 +02:00
mgrojo
9fd4ebe0e0 Fixed crashed when editing the display format and the currently browsed table name is actually a view.
Now it is checked the object type before the cast. This avoids the crash and the field name is obtained for each case.
2017-10-27 11:50:38 +02:00
Martin Kleusberg
c69314f566 Fix ampersand not showing up in dialog when renaming SQL tabs
This didn't work on Windows as pointed out by Chris Locke.
2017-10-27 11:30:59 +02:00
Martin Kleusberg
66fa44497d Try to fix build on Windows
See issue #1193.
2017-10-26 23:24:04 +02:00
Martin Kleusberg
bc91126b2c Allow renaming SQL tabs by double clicking them
See issue #1186.
2017-10-22 14:08:52 +02:00
Martin Kleusberg
37e5b62842 Make code easier to read 2017-10-20 17:47:04 +02:00
Martin Kleusberg
32da4de94d Fix collate warning after addition of multi-threaded loading
The no collate function warning is triggered in a thread which is used
for loading data. However, the warning is a message box and GUI elements
can only be drawn in the main thread. So the old code would crash. This
is fixed here by jumping to the main thread for showing the message box.
2017-10-16 21:58:30 +02:00
Martin Kleusberg
973f97c1eb Move row count query into a separate thread
In the SqliteTableModel class we need to know the total number of rows
in the table or returned by the query. This takes a considerable amount
of time and can be moved into a separate thread. I haven't done any
performance measurements with this but it might speed up switching
between large tables a bit.
2017-10-15 11:46:47 +02:00
kehugter
c4c4cf62a2 Remove activateWindow() when EditDock is toggled
There's no need to set sqlitebrowser as active window when updating
the main application window. The `activateWindow()` call prevents
switching workspaces in GNOME and Cinnamon desktops.

Fixes #934
2017-10-11 22:54:06 +02:00