author | leseb <leseb> | 2002-06-07 20:30:30 (UTC) |
---|---|---|
committer | leseb <leseb> | 2002-06-07 20:30:30 (UTC) |
commit | 9dcd598f9b815511cae884d26b18e3c8913b9fcf (patch) (unidiff) | |
tree | 4b18e7fa7c864b2dca4da76bc89c2a975e80a73c | |
parent | 640d964cfdc7467f6cacb513087cd3acda2c04f0 (diff) | |
download | opie-9dcd598f9b815511cae884d26b18e3c8913b9fcf.zip opie-9dcd598f9b815511cae884d26b18e3c8913b9fcf.tar.gz opie-9dcd598f9b815511cae884d26b18e3c8913b9fcf.tar.bz2 |
Make progress in thumbnail view
-rw-r--r-- | noncore/graphics/drawpad/drawpad.cpp | 54 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpad.h | 4 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpadcanvas.cpp | 75 | ||||
-rw-r--r-- | noncore/graphics/drawpad/thumbnailview.cpp | 196 | ||||
-rw-r--r-- | noncore/graphics/drawpad/thumbnailview.h | 53 |
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 | |||
@@ -37,8 +37,9 @@ | |||
37 | #include <qpe/resource.h> | 37 | #include <qpe/resource.h> |
38 | 38 | ||
39 | #include <qaction.h> | 39 | #include <qaction.h> |
40 | #include <qfile.h> | 40 | #include <qfile.h> |
41 | #include <qmessagebox.h> | ||
41 | #include <qpainter.h> | 42 | #include <qpainter.h> |
42 | #include <qspinbox.h> | 43 | #include <qspinbox.h> |
43 | #include <qtoolbutton.h> | 44 | #include <qtoolbutton.h> |
44 | #include <qtooltip.h> | 45 | #include <qtooltip.h> |
@@ -65,9 +66,9 @@ DrawPad::DrawPad(QWidget* parent, const char* name) | |||
65 | 66 | ||
66 | QPopupMenu *toolsPopupMenu = new QPopupMenu(menuBar); | 67 | QPopupMenu *toolsPopupMenu = new QPopupMenu(menuBar); |
67 | 68 | ||
68 | QAction* deleteAllAction = new QAction(tr("Delete All"), QString::null, 0, this); | 69 | QAction* deleteAllAction = new QAction(tr("Delete All"), QString::null, 0, this); |
69 | connect(deleteAllAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(deleteAll())); | 70 | connect(deleteAllAction, SIGNAL(activated()), this, SLOT(deleteAll())); |
70 | deleteAllAction->addTo(toolsPopupMenu); | 71 | deleteAllAction->addTo(toolsPopupMenu); |
71 | 72 | ||
72 | toolsPopupMenu->insertSeparator(); | 73 | toolsPopupMenu->insertSeparator(); |
73 | 74 | ||
@@ -95,13 +96,13 @@ DrawPad::DrawPad(QWidget* parent, const char* name) | |||
95 | connect(newPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(newPage())); | 96 | connect(newPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(newPage())); |
96 | newPageAction->addTo(pageToolBar); | 97 | newPageAction->addTo(pageToolBar); |
97 | 98 | ||
98 | QAction* clearPageAction = new QAction(tr("Clear Page"), Resource::loadIconSet("drawpad/clear"), QString::null, 0, this); | 99 | QAction* clearPageAction = new QAction(tr("Clear Page"), Resource::loadIconSet("drawpad/clear"), QString::null, 0, this); |
99 | connect(clearPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(clearPage())); | 100 | connect(clearPageAction, SIGNAL(activated()), this, SLOT(clearPage())); |
100 | clearPageAction->addTo(pageToolBar); | 101 | clearPageAction->addTo(pageToolBar); |
101 | 102 | ||
102 | QAction* deletePageAction = new QAction(tr("Delete Page"), Resource::loadIconSet("trash"), QString::null, 0, this); | 103 | QAction* deletePageAction = new QAction(tr("Delete Page"), Resource::loadIconSet("trash"), QString::null, 0, this); |
103 | connect(deletePageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(deletePage())); | 104 | connect(deletePageAction, SIGNAL(activated()), this, SLOT(deletePage())); |
104 | deletePageAction->addTo(pageToolBar); | 105 | deletePageAction->addTo(pageToolBar); |
105 | 106 | ||
106 | QPEToolBar* emptyToolBar = new QPEToolBar(this); | 107 | QPEToolBar* emptyToolBar = new QPEToolBar(this); |
107 | emptyToolBar->setHorizontalStretchable(true); | 108 | emptyToolBar->setHorizontalStretchable(true); |
@@ -266,8 +267,38 @@ DrawPad::~DrawPad() | |||
266 | file.close(); | 267 | file.close(); |
267 | } | 268 | } |
268 | } | 269 | } |
269 | 270 | ||
271 | void DrawPad::clearPage() | ||
272 | { | ||
273 | QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe current page?"), | ||
274 | QMessageBox::Information, QMessageBox::Yes, | ||
275 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, | ||
276 | QMessageBox::NoButton, this); | ||
277 | |||
278 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); | ||
279 | messageBox.setButtonText(QMessageBox::No, tr("No")); | ||
280 | |||
281 | if (messageBox.exec() == QMessageBox::Yes) { | ||
282 | m_pDrawPadCanvas->clearPage(); | ||
283 | } | ||
284 | } | ||
285 | |||
286 | void DrawPad::deletePage() | ||
287 | { | ||
288 | QMessageBox messageBox(tr("Delete Page"), tr("Do you want to delete\nthe current page?"), | ||
289 | QMessageBox::Information, QMessageBox::Yes, | ||
290 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, | ||
291 | QMessageBox::NoButton, this); | ||
292 | |||
293 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); | ||
294 | messageBox.setButtonText(QMessageBox::No, tr("No")); | ||
295 | |||
296 | if (messageBox.exec() == QMessageBox::Yes) { | ||
297 | m_pDrawPadCanvas->deletePage(); | ||
298 | } | ||
299 | } | ||
300 | |||
270 | void DrawPad::setPointTool() | 301 | void DrawPad::setPointTool() |
271 | { | 302 | { |
272 | if (m_pTool) { | 303 | if (m_pTool) { |
273 | delete m_pTool; | 304 | delete m_pTool; |
@@ -498,8 +529,23 @@ void DrawPad::updateCaption() | |||
498 | setCaption(tr("DrawPad") + " - " + tr("Page") + " " | 529 | setCaption(tr("DrawPad") + " - " + tr("Page") + " " |
499 | + QString::number(pagePosition) + "/" + QString::number(pageCount)); | 530 | + QString::number(pagePosition) + "/" + QString::number(pageCount)); |
500 | } | 531 | } |
501 | 532 | ||
533 | void DrawPad::deleteAll() | ||
534 | { | ||
535 | QMessageBox messageBox(tr("Delete All"), tr("Do you want to delete\nall the pages?"), | ||
536 | QMessageBox::Information, QMessageBox::Yes, | ||
537 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, | ||
538 | QMessageBox::NoButton, this); | ||
539 | |||
540 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); | ||
541 | messageBox.setButtonText(QMessageBox::No, tr("No")); | ||
542 | |||
543 | if (messageBox.exec() == QMessageBox::Yes) { | ||
544 | m_pDrawPadCanvas->deleteAll(); | ||
545 | } | ||
546 | } | ||
547 | |||
502 | void DrawPad::importPage() | 548 | void DrawPad::importPage() |
503 | { | 549 | { |
504 | ImportDialog importDialog(this); | 550 | ImportDialog importDialog(this); |
505 | 551 | ||
@@ -528,9 +574,9 @@ void DrawPad::exportPage() | |||
528 | } | 574 | } |
529 | 575 | ||
530 | void DrawPad::thumbnailView() | 576 | void DrawPad::thumbnailView() |
531 | { | 577 | { |
532 | ThumbnailView thumbnailView(m_pDrawPadCanvas->pages(), this); | 578 | ThumbnailView thumbnailView(m_pDrawPadCanvas, this); |
533 | 579 | ||
534 | thumbnailView.showMaximized(); | 580 | thumbnailView.showMaximized(); |
535 | thumbnailView.exec(); | 581 | thumbnailView.exec(); |
536 | } | 582 | } |
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 | |||
@@ -38,8 +38,11 @@ public: | |||
38 | QPen pen() { return m_pen; } | 38 | QPen pen() { return m_pen; } |
39 | QBrush brush() { return m_brush; } | 39 | QBrush brush() { return m_brush; } |
40 | 40 | ||
41 | private slots: | 41 | private slots: |
42 | void clearPage(); | ||
43 | void deletePage(); | ||
44 | |||
42 | void setPointTool(); | 45 | void setPointTool(); |
43 | void setLineTool(); | 46 | void setLineTool(); |
44 | void setRectangleTool(); | 47 | void setRectangleTool(); |
45 | void setFilledRectangleTool(); | 48 | void setFilledRectangleTool(); |
@@ -56,8 +59,9 @@ private slots: | |||
56 | void updateUndoRedoToolButtons(); | 59 | void updateUndoRedoToolButtons(); |
57 | void updateNavigationToolButtons(); | 60 | void updateNavigationToolButtons(); |
58 | void updateCaption(); | 61 | void updateCaption(); |
59 | 62 | ||
63 | void deleteAll(); | ||
60 | void importPage(); | 64 | void importPage(); |
61 | void exportPage(); | 65 | void exportPage(); |
62 | void thumbnailView(); | 66 | void thumbnailView(); |
63 | 67 | ||
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 | |||
@@ -23,9 +23,8 @@ | |||
23 | #include <qpe/mimetype.h> | 23 | #include <qpe/mimetype.h> |
24 | 24 | ||
25 | #include <qbuffer.h> | 25 | #include <qbuffer.h> |
26 | #include <qimage.h> | 26 | #include <qimage.h> |
27 | #include <qmessagebox.h> | ||
28 | #include <qpainter.h> | 27 | #include <qpainter.h> |
29 | #include <qtextcodec.h> | 28 | #include <qtextcodec.h> |
30 | #include <qtextstream.h> | 29 | #include <qtextstream.h> |
31 | #include <qxml.h> | 30 | #include <qxml.h> |
@@ -345,31 +344,21 @@ void DrawPadCanvas::backupPage() | |||
345 | } | 344 | } |
346 | 345 | ||
347 | void DrawPadCanvas::deleteAll() | 346 | void DrawPadCanvas::deleteAll() |
348 | { | 347 | { |
349 | QMessageBox messageBox(tr("Delete All"), tr("Do you want to delete\nall the pages?"), | 348 | m_pages.clear(); |
350 | QMessageBox::Information, QMessageBox::Yes, | ||
351 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, | ||
352 | QMessageBox::NoButton, this); | ||
353 | 349 | ||
354 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); | 350 | m_pages.append(new Page(contentsRect().size())); |
355 | messageBox.setButtonText(QMessageBox::No, tr("No")); | 351 | m_pages.current()->fill(Qt::white); |
356 | |||
357 | if (messageBox.exec() == QMessageBox::Yes) { | ||
358 | m_pages.clear(); | ||
359 | |||
360 | m_pages.append(new Page(contentsRect().size())); | ||
361 | m_pages.current()->fill(Qt::white); | ||
362 | 352 | ||
363 | m_pageBackups.clear(); | 353 | m_pageBackups.clear(); |
364 | m_pageBackups.append(new Page(*(m_pages.current()))); | 354 | m_pageBackups.append(new Page(*(m_pages.current()))); |
365 | 355 | ||
366 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 356 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
367 | viewport()->update(); | 357 | viewport()->update(); |
368 | 358 | ||
369 | emit pagesChanged(); | 359 | emit pagesChanged(); |
370 | emit pageBackupsChanged(); | 360 | emit pageBackupsChanged(); |
371 | } | ||
372 | } | 361 | } |
373 | 362 | ||
374 | void DrawPadCanvas::newPage() | 363 | void DrawPadCanvas::newPage() |
375 | { | 364 | { |
@@ -395,50 +384,30 @@ void DrawPadCanvas::newPage() | |||
395 | } | 384 | } |
396 | 385 | ||
397 | void DrawPadCanvas::clearPage() | 386 | void DrawPadCanvas::clearPage() |
398 | { | 387 | { |
399 | QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe current page?"), | 388 | m_pages.current()->fill(Qt::white); |
400 | QMessageBox::Information, QMessageBox::Yes, | ||
401 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, | ||
402 | QMessageBox::NoButton, this); | ||
403 | |||
404 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); | ||
405 | messageBox.setButtonText(QMessageBox::No, tr("No")); | ||
406 | |||
407 | if (messageBox.exec() == QMessageBox::Yes) { | ||
408 | m_pages.current()->fill(Qt::white); | ||
409 | 389 | ||
410 | viewport()->update(); | 390 | viewport()->update(); |
411 | } | ||
412 | } | 391 | } |
413 | 392 | ||
414 | void DrawPadCanvas::deletePage() | 393 | void DrawPadCanvas::deletePage() |
415 | { | 394 | { |
416 | QMessageBox messageBox(tr("Delete Page"), tr("Do you want to delete\nthe current page?"), | 395 | m_pages.remove(m_pages.current()); |
417 | QMessageBox::Information, QMessageBox::Yes, | ||
418 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, | ||
419 | QMessageBox::NoButton, this); | ||
420 | |||
421 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); | ||
422 | messageBox.setButtonText(QMessageBox::No, tr("No")); | ||
423 | 396 | ||
424 | if (messageBox.exec() == QMessageBox::Yes) { | 397 | if (m_pages.isEmpty()) { |
425 | m_pages.remove(m_pages.current()); | 398 | m_pages.append(new Page(contentsRect().size())); |
426 | 399 | m_pages.current()->fill(Qt::white); | |
427 | if (m_pages.isEmpty()) { | 400 | } |
428 | m_pages.append(new Page(contentsRect().size())); | ||
429 | m_pages.current()->fill(Qt::white); | ||
430 | } | ||
431 | 401 | ||
432 | m_pageBackups.clear(); | 402 | m_pageBackups.clear(); |
433 | m_pageBackups.append(new Page(*(m_pages.current()))); | 403 | m_pageBackups.append(new Page(*(m_pages.current()))); |
434 | 404 | ||
435 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | 405 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); |
436 | viewport()->update(); | 406 | viewport()->update(); |
437 | 407 | ||
438 | emit pagesChanged(); | 408 | emit pagesChanged(); |
439 | emit pageBackupsChanged(); | 409 | emit pageBackupsChanged(); |
440 | } | ||
441 | } | 410 | } |
442 | 411 | ||
443 | bool DrawPadCanvas::undoEnabled() | 412 | bool DrawPadCanvas::undoEnabled() |
444 | { | 413 | { |
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 | |||
@@ -12,89 +12,151 @@ | |||
12 | ***************************************************************************/ | 12 | ***************************************************************************/ |
13 | 13 | ||
14 | #include "thumbnailview.h" | 14 | #include "thumbnailview.h" |
15 | 15 | ||
16 | #include "drawpadcanvas.h" | ||
16 | #include "page.h" | 17 | #include "page.h" |
17 | 18 | ||
18 | #include <qpe/resource.h> | 19 | #include <qpe/resource.h> |
19 | 20 | ||
21 | #include <qapplication.h> | ||
20 | #include <qheader.h> | 22 | #include <qheader.h> |
21 | #include <qimage.h> | 23 | #include <qimage.h> |
22 | #include <qlayout.h> | 24 | #include <qlayout.h> |
23 | #include <qlistview.h> | 25 | #include <qmessagebox.h> |
24 | #include <qtoolbutton.h> | 26 | #include <qtoolbutton.h> |
25 | 27 | ||
26 | ThumbnailView::ThumbnailView(QList<Page> pages, QWidget* parent, const char* name) | 28 | PageListViewItem::PageListViewItem(Page* page, QListView* parent) |
27 | : QDialog(parent, name, true) | 29 | : QListViewItem(parent) |
28 | { | 30 | { |
29 | setCaption(tr("Thumbnail")); | 31 | m_pPage = page; |
30 | 32 | ||
31 | QToolButton* newPageButton = new QToolButton(this); | 33 | QImage image = m_pPage->convertToImage(); |
32 | newPageButton->setIconSet(Resource::loadIconSet("new")); | ||
33 | newPageButton->setAutoRaise(true); | ||
34 | 34 | ||
35 | QToolButton* clearPageButton = new QToolButton(this); | 35 | int previewWidth = 64; |
36 | clearPageButton->setIconSet(Resource::loadIconSet("drawpad/clear")); | 36 | int previewHeight = 64; |
37 | clearPageButton->setAutoRaise(true); | ||
38 | 37 | ||
39 | QToolButton* deletePageButton = new QToolButton(this); | 38 | float widthScale = 1.0; |
40 | deletePageButton->setIconSet(Resource::loadIconSet("trash")); | 39 | float heightScale = 1.0; |
41 | deletePageButton->setAutoRaise(true); | ||
42 | 40 | ||
43 | QToolButton* movePageUpButton = new QToolButton(this); | 41 | if (previewWidth < image.width()) { |
44 | movePageUpButton->setIconSet(Resource::loadIconSet("up")); | 42 | widthScale = (float)previewWidth / float(image.width()); |
45 | movePageUpButton->setAutoRaise(true); | 43 | } |
46 | 44 | ||
47 | QToolButton* movePageDownButton = new QToolButton(this); | 45 | if (previewHeight < image.height()) { |
48 | movePageDownButton->setIconSet(Resource::loadIconSet("down")); | 46 | heightScale = (float)previewHeight / float(image.height()); |
49 | movePageDownButton->setAutoRaise(true); | 47 | } |
48 | |||
49 | float scale = (widthScale < heightScale ? widthScale : heightScale); | ||
50 | QImage previewImage = image.smoothScale((int)(image.width() * scale) , (int)(image.height() * scale)); | ||
51 | |||
52 | QPixmap previewPixmap; | ||
53 | previewPixmap.convertFromImage(previewImage); | ||
50 | 54 | ||
51 | m_pListView = new QListView(this); | 55 | QPixmap pixmap(64, 64); |
52 | 56 | ||
53 | m_pListView->header()->hide(); | 57 | pixmap.fill(listView()->colorGroup().mid()); |
54 | m_pListView->setAllColumnsShowFocus(true); | 58 | bitBlt(&pixmap, (pixmap.width() - previewPixmap.width()) / 2, |
59 | (pixmap.height() - previewPixmap.height()) / 2, &previewPixmap); | ||
55 | 60 | ||
56 | m_pListView->addColumn(tr("Thumbnail")); | 61 | setPixmap(0, pixmap); |
57 | m_pListView->addColumn(tr("Information")); | 62 | } |
58 | 63 | ||
59 | m_pListView->setColumnAlignment(0, Qt::AlignHCenter | Qt::AlignVCenter); | 64 | PageListViewItem::~PageListViewItem() |
60 | m_pListView->setColumnAlignment(1, Qt::AlignTop); | 65 | { |
66 | } | ||
67 | |||
68 | Page* PageListViewItem::page() const | ||
69 | { | ||
70 | return m_pPage; | ||
71 | } | ||
61 | 72 | ||
62 | QListIterator<Page> iterator(pages); | 73 | PageListView::PageListView(DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name) |
74 | : QListView(parent, name) | ||
75 | { | ||
76 | m_pDrawPadCanvas = drawPadCanvas; | ||
63 | 77 | ||
64 | for (; iterator.current(); ++iterator) { | 78 | header()->hide(); |
65 | QImage image = iterator.current()->convertToImage(); | 79 | setVScrollBarMode(QScrollView::AlwaysOn); |
80 | setAllColumnsShowFocus(true); | ||
66 | 81 | ||
67 | int previewWidth = 64; | 82 | addColumn(tr("Thumbnail")); |
68 | int previewHeight = 64; | 83 | addColumn(tr("Information")); |
69 | 84 | ||
70 | float widthScale = 1.0; | 85 | updateView(); |
71 | float heightScale = 1.0; | 86 | } |
72 | 87 | ||
73 | if (previewWidth < image.width()) { | 88 | PageListView::~PageListView() |
74 | widthScale = (float)previewWidth / float(image.width()); | 89 | { |
75 | } | 90 | } |
91 | |||
92 | void PageListView::updateView() | ||
93 | { | ||
94 | clear(); | ||
76 | 95 | ||
77 | if (previewHeight < image.height()) { | 96 | if (m_pDrawPadCanvas) { |
78 | heightScale = (float)previewHeight / float(image.height()); | 97 | QList<Page> pageList = m_pDrawPadCanvas->pages(); |
98 | QListIterator<Page> it(pageList); | ||
99 | |||
100 | for (; it.current(); ++it) { | ||
101 | new PageListViewItem(it.current(), this); | ||
79 | } | 102 | } |
103 | } | ||
104 | } | ||
80 | 105 | ||
81 | float scale = (widthScale < heightScale ? widthScale : heightScale); | 106 | void PageListView::resizeEvent(QResizeEvent* e) |
82 | QImage previewImage = image.smoothScale((int)(image.width() * scale) , (int)(image.height() * scale)); | 107 | { |
108 | Q_UNUSED(e); | ||
83 | 109 | ||
84 | QPixmap previewPixmap; | 110 | setColumnWidth(1, contentsRect().width() - columnWidth(0) - verticalScrollBar()->width()); |
85 | previewPixmap.convertFromImage(previewImage); | 111 | } |
86 | 112 | ||
87 | QPixmap pixmap(64, 64); | 113 | Page* PageListView::selected() const |
114 | { | ||
115 | Page* page; | ||
88 | 116 | ||
89 | pixmap.fill(colorGroup().mid()); | 117 | PageListViewItem* item = (PageListViewItem*)selectedItem(); |
90 | bitBlt(&pixmap, (pixmap.width() - previewPixmap.width()) / 2, | ||
91 | (pixmap.height() - previewPixmap.height()) / 2, &previewPixmap); | ||
92 | 118 | ||
93 | QListViewItem* item = new QListViewItem(m_pListView); | 119 | if (item) { |
94 | item->setPixmap(0, pixmap); | 120 | page = item->page(); |
121 | } else { | ||
122 | page = NULL; | ||
95 | } | 123 | } |
96 | 124 | ||
125 | return page; | ||
126 | } | ||
127 | |||
128 | |||
129 | ThumbnailView::ThumbnailView(DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name) | ||
130 | : QWidget(parent, name, Qt::WType_Modal | Qt::WType_TopLevel) | ||
131 | { | ||
132 | inLoop = false; | ||
133 | m_pDrawPadCanvas = drawPadCanvas; | ||
134 | |||
135 | setCaption(tr("Thumbnail")); | ||
136 | |||
137 | QToolButton* newPageButton = new QToolButton(this); | ||
138 | newPageButton->setIconSet(Resource::loadIconSet("new")); | ||
139 | newPageButton->setAutoRaise(true); | ||
140 | |||
141 | QToolButton* clearPageButton = new QToolButton(this); | ||
142 | clearPageButton->setIconSet(Resource::loadIconSet("drawpad/clear")); | ||
143 | clearPageButton->setAutoRaise(true); | ||
144 | |||
145 | QToolButton* deletePageButton = new QToolButton(this); | ||
146 | deletePageButton->setIconSet(Resource::loadIconSet("trash")); | ||
147 | deletePageButton->setAutoRaise(true); | ||
148 | |||
149 | QToolButton* movePageUpButton = new QToolButton(this); | ||
150 | movePageUpButton->setIconSet(Resource::loadIconSet("up")); | ||
151 | movePageUpButton->setAutoRaise(true); | ||
152 | |||
153 | QToolButton* movePageDownButton = new QToolButton(this); | ||
154 | movePageDownButton->setIconSet(Resource::loadIconSet("down")); | ||
155 | movePageDownButton->setAutoRaise(true); | ||
156 | |||
157 | m_pPageListView = new PageListView(m_pDrawPadCanvas, this); | ||
158 | |||
97 | QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); | 159 | QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); |
98 | QHBoxLayout* buttonLayout = new QHBoxLayout(0); | 160 | QHBoxLayout* buttonLayout = new QHBoxLayout(0); |
99 | 161 | ||
100 | buttonLayout->addWidget(newPageButton); | 162 | buttonLayout->addWidget(newPageButton); |
@@ -104,18 +166,46 @@ ThumbnailView::ThumbnailView(QList<Page> pages, QWidget* parent, const char* nam | |||
104 | buttonLayout->addWidget(movePageUpButton); | 166 | buttonLayout->addWidget(movePageUpButton); |
105 | buttonLayout->addWidget(movePageDownButton); | 167 | buttonLayout->addWidget(movePageDownButton); |
106 | 168 | ||
107 | mainLayout->addLayout(buttonLayout); | 169 | mainLayout->addLayout(buttonLayout); |
108 | mainLayout->addWidget(m_pListView); | 170 | mainLayout->addWidget(m_pPageListView); |
109 | } | 171 | } |
110 | 172 | ||
111 | ThumbnailView::~ThumbnailView() | 173 | ThumbnailView::~ThumbnailView() |
112 | { | 174 | { |
175 | hide(); | ||
113 | } | 176 | } |
114 | 177 | ||
115 | void ThumbnailView::resizeEvent(QResizeEvent* e) | 178 | void ThumbnailView::hide() |
116 | { | 179 | { |
117 | QDialog::resizeEvent(e); | 180 | QWidget::hide(); |
181 | |||
182 | if (inLoop) { | ||
183 | inLoop = false; | ||
184 | qApp->exit_loop(); | ||
185 | } | ||
186 | } | ||
118 | 187 | ||
119 | m_pListView->setColumnWidth(1, m_pListView->contentsRect().width() - m_pListView->columnWidth(0) | 188 | void ThumbnailView::exec() |
120 | - m_pListView->verticalScrollBar()->width()); | 189 | { |
190 | show(); | ||
191 | |||
192 | if (!inLoop) { | ||
193 | inLoop = true; | ||
194 | qApp->enter_loop(); | ||
195 | } | ||
196 | } | ||
197 | |||
198 | void ThumbnailView::deletePage() | ||
199 | { | ||
200 | QMessageBox messageBox(tr("Delete Page"), tr("Do you want to delete\nthe selected page?"), | ||
201 | QMessageBox::Information, QMessageBox::Yes, | ||
202 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, | ||
203 | QMessageBox::NoButton, this); | ||
204 | |||
205 | messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); | ||
206 | messageBox.setButtonText(QMessageBox::No, tr("No")); | ||
207 | |||
208 | if (messageBox.exec() == QMessageBox::Yes) { | ||
209 | m_pDrawPadCanvas->deletePage(); | ||
210 | } | ||
121 | } | 211 | } |
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 | |||
@@ -13,28 +13,61 @@ | |||
13 | 13 | ||
14 | #ifndef THUMBNAILVIEW_H | 14 | #ifndef THUMBNAILVIEW_H |
15 | #define THUMBNAILVIEW_H | 15 | #define THUMBNAILVIEW_H |
16 | 16 | ||
17 | #include <qdialog.h> | 17 | #include <qwidget.h> |
18 | #include <qlistview.h> | ||
18 | 19 | ||
19 | #include <qlist.h> | 20 | class DrawPadCanvas; |
21 | class Page; | ||
20 | 22 | ||
21 | class QListView; | 23 | class PageListViewItem : public QListViewItem |
24 | { | ||
25 | public: | ||
26 | PageListViewItem(Page* page, QListView* parent); | ||
27 | ~PageListViewItem(); | ||
22 | 28 | ||
23 | class Page; | 29 | Page* page() const; |
24 | 30 | ||
25 | class ThumbnailView : public QDialog | 31 | private: |
26 | { | 32 | Page* m_pPage; |
27 | Q_OBJECT | 33 | }; |
28 | 34 | ||
35 | class PageListView : public QListView | ||
36 | { | ||
29 | public: | 37 | public: |
30 | ThumbnailView(QList<Page> pages, QWidget* parent = 0, const char* name = 0); | 38 | PageListView(DrawPadCanvas* drawPadCanvas, QWidget* parent = 0, const char* name = 0); |
31 | ~ThumbnailView(); | 39 | ~PageListView(); |
40 | |||
41 | void updateView(); | ||
42 | |||
43 | Page* selected() const; | ||
32 | 44 | ||
33 | protected: | 45 | protected: |
34 | void resizeEvent(QResizeEvent* e); | 46 | void resizeEvent(QResizeEvent* e); |
35 | 47 | ||
36 | private: | 48 | private: |
37 | QListView* m_pListView; | 49 | DrawPadCanvas* m_pDrawPadCanvas; |
50 | }; | ||
51 | |||
52 | class ThumbnailView : public QWidget | ||
53 | { | ||
54 | Q_OBJECT | ||
55 | |||
56 | public: | ||
57 | ThumbnailView(DrawPadCanvas* drawPadCanvas, QWidget* parent = 0, const char* name = 0); | ||
58 | ~ThumbnailView(); | ||
59 | |||
60 | void hide(); | ||
61 | void exec(); | ||
62 | |||
63 | public slots: | ||
64 | void deletePage(); | ||
65 | |||
66 | private: | ||
67 | bool inLoop; | ||
68 | DrawPadCanvas* m_pDrawPadCanvas; | ||
69 | |||
70 | PageListView* m_pPageListView; | ||
38 | }; | 71 | }; |
39 | 72 | ||
40 | #endif // THUMBNAILVIEW_H | 73 | #endif // THUMBNAILVIEW_H |