Changeset View
Changeset View
Standalone View
Standalone View
src/acbf/AcbfBody.h
Show All 23 Lines | |||||
24 | 24 | | |||
25 | #include <memory> | 25 | #include <memory> | ||
26 | 26 | | |||
27 | #include "AcbfDocument.h" | 27 | #include "AcbfDocument.h" | ||
28 | 28 | | |||
29 | #include <QDate> | 29 | #include <QDate> | ||
30 | class QXmlStreamWriter; | 30 | class QXmlStreamWriter; | ||
31 | class QXmlStreamReader; | 31 | class QXmlStreamReader; | ||
32 | 32 | /** | |||
33 | * \brief Class to handle the body section of ACBF. | ||||
34 | * | ||||
35 | * ACBF's body section holds all the pages. Beyond that, | ||||
36 | * it has a bgcolor. The presence of the body section | ||||
37 | * is mandatory. | ||||
38 | * | ||||
39 | * This class can load and save the body section. | ||||
40 | * It also holds the page objects and allows | ||||
41 | * ordering/adding/removing them. | ||||
42 | */ | ||||
33 | namespace AdvancedComicBookFormat | 43 | namespace AdvancedComicBookFormat | ||
34 | { | 44 | { | ||
35 | class Page; | 45 | class Page; | ||
36 | class ACBF_EXPORT Body : public QObject | 46 | class ACBF_EXPORT Body : public QObject | ||
37 | { | 47 | { | ||
38 | Q_OBJECT | 48 | Q_OBJECT | ||
39 | public: | 49 | public: | ||
40 | explicit Body(Document* parent = nullptr); | 50 | explicit Body(Document* parent = nullptr); | ||
41 | ~Body(); | 51 | ~Body(); | ||
42 | 52 | | |||
43 | Document* document() const; | 53 | Document* document() const; | ||
44 | 54 | | |||
55 | /** | ||||
56 | * \brief write body data into the XMLWriter. | ||||
57 | */ | ||||
45 | void toXml(QXmlStreamWriter *writer); | 58 | void toXml(QXmlStreamWriter *writer); | ||
59 | | ||||
60 | /** | ||||
61 | * \brief Load data from the xml into this body object. | ||||
62 | * @return True if the xmlReader encountered no errors. | ||||
63 | */ | ||||
46 | bool fromXml(QXmlStreamReader *xmlReader); | 64 | bool fromXml(QXmlStreamReader *xmlReader); | ||
47 | 65 | | |||
66 | /** | ||||
67 | * @return the background color as a QString. | ||||
68 | * | ||||
69 | * It should be an 8bit per channel rgb hexcode. | ||||
70 | */ | ||||
48 | QString bgcolor() const; | 71 | QString bgcolor() const; | ||
72 | | ||||
73 | /** | ||||
74 | * \brief set the background color. | ||||
75 | * | ||||
76 | * @param newColor - a String with an 8bit per channel rgb hexcode (#ff00ff, or the like) | ||||
77 | */ | ||||
49 | void setBgcolor(const QString& newColor); | 78 | void setBgcolor(const QString& newColor); | ||
50 | 79 | | |||
80 | /** | ||||
81 | * @return a QList of all the pages stored currently. | ||||
82 | */ | ||||
51 | QList<Page*> pages() const; | 83 | QList<Page*> pages() const; | ||
84 | | ||||
85 | /** | ||||
86 | * @param index - the index of the page. | ||||
87 | * @return the page object at the given index. | ||||
88 | */ | ||||
52 | Page* page(int index) const; | 89 | Page* page(int index) const; | ||
90 | | ||||
91 | /** | ||||
92 | * @param page - The page for which to return the index. | ||||
93 | * @return index of the page given, will return -1 if the page isn't in this document. | ||||
94 | */ | ||||
53 | int pageIndex(Page* page) const; | 95 | int pageIndex(Page* page) const; | ||
54 | 96 | | |||
55 | // If afterIndex is larger than zero, the insertion will happen at that index | 97 | // If afterIndex is larger than zero, the insertion will happen at that index | ||
56 | void addPage(Page* page, int index = -1); | 98 | void addPage(Page* page, int index = -1); | ||
99 | | ||||
100 | /** | ||||
101 | * \brief remove the given page object from this body. | ||||
102 | * @param page - the page to remove. | ||||
103 | */ | ||||
57 | void removePage(Page* page); | 104 | void removePage(Page* page); | ||
105 | | ||||
106 | /** | ||||
107 | * \brief Swap two pages in the list. | ||||
108 | * @param swapThis - the first page to swap. | ||||
109 | * @param withThis - the second page to swap. | ||||
110 | */ | ||||
58 | bool swapPages(Page* swapThis, Page* withThis); | 111 | bool swapPages(Page* swapThis, Page* withThis); | ||
59 | 112 | | |||
60 | private: | 113 | private: | ||
61 | class Private; | 114 | class Private; | ||
62 | std::unique_ptr<Private> d; | 115 | std::unique_ptr<Private> d; | ||
63 | }; | 116 | }; | ||
64 | } | 117 | } | ||
65 | 118 | | |||
66 | #endif//ACBFBODY_H | 119 | #endif//ACBFBODY_H |