Commit bfaab6ab authored by Rodolfo Panerai's avatar Rodolfo Panerai Committed by Albert Astals Cid
Browse files

Highlight TOC items with a bold font

parent d1568efd
Pipeline #16511 passed with stage
in 10 minutes and 41 seconds
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include <qlist.h> #include <qlist.h>
#include <qtreeview.h> #include <qtreeview.h>
#include <QIcon> #include <QFont>
#include "pageitemdelegate.h" #include "pageitemdelegate.h"
#include "core/document.h" #include "core/document.h"
...@@ -229,31 +229,33 @@ QVariant TOCModel::data( const QModelIndex &index, int role ) const ...@@ -229,31 +229,33 @@ QVariant TOCModel::data( const QModelIndex &index, int role ) const
case Qt::ToolTipRole: case Qt::ToolTipRole:
return item->text; return item->text;
break; break;
case Qt::DecorationRole: case Qt::FontRole:
if ( item->highlight ) if ( item->highlight )
{ {
const QVariant icon = QIcon::fromTheme( QApplication::layoutDirection() == Qt::RightToLeft ? QStringLiteral("arrow-left") : QStringLiteral("arrow-right") ); QFont font;
font.setBold(true);
TOCItem *lastHighlighted = d->currentPage.last(); TOCItem *lastHighlighted = d->currentPage.last();
// in the mobile version our parent is not a QTreeView; add icon to the last highlighted item // in the mobile version our parent is not a QTreeView; embolden the last highlighted item
// TODO misusing parent() here, fix // TODO misusing parent() here, fix
QTreeView *view = dynamic_cast< QTreeView* > ( QObject::parent() ); QTreeView *view = dynamic_cast< QTreeView* > ( QObject::parent() );
if ( !view ) if ( !view )
{ {
if ( item == lastHighlighted ) if ( item == lastHighlighted )
return icon; return font;
return QVariant(); return QVariant();
} }
if ( view->isExpanded( index ) ) if ( view->isExpanded( index ) )
{ {
// if this is the last highlighted node, its child is on a page below, thus it needs icon // if this is the last highlighted node, its child is on a page below, thus it gets emboldened
if ( item == lastHighlighted ) if ( item == lastHighlighted )
return icon; return font;
} }
else else
{ {
return icon; return font;
} }
} }
break; break;
......
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