File attachments

This commit is contained in:
Jakub Melka
2019-12-01 18:10:11 +01:00
parent 939a011ca6
commit 159fc9f815
7 changed files with 711 additions and 7 deletions

View File

@ -30,7 +30,8 @@ PDFSidebarWidget::PDFSidebarWidget(QWidget* parent) :
m_outlineTreeModel(nullptr),
m_optionalContentTreeModel(nullptr),
m_document(nullptr),
m_optionalContentActivity(nullptr)
m_optionalContentActivity(nullptr),
m_attachmentsTreeModel(nullptr)
{
ui->setupUi(this);
@ -46,10 +47,18 @@ PDFSidebarWidget::PDFSidebarWidget(QWidget* parent) :
m_optionalContentTreeModel = new pdf::PDFOptionalContentTreeItemModel(this);
ui->optionalContentTreeView->setModel(m_optionalContentTreeModel);
// Attachments
ui->attachmentsTreeView->header()->hide();
m_attachmentsTreeModel = new pdf::PDFAttachmentsTreeItemModel(this);
ui->attachmentsTreeView->setModel(m_attachmentsTreeModel);
ui->attachmentsTreeView->setSelectionMode(QAbstractItemView::SingleSelection);
ui->attachmentsTreeView->setSelectionBehavior(QAbstractItemView::SelectRows);
m_pageInfo[Invalid] = { nullptr, ui->emptyPage };
m_pageInfo[OptionalContent] = { ui->optionalContentButton, ui->optionalContentPage };
m_pageInfo[Bookmarks] = { ui->bookmarksButton, ui->bookmarksPage };
m_pageInfo[Thumbnails] = { ui->thumbnailsButton, ui->thumbnailsPage };
m_pageInfo[Attachments] = { ui->attachmentsButton, ui->attachmentsPage };
setAutoFillBackground(true);
selectPage(Invalid);
@ -74,6 +83,11 @@ void PDFSidebarWidget::setDocument(const pdf::PDFDocument* document, pdf::PDFOpt
m_optionalContentTreeModel->setActivity(m_optionalContentActivity);
ui->optionalContentTreeView->expandAll();
// Update attachments
m_attachmentsTreeModel->setDocument(document);
ui->attachmentsTreeView->expandAll();
ui->attachmentsTreeView->resizeColumnToContents(0);
Page preferred = Invalid;
if (m_document)
{
@ -92,6 +106,10 @@ void PDFSidebarWidget::setDocument(const pdf::PDFDocument* document, pdf::PDFOpt
preferred = OptionalContent;
break;
case pdf::PageMode::UseAttachments:
preferred = Attachments;
break;
default:
break;
}
@ -122,15 +140,18 @@ bool PDFSidebarWidget::isEmpty(Page page) const
case Invalid:
return true;
case OptionalContent:
return m_optionalContentTreeModel->isEmpty();
case Bookmarks:
return m_outlineTreeModel->isEmpty();
case Thumbnails:
return true;
case OptionalContent:
return m_optionalContentTreeModel->isEmpty();
case Attachments:
return m_attachmentsTreeModel->isEmpty();
default:
Q_ASSERT(false);
break;