
Originally Posted by
wysota
Do you know apriori (before starting the search) that the result you're looking for is a child of C5? Or is it just that you search all items and want to get an item which only happens to be a child of C5.
I will try to explain this problem as follow:
QString _cmp_name
= name.
section(":",
0,
0);
QString _x_name
= name.
section(":",
1,
1);
QString _cmp_name = name.section(":", 0, 0);
QString _x_name = name.section(":", 1, 1);
To copy to clipboard, switch view to plain text mode
with the above code i get the name of C5 and the child of C5 which is 1..
QListViewItem * _cmp_item = (((CView
*)(pWorkView->pStack->visibleWidget()))->ui_view->firstChild()->firstChild());
QListViewItem * _cmp_item = (((CView
*)(pWorkView->pStack->visibleWidget()))->ui_view->firstChild()->firstChild());
To copy to clipboard, switch view to plain text mode
this is the pointer to the ListView in which all those item are available(see the picture)
this is my listviewItem iterator, which would iterate in the listview..
QListViewItemIterator it2= _cmp_item;
QListViewItemIterator it2= _cmp_item;
To copy to clipboard, switch view to plain text mode
in this place i search if the child item which i select is equal to the _x_name
if it is so i will get highlighted.(see the picture)
if it is not so it should iterate on my list till it will find the childItem
while (_child_item)
if ( _child_item->text(0) == _x_name )
{
item = _child_item;
break;
}
else
{
item = _child_item->nextSibling();
}
while (_child_item)
if ( _child_item->text(0) == _x_name )
{
item = _child_item;
break;
}
else
{
item = _child_item->nextSibling();
}
To copy to clipboard, switch view to plain text mode
in this code i will search for the childItem, but u see i have a probleem that the most of the childItems have the same name for example "1" is the name of childItem of C5 en that of C1 and almost all of the items have the same childItem name and this code finds the childItem of first item in the list and do not see further. I select for example C5's child item which is "1", but this code hightlight the wrong childItem (the first occurance)
while(*it2)
{
if(it2.current()->text( 0 ).contains(_x_name))
{
if ((*it2) && !(*it2)->pixmap(0))
{
((CView *)(pWorkView->pStack->visibleWidget()))->selectItem(*it2);
pWorkView->m_TabView->setCurrentPage(0);
((CView *)(pWorkView->pStack->visibleWidget()))->ui_view->ensureItemVisible(*it2);
break;
}
}
it2++;
while(*it2)
{
if(it2.current()->text( 0 ).contains(_x_name))
{
if ((*it2) && !(*it2)->pixmap(0))
{
((CView *)(pWorkView->pStack->visibleWidget()))->selectItem(*it2);
pWorkView->m_TabView->setCurrentPage(0);
((CView *)(pWorkView->pStack->visibleWidget()))->ui_view->ensureItemVisible(*it2);
break;
}
}
it2++;
To copy to clipboard, switch view to plain text mode
Bookmarks