Commit 5bfb9dca authored by Pino Toscano's avatar Pino Toscano

Support for external URLs as destination for the TOC items.

svn path=/trunk/KDE/kdegraphics/okular/; revision=890883
parent b43fe1ce
......@@ -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() )
......
......@@ -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"
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment