summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore 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.cpp75
-rw-r--r--noncore/graphics/drawpad/thumbnailview.cpp196
-rw-r--r--noncore/graphics/drawpad/thumbnailview.h53
5 files changed, 262 insertions, 120 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
@@ -40,2 +40,3 @@
#include <qfile.h>
+#include <qmessagebox.h>
#include <qpainter.h>
@@ -68,3 +69,3 @@ DrawPad::DrawPad(QWidget* parent, const char* name)
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);
@@ -98,3 +99,3 @@ DrawPad::DrawPad(QWidget* parent, const char* name)
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);
@@ -102,3 +103,3 @@ DrawPad::DrawPad(QWidget* parent, const char* name)
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);
@@ -269,2 +270,32 @@ 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()
@@ -501,2 +532,17 @@ void DrawPad::updateCaption()
+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()
@@ -531,3 +577,3 @@ void DrawPad::thumbnailView()
{
- ThumbnailView thumbnailView(m_pDrawPadCanvas->pages(), this);
+ ThumbnailView thumbnailView(m_pDrawPadCanvas, this);
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
@@ -41,2 +41,5 @@ public:
private slots:
+ void clearPage();
+ void deletePage();
+
void setPointTool();
@@ -59,2 +62,3 @@ private slots:
+ void deleteAll();
void importPage();
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
@@ -26,3 +26,2 @@
#include <qimage.h>
-#include <qmessagebox.h>
#include <qpainter.h>
@@ -348,25 +347,15 @@ 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);
+ m_pages.clear();
- 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()));
- m_pages.current()->fill(Qt::white);
+ m_pages.append(new Page(contentsRect().size()));
+ m_pages.current()->fill(Qt::white);
- m_pageBackups.clear();
- m_pageBackups.append(new Page(*(m_pages.current())));
+ m_pageBackups.clear();
+ m_pageBackups.append(new Page(*(m_pages.current())));
- resizeContents(m_pages.current()->width(), m_pages.current()->height());
- viewport()->update();
+ resizeContents(m_pages.current()->width(), m_pages.current()->height());
+ viewport()->update();
- emit pagesChanged();
- emit pageBackupsChanged();
- }
+ emit pagesChanged();
+ emit pageBackupsChanged();
}
@@ -398,15 +387,5 @@ 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);
+ m_pages.current()->fill(Qt::white);
- viewport()->update();
- }
+ viewport()->update();
}
@@ -415,27 +394,17 @@ 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"));
+ m_pages.remove(m_pages.current());
- if (messageBox.exec() == QMessageBox::Yes) {
- m_pages.remove(m_pages.current());
-
- if (m_pages.isEmpty()) {
- m_pages.append(new Page(contentsRect().size()));
- m_pages.current()->fill(Qt::white);
- }
+ if (m_pages.isEmpty()) {
+ m_pages.append(new Page(contentsRect().size()));
+ m_pages.current()->fill(Qt::white);
+ }
- m_pageBackups.clear();
- m_pageBackups.append(new Page(*(m_pages.current())));
+ m_pageBackups.clear();
+ m_pageBackups.append(new Page(*(m_pages.current())));
- resizeContents(m_pages.current()->width(), m_pages.current()->height());
- viewport()->update();
+ resizeContents(m_pages.current()->width(), m_pages.current()->height());
+ viewport()->update();
- emit pagesChanged();
- emit pageBackupsChanged();
- }
+ emit pagesChanged();
+ emit pageBackupsChanged();
}
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
@@ -15,2 +15,3 @@
+#include "drawpadcanvas.h"
#include "page.h"
@@ -19,2 +20,3 @@
+#include <qapplication.h>
#include <qheader.h>
@@ -22,76 +24,136 @@
#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"));
+ m_pPage = page;
- QToolButton* newPageButton = new QToolButton(this);
- newPageButton->setIconSet(Resource::loadIconSet("new"));
- newPageButton->setAutoRaise(true);
+ QImage image = m_pPage->convertToImage();
- QToolButton* clearPageButton = new QToolButton(this);
- clearPageButton->setIconSet(Resource::loadIconSet("drawpad/clear"));
- clearPageButton->setAutoRaise(true);
+ int previewWidth = 64;
+ int previewHeight = 64;
- QToolButton* deletePageButton = new QToolButton(this);
- deletePageButton->setIconSet(Resource::loadIconSet("trash"));
- deletePageButton->setAutoRaise(true);
+ float widthScale = 1.0;
+ float heightScale = 1.0;
- QToolButton* movePageUpButton = new QToolButton(this);
- movePageUpButton->setIconSet(Resource::loadIconSet("up"));
- movePageUpButton->setAutoRaise(true);
+ if (previewWidth < image.width()) {
+ widthScale = (float)previewWidth / float(image.width());
+ }
- QToolButton* movePageDownButton = new QToolButton(this);
- movePageDownButton->setIconSet(Resource::loadIconSet("down"));
- movePageDownButton->setAutoRaise(true);
+ 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);
- m_pListView = new QListView(this);
+ QPixmap pixmap(64, 64);
- m_pListView->header()->hide();
- m_pListView->setAllColumnsShowFocus(true);
+ pixmap.fill(listView()->colorGroup().mid());
+ bitBlt(&pixmap, (pixmap.width() - previewPixmap.width()) / 2,
+ (pixmap.height() - previewPixmap.height()) / 2, &previewPixmap);
- m_pListView->addColumn(tr("Thumbnail"));
- m_pListView->addColumn(tr("Information"));
+ setPixmap(0, pixmap);
+}
- m_pListView->setColumnAlignment(0, Qt::AlignHCenter | Qt::AlignVCenter);
- m_pListView->setColumnAlignment(1, Qt::AlignTop);
+PageListViewItem::~PageListViewItem()
+{
+}
+
+Page* PageListViewItem::page() const
+{
+ return m_pPage;
+}
- QListIterator<Page> iterator(pages);
+PageListView::PageListView(DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name)
+ : QListView(parent, name)
+{
+ m_pDrawPadCanvas = drawPadCanvas;
- for (; iterator.current(); ++iterator) {
- QImage image = iterator.current()->convertToImage();
+ header()->hide();
+ setVScrollBarMode(QScrollView::AlwaysOn);
+ setAllColumnsShowFocus(true);
- int previewWidth = 64;
- int previewHeight = 64;
+ addColumn(tr("Thumbnail"));
+ addColumn(tr("Information"));
- float widthScale = 1.0;
- float heightScale = 1.0;
+ updateView();
+}
- if (previewWidth < image.width()) {
- widthScale = (float)previewWidth / float(image.width());
- }
+PageListView::~PageListView()
+{
+}
+
+void PageListView::updateView()
+{
+ clear();
- if (previewHeight < image.height()) {
- heightScale = (float)previewHeight / float(image.height());
+ if (m_pDrawPadCanvas) {
+ QList<Page> pageList = m_pDrawPadCanvas->pages();
+ QListIterator<Page> it(pageList);
+
+ for (; it.current(); ++it) {
+ new PageListViewItem(it.current(), this);
}
+ }
+}
- float scale = (widthScale < heightScale ? widthScale : heightScale);
- QImage previewImage = image.smoothScale((int)(image.width() * scale) , (int)(image.height() * scale));
+void PageListView::resizeEvent(QResizeEvent* e)
+{
+ Q_UNUSED(e);
- QPixmap previewPixmap;
- previewPixmap.convertFromImage(previewImage);
+ setColumnWidth(1, contentsRect().width() - columnWidth(0) - verticalScrollBar()->width());
+}
- QPixmap pixmap(64, 64);
+Page* PageListView::selected() const
+{
+ Page* page;
- pixmap.fill(colorGroup().mid());
- bitBlt(&pixmap, (pixmap.width() - previewPixmap.width()) / 2,
- (pixmap.height() - previewPixmap.height()) / 2, &previewPixmap);
+ PageListViewItem* item = (PageListViewItem*)selectedItem();
- QListViewItem* item = new QListViewItem(m_pListView);
- item->setPixmap(0, pixmap);
+ 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);
@@ -107,3 +169,3 @@ ThumbnailView::ThumbnailView(QList<Page> pages, QWidget* parent, const char* nam
mainLayout->addLayout(buttonLayout);
- mainLayout->addWidget(m_pListView);
+ mainLayout->addWidget(m_pPageListView);
}
@@ -112,10 +174,38 @@ ThumbnailView::~ThumbnailView()
{
+ hide();
}
-void ThumbnailView::resizeEvent(QResizeEvent* e)
+void ThumbnailView::hide()
{
- QDialog::resizeEvent(e);
+ QWidget::hide();
+
+ if (inLoop) {
+ inLoop = false;
+ qApp->exit_loop();
+ }
+}
- m_pListView->setColumnWidth(1, m_pListView->contentsRect().width() - m_pListView->columnWidth(0)
- - m_pListView->verticalScrollBar()->width());
+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
@@ -16,17 +16,29 @@
-#include <qdialog.h>
+#include <qwidget.h>
+#include <qlistview.h>
-#include <qlist.h>
+class DrawPadCanvas;
+class Page;
-class QListView;
+class PageListViewItem : public QListViewItem
+{
+public:
+ PageListViewItem(Page* page, QListView* parent);
+ ~PageListViewItem();
-class Page;
+ Page* page() const;
-class ThumbnailView : public QDialog
-{
- Q_OBJECT
+private:
+ Page* m_pPage;
+};
+class PageListView : public QListView
+{
public:
- ThumbnailView(QList<Page> pages, QWidget* parent = 0, const char* name = 0);
- ~ThumbnailView();
+ PageListView(DrawPadCanvas* drawPadCanvas, QWidget* parent = 0, const char* name = 0);
+ ~PageListView();
+
+ void updateView();
+
+ Page* selected() const;
@@ -36,3 +48,24 @@ protected:
private:
- QListView* m_pListView;
+ DrawPadCanvas* m_pDrawPadCanvas;
+};
+
+class ThumbnailView : public QWidget
+{
+ Q_OBJECT
+
+public:
+ ThumbnailView(DrawPadCanvas* drawPadCanvas, QWidget* parent = 0, const char* name = 0);
+ ~ThumbnailView();
+
+ void hide();
+ void exec();
+
+public slots:
+ void deletePage();
+
+private:
+ bool inLoop;
+ DrawPadCanvas* m_pDrawPadCanvas;
+
+ PageListView* m_pPageListView;
};