author | leseb <leseb> | 2002-06-08 12:48:01 (UTC) |
---|---|---|
committer | leseb <leseb> | 2002-06-08 12:48:01 (UTC) |
commit | 571908b989a85d256767dc5b27bccdb717554bb5 (patch) (side-by-side diff) | |
tree | 09149eb5ed82683020ebd9372635d4d0233982a3 /noncore/graphics/drawpad/thumbnailview.cpp | |
parent | 9dcd598f9b815511cae884d26b18e3c8913b9fcf (diff) | |
download | opie-571908b989a85d256767dc5b27bccdb717554bb5.zip opie-571908b989a85d256767dc5b27bccdb717554bb5.tar.gz opie-571908b989a85d256767dc5b27bccdb717554bb5.tar.bz2 |
Selection and delete now work in thumbnail view
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 @@ -99,8 +99,11 @@ void PageListView::updateView() for (; it.current(); ++it) { new PageListViewItem(it.current(), this); } + + setSorting(0, false); + select(m_pDrawPadCanvas->currentPage()); } } void PageListView::resizeEvent(QResizeEvent* e) @@ -109,8 +112,23 @@ 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; @@ -124,9 +142,8 @@ Page* PageListView::selected() const return page; } - ThumbnailView::ThumbnailView(DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name) : QWidget(parent, name, Qt::WType_Modal | Qt::WType_TopLevel) { inLoop = false; @@ -144,8 +161,9 @@ 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")); movePageUpButton->setAutoRaise(true); @@ -154,8 +172,9 @@ ThumbnailView::ThumbnailView(DrawPadCanvas* drawPadCanvas, QWidget* parent, cons 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); @@ -206,6 +225,12 @@ void ThumbnailView::deletePage() 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()); +} |