or do you think this is niche enough to not warrant a PR into the official repo?
hmm, true.
The thought of this PR was for specifically todo comments in the style of
// todo: something
perhaps we have the keyword with a :
character following case-insensitive? thoughts?
This simple changes marks alerts as non-case sensitive. for example, some preferences might have todo
as lower case, and would not have been syntax highlighted
related bug/feature request: https://bugs.kde.org/show_bug.cgi?id=474884
Jamal Bouajjaj (78c7ab92) at 10 Oct 02:37
Changed case sensitivity
I concur that this PR greatly improves performance, at least anecdotally loading a particular data set's worksheet went from unusable to great.
It looks like I have access to edit it when not using my VPN. I updated the stable release. For the screenshot, is there a prime example of one that I can update it with?
So I got it working in an experimental stage:
I did this by, inside PageItemDelegate
, calling the parent's header width. I found (thru debugging) that the ratio between a child's actual paint width and the width of the header to be about 75%, so I calculate the height with a 60% header width. Then I create a custom QTreeView
class that overrides the resizeEvent
callback, which it also calls the dataChanged
function for all indexes.
It's not perfect, but it seems to be working so far. More testing and cleanup is needed before this can be released, perhaps noted as an experimental feature (maybe have it's own experimental section in the configuration menu)
Jamal Bouajjaj (9421510b) at 19 Jul 02:57
Mostly working
Nope, it doesn't. Actually if you read option.features
that is given to paint
, it already has that flag set.
As I noticed the chicken-and-egg problem with getting an item's width (part of it's size property, which includes the height) and painting the item, I have a couple of ideas/hacks to get this working:
SizeHint
) and the width of an item and subitems. Need to debug the width to see if a relationship can be made. Then add something like a 1.1-1.2 multiplier for head-roomThoughts? I'm going to investigate the last option, and it seems like the best way to handle this.
EDIT: Added the 3rd option
So it's kind of working as of the latest commit. The PageItemDelegate::paint
function calls setData
for a model for the index's rectangle width, and inside TOCModel::data
for SizeHintRole
it looks up that width with index.data()
.
Unfortunately SizeHintRole
only gets called when for example if an item is double clicked. Ideally the paint
function or drawDisplay
would call an equivalent of sizeHint
as it's drawing stuff, but that leads into a chicken or egg situation when during painting, it knows the index's width, calls the sizeHint, but that must recall paint
and the cycle continues.
Jamal Bouajjaj (1f73f0d9) at 07 Jul 04:34
Kind of working
Jamal Bouajjaj (ff148bdc) at 06 Jul 07:10
Playing around with setting a model's height for word wrapping. Sti...
Ok so I got it kind of working:
QSize PageItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
{
// https://stackoverflow.com/questions/8932966/how-to-get-qtreeview-cell-width-inside-qitemdelegate-sizehint
QSize sz = QSize(d->parent->header()->sectionSize(0), 10000);
qDebug() << d->parent->header()->sectionSize(0);
qDebug() << index.data().toString() << sz;
QFontMetrics metrics(index.data(Qt::FontRole).value<QFont>());
QRect outRect = metrics.boundingRect(QRect(QPoint(0, 0), sz), Qt::AlignLeft | Qt::TextWordWrap, index.data().toString());
sz.setHeight(outRect.height());
return sz;
}
Issue tough is that sizeHint only gets called when for example an item in the TOC gets clicked on, and doesn't account for things like font changes:
This is probably some callback function I have to implement somewhere, right? The other option is to implement word wrapping inside of drawDisplay
directly, but I am unsure as how to have that function essentially call a sizeHint to QT. Need to dig to it some more
I've started to look down that route:
QSize PageItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QSize sz = QItemDelegate::sizeHint(option, index);
qDebug() << index.data().toString() << sz << index.data(Qt::SizeHintRole).value<QSize>();
QFontMetrics metrics(index.data(Qt::FontRole).value<QFont>());
QRect outRect = metrics.boundingRect(QRect(QPoint(0, 0), sz), Qt::AlignLeft | Qt::TextWordWrap, index.data().toString());
sz.setHeight(outRect.height());
return sz;
}
Issue here is calling the parent QItemDelegate::sizeHint
function returns a size hint for the text, not of the view's (which is what I need to compensate for a word wrap's width)
Hm, intresting. In that case perhaps the best location for the height adjustment will be in the drawDisplay
function as it gets the rectangular area of the item as part of it's argument. Issue there is that adjusting the delegate height does not adjust the model's height, got to look into if there's a way of doing so.
I've started to take a look at PageItemDelegate
, and overriding the sizeHint
function also works for this purpose. Still same issue tough of trying to get the list item's width so that word wrapping can be compensated for in height.