-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
More options in conditional formatting #2013
Conversation
The column headers contained in a selection are highlighted for consistency to the row headers and to emulated spreadsheet behaviour.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are the only two (minor) issues I found. It all works really well 😄 Maybe it's best to merge this quickly then, just to avoid more merge conflicts later.
return condFormat; | ||
bool isNumber; | ||
value.toDouble(&isNumber); | ||
return isNumber ? Qt::AlignRight : Qt::AlignLeft; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add vertical alignment here? Like so:
return static_cast<int>((isNumber ? Qt::AlignRight : Qt::AlignLeft) | Qt::AlignVCenter);
Same for the case where there is a conditional format. At least on my system it looks kind of weird without this because Qt set the row height a bit to high.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or what about AlignBottom? That is what LibreOffice does by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the other hand, LibreOffice centers vertically when the height of the text and the cell are the default. I'll use your proposal, since it was the alignment used before this change.
QTreeWidgetItem* item = ui->tableCondFormats->topLevelItem(selectedRow); | ||
|
||
// Rescue widgets, since they will be deleted, and add them later. | ||
QFontComboBox* fontCombo = qobject_cast<QFontComboBox*>(ui->tableCondFormats->itemWidget(item, ColumnFont)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new toolbar is hidden by default and can be toggled using a button in the main Data Browser toolbar. Margins and spacing have been updated to improve appearance of the two toolbars. These tool buttons apply the format to the columns which are contained in the selection. This is done by updating or adding a new condition-less format to the list of conditional formats of those columns. New style icons from the Silk icon set. Changed existent ones for coherence. See issue #1976.
I'm having problems with the merge. The find functionality has stopped moving the scroll to the found cell, don't know why. @MKleusberg, in case you have some idea about where to look, it will be appreciated. I go on looking into this. |
I had to add a call to |
The requested text alignment is always combined with AlignVCenter, which is the value used before conditional formatting was implemented and gives better display result. When creating a new conditional formatting while applying a format from the toolbar to a column which does not already have one, the alignment flag of the format is taken from the current cell. In this way, the default text alignment for numbers is preserved. See issue #1976 and PR #2013
I've discovered the problem with the find toolbar, which is also affecting the cursor navigation inside the table. I'm trying to use a protected slot as if it were a signal. sqlitebrowser/src/TableBrowser.cpp Line 196 in b7f6bef
sqlitebrowser/src/ExtendedTableWidget.h Line 78 in b7f6bef
I've tried with this without success: connect(ui->dataTable->selectionModel(), &QItemSelectionModel::currentChanged, this, [this]() { Isn't there any signal to be notified when the current index changes? |
@scottfurry @MKleusberg ping? 😄 |
Part of the problem may be the inheritance. TableBrowser class has QWidget as parent. Unlike other Qt classes with underlying table structures, we're missing a signal. Easiest solution is to edit the header and custom signals and/or slots
... and then the implementation in the cpp file. |
Oh yeah... and then implement the connectivity where used. |
An example of a custom color widget: // https://stackoverflow.com/questions/18257281/qt-color-picker-widget/43871405#43871405 |
Thank you, @scottfurry. I guess I can reimplement the currentChanged slot in ExtentedTableWidget, call the parent implementation and then emit a new signal that can be connected from TableBrowser. I'm just surprised that there doesn't seem to be an easier way. |
Hello @mgrojo Just tested on Windows 10 (64 bit) the new options as regards the Conditional Formats Just a minor glitch: On top of this, you lose all your changes when you close the database. BTW, with the conditional formats you can not undo quickly your change (with other applications the shortcuts are usually ctr+z to undo AND ctr+y to redo). You are forced to apply the conditional filter once again to remove the colours. |
Hello @mgrojo Today, I have tested your improvements on a different computer at work. A problem with the conditional format is that I can not find a way to select only the whole word. As far as the changes in the GUIs are concerned (I mean the option to save all format changes in the preference file, in order to get them when you reopen the database) I really don't know whether this might open a can of worms. In short, create a feature which is extremely complicated and extremely time-consuming to code. With GUIs changes (new improvements) there are often new bugs as soon as you change the QT version. On Windows 64, the current version with Db Browser is 5.11.3 whereas the stable version for QT is 5.13.X... |
Great to hear that!
No? I can resize it in Linux native and in Linux using Wine. Do you mean the column or that box that appears in your screenshot?
Yes, there are issues in this dialog. In my case they are fixed when you resize the window. It seems a Qt bug, but don't know whether I'm doing something "unusual".
Aha, I tested only when opening an already saved project, and I didn't notice that we are not warning the user to save the project when there is no project file, except for changes in SQL tabs. I guess we should do the same when there are changes in conditional formats.
I knew this was the next thing to be missed! You already have the reset button in the dialog and the "Clear All Conditional Formats" in the toolbar, but I know they are a poor replacement. Some day...
I don't get this. You hadn't seen yet the toolbar, had you? It doesn't allow yet direct formatting of cells, only of whole columns, though.
You can save them in a project file. The only thing missing is the warning to save the changes when you haven't saved to a project file yet.
Great! Icons thanks to our usual icon set: http://www.famfamfam.com/lab/icons/silk/preview.php
The condition field has the same syntax as the filters. So you can write "=melon" and melone will not match the conditional format. Did you mean that or have I misunderstood? Ideally the condition box should also have the same contextual menu than the filters.
Are you aware that you can save them in a project file? Definitely the warning when the use has changed the formats but not yet created a project file is needed.
The same warning should be raised when adding display formats. What if we warn the user with any change? The problem is that changing column sizes, sorting, filter... might be too minor to ask for saving when the user has open directly the DB. Any opinions?
It would be good to test whether the glitches with the Conditional Format Manager dialog are solved. @justinclift would it be possible? |
Hello @mgrojo,
Yeah. It might be annoying... BTW, I have just looked for a whole word with = and it does work (e.g. =melo), in the conditional format. Thanks for the tip!
Yep. I am aware. I did not make myself clear in my previous message (sorry about that). |
EDIT:
Nope. I am completely wrong here! QT 5.13.1 is the bleeding edge brand-new version. |
This fixes the following issues, which might be Qt bugs or not: - When moving an item to the top, the inserted widgets of the other items are misplaced. - When columns are resized to contents, the font combo box does not resize with the column, overlapping the cells to its right. - When adding a new item, the text just input in one filter line edit could be lost. See issue #1976 and comments in PR #2013.
This implements more style options for the conditional formats feature (#1815), being the first step in the addition of more formatting options to the data browser (#1976).
This also adds some minor spreadsheet-like features, like default right alignment for numbers and highlighting of column headers when a cell of that column is included in the selection.
See individual commits for details.
It is ready for merging and testing, but I plan to add more free formatting capabilities later.