Kexi/Plugins/Tables/Table hyperlinks: Difference between revisions

From KDE Community Wiki
< Kexi‎ | Plugins‎ | Tables
No edit summary
No edit summary
 
Line 5: Line 5:
*Target: ?
*Target: ?
*Status: '''Waiting for more specifications'''
*Status: '''Waiting for more specifications'''
*https://invent.kde.org/office/kexi/-/issues/137


__TOC__
__TOC__

Latest revision as of 21:05, 13 April 2023

Design page for task: "Add support for displaying clickable hyperlinks in the tabular view ".

Rationale

It should be possible to display a clickable hyperlinks based on data from a text field in the tabular view.

Details

The links should be displayed as underlined with default hyperlink style. This applies also to local paths.


Below are propositions by Roman Shtemberko.

General implementation propositions

Based on information below, I would propose the following implementation:
Rendering: If text has hyperlink(s) and/or local path(s) - split text on normal/links parts and use drawText() to draw each part successively, changing QPainter properly for each part.
Link opening: Implement separate context menu option for cells with links/paths for links opening.


Hyperlink Detection

Detect link in the text

Links can be detected by searching the text of the cell for some patterns, e.g. "http::/" and "https://" followed by some symbols/numbers for hyperlinks. RegEx can be used (see 6th milestone here ).

Local paths can be more trickier: for Unix-likes it will probably be '/' at the begging, Windows - "::\" preceded by some letter (disk name). I haven't found any RegEx for that yet.

Alternatively we can make links/paths to follow some pattern, like: [link text](link itself)
[link]
["http://","https://"]
etc.

Also we can use QLabels with Rich Text support for each of the cells.

Where to perform detection

1) We can perform checks just when we need them, i.e. on text rendering.
2) We can perform checks once text is loaded and after it's edited. This will require some more tweaking for the each text cell to store something like hasHyperlink. Also we might want to store different parts of text that is/is not hyperlink (see Text Rendering).

Text Rendering

1) Use QPainter::drawText() to draw hyperlinks (font - blue, underlined). In this case we will need to successively draw each part of the text, e.g. text-link-text-link depending on how plain text is mixed with hyperlinks in the cell.
2) Use the same approach as in 1, but draw hyperlinks as QLabels (QWidget::render()).

Open link signal

As double-click on the cell is reserved for editing, I would assume we need context menu option for opening links.
No more guesses so far.

See also Forms/Button hyperlinks.

Further work

...