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 /noncore/graphics/drawpad/thumbnailview.cpp | |
parent | 640d964cfdc7467f6cacb513087cd3acda2c04f0 (diff) | |
download | opie-9dcd598f9b815511cae884d26b18e3c8913b9fcf.zip opie-9dcd598f9b815511cae884d26b18e3c8913b9fcf.tar.gz opie-9dcd598f9b815511cae884d26b18e3c8913b9fcf.tar.bz2 |
Make progress in thumbnail view
Diffstat (limited to 'noncore/graphics/drawpad/thumbnailview.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/graphics/drawpad/thumbnailview.cpp | 184 |
1 files changed, 137 insertions, 47 deletions
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 @@ | |||
15 | 15 | ||
16 | #include "drawpadcanvas.h" | ||
16 | #include "page.h" | 17 | #include "page.h" |
@@ -19,2 +20,3 @@ | |||
19 | 20 | ||
21 | #include <qapplication.h> | ||
20 | #include <qheader.h> | 22 | #include <qheader.h> |
@@ -22,45 +24,11 @@ | |||
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 | |||
31 | QToolButton* newPageButton = new QToolButton(this); | ||
32 | newPageButton->setIconSet(Resource::loadIconSet("new")); | ||
33 | newPageButton->setAutoRaise(true); | ||
34 | |||
35 | QToolButton* clearPageButton = new QToolButton(this); | ||
36 | clearPageButton->setIconSet(Resource::loadIconSet("drawpad/clear")); | ||
37 | clearPageButton->setAutoRaise(true); | ||
38 | |||
39 | QToolButton* deletePageButton = new QToolButton(this); | ||
40 | deletePageButton->setIconSet(Resource::loadIconSet("trash")); | ||
41 | deletePageButton->setAutoRaise(true); | ||
42 | |||
43 | QToolButton* movePageUpButton = new QToolButton(this); | ||
44 | movePageUpButton->setIconSet(Resource::loadIconSet("up")); | ||
45 | movePageUpButton->setAutoRaise(true); | ||
46 | |||
47 | QToolButton* movePageDownButton = new QToolButton(this); | ||
48 | movePageDownButton->setIconSet(Resource::loadIconSet("down")); | ||
49 | movePageDownButton->setAutoRaise(true); | ||
50 | |||
51 | m_pListView = new QListView(this); | ||
52 | |||
53 | m_pListView->header()->hide(); | ||
54 | m_pListView->setAllColumnsShowFocus(true); | ||
55 | |||
56 | m_pListView->addColumn(tr("Thumbnail")); | ||
57 | m_pListView->addColumn(tr("Information")); | ||
58 | |||
59 | m_pListView->setColumnAlignment(0, Qt::AlignHCenter | Qt::AlignVCenter); | ||
60 | m_pListView->setColumnAlignment(1, Qt::AlignTop); | ||
61 | 32 | ||
62 | QListIterator<Page> iterator(pages); | 33 | QImage image = m_pPage->convertToImage(); |
63 | |||
64 | for (; iterator.current(); ++iterator) { | ||
65 | QImage image = iterator.current()->convertToImage(); | ||
66 | 34 | ||
@@ -88,3 +56,3 @@ ThumbnailView::ThumbnailView(QList<Page> pages, QWidget* parent, const char* nam | |||
88 | 56 | ||
89 | pixmap.fill(colorGroup().mid()); | 57 | pixmap.fill(listView()->colorGroup().mid()); |
90 | bitBlt(&pixmap, (pixmap.width() - previewPixmap.width()) / 2, | 58 | bitBlt(&pixmap, (pixmap.width() - previewPixmap.width()) / 2, |
@@ -92,6 +60,100 @@ ThumbnailView::ThumbnailView(QList<Page> pages, QWidget* parent, const char* nam | |||
92 | 60 | ||
93 | QListViewItem* item = new QListViewItem(m_pListView); | 61 | setPixmap(0, pixmap); |
94 | item->setPixmap(0, pixmap); | 62 | } |
63 | |||
64 | PageListViewItem::~PageListViewItem() | ||
65 | { | ||
66 | } | ||
67 | |||
68 | Page* PageListViewItem::page() const | ||
69 | { | ||
70 | return m_pPage; | ||
71 | } | ||
72 | |||
73 | PageListView::PageListView(DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name) | ||
74 | : QListView(parent, name) | ||
75 | { | ||
76 | m_pDrawPadCanvas = drawPadCanvas; | ||
77 | |||
78 | header()->hide(); | ||
79 | setVScrollBarMode(QScrollView::AlwaysOn); | ||
80 | setAllColumnsShowFocus(true); | ||
81 | |||
82 | addColumn(tr("Thumbnail")); | ||
83 | addColumn(tr("Information")); | ||
84 | |||
85 | updateView(); | ||
86 | } | ||
87 | |||
88 | PageListView::~PageListView() | ||
89 | { | ||
90 | } | ||
91 | |||
92 | void PageListView::updateView() | ||
93 | { | ||
94 | clear(); | ||
95 | |||
96 | if (m_pDrawPadCanvas) { | ||
97 | QList<Page> pageList = m_pDrawPadCanvas->pages(); | ||
98 | QListIterator<Page> it(pageList); | ||
99 | |||
100 | for (; it.current(); ++it) { | ||
101 | new PageListViewItem(it.current(), this); | ||
102 | } | ||
103 | } | ||
95 | } | 104 | } |
96 | 105 | ||
106 | void PageListView::resizeEvent(QResizeEvent* e) | ||
107 | { | ||
108 | Q_UNUSED(e); | ||
109 | |||
110 | setColumnWidth(1, contentsRect().width() - columnWidth(0) - verticalScrollBar()->width()); | ||
111 | } | ||
112 | |||
113 | Page* PageListView::selected() const | ||
114 | { | ||
115 | Page* page; | ||
116 | |||
117 | PageListViewItem* item = (PageListViewItem*)selectedItem(); | ||
118 | |||
119 | if (item) { | ||
120 | page = item->page(); | ||
121 | } else { | ||
122 | page = NULL; | ||
123 | } | ||
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); |
@@ -107,3 +169,3 @@ ThumbnailView::ThumbnailView(QList<Page> pages, QWidget* parent, const char* nam | |||
107 | mainLayout->addLayout(buttonLayout); | 169 | mainLayout->addLayout(buttonLayout); |
108 | mainLayout->addWidget(m_pListView); | 170 | mainLayout->addWidget(m_pPageListView); |
109 | } | 171 | } |
@@ -112,10 +174,38 @@ 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(); |
118 | 181 | ||
119 | m_pListView->setColumnWidth(1, m_pListView->contentsRect().width() - m_pListView->columnWidth(0) | 182 | if (inLoop) { |
120 | - m_pListView->verticalScrollBar()->width()); | 183 | inLoop = false; |
184 | qApp->exit_loop(); | ||
185 | } | ||
186 | } | ||
187 | |||
188 | void ThumbnailView::exec() | ||
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 | } |