=== chriadam|away is now known as chriadam | ||
kongsu | hello | 05:26 |
---|---|---|
=== chihchun_afk is now known as chihchun | ||
dholbach | good morning | 06:54 |
=== chriadam is now known as chriadam|away | ||
=== chihchun is now known as chihchun_afk | ||
=== chihchun_afk is now known as chihchun | ||
=== _salem is now known as salem_ | ||
=== chihchun is now known as chihchun_afk | ||
=== chihchun_afk is now known as chihchun | ||
=== JanC_ is now known as JanC | ||
didrocks | zsombi: hey, small question about delegates in listView vs refering by id. I had an leading and trailing actions defined within the component itself. However, reading the documentation, for perf reason, you say rightly to put them at outside | 14:21 |
didrocks | like at https://developer.ubuntu.com/api/apps/qml/sdk-15.04/Ubuntu.Components.ListItemActions/ | 14:21 |
didrocks | so, I tried to do that in bhttp://paste.ubuntu.com/11966640/, but I can't access to the item attached to this delegate | 14:21 |
didrocks | value is indeed the index, but I want to access through that index to the correct delegated item | 14:22 |
zsombi | didrocks: there's no item attached to a delegate | 14:22 |
zsombi | didrocks: you cannot do that | 14:22 |
zsombi | didrocks: the thing is that those items are cached, and disappear whjen you scroll out | 14:22 |
zsombi | didrocks: I am checking what are you doing... but I don't get it | 14:24 |
zsombi | didrocks: contentItem is a single item, not an array | 14:24 |
didrocks | zsombi: basically, I want when clicking on "edit" to run a function() on the delegated object | 14:24 |
zsombi | didrocks: and it contains all the list items visible at a time... + the cached ones | 14:24 |
zsombi | delegated object? | 14:24 |
zsombi | didrocks: why woudl you do that? | 14:25 |
didrocks | zsombi: BillListItem content | 14:25 |
didrocks | zsombi: before, it was inlined | 14:25 |
didrocks | (before looking at your perf comment in the doc) | 14:25 |
zsombi | didrocks: why everyone wants to rape ListView? | 14:26 |
didrocks | rape? | 14:26 |
zsombi | didrocks: ListView visualizes a model, you shoudl work on models not on the items, the delegates only visualize the model, they should never do more | 14:26 |
zsombi | didrocks: so if you want too much on a ListItem, you are designing your app wrongly | 14:27 |
zsombi | didrocks: beside, listview.contentItem[value] is just wrong | 14:27 |
didrocks | zsombi: so, basically, you mean that edit() just call the edit on the model? that doesn't sound like controller separated from model | 14:27 |
zsombi | didrocks: ListView.contentItem is a single item, not an array, you cannot access the visible list items like that | 14:28 |
didrocks | got that | 14:28 |
zsombi | didrocks: then, actions do get the index, so they can do whatever is needed based on that | 14:28 |
zsombi | you can do whaveter you want wit separate functions, preferably on the action level, so mbased on the model data and the index you can do your magic | 14:29 |
zsombi | not saying that the edit should be on teh model, but it should be separated from teh delegate (which is btw a Compinent, from which ListView creates the items) | 14:30 |
zsombi | didrocks: so what you should do is to have this function either in the action, which does turn on some whatever page or whatever it is needed to edit the model data from the index | 14:31 |
zsombi | or to have this function somewhere else, but definitely not in the listview's delegate | 14:31 |
didrocks | zsombi: so, let's say I implement this edit() on another handler | 14:31 |
didrocks | zsombi: now, in the ListView, I want that a long press to call this edit() as well, you would pass the handler to each ref? | 14:32 |
zsombi | didrocks: by handler you mean in a different module? | 14:33 |
zsombi | or in a different document? | 14:33 |
didrocks | different document | 14:33 |
zsombi | didrocks: so this handler would be a page? | 14:34 |
zsombi | didrocks: if it is, you use a PAgeStack, then you push the new page with the parameters you need | 14:34 |
zsombi | didrocks: in the action you can reference the ListView.model, right? | 14:34 |
zsombi | didrocks: if the model has a get funtion (like ListModel does) then you simply pass the entire model.get(value) as parameter to the push function | 14:35 |
bregma | folks, I'm looking for information on help apps proposed for the Unity 8 environment -- are there plans or something in the works? | 14:36 |
didrocks | zsombi: right, but it means that the ListItem will have a reference to the handler to call that function on long press event forinstance | 14:36 |
didrocks | zsombi: it has some from the model, of course, but it adds another coupling? | 14:37 |
zsombi | didrocks: thats' why I asked what a handler is, a Page you want to open, or what? | 14:37 |
zsombi | didrocks: beside, now you want long press, in your sample you have trailing actions :) | 14:37 |
didrocks | zsombi: no, it's another Component { function edit() { /* do stuff */ }} | 14:38 |
zsombi | didrocks: component... | 14:38 |
didrocks | zsombi: this is just an example for something where the event is in the ListEvent | 14:38 |
didrocks | ListItem* | 14:38 |
zsombi | didrocks: a Component cannot have anything else but an item in it... | 14:38 |
zsombi | didrocks: or you meant Item {....} | 14:38 |
didrocks | zsombi: ok, sorry for being a qml newbie, but I think you got what I meant | 14:38 |
didrocks | so yeah, an Item { } | 14:39 |
zsombi | didrocks: that's why I'm asking, in orde rto drive you I need to know what you want :) | 14:39 |
didrocks | so, I have an Item { function edit(model, value) { /* do stuff with model, value */ }} being a controller | 14:40 |
didrocks | (or model being data-bound) | 14:40 |
zsombi | didrocks: so, if this handler component (i.e. QtObject { id: handler; function edit(data) {...}}) is in teh same document as the ListView, then you can give the whole data to the edit | 14:40 |
zsombi | didrocks: like ListItem.onPressAndHold: handler.edit(modelData) | 14:41 |
didrocks | ok, so I need to data-bound to all ListItem elements the handler? | 14:41 |
didrocks | (so that they can act on it) | 14:41 |
zsombi | didrocks: if you want it in the Action, then if you know the model id, and if the model has the get() function, you can do the following: Action.onTriggered: handler.edit(theListItemModel.get(value)) | 14:42 |
didrocks | zsombi: yeah, which is quite easy because the Action is outside of the ListItem/ListView (and just attached), but I think you meant that for the listItem I just pass the whole handler object as a property binding (and then, use the modelData) | 14:44 |
zsombi | didrocks: you never pass whole objects in QML :) | 14:45 |
didrocks | ref* | 14:45 |
zsombi | didrocks: the same woudl be if you'd have the Actions inside the ListView btw | 14:45 |
didrocks | well, you pass the reference, right? | 14:45 |
didrocks | (so I guess a pointer) | 14:45 |
zsombi | didrocks: when you use Actions, you should think that these, on right click, appear in teh context menu of the ListItem | 14:45 |
zsombi | didrocks: yes | 14:45 |
zsombi | didrocks: and, what you pass to the edit() is the content that is visualized by the ListItem | 14:46 |
didrocks | zsombi: hum, let's take back that edit() method being on the ListItem (the edit() acts on the model anyway) | 14:47 |
didrocks | shouldn't I would be able in my case to directly call then: | 14:48 |
didrocks | onTriggered: edit() | 14:48 |
didrocks | ? | 14:48 |
zsombi | didrocks: onTriggered being the Action's one? | 14:48 |
didrocks | yeah | 14:48 |
didrocks | that's the first thing I tried | 14:48 |
zsombi | didrocks: the Action being in the trailing? | 14:48 |
didrocks | yep | 14:48 |
zsombi | or leading? | 14:49 |
zsombi | ok | 14:49 |
didrocks | trailing | 14:49 |
didrocks | but doesn't matter I guess | 14:49 |
zsombi | didrocks: so, if you check what I've said before, the Action part applies to it | 14:49 |
didrocks | I would have thought that would call the edit() method on the ListItem element that has this trailing attached | 14:49 |
didrocks | (as it's in context) | 14:49 |
zsombi | didrocks: these actions - as said - will also be in the menu, so the menu won't necessarily be in the ListItem, right? | 14:50 |
zsombi | didrocks: so the Action cannot be linked to the ListItem | 14:50 |
zsombi | only | 14:50 |
didrocks | zsombi: it's not attached to a menu in that case, so only to a ListItem, but it's not executed in context of the ListItem right? Otherwise edit() would be accessible as it's a function on my ListItem | 14:51 |
zsombi | didrocks: you need to know on what model the action has been triggered, and only if the value parameter is not invalid | 14:51 |
zsombi | didrocks: it will be shown in the menu context menu of the ListItem as well | 14:51 |
didrocks | ah, that's what you mean by "content" | 14:51 |
didrocks | context* | 14:52 |
zsombi | didrocks: and as Actions are generic, you don't know where these can be used | 14:52 |
didrocks | got it | 14:52 |
zsombi | s/can/are | 14:52 |
didrocks | I thought you told that the Item would be in context | 14:52 |
didrocks | yeah, ok, that's why I misunderstood your last part :) | 14:52 |
zsombi | didrocks: so, the Actions you give there do not have a clue on what "context" are they used atm | 14:52 |
zsombi | i.e a ListItem, Menu, Button, CheckBox, etc | 14:52 |
zsombi | or even in the Header... | 14:53 |
didrocks | ok, making sense | 14:53 |
zsombi | didrocks: value is the only thing that drives you, it can be an integer, a string, whatever | 14:53 |
didrocks | yeah, it's the index of the model, right? (index which can be a hash key) | 14:54 |
zsombi | didrocks: so if value is defined, then you can assume (as you are the app developer ;) ) that it was triggered from the known ListView, so the model can also be accessed, and then get() function, and you have the whole data you need in place | 14:54 |
zsombi | yes | 14:54 |
didrocks | zsombi: ok, I think I understood how to properly implement it now. Many thanks! | 14:55 |
zsombi | didrocks: yw :) | 14:55 |
=== chihchun is now known as chihchun_afk | ||
=== Pici` is now known as Pici | ||
mihir | hey popey | 18:57 |
mihir | popey: i have reviews some of MP from Gray and kunal. | 19:30 |
mihir | When you have talk with Gray , could you ask him to revert pot file changes ? | 19:30 |
mihir | from that , the MP becomes too large in terms of lines and fie changes , which is not neccery | 19:31 |
mihir | popey: ^ | 19:31 |
mihir | Good night. | 19:31 |
=== chihchunl is now known as chihchun | ||
=== cwayne- is now known as cwayne | ||
=== salem_ is now known as _salem |
Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!