diff --git a/ui/toc.cpp b/ui/toc.cpp index 93c9e1cc1..e14349756 100644 --- a/ui/toc.cpp +++ b/ui/toc.cpp @@ -105,6 +105,14 @@ void TOC::slotExecuted( const QModelIndex &index ) if ( !index.isValid() ) return; + QString url = m_model->urlForIndex( index ); + if ( !url.isEmpty() ) + { + Okular::BrowseAction action( url ); + m_document->processAction( &action ); + return; + } + QString externalFileName = m_model->externalFileNameForIndex( index ); Okular::DocumentViewport viewport = m_model->viewportForIndex( index ); if ( !externalFileName.isEmpty() ) diff --git a/ui/tocmodel.cpp b/ui/tocmodel.cpp index f6eb429d8..8f0e8396b 100644 --- a/ui/tocmodel.cpp +++ b/ui/tocmodel.cpp @@ -30,6 +30,7 @@ struct TOCItem QString text; Okular::DocumentViewport viewport; QString extFileName; + QString url; bool highlight : 1; TOCItem *parent; QList< TOCItem* > children; @@ -84,6 +85,7 @@ TOCItem::TOCItem( TOCItem *_parent, const QDomElement &e ) } extFileName = e.attribute( "ExternalFileName" ); + url = e.attribute( "URL" ); } TOCItem::~TOCItem() @@ -337,4 +339,13 @@ Okular::DocumentViewport TOCModel::viewportForIndex( const QModelIndex &index ) return item->viewport; } +QString TOCModel::urlForIndex( const QModelIndex &index ) const +{ + if ( !index.isValid() ) + return QString(); + + TOCItem *item = static_cast< TOCItem* >( index.internalPointer() ); + return item->url; +} + #include "tocmodel.moc" diff --git a/ui/tocmodel.h b/ui/tocmodel.h index 5d172573b..d90fc4f19 100644 --- a/ui/tocmodel.h +++ b/ui/tocmodel.h @@ -45,6 +45,7 @@ class TOCModel : public QAbstractItemModel QString externalFileNameForIndex( const QModelIndex &index ) const; Okular::DocumentViewport viewportForIndex( const QModelIndex &index ) const; + QString urlForIndex( const QModelIndex &index ) const; private: // storage