1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
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
|