-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 @@ -327,6 +327,19 @@ uint DrawPadCanvas::pageCount() return m_pages.count(); } +void DrawPadCanvas::selectPage(Page* page) +{ + m_pages.findRef(page); + m_pageBackups.clear(); + m_pageBackups.append(new Page(*(m_pages.current()))); + + resizeContents(m_pages.current()->width(), m_pages.current()->height()); + viewport()->update(); + + emit pagesChanged(); + emit pageBackupsChanged(); +} + void DrawPadCanvas::backupPage() { QPixmap* currentBackup = m_pageBackups.current(); 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 @@ -47,6 +47,7 @@ public: uint pagePosition(); uint pageCount(); + void selectPage(Page* page); void backupPage(); public slots: 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 @@ -100,6 +100,9 @@ void PageListView::updateView() for (; it.current(); ++it) { new PageListViewItem(it.current(), this); } + + setSorting(0, false); + select(m_pDrawPadCanvas->currentPage()); } } @@ -110,6 +113,21 @@ void PageListView::resizeEvent(QResizeEvent* e) setColumnWidth(1, contentsRect().width() - columnWidth(0) - verticalScrollBar()->width()); } +void PageListView::select(Page* page) +{ + PageListViewItem* item = (PageListViewItem*)firstChild(); + + while (item) { + if (item->page() == page) { + setSelected(item, true); + ensureItemVisible(item); + break; + } + + item = (PageListViewItem*)(item->nextSibling()); + } +} + Page* PageListView::selected() const { Page* page; @@ -125,7 +143,6 @@ Page* PageListView::selected() const return page; } - ThumbnailView::ThumbnailView(DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name) : QWidget(parent, name, Qt::WType_Modal | Qt::WType_TopLevel) { @@ -145,6 +162,7 @@ ThumbnailView::ThumbnailView(DrawPadCanvas* drawPadCanvas, QWidget* parent, cons QToolButton* deletePageButton = new QToolButton(this); deletePageButton->setIconSet(Resource::loadIconSet("trash")); deletePageButton->setAutoRaise(true); + connect(deletePageButton, SIGNAL(clicked()), this, SLOT(deletePage())); QToolButton* movePageUpButton = new QToolButton(this); movePageUpButton->setIconSet(Resource::loadIconSet("up")); @@ -155,6 +173,7 @@ ThumbnailView::ThumbnailView(DrawPadCanvas* drawPadCanvas, QWidget* parent, cons movePageDownButton->setAutoRaise(true); m_pPageListView = new PageListView(m_pDrawPadCanvas, this); + connect(m_pPageListView, SIGNAL(selectionChanged()), this, SLOT(changePage())); QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); QHBoxLayout* buttonLayout = new QHBoxLayout(0); @@ -207,5 +226,11 @@ void ThumbnailView::deletePage() if (messageBox.exec() == QMessageBox::Yes) { m_pDrawPadCanvas->deletePage(); + m_pPageListView->updateView(); } } + +void ThumbnailView::changePage() +{ + m_pDrawPadCanvas->selectPage(m_pPageListView->selected()); +} 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 @@ -40,6 +40,7 @@ public: void updateView(); + void select(Page* page); Page* selected() const; protected: @@ -62,6 +63,7 @@ public: public slots: void deletePage(); + void changePage(); private: bool inLoop; |