Flex/QNX scrolling gallery - apache-flex

I was hoping someone could give me some guidance on building an image gallery which loads images dynamically for a PlayBook application.I've uploaded a quick mockup of what I am trying to achieve, I want to dynamically load images into a QNX TileList or Flex equivalent and as the user scrolls through the list I want to call another 'page' of images dynamically. I have already produced an example which uses a custom cell renderer to dynamically load images but I am having problems when I attempt to identify when the user has reached the end of the list.
I have tried using the lastVisibleItem property of the list while the user is scrolling to identify if the last item visible in the list is also last in the DataProvider (so I know when I need to call for more images) but when I add images to the DataProvider it takes me back to the start of the list, can anyone tell me the reason for this?
Any advice on a different approach or how to modify the TileList would be greatly appreciated.

The scrollPosition automatically gets reset to 0 when you update the dataProvider. I've done workarounds that store the current scrollPosition before updating the dataProvider and then re-set it after the update to the dataProvider has completed. Let me know if you need some code sample and I'll see if I can dig something up.
Another option would be to use dataPaging. Here is a good example of how to do that:
http://www.jamesward.com/2010/10/11/data-paging-in-flex-4/

Related

Loop over cards in the UI

Is there someone who can tell me how you loop over the contacts in the template "Vendor ratings" please ?
I give you a screenshot of the page. To reproduce, go to the "Contacts" page, add a new contact and see two contacts...
I want to do the same behavior for my application and I don't know how to loop...
When I create a single card with a label binding #datasource.item.name for example, I only have 1 card displayed although in my datasource I have two results...
Thanks a lot for your help.
You are looking for widgets that can render repetitive data: List, Accordion, Grid. You can build prototype row/cell inside such widget, bind it to array of items (datasource) and App Maker's runtime will take care about the rest for you:

ASP.Net 4.0 image select and change source

If I have a set of image (buttons) or even just plane images, 5 in a row, and I want to achieve the following, what would be the easiest way, I can't realy find a good solutions to this:
On clicking either of the images, it needs to get a new src, but others need to be restored to the original state.
A Asp:Label needs to be set on clicking, based on the image clicked
On doing a PostBack, I need to know which one is selected
Asside from this, it's asp.net 4.0, so single quotes are giving me javascript pain.
On clicking either of the images, it needs to get a new src, but others need to be restored to the original state.
First of all you have to create a function in which you will set all 5 images to the original state.
Then be sure to give same class name to each image element.
After that crate a function which will fire according to class name like
$(".classname").click(function(){
//first call the function which will set all 5 images to original state.
//then change the source of the current image. onwhich user has clicked as below:
$(this).attr("src","new source");
// here you can store the id of current image in a variable to keep the record which images have been clicked
});
A Asp:Label needs to be set on clicking, based on the image clicked
you can easily set the Asp:Label in above function. If you are familiar with javascript code. Its too simple to set.
On doing a PostBack, I need to know which one is selected
After creating the first function your rest of two steps get completed them selves.
in above function you have saved the IDs of images on which a user has clicked in a variable.
on doing postback you can easily save the varibale's data in hiddenfield or assign it to static varibale or what ever the way you like.
at last you can access it in code behind.
If i have to do this thing. i'll follow the above process. Its far easy and fast process. Everything can be done at client side.
what you think?

How to update a QLayout and get the new dimensions before returning?

This is driving me nuts. I have a custom menu class that, when set visible, shows a list of items located in a particular folder. When a hardware button is pressed, my application gets the latest list of items, populates the menu with them, and returns.
The menu displaying these items uses a QListWidget filled with custom widgets. Each of the widgets contains one or more QLabels in a horizontal layout, and is created at the time the menu is shown. In order to adjust the text displayed based on the menu width available, I need to get the size of the QLabel AFTER it has been resized according to the layout, but before the menu becomes visible to the user. The problem is, my layout does not get updated until all of the functions constructing my list return.
I have tried QApplication::ProcessEvents() and the layout update functions, but none of them have updated the values of my QLabels before returning. I can set a QTimer when the button is initially pressed, and have it show the menu, update the items, and stop itself, but that seems like a terrible solution.
Any help would really be appreciated! I've spent most of a day on this.
Marlon
I had this exact problem and could not find an answer anywhere on the Internet. Calling Layout.update(), Layout.activate(), or widget.adjustSize() (all suggested in various places) all did not work.
I had a widget with a vertical layout that I wanted to add a QLabel to and then immediately use the size of the QLabel.
The only thing that worked reliably was
layout->addWidget(myLabel);
myLabel->show();
size = myLabel->size();
It would seem that layouts will just not recalculate until you either return from a function and allow the Qt event loop to progress or manually call show() yourself.
How to update a QLayout and get the new dimensions before returning?
Don't. You're not meant to do that. It'll drive you "nuts" because you're doing it backwards. Layout updates are handled asynchronously from the event loop. Instead of getting layout dimensions right away, set yourself up to be part of the system. Some options are:
Implement a custom widget that will interact properly with the layout, growing to fill the available width of the layout. Perhaps all you need is a size policy and a way to elide text?
Make a custom layout that takes the special properties of your use case into account.
You want to call QWidget::adjustSize() on your parent widget. This will force the layout recalculations.
Have you tried using layout()->update(); ?
I've tried many but nothing works for me on Qt 5.15.
Only invented little patch - create timer and get size after 20 msec:
QTimer::singleShot(20, this, [this]
{
const auto height = myLayout->contentsRect().height();
// ...
});

Flex TileList itemrenderer + scroll = HELL

I'm going insane over this issue. Basically, I have a TileList with a custom item renderer that has a TextInput in it. Let's say that the list can show 4 items at once, if there are 5 items and I edit the text on the first one, the fifth will be edited also. In general if an item is out of view, it will be change when I edit one that is showing.
Also, I had overriden the TileList class to expose the rendererArray property (so that I could access the texts on each renderer) but it will only return the renderers which are displayed.
Any help is appreciated. I need to know how to override this weird behaviour with itemrenderers that aren't currently displayed. Thanks.
Ok, if anyone runs into a similar issue, here is what you need to do:
First of all, avoid trying to iterate through the itemrenderers like I did. If you need a TextInput or another control on your TileList, make sure that these controls are bound to a property on your data object, otherwise off-screen items will have incorrect values since their itemrenderers will be recycled from the items that left the screen when you scrolled.
If you think it through, any requirement can be solved by iterating through the dataprovider instead of the itemrenderers.
Also, if you try to expose the rendererArray property like I did, notice that you will only be able to iterate through the itemrenderers that are currently displayed, since those that would belong to the items that are off-screen will not be created yet.
I hope this wasn't too confusing..

how to display an element of parent in iframe

newbie question
I have a multiselect box that i populate with some ajax and shape with some jquery.SO i dont want to repeat all these operations whenever an iframe shows up.
is it possible to reuse it ? ?
this has been an old question but i wanted to answer as it may help someone someday.
To avoid all the repeating Ajax calls , i just saved the data in objects ,then access the data from iframe to draw my elements.

Resources