You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Custom type isn't saved when enter isn't pressed #1144
Steps to reproduce:
Create a new table and add a field. In the field edit the type to say VARCHAR(5). If you don't press enter after writing the custom type and e.g. just add another field, the custom type isn't saved when confirming the table structure (the SQL below the table isn't updated in this case).
This is extremely error-prone and confusing because it seems that the value has been entered as the Type column shows the custom type but the default INTEGER type is saved instead. It's pretty easy to forget to press enter especially when one wants to modify types of an existing table to something else and quickly pastes the new value to multiple columns.
It would be best to update the SQL command not only on enter, but also when mouse focus leaves the table and to be sure also when OK is pressed when confirming the dialog.
I had a look at the code (without knowing Qt at all) and it seems that the problem is that the updateTypes() function which is responsible for updating the SQL command is invoked for the currentIndexChanged signal:
This means it's invoked only when the value entered corresponds to some entry inside the combo box and the selected index of the value changes. This works fine for the pre-defined types which are present in the combo box as entering the existing value triggers the index change. By accident it also works when enter is pressed for an undefined value - enter causes that the new value is added to the combo box and afterwards the index changes.
Ideally this shouldn't happen in currentIndexChanged but some "focus lost" signal but at least looking here
I don't see any such signal (again, I don't know Qt, maybe I overlook something). I tried the editTextChanged signal which works fine but I'm not sure if it wouldn't become too slow for tables with many fields because it updates the SQL query after entering every single character.
@techee I only read your comment now. Looks like you're learning very quickly considering that you say that you don't know Qt 😄 As I said in your PR, you're always welcome to have a look at the code and see if you can fix it. If you're in doubt about something, just open an incomplete PR and we'll try to help you out. But if you don't have the time, that's no problem either 😄
@MKleusberg Well, I've used quite a few UI libraries by now (GTK, Cocoa touch, wxWidgets, Tk, ILOG Views, xlib) so Qt wasn't very surprising (except that widgets don't have a focus-out signal :-/).
Sqlitebrowser works really well for me otherwise so I'm not so much motivated to do more work right now (and I'm involved in other open source projects so I don't have so much time either). The only other problem I'm facing is #1142 which I'll rather leave to you because it would take too much time to study the grammar, I'd probably overlook some corner case and I have no experience with ANTLR (just bison).
Activity
justinclift commentedon Sep 18, 2017
Good catch @techee. 😄
techee commentedon Sep 18, 2017
I had a look at the code (without knowing Qt at all) and it seems that the problem is that the updateTypes() function which is responsible for updating the SQL command is invoked for the currentIndexChanged signal:
https://github.com/sqlitebrowser/sqlitebrowser/blob/master/src/EditTableDialog.cpp#L536
This means it's invoked only when the value entered corresponds to some entry inside the combo box and the selected index of the value changes. This works fine for the pre-defined types which are present in the combo box as entering the existing value triggers the index change. By accident it also works when enter is pressed for an undefined value - enter causes that the new value is added to the combo box and afterwards the index changes.
Ideally this shouldn't happen in currentIndexChanged but some "focus lost" signal but at least looking here
http://doc.qt.io/qt-5/qcombobox.html
I don't see any such signal (again, I don't know Qt, maybe I overlook something). I tried the editTextChanged signal which works fine but I'm not sure if it wouldn't become too slow for tables with many fields because it updates the SQL query after entering every single character.
MKleusberg commentedon Sep 19, 2017
@techee I only read your comment now. Looks like you're learning very quickly considering that you say that you don't know Qt 😄 As I said in your PR, you're always welcome to have a look at the code and see if you can fix it. If you're in doubt about something, just open an incomplete PR and we'll try to help you out. But if you don't have the time, that's no problem either 😄
techee commentedon Sep 19, 2017
@MKleusberg Well, I've used quite a few UI libraries by now (GTK, Cocoa touch, wxWidgets, Tk, ILOG Views, xlib) so Qt wasn't very surprising (except that widgets don't have a focus-out signal :-/).
Sqlitebrowser works really well for me otherwise so I'm not so much motivated to do more work right now (and I'm involved in other open source projects so I don't have so much time either). The only other problem I'm facing is #1142 which I'll rather leave to you because it would take too much time to study the grammar, I'd probably overlook some corner case and I have no experience with ANTLR (just bison).
MKleusberg commentedon Sep 19, 2017
Ah I see 😄 And no worries, I'm glad Sqlitebrowser mostly just works fine for you 😄