mirror of
https://github.com/JakubMelka/PDF4QT.git
synced 2025-06-05 21:59:17 +02:00
Continuation of object editing
This commit is contained in:
@ -60,6 +60,7 @@ SOURCES += \
|
|||||||
sources/pdfmultimedia.cpp \
|
sources/pdfmultimedia.cpp \
|
||||||
sources/pdfobject.cpp \
|
sources/pdfobject.cpp \
|
||||||
sources/pdfobjecteditormodel.cpp \
|
sources/pdfobjecteditormodel.cpp \
|
||||||
|
sources/pdfobjecteditorwidget.cpp \
|
||||||
sources/pdfobjectutils.cpp \
|
sources/pdfobjectutils.cpp \
|
||||||
sources/pdfoptimizer.cpp \
|
sources/pdfoptimizer.cpp \
|
||||||
sources/pdfoptionalcontent.cpp \
|
sources/pdfoptionalcontent.cpp \
|
||||||
@ -120,6 +121,7 @@ HEADERS += \
|
|||||||
sources/pdfnametreeloader.h \
|
sources/pdfnametreeloader.h \
|
||||||
sources/pdfobject.h \
|
sources/pdfobject.h \
|
||||||
sources/pdfobjecteditormodel.h \
|
sources/pdfobjecteditormodel.h \
|
||||||
|
sources/pdfobjecteditorwidget.h \
|
||||||
sources/pdfobjectutils.h \
|
sources/pdfobjectutils.h \
|
||||||
sources/pdfoptimizer.h \
|
sources/pdfoptimizer.h \
|
||||||
sources/pdfoptionalcontent.h \
|
sources/pdfoptionalcontent.h \
|
||||||
|
@ -129,4 +129,72 @@ QString PDFBlendModeInfo::getBlendModeName(BlendMode mode)
|
|||||||
return "Unknown";
|
return "Unknown";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString PDFBlendModeInfo::getBlendModeTranslatedName(BlendMode mode)
|
||||||
|
{
|
||||||
|
switch (mode)
|
||||||
|
{
|
||||||
|
case BlendMode::Normal:
|
||||||
|
case BlendMode::Compatible:
|
||||||
|
return PDFTranslationContext::tr("Normal");
|
||||||
|
case BlendMode::Multiply:
|
||||||
|
return PDFTranslationContext::tr("Multiply");
|
||||||
|
case BlendMode::Screen:
|
||||||
|
return PDFTranslationContext::tr("Screem");
|
||||||
|
case BlendMode::Overlay:
|
||||||
|
return PDFTranslationContext::tr("Overlay");
|
||||||
|
case BlendMode::Darken:
|
||||||
|
return PDFTranslationContext::tr("Darken");
|
||||||
|
case BlendMode::Lighten:
|
||||||
|
return PDFTranslationContext::tr("Lighten");
|
||||||
|
case BlendMode::ColorDodge:
|
||||||
|
return PDFTranslationContext::tr("ColorDodge");
|
||||||
|
case BlendMode::ColorBurn:
|
||||||
|
return PDFTranslationContext::tr("ColorBurn");
|
||||||
|
case BlendMode::HardLight:
|
||||||
|
return PDFTranslationContext::tr("HardLight");
|
||||||
|
case BlendMode::SoftLight:
|
||||||
|
return PDFTranslationContext::tr("SoftLight");
|
||||||
|
case BlendMode::Difference:
|
||||||
|
return PDFTranslationContext::tr("Difference");
|
||||||
|
case BlendMode::Exclusion:
|
||||||
|
return PDFTranslationContext::tr("Exclusion");
|
||||||
|
case BlendMode::Hue:
|
||||||
|
return PDFTranslationContext::tr("Hue");
|
||||||
|
case BlendMode::Saturation:
|
||||||
|
return PDFTranslationContext::tr("Saturation");
|
||||||
|
case BlendMode::Color:
|
||||||
|
return PDFTranslationContext::tr("Color");
|
||||||
|
case BlendMode::Luminosity:
|
||||||
|
return PDFTranslationContext::tr("Luminosity");
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return PDFTranslationContext::tr("Unknown");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<BlendMode> PDFBlendModeInfo::getBlendModes()
|
||||||
|
{
|
||||||
|
return
|
||||||
|
{
|
||||||
|
BlendMode::Normal,
|
||||||
|
BlendMode::Multiply,
|
||||||
|
BlendMode::Screen,
|
||||||
|
BlendMode::Overlay,
|
||||||
|
BlendMode::Darken,
|
||||||
|
BlendMode::Lighten,
|
||||||
|
BlendMode::ColorDodge,
|
||||||
|
BlendMode::ColorBurn,
|
||||||
|
BlendMode::HardLight,
|
||||||
|
BlendMode::SoftLight,
|
||||||
|
BlendMode::Difference,
|
||||||
|
BlendMode::Exclusion,
|
||||||
|
BlendMode::Hue,
|
||||||
|
BlendMode::Saturation,
|
||||||
|
BlendMode::Color,
|
||||||
|
BlendMode::Luminosity
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace pdf
|
} // namespace pdf
|
||||||
|
@ -78,6 +78,14 @@ public:
|
|||||||
/// Returns blend mode name
|
/// Returns blend mode name
|
||||||
/// \param mode Blend mode
|
/// \param mode Blend mode
|
||||||
static QString getBlendModeName(BlendMode mode);
|
static QString getBlendModeName(BlendMode mode);
|
||||||
|
|
||||||
|
/// Returns blend mode translated name
|
||||||
|
/// \param mode Blend mode
|
||||||
|
static QString getBlendModeTranslatedName(BlendMode mode);
|
||||||
|
|
||||||
|
/// Returns vector of all blend modes, excluding duplicate ones (for example,
|
||||||
|
/// Compatible mode is equal to Normal blend mode)
|
||||||
|
static std::vector<BlendMode> getBlendModes();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace pdf
|
} // namespace pdf
|
||||||
|
@ -16,12 +16,16 @@
|
|||||||
// along with PDFForQt. If not, see <https://www.gnu.org/licenses/>.
|
// along with PDFForQt. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include "pdfobjecteditormodel.h"
|
#include "pdfobjecteditormodel.h"
|
||||||
|
#include "pdfdocumentbuilder.h"
|
||||||
|
#include "pdfblendfunction.h"
|
||||||
|
|
||||||
namespace pdf
|
namespace pdf
|
||||||
{
|
{
|
||||||
|
|
||||||
PDFObjectEditorAbstractModel::PDFObjectEditorAbstractModel(QObject* parent) :
|
PDFObjectEditorAbstractModel::PDFObjectEditorAbstractModel(QObject* parent) :
|
||||||
BaseClass(parent)
|
BaseClass(parent),
|
||||||
|
m_storage(nullptr),
|
||||||
|
m_typeAttribute(0)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -51,8 +55,83 @@ const QString& PDFObjectEditorAbstractModel::getAttributeName(size_t index) cons
|
|||||||
return m_attributes.at(index).name;
|
return m_attributes.at(index).name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PDFObjectEditorAbstractModel::queryAttribute(size_t index, Question question) const
|
||||||
|
{
|
||||||
|
const PDFObjectEditorModelAttribute& attribute = m_attributes.at(index);
|
||||||
|
|
||||||
|
switch (question)
|
||||||
|
{
|
||||||
|
case Question::IsMapped:
|
||||||
|
return attribute.attributeFlags.testFlag(PDFObjectEditorModelAttribute::Hidden) || attribute.type == ObjectEditorAttributeType::Constant;
|
||||||
|
|
||||||
|
case Question::HasAttribute:
|
||||||
|
{
|
||||||
|
// Check type flags
|
||||||
|
if (attribute.typeFlags)
|
||||||
|
{
|
||||||
|
uint32_t currentTypeFlags = getCurrentTypeFlags();
|
||||||
|
if (!(attribute.typeFlags & currentTypeFlags))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check selector
|
||||||
|
if (attribute.selectorAttribute)
|
||||||
|
{
|
||||||
|
if (!getSelectorValue(attribute.selectorAttribute))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
s
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
PDFObject PDFObjectEditorAbstractModel::getValue(size_t index) const
|
||||||
|
{
|
||||||
|
const QByteArrayList& dictionaryAttribute = m_attributes.at(index).dictionaryAttribute;
|
||||||
|
if (dictionaryAttribute.isEmpty())
|
||||||
|
{
|
||||||
|
return PDFObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
PDFDocumentDataLoaderDecorator loader(m_storage);
|
||||||
|
|
||||||
|
if (const PDFDictionary* dictionary = m_storage->getDictionaryFromObject(m_editedObject))
|
||||||
|
{
|
||||||
|
const int pathDepth = dictionaryAttribute.size() - 1;
|
||||||
|
|
||||||
|
for (int i = 0; i < pathDepth; ++i)
|
||||||
|
{
|
||||||
|
dictionary = m_storage->getDictionaryFromObject(dictionaryAttribute[i]);
|
||||||
|
if (!dictionary)
|
||||||
|
{
|
||||||
|
return PDFObject();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return dictionary->get(dictionaryAttribute.back());
|
||||||
|
}
|
||||||
|
|
||||||
|
return PDFObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
PDFObject PDFObjectEditorAbstractModel::getDefaultValue(size_t index) const
|
||||||
|
{
|
||||||
|
return m_attributes.at(index).defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
size_t PDFObjectEditorAbstractModel::createAttribute(ObjectEditorAttributeType type,
|
size_t PDFObjectEditorAbstractModel::createAttribute(ObjectEditorAttributeType type,
|
||||||
QString attributeName,
|
QByteArray attributeName,
|
||||||
QString category,
|
QString category,
|
||||||
QString subcategory,
|
QString subcategory,
|
||||||
QString name,
|
QString name,
|
||||||
@ -64,7 +143,7 @@ size_t PDFObjectEditorAbstractModel::createAttribute(ObjectEditorAttributeType t
|
|||||||
|
|
||||||
PDFObjectEditorModelAttribute attribute;
|
PDFObjectEditorModelAttribute attribute;
|
||||||
attribute.type = type;
|
attribute.type = type;
|
||||||
attribute.dictionaryAttribute = QStringList(qMove(attributeName));
|
attribute.dictionaryAttribute = QByteArrayList(qMove(attributeName));
|
||||||
attribute.category = qMove(category);
|
attribute.category = qMove(category);
|
||||||
attribute.subcategory = qMove(subcategory);
|
attribute.subcategory = qMove(subcategory);
|
||||||
attribute.name = qMove(name);
|
attribute.name = qMove(name);
|
||||||
@ -73,9 +152,43 @@ size_t PDFObjectEditorAbstractModel::createAttribute(ObjectEditorAttributeType t
|
|||||||
attribute.attributeFlags = flags;
|
attribute.attributeFlags = flags;
|
||||||
m_attributes.emplace_back(qMove(attribute));
|
m_attributes.emplace_back(qMove(attribute));
|
||||||
|
|
||||||
|
if (type == ObjectEditorAttributeType::Type)
|
||||||
|
{
|
||||||
|
m_typeAttribute = index;
|
||||||
|
}
|
||||||
|
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t PDFObjectEditorAbstractModel::createSelectorAttribute(QString category, QString subcategory, QString name)
|
||||||
|
{
|
||||||
|
return createAttribute(ObjectEditorAttributeType::Selector, QString(), qMove(category), qMove(subcategory), qMove(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t PDFObjectEditorAbstractModel::getCurrentTypeFlags() const
|
||||||
|
{
|
||||||
|
PDFObject value = getValue(m_typeAttribute);
|
||||||
|
|
||||||
|
for (const PDFObjectEditorModelAttributeEnumItem& item : m_attributes.at(index).enumItems)
|
||||||
|
{
|
||||||
|
if (item.value == value)
|
||||||
|
{
|
||||||
|
return item.flags;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
PDFObject PDFObjectEditorAbstractModel::getDefaultColor() const
|
||||||
|
{
|
||||||
|
PDFObjectFactory factory;
|
||||||
|
factory.beginArray();
|
||||||
|
factory << std::initializer_list<PDFReal>{ 0.0, 0.0, 0.0 };
|
||||||
|
factory.endArray();
|
||||||
|
return factory.takeObject();
|
||||||
|
}
|
||||||
|
|
||||||
PDFObjectEditorAnnotationsModel::PDFObjectEditorAnnotationsModel(QObject* parent) :
|
PDFObjectEditorAnnotationsModel::PDFObjectEditorAnnotationsModel(QObject* parent) :
|
||||||
BaseClass(parent)
|
BaseClass(parent)
|
||||||
{
|
{
|
||||||
@ -103,9 +216,66 @@ PDFObjectEditorAnnotationsModel::PDFObjectEditorAnnotationsModel(QObject* parent
|
|||||||
m_attributes.back().enumItems = qMove(typeEnumItems);
|
m_attributes.back().enumItems = qMove(typeEnumItems);
|
||||||
|
|
||||||
createAttribute(ObjectEditorAttributeType::Rectangle, "Rect", tr("General"), tr("General"), tr("Rectangle"), PDFObject());
|
createAttribute(ObjectEditorAttributeType::Rectangle, "Rect", tr("General"), tr("General"), tr("Rectangle"), PDFObject());
|
||||||
createAttribute(ObjectEditorAttributeType::TextLine, "NM", tr("Contents"), tr("Contents"), tr("Name"));
|
createAttribute(ObjectEditorAttributeType::TextLine, "T", tr("Contents"), tr("Contents"), tr("Author"), PDFObject(), Markup);
|
||||||
|
createAttribute(ObjectEditorAttributeType::TextLine, "Subj", tr("Contents"), tr("Contents"), tr("Subj"), PDFObject(), Markup);
|
||||||
createAttribute(ObjectEditorAttributeType::TextBrowser, "Contents", tr("Contents"), tr("Contents"), tr("Contents"));
|
createAttribute(ObjectEditorAttributeType::TextBrowser, "Contents", tr("Contents"), tr("Contents"), tr("Contents"));
|
||||||
|
createAttribute(ObjectEditorAttributeType::TextLine, "NM", tr("Contents"), tr("Contents"), tr("Annotation name"));
|
||||||
createAttribute(ObjectEditorAttributeType::DateTime, "M", tr("General"), tr("Info"), tr("Modified"), PDFObject(), 0, PDFObjectEditorModelAttribute::Readonly);
|
createAttribute(ObjectEditorAttributeType::DateTime, "M", tr("General"), tr("Info"), tr("Modified"), PDFObject(), 0, PDFObjectEditorModelAttribute::Readonly);
|
||||||
|
createAttribute(ObjectEditorAttributeType::DateTime, "M", tr("General"), tr("Info"), tr("Created"), PDFObject(), Markup, PDFObjectEditorModelAttribute::Readonly);
|
||||||
|
createAttribute(ObjectEditorAttributeType::Flags, "F", tr("Options"), tr("Options"), QString());
|
||||||
|
|
||||||
|
PDFObjectEditorModelAttributeEnumItems annotationFlagItems;
|
||||||
|
annotationFlagItems.emplace_back(tr("Invisible"), 1 << 0, PDFObject());
|
||||||
|
annotationFlagItems.emplace_back(tr("Hidden"), 1 << 1, PDFObject());
|
||||||
|
annotationFlagItems.emplace_back(tr("Print"), 1 << 2, PDFObject());
|
||||||
|
annotationFlagItems.emplace_back(tr("NoZoom"), 1 << 3, PDFObject());
|
||||||
|
annotationFlagItems.emplace_back(tr("NoRotate"), 1 << 4, PDFObject());
|
||||||
|
annotationFlagItems.emplace_back(tr("NoView"), 1 << 5, PDFObject());
|
||||||
|
annotationFlagItems.emplace_back(tr("ReadOnly"), 1 << 6, PDFObject());
|
||||||
|
annotationFlagItems.emplace_back(tr("Locked"), 1 << 7, PDFObject());
|
||||||
|
annotationFlagItems.emplace_back(tr("ToggleNoView"), 1 << 8, PDFObject());
|
||||||
|
annotationFlagItems.emplace_back(tr("LockedContents"), 1 << 9, PDFObject());
|
||||||
|
m_attributes.back().enumItems = qMove(annotationFlagItems);
|
||||||
|
|
||||||
|
size_t appearanceSelector = createSelectorAttribute(tr("General"), tr("Options"), tr("Modify appearance"));
|
||||||
|
createAttribute(ObjectEditorAttributeType::Color, "C", tr("Appearance"), tr("Colors"), tr("Color"), getDefaultColor());
|
||||||
|
m_attributes.back().selectorAttribute = appearanceSelector;
|
||||||
|
|
||||||
|
createAttribute(ObjectEditorAttributeType::ComboBox, "BM", tr("Appearance"), tr("Transparency"), tr("Blend mode"), PDFObject::createName("Normal"));
|
||||||
|
m_attributes.back().selectorAttribute = appearanceSelector;
|
||||||
|
|
||||||
|
PDFObjectEditorModelAttributeEnumItems blendModeEnumItems;
|
||||||
|
for (BlendMode mode : PDFBlendModeInfo::getBlendModes())
|
||||||
|
{
|
||||||
|
annotationFlagItems.emplace_back(PDFBlendModeInfo::getBlendModeTranslatedName(mode), uint(mode), PDFObject::createName(PDFBlendModeInfo::getBlendModeName(mode).toLatin1()));
|
||||||
|
}
|
||||||
|
m_attributes.back().enumItems = qMove(blendModeEnumItems);
|
||||||
|
|
||||||
|
createAttribute(ObjectEditorAttributeType::Double, "ca", tr("Appearance"), tr("Transparency"), tr("Fill opacity"), PDFObject::createReal(1.0));
|
||||||
|
m_attributes.back().selectorAttribute = appearanceSelector;
|
||||||
|
m_attributes.back().minValue = 0.0;
|
||||||
|
m_attributes.back().maxValue = 1.0;
|
||||||
|
createAttribute(ObjectEditorAttributeType::Double, "CA", tr("Appearance"), tr("Transparency"), tr("Stroke opacity"), PDFObject::createReal(1.0));
|
||||||
|
m_attributes.back().selectorAttribute = appearanceSelector;
|
||||||
|
m_attributes.back().minValue = 0.0;
|
||||||
|
m_attributes.back().maxValue = 1.0;
|
||||||
|
|
||||||
|
createAttribute(ObjectEditorAttributeType::TextLine, "Lang", tr("General"), tr("General"), tr("Language"));
|
||||||
|
|
||||||
|
// Sticky note annotation
|
||||||
|
createAttribute(ObjectEditorAttributeType::ComboBox, "Name", tr("Sticky note"), tr("Sticky note"), tr("Type"), PDFObject::createName("Note"), Text);
|
||||||
|
|
||||||
|
PDFObjectEditorModelAttributeEnumItems stickyNoteEnum;
|
||||||
|
stickyNoteEnum.emplace_back(tr("Comment"), 0, PDFObject::createName("Comment"));
|
||||||
|
stickyNoteEnum.emplace_back(tr("Key"), 2, PDFObject::createName("Key"));
|
||||||
|
stickyNoteEnum.emplace_back(tr("Note"), 4, PDFObject::createName("Note"));
|
||||||
|
stickyNoteEnum.emplace_back(tr("Help"), 8, PDFObject::createName("Help"));
|
||||||
|
stickyNoteEnum.emplace_back(tr("New Paragraph"), 16, PDFObject::createName("NewParagraph"));
|
||||||
|
stickyNoteEnum.emplace_back(tr("Paragraph,"), 32, PDFObject::createName("Paragraph"));
|
||||||
|
stickyNoteEnum.emplace_back(tr("Insert"), 64, PDFObject::createName("Insert"));
|
||||||
|
m_attributes.back().enumItems = qMove(stickyNoteEnum);
|
||||||
|
|
||||||
|
createAttribute(ObjectEditorAttributeType::Boolean, "Name", tr("Sticky note"), tr("Sticky note"), tr("Open"), PDFObject::createBool(false), Text);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace pdf
|
} // namespace pdf
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#define PDFOBJECTEDITORABSTRACTMODEL_H
|
#define PDFOBJECTEDITORABSTRACTMODEL_H
|
||||||
|
|
||||||
#include "pdfobject.h"
|
#include "pdfobject.h"
|
||||||
|
#include "pdfdocument.h"
|
||||||
|
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
@ -33,6 +34,12 @@ enum ObjectEditorAttributeType
|
|||||||
TextBrowser, ///< Multiple line text
|
TextBrowser, ///< Multiple line text
|
||||||
Rectangle, ///< Rectangle defined by x,y,width,height
|
Rectangle, ///< Rectangle defined by x,y,width,height
|
||||||
DateTime, ///< Date/time
|
DateTime, ///< Date/time
|
||||||
|
Flags, ///< Flags
|
||||||
|
Selector, ///< Selector attribute, it is not persisted
|
||||||
|
Color, ///< Color
|
||||||
|
Double, ///< Double value
|
||||||
|
ComboBox, ///< Combo box with predefined set of items
|
||||||
|
Boolean, ///< Check box
|
||||||
Invalid
|
Invalid
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -63,7 +70,7 @@ struct PDFObjectEditorModelAttribute
|
|||||||
/// there can be a path of constisting of dictionary names and last
|
/// there can be a path of constisting of dictionary names and last
|
||||||
/// string in the string list is key in the dictionary. If this attribute
|
/// string in the string list is key in the dictionary. If this attribute
|
||||||
/// is empty, then this attribute is not represented in final object.
|
/// is empty, then this attribute is not represented in final object.
|
||||||
QStringList dictionaryAttribute;
|
QByteArrayList dictionaryAttribute;
|
||||||
|
|
||||||
/// Category
|
/// Category
|
||||||
QString category;
|
QString category;
|
||||||
@ -84,6 +91,16 @@ struct PDFObjectEditorModelAttribute
|
|||||||
/// Attribute flags
|
/// Attribute flags
|
||||||
Flags attributeFlags = None;
|
Flags attributeFlags = None;
|
||||||
|
|
||||||
|
/// Selector attribute. This is a zero (no selector attribute), or valid
|
||||||
|
/// selector attribute which is a bool attribute. Selector attribute turns
|
||||||
|
/// on/off displaying of this attribute. If selector state is off, then default
|
||||||
|
/// value is stored into the object. If selector state is on, then user
|
||||||
|
/// can select the attribute value.
|
||||||
|
size_t selectorAttribute = 0;
|
||||||
|
|
||||||
|
QVariant minValue;
|
||||||
|
QVariant maxValue;
|
||||||
|
|
||||||
/// Enum items
|
/// Enum items
|
||||||
PDFObjectEditorModelAttributeEnumItems enumItems;
|
PDFObjectEditorModelAttributeEnumItems enumItems;
|
||||||
};
|
};
|
||||||
@ -104,9 +121,22 @@ public:
|
|||||||
const QString& getAttributeSubcategory(size_t index) const;
|
const QString& getAttributeSubcategory(size_t index) const;
|
||||||
const QString& getAttributeName(size_t index) const;
|
const QString& getAttributeName(size_t index) const;
|
||||||
|
|
||||||
|
enum class Question
|
||||||
|
{
|
||||||
|
IsMapped,
|
||||||
|
HasAttribute,
|
||||||
|
IsAttributeEditable
|
||||||
|
};
|
||||||
|
|
||||||
|
bool queryAttribute(size_t index, Question question) const;
|
||||||
|
|
||||||
|
bool getSelectorValue(size_t index) const;
|
||||||
|
PDFObject getValue(size_t index) const;
|
||||||
|
PDFObject getDefaultValue(size_t index) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
size_t createAttribute(ObjectEditorAttributeType type,
|
size_t createAttribute(ObjectEditorAttributeType type,
|
||||||
QString attributeName,
|
QByteArray attributeName,
|
||||||
QString category,
|
QString category,
|
||||||
QString subcategory,
|
QString subcategory,
|
||||||
QString name,
|
QString name,
|
||||||
@ -114,7 +144,19 @@ protected:
|
|||||||
uint32_t typeFlags = 0,
|
uint32_t typeFlags = 0,
|
||||||
PDFObjectEditorModelAttribute::Flags flags = PDFObjectEditorModelAttribute::None);
|
PDFObjectEditorModelAttribute::Flags flags = PDFObjectEditorModelAttribute::None);
|
||||||
|
|
||||||
|
size_t createSelectorAttribute(QString category,
|
||||||
|
QString subcategory,
|
||||||
|
QString name);
|
||||||
|
|
||||||
|
uint32_t getCurrentTypeFlags() const;
|
||||||
|
|
||||||
|
PDFObject getDefaultColor() const;
|
||||||
|
|
||||||
std::vector<PDFObjectEditorModelAttribute> m_attributes;
|
std::vector<PDFObjectEditorModelAttribute> m_attributes;
|
||||||
|
|
||||||
|
PDFObject m_editedObject;
|
||||||
|
const PDFObjectStorage* m_storage;
|
||||||
|
size_t m_typeAttribute;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PDFFORQTLIBSHARED_EXPORT PDFObjectEditorAnnotationsModel : public PDFObjectEditorAbstractModel
|
class PDFFORQTLIBSHARED_EXPORT PDFObjectEditorAnnotationsModel : public PDFObjectEditorAbstractModel
|
||||||
|
68
PdfForQtLib/sources/pdfobjecteditorwidget.cpp
Normal file
68
PdfForQtLib/sources/pdfobjecteditorwidget.cpp
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
// Copyright (C) 2020 Jakub Melka
|
||||||
|
//
|
||||||
|
// This file is part of PdfForQt.
|
||||||
|
//
|
||||||
|
// PdfForQt is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// PdfForQt is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with PDFForQt. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#include "pdfobjecteditorwidget.h"
|
||||||
|
|
||||||
|
#include <QTabWidget>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QGridLayout>
|
||||||
|
|
||||||
|
namespace pdf
|
||||||
|
{
|
||||||
|
|
||||||
|
class PDFObjectEditorWidgetMapper : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
private:
|
||||||
|
using BaseClass = QObject;
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit PDFObjectEditorWidgetMapper(PDFObjectEditorAbstractModel* model, QObject* parent);
|
||||||
|
|
||||||
|
void initialize();
|
||||||
|
|
||||||
|
private:
|
||||||
|
PDFObjectEditorAbstractModel* m_model;
|
||||||
|
};
|
||||||
|
|
||||||
|
PDFObjectEditorWidget::PDFObjectEditorWidget(PDFObjectEditorAbstractModel* model, QWidget* parent) :
|
||||||
|
BaseClass(parent),
|
||||||
|
m_mapper(nullptr),
|
||||||
|
m_tabWidget(nullptr)
|
||||||
|
{
|
||||||
|
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||||
|
m_tabWidget = new QTabWidget(this);
|
||||||
|
layout->addWidget(m_tabWidget);
|
||||||
|
|
||||||
|
m_mapper = new PDFObjectEditorWidgetMapper(model, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
PDFObjectEditorWidgetMapper::PDFObjectEditorWidgetMapper(PDFObjectEditorAbstractModel* model, QObject* parent) :
|
||||||
|
BaseClass(parent),
|
||||||
|
m_model(model)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void PDFObjectEditorWidgetMapper::initialize()
|
||||||
|
{
|
||||||
|
size_t attributeCount = m_model->getAttributeCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace pdf
|
48
PdfForQtLib/sources/pdfobjecteditorwidget.h
Normal file
48
PdfForQtLib/sources/pdfobjecteditorwidget.h
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
// Copyright (C) 2020 Jakub Melka
|
||||||
|
//
|
||||||
|
// This file is part of PdfForQt.
|
||||||
|
//
|
||||||
|
// PdfForQt is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// PdfForQt is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with PDFForQt. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#ifndef PDFOBJECTEDITORWIDGET_H
|
||||||
|
#define PDFOBJECTEDITORWIDGET_H
|
||||||
|
|
||||||
|
#include "pdfobjecteditormodel.h"
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
class QTabWidget;
|
||||||
|
|
||||||
|
namespace pdf
|
||||||
|
{
|
||||||
|
class PDFObjectEditorWidgetMapper;
|
||||||
|
|
||||||
|
class PDFObjectEditorWidget : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
private:
|
||||||
|
using BaseClass = QWidget;
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit PDFObjectEditorWidget(PDFObjectEditorAbstractModel* model, QWidget* parent);
|
||||||
|
|
||||||
|
private:
|
||||||
|
PDFObjectEditorWidgetMapper* m_mapper;
|
||||||
|
QTabWidget* m_tabWidget;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace pdf
|
||||||
|
|
||||||
|
#endif // PDFOBJECTEDITORWIDGET_H
|
Reference in New Issue
Block a user