author | leseb <leseb> | 2002-06-14 15:13:02 (UTC) |
---|---|---|
committer | leseb <leseb> | 2002-06-14 15:13:02 (UTC) |
commit | 4898376fe38510a7cd54d24485860a3fa7187ad3 (patch) (unidiff) | |
tree | e8d0fe758cc3ce655074713103ea00cf96bac43b | |
parent | f1d0fd5330f4e6a8313cd8e5dcdb5e843805ae3f (diff) | |
download | opie-4898376fe38510a7cd54d24485860a3fa7187ad3.zip opie-4898376fe38510a7cd54d24485860a3fa7187ad3.tar.gz opie-4898376fe38510a7cd54d24485860a3fa7187ad3.tar.bz2 |
Page attributes works!!!
-rw-r--r-- | noncore/graphics/drawpad/drawpad.cpp | 6 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpadcanvas.cpp | 48 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpadcanvas.h | 2 | ||||
-rw-r--r-- | noncore/graphics/drawpad/newpagedialog.cpp | 5 | ||||
-rw-r--r-- | noncore/graphics/drawpad/newpagedialog.h | 1 | ||||
-rw-r--r-- | noncore/graphics/drawpad/page.cpp | 6 | ||||
-rw-r--r-- | noncore/graphics/drawpad/page.h | 4 | ||||
-rw-r--r-- | noncore/graphics/drawpad/thumbnailview.cpp | 4 |
8 files changed, 56 insertions, 20 deletions
diff --git a/noncore/graphics/drawpad/drawpad.cpp b/noncore/graphics/drawpad/drawpad.cpp index 369e7f0..45fb886 100644 --- a/noncore/graphics/drawpad/drawpad.cpp +++ b/noncore/graphics/drawpad/drawpad.cpp | |||
@@ -23,6 +23,7 @@ | |||
23 | #include "importdialog.h" | 23 | #include "importdialog.h" |
24 | #include "linetool.h" | 24 | #include "linetool.h" |
25 | #include "newpagedialog.h" | 25 | #include "newpagedialog.h" |
26 | #include "page.h" | ||
26 | #include "pageinformationdialog.h" | 27 | #include "pageinformationdialog.h" |
27 | #include "pointtool.h" | 28 | #include "pointtool.h" |
28 | #include "rectangletool.h" | 29 | #include "rectangletool.h" |
@@ -281,8 +282,8 @@ void DrawPad::newPage() | |||
281 | NewPageDialog newPageDialog(rect.width(), rect.height(), m_pen.color(), m_brush.color(), this); | 282 | NewPageDialog newPageDialog(rect.width(), rect.height(), m_pen.color(), m_brush.color(), this); |
282 | 283 | ||
283 | if (newPageDialog.exec() == QDialog::Accepted) { | 284 | if (newPageDialog.exec() == QDialog::Accepted) { |
284 | m_pDrawPadCanvas->newPage(newPageDialog.selectedWidth(), newPageDialog.selectedHeight(), | 285 | m_pDrawPadCanvas->newPage(newPageDialog.selectedTitle(), newPageDialog.selectedWidth(), |
285 | newPageDialog.selectedColor()); | 286 | newPageDialog.selectedHeight(), newPageDialog.selectedColor()); |
286 | } | 287 | } |
287 | } | 288 | } |
288 | 289 | ||
@@ -604,5 +605,6 @@ void DrawPad::pageInformation() | |||
604 | PageInformationDialog pageInformationDialog(m_pDrawPadCanvas->currentPage()); | 605 | PageInformationDialog pageInformationDialog(m_pDrawPadCanvas->currentPage()); |
605 | 606 | ||
606 | if (pageInformationDialog.exec() == QDialog::Accepted) { | 607 | if (pageInformationDialog.exec() == QDialog::Accepted) { |
608 | m_pDrawPadCanvas->currentPage()->setTitle(pageInformationDialog.selectedTitle()); | ||
607 | } | 609 | } |
608 | } | 610 | } |
diff --git a/noncore/graphics/drawpad/drawpadcanvas.cpp b/noncore/graphics/drawpad/drawpadcanvas.cpp index bcb6877..dcf0871 100644 --- a/noncore/graphics/drawpad/drawpadcanvas.cpp +++ b/noncore/graphics/drawpad/drawpadcanvas.cpp | |||
@@ -47,10 +47,14 @@ public: | |||
47 | private: | 47 | private: |
48 | enum State { | 48 | enum State { |
49 | Unknown, | 49 | Unknown, |
50 | InTitle, | ||
51 | InDate, | ||
50 | InData | 52 | InData |
51 | }; | 53 | }; |
52 | 54 | ||
53 | State m_state; | 55 | State m_state; |
56 | QString m_title; | ||
57 | QDateTime m_date; | ||
54 | ulong m_dataLenght; | 58 | ulong m_dataLenght; |
55 | QString m_dataFormat; | 59 | QString m_dataFormat; |
56 | QList<Page> m_pages; | 60 | QList<Page> m_pages; |
@@ -76,7 +80,14 @@ bool DrawPadCanvasXmlHandler::startElement(const QString& namespaceURI, const QS | |||
76 | Q_CONST_UNUSED(namespaceURI) | 80 | Q_CONST_UNUSED(namespaceURI) |
77 | Q_CONST_UNUSED(localName) | 81 | Q_CONST_UNUSED(localName) |
78 | 82 | ||
79 | if (qName.compare("data") == 0) { | 83 | if (qName == "image") { |
84 | m_title = QString(); | ||
85 | m_date = QDateTime(QDate(1970, 1, 1)); | ||
86 | } else if (qName == "title") { | ||
87 | m_state = InTitle; | ||
88 | } else if (qName == "date") { | ||
89 | m_state = InDate; | ||
90 | } else if (qName == "data") { | ||
80 | m_state = InData; | 91 | m_state = InData; |
81 | m_dataLenght = atts.value("length").toULong(); | 92 | m_dataLenght = atts.value("length").toULong(); |
82 | m_dataFormat = atts.value("format"); | 93 | m_dataFormat = atts.value("format"); |
@@ -95,7 +106,11 @@ bool DrawPadCanvasXmlHandler::endElement(const QString& namespaceURI, const QStr | |||
95 | Q_CONST_UNUSED(namespaceURI) | 106 | Q_CONST_UNUSED(namespaceURI) |
96 | Q_CONST_UNUSED(localName) | 107 | Q_CONST_UNUSED(localName) |
97 | 108 | ||
98 | if (qName.compare("data") == 0) { | 109 | if (qName == "title") { |
110 | m_state = Unknown; | ||
111 | } else if (qName == "date") { | ||
112 | m_state = Unknown; | ||
113 | } else if (qName == "data") { | ||
99 | m_state = Unknown; | 114 | m_state = Unknown; |
100 | } | 115 | } |
101 | 116 | ||
@@ -104,7 +119,11 @@ bool DrawPadCanvasXmlHandler::endElement(const QString& namespaceURI, const QStr | |||
104 | 119 | ||
105 | bool DrawPadCanvasXmlHandler::characters(const QString& ch) | 120 | bool DrawPadCanvasXmlHandler::characters(const QString& ch) |
106 | { | 121 | { |
107 | if (m_state == InData) { | 122 | if (m_state == InTitle) { |
123 | m_title = ch; | ||
124 | } else if (m_state == InDate) { | ||
125 | m_date = m_date.addSecs(ch.toInt()); | ||
126 | } else if (m_state == InData) { | ||
108 | QByteArray byteArray(ch.length() / 2); | 127 | QByteArray byteArray(ch.length() / 2); |
109 | 128 | ||
110 | for (int i = 0; i < (int)ch.length() / 2; i++) { | 129 | for (int i = 0; i < (int)ch.length() / 2; i++) { |
@@ -145,7 +164,8 @@ bool DrawPadCanvasXmlHandler::characters(const QString& ch) | |||
145 | image.loadFromData((const uchar*)byteArray.data(), m_dataLenght, m_dataFormat); | 164 | image.loadFromData((const uchar*)byteArray.data(), m_dataLenght, m_dataFormat); |
146 | } | 165 | } |
147 | 166 | ||
148 | Page* page = new Page(image.width(), image.height()); | 167 | Page* page = new Page(m_title, image.width(), image.height()); |
168 | page->setLastModified(m_date); | ||
149 | page->convertFromImage(image); | 169 | page->convertFromImage(image); |
150 | m_pages.append(page); | 170 | m_pages.append(page); |
151 | } | 171 | } |
@@ -182,7 +202,7 @@ void DrawPadCanvas::load(QIODevice* ioDevice) | |||
182 | m_pages = drawPadCanvasXmlHandler.pages(); | 202 | m_pages = drawPadCanvasXmlHandler.pages(); |
183 | 203 | ||
184 | if (m_pages.isEmpty()) { | 204 | if (m_pages.isEmpty()) { |
185 | m_pages.append(new Page(contentsRect().size())); | 205 | m_pages.append(new Page("", contentsRect().size())); |
186 | m_pages.current()->fill(Qt::white); | 206 | m_pages.current()->fill(Qt::white); |
187 | } | 207 | } |
188 | 208 | ||
@@ -198,7 +218,7 @@ void DrawPadCanvas::load(QIODevice* ioDevice) | |||
198 | 218 | ||
199 | void DrawPadCanvas::initialPage() | 219 | void DrawPadCanvas::initialPage() |
200 | { | 220 | { |
201 | m_pages.append(new Page(236, 232)); | 221 | m_pages.append(new Page("", 236, 232)); |
202 | m_pages.current()->fill(Qt::white); | 222 | m_pages.current()->fill(Qt::white); |
203 | 223 | ||
204 | m_pageBackups.clear(); | 224 | m_pageBackups.clear(); |
@@ -223,6 +243,10 @@ void DrawPadCanvas::save(QIODevice* ioDevice) | |||
223 | 243 | ||
224 | for (bufferIterator.toFirst(); bufferIterator.current() != 0; ++bufferIterator) { | 244 | for (bufferIterator.toFirst(); bufferIterator.current() != 0; ++bufferIterator) { |
225 | textStream << " <image>" << endl; | 245 | textStream << " <image>" << endl; |
246 | textStream << " <title>" << bufferIterator.current()->title() << "</title>" << endl; | ||
247 | |||
248 | int intDate = QDateTime(QDate(1970, 1, 1)).secsTo(bufferIterator.current()->lastModified()); | ||
249 | textStream << " <date>" << intDate << "</date>" << endl; | ||
226 | 250 | ||
227 | QImage image = bufferIterator.current()->convertToImage(); | 251 | QImage image = bufferIterator.current()->convertToImage(); |
228 | QByteArray byteArray; | 252 | QByteArray byteArray; |
@@ -341,7 +365,9 @@ void DrawPadCanvas::selectPage(Page* page) | |||
341 | 365 | ||
342 | void DrawPadCanvas::backupPage() | 366 | void DrawPadCanvas::backupPage() |
343 | { | 367 | { |
344 | QPixmap* currentBackup = m_pageBackups.current(); | 368 | m_pages.current()->setLastModified(QDateTime::currentDateTime()); |
369 | |||
370 | Page* currentBackup = m_pageBackups.current(); | ||
345 | while (m_pageBackups.last() != currentBackup) { | 371 | while (m_pageBackups.last() != currentBackup) { |
346 | m_pageBackups.removeLast(); | 372 | m_pageBackups.removeLast(); |
347 | } | 373 | } |
@@ -359,7 +385,7 @@ void DrawPadCanvas::deleteAll() | |||
359 | { | 385 | { |
360 | m_pages.clear(); | 386 | m_pages.clear(); |
361 | 387 | ||
362 | m_pages.append(new Page(contentsRect().size())); | 388 | m_pages.append(new Page("", contentsRect().size())); |
363 | m_pages.current()->fill(Qt::white); | 389 | m_pages.current()->fill(Qt::white); |
364 | 390 | ||
365 | m_pageBackups.clear(); | 391 | m_pageBackups.clear(); |
@@ -372,9 +398,9 @@ void DrawPadCanvas::deleteAll() | |||
372 | emit pageBackupsChanged(); | 398 | emit pageBackupsChanged(); |
373 | } | 399 | } |
374 | 400 | ||
375 | void DrawPadCanvas::newPage(uint width, uint height, const QColor& color) | 401 | void DrawPadCanvas::newPage(QString title, uint width, uint height, const QColor& color) |
376 | { | 402 | { |
377 | m_pages.insert(m_pages.at() + 1, new Page(width, height)); | 403 | m_pages.insert(m_pages.at() + 1, new Page(title, width, height)); |
378 | m_pages.current()->fill(color); | 404 | m_pages.current()->fill(color); |
379 | 405 | ||
380 | m_pageBackups.clear(); | 406 | m_pageBackups.clear(); |
@@ -405,7 +431,7 @@ void DrawPadCanvas::deletePage() | |||
405 | m_pages.remove(m_pages.current()); | 431 | m_pages.remove(m_pages.current()); |
406 | 432 | ||
407 | if (m_pages.isEmpty()) { | 433 | if (m_pages.isEmpty()) { |
408 | m_pages.append(new Page(contentsRect().size())); | 434 | m_pages.append(new Page("", contentsRect().size())); |
409 | m_pages.current()->fill(Qt::white); | 435 | m_pages.current()->fill(Qt::white); |
410 | } | 436 | } |
411 | 437 | ||
diff --git a/noncore/graphics/drawpad/drawpadcanvas.h b/noncore/graphics/drawpad/drawpadcanvas.h index 39cf752..dcaff5c 100644 --- a/noncore/graphics/drawpad/drawpadcanvas.h +++ b/noncore/graphics/drawpad/drawpadcanvas.h | |||
@@ -52,7 +52,7 @@ public: | |||
52 | 52 | ||
53 | public slots: | 53 | public slots: |
54 | void deleteAll(); | 54 | void deleteAll(); |
55 | void newPage(uint width, uint height, const QColor& color); | 55 | void newPage(QString title, uint width, uint height, const QColor& color); |
56 | void clearPage(); | 56 | void clearPage(); |
57 | void deletePage(); | 57 | void deletePage(); |
58 | void movePageUp(); | 58 | void movePageUp(); |
diff --git a/noncore/graphics/drawpad/newpagedialog.cpp b/noncore/graphics/drawpad/newpagedialog.cpp index ff31aad..e6e7fcb 100644 --- a/noncore/graphics/drawpad/newpagedialog.cpp +++ b/noncore/graphics/drawpad/newpagedialog.cpp | |||
@@ -85,6 +85,11 @@ NewPageDialog::~NewPageDialog() | |||
85 | { | 85 | { |
86 | } | 86 | } |
87 | 87 | ||
88 | QString NewPageDialog::selectedTitle() | ||
89 | { | ||
90 | return (m_pTitleLineEdit->text()); | ||
91 | } | ||
92 | |||
88 | uint NewPageDialog::selectedWidth() | 93 | uint NewPageDialog::selectedWidth() |
89 | { | 94 | { |
90 | return (m_pWidthSpinBox->value()); | 95 | return (m_pWidthSpinBox->value()); |
diff --git a/noncore/graphics/drawpad/newpagedialog.h b/noncore/graphics/drawpad/newpagedialog.h index fe8f562..c8f84b8 100644 --- a/noncore/graphics/drawpad/newpagedialog.h +++ b/noncore/graphics/drawpad/newpagedialog.h | |||
@@ -29,6 +29,7 @@ public: | |||
29 | const QColor& backgroundColor, QWidget* parent = 0, const char* name = 0); | 29 | const QColor& backgroundColor, QWidget* parent = 0, const char* name = 0); |
30 | ~NewPageDialog(); | 30 | ~NewPageDialog(); |
31 | 31 | ||
32 | QString selectedTitle(); | ||
32 | uint selectedWidth(); | 33 | uint selectedWidth(); |
33 | uint selectedHeight(); | 34 | uint selectedHeight(); |
34 | const QColor& selectedColor(); | 35 | const QColor& selectedColor(); |
diff --git a/noncore/graphics/drawpad/page.cpp b/noncore/graphics/drawpad/page.cpp index 7034a20..601d1c3 100644 --- a/noncore/graphics/drawpad/page.cpp +++ b/noncore/graphics/drawpad/page.cpp | |||
@@ -19,15 +19,17 @@ Page::Page() | |||
19 | m_lastModified = QDateTime::currentDateTime(); | 19 | m_lastModified = QDateTime::currentDateTime(); |
20 | } | 20 | } |
21 | 21 | ||
22 | Page::Page(int w, int h) | 22 | Page::Page(QString title, int w, int h) |
23 | : QPixmap(w, h) | 23 | : QPixmap(w, h) |
24 | { | 24 | { |
25 | m_title = title; | ||
25 | m_lastModified = QDateTime::currentDateTime(); | 26 | m_lastModified = QDateTime::currentDateTime(); |
26 | } | 27 | } |
27 | 28 | ||
28 | Page::Page(const QSize& size) | 29 | Page::Page(QString title, const QSize& size) |
29 | : QPixmap(size) | 30 | : QPixmap(size) |
30 | { | 31 | { |
32 | m_title = title; | ||
31 | m_lastModified = QDateTime::currentDateTime(); | 33 | m_lastModified = QDateTime::currentDateTime(); |
32 | } | 34 | } |
33 | 35 | ||
diff --git a/noncore/graphics/drawpad/page.h b/noncore/graphics/drawpad/page.h index 020ab1f..20a37b5 100644 --- a/noncore/graphics/drawpad/page.h +++ b/noncore/graphics/drawpad/page.h | |||
@@ -22,8 +22,8 @@ class Page : public QPixmap | |||
22 | { | 22 | { |
23 | public: | 23 | public: |
24 | Page(); | 24 | Page(); |
25 | Page(int w, int h); | 25 | Page(QString title, int w, int h); |
26 | Page(const QSize& size); | 26 | Page(QString title, const QSize& size); |
27 | 27 | ||
28 | ~Page(); | 28 | ~Page(); |
29 | 29 | ||
diff --git a/noncore/graphics/drawpad/thumbnailview.cpp b/noncore/graphics/drawpad/thumbnailview.cpp index 35955e8..81ec79f 100644 --- a/noncore/graphics/drawpad/thumbnailview.cpp +++ b/noncore/graphics/drawpad/thumbnailview.cpp | |||
@@ -321,8 +321,8 @@ void ThumbnailView::newPage() | |||
321 | m_pDrawPad->brush().color(), this); | 321 | m_pDrawPad->brush().color(), this); |
322 | 322 | ||
323 | if (newPageDialog.exec() == QDialog::Accepted) { | 323 | if (newPageDialog.exec() == QDialog::Accepted) { |
324 | m_pDrawPadCanvas->newPage(newPageDialog.selectedWidth(), newPageDialog.selectedHeight(), | 324 | m_pDrawPadCanvas->newPage(newPageDialog.selectedTitle(), newPageDialog.selectedWidth(), |
325 | newPageDialog.selectedColor()); | 325 | newPageDialog.selectedHeight(), newPageDialog.selectedColor()); |
326 | m_pPageListBox->updateView(); | 326 | m_pPageListBox->updateView(); |
327 | updateView(); | 327 | updateView(); |
328 | } | 328 | } |