summaryrefslogtreecommitdiff
authorleseb <leseb>2002-06-10 20:24:06 (UTC)
committer leseb <leseb>2002-06-10 20:24:06 (UTC)
commit743296b2abaa9278ce7b83ebde55fbf2c198e218 (patch) (unidiff)
tree22776ec0e2921fc36a61c9522e8a105e7a3eba13
parent4e125ad47285d36a4be02e8b20b6fa36e387c1bc (diff)
downloadopie-743296b2abaa9278ce7b83ebde55fbf2c198e218.zip
opie-743296b2abaa9278ce7b83ebde55fbf2c198e218.tar.gz
opie-743296b2abaa9278ce7b83ebde55fbf2c198e218.tar.bz2
Thumbnail view ready for page attributes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/drawpad/thumbnailview.cpp150
-rw-r--r--noncore/graphics/drawpad/thumbnailview.h31
2 files changed, 118 insertions, 63 deletions
diff --git a/noncore/graphics/drawpad/thumbnailview.cpp b/noncore/graphics/drawpad/thumbnailview.cpp
index 428e008..1eadc13 100644
--- a/noncore/graphics/drawpad/thumbnailview.cpp
+++ b/noncore/graphics/drawpad/thumbnailview.cpp
@@ -1,299 +1,345 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * DrawPad - a drawing program for Opie Environment * 3 * DrawPad - a drawing program for Opie Environment *
4 * * 4 * *
5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * 5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
6 * * 6 * *
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 * * 11 * *
12 ***************************************************************************/ 12 ***************************************************************************/
13 13
14#include "thumbnailview.h" 14#include "thumbnailview.h"
15 15
16#include "drawpad.h" 16#include "drawpad.h"
17#include "drawpadcanvas.h" 17#include "drawpadcanvas.h"
18#include "newpagedialog.h" 18#include "newpagedialog.h"
19#include "page.h" 19#include "page.h"
20 20
21#include <qpe/resource.h> 21#include <qpe/resource.h>
22 22
23#include <qapplication.h> 23#include <qapplication.h>
24#include <qheader.h>
25#include <qimage.h> 24#include <qimage.h>
26#include <qlayout.h> 25#include <qlayout.h>
27#include <qmessagebox.h> 26#include <qmessagebox.h>
28#include <qtoolbutton.h> 27#include <qtoolbutton.h>
29 28
30PageListViewItem::PageListViewItem(Page* page, QListView* parent) 29#define THUMBNAIL_SIZE 48
31 : QListViewItem(parent) 30
31PageListBoxItem::PageListBoxItem(Page* page, QListBox* parent)
32 : QListBoxItem(parent)
32{ 33{
33 m_pPage = page; 34 m_pPage = page;
34 35
35 QImage image = m_pPage->convertToImage(); 36 QImage image = m_pPage->convertToImage();
36 37
37 int previewWidth = 64; 38 int previewWidth = THUMBNAIL_SIZE;
38 int previewHeight = 64; 39 int previewHeight = THUMBNAIL_SIZE;
39 40
40 float widthScale = 1.0; 41 float widthScale = 1.0;
41 float heightScale = 1.0; 42 float heightScale = 1.0;
42 43
43 if (previewWidth < image.width()) { 44 if (previewWidth < image.width()) {
44 widthScale = (float)previewWidth / float(image.width()); 45 widthScale = (float)previewWidth / float(image.width());
45 } 46 }
46 47
47 if (previewHeight < image.height()) { 48 if (previewHeight < image.height()) {
48 heightScale = (float)previewHeight / float(image.height()); 49 heightScale = (float)previewHeight / float(image.height());
49 } 50 }
50 51
51 float scale = (widthScale < heightScale ? widthScale : heightScale); 52 float scale = (widthScale < heightScale ? widthScale : heightScale);
52 QImage previewImage = image.smoothScale((int)(image.width() * scale) , (int)(image.height() * scale)); 53 QImage thumbnailImage = image.smoothScale((int)(image.width() * scale) , (int)(image.height() * scale));
54
55 m_thumbnail.convertFromImage(thumbnailImage);
53 56
54 QPixmap previewPixmap; 57 m_titleText = QObject::tr("Title:") + " -";
55 previewPixmap.convertFromImage(previewImage); 58 m_dimensionText = QObject::tr("Dimension:") + " " + QString::number(m_pPage->width())
59 + "x" + QString::number(m_pPage->height());
60 m_dateTimeText = QObject::tr("Date:") + " -";
56 61
57 QPixmap pixmap(64, 64); 62 QColor baseColor = parent->colorGroup().base();
63 int h, s, v;
64 baseColor.hsv(&h, &s, &v);
58 65
59 pixmap.fill(listView()->colorGroup().mid()); 66 if (v > 128) {
60 bitBlt(&pixmap, (pixmap.width() - previewPixmap.width()) / 2, 67 m_alternateColor = baseColor.dark(106);
61 (pixmap.height() - previewPixmap.height()) / 2, &previewPixmap); 68 } else if (baseColor != Qt::black) {
69 m_alternateColor = baseColor.light(110);
70 } else {
71 m_alternateColor = QColor(32, 32, 32);
72 }
73}
74
75PageListBoxItem::~PageListBoxItem()
76{
77}
78
79int PageListBoxItem::height(const QListBox*) const
80{
81 return QMAX(THUMBNAIL_SIZE + 4, QApplication::globalStrut().height());
82}
83
84int PageListBoxItem::width(const QListBox* lb) const
85{
86 QFontMetrics fontMetrics = lb->fontMetrics();
87 int maxtextLength = QMAX(fontMetrics.width(m_titleText),
88 QMAX(fontMetrics.width(m_dimensionText),
89 fontMetrics.width(m_dateTimeText)));
62 90
63 setPixmap(0, pixmap); 91 return QMAX(THUMBNAIL_SIZE + maxtextLength + 8, QApplication::globalStrut().width());
64} 92}
65 93
66PageListViewItem::~PageListViewItem() 94void PageListBoxItem::paint(QPainter *painter)
67{ 95{
96 QRect itemRect = listBox()->itemRect(this);
97
98 if (!selected() && (listBox()->index(this) % 2)) {
99 painter->fillRect(0, 0, itemRect.width(), itemRect.height(), m_alternateColor);
100 }
101
102 painter->drawPixmap(2 + (THUMBNAIL_SIZE - m_thumbnail.width()) / 2,
103 2 + (THUMBNAIL_SIZE - m_thumbnail.height()) / 2,
104 m_thumbnail);
105
106 QFont standardFont = painter->font();
107 QFont boldFont = painter->font();
108 boldFont.setBold(TRUE);
109
110 QFontMetrics fontMetrics = painter->fontMetrics();
111 QRect textRect(THUMBNAIL_SIZE + 6, 2,
112 itemRect.width() - THUMBNAIL_SIZE - 8,
113 itemRect.height() - 4);
114
115 painter->setFont(boldFont);
116 painter->drawText(textRect, Qt::AlignLeft | Qt::AlignTop, m_titleText);
117
118 painter->setFont(standardFont);
119 painter->drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, m_dimensionText);
120 painter->drawText(textRect, Qt::AlignLeft | Qt::AlignBottom, m_dateTimeText);
121
122 if (!selected() && !(listBox()->hasFocus() && listBox()->item(listBox()->currentItem()) == this)) {
123 painter->drawLine(0, itemRect.height() - 1, itemRect.width() - 1, itemRect.height() - 1);
124 }
68} 125}
69 126
70Page* PageListViewItem::page() const 127Page* PageListBoxItem::page() const
71{ 128{
72 return m_pPage; 129 return m_pPage;
73} 130}
74 131
75PageListView::PageListView(DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name) 132PageListBox::PageListBox(DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name)
76 : QListView(parent, name) 133 : QListBox(parent, name)
77{ 134{
78 m_pDrawPadCanvas = drawPadCanvas; 135 m_pDrawPadCanvas = drawPadCanvas;
79 136
80 header()->hide();
81 setVScrollBarMode(QScrollView::AlwaysOn); 137 setVScrollBarMode(QScrollView::AlwaysOn);
82 setAllColumnsShowFocus(true);
83
84 addColumn(tr("Thumbnail"));
85 addColumn(tr("Information"));
86 138
87 updateView(); 139 updateView();
88} 140}
89 141
90PageListView::~PageListView() 142PageListBox::~PageListBox()
91{ 143{
92} 144}
93 145
94void PageListView::updateView() 146void PageListBox::updateView()
95{ 147{
96 clear(); 148 clear();
97 149
98 if (m_pDrawPadCanvas) { 150 if (m_pDrawPadCanvas) {
99 QList<Page> pageList = m_pDrawPadCanvas->pages(); 151 QList<Page> pageList = m_pDrawPadCanvas->pages();
100 QListIterator<Page> it(pageList); 152 QListIterator<Page> it(pageList);
101 153
102 for (; it.current(); ++it) { 154 for (; it.current(); ++it) {
103 new PageListViewItem(it.current(), this); 155 new PageListBoxItem(it.current(), this);
104 } 156 }
105 157
106 setSorting(0, false);
107 select(m_pDrawPadCanvas->currentPage()); 158 select(m_pDrawPadCanvas->currentPage());
108 } 159 }
109} 160}
110 161
111void PageListView::resizeEvent(QResizeEvent* e) 162void PageListBox::select(Page* page)
112{ 163{
113 Q_UNUSED(e); 164 uint i = 0;
165 uint itemCount = count();
114 166
115 setColumnWidth(1, contentsRect().width() - columnWidth(0) - verticalScrollBar()->width()); 167 while (i < itemCount) {
116} 168 PageListBoxItem* currentItem = (PageListBoxItem*)item(i);
117
118void PageListView::select(Page* page)
119{
120 PageListViewItem* item = (PageListViewItem*)firstChild();
121 169
122 while (item) { 170 if (currentItem->page() == page) {
123 if (item->page() == page) { 171 setCurrentItem(currentItem);
124 setSelected(item, true);
125 ensureItemVisible(item);
126 break; 172 break;
127 } 173 }
128 174
129 item = (PageListViewItem*)(item->nextSibling()); 175 i++;
130 } 176 }
131} 177}
132 178
133Page* PageListView::selected() const 179Page* PageListBox::selected() const
134{ 180{
135 Page* page; 181 Page* page;
136 182
137 PageListViewItem* item = (PageListViewItem*)selectedItem(); 183 PageListBoxItem* selectedItem = (PageListBoxItem*)item(currentItem());
138 184
139 if (item) { 185 if (selectedItem) {
140 page = item->page(); 186 page = selectedItem->page();
141 } else { 187 } else {
142 page = NULL; 188 page = NULL;
143 } 189 }
144 190
145 return page; 191 return page;
146} 192}
147 193
148ThumbnailView::ThumbnailView(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name) 194ThumbnailView::ThumbnailView(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name)
149 : QWidget(parent, name, Qt::WType_Modal | Qt::WType_TopLevel) 195 : QWidget(parent, name, Qt::WType_Modal | Qt::WType_TopLevel)
150{ 196{
151 inLoop = false; 197 inLoop = false;
152 198
153 m_pDrawPad = drawPad; 199 m_pDrawPad = drawPad;
154 m_pDrawPadCanvas = drawPadCanvas; 200 m_pDrawPadCanvas = drawPadCanvas;
155 201
156 setCaption(tr("DrawPad - Thumbnail View")); 202 setCaption(tr("DrawPad - Thumbnail View"));
157 203
158 QToolButton* newPageButton = new QToolButton(this); 204 QToolButton* newPageButton = new QToolButton(this);
159 newPageButton->setIconSet(Resource::loadIconSet("new")); 205 newPageButton->setIconSet(Resource::loadIconSet("new"));
160 newPageButton->setAutoRaise(true); 206 newPageButton->setAutoRaise(true);
161 connect(newPageButton, SIGNAL(clicked()), this, SLOT(newPage())); 207 connect(newPageButton, SIGNAL(clicked()), this, SLOT(newPage()));
162 208
163 QToolButton* clearPageButton = new QToolButton(this); 209 QToolButton* clearPageButton = new QToolButton(this);
164 clearPageButton->setIconSet(Resource::loadIconSet("drawpad/clear")); 210 clearPageButton->setIconSet(Resource::loadIconSet("drawpad/clear"));
165 clearPageButton->setAutoRaise(true); 211 clearPageButton->setAutoRaise(true);
166 connect(clearPageButton, SIGNAL(clicked()), this, SLOT(clearPage())); 212 connect(clearPageButton, SIGNAL(clicked()), this, SLOT(clearPage()));
167 213
168 QToolButton* deletePageButton = new QToolButton(this); 214 QToolButton* deletePageButton = new QToolButton(this);
169 deletePageButton->setIconSet(Resource::loadIconSet("trash")); 215 deletePageButton->setIconSet(Resource::loadIconSet("trash"));
170 deletePageButton->setAutoRaise(true); 216 deletePageButton->setAutoRaise(true);
171 connect(deletePageButton, SIGNAL(clicked()), this, SLOT(deletePage())); 217 connect(deletePageButton, SIGNAL(clicked()), this, SLOT(deletePage()));
172 218
173 m_pMovePageUpButton = new QToolButton(this); 219 m_pMovePageUpButton = new QToolButton(this);
174 m_pMovePageUpButton->setIconSet(Resource::loadIconSet("up")); 220 m_pMovePageUpButton->setIconSet(Resource::loadIconSet("up"));
175 m_pMovePageUpButton->setAutoRaise(true); 221 m_pMovePageUpButton->setAutoRaise(true);
176 connect(m_pMovePageUpButton, SIGNAL(clicked()), this, SLOT(movePageUp())); 222 connect(m_pMovePageUpButton, SIGNAL(clicked()), this, SLOT(movePageUp()));
177 223
178 m_pMovePageDownButton = new QToolButton(this); 224 m_pMovePageDownButton = new QToolButton(this);
179 m_pMovePageDownButton->setIconSet(Resource::loadIconSet("down")); 225 m_pMovePageDownButton->setIconSet(Resource::loadIconSet("down"));
180 m_pMovePageDownButton->setAutoRaise(true); 226 m_pMovePageDownButton->setAutoRaise(true);
181 connect(m_pMovePageDownButton, SIGNAL(clicked()), this, SLOT(movePageDown())); 227 connect(m_pMovePageDownButton, SIGNAL(clicked()), this, SLOT(movePageDown()));
182 228
183 m_pPageListView = new PageListView(m_pDrawPadCanvas, this); 229 m_pPageListBox = new PageListBox(m_pDrawPadCanvas, this);
184 connect(m_pPageListView, SIGNAL(selectionChanged()), this, SLOT(changePage())); 230 connect(m_pPageListBox, SIGNAL(selectionChanged()), this, SLOT(changePage()));
185 231
186 QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); 232 QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4);
187 QHBoxLayout* buttonLayout = new QHBoxLayout(0); 233 QHBoxLayout* buttonLayout = new QHBoxLayout(0);
188 234
189 buttonLayout->addWidget(newPageButton); 235 buttonLayout->addWidget(newPageButton);
190 buttonLayout->addWidget(clearPageButton); 236 buttonLayout->addWidget(clearPageButton);
191 buttonLayout->addWidget(deletePageButton); 237 buttonLayout->addWidget(deletePageButton);
192 buttonLayout->addStretch(); 238 buttonLayout->addStretch();
193 buttonLayout->addWidget(m_pMovePageUpButton); 239 buttonLayout->addWidget(m_pMovePageUpButton);
194 buttonLayout->addWidget(m_pMovePageDownButton); 240 buttonLayout->addWidget(m_pMovePageDownButton);
195 241
196 mainLayout->addLayout(buttonLayout); 242 mainLayout->addLayout(buttonLayout);
197 mainLayout->addWidget(m_pPageListView); 243 mainLayout->addWidget(m_pPageListBox);
198 244
199 updateView(); 245 updateView();
200} 246}
201 247
202ThumbnailView::~ThumbnailView() 248ThumbnailView::~ThumbnailView()
203{ 249{
204 hide(); 250 hide();
205} 251}
206 252
207void ThumbnailView::updateView() 253void ThumbnailView::updateView()
208{ 254{
209 m_pMovePageUpButton->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); 255 m_pMovePageUpButton->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled());
210 m_pMovePageDownButton->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); 256 m_pMovePageDownButton->setEnabled(m_pDrawPadCanvas->goNextPageEnabled());
211} 257}
212 258
213void ThumbnailView::hide() 259void ThumbnailView::hide()
214{ 260{
215 QWidget::hide(); 261 QWidget::hide();
216 262
217 if (inLoop) { 263 if (inLoop) {
218 inLoop = false; 264 inLoop = false;
219 qApp->exit_loop(); 265 qApp->exit_loop();
220 } 266 }
221} 267}
222 268
223void ThumbnailView::exec() 269void ThumbnailView::exec()
224{ 270{
225 show(); 271 show();
226 272
227 if (!inLoop) { 273 if (!inLoop) {
228 inLoop = true; 274 inLoop = true;
229 qApp->enter_loop(); 275 qApp->enter_loop();
230 } 276 }
231} 277}
232 278
233void ThumbnailView::newPage() 279void ThumbnailView::newPage()
234{ 280{
235 QRect rect = m_pDrawPadCanvas->contentsRect(); 281 QRect rect = m_pDrawPadCanvas->contentsRect();
236 282
237 NewPageDialog newPageDialog(rect.width(), rect.height(), m_pDrawPad->pen().color(), 283 NewPageDialog newPageDialog(rect.width(), rect.height(), m_pDrawPad->pen().color(),
238 m_pDrawPad->brush().color(), this); 284 m_pDrawPad->brush().color(), this);
239 285
240 if (newPageDialog.exec() == QDialog::Accepted) { 286 if (newPageDialog.exec() == QDialog::Accepted) {
241 m_pDrawPadCanvas->newPage(newPageDialog.selectedWidth(), newPageDialog.selectedHeight(), 287 m_pDrawPadCanvas->newPage(newPageDialog.selectedWidth(), newPageDialog.selectedHeight(),
242 newPageDialog.selectedColor()); 288 newPageDialog.selectedColor());
243 m_pPageListView->updateView(); 289 m_pPageListBox->updateView();
244 updateView(); 290 updateView();
245 } 291 }
246} 292}
247 293
248void ThumbnailView::clearPage() 294void ThumbnailView::clearPage()
249{ 295{
250 QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe selected page?"), 296 QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe selected page?"),
251 QMessageBox::Information, QMessageBox::Yes, 297 QMessageBox::Information, QMessageBox::Yes,
252 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, 298 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default,
253 QMessageBox::NoButton, this); 299 QMessageBox::NoButton, this);
254 300
255 messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); 301 messageBox.setButtonText(QMessageBox::Yes, tr("Yes"));
256 messageBox.setButtonText(QMessageBox::No, tr("No")); 302 messageBox.setButtonText(QMessageBox::No, tr("No"));
257 303
258 if (messageBox.exec() == QMessageBox::Yes) { 304 if (messageBox.exec() == QMessageBox::Yes) {
259 m_pDrawPadCanvas->clearPage(); 305 m_pDrawPadCanvas->clearPage();
260 m_pPageListView->updateView(); 306 m_pPageListBox->updateView();
261 } 307 }
262} 308}
263 309
264void ThumbnailView::deletePage() 310void ThumbnailView::deletePage()
265{ 311{
266 QMessageBox messageBox(tr("Delete Page"), tr("Do you want to delete\nthe selected page?"), 312 QMessageBox messageBox(tr("Delete Page"), tr("Do you want to delete\nthe selected page?"),
267 QMessageBox::Information, QMessageBox::Yes, 313 QMessageBox::Information, QMessageBox::Yes,
268 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, 314 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default,
269 QMessageBox::NoButton, this); 315 QMessageBox::NoButton, this);
270 316
271 messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); 317 messageBox.setButtonText(QMessageBox::Yes, tr("Yes"));
272 messageBox.setButtonText(QMessageBox::No, tr("No")); 318 messageBox.setButtonText(QMessageBox::No, tr("No"));
273 319
274 if (messageBox.exec() == QMessageBox::Yes) { 320 if (messageBox.exec() == QMessageBox::Yes) {
275 m_pDrawPadCanvas->deletePage(); 321 m_pDrawPadCanvas->deletePage();
276 m_pPageListView->updateView(); 322 m_pPageListBox->updateView();
277 updateView(); 323 updateView();
278 } 324 }
279} 325}
280 326
281void ThumbnailView::movePageUp() 327void ThumbnailView::movePageUp()
282{ 328{
283 m_pDrawPadCanvas->movePageUp(); 329 m_pDrawPadCanvas->movePageUp();
284 m_pPageListView->updateView(); 330 m_pPageListBox->updateView();
285 updateView(); 331 updateView();
286} 332}
287 333
288void ThumbnailView::movePageDown() 334void ThumbnailView::movePageDown()
289{ 335{
290 m_pDrawPadCanvas->movePageDown(); 336 m_pDrawPadCanvas->movePageDown();
291 m_pPageListView->updateView(); 337 m_pPageListBox->updateView();
292 updateView(); 338 updateView();
293} 339}
294 340
295void ThumbnailView::changePage() 341void ThumbnailView::changePage()
296{ 342{
297 m_pDrawPadCanvas->selectPage(m_pPageListView->selected()); 343 m_pDrawPadCanvas->selectPage(m_pPageListBox->selected());
298 updateView(); 344 updateView();
299} 345}
diff --git a/noncore/graphics/drawpad/thumbnailview.h b/noncore/graphics/drawpad/thumbnailview.h
index eb748fa..88c3b27 100644
--- a/noncore/graphics/drawpad/thumbnailview.h
+++ b/noncore/graphics/drawpad/thumbnailview.h
@@ -1,89 +1,98 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * DrawPad - a drawing program for Opie Environment * 3 * DrawPad - a drawing program for Opie Environment *
4 * * 4 * *
5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * 5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
6 * * 6 * *
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 * * 11 * *
12 ***************************************************************************/ 12 ***************************************************************************/
13 13
14#ifndef THUMBNAILVIEW_H 14#ifndef THUMBNAILVIEW_H
15#define THUMBNAILVIEW_H 15#define THUMBNAILVIEW_H
16 16
17#include <qlistbox.h>
17#include <qwidget.h> 18#include <qwidget.h>
18#include <qlistview.h>
19 19
20class DrawPad; 20class DrawPad;
21class DrawPadCanvas; 21class DrawPadCanvas;
22class Page; 22class Page;
23 23
24class QToolButton; 24class QToolButton;
25 25
26class PageListViewItem : public QListViewItem 26class PageListBoxItem : public QListBoxItem
27{ 27{
28public: 28public:
29 PageListViewItem(Page* page, QListView* parent); 29 PageListBoxItem(Page* page, QListBox* parent);
30 ~PageListViewItem(); 30 ~PageListBoxItem();
31
32 int height(const QListBox* lb) const;
33 int width(const QListBox* lb) const;
34 void paint(QPainter *painter);
31 35
32 Page* page() const; 36 Page* page() const;
33 37
34private: 38private:
35 Page* m_pPage; 39 Page* m_pPage;
40
41 QPixmap m_thumbnail;
42
43 QString m_titleText;
44 QString m_dimensionText;
45 QString m_dateTimeText;
46
47 QColor m_alternateColor;
36}; 48};
37 49
38class PageListView : public QListView 50class PageListBox : public QListBox
39{ 51{
40public: 52public:
41 PageListView(DrawPadCanvas* drawPadCanvas, QWidget* parent = 0, const char* name = 0); 53 PageListBox(DrawPadCanvas* drawPadCanvas, QWidget* parent = 0, const char* name = 0);
42 ~PageListView(); 54 ~PageListBox();
43 55
44 void updateView(); 56 void updateView();
45 57
46 void select(Page* page); 58 void select(Page* page);
47 Page* selected() const; 59 Page* selected() const;
48 60
49protected:
50 void resizeEvent(QResizeEvent* e);
51
52private: 61private:
53 DrawPadCanvas* m_pDrawPadCanvas; 62 DrawPadCanvas* m_pDrawPadCanvas;
54}; 63};
55 64
56class ThumbnailView : public QWidget 65class ThumbnailView : public QWidget
57{ 66{
58 Q_OBJECT 67 Q_OBJECT
59 68
60public: 69public:
61 ThumbnailView(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas, QWidget* parent = 0, const char* name = 0); 70 ThumbnailView(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas, QWidget* parent = 0, const char* name = 0);
62 ~ThumbnailView(); 71 ~ThumbnailView();
63 72
64 void updateView(); 73 void updateView();
65 74
66 void hide(); 75 void hide();
67 void exec(); 76 void exec();
68 77
69public slots: 78public slots:
70 void newPage(); 79 void newPage();
71 void clearPage(); 80 void clearPage();
72 void deletePage(); 81 void deletePage();
73 void movePageUp(); 82 void movePageUp();
74 void movePageDown(); 83 void movePageDown();
75 void changePage(); 84 void changePage();
76 85
77private: 86private:
78 bool inLoop; 87 bool inLoop;
79 88
80 DrawPad* m_pDrawPad; 89 DrawPad* m_pDrawPad;
81 DrawPadCanvas* m_pDrawPadCanvas; 90 DrawPadCanvas* m_pDrawPadCanvas;
82 91
83 QToolButton* m_pMovePageUpButton; 92 QToolButton* m_pMovePageUpButton;
84 QToolButton* m_pMovePageDownButton; 93 QToolButton* m_pMovePageDownButton;
85 94
86 PageListView* m_pPageListView; 95 PageListBox* m_pPageListBox;
87}; 96};
88 97
89#endif // THUMBNAILVIEW_H 98#endif // THUMBNAILVIEW_H