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 @@ -97,22 +97,40 @@ void PageListView::updateView() QList<Page> pageList = m_pDrawPadCanvas->pages(); QListIterator<Page> it(pageList); for (; it.current(); ++it) { new PageListViewItem(it.current(), this); } + + setSorting(0, false); + select(m_pDrawPadCanvas->currentPage()); } } void PageListView::resizeEvent(QResizeEvent* e) { Q_UNUSED(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; PageListViewItem* item = (PageListViewItem*)selectedItem(); @@ -122,13 +140,12 @@ Page* PageListView::selected() const page = NULL; } return page; } - ThumbnailView::ThumbnailView(DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name) : QWidget(parent, name, Qt::WType_Modal | Qt::WType_TopLevel) { inLoop = false; m_pDrawPadCanvas = drawPadCanvas; @@ -142,22 +159,24 @@ ThumbnailView::ThumbnailView(DrawPadCanvas* drawPadCanvas, QWidget* parent, cons clearPageButton->setIconSet(Resource::loadIconSet("drawpad/clear")); clearPageButton->setAutoRaise(true); 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")); movePageUpButton->setAutoRaise(true); QToolButton* movePageDownButton = new QToolButton(this); movePageDownButton->setIconSet(Resource::loadIconSet("down")); 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); buttonLayout->addWidget(newPageButton); buttonLayout->addWidget(clearPageButton); @@ -204,8 +223,14 @@ void ThumbnailView::deletePage() messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); messageBox.setButtonText(QMessageBox::No, tr("No")); if (messageBox.exec() == QMessageBox::Yes) { m_pDrawPadCanvas->deletePage(); + m_pPageListView->updateView(); } } + +void ThumbnailView::changePage() +{ + m_pDrawPadCanvas->selectPage(m_pPageListView->selected()); +} |