Kexi/Plugins/Tables/Table hyperlinks: Difference between revisions
mNo edit summary |
No edit summary |
||
(5 intermediate revisions by 2 users not shown) | |||
Line 4: | Line 4: | ||
*{{wish|308838}} | *{{wish|308838}} | ||
*Target: ? | *Target: ? | ||
*Status: '''Waiting for more specifications''' | |||
*https://invent.kde.org/office/kexi/-/issues/137 | |||
__TOC__ | __TOC__ | ||
Line 11: | Line 13: | ||
==Details== | ==Details== | ||
The links should be displayed as underlined with default hyperlink style. This applies also to local paths. | 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: <BR> | |||
'''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. <BR> | |||
'''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 [http://code.tutsplus.com/tutorials/8-regular-expressions-you-should-know--net-6149 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)<BR> | |||
[link]<BR> | |||
["http://","https://"]<BR> | |||
etc.<BR> | |||
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. <BR> | |||
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'''). <BR> | |||
=== 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. <BR> | |||
2) Use the same approach as in '''1''', but draw hyperlinks as QLabels (QWidget::render()). <BR> | |||
===Open link signal=== | |||
As double-click on the cell is reserved for editing, I would assume we need context menu option for opening links. <BR> | |||
No more guesses so far. | |||
See also [[Kexi/Plugins/Forms/Button hyperlinks|Forms/Button hyperlinks]]. | See also [[Kexi/Plugins/Forms/Button hyperlinks|Forms/Button hyperlinks]]. |
Latest revision as of 21:05, 13 April 2023
Design page for task: "Add support for displaying clickable hyperlinks in the tabular view ".
- Started: Jstaniek October 2012
- Wish #308838
- Target: ?
- Status: Waiting for more specifications
- https://invent.kde.org/office/kexi/-/issues/137
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
...