summaryrefslogtreecommitdiff
authorleseb <leseb>2002-06-09 16:06:21 (UTC)
committer leseb <leseb>2002-06-09 16:06:21 (UTC)
commitb59a64c90deba66180e3a778d411296e984f64ea (patch) (unidiff)
tree88ef0767602dd174f5911719ffb346a4fcf7420f
parent29c0d188836a59bff1fbcd1d338fcd3334c0f1f5 (diff)
downloadopie-b59a64c90deba66180e3a778d411296e984f64ea.zip
opie-b59a64c90deba66180e3a778d411296e984f64ea.tar.gz
opie-b59a64c90deba66180e3a778d411296e984f64ea.tar.bz2
Changing page order now works in thumbnail view
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/drawpad/drawpadcanvas.cpp18
-rw-r--r--noncore/graphics/drawpad/drawpadcanvas.h2
-rw-r--r--noncore/graphics/drawpad/thumbnailview.cpp43
-rw-r--r--noncore/graphics/drawpad/thumbnailview.h11
4 files changed, 65 insertions, 9 deletions
diff --git a/noncore/graphics/drawpad/drawpadcanvas.cpp b/noncore/graphics/drawpad/drawpadcanvas.cpp
index c23ee34..bcb6877 100644
--- a/noncore/graphics/drawpad/drawpadcanvas.cpp
+++ b/noncore/graphics/drawpad/drawpadcanvas.cpp
@@ -414,16 +414,34 @@ void DrawPadCanvas::deletePage()
414 414
415 resizeContents(m_pages.current()->width(), m_pages.current()->height()); 415 resizeContents(m_pages.current()->width(), m_pages.current()->height());
416 viewport()->update(); 416 viewport()->update();
417 417
418 emit pagesChanged(); 418 emit pagesChanged();
419 emit pageBackupsChanged(); 419 emit pageBackupsChanged();
420} 420}
421 421
422void DrawPadCanvas::movePageUp()
423{
424 int index = m_pages.at();
425 Page* page = m_pages.take();
426 m_pages.insert(index - 1, page);
427
428 emit pagesChanged();
429}
430
431void DrawPadCanvas::movePageDown()
432{
433 int index = m_pages.at();
434 Page* page = m_pages.take();
435 m_pages.insert(index + 1, page);
436
437 emit pagesChanged();
438}
439
422bool DrawPadCanvas::undoEnabled() 440bool DrawPadCanvas::undoEnabled()
423{ 441{
424 return (m_pageBackups.current() != m_pageBackups.getFirst()); 442 return (m_pageBackups.current() != m_pageBackups.getFirst());
425} 443}
426 444
427bool DrawPadCanvas::redoEnabled() 445bool DrawPadCanvas::redoEnabled()
428{ 446{
429 return (m_pageBackups.current() != m_pageBackups.getLast()); 447 return (m_pageBackups.current() != m_pageBackups.getLast());
diff --git a/noncore/graphics/drawpad/drawpadcanvas.h b/noncore/graphics/drawpad/drawpadcanvas.h
index d74d425..39cf752 100644
--- a/noncore/graphics/drawpad/drawpadcanvas.h
+++ b/noncore/graphics/drawpad/drawpadcanvas.h
@@ -50,16 +50,18 @@ public:
50 void selectPage(Page* page); 50 void selectPage(Page* page);
51 void backupPage(); 51 void backupPage();
52 52
53public slots: 53public slots:
54 void deleteAll(); 54 void deleteAll();
55 void newPage(uint width, uint height, const QColor& color); 55 void newPage(uint width, uint height, const QColor& color);
56 void clearPage(); 56 void clearPage();
57 void deletePage(); 57 void deletePage();
58 void movePageUp();
59 void movePageDown();
58 60
59 void undo(); 61 void undo();
60 void redo(); 62 void redo();
61 63
62 void goFirstPage(); 64 void goFirstPage();
63 void goPreviousPage(); 65 void goPreviousPage();
64 void goNextPage(); 66 void goNextPage();
65 void goLastPage(); 67 void goLastPage();
diff --git a/noncore/graphics/drawpad/thumbnailview.cpp b/noncore/graphics/drawpad/thumbnailview.cpp
index 0c7934e..428e008 100644
--- a/noncore/graphics/drawpad/thumbnailview.cpp
+++ b/noncore/graphics/drawpad/thumbnailview.cpp
@@ -165,46 +165,56 @@ ThumbnailView::ThumbnailView(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas, QWi
165 clearPageButton->setAutoRaise(true); 165 clearPageButton->setAutoRaise(true);
166 connect(clearPageButton, SIGNAL(clicked()), this, SLOT(clearPage())); 166 connect(clearPageButton, SIGNAL(clicked()), this, SLOT(clearPage()));
167 167
168 QToolButton* deletePageButton = new QToolButton(this); 168 QToolButton* deletePageButton = new QToolButton(this);
169 deletePageButton->setIconSet(Resource::loadIconSet("trash")); 169 deletePageButton->setIconSet(Resource::loadIconSet("trash"));
170 deletePageButton->setAutoRaise(true); 170 deletePageButton->setAutoRaise(true);
171 connect(deletePageButton, SIGNAL(clicked()), this, SLOT(deletePage())); 171 connect(deletePageButton, SIGNAL(clicked()), this, SLOT(deletePage()));
172 172
173 QToolButton* movePageUpButton = new QToolButton(this); 173 m_pMovePageUpButton = new QToolButton(this);
174 movePageUpButton->setIconSet(Resource::loadIconSet("up")); 174 m_pMovePageUpButton->setIconSet(Resource::loadIconSet("up"));
175 movePageUpButton->setAutoRaise(true); 175 m_pMovePageUpButton->setAutoRaise(true);
176 connect(m_pMovePageUpButton, SIGNAL(clicked()), this, SLOT(movePageUp()));
176 177
177 QToolButton* movePageDownButton = new QToolButton(this); 178 m_pMovePageDownButton = new QToolButton(this);
178 movePageDownButton->setIconSet(Resource::loadIconSet("down")); 179 m_pMovePageDownButton->setIconSet(Resource::loadIconSet("down"));
179 movePageDownButton->setAutoRaise(true); 180 m_pMovePageDownButton->setAutoRaise(true);
181 connect(m_pMovePageDownButton, SIGNAL(clicked()), this, SLOT(movePageDown()));
180 182
181 m_pPageListView = new PageListView(m_pDrawPadCanvas, this); 183 m_pPageListView = new PageListView(m_pDrawPadCanvas, this);
182 connect(m_pPageListView, SIGNAL(selectionChanged()), this, SLOT(changePage())); 184 connect(m_pPageListView, SIGNAL(selectionChanged()), this, SLOT(changePage()));
183 185
184 QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); 186 QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4);
185 QHBoxLayout* buttonLayout = new QHBoxLayout(0); 187 QHBoxLayout* buttonLayout = new QHBoxLayout(0);
186 188
187 buttonLayout->addWidget(newPageButton); 189 buttonLayout->addWidget(newPageButton);
188 buttonLayout->addWidget(clearPageButton); 190 buttonLayout->addWidget(clearPageButton);
189 buttonLayout->addWidget(deletePageButton); 191 buttonLayout->addWidget(deletePageButton);
190 buttonLayout->addStretch(); 192 buttonLayout->addStretch();
191 buttonLayout->addWidget(movePageUpButton); 193 buttonLayout->addWidget(m_pMovePageUpButton);
192 buttonLayout->addWidget(movePageDownButton); 194 buttonLayout->addWidget(m_pMovePageDownButton);
193 195
194 mainLayout->addLayout(buttonLayout); 196 mainLayout->addLayout(buttonLayout);
195 mainLayout->addWidget(m_pPageListView); 197 mainLayout->addWidget(m_pPageListView);
198
199 updateView();
196} 200}
197 201
198ThumbnailView::~ThumbnailView() 202ThumbnailView::~ThumbnailView()
199{ 203{
200 hide(); 204 hide();
201} 205}
202 206
207void ThumbnailView::updateView()
208{
209 m_pMovePageUpButton->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled());
210 m_pMovePageDownButton->setEnabled(m_pDrawPadCanvas->goNextPageEnabled());
211}
212
203void ThumbnailView::hide() 213void ThumbnailView::hide()
204{ 214{
205 QWidget::hide(); 215 QWidget::hide();
206 216
207 if (inLoop) { 217 if (inLoop) {
208 inLoop = false; 218 inLoop = false;
209 qApp->exit_loop(); 219 qApp->exit_loop();
210 } 220 }
@@ -226,16 +236,17 @@ void ThumbnailView::newPage()
226 236
227 NewPageDialog newPageDialog(rect.width(), rect.height(), m_pDrawPad->pen().color(), 237 NewPageDialog newPageDialog(rect.width(), rect.height(), m_pDrawPad->pen().color(),
228 m_pDrawPad->brush().color(), this); 238 m_pDrawPad->brush().color(), this);
229 239
230 if (newPageDialog.exec() == QDialog::Accepted) { 240 if (newPageDialog.exec() == QDialog::Accepted) {
231 m_pDrawPadCanvas->newPage(newPageDialog.selectedWidth(), newPageDialog.selectedHeight(), 241 m_pDrawPadCanvas->newPage(newPageDialog.selectedWidth(), newPageDialog.selectedHeight(),
232 newPageDialog.selectedColor()); 242 newPageDialog.selectedColor());
233 m_pPageListView->updateView(); 243 m_pPageListView->updateView();
244 updateView();
234 } 245 }
235} 246}
236 247
237void ThumbnailView::clearPage() 248void ThumbnailView::clearPage()
238{ 249{
239 QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe selected page?"), 250 QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe selected page?"),
240 QMessageBox::Information, QMessageBox::Yes, 251 QMessageBox::Information, QMessageBox::Yes,
241 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, 252 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default,
@@ -258,15 +269,31 @@ void ThumbnailView::deletePage()
258 QMessageBox::NoButton, this); 269 QMessageBox::NoButton, this);
259 270
260 messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); 271 messageBox.setButtonText(QMessageBox::Yes, tr("Yes"));
261 messageBox.setButtonText(QMessageBox::No, tr("No")); 272 messageBox.setButtonText(QMessageBox::No, tr("No"));
262 273
263 if (messageBox.exec() == QMessageBox::Yes) { 274 if (messageBox.exec() == QMessageBox::Yes) {
264 m_pDrawPadCanvas->deletePage(); 275 m_pDrawPadCanvas->deletePage();
265 m_pPageListView->updateView(); 276 m_pPageListView->updateView();
277 updateView();
266 } 278 }
267} 279}
268 280
281void ThumbnailView::movePageUp()
282{
283 m_pDrawPadCanvas->movePageUp();
284 m_pPageListView->updateView();
285 updateView();
286}
287
288void ThumbnailView::movePageDown()
289{
290 m_pDrawPadCanvas->movePageDown();
291 m_pPageListView->updateView();
292 updateView();
293}
294
269void ThumbnailView::changePage() 295void ThumbnailView::changePage()
270{ 296{
271 m_pDrawPadCanvas->selectPage(m_pPageListView->selected()); 297 m_pDrawPadCanvas->selectPage(m_pPageListView->selected());
298 updateView();
272} 299}
diff --git a/noncore/graphics/drawpad/thumbnailview.h b/noncore/graphics/drawpad/thumbnailview.h
index 1fdb168..eb748fa 100644
--- a/noncore/graphics/drawpad/thumbnailview.h
+++ b/noncore/graphics/drawpad/thumbnailview.h
@@ -16,16 +16,18 @@
16 16
17#include <qwidget.h> 17#include <qwidget.h>
18#include <qlistview.h> 18#include <qlistview.h>
19 19
20class DrawPad; 20class DrawPad;
21class DrawPadCanvas; 21class DrawPadCanvas;
22class Page; 22class Page;
23 23
24class QToolButton;
25
24class PageListViewItem : public QListViewItem 26class PageListViewItem : public QListViewItem
25{ 27{
26public: 28public:
27 PageListViewItem(Page* page, QListView* parent); 29 PageListViewItem(Page* page, QListView* parent);
28 ~PageListViewItem(); 30 ~PageListViewItem();
29 31
30 Page* page() const; 32 Page* page() const;
31 33
@@ -53,28 +55,35 @@ private:
53 55
54class ThumbnailView : public QWidget 56class ThumbnailView : public QWidget
55{ 57{
56 Q_OBJECT 58 Q_OBJECT
57 59
58public: 60public:
59 ThumbnailView(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas, QWidget* parent = 0, const char* name = 0); 61 ThumbnailView(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas, QWidget* parent = 0, const char* name = 0);
60 ~ThumbnailView(); 62 ~ThumbnailView();
61 63
64 void updateView();
65
62 void hide(); 66 void hide();
63 void exec(); 67 void exec();
64 68
65public slots: 69public slots:
66 void newPage(); 70 void newPage();
67 void clearPage(); 71 void clearPage();
68 void deletePage(); 72 void deletePage();
73 void movePageUp();
74 void movePageDown();
69 void changePage(); 75 void changePage();
70 76
71private: 77private:
72 bool inLoop; 78 bool inLoop;
73 79
74 DrawPad* m_pDrawPad; 80 DrawPad* m_pDrawPad;
75 DrawPadCanvas* m_pDrawPadCanvas; 81 DrawPadCanvas* m_pDrawPadCanvas;
76 82
83 QToolButton* m_pMovePageUpButton;
84 QToolButton* m_pMovePageDownButton;
85
77 PageListView* m_pPageListView; 86 PageListView* m_pPageListView;
78}; 87};
79 88
80#endif // THUMBNAILVIEW_H 89#endif // THUMBNAILVIEW_H