Commit 914be0e8 authored by Philipp Erhardt's avatar Philipp Erhardt
Browse files

Add toc header and empty indicator

parent 80649b81
......@@ -22,7 +22,9 @@ Toc::Toc(Viewer *v, QWidget *parent) :
h->setStretchLastSection(false);
h->setResizeMode(0, QHeaderView::Stretch);
h->setResizeMode(1, QHeaderView::ResizeToContents);
h->hide();
QStringList list = QStringList() << "Contents" << QString();
setHeaderLabels(list);
setAlternatingRowColors(true);
......@@ -39,6 +41,12 @@ void Toc::init() {
build(contents, invisibleRootItem());
delete contents;
}
// indicate empty toc
if (topLevelItemCount() == 0) {
QTreeWidgetItem *item = new QTreeWidgetItem(invisibleRootItem(), QStringList("(empty)"));
item->setFlags(Qt::NoItemFlags);
}
}
Toc::~Toc() {
......@@ -59,6 +67,11 @@ void Toc::goto_link(QTreeWidgetItem *item, int column) {
if (column == -1) {
return;
}
// handle empty-indicator
if (item->text(1).isEmpty()) {
return;
}
int old_page = viewer->get_canvas()->get_layout()->get_page();
Poppler::LinkDestination *link = item->data(0, Qt::UserRole).value<Poppler::LinkDestination *>();
if (viewer->get_canvas()->get_layout()->goto_link_destination(*link)) {
......
Supports Markdown
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