From a69e97943539a8abc4d2762638c169dc19c88516 Mon Sep 17 00:00:00 2001 From: Javier Date: Sun, 7 Jun 2015 21:22:45 +0200 Subject: initial import --- afdnotebook.h | 119 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 afdnotebook.h (limited to 'afdnotebook.h') diff --git a/afdnotebook.h b/afdnotebook.h new file mode 100644 index 0000000..ea90661 --- /dev/null +++ b/afdnotebook.h @@ -0,0 +1,119 @@ +#ifndef AFDNOTEBOOK_H +#define AFDNOTEBOOK_H + +#include +#include +#include +#include +#include "stfreader.h" + +class AfdNotebook : public QObject +{ + Q_OBJECT + +public: + AfdNotebook(QObject *parent = 0); + ~AfdNotebook(); + + bool open(const QString &path); + void close(); + + QString title() const; + + int numPages() const; + + QString getPageBackgroundName(int page) const; + QPixmap getPageBackground(int page); + + QSize getPageSize(int page) const; + QRect getPageTrim(int page) const; + + QStringList penSerials() const; + QList pagesWithStrokes(const QString &penSerial) const; + + QStringList strokeFiles(const QString &penSerial, int page) const; + + bool readStrokes(const QString &penSerial, int page, StfReader::StrokeHandler *handler); + +private: + struct PageAddress { + PageAddress(); + explicit PageAddress(uint shelf, uint segment, uint book, uint page); + explicit PageAddress(uint series, uint shelf, uint segment, uint book, uint page); + explicit PageAddress(const QString &str); + + QString toString() const; + + bool operator<(const PageAddress& o) const; + bool operator==(const PageAddress& o) const; + + uint series : 12; + uint shelf : 12; + uint segment : 16; + uint book : 12; + uint page : 12; + }; + + struct Gfx { + QString basename; + }; + + struct Page { + Gfx *gfx; + QSize size; + }; + + struct StrokeData { + QString file; + QDateTime begin; + QDateTime end; + }; + + struct PenData { + QMultiMap strokes; + }; + +private: + static QMap parsePropertyList(QIODevice *dev); + QMap parsePropertyList(const QString &relativePath) const; + + bool parseMainInfo(); + bool parseMainDocument(); + bool parseGfx(const QString &file); + bool findPenData(); + + PageAddress getPageAddress(int page) const; + int getPageNumber(const PageAddress &addr); + +private: + QDir _dir; + QString _title; + PageAddress _firstPage, _lastPage; + uint _pagesPerBook; + QMap _gfx; + QList _pages; + QMap _penData; +}; + +inline AfdNotebook::PageAddress::PageAddress() + : series(0), shelf(0), segment(0), book(0), page(0) +{ +} + +inline AfdNotebook::PageAddress::PageAddress(uint shelf, uint segment, uint book, uint page) + : series(0), shelf(shelf), segment(segment), book(book), page(page) +{ +} + +inline AfdNotebook::PageAddress::PageAddress(uint series, uint shelf, uint segment, uint book, uint page) + : series(series), shelf(shelf), segment(segment), book(book), page(page) +{ +} + +inline bool AfdNotebook::PageAddress::operator ==(const PageAddress &o) const +{ + return series == o.series && shelf == o.shelf && segment == o.segment && + book == o.book && page == o.page; +} + +#endif -- cgit v1.2.3