summaryrefslogtreecommitdiff
authorleseb <leseb>2002-06-14 15:13:02 (UTC)
committer leseb <leseb>2002-06-14 15:13:02 (UTC)
commit4898376fe38510a7cd54d24485860a3fa7187ad3 (patch) (side-by-side diff)
treee8d0fe758cc3ce655074713103ea00cf96bac43b
parentf1d0fd5330f4e6a8313cd8e5dcdb5e843805ae3f (diff)
downloadopie-4898376fe38510a7cd54d24485860a3fa7187ad3.zip
opie-4898376fe38510a7cd54d24485860a3fa7187ad3.tar.gz
opie-4898376fe38510a7cd54d24485860a3fa7187ad3.tar.bz2
Page attributes works!!!
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/drawpad/drawpad.cpp6
-rw-r--r--noncore/graphics/drawpad/drawpadcanvas.cpp50
-rw-r--r--noncore/graphics/drawpad/drawpadcanvas.h2
-rw-r--r--noncore/graphics/drawpad/newpagedialog.cpp5
-rw-r--r--noncore/graphics/drawpad/newpagedialog.h1
-rw-r--r--noncore/graphics/drawpad/page.cpp6
-rw-r--r--noncore/graphics/drawpad/page.h4
-rw-r--r--noncore/graphics/drawpad/thumbnailview.cpp4
8 files changed, 57 insertions, 21 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
@@ -20,12 +20,13 @@
#include "filledellipsetool.h"
#include "filledrectangletool.h"
#include "filltool.h"
#include "importdialog.h"
#include "linetool.h"
#include "newpagedialog.h"
+#include "page.h"
#include "pageinformationdialog.h"
#include "pointtool.h"
#include "rectangletool.h"
#include "texttool.h"
#include "thumbnailview.h"
@@ -278,14 +279,14 @@ void DrawPad::newPage()
{
QRect rect = m_pDrawPadCanvas->contentsRect();
NewPageDialog newPageDialog(rect.width(), rect.height(), m_pen.color(), m_brush.color(), this);
if (newPageDialog.exec() == QDialog::Accepted) {
- m_pDrawPadCanvas->newPage(newPageDialog.selectedWidth(), newPageDialog.selectedHeight(),
- newPageDialog.selectedColor());
+ m_pDrawPadCanvas->newPage(newPageDialog.selectedTitle(), newPageDialog.selectedWidth(),
+ newPageDialog.selectedHeight(), newPageDialog.selectedColor());
}
}
void DrawPad::clearPage()
{
QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe current page?"),
@@ -601,8 +602,9 @@ void DrawPad::thumbnailView()
void DrawPad::pageInformation()
{
PageInformationDialog pageInformationDialog(m_pDrawPadCanvas->currentPage());
if (pageInformationDialog.exec() == QDialog::Accepted) {
+ m_pDrawPadCanvas->currentPage()->setTitle(pageInformationDialog.selectedTitle());
}
}
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
@@ -44,16 +44,20 @@ public:
const QString& qName);
bool characters(const QString& ch);
private:
enum State {
Unknown,
+ InTitle,
+ InDate,
InData
};
State m_state;
+ QString m_title;
+ QDateTime m_date;
ulong m_dataLenght;
QString m_dataFormat;
QList<Page> m_pages;
};
DrawPadCanvasXmlHandler::DrawPadCanvasXmlHandler()
@@ -73,13 +77,20 @@ QList<Page> DrawPadCanvasXmlHandler::pages()
bool DrawPadCanvasXmlHandler::startElement(const QString& namespaceURI, const QString& localName,
const QString& qName, const QXmlAttributes& atts)
{
Q_CONST_UNUSED(namespaceURI)
Q_CONST_UNUSED(localName)
- if (qName.compare("data") == 0) {
+ if (qName == "image") {
+ m_title = QString();
+ m_date = QDateTime(QDate(1970, 1, 1));
+ } else if (qName == "title") {
+ m_state = InTitle;
+ } else if (qName == "date") {
+ m_state = InDate;
+ } else if (qName == "data") {
m_state = InData;
m_dataLenght = atts.value("length").toULong();
m_dataFormat = atts.value("format");
if (m_dataFormat.isEmpty()) {
m_dataFormat = "XPM";
@@ -92,22 +103,30 @@ bool DrawPadCanvasXmlHandler::startElement(const QString& namespaceURI, const QS
bool DrawPadCanvasXmlHandler::endElement(const QString& namespaceURI, const QString& localName,
const QString& qName)
{
Q_CONST_UNUSED(namespaceURI)
Q_CONST_UNUSED(localName)
- if (qName.compare("data") == 0) {
+ if (qName == "title") {
+ m_state = Unknown;
+ } else if (qName == "date") {
+ m_state = Unknown;
+ } else if (qName == "data") {
m_state = Unknown;
}
return true;
}
-bool DrawPadCanvasXmlHandler::characters(const QString& ch)
+bool DrawPadCanvasXmlHandler::characters(const QString& ch)
{
- if (m_state == InData) {
+ if (m_state == InTitle) {
+ m_title = ch;
+ } else if (m_state == InDate) {
+ m_date = m_date.addSecs(ch.toInt());
+ } else if (m_state == InData) {
QByteArray byteArray(ch.length() / 2);
for (int i = 0; i < (int)ch.length() / 2; i++) {
char h = ch[2 * i].latin1();
char l = ch[2 * i + 1].latin1();
uchar r = 0;
@@ -142,13 +161,14 @@ bool DrawPadCanvasXmlHandler::characters(const QString& ch)
image.loadFromData((const uchar*)byteArrayUnzipped.data(), m_dataLenght, m_dataFormat);
} else {
image.loadFromData((const uchar*)byteArray.data(), m_dataLenght, m_dataFormat);
}
- Page* page = new Page(image.width(), image.height());
+ Page* page = new Page(m_title, image.width(), image.height());
+ page->setLastModified(m_date);
page->convertFromImage(image);
m_pages.append(page);
}
return true;
}
@@ -179,13 +199,13 @@ void DrawPadCanvas::load(QIODevice* ioDevice)
xmlSimpleReader.setContentHandler(&drawPadCanvasXmlHandler);
xmlSimpleReader.parse(xmlInputSource);
m_pages = drawPadCanvasXmlHandler.pages();
if (m_pages.isEmpty()) {
- m_pages.append(new Page(contentsRect().size()));
+ m_pages.append(new Page("", contentsRect().size()));
m_pages.current()->fill(Qt::white);
}
m_pageBackups.clear();
m_pageBackups.append(new Page(*(m_pages.current())));
@@ -195,13 +215,13 @@ void DrawPadCanvas::load(QIODevice* ioDevice)
emit pagesChanged();
emit pageBackupsChanged();
}
void DrawPadCanvas::initialPage()
{
- m_pages.append(new Page(236, 232));
+ m_pages.append(new Page("", 236, 232));
m_pages.current()->fill(Qt::white);
m_pageBackups.clear();
m_pageBackups.append(new Page(*(m_pages.current())));
resizeContents(m_pages.current()->width(), m_pages.current()->height());
@@ -220,12 +240,16 @@ void DrawPadCanvas::save(QIODevice* ioDevice)
textStream << " <images>" << endl;
QListIterator<Page> bufferIterator(m_pages);
for (bufferIterator.toFirst(); bufferIterator.current() != 0; ++bufferIterator) {
textStream << " <image>" << endl;
+ textStream << " <title>" << bufferIterator.current()->title() << "</title>" << endl;
+
+ int intDate = QDateTime(QDate(1970, 1, 1)).secsTo(bufferIterator.current()->lastModified());
+ textStream << " <date>" << intDate << "</date>" << endl;
QImage image = bufferIterator.current()->convertToImage();
QByteArray byteArray;
QBuffer buffer(byteArray);
QImageIO imageIO(&buffer, "PNG");
@@ -338,13 +362,15 @@ void DrawPadCanvas::selectPage(Page* page)
emit pagesChanged();
emit pageBackupsChanged();
}
void DrawPadCanvas::backupPage()
{
- QPixmap* currentBackup = m_pageBackups.current();
+ m_pages.current()->setLastModified(QDateTime::currentDateTime());
+
+ Page* currentBackup = m_pageBackups.current();
while (m_pageBackups.last() != currentBackup) {
m_pageBackups.removeLast();
}
while (m_pageBackups.count() >= (5 + 1)) {
m_pageBackups.removeFirst();
@@ -356,28 +382,28 @@ void DrawPadCanvas::backupPage()
}
void DrawPadCanvas::deleteAll()
{
m_pages.clear();
- m_pages.append(new Page(contentsRect().size()));
+ m_pages.append(new Page("", contentsRect().size()));
m_pages.current()->fill(Qt::white);
m_pageBackups.clear();
m_pageBackups.append(new Page(*(m_pages.current())));
resizeContents(m_pages.current()->width(), m_pages.current()->height());
viewport()->update();
emit pagesChanged();
emit pageBackupsChanged();
}
-void DrawPadCanvas::newPage(uint width, uint height, const QColor& color)
+void DrawPadCanvas::newPage(QString title, uint width, uint height, const QColor& color)
{
- m_pages.insert(m_pages.at() + 1, new Page(width, height));
+ m_pages.insert(m_pages.at() + 1, new Page(title, width, height));
m_pages.current()->fill(color);
m_pageBackups.clear();
m_pageBackups.append(new Page(*(m_pages.current())));
resizeContents(m_pages.current()->width(), m_pages.current()->height());
@@ -402,13 +428,13 @@ void DrawPadCanvas::clearPage()
void DrawPadCanvas::deletePage()
{
m_pages.remove(m_pages.current());
if (m_pages.isEmpty()) {
- m_pages.append(new Page(contentsRect().size()));
+ m_pages.append(new Page("", contentsRect().size()));
m_pages.current()->fill(Qt::white);
}
m_pageBackups.clear();
m_pageBackups.append(new Page(*(m_pages.current())));
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
@@ -49,13 +49,13 @@ public:
void selectPage(Page* page);
void backupPage();
public slots:
void deleteAll();
- void newPage(uint width, uint height, const QColor& color);
+ void newPage(QString title, uint width, uint height, const QColor& color);
void clearPage();
void deletePage();
void movePageUp();
void movePageDown();
void undo();
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
@@ -82,12 +82,17 @@ NewPageDialog::NewPageDialog(uint width, uint height, const QColor& penColor,
}
NewPageDialog::~NewPageDialog()
{
}
+QString NewPageDialog::selectedTitle()
+{
+ return (m_pTitleLineEdit->text());
+}
+
uint NewPageDialog::selectedWidth()
{
return (m_pWidthSpinBox->value());
}
uint NewPageDialog::selectedHeight()
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
@@ -26,12 +26,13 @@ class NewPageDialog : public QDialog
public:
NewPageDialog(uint width, uint height, const QColor& foregroundColor,
const QColor& backgroundColor, QWidget* parent = 0, const char* name = 0);
~NewPageDialog();
+ QString selectedTitle();
uint selectedWidth();
uint selectedHeight();
const QColor& selectedColor();
private:
QLineEdit* m_pTitleLineEdit;
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
@@ -16,21 +16,23 @@
Page::Page()
: QPixmap()
{
m_lastModified = QDateTime::currentDateTime();
}
-Page::Page(int w, int h)
+Page::Page(QString title, int w, int h)
: QPixmap(w, h)
{
+ m_title = title;
m_lastModified = QDateTime::currentDateTime();
}
-Page::Page(const QSize& size)
+Page::Page(QString title, const QSize& size)
: QPixmap(size)
{
+ m_title = title;
m_lastModified = QDateTime::currentDateTime();
}
Page::~Page()
{
}
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
@@ -19,14 +19,14 @@
#include <qdatetime.h>
class Page : public QPixmap
{
public:
Page();
- Page(int w, int h);
- Page(const QSize& size);
+ Page(QString title, int w, int h);
+ Page(QString title, const QSize& size);
~Page();
QString title() const;
QDateTime lastModified() const;
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
@@ -318,14 +318,14 @@ void ThumbnailView::newPage()
QRect rect = m_pDrawPadCanvas->contentsRect();
NewPageDialog newPageDialog(rect.width(), rect.height(), m_pDrawPad->pen().color(),
m_pDrawPad->brush().color(), this);
if (newPageDialog.exec() == QDialog::Accepted) {
- m_pDrawPadCanvas->newPage(newPageDialog.selectedWidth(), newPageDialog.selectedHeight(),
- newPageDialog.selectedColor());
+ m_pDrawPadCanvas->newPage(newPageDialog.selectedTitle(), newPageDialog.selectedWidth(),
+ newPageDialog.selectedHeight(), newPageDialog.selectedColor());
m_pPageListBox->updateView();
updateView();
}
}
void ThumbnailView::clearPage()