Diffstat (limited to 'noncore/graphics/drawpad/thumbnailview.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/graphics/drawpad/thumbnailview.cpp | 27 |
1 files changed, 26 insertions, 1 deletions
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() new PageListViewItem(it.current(), this); } + + setSorting(0, false); + select(m_pDrawPadCanvas->currentPage()); } } @@ -111,4 +114,19 @@ void PageListView::resizeEvent(QResizeEvent* e) } +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 { @@ -126,5 +144,4 @@ Page* PageListView::selected() const } - ThumbnailView::ThumbnailView(DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name) : QWidget(parent, name, Qt::WType_Modal | Qt::WType_TopLevel) @@ -146,4 +163,5 @@ ThumbnailView::ThumbnailView(DrawPadCanvas* drawPadCanvas, QWidget* parent, cons deletePageButton->setIconSet(Resource::loadIconSet("trash")); deletePageButton->setAutoRaise(true); + connect(deletePageButton, SIGNAL(clicked()), this, SLOT(deletePage())); QToolButton* movePageUpButton = new QToolButton(this); @@ -156,4 +174,5 @@ ThumbnailView::ThumbnailView(DrawPadCanvas* drawPadCanvas, QWidget* parent, cons m_pPageListView = new PageListView(m_pDrawPadCanvas, this); + connect(m_pPageListView, SIGNAL(selectionChanged()), this, SLOT(changePage())); QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); @@ -208,4 +227,10 @@ void ThumbnailView::deletePage() if (messageBox.exec() == QMessageBox::Yes) { m_pDrawPadCanvas->deletePage(); + m_pPageListView->updateView(); } } + +void ThumbnailView::changePage() +{ + m_pDrawPadCanvas->selectPage(m_pPageListView->selected()); +} |