Opened 5 years ago

Closed 5 years ago

#11620 closed enhancement (fixed)

Add wxTreeCtrl::SelectAll()

Reported by: TNikolay Owned by:
Priority: low Milestone:
Component: GUI-all Version: stable-latest
Keywords: wxTreeCtrl selection simple Cc:
Blocked By: Blocking:
Patch: yes

Description

Why wxTreeCtrl has UnselectAll(), but does not has SelectAll()? I noticed that there is no direct way correctly write method SelectAll for wxTreeCtrl delivered class without duplicating a lot of private code from wxTreeCtrl class. So I have tried add this method into wxTreeCtrl. Hope it's a correct version.

Attachments (3)

tree-add-select-all.patch download (1.9 KB) - added by TNikolay 5 years ago.
tree-selectall.patch download (8.3 KB) - added by TNikolay 5 years ago.
tree-selectall-vz.diff download (8.0 KB) - added by vadz 5 years ago.
VZ's updated version of the patch

Download all attachments as: .zip

Change History (10)

Changed 5 years ago by TNikolay

comment:1 follow-up: Changed 5 years ago by vadz

  • Component changed from wxMSW to GUI-all
  • Keywords simple added
  • Priority changed from normal to low
  • Status changed from new to confirmed
  • Summary changed from Adding wxTreeCtrl::SelectAll() to Add wxTreeCtrl::SelectAll()
  • Type changed from defect to enhancement

Thanks for your patch, I agree that adding this method would make sense.

However, as usual, we need:

  1. Documentation for the new function (in interface/wx/treectrl.h)
  2. Its declaration in the base class
  3. Its implementation for the generic version (this is so simple that it really seems a pity to not add it)
  4. ideally a test for it in the tree sample

TIA!

comment:2 in reply to: ↑ 1 Changed 5 years ago by TNikolay

  • Patch set

I did all that, but I see two problems

  1. I don't sure that I did all correct for the generic version - somebody who know how it works should check and fix this:)
  1. I have added in include/wx/treectrl.h a two pure virtual functions, it seems something should be added to all ports now, in order to compile them?

Changed 5 years ago by TNikolay

comment:3 Changed 5 years ago by vadz

  • Status changed from confirmed to infoneeded_new

The patch looks great now, thanks for updating it! I've done just a couple of minor changes, please see my version in the attachment.

But I am confused now: why doesn't the method called SelectAll() actually select all items? I could understand if it selected only the children of the given parent but I don't understand why does it select only the immediate children.

If this is really intentional, the method should be called differently, e.g. SelectChildren() because it's not the opposite of UnselectAll(). But I wonder if this is really intentional and if this behaviour is really useful?

Changed 5 years ago by vadz

VZ's updated version of the patch

comment:4 follow-up: Changed 5 years ago by TNikolay

  • Status changed from infoneeded_new to new

I can't imagine situation where we need to select all children. Do you know such user case?

But you are right in general case SelectAll should select all :) What about the following version ?

SelectAll(const wxTreeItemId& parent, bool onlyDirectChildren = true);

I think I can modify code in order to implement this

comment:5 in reply to: ↑ 4 Changed 5 years ago by vadz

Replying to TNikolay:

I can't imagine situation where we need to select all children. Do you know such user case?

In my own program I use wxTreeCtrl to present the list of mailboxes. I could see how selecting all of them could be useful if you had an operation which works on all selected folders (I don't and the tree is single selection anyhow but well, it's an example...).

But you are right in general case SelectAll should select all :) What about the following version ?

SelectAll(const wxTreeItemId& parent, bool onlyDirectChildren = true);

I think I can modify code in order to implement this

I dislike boolean arguments so I still think that it should be renamed to SelectChildren(). I can do it with the existing patch (my version of it) if you agree.

comment:6 Changed 5 years ago by TNikolay

In my own program I use wxTreeCtrl to present the list of mailboxes. I could see how selecting all of them could be useful if you had an operation which works on all selected folders (I don't and the tree is single selection anyhow but well, it's an example...).

I think - usually when we doing something with folder we doing this and with all its children (delete, move, drag&drop, get some information etc)... so it is enough to select only direct parent. But it does not matter, I do not have any objections against renaming to SelectChildren()

Thanks for help.

 

comment:7 Changed 5 years ago by VZ

  • Resolution set to fixed
  • Status changed from new to closed

(In [63277]) Add wxTreeCtrl::SelectChildren() method.

Add MSW and generic implementation, documentation and change to the sample
showing it.

Closes #11620.

Note: See TracTickets for help on using tickets.