aboutsummaryrefslogtreecommitdiff
path: root/afdnotebook.h
blob: 74861ca943c57fff916d1d274779888f377a3cb9 (plain)
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
#ifndef AFDNOTEBOOK_H
#define AFDNOTEBOOK_H

#include <QtCore/QDateTime>
#include <QtCore/QDir>
#include <QtCore/QMap>
#include <QtGui/QImage>
#include "afdpageaddress.h"
#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;
	quint64 guid() const;

	int numPages() const;

	AfdPageAddress getPageAddress(int pageNum) const;
	int getPageNumber(const AfdPageAddress &addr) 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 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();

private:
	QDir _dir;
	QString _title;
	quint64 _guid;
	AfdPageAddress _firstPage, _lastPage;
	uint _pagesPerBook;
	QMap<QString, Gfx> _gfx;
	QList<Page> _pages;
	QMap<QString, PenData> _penData;
};

#endif