shared: Introduce DocumentOutlineEntry
This commit is contained in:
父節點
8550506517
當前提交
c5713f5839
31
shared/documentoutlineentry.cpp
Normal file
31
shared/documentoutlineentry.cpp
Normal file
@ -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;
|
||||
}
|
29
shared/documentoutlineentry.h
Normal file
29
shared/documentoutlineentry.h
Normal file
@ -0,0 +1,29 @@
|
||||
#ifndef DOCUMENTOUTLINEENTRY_H
|
||||
#define DOCUMENTOUTLINEENTRY_H
|
||||
#include <QMetaType>
|
||||
#include <QDataStream>
|
||||
#include <QString>
|
||||
|
||||
enum OutlineDestinationType
|
||||
{
|
||||
OUTLINE_DESTINATION_TYPE_NONE,
|
||||
OUTLINE_DESTINATION_TYPE_PAGE
|
||||
/* In the future, links, or #anchors are possible */
|
||||
};
|
||||
|
||||
class DocumentOutlineEntry
|
||||
{
|
||||
public:
|
||||
DocumentOutlineEntry();
|
||||
QVector<DocumentOutlineEntry> 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
|
載入中…
新增問題並參考
Block a user