move the search for the item for a specified url into an own method

svn path=/trunk/KDE/kdegraphics/okular/; revision=793540
This commit is contained in:
Pino Toscano 2008-04-04 10:19:12 +00:00
parent 39b730d371
commit b5a4b0edb5
2 changed files with 19 additions and 9 deletions

View file

@ -206,16 +206,10 @@ void BookmarkList::slotBookmarksChanged( const KUrl& url )
if ( m_showBoomarkOnlyAction->isChecked() )
return;
const int count = m_tree->topLevelItemCount();
for ( int i = 0; i < count; ++i )
QTreeWidgetItem *item = itemForUrl( url );
if ( item )
{
QTreeWidgetItem *item = m_tree->topLevelItem( i );
const KUrl itemurl = item->data( 0, UrlRole ).value< KUrl >();
if ( itemurl.isValid() && itemurl == url )
{
selectiveUrlUpdate( url, item );
break;
}
selectiveUrlUpdate( url, item );
}
}
@ -347,4 +341,19 @@ void BookmarkList::selectiveUrlUpdate( const KUrl& url, QTreeWidgetItem*& item )
}
}
QTreeWidgetItem* BookmarkList::itemForUrl( const KUrl& url ) const
{
const int count = m_tree->topLevelItemCount();
for ( int i = 0; i < count; ++i )
{
QTreeWidgetItem *item = m_tree->topLevelItem( i );
const KUrl itemurl = item->data( 0, UrlRole ).value< KUrl >();
if ( itemurl.isValid() && itemurl == url )
{
return item;
}
}
return 0;
}
#include "bookmarklist.moc"

View file

@ -48,6 +48,7 @@ class BookmarkList : public QWidget, public Okular::DocumentObserver
void rebuildTree( bool filter );
void goTo( BookmarkItem * item );
void selectiveUrlUpdate( const KUrl& url, QTreeWidgetItem*& item );
QTreeWidgetItem* itemForUrl( const KUrl& url ) const;
Okular::Document * m_document;
QTreeWidget * m_tree;