summaryrefslogtreecommitdiff
authorleseb <leseb>2002-06-07 20:30:30 (UTC)
committer leseb <leseb>2002-06-07 20:30:30 (UTC)
commit9dcd598f9b815511cae884d26b18e3c8913b9fcf (patch) (side-by-side diff)
tree4b18e7fa7c864b2dca4da76bc89c2a975e80a73c
parent640d964cfdc7467f6cacb513087cd3acda2c04f0 (diff)
downloadopie-9dcd598f9b815511cae884d26b18e3c8913b9fcf.zip
opie-9dcd598f9b815511cae884d26b18e3c8913b9fcf.tar.gz
opie-9dcd598f9b815511cae884d26b18e3c8913b9fcf.tar.bz2
Make progress in thumbnail view
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/graphics/drawpad/drawpad.cpp54
-rw-r--r--noncore/graphics/drawpad/drawpad.h4
-rw-r--r--noncore/graphics/drawpad/drawpadcanvas.cpp31
-rw-r--r--noncore/graphics/drawpad/thumbnailview.cpp184
-rw-r--r--noncore/graphics/drawpad/thumbnailview.h51
5 files changed, 233 insertions, 91 deletions
diff --git a/noncore/graphics/drawpad/drawpad.cpp b/noncore/graphics/drawpad/drawpad.cpp
index b325323..58c0d09 100644
--- a/noncore/graphics/drawpad/drawpad.cpp
+++ b/noncore/graphics/drawpad/drawpad.cpp
@@ -38,6 +38,7 @@
#include <qaction.h>
#include <qfile.h>
+#include <qmessagebox.h>
#include <qpainter.h>
#include <qspinbox.h>
#include <qtoolbutton.h>
@@ -66,7 +67,7 @@ DrawPad::DrawPad(QWidget* parent, const char* name)
QPopupMenu *toolsPopupMenu = new QPopupMenu(menuBar);
QAction* deleteAllAction = new QAction(tr("Delete All"), QString::null, 0, this);
- connect(deleteAllAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(deleteAll()));
+ connect(deleteAllAction, SIGNAL(activated()), this, SLOT(deleteAll()));
deleteAllAction->addTo(toolsPopupMenu);
toolsPopupMenu->insertSeparator();
@@ -96,11 +97,11 @@ DrawPad::DrawPad(QWidget* parent, const char* name)
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()));
+ connect(clearPageAction, SIGNAL(activated()), this, 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()));
+ connect(deletePageAction, SIGNAL(activated()), this, SLOT(deletePage()));
deletePageAction->addTo(pageToolBar);
QPEToolBar* emptyToolBar = new QPEToolBar(this);
@@ -267,6 +268,36 @@ DrawPad::~DrawPad()
}
}
+void DrawPad::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_pDrawPadCanvas->clearPage();
+ }
+}
+
+void DrawPad::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_pDrawPadCanvas->deletePage();
+ }
+}
+
void DrawPad::setPointTool()
{
if (m_pTool) {
@@ -499,6 +530,21 @@ void DrawPad::updateCaption()
+ QString::number(pagePosition) + "/" + QString::number(pageCount));
}
+void DrawPad::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_pDrawPadCanvas->deleteAll();
+ }
+}
+
void DrawPad::importPage()
{
ImportDialog importDialog(this);
@@ -529,7 +575,7 @@ void DrawPad::exportPage()
void DrawPad::thumbnailView()
{
- ThumbnailView thumbnailView(m_pDrawPadCanvas->pages(), this);
+ ThumbnailView thumbnailView(m_pDrawPadCanvas, this);
thumbnailView.showMaximized();
thumbnailView.exec();
diff --git a/noncore/graphics/drawpad/drawpad.h b/noncore/graphics/drawpad/drawpad.h
index b0b3666..01061b4 100644
--- a/noncore/graphics/drawpad/drawpad.h
+++ b/noncore/graphics/drawpad/drawpad.h
@@ -39,6 +39,9 @@ public:
QBrush brush() { return m_brush; }
private slots:
+ void clearPage();
+ void deletePage();
+
void setPointTool();
void setLineTool();
void setRectangleTool();
@@ -57,6 +60,7 @@ private slots:
void updateNavigationToolButtons();
void updateCaption();
+ void deleteAll();
void importPage();
void exportPage();
void thumbnailView();
diff --git a/noncore/graphics/drawpad/drawpadcanvas.cpp b/noncore/graphics/drawpad/drawpadcanvas.cpp
index 79bef35..252f4d5 100644
--- a/noncore/graphics/drawpad/drawpadcanvas.cpp
+++ b/noncore/graphics/drawpad/drawpadcanvas.cpp
@@ -24,7 +24,6 @@
#include <qbuffer.h>
#include <qimage.h>
-#include <qmessagebox.h>
#include <qpainter.h>
#include <qtextcodec.h>
#include <qtextstream.h>
@@ -346,15 +345,6 @@ void DrawPadCanvas::backupPage()
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 Page(contentsRect().size()));
@@ -369,7 +359,6 @@ void DrawPadCanvas::deleteAll()
emit pagesChanged();
emit pageBackupsChanged();
}
-}
void DrawPadCanvas::newPage()
{
@@ -396,32 +385,13 @@ void DrawPadCanvas::newPage()
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()) {
@@ -438,7 +408,6 @@ void DrawPadCanvas::deletePage()
emit pagesChanged();
emit pageBackupsChanged();
}
-}
bool DrawPadCanvas::undoEnabled()
{
diff --git a/noncore/graphics/drawpad/thumbnailview.cpp b/noncore/graphics/drawpad/thumbnailview.cpp
index 10ade90..1754ce9 100644
--- a/noncore/graphics/drawpad/thumbnailview.cpp
+++ b/noncore/graphics/drawpad/thumbnailview.cpp
@@ -13,56 +13,24 @@
#include "thumbnailview.h"
+#include "drawpadcanvas.h"
#include "page.h"
#include <qpe/resource.h>
+#include <qapplication.h>
#include <qheader.h>
#include <qimage.h>
#include <qlayout.h>
-#include <qlistview.h>
+#include <qmessagebox.h>
#include <qtoolbutton.h>
-ThumbnailView::ThumbnailView(QList<Page> pages, QWidget* parent, const char* name)
- : QDialog(parent, name, true)
+PageListViewItem::PageListViewItem(Page* page, QListView* parent)
+ : QListViewItem(parent)
{
- 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);
+ m_pPage = page;
- QListIterator<Page> iterator(pages);
-
- for (; iterator.current(); ++iterator) {
- QImage image = iterator.current()->convertToImage();
+ QImage image = m_pPage->convertToImage();
int previewWidth = 64;
int previewHeight = 64;
@@ -86,14 +54,108 @@ ThumbnailView::ThumbnailView(QList<Page> pages, QWidget* parent, const char* nam
QPixmap pixmap(64, 64);
- pixmap.fill(colorGroup().mid());
+ pixmap.fill(listView()->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);
+ setPixmap(0, pixmap);
+}
+
+PageListViewItem::~PageListViewItem()
+{
+}
+
+Page* PageListViewItem::page() const
+{
+ return m_pPage;
+}
+
+PageListView::PageListView(DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name)
+ : QListView(parent, name)
+{
+ m_pDrawPadCanvas = drawPadCanvas;
+
+ header()->hide();
+ setVScrollBarMode(QScrollView::AlwaysOn);
+ setAllColumnsShowFocus(true);
+
+ addColumn(tr("Thumbnail"));
+ addColumn(tr("Information"));
+
+ updateView();
+}
+
+PageListView::~PageListView()
+{
+}
+
+void PageListView::updateView()
+{
+ clear();
+
+ if (m_pDrawPadCanvas) {
+ QList<Page> pageList = m_pDrawPadCanvas->pages();
+ QListIterator<Page> it(pageList);
+
+ for (; it.current(); ++it) {
+ new PageListViewItem(it.current(), this);
+ }
+ }
}
+void PageListView::resizeEvent(QResizeEvent* e)
+{
+ Q_UNUSED(e);
+
+ setColumnWidth(1, contentsRect().width() - columnWidth(0) - verticalScrollBar()->width());
+}
+
+Page* PageListView::selected() const
+{
+ Page* page;
+
+ PageListViewItem* item = (PageListViewItem*)selectedItem();
+
+ if (item) {
+ page = item->page();
+ } else {
+ page = NULL;
+ }
+
+ return page;
+}
+
+
+ThumbnailView::ThumbnailView(DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name)
+ : QWidget(parent, name, Qt::WType_Modal | Qt::WType_TopLevel)
+{
+ inLoop = false;
+ m_pDrawPadCanvas = drawPadCanvas;
+
+ 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_pPageListView = new PageListView(m_pDrawPadCanvas, this);
+
QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4);
QHBoxLayout* buttonLayout = new QHBoxLayout(0);
@@ -105,17 +167,45 @@ ThumbnailView::ThumbnailView(QList<Page> pages, QWidget* parent, const char* nam
buttonLayout->addWidget(movePageDownButton);
mainLayout->addLayout(buttonLayout);
- mainLayout->addWidget(m_pListView);
+ mainLayout->addWidget(m_pPageListView);
}
ThumbnailView::~ThumbnailView()
{
+ hide();
}
-void ThumbnailView::resizeEvent(QResizeEvent* e)
+void ThumbnailView::hide()
{
- QDialog::resizeEvent(e);
+ QWidget::hide();
- m_pListView->setColumnWidth(1, m_pListView->contentsRect().width() - m_pListView->columnWidth(0)
- - m_pListView->verticalScrollBar()->width());
+ if (inLoop) {
+ inLoop = false;
+ qApp->exit_loop();
+ }
+}
+
+void ThumbnailView::exec()
+{
+ show();
+
+ if (!inLoop) {
+ inLoop = true;
+ qApp->enter_loop();
+ }
+}
+
+void ThumbnailView::deletePage()
+{
+ QMessageBox messageBox(tr("Delete Page"), tr("Do you want to delete\nthe selected 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_pDrawPadCanvas->deletePage();
+ }
}
diff --git a/noncore/graphics/drawpad/thumbnailview.h b/noncore/graphics/drawpad/thumbnailview.h
index c74730d..ae97ff1 100644
--- a/noncore/graphics/drawpad/thumbnailview.h
+++ b/noncore/graphics/drawpad/thumbnailview.h
@@ -14,27 +14,60 @@
#ifndef THUMBNAILVIEW_H
#define THUMBNAILVIEW_H
-#include <qdialog.h>
+#include <qwidget.h>
+#include <qlistview.h>
-#include <qlist.h>
+class DrawPadCanvas;
+class Page;
+
+class PageListViewItem : public QListViewItem
+{
+public:
+ PageListViewItem(Page* page, QListView* parent);
+ ~PageListViewItem();
-class QListView;
+ Page* page() const;
-class Page;
+private:
+ Page* m_pPage;
+};
+
+class PageListView : public QListView
+{
+public:
+ PageListView(DrawPadCanvas* drawPadCanvas, QWidget* parent = 0, const char* name = 0);
+ ~PageListView();
+
+ void updateView();
-class ThumbnailView : public QDialog
+ Page* selected() const;
+
+protected:
+ void resizeEvent(QResizeEvent* e);
+
+private:
+ DrawPadCanvas* m_pDrawPadCanvas;
+};
+
+class ThumbnailView : public QWidget
{
Q_OBJECT
public:
- ThumbnailView(QList<Page> pages, QWidget* parent = 0, const char* name = 0);
+ ThumbnailView(DrawPadCanvas* drawPadCanvas, QWidget* parent = 0, const char* name = 0);
~ThumbnailView();
-protected:
- void resizeEvent(QResizeEvent* e);
+ void hide();
+ void exec();
+
+public slots:
+ void deletePage();
private:
- QListView* m_pListView;
+ bool inLoop;
+ DrawPadCanvas* m_pDrawPadCanvas;
+
+ PageListView* m_pPageListView;
};
#endif // THUMBNAILVIEW_H