diff --git a/shared/documentoutlineentry.cpp b/shared/documentoutlineentry.cpp new file mode 100644 index 0000000..224037c --- /dev/null +++ b/shared/documentoutlineentry.cpp @@ -0,0 +1,31 @@ +#include "documentoutlineentry.h" + +DocumentOutlineEntry::DocumentOutlineEntry() +{ +} + +QDataStream &operator<<(QDataStream &out, const DocumentOutlineEntry &pd) +{ + out << pd.text << pd.type << pd.destinationPage; + out << pd.children.size(); + for(const DocumentOutlineEntry &entry : pd.children) + { + out << entry; + } + return out; +} + +QDataStream &operator>>(QDataStream &in, DocumentOutlineEntry &pd) +{ + in >> pd.text >> pd.type >> pd.destinationPage; + + int numChildren; + in >> numChildren; + for(int i = 0; i < numChildren; i++) + { + DocumentOutlineEntry entry; + in >> entry; + pd.children.append(entry); + } + return in; +} diff --git a/shared/documentoutlineentry.h b/shared/documentoutlineentry.h new file mode 100644 index 0000000..abf83b7 --- /dev/null +++ b/shared/documentoutlineentry.h @@ -0,0 +1,29 @@ +#ifndef DOCUMENTOUTLINEENTRY_H +#define DOCUMENTOUTLINEENTRY_H +#include +#include +#include + +enum OutlineDestinationType +{ + OUTLINE_DESTINATION_TYPE_NONE, + OUTLINE_DESTINATION_TYPE_PAGE + /* In the future, links, or #anchors are possible */ +}; + +class DocumentOutlineEntry +{ + public: + DocumentOutlineEntry(); + QVector children; + OutlineDestinationType type; + QString text; + unsigned int destinationPage; +}; + +Q_DECLARE_METATYPE(DocumentOutlineEntry); + +QDataStream &operator<<(QDataStream &out, const DocumentOutlineEntry &pd); +QDataStream &operator>>(QDataStream &in, DocumentOutlineEntry &pd); + +#endif // DOCUMENTOUTLINEENTRY_H