aboutsummaryrefslogtreecommitdiff
path: root/afdnotebook.h
diff options
context:
space:
mode:
Diffstat (limited to 'afdnotebook.h')
-rw-r--r--afdnotebook.h119
1 files changed, 119 insertions, 0 deletions
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 <QtCore/QDateTime>
+#include <QtCore/QDir>
+#include <QtCore/QMap>
+#include <QtGui/QImage>
+#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<int> 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<int, StrokeData> strokes;
+ };
+
+private:
+ static QMap<QString, QString> parsePropertyList(QIODevice *dev);
+ QMap<QString, QString> 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<QString, Gfx> _gfx;
+ QList<Page> _pages;
+ QMap<QString, PenData> _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