Skip to content

Commit

Permalink
multi selection: return ValueChanged if notify and immediate set
Browse files Browse the repository at this point in the history
add comment about single/multi

provide changelog

improve changelog
  • Loading branch information
gabi2 committed May 28, 2013
1 parent c1614c6 commit 0b69bb4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Tue May 28 13:40:41 CEST 2013 - gs@suse.de

- NCTable in multi selection mode: return ValueChanged event if
selection has changed (if options `notify and `immendiate set)

-------------------------------------------------------------------
Fri May 10 10:40:00 UTC 2013 - bjoern.esser@gmail.com

Expand Down
18 changes: 18 additions & 0 deletions src/NCTable.cc
Expand Up @@ -31,6 +31,20 @@

using std::endl;

/*
* Some remarks about single/multi selection:
* A table in single selection mode has only one line/item selected which is equal to the
* current item (means the highlighted line). Asking for `CurrentItem in YCP looks for
* selectedItem() (see YCPPropertyHandler::tryGetSelectionWidgetValue).
* In multi selection mode there can be several items selected (here is means checked/marked
* with [x]) and the value is also got from selectedItem() when asking for `SelectedItems
* (see YCPPropertyHandler::tryGetSelectionWidgetValue).
* This means for multi selection mode: at the moment there isn't a possibility to get the
* `CurrentItem. To get the current item (which line of the list is currently highlighted),
* a virtual function currentItem() like available for the MultiSelectionBox has to be
* provided to allow NCTable to specify the line number itself (getCurrentItem).
*
*/
NCTable::NCTable( YWidget * parent, YTableHeader *tableHeader, bool multiSelection )
: YTable( parent, tableHeader, multiSelection )
, NCPadWidget( parent )
Expand Down Expand Up @@ -529,6 +543,10 @@ NCursesEvent NCTable::wHandleInput( wint_t key )
else
{
toggleCurrentItem();
if ( notify() && immediateMode() )
{
return NCursesEvent::ValueChanged;
}
}
break;

Expand Down

6 comments on commit 0b69bb4

@anaselli
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seem to show what i always said, checks and selections are quite different :)
IMO though a different approach should be provided, i mean now multi-selection in ncurses send a different YEvent, so QT and GTK work differently. I think YTable should have a list of items that can be retrieved by using getSelectedItems(...) and when a selection is performed
this list should be provided with a setSelectedItems(...) maybe in such a case the event should be Selected and not Activated, but that could have regressions in the current usage.
WDYT?
cheers,
Angelo

@anaselli
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm, there a thing i can't get. From header file (immdiate mode explanation)
Deliver even more events than with notify() set.

With "notify" alone, a table widget sends an ActivatedEvent when the
user double-clicks an item or presses the "space" key on it. It does
not send an event when the user just sends another item.

With "immediate", it also sends a SelectionChangedEvent when the user
selects another item. "immediate" implicitly includes "notify".

So it seems that immediate mode includes notify, and i wonder why then if ( notify() && immediateMode() ), moreover i often use in my tests notify only, and without an || notify only does nothing.

Angelo

@gabi2
Copy link
Contributor Author

@gabi2 gabi2 commented on 0b69bb4 Jun 4, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, checks and selections are different. To make this clear I have added the comment "Some remarks about single/multi selection" to NCTable.cc.
getSelectedItems() is not a member of YTable but implemented in YSelectionWidget, see YSelectionWidget.
YSelectionWidget.h
virtual YItemCollection selectedItems();

About the events:
An Activated Event in general means an action should be done, the double click or Return/Space indicate this.
SelectionChanged e.g. in a list means that "only" the line has changed. The exact meaning can differ, e.g. it differs for the Table widget depending on single/multi selection mode set. Not in multiselection mode on Return/Space an Activated event is returned, in multiselection mode it means this line will be checked/unchecked (toogled). See also comment in NCTable.cc about the selectItem().
I have added the ValueChanged event to NCTable to indicate that the list of selected items has changed. Of course, this should be added to YQTable as well.

About the options:
notify andimmediate determine when to send the event. Yes, immediate somehow include notify but this is like this for all widgets (see also NCSelectionBox).

To have a better understanding of how to use the options/the events I have added 2 additional examples to yast-ycp-ui-bings (Table8-mutliSel.ycp and MutiSelectionBox5.ycp).

@anaselli
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow, i have a lot of things to check after your comment :)
BTW your change, allows me to add checkable columns easily now. Can you give a look at my fork to see if the implementation i did now is more suitable? Thanks

@gabi2
Copy link
Contributor Author

@gabi2 gabi2 commented on 0b69bb4 Jun 4, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can take a look at the new examples Table8-mutliSel.ycp and MutiSelectionBox5.ycp (and also the other examples for the table widget ) on git@github.com:yast/yast-ycp-ui-bindings.git. I think the examples are well suited for understanding how the events/options are used in practice.
To run the examples, call "/usr/lib/YaST2/bin/y2base ./Example.ycp ncurses (or qt)".
To have the changes in NCTable from this commit available you have to compile the yast-ycp-ui-bindings. Table8-multiSel.ycp will then show the list of selected items on every change in selection (for ncurses; not yet for qt).
table_multi

@anaselli
Copy link
Contributor

@anaselli anaselli commented on 0b69bb4 Jun 4, 2013 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.