[Lazarus] Treeview Question

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[Lazarus] Treeview Question

Free Pascal - Lazarus mailing list
Hi,

I'm porting an application I started (but never finished) in Pyside to Lazarus. This question is only about cosmetics as Treeview works as I want it to.

In Pyside I could set a space between nodes by setting the node text as "" and disabling that node so it never gets selection, e.g.

    self.tvSpace001 = QTreeWidgetItem(self.leftTreeWidget)
    self.tvSpace001.setText(0, "")
    self.tvSpace001.setDisabled(True)

In Lazarus there seems to be no disabled property for nodes, so when transversing a node with text "" with the keyboard, it will move onto that empty node but not highlight it, when I would prefer it instead moved onto the next or previous node and highlight it.

I could write a workaround, storing the last node index, working out if the user has moved up or down, checking if the text is "" and highlighting the previous or next node as required, BUT I just wondered if anyone has a more simple, more elegant solution please?

It's only to show visual definition between groups of parents and childs and doesn't actually affect how the application works.

Thanks for your help.

Martin

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Treeview Question

Free Pascal - Lazarus mailing list
On 6/30/20 1:10 AM, Martin via lazarus wrote:

> Hi,
>
> I'm porting an application I started (but never finished) in Pyside to
> Lazarus. This question is only about cosmetics as Treeview works as I
> want it to.
>
> In Pyside I could set a space between nodes by setting the node text as
> "" and disabling that node so it never gets selection, e.g.
>
>      self.tvSpace001 = QTreeWidgetItem(self.leftTreeWidget)
>      self.tvSpace001.setText(0, "")
>      self.tvSpace001.setDisabled(True)
>
> In Lazarus there seems to be no disabled property for nodes, so when
> transversing a node with text "" with the keyboard, it will move onto
> that empty node but not highlight it, when I would prefer it instead
> moved onto the next or previous node and highlight it.
>
> I could write a workaround, storing the last node index, working out if
> the user has moved up or down, checking if the text is "" and
> highlighting the previous or next node as required, BUT I just wondered
> if anyone has a more simple, more elegant solution please?
>
> It's only to show visual definition between groups of parents and childs
> and doesn't actually affect how the application works.

Lazarus uses it's own implementation of TTreeView, so you have to create
your own LCL wrapper for QTreeWidget.

zeljko

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Treeview Question

Free Pascal - Lazarus mailing list
In reply to this post by Free Pascal - Lazarus mailing list
On Tue, Jun 30, 2020 at 2:10 AM Martin via lazarus
<[hidden email]> wrote:
> In Lazarus there seems to be no disabled property for nodes, ...

It could be implemented in TreeNode.
However property "Enabled" instead of "Disabled" would be more
consistent with other controls.

Juha
--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Treeview Question

Free Pascal - Lazarus mailing list
In reply to this post by Free Pascal - Lazarus mailing list
Thank you. I didn't particularly want to use QT in Lazarus but Pyside is QT only. 

I'll get my application up and working first I think and then maybe have a look at the treeview source for cosmetic tweaks. Writing my own wrapper for a QT widget set is beyond my capabilities but thank you anyway.

Best regards,

Martin

On 30 June 2020 08:09:39 zeljko <[hidden email]> wrote:

On 6/30/20 1:10 AM, Martin via lazarus wrote:
Hi,

I'm porting an application I started (but never finished) in Pyside to 
Lazarus. This question is only about cosmetics as Treeview works as I 
want it to.

In Pyside I could set a space between nodes by setting the node text as 
"" and disabling that node so it never gets selection, e.g.

    self.tvSpace001 = QTreeWidgetItem(self.leftTreeWidget)
    self.tvSpace001.setText(0, "")
    self.tvSpace001.setDisabled(True)

In Lazarus there seems to be no disabled property for nodes, so when 
transversing a node with text "" with the keyboard, it will move onto 
that empty node but not highlight it, when I would prefer it instead 
moved onto the next or previous node and highlight it.

I could write a workaround, storing the last node index, working out if 
the user has moved up or down, checking if the text is "" and 
highlighting the previous or next node as required, BUT I just wondered 
if anyone has a more simple, more elegant solution please?

It's only to show visual definition between groups of parents and childs 
and doesn't actually affect how the application works.

Lazarus uses it's own implementation of TTreeView, so you have to create 
your own LCL wrapper for QTreeWidget.

zeljko


--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Treeview Question

Free Pascal - Lazarus mailing list
In reply to this post by Free Pascal - Lazarus mailing list
On Tue, 30 Jun 2020 11:20:58 +0300
Juha Manninen via lazarus <[hidden email]> wrote:

> On Tue, Jun 30, 2020 at 2:10 AM Martin via lazarus
> <[hidden email]> wrote:
> > In Lazarus there seems to be no disabled property for nodes, ...  
>
> It could be implemented in TreeNode.
> However property "Enabled" instead of "Disabled" would be more
> consistent with other controls.

Or you can write a descendant of TTreeView with your descendant of
TTreeNode.

Mattias
--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus