summaryrefslogtreecommitdiff
authorleseb <leseb>2002-06-06 20:51:27 (UTC)
committer leseb <leseb>2002-06-06 20:51:27 (UTC)
commit43bde653ce03f4c5202860f4e23c7612144a38f0 (patch) (side-by-side diff)
treeaa89f01ade2667699e2d9ba69daabb9810e48c35
parent38946b6ef966a154d979d7dd254cf463f6dadbe5 (diff)
downloadopie-43bde653ce03f4c5202860f4e23c7612144a38f0.zip
opie-43bde653ce03f4c5202860f4e23c7612144a38f0.tar.gz
opie-43bde653ce03f4c5202860f4e23c7612144a38f0.tar.bz2
New page class, thumbnail view draft
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/drawpad/drawpad.cpp15
-rw-r--r--noncore/graphics/drawpad/drawpad.h1
-rw-r--r--noncore/graphics/drawpad/drawpad.pro4
-rw-r--r--noncore/graphics/drawpad/drawpadcanvas.cpp64
-rw-r--r--noncore/graphics/drawpad/drawpadcanvas.h11
-rw-r--r--noncore/graphics/drawpad/erasetool.cpp2
-rw-r--r--noncore/graphics/drawpad/filltool.cpp2
-rw-r--r--noncore/graphics/drawpad/page.cpp33
-rw-r--r--noncore/graphics/drawpad/page.h29
-rw-r--r--noncore/graphics/drawpad/pointtool.cpp2
-rw-r--r--noncore/graphics/drawpad/shapetool.cpp2
-rw-r--r--noncore/graphics/drawpad/texttool.cpp2
-rw-r--r--noncore/graphics/drawpad/thumbnailview.cpp121
-rw-r--r--noncore/graphics/drawpad/thumbnailview.h40
14 files changed, 285 insertions, 43 deletions
diff --git a/noncore/graphics/drawpad/drawpad.cpp b/noncore/graphics/drawpad/drawpad.cpp
index 74787e5..b325323 100644
--- a/noncore/graphics/drawpad/drawpad.cpp
+++ b/noncore/graphics/drawpad/drawpad.cpp
@@ -1,128 +1,135 @@
/***************************************************************************
* *
* DrawPad - a drawing program for Opie Environment *
* *
* (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "drawpad.h"
#include "drawpadcanvas.h"
#include "ellipsetool.h"
#include "erasetool.h"
#include "exportdialog.h"
#include "filledellipsetool.h"
#include "filledrectangletool.h"
#include "filltool.h"
#include "importdialog.h"
#include "linetool.h"
#include "pointtool.h"
#include "rectangletool.h"
#include "texttool.h"
+#include "thumbnailview.h"
#include <opie/colordialog.h>
#include <opie/colorpopupmenu.h>
#include <qpe/applnk.h>
#include <qpe/global.h>
#include <qpe/qpemenubar.h>
#include <qpe/qpetoolbar.h>
#include <qpe/resource.h>
#include <qaction.h>
#include <qfile.h>
#include <qpainter.h>
#include <qspinbox.h>
#include <qtoolbutton.h>
#include <qtooltip.h>
DrawPad::DrawPad(QWidget* parent, const char* name)
: QMainWindow(parent, name)
{
// init members
m_pDrawPadCanvas = new DrawPadCanvas(this, this);
connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateNavigationToolButtons()));
connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateCaption()));
connect(m_pDrawPadCanvas, SIGNAL(pageBackupsChanged()), this, SLOT(updateUndoRedoToolButtons()));
setCentralWidget(m_pDrawPadCanvas);
// init menu
setToolBarsMovable(false);
QPEToolBar* menuToolBar = new QPEToolBar(this);
QPEMenuBar* menuBar = new QPEMenuBar(menuToolBar);
QPopupMenu *toolsPopupMenu = new QPopupMenu(menuBar);
QAction* deleteAllAction = new QAction(tr("Delete All"), QString::null, 0, this);
connect(deleteAllAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(deleteAll()));
deleteAllAction->addTo(toolsPopupMenu);
toolsPopupMenu->insertSeparator();
QAction* importPageAction = new QAction(tr("Import"), tr("Import..."), 0, this);
connect(importPageAction, SIGNAL(activated()), this, SLOT(importPage()));
importPageAction->addTo(toolsPopupMenu);
QAction* exportPageAction = new QAction(tr("Export"), tr("Export..."), 0, this);
connect(exportPageAction, SIGNAL(activated()), this, SLOT(exportPage()));
exportPageAction->addTo(toolsPopupMenu);
+ toolsPopupMenu->insertSeparator();
+
+ QAction* thumbnailViewAction = new QAction(tr("Thumbnail View"), tr("Thumbnail View..."), 0, this);
+ connect(thumbnailViewAction, SIGNAL(activated()), this, SLOT(thumbnailView()));
+ thumbnailViewAction->addTo(toolsPopupMenu);
+
menuBar->insertItem(tr("Tools"), toolsPopupMenu);
// init page toolbar
QPEToolBar* pageToolBar = new QPEToolBar(this);
QAction* newPageAction = new QAction(tr("New Page"), Resource::loadIconSet("new"), QString::null, 0, this);
connect(newPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(newPage()));
newPageAction->addTo(pageToolBar);
QAction* clearPageAction = new QAction(tr("Clear Page"), Resource::loadIconSet("drawpad/clear"), QString::null, 0, this);
connect(clearPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(clearPage()));
clearPageAction->addTo(pageToolBar);
QAction* deletePageAction = new QAction(tr("Delete Page"), Resource::loadIconSet("trash"), QString::null, 0, this);
connect(deletePageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(deletePage()));
deletePageAction->addTo(pageToolBar);
QPEToolBar* emptyToolBar = new QPEToolBar(this);
emptyToolBar->setHorizontalStretchable(true);
// init navigation toolbar
QPEToolBar* navigationToolBar = new QPEToolBar(this);
m_pUndoAction = new QAction(tr("Undo"), Resource::loadIconSet("drawpad/undo"), QString::null, 0, this);
connect(m_pUndoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(undo()));
m_pUndoAction->addTo(navigationToolBar);
m_pRedoAction = new QAction(tr("Redo"), Resource::loadIconSet("drawpad/redo"), QString::null, 0, this);
connect(m_pRedoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(redo()));
m_pRedoAction->addTo(navigationToolBar);
m_pFirstPageAction = new QAction(tr("First Page"), Resource::loadIconSet("fastback"), QString::null, 0, this);
connect(m_pFirstPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goFirstPage()));
m_pFirstPageAction->addTo(navigationToolBar);
m_pPreviousPageAction = new QAction(tr("Previous Page"), Resource::loadIconSet("back"), QString::null, 0, this);
connect(m_pPreviousPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goPreviousPage()));
m_pPreviousPageAction->addTo(navigationToolBar);
m_pNextPageAction = new QAction(tr("Next Page"), Resource::loadIconSet("forward"), QString::null, 0, this);
connect(m_pNextPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goNextPage()));
m_pNextPageAction->addTo(navigationToolBar);
m_pLastPageAction = new QAction(tr("Last Page"), Resource::loadIconSet("fastforward"), QString::null, 0, this);
connect(m_pLastPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goLastPage()));
m_pLastPageAction->addTo(navigationToolBar);
@@ -474,48 +481,56 @@ void DrawPad::updateUndoRedoToolButtons()
m_pUndoAction->setEnabled(m_pDrawPadCanvas->undoEnabled());
m_pRedoAction->setEnabled(m_pDrawPadCanvas->redoEnabled());
}
void DrawPad::updateNavigationToolButtons()
{
m_pFirstPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled());
m_pPreviousPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled());
m_pNextPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled());
m_pLastPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled());
}
void DrawPad::updateCaption()
{
uint pagePosition = m_pDrawPadCanvas->pagePosition();
uint pageCount = m_pDrawPadCanvas->pageCount();
setCaption(tr("DrawPad") + " - " + tr("Page") + " "
+ QString::number(pagePosition) + "/" + QString::number(pageCount));
}
void DrawPad::importPage()
{
ImportDialog importDialog(this);
importDialog.showMaximized();
if (importDialog.exec() == QDialog::Accepted) {
const DocLnk* docLnk = importDialog.selected();
if (docLnk) {
m_pDrawPadCanvas->importPage(docLnk->file());
delete docLnk;
}
}
}
void DrawPad::exportPage()
{
ExportDialog exportDialog(m_pDrawPadCanvas->pagePosition(), m_pDrawPadCanvas->pageCount(), this);
exportDialog.showMaximized();
if (exportDialog.exec() == QDialog::Accepted) {
m_pDrawPadCanvas->exportPage(exportDialog.selectedFromPage(), exportDialog.selectedToPage(),
exportDialog.selectedName(), exportDialog.selectedFormat());
}
}
+
+void DrawPad::thumbnailView()
+{
+ ThumbnailView thumbnailView(m_pDrawPadCanvas->pages(), this);
+
+ thumbnailView.showMaximized();
+ thumbnailView.exec();
+}
diff --git a/noncore/graphics/drawpad/drawpad.h b/noncore/graphics/drawpad/drawpad.h
index 0dcd5c9..b0b3666 100644
--- a/noncore/graphics/drawpad/drawpad.h
+++ b/noncore/graphics/drawpad/drawpad.h
@@ -14,82 +14,83 @@
#ifndef DRAWPAD_H
#define DRAWPAD_H
#include <qmainwindow.h>
#include <qpen.h>
class DrawPadCanvas;
class Tool;
class QAction;
class QColor;
class QToolButton;
class QWidgetStack;
class DrawPad : public QMainWindow
{
Q_OBJECT
public:
DrawPad(QWidget* parent = 0, const char* name = 0);
~DrawPad();
Tool* tool() { return m_pTool; }
QPen pen() { return m_pen; }
QBrush brush() { return m_brush; }
private slots:
void setPointTool();
void setLineTool();
void setRectangleTool();
void setFilledRectangleTool();
void setEllipseTool();
void setFilledEllipseTool();
void setTextTool();
void setFillTool();
void setEraseTool();
void changePenWidth(int value);
void changePenColor(const QColor& color);
void changeBrushColor(const QColor& color);
void updateUndoRedoToolButtons();
void updateNavigationToolButtons();
void updateCaption();
void importPage();
void exportPage();
+ void thumbnailView();
private:
DrawPadCanvas* m_pDrawPadCanvas;
Tool* m_pTool;
QPen m_pen;
QBrush m_brush;
QAction* m_pUndoAction;
QAction* m_pRedoAction;
QAction* m_pFirstPageAction;
QAction* m_pPreviousPageAction;
QAction* m_pNextPageAction;
QAction* m_pLastPageAction;
QAction* m_pPointToolAction;
QAction* m_pLineToolAction;
QAction* m_pRectangleToolAction;
QAction* m_pFilledRectangleToolAction;
QAction* m_pEllipseToolAction;
QAction* m_pFilledEllipseToolAction;
QAction* m_pTextToolAction;
QAction* m_pFillToolAction;
QAction* m_pEraseToolAction;
QToolButton* m_pLineToolButton;
QToolButton* m_pRectangleToolButton;
QToolButton* m_pEllipseToolButton;
QToolButton* m_pPenColorToolButton;
QToolButton* m_pBrushColorToolButton;
};
#endif // DRAWPAD_H
diff --git a/noncore/graphics/drawpad/drawpad.pro b/noncore/graphics/drawpad/drawpad.pro
index 9360256..9a640d2 100644
--- a/noncore/graphics/drawpad/drawpad.pro
+++ b/noncore/graphics/drawpad/drawpad.pro
@@ -1,54 +1,58 @@
TEMPLATE = app
CONFIG = qt warn_on release
HEADERS = drawpad.h \
drawpadcanvas.h \
ellipsetool.h \
erasetool.h \
exportdialog.h \
filltool.h \
filledellipsetool.h \
filledrectangletool.h \
importdialog.h \
linetool.h \
newpagedialog.h \
+ page.h \
pointtool.h \
rectangletool.h \
shapetool.h \
texttool.h \
+ thumbnailview.h \
tool.h
SOURCES = drawpad.cpp \
drawpadcanvas.cpp \
ellipsetool.cpp \
erasetool.cpp \
exportdialog.cpp \
filltool.cpp \
filledellipsetool.cpp \
filledrectangletool.cpp \
importdialog.cpp \
linetool.cpp \
main.cpp \
newpagedialog.cpp \
+ page.cpp \
pointtool.cpp \
rectangletool.cpp \
shapetool.cpp \
texttool.cpp \
+ thumbnailview.cpp \
tool.cpp
INCLUDEPATH += $(OPIEDIR)/include \
$(QTDIR)/src/3rdparty/zlib
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe -lopie
DESTDIR = $(OPIEDIR)/bin
TARGET = drawpad
TRANSLATIONS = ../../i18n/de/drawpad.ts
TRANSLATIONS += ../../i18n/en/drawpad.ts
TRANSLATIONS += ../../i18n/fr/drawpad.ts
TRANSLATIONS += ../../i18n/hu/drawpad.ts
TRANSLATIONS += ../../i18n/ja/drawpad.ts
TRANSLATIONS += ../../i18n/ko/drawpad.ts
TRANSLATIONS += ../../i18n/no/drawpad.ts
TRANSLATIONS += ../../i18n/pl/drawpad.ts
TRANSLATIONS += ../../i18n/pt_BR/drawpad.ts
TRANSLATIONS += ../../i18n/sl/drawpad.ts
TRANSLATIONS += ../../i18n/zh_CN/drawpad.ts
TRANSLATIONS += ../../i18n/zh_TW/drawpad.ts
diff --git a/noncore/graphics/drawpad/drawpadcanvas.cpp b/noncore/graphics/drawpad/drawpadcanvas.cpp
index 9f1e50b..79bef35 100644
--- a/noncore/graphics/drawpad/drawpadcanvas.cpp
+++ b/noncore/graphics/drawpad/drawpadcanvas.cpp
@@ -1,563 +1,563 @@
/***************************************************************************
* *
* DrawPad - a drawing program for Opie Environment *
* *
* (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "drawpadcanvas.h"
#include "drawpad.h"
#include "newpagedialog.h"
+#include "page.h"
#include "tool.h"
#include <qpe/applnk.h>
#include <qpe/filemanager.h>
#include <qpe/mimetype.h>
#include <qbuffer.h>
#include <qimage.h>
#include <qmessagebox.h>
#include <qpainter.h>
-#include <qpixmap.h>
#include <qtextcodec.h>
#include <qtextstream.h>
#include <qxml.h>
#include <zlib.h>
class DrawPadCanvasXmlHandler: public QXmlDefaultHandler
{
public:
DrawPadCanvasXmlHandler();
~DrawPadCanvasXmlHandler();
- QList<QPixmap> pixmaps();
+ QList<Page> pages();
bool startElement(const QString& namespaceURI, const QString& localName,
const QString& qName, const QXmlAttributes& atts);
bool endElement(const QString& namespaceURI, const QString& localName,
const QString& qName);
bool characters(const QString& ch);
private:
enum State {
Unknown,
InData
};
State m_state;
ulong m_dataLenght;
QString m_dataFormat;
- QList<QPixmap> m_pixmaps;
+ QList<Page> m_pages;
};
DrawPadCanvasXmlHandler::DrawPadCanvasXmlHandler()
{
m_state = Unknown;
}
DrawPadCanvasXmlHandler::~DrawPadCanvasXmlHandler()
{
}
-QList<QPixmap> DrawPadCanvasXmlHandler::pixmaps()
+QList<Page> DrawPadCanvasXmlHandler::pages()
{
- return m_pixmaps;
+ return m_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) {
m_state = InData;
m_dataLenght = atts.value("length").toULong();
m_dataFormat = atts.value("format");
if (m_dataFormat.isEmpty()) {
m_dataFormat = "XPM";
}
}
return true;
}
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) {
m_state = Unknown;
}
return true;
}
bool DrawPadCanvasXmlHandler::characters(const QString& ch)
{
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;
if (h <= '9') {
r += h - '0';
} else {
r += h - 'a' + 10;
}
r = r << 4;
if (l <= '9') {
r += l - '0';
} else {
r += l - 'a' + 10;
}
byteArray[i] = r;
}
QImage image;
if (m_dataFormat == "XPM") {
if (m_dataLenght < ch.length() * 5) {
m_dataLenght = ch.length() * 5;
}
QByteArray byteArrayUnzipped(m_dataLenght);
::uncompress((uchar*)byteArrayUnzipped.data(), &m_dataLenght, (uchar*)byteArray.data(), byteArray.size());
image.loadFromData((const uchar*)byteArrayUnzipped.data(), m_dataLenght, m_dataFormat);
} else {
image.loadFromData((const uchar*)byteArray.data(), m_dataLenght, m_dataFormat);
}
- QPixmap* pixmap = new QPixmap(image.width(), image.height());
- pixmap->convertFromImage(image);
- m_pixmaps.append(pixmap);
+ Page* page = new Page(image.width(), image.height());
+ page->convertFromImage(image);
+ m_pages.append(page);
}
return true;
}
DrawPadCanvas::DrawPadCanvas(DrawPad* drawPad, QWidget* parent, const char* name)
: QScrollView(parent, name)
{
m_pDrawPad = drawPad;
m_pages.setAutoDelete(true);
m_pageBackups.setAutoDelete(true);
viewport()->setBackgroundMode(QWidget::NoBackground);
}
DrawPadCanvas::~DrawPadCanvas()
{
}
void DrawPadCanvas::load(QIODevice* ioDevice)
{
QTextStream textStream(ioDevice);
textStream.setCodec(QTextCodec::codecForName("UTF-8"));
QXmlInputSource xmlInputSource(textStream);
QXmlSimpleReader xmlSimpleReader;
DrawPadCanvasXmlHandler drawPadCanvasXmlHandler;
xmlSimpleReader.setContentHandler(&drawPadCanvasXmlHandler);
xmlSimpleReader.parse(xmlInputSource);
- m_pages = drawPadCanvasXmlHandler.pixmaps();
+ m_pages = drawPadCanvasXmlHandler.pages();
if (m_pages.isEmpty()) {
- m_pages.append(new QPixmap(contentsRect().size()));
+ m_pages.append(new Page(contentsRect().size()));
m_pages.current()->fill(Qt::white);
}
m_pageBackups.clear();
- m_pageBackups.append(new QPixmap(*(m_pages.current())));
+ 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::initialPage()
{
- m_pages.append(new QPixmap(236, 232));
+ m_pages.append(new Page(236, 232));
m_pages.current()->fill(Qt::white);
m_pageBackups.clear();
- m_pageBackups.append(new QPixmap(*(m_pages.current())));
+ 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::save(QIODevice* ioDevice)
{
QTextStream textStream(ioDevice);
textStream.setCodec(QTextCodec::codecForName("UTF-8"));
textStream << "<drawpad>" << endl;
textStream << " <images>" << endl;
- QListIterator<QPixmap> bufferIterator(m_pages);
+ QListIterator<Page> bufferIterator(m_pages);
for (bufferIterator.toFirst(); bufferIterator.current() != 0; ++bufferIterator) {
textStream << " <image>" << endl;
QImage image = bufferIterator.current()->convertToImage();
QByteArray byteArray;
QBuffer buffer(byteArray);
QImageIO imageIO(&buffer, "PNG");
buffer.open(IO_WriteOnly);
imageIO.setImage(image);
imageIO.write();
buffer.close();
textStream << " <data length=\"" << byteArray.size() << "\" format=\"PNG\">";
static const char hexchars[] = "0123456789abcdef";
for (int i = 0; i < (int)byteArray.size(); i++ ) {
uchar s = (uchar)byteArray[i];
textStream << hexchars[s >> 4];
textStream << hexchars[s & 0x0f];
}
textStream << "</data>" << endl;
textStream << " </image>" << endl;
}
textStream << " </images>" << endl;
textStream << "</drawpad>";
}
void DrawPadCanvas::importPage(const QString& fileName)
{
- QPixmap* importedPixmap = new QPixmap();
+ Page* importedPage = new Page();
- importedPixmap->load(fileName);
- m_pages.insert(m_pages.at() + 1, importedPixmap);
+ importedPage->load(fileName);
+ m_pages.insert(m_pages.at() + 1, importedPage);
m_pageBackups.clear();
- m_pageBackups.append(new QPixmap(*(m_pages.current())));
+ 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::exportPage(uint fromPage, uint toPage, const QString& name,const QString& format)
{
if (fromPage == toPage) {
DocLnk docLnk;
MimeType mimeType(format);
docLnk.setName(name);
docLnk.setType(mimeType.id());
FileManager fileManager;
QIODevice* ioDevice = fileManager.saveFile(docLnk);
QImageIO imageIO(ioDevice, format);
QImage image = m_pages.current()->convertToImage();
imageIO.setImage(image);
imageIO.write();
delete ioDevice;
} else {
for (uint i = fromPage; i <= toPage; i++) {
DocLnk docLnk;
MimeType mimeType(format);
docLnk.setName(name + QString::number(i));
docLnk.setType(mimeType.id());
FileManager fileManager;
QIODevice* ioDevice = fileManager.saveFile(docLnk);
QImageIO imageIO(ioDevice, format);
QImage image = m_pages.at(i - 1)->convertToImage();
imageIO.setImage(image);
imageIO.write();
delete ioDevice;
}
}
}
-QPixmap* DrawPadCanvas::currentPage()
+Page* DrawPadCanvas::currentPage()
{
return m_pages.current();
}
-QList<QPixmap> DrawPadCanvas::pages()
+QList<Page> DrawPadCanvas::pages()
{
return m_pages;
}
uint DrawPadCanvas::pagePosition()
{
return (m_pages.at() + 1);
}
uint DrawPadCanvas::pageCount()
{
return m_pages.count();
}
void DrawPadCanvas::backupPage()
{
QPixmap* currentBackup = m_pageBackups.current();
while (m_pageBackups.last() != currentBackup) {
m_pageBackups.removeLast();
}
while (m_pageBackups.count() >= (5 + 1)) {
m_pageBackups.removeFirst();
}
- m_pageBackups.append(new QPixmap(*(m_pages.current())));
+ m_pageBackups.append(new Page(*(m_pages.current())));
emit pageBackupsChanged();
}
void DrawPadCanvas::deleteAll()
{
QMessageBox messageBox(tr("Delete All"), tr("Do you want to delete\nall the pages?"),
QMessageBox::Information, QMessageBox::Yes,
QMessageBox::No | QMessageBox::Escape | QMessageBox::Default,
QMessageBox::NoButton, this);
messageBox.setButtonText(QMessageBox::Yes, tr("Yes"));
messageBox.setButtonText(QMessageBox::No, tr("No"));
if (messageBox.exec() == QMessageBox::Yes) {
m_pages.clear();
- m_pages.append(new QPixmap(contentsRect().size()));
+ m_pages.append(new Page(contentsRect().size()));
m_pages.current()->fill(Qt::white);
m_pageBackups.clear();
- m_pageBackups.append(new QPixmap(*(m_pages.current())));
+ 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()
{
QRect rect = contentsRect();
NewPageDialog newPageDialog(rect.width(), rect.height(), m_pDrawPad->pen().color(),
m_pDrawPad->brush().color(), this);
if (newPageDialog.exec() == QDialog::Accepted) {
- m_pages.insert(m_pages.at() + 1, new QPixmap(newPageDialog.selectedWidth(),
- newPageDialog.selectedHeight()));
+ m_pages.insert(m_pages.at() + 1, new Page(newPageDialog.selectedWidth(),
+ newPageDialog.selectedHeight()));
m_pages.current()->fill(newPageDialog.selectedColor());
m_pageBackups.clear();
- m_pageBackups.append(new QPixmap(*(m_pages.current())));
+ 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::clearPage()
{
QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe current page?"),
QMessageBox::Information, QMessageBox::Yes,
QMessageBox::No | QMessageBox::Escape | QMessageBox::Default,
QMessageBox::NoButton, this);
messageBox.setButtonText(QMessageBox::Yes, tr("Yes"));
messageBox.setButtonText(QMessageBox::No, tr("No"));
if (messageBox.exec() == QMessageBox::Yes) {
m_pages.current()->fill(Qt::white);
viewport()->update();
}
}
void DrawPadCanvas::deletePage()
{
QMessageBox messageBox(tr("Delete Page"), tr("Do you want to delete\nthe current page?"),
QMessageBox::Information, QMessageBox::Yes,
QMessageBox::No | QMessageBox::Escape | QMessageBox::Default,
QMessageBox::NoButton, this);
messageBox.setButtonText(QMessageBox::Yes, tr("Yes"));
messageBox.setButtonText(QMessageBox::No, tr("No"));
if (messageBox.exec() == QMessageBox::Yes) {
m_pages.remove(m_pages.current());
if (m_pages.isEmpty()) {
- m_pages.append(new QPixmap(contentsRect().size()));
+ m_pages.append(new Page(contentsRect().size()));
m_pages.current()->fill(Qt::white);
}
m_pageBackups.clear();
- m_pageBackups.append(new QPixmap(*(m_pages.current())));
+ m_pageBackups.append(new Page(*(m_pages.current())));
resizeContents(m_pages.current()->width(), m_pages.current()->height());
viewport()->update();
emit pagesChanged();
emit pageBackupsChanged();
}
}
bool DrawPadCanvas::undoEnabled()
{
return (m_pageBackups.current() != m_pageBackups.getFirst());
}
bool DrawPadCanvas::redoEnabled()
{
return (m_pageBackups.current() != m_pageBackups.getLast());
}
bool DrawPadCanvas::goPreviousPageEnabled()
{
return (m_pages.current() != m_pages.getFirst());
}
bool DrawPadCanvas::goNextPageEnabled()
{
return (m_pages.current() != m_pages.getLast());
}
void DrawPadCanvas::undo()
{
*(m_pages.current()) = *(m_pageBackups.prev());
viewport()->update();
emit pageBackupsChanged();
}
void DrawPadCanvas::redo()
{
*(m_pages.current()) = *(m_pageBackups.next());
viewport()->update();
emit pageBackupsChanged();
}
void DrawPadCanvas::goFirstPage()
{
m_pages.first();
m_pageBackups.clear();
- m_pageBackups.append(new QPixmap(*(m_pages.current())));
+ 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::goPreviousPage()
{
m_pages.prev();
m_pageBackups.clear();
- m_pageBackups.append(new QPixmap(*(m_pages.current())));
+ 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::goNextPage()
{
m_pages.next();
m_pageBackups.clear();
- m_pageBackups.append(new QPixmap(*(m_pages.current())));
+ 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::goLastPage()
{
m_pages.last();
m_pageBackups.clear();
- m_pageBackups.append(new QPixmap(*(m_pages.current())));
+ 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::contentsMousePressEvent(QMouseEvent* e)
{
m_pDrawPad->tool()->mousePressEvent(e);
}
void DrawPadCanvas::contentsMouseReleaseEvent(QMouseEvent* e)
{
m_pDrawPad->tool()->mouseReleaseEvent(e);
}
void DrawPadCanvas::contentsMouseMoveEvent(QMouseEvent* e)
{
m_pDrawPad->tool()->mouseMoveEvent(e);
}
void DrawPadCanvas::drawContents(QPainter* p, int cx, int cy, int cw, int ch)
{
QRect clipRect(cx, cy, cw, ch);
QRect pixmapRect(0, 0, m_pages.current()->width(), m_pages.current()->height());
QRect drawRect = pixmapRect.intersect(clipRect);
p->drawPixmap(drawRect.topLeft(), *(m_pages.current()), drawRect);
if (drawRect.right() < clipRect.right()) {
p->fillRect(drawRect.right() + 1, cy, cw - drawRect.width(), ch, colorGroup().dark());
}
if (drawRect.bottom() < clipRect.bottom()) {
p->fillRect(cx, drawRect.bottom() + 1, cw, ch - drawRect.height(), colorGroup().dark());
}
}
diff --git a/noncore/graphics/drawpad/drawpadcanvas.h b/noncore/graphics/drawpad/drawpadcanvas.h
index e05ce8a..47763f9 100644
--- a/noncore/graphics/drawpad/drawpadcanvas.h
+++ b/noncore/graphics/drawpad/drawpadcanvas.h
@@ -1,83 +1,82 @@
/***************************************************************************
* *
* DrawPad - a drawing program for Opie Environment *
* *
* (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef DRAWPADCANVAS_H
#define DRAWPADCANVAS_H
#include <qscrollview.h>
#include <qlist.h>
#include <qpointarray.h>
class DrawPad;
-
-class QPixmap;
+class Page;
class DrawPadCanvas : public QScrollView
{
Q_OBJECT
public:
DrawPadCanvas(DrawPad* drawPad, QWidget* parent = 0, const char* name = 0);
~DrawPadCanvas();
void load(QIODevice* ioDevice);
void initialPage();
void save(QIODevice* ioDevice);
void importPage(const QString& fileName);
void exportPage(uint fromPage, uint toPage, const QString& name, const QString& format);
bool undoEnabled();
bool redoEnabled();
bool goPreviousPageEnabled();
bool goNextPageEnabled();
- QPixmap* currentPage();
- QList<QPixmap> pages();
+ Page* currentPage();
+ QList<Page> pages();
uint pagePosition();
uint pageCount();
void backupPage();
public slots:
void deleteAll();
void newPage();
void clearPage();
void deletePage();
void undo();
void redo();
void goFirstPage();
void goPreviousPage();
void goNextPage();
void goLastPage();
signals:
void pagesChanged();
void pageBackupsChanged();
protected:
void contentsMousePressEvent(QMouseEvent* e);
void contentsMouseReleaseEvent(QMouseEvent* e);
void contentsMouseMoveEvent(QMouseEvent* e);
void drawContents(QPainter* p, int cx, int cy, int cw, int ch);
private:
DrawPad* m_pDrawPad;
- QList<QPixmap> m_pages;
- QList<QPixmap> m_pageBackups;
+ QList<Page> m_pages;
+ QList<Page> m_pageBackups;
};
#endif // DRAWPADCANVAS_H
diff --git a/noncore/graphics/drawpad/erasetool.cpp b/noncore/graphics/drawpad/erasetool.cpp
index 828994b..f77e038 100644
--- a/noncore/graphics/drawpad/erasetool.cpp
+++ b/noncore/graphics/drawpad/erasetool.cpp
@@ -1,68 +1,68 @@
/***************************************************************************
* *
* DrawPad - a drawing program for Opie Environment *
* *
* (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "erasetool.h"
#include "drawpad.h"
#include "drawpadcanvas.h"
+#include "page.h"
#include <qpainter.h>
-#include <qpixmap.h>
EraseTool::EraseTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas)
: Tool(drawPad, drawPadCanvas)
{
m_mousePressed = false;
m_polyline.resize(3);
}
EraseTool::~EraseTool()
{
}
void EraseTool::mousePressEvent(QMouseEvent* e)
{
m_mousePressed = true;
m_polyline[2] = m_polyline[1] = m_polyline[0] = e->pos();
}
void EraseTool::mouseReleaseEvent(QMouseEvent* e)
{
Q_UNUSED(e)
m_mousePressed = false;
m_pDrawPadCanvas->backupPage();
}
void EraseTool::mouseMoveEvent(QMouseEvent* e)
{
if (m_mousePressed) {
QPainter painter;
QPen pen(Qt::white, m_pDrawPad->pen().width());
painter.begin(m_pDrawPadCanvas->currentPage());
painter.setPen(pen);
m_polyline[2] = m_polyline[1];
m_polyline[1] = m_polyline[0];
m_polyline[0] = e->pos();
painter.drawPolyline(m_polyline);
painter.end();
QRect r = m_polyline.boundingRect();
r = r.normalize();
r.setLeft(r.left() - m_pDrawPad->pen().width());
r.setTop(r.top() - m_pDrawPad->pen().width());
r.setRight(r.right() + m_pDrawPad->pen().width());
r.setBottom(r.bottom() + m_pDrawPad->pen().width());
QRect viewportRect(m_pDrawPadCanvas->contentsToViewport(r.topLeft()),
diff --git a/noncore/graphics/drawpad/filltool.cpp b/noncore/graphics/drawpad/filltool.cpp
index 004da02..d323cc2 100644
--- a/noncore/graphics/drawpad/filltool.cpp
+++ b/noncore/graphics/drawpad/filltool.cpp
@@ -1,68 +1,68 @@
/***************************************************************************
* *
* DrawPad - a drawing program for Opie Environment *
* *
* (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "filltool.h"
#include "drawpad.h"
#include "drawpadcanvas.h"
+#include "page.h"
#include <qimage.h>
-#include <qpixmap.h>
FillTool::FillTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas)
: Tool(drawPad, drawPadCanvas)
{
}
FillTool::~FillTool()
{
}
void FillTool::mousePressEvent(QMouseEvent* e)
{
int x = e->x();
int y = e->y();
m_image = m_pDrawPadCanvas->currentPage()->convertToImage();
m_fillRgb = m_pDrawPad->brush().color().rgb();
m_oldRgb = m_image.pixel(x, y);
if (m_oldRgb != m_fillRgb) {
fillLine(x, y);
m_pDrawPadCanvas->currentPage()->convertFromImage(m_image);
m_pDrawPadCanvas->viewport()->update();
m_pDrawPadCanvas->backupPage();
}
}
void FillTool::mouseReleaseEvent(QMouseEvent* e)
{
Q_UNUSED(e)
}
void FillTool::mouseMoveEvent(QMouseEvent* e)
{
Q_UNUSED(e)
}
void FillTool::fillLine(int x, int y)
{
if ((x >= 0) && (x < m_image.width()) && (y >= 0) && (y < m_image.height())) {
if (m_image.pixel(x, y) == m_oldRgb) {
int x1, x2;
x1 = x - 1;
x2 = x + 1;
diff --git a/noncore/graphics/drawpad/page.cpp b/noncore/graphics/drawpad/page.cpp
new file mode 100644
index 0000000..35ec0e0
--- a/dev/null
+++ b/noncore/graphics/drawpad/page.cpp
@@ -0,0 +1,33 @@
+/***************************************************************************
+ * *
+ * DrawPad - a drawing program for Opie Environment *
+ * *
+ * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "page.h"
+
+Page::Page()
+ : QPixmap()
+{
+}
+
+Page::Page(int w, int h)
+ : QPixmap(w, h)
+{
+}
+
+Page::Page(const QSize& size)
+ : QPixmap(size)
+{
+}
+
+Page::~Page()
+{
+}
diff --git a/noncore/graphics/drawpad/page.h b/noncore/graphics/drawpad/page.h
new file mode 100644
index 0000000..888f552
--- a/dev/null
+++ b/noncore/graphics/drawpad/page.h
@@ -0,0 +1,29 @@
+/***************************************************************************
+ * *
+ * DrawPad - a drawing program for Opie Environment *
+ * *
+ * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef PAGE_H
+#define PAGE_H
+
+#include <qpixmap.h>
+
+class Page : public QPixmap
+{
+public:
+ Page();
+ Page(int w, int h);
+ Page(const QSize& size);
+
+ ~Page();
+};
+
+#endif // PAGE_H
diff --git a/noncore/graphics/drawpad/pointtool.cpp b/noncore/graphics/drawpad/pointtool.cpp
index e281284..656044b 100644
--- a/noncore/graphics/drawpad/pointtool.cpp
+++ b/noncore/graphics/drawpad/pointtool.cpp
@@ -1,68 +1,68 @@
/***************************************************************************
* *
* DrawPad - a drawing program for Opie Environment *
* *
* (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "pointtool.h"
#include "drawpad.h"
#include "drawpadcanvas.h"
+#include "page.h"
#include <qpainter.h>
-#include <qpixmap.h>
PointTool::PointTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas)
: Tool(drawPad, drawPadCanvas)
{
m_mousePressed = false;
m_polyline.resize(3);
}
PointTool::~PointTool()
{
}
void PointTool::mousePressEvent(QMouseEvent* e)
{
m_mousePressed = true;
m_polyline[2] = m_polyline[1] = m_polyline[0] = e->pos();
}
void PointTool::mouseReleaseEvent(QMouseEvent* e)
{
Q_UNUSED(e)
m_mousePressed = false;
m_pDrawPadCanvas->backupPage();
}
void PointTool::mouseMoveEvent(QMouseEvent* e)
{
if (m_mousePressed) {
QPainter painter;
painter.begin(m_pDrawPadCanvas->currentPage());
painter.setPen(m_pDrawPad->pen());
m_polyline[2] = m_polyline[1];
m_polyline[1] = m_polyline[0];
m_polyline[0] = e->pos();
painter.drawPolyline(m_polyline);
painter.end();
QRect r = m_polyline.boundingRect();
r = r.normalize();
r.setLeft(r.left() - m_pDrawPad->pen().width());
r.setTop(r.top() - m_pDrawPad->pen().width());
r.setRight(r.right() + m_pDrawPad->pen().width());
r.setBottom(r.bottom() + m_pDrawPad->pen().width());
QRect viewportRect(m_pDrawPadCanvas->contentsToViewport(r.topLeft()),
m_pDrawPadCanvas->contentsToViewport(r.bottomRight()));
diff --git a/noncore/graphics/drawpad/shapetool.cpp b/noncore/graphics/drawpad/shapetool.cpp
index bc5d9c0..8870a78 100644
--- a/noncore/graphics/drawpad/shapetool.cpp
+++ b/noncore/graphics/drawpad/shapetool.cpp
@@ -1,68 +1,68 @@
/***************************************************************************
* *
* DrawPad - a drawing program for Opie Environment *
* *
* (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "shapetool.h"
#include "drawpad.h"
#include "drawpadcanvas.h"
+#include "page.h"
#include <qpainter.h>
-#include <qpixmap.h>
ShapeTool::ShapeTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas)
: Tool(drawPad, drawPadCanvas)
{
m_mousePressed = false;
m_polyline.resize(3);
}
ShapeTool::~ShapeTool()
{
}
void ShapeTool::mousePressEvent(QMouseEvent* e)
{
m_mousePressed = true;
m_polyline[2] = m_polyline[1] = m_polyline[0] = e->pos();
}
void ShapeTool::mouseReleaseEvent(QMouseEvent* e)
{
Q_UNUSED(e)
QPainter painter;
painter.begin(m_pDrawPadCanvas->currentPage());
drawFinalShape(painter);
painter.end();
QRect r = m_polyline.boundingRect();
r = r.normalize();
r.setLeft(r.left() - m_pDrawPad->pen().width());
r.setTop(r.top() - m_pDrawPad->pen().width());
r.setRight(r.right() + m_pDrawPad->pen().width());
r.setBottom(r.bottom() + m_pDrawPad->pen().width());
QRect viewportRect(m_pDrawPadCanvas->contentsToViewport(r.topLeft()),
m_pDrawPadCanvas->contentsToViewport(r.bottomRight()));
bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(),
m_pDrawPadCanvas->currentPage(), r.x(), r.y(), r.width(), r.height());
m_pDrawPadCanvas->viewport()->update(viewportRect);
m_mousePressed = false;
m_pDrawPadCanvas->backupPage();
}
void ShapeTool::mouseMoveEvent(QMouseEvent* e)
diff --git a/noncore/graphics/drawpad/texttool.cpp b/noncore/graphics/drawpad/texttool.cpp
index 37b4801..34c8a76 100644
--- a/noncore/graphics/drawpad/texttool.cpp
+++ b/noncore/graphics/drawpad/texttool.cpp
@@ -1,70 +1,70 @@
/***************************************************************************
* *
* DrawPad - a drawing program for Opie Environment *
* *
* (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "texttool.h"
#include "drawpad.h"
#include "drawpadcanvas.h"
+#include "page.h"
#include <qlayout.h>
#include <qlineedit.h>
#include <qpainter.h>
-#include <qpixmap.h>
TextToolDialog::TextToolDialog(QWidget* parent, const char* name)
: QDialog(parent, name, true)
{
setCaption(tr("Insert Text"));
m_pLineEdit = new QLineEdit(this);
QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4);
mainLayout->addWidget(m_pLineEdit);
}
TextToolDialog::~TextToolDialog()
{
}
QString TextToolDialog::text()
{
return m_pLineEdit->text();
}
TextTool::TextTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas)
: Tool(drawPad, drawPadCanvas)
{
}
TextTool::~TextTool()
{
}
void TextTool::mousePressEvent(QMouseEvent* e)
{
TextToolDialog textToolDialog(m_pDrawPad);
if (textToolDialog.exec() == QDialog::Accepted && !textToolDialog.text().isEmpty()) {
QPainter painter;
painter.begin(m_pDrawPadCanvas->currentPage());
painter.setPen(m_pDrawPad->pen());
painter.drawText(e->x(), e->y(), textToolDialog.text());
painter.end();
m_pDrawPadCanvas->viewport()->update();
m_pDrawPadCanvas->backupPage();
}
}
diff --git a/noncore/graphics/drawpad/thumbnailview.cpp b/noncore/graphics/drawpad/thumbnailview.cpp
new file mode 100644
index 0000000..10ade90
--- a/dev/null
+++ b/noncore/graphics/drawpad/thumbnailview.cpp
@@ -0,0 +1,121 @@
+/***************************************************************************
+ * *
+ * DrawPad - a drawing program for Opie Environment *
+ * *
+ * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "thumbnailview.h"
+
+#include "page.h"
+
+#include <qpe/resource.h>
+
+#include <qheader.h>
+#include <qimage.h>
+#include <qlayout.h>
+#include <qlistview.h>
+#include <qtoolbutton.h>
+
+ThumbnailView::ThumbnailView(QList<Page> pages, QWidget* parent, const char* name)
+ : QDialog(parent, name, true)
+{
+ setCaption(tr("Thumbnail"));
+
+ QToolButton* newPageButton = new QToolButton(this);
+ newPageButton->setIconSet(Resource::loadIconSet("new"));
+ newPageButton->setAutoRaise(true);
+
+ QToolButton* clearPageButton = new QToolButton(this);
+ clearPageButton->setIconSet(Resource::loadIconSet("drawpad/clear"));
+ clearPageButton->setAutoRaise(true);
+
+ QToolButton* deletePageButton = new QToolButton(this);
+ deletePageButton->setIconSet(Resource::loadIconSet("trash"));
+ deletePageButton->setAutoRaise(true);
+
+ QToolButton* movePageUpButton = new QToolButton(this);
+ movePageUpButton->setIconSet(Resource::loadIconSet("up"));
+ movePageUpButton->setAutoRaise(true);
+
+ QToolButton* movePageDownButton = new QToolButton(this);
+ movePageDownButton->setIconSet(Resource::loadIconSet("down"));
+ movePageDownButton->setAutoRaise(true);
+
+ m_pListView = new QListView(this);
+
+ m_pListView->header()->hide();
+ m_pListView->setAllColumnsShowFocus(true);
+
+ m_pListView->addColumn(tr("Thumbnail"));
+ m_pListView->addColumn(tr("Information"));
+
+ m_pListView->setColumnAlignment(0, Qt::AlignHCenter | Qt::AlignVCenter);
+ m_pListView->setColumnAlignment(1, Qt::AlignTop);
+
+ QListIterator<Page> iterator(pages);
+
+ for (; iterator.current(); ++iterator) {
+ QImage image = iterator.current()->convertToImage();
+
+ int previewWidth = 64;
+ int previewHeight = 64;
+
+ float widthScale = 1.0;
+ float heightScale = 1.0;
+
+ if (previewWidth < image.width()) {
+ widthScale = (float)previewWidth / float(image.width());
+ }
+
+ if (previewHeight < image.height()) {
+ heightScale = (float)previewHeight / float(image.height());
+ }
+
+ float scale = (widthScale < heightScale ? widthScale : heightScale);
+ QImage previewImage = image.smoothScale((int)(image.width() * scale) , (int)(image.height() * scale));
+
+ QPixmap previewPixmap;
+ previewPixmap.convertFromImage(previewImage);
+
+ QPixmap pixmap(64, 64);
+
+ pixmap.fill(colorGroup().mid());
+ bitBlt(&pixmap, (pixmap.width() - previewPixmap.width()) / 2,
+ (pixmap.height() - previewPixmap.height()) / 2, &previewPixmap);
+
+ QListViewItem* item = new QListViewItem(m_pListView);
+ item->setPixmap(0, pixmap);
+ }
+
+ QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4);
+ QHBoxLayout* buttonLayout = new QHBoxLayout(0);
+
+ buttonLayout->addWidget(newPageButton);
+ buttonLayout->addWidget(clearPageButton);
+ buttonLayout->addWidget(deletePageButton);
+ buttonLayout->addStretch();
+ buttonLayout->addWidget(movePageUpButton);
+ buttonLayout->addWidget(movePageDownButton);
+
+ mainLayout->addLayout(buttonLayout);
+ mainLayout->addWidget(m_pListView);
+}
+
+ThumbnailView::~ThumbnailView()
+{
+}
+
+void ThumbnailView::resizeEvent(QResizeEvent* e)
+{
+ QDialog::resizeEvent(e);
+
+ m_pListView->setColumnWidth(1, m_pListView->contentsRect().width() - m_pListView->columnWidth(0)
+ - m_pListView->verticalScrollBar()->width());
+}
diff --git a/noncore/graphics/drawpad/thumbnailview.h b/noncore/graphics/drawpad/thumbnailview.h
new file mode 100644
index 0000000..c74730d
--- a/dev/null
+++ b/noncore/graphics/drawpad/thumbnailview.h
@@ -0,0 +1,40 @@
+/***************************************************************************
+ * *
+ * DrawPad - a drawing program for Opie Environment *
+ * *
+ * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef THUMBNAILVIEW_H
+#define THUMBNAILVIEW_H
+
+#include <qdialog.h>
+
+#include <qlist.h>
+
+class QListView;
+
+class Page;
+
+class ThumbnailView : public QDialog
+{
+ Q_OBJECT
+
+public:
+ ThumbnailView(QList<Page> pages, QWidget* parent = 0, const char* name = 0);
+ ~ThumbnailView();
+
+protected:
+ void resizeEvent(QResizeEvent* e);
+
+private:
+ QListView* m_pListView;
+};
+
+#endif // THUMBNAILVIEW_H