Kexi/Plugins/Tables/Table hyperlinks: Difference between revisions
Rshtemberko (talk | contribs) No edit summary |
Rshtemberko (talk | contribs) |
||
Line 12: | Line 12: | ||
==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.'' | |||
=== 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]]. |
Revision as of 09:58, 28 August 2015
Design page for task: "Add support for displaying clickable hyperlinks in the tabular view ".
- Started: Jstaniek October 2012
- Wish #308838
- Target: ?
- Status: In Progress, Assigned to Roman Shtemberko
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.
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
...