mirror of
https://github.com/JakubMelka/PDF4QT.git
synced 2025-01-16 10:32:29 +01:00
Pin/unpin functionality
This commit is contained in:
parent
47baae321e
commit
7264a45e30
@ -103,6 +103,8 @@ ObjectInspectorDialog::ObjectInspectorDialog(const pdf::PDFCMS* cms, const pdf::
|
|||||||
ui->splitter->setSizes(QList<int>() << pdf::PDFWidgetUtils::scaleDPI_x(this, 300) << pdf::PDFWidgetUtils::scaleDPI_x(this, 200));
|
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);
|
connect(ui->objectTreeView->selectionModel(), &QItemSelectionModel::currentChanged, this, &ObjectInspectorDialog::onCurrentIndexChanged);
|
||||||
|
connect(ui->currentObjectWidget, &ObjectViewerWidget::pinRequest, this, &ObjectInspectorDialog::onPinRequest);
|
||||||
|
connect(ui->currentObjectWidget, &ObjectViewerWidget::unpinRequest, this, &ObjectInspectorDialog::onUnpinRequest);
|
||||||
|
|
||||||
ui->objectTreeView->setMinimumWidth(pdf::PDFWidgetUtils::scaleDPI_x(this, 200));
|
ui->objectTreeView->setMinimumWidth(pdf::PDFWidgetUtils::scaleDPI_x(this, 200));
|
||||||
setMinimumSize(pdf::PDFWidgetUtils::scaleDPI(this, QSize(800, 600)));
|
setMinimumSize(pdf::PDFWidgetUtils::scaleDPI(this, QSize(800, 600)));
|
||||||
@ -119,6 +121,34 @@ void ObjectInspectorDialog::onModeChanged()
|
|||||||
m_model->setMode(mode);
|
m_model->setMode(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ObjectInspectorDialog::onPinRequest()
|
||||||
|
{
|
||||||
|
ObjectViewerWidget* source = qobject_cast<ObjectViewerWidget*>(sender());
|
||||||
|
|
||||||
|
if (!source || source != ui->currentObjectWidget)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ObjectViewerWidget* cloned = ui->currentObjectWidget->clone(true, this);
|
||||||
|
connect(cloned, &ObjectViewerWidget::pinRequest, this, &ObjectInspectorDialog::onPinRequest);
|
||||||
|
connect(cloned, &ObjectViewerWidget::unpinRequest, this, &ObjectInspectorDialog::onUnpinRequest);
|
||||||
|
ui->tabWidget->addTab(cloned, cloned->getTitleText());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ObjectInspectorDialog::onUnpinRequest()
|
||||||
|
{
|
||||||
|
ObjectViewerWidget* source = qobject_cast<ObjectViewerWidget*>(sender());
|
||||||
|
|
||||||
|
if (!source || source == ui->currentObjectWidget)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->tabWidget->removeTab(ui->tabWidget->indexOf(source));
|
||||||
|
source->deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
void ObjectInspectorDialog::onCurrentIndexChanged(const QModelIndex& current, const QModelIndex& previous)
|
void ObjectInspectorDialog::onCurrentIndexChanged(const QModelIndex& current, const QModelIndex& previous)
|
||||||
{
|
{
|
||||||
Q_UNUSED(previous);
|
Q_UNUSED(previous);
|
||||||
|
@ -43,6 +43,8 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void onModeChanged();
|
void onModeChanged();
|
||||||
|
void onPinRequest();
|
||||||
|
void onUnpinRequest();
|
||||||
void onCurrentIndexChanged(const QModelIndex& current, const QModelIndex& previous);
|
void onCurrentIndexChanged(const QModelIndex& current, const QModelIndex& previous);
|
||||||
|
|
||||||
Ui::ObjectInspectorDialog* ui;
|
Ui::ObjectInspectorDialog* ui;
|
||||||
|
@ -40,6 +40,9 @@
|
|||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="movable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
<widget class="QWidget" name="currentObjectTab">
|
<widget class="QWidget" name="currentObjectTab">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>Current Object</string>
|
<string>Current Object</string>
|
||||||
|
@ -46,7 +46,7 @@ ObjectViewerWidget::ObjectViewerWidget(bool isPinned, QWidget* parent) :
|
|||||||
m_printableCharacters.push_back('\n');
|
m_printableCharacters.push_back('\n');
|
||||||
|
|
||||||
connect(ui->pinButton, &QPushButton::clicked, this, &ObjectViewerWidget::pinRequest);
|
connect(ui->pinButton, &QPushButton::clicked, this, &ObjectViewerWidget::pinRequest);
|
||||||
connect(ui->unpinButton, &QPushButton::clicked, this, &ObjectViewerWidget::pinRequest);
|
connect(ui->unpinButton, &QPushButton::clicked, this, &ObjectViewerWidget::unpinRequest);
|
||||||
|
|
||||||
updateUi();
|
updateUi();
|
||||||
updatePinnedUi();
|
updatePinnedUi();
|
||||||
@ -57,6 +57,18 @@ ObjectViewerWidget::~ObjectViewerWidget()
|
|||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ObjectViewerWidget* ObjectViewerWidget::clone(bool isPinned, QWidget* parent)
|
||||||
|
{
|
||||||
|
ObjectViewerWidget* cloned = new ObjectViewerWidget(isPinned, parent);
|
||||||
|
|
||||||
|
cloned->setDocument(m_document);
|
||||||
|
cloned->setCms(m_cms);
|
||||||
|
cloned->setData(m_currentReference, m_currentObject, m_isRootObject);
|
||||||
|
|
||||||
|
|
||||||
|
return cloned;
|
||||||
|
}
|
||||||
|
|
||||||
void ObjectViewerWidget::setPinned(bool isPinned)
|
void ObjectViewerWidget::setPinned(bool isPinned)
|
||||||
{
|
{
|
||||||
if (m_isPinned != isPinned)
|
if (m_isPinned != isPinned)
|
||||||
@ -271,6 +283,25 @@ void ObjectViewerWidget::setCms(const pdf::PDFCMS* cms)
|
|||||||
m_cms = cms;
|
m_cms = cms;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString ObjectViewerWidget::getTitleText() const
|
||||||
|
{
|
||||||
|
if (!m_currentReference.isValid())
|
||||||
|
{
|
||||||
|
return tr("[Unknown]");
|
||||||
|
}
|
||||||
|
|
||||||
|
QString referenceString = tr("%1 %2 R").arg(m_currentReference.objectNumber).arg(m_currentReference.generation);
|
||||||
|
|
||||||
|
if (m_isRootObject)
|
||||||
|
{
|
||||||
|
return referenceString;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return tr("%1 (part)").arg(referenceString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const pdf::PDFDocument* ObjectViewerWidget::getDocument() const
|
const pdf::PDFDocument* ObjectViewerWidget::getDocument() const
|
||||||
{
|
{
|
||||||
return m_document;
|
return m_document;
|
||||||
|
@ -40,6 +40,8 @@ public:
|
|||||||
explicit ObjectViewerWidget(bool isPinned, QWidget* parent);
|
explicit ObjectViewerWidget(bool isPinned, QWidget* parent);
|
||||||
virtual ~ObjectViewerWidget() override;
|
virtual ~ObjectViewerWidget() override;
|
||||||
|
|
||||||
|
ObjectViewerWidget* clone(bool isPinned, QWidget* parent);
|
||||||
|
|
||||||
void setPinned(bool isPinned);
|
void setPinned(bool isPinned);
|
||||||
void setData(pdf::PDFObjectReference currentReference, pdf::PDFObject currentObject, bool isRootObject);
|
void setData(pdf::PDFObjectReference currentReference, pdf::PDFObject currentObject, bool isRootObject);
|
||||||
|
|
||||||
@ -49,6 +51,8 @@ public:
|
|||||||
const pdf::PDFCMS* getCms() const;
|
const pdf::PDFCMS* getCms() const;
|
||||||
void setCms(const pdf::PDFCMS* cms);
|
void setCms(const pdf::PDFCMS* cms);
|
||||||
|
|
||||||
|
QString getTitleText() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void pinRequest();
|
void pinRequest();
|
||||||
void unpinRequest();
|
void unpinRequest();
|
||||||
|
Loading…
Reference in New Issue
Block a user