Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow viewing via the EditDialog for executed sql statements #570

Merged
merged 5 commits into from
Apr 25, 2016

Conversation

larsimmisch
Copy link
Contributor

This patch allows to view result data from the Execute SQL tab in the EditDialog.

This patch is lightweight and already useful to me - and hopefully other people

Ideally, I'd like to be able to edit the data too, but I couldn't get it to work, because when the user enters freeform SQL, it is nontrivial to determine what the underlying table is (see http://www.sqlite.org/sessions/lang_select.html).

Editing is disallowed, becuase we do not know which table the freeform
query operates on
@@ -32,7 +34,8 @@ class SqlExecutionArea : public QWidget
SqliteTableModel* getModel() { return model; }
QTextEdit* getResultView();
SqlTextEdit* getEditor();

ExtendedTableWidget *getTableResult();
Copy link
Member

@justinclift justinclift Apr 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, this seems to be using embedded tabs instead of spaces.

Would you be ok to fix that (for the other files you're touching too)? 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, sorry. These are the (retarded) whitespace settings I had to configure for work.

Should be fixed

@justinclift
Copy link
Member

Thanks, trying it out here now. 😄

@justinclift
Copy link
Member

Hmmm, I must be blind... I'm not noticing a change from an end user point of view?

Er.... clue me in? 😀

@@ -989,7 +989,8 @@ void MainWindow::mainTabSelected(int tabindex)
} else if(tabindex == 3) {
SqlExecutionArea* sqlWidget = qobject_cast<SqlExecutionArea*>(ui->tabSqlAreas->currentWidget());

m_currentTabTableModel = sqlWidget->getModel();
if (sqlWidget)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops! 😁

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got me. It's late.

@larsimmisch
Copy link
Contributor Author

Ah. I think there is a double-click action missing, so I have to admit it is nonobvious:

To see what I am trying to accomplish:

  • open a database
  • enable View -> Edit Cell
  • Go to Execute SQL and enter a select statement suitable for your db.
  • In the result table view, click on an item and watch the Edit Cell update the data.

I use this for a db that has lots of JSON blobs that I need to inspect.

@justinclift
Copy link
Member

justinclift commented Apr 20, 2016

Ahhh, interesting addition. Found a bug in it though, where it's not clearing the existing Edit Cell data when a new field on the same row is clicked.

The test database I'm using is very small (516KB). Just emailed it to you, along with the SQL used to trigger the bug. Hopefully it's something simple. 😄

@larsimmisch
Copy link
Contributor Author

larsimmisch commented Apr 20, 2016

Yes, please.

Also, I'll look into adding a double click action so that the Edit Dialog opens when a cell is double clicked. That would make the new functionality much more discoverable.

(But not today, I'll look into it tomorrow)

@justinclift
Copy link
Member

Sure, no worries at all. It's late here for me too. 😄

@larsimmisch
Copy link
Contributor Author

I added the double click action (much better).

But I can not reproduce your bug on my machine. In any case, I don't understand how I could have introduced that sort of bug - this pull request mostly only connects the edit dialog with the result table.

Can you reproduce your bug when browsing the table?

@justinclift
Copy link
Member

Cool. 😄

For the weird bug behaviour, @MKleusberg returned from holidays yesterday, so he's probably the right person to review bits. (there is a large queue for him through 😵 )

I really should get around to learning C++ eh? 😉

@MKleusberg
Copy link
Member

Hi Lars!
First of all thank you very much for the contribution 😃 I've just had a first quick look and it seems to work very well and to really improve the user experience 👍 I'll have a closer look soon and will just put some comments into the Github diff. From what I can tell it'll be mostly code style though 😃

I'm not sure either how the bug mentioned by Justin could be introduced by this. But maybe he can help us out here debugging this - though I assume the bug is to be found somewhere else, most likely in my code for the edit cell panel itself, not in your code. So I probably won't be worrying about that too much for this pull request.

@larsimmisch
Copy link
Contributor Author

Thanks for the quick thumbs-up (to both of you)

If you have suggestions regarding code style, do let me know and I will update the pull request

@@ -270,7 +270,8 @@ QSet<int> ExtendedTableWidget::selectedCols()
void ExtendedTableWidget::cellClicked(const QModelIndex& index)
{
// If Alt key is pressed try to jump to the row referenced by the foreign key of the clicked cell
if(qApp->keyboardModifiers().testFlag(Qt::ControlModifier) && qApp->keyboardModifiers().testFlag(Qt::ShiftModifier) && model())
if(qApp->keyboardModifiers().testFlag(Qt::ControlModifier) && qApp->keyboardModifiers().testFlag(Qt::ShiftModifier)
&& model())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to keep this line as it was. Since there is no code changed in this file, changing the formatting of this line could be confusing later: it looks like the code in this file was changed by this commit when in reality it wasn't. Hope this makes sense 😀

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry - that was just an automatism on my part. I'll revert that change

@MKleusberg
Copy link
Member

I've put some comments concerning the code-style in your commits. Nothing major, though 😃 There's one more techical suggestion in there, too. Despite those I just noticed one more thing: if you have multiple SQL tabs opened, each showing a query result with a selected cell, the edit cell panel isn't updated when you switch between the tabs. This might be a bit confusing for the user to see the 'old' value there. But again, nothing major 😀 If you're interested you could maybe add a new slot which is getting triggered when the selected SQL tab changes and which just updates the panel to the current selection.

Sorry again for the nitpicking parts 😃 I actually think this is quite a good pull request which I hope we can merge as soon as possible 👍

@larsimmisch
Copy link
Contributor Author

Hi @MKleusberg: I've made the changes you suggested - thank you for your thorough review.

I'll look into the new slot for multiple SQL tabs this evening, but I'd prefer to open a new pull request for that.

@MKleusberg
Copy link
Member

Awesome! Looks good 👍 Thank you very much for this 😃 If you should need any help with your next pull request feel free to always open an issue or email me directly - I'd be glad to help out.

@MKleusberg MKleusberg merged commit 1192f45 into sqlitebrowser:master Apr 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature requests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants