Object content viewer

This commit is contained in:
Jakub Melka
2021-06-13 18:54:47 +02:00
parent c0b0fb6010
commit f4ea513208
11 changed files with 283 additions and 6 deletions

View File

@ -26,9 +26,10 @@
namespace pdfplugin
{
ObjectInspectorDialog::ObjectInspectorDialog(const pdf::PDFDocument* document, QWidget* parent) :
ObjectInspectorDialog::ObjectInspectorDialog(const pdf::PDFCMS* cms, const pdf::PDFDocument* document, QWidget* parent) :
QDialog(parent, Qt::Dialog | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint),
ui(new Ui::ObjectInspectorDialog),
m_cms(cms),
m_document(document),
m_model(nullptr)
{
@ -36,6 +37,9 @@ ObjectInspectorDialog::ObjectInspectorDialog(const pdf::PDFDocument* document, Q
m_objectClassifier.classify(document);
ui->currentObjectWidget->setCms(cms);
ui->currentObjectWidget->setDocument(document);
ui->modeComboBox->addItem(tr("Document"), int(PDFObjectInspectorTreeItemModel::Document));
ui->modeComboBox->addItem(tr("Pages"), int(PDFObjectInspectorTreeItemModel::Page));
@ -98,6 +102,8 @@ ObjectInspectorDialog::ObjectInspectorDialog(const pdf::PDFDocument* document, Q
ui->splitter->setCollapsible(1, true);
ui->splitter->setSizes(QList<int>() << pdf::PDFWidgetUtils::scaleDPI_x(this, 300) << pdf::PDFWidgetUtils::scaleDPI_x(this, 200));
connect(ui->objectTreeView->selectionModel(), &QItemSelectionModel::currentChanged, this, &ObjectInspectorDialog::onCurrentIndexChanged);
ui->objectTreeView->setMinimumWidth(pdf::PDFWidgetUtils::scaleDPI_x(this, 200));
setMinimumSize(pdf::PDFWidgetUtils::scaleDPI(this, QSize(800, 600)));
}
@ -113,4 +119,22 @@ void ObjectInspectorDialog::onModeChanged()
m_model->setMode(mode);
}
void ObjectInspectorDialog::onCurrentIndexChanged(const QModelIndex& current, const QModelIndex& previous)
{
Q_UNUSED(previous);
pdf::PDFObject object = m_model->getObjectFromIndex(current);
pdf::PDFObjectReference reference = m_model->getObjectReferenceFromIndex(current);
bool isRoot = m_model->isRootObject(current);
if (!isRoot && object.isReference())
{
reference = object.getReference();
object = m_document->getObjectByReference(reference);
isRoot = true;
}
ui->currentObjectWidget->setData(reference, qMove(object), isRoot);
}
} // namespace pdfplugin