-rw-r--r-- | noncore/graphics/drawpad/drawpadcanvas.cpp | 13 | ||||
-rw-r--r-- | noncore/graphics/drawpad/drawpadcanvas.h | 1 | ||||
-rw-r--r-- | noncore/graphics/drawpad/thumbnailview.cpp | 27 | ||||
-rw-r--r-- | noncore/graphics/drawpad/thumbnailview.h | 2 |
4 files changed, 42 insertions, 1 deletions
diff --git a/noncore/graphics/drawpad/drawpadcanvas.cpp b/noncore/graphics/drawpad/drawpadcanvas.cpp index 252f4d5..0a1e9a5 100644 --- a/noncore/graphics/drawpad/drawpadcanvas.cpp +++ b/noncore/graphics/drawpad/drawpadcanvas.cpp | |||
@@ -328,4 +328,17 @@ uint DrawPadCanvas::pageCount() | |||
328 | } | 328 | } |
329 | 329 | ||
330 | void DrawPadCanvas::selectPage(Page* page) | ||
331 | { | ||
332 | m_pages.findRef(page); | ||
333 | m_pageBackups.clear(); | ||
334 | m_pageBackups.append(new Page(*(m_pages.current()))); | ||
335 | |||
336 | resizeContents(m_pages.current()->width(), m_pages.current()->height()); | ||
337 | viewport()->update(); | ||
338 | |||
339 | emit pagesChanged(); | ||
340 | emit pageBackupsChanged(); | ||
341 | } | ||
342 | |||
330 | void DrawPadCanvas::backupPage() | 343 | void DrawPadCanvas::backupPage() |
331 | { | 344 | { |
diff --git a/noncore/graphics/drawpad/drawpadcanvas.h b/noncore/graphics/drawpad/drawpadcanvas.h index 47763f9..cf2d904 100644 --- a/noncore/graphics/drawpad/drawpadcanvas.h +++ b/noncore/graphics/drawpad/drawpadcanvas.h | |||
@@ -48,4 +48,5 @@ public: | |||
48 | uint pageCount(); | 48 | uint pageCount(); |
49 | 49 | ||
50 | void selectPage(Page* page); | ||
50 | void backupPage(); | 51 | void backupPage(); |
51 | 52 | ||
diff --git a/noncore/graphics/drawpad/thumbnailview.cpp b/noncore/graphics/drawpad/thumbnailview.cpp index 1754ce9..476b7b9 100644 --- a/noncore/graphics/drawpad/thumbnailview.cpp +++ b/noncore/graphics/drawpad/thumbnailview.cpp | |||
@@ -101,4 +101,7 @@ void PageListView::updateView() | |||
101 | new PageListViewItem(it.current(), this); | 101 | new PageListViewItem(it.current(), this); |
102 | } | 102 | } |
103 | |||
104 | setSorting(0, false); | ||
105 | select(m_pDrawPadCanvas->currentPage()); | ||
103 | } | 106 | } |
104 | } | 107 | } |
@@ -111,4 +114,19 @@ void PageListView::resizeEvent(QResizeEvent* e) | |||
111 | } | 114 | } |
112 | 115 | ||
116 | void PageListView::select(Page* page) | ||
117 | { | ||
118 | PageListViewItem* item = (PageListViewItem*)firstChild(); | ||
119 | |||
120 | while (item) { | ||
121 | if (item->page() == page) { | ||
122 | setSelected(item, true); | ||
123 | ensureItemVisible(item); | ||
124 | break; | ||
125 | } | ||
126 | |||
127 | item = (PageListViewItem*)(item->nextSibling()); | ||
128 | } | ||
129 | } | ||
130 | |||
113 | Page* PageListView::selected() const | 131 | Page* PageListView::selected() const |
114 | { | 132 | { |
@@ -126,5 +144,4 @@ Page* PageListView::selected() const | |||
126 | } | 144 | } |
127 | 145 | ||
128 | |||
129 | ThumbnailView::ThumbnailView(DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name) | 146 | ThumbnailView::ThumbnailView(DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name) |
130 | : QWidget(parent, name, Qt::WType_Modal | Qt::WType_TopLevel) | 147 | : QWidget(parent, name, Qt::WType_Modal | Qt::WType_TopLevel) |
@@ -146,4 +163,5 @@ ThumbnailView::ThumbnailView(DrawPadCanvas* drawPadCanvas, QWidget* parent, cons | |||
146 | deletePageButton->setIconSet(Resource::loadIconSet("trash")); | 163 | deletePageButton->setIconSet(Resource::loadIconSet("trash")); |
147 | deletePageButton->setAutoRaise(true); | 164 | deletePageButton->setAutoRaise(true); |
165 | connect(deletePageButton, SIGNAL(clicked()), this, SLOT(deletePage())); | ||
148 | 166 | ||
149 | QToolButton* movePageUpButton = new QToolButton(this); | 167 | QToolButton* movePageUpButton = new QToolButton(this); |
@@ -156,4 +174,5 @@ ThumbnailView::ThumbnailView(DrawPadCanvas* drawPadCanvas, QWidget* parent, cons | |||
156 | 174 | ||
157 | m_pPageListView = new PageListView(m_pDrawPadCanvas, this); | 175 | m_pPageListView = new PageListView(m_pDrawPadCanvas, this); |
176 | connect(m_pPageListView, SIGNAL(selectionChanged()), this, SLOT(changePage())); | ||
158 | 177 | ||
159 | QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); | 178 | QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); |
@@ -208,4 +227,10 @@ void ThumbnailView::deletePage() | |||
208 | if (messageBox.exec() == QMessageBox::Yes) { | 227 | if (messageBox.exec() == QMessageBox::Yes) { |
209 | m_pDrawPadCanvas->deletePage(); | 228 | m_pDrawPadCanvas->deletePage(); |
229 | m_pPageListView->updateView(); | ||
210 | } | 230 | } |
211 | } | 231 | } |
232 | |||
233 | void ThumbnailView::changePage() | ||
234 | { | ||
235 | m_pDrawPadCanvas->selectPage(m_pPageListView->selected()); | ||
236 | } | ||
diff --git a/noncore/graphics/drawpad/thumbnailview.h b/noncore/graphics/drawpad/thumbnailview.h index ae97ff1..9417655 100644 --- a/noncore/graphics/drawpad/thumbnailview.h +++ b/noncore/graphics/drawpad/thumbnailview.h | |||
@@ -41,4 +41,5 @@ public: | |||
41 | void updateView(); | 41 | void updateView(); |
42 | 42 | ||
43 | void select(Page* page); | ||
43 | Page* selected() const; | 44 | Page* selected() const; |
44 | 45 | ||
@@ -63,4 +64,5 @@ public: | |||
63 | public slots: | 64 | public slots: |
64 | void deletePage(); | 65 | void deletePage(); |
66 | void changePage(); | ||
65 | 67 | ||
66 | private: | 68 | private: |