summaryrefslogtreecommitdiff
authorleseb <leseb>2002-06-08 12:48:01 (UTC)
committer leseb <leseb>2002-06-08 12:48:01 (UTC)
commit571908b989a85d256767dc5b27bccdb717554bb5 (patch) (side-by-side diff)
tree09149eb5ed82683020ebd9372635d4d0233982a3
parent9dcd598f9b815511cae884d26b18e3c8913b9fcf (diff)
downloadopie-571908b989a85d256767dc5b27bccdb717554bb5.zip
opie-571908b989a85d256767dc5b27bccdb717554bb5.tar.gz
opie-571908b989a85d256767dc5b27bccdb717554bb5.tar.bz2
Selection and delete now work in thumbnail view
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/drawpad/drawpadcanvas.cpp13
-rw-r--r--noncore/graphics/drawpad/drawpadcanvas.h1
-rw-r--r--noncore/graphics/drawpad/thumbnailview.cpp27
-rw-r--r--noncore/graphics/drawpad/thumbnailview.h2
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
@@ -318,24 +318,37 @@ QList<Page> DrawPadCanvas::pages()
}
uint DrawPadCanvas::pagePosition()
{
return (m_pages.at() + 1);
}
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();
while (m_pageBackups.last() != currentBackup) {
m_pageBackups.removeLast();
}
while (m_pageBackups.count() >= (5 + 1)) {
m_pageBackups.removeFirst();
}
m_pageBackups.append(new Page(*(m_pages.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
@@ -38,24 +38,25 @@ public:
void exportPage(uint fromPage, uint toPage, const QString& name, const QString& format);
bool undoEnabled();
bool redoEnabled();
bool goPreviousPageEnabled();
bool goNextPageEnabled();
Page* currentPage();
QList<Page> pages();
uint pagePosition();
uint pageCount();
+ void selectPage(Page* page);
void backupPage();
public slots:
void deleteAll();
void newPage();
void clearPage();
void deletePage();
void undo();
void redo();
void goFirstPage();
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
@@ -91,79 +91,98 @@ PageListView::~PageListView()
void PageListView::updateView()
{
clear();
if (m_pDrawPadCanvas) {
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();
if (item) {
page = item->page();
} else {
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;
setCaption(tr("Thumbnail"));
QToolButton* newPageButton = new QToolButton(this);
newPageButton->setIconSet(Resource::loadIconSet("new"));
newPageButton->setAutoRaise(true);
QToolButton* clearPageButton = new QToolButton(this);
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);
buttonLayout->addWidget(deletePageButton);
buttonLayout->addStretch();
buttonLayout->addWidget(movePageUpButton);
buttonLayout->addWidget(movePageDownButton);
mainLayout->addLayout(buttonLayout);
@@ -198,14 +217,20 @@ void ThumbnailView::exec()
void ThumbnailView::deletePage()
{
QMessageBox messageBox(tr("Delete Page"), tr("Do you want to delete\nthe selected page?"),
QMessageBox::Information, QMessageBox::Yes,
QMessageBox::No | QMessageBox::Escape | QMessageBox::Default,
QMessageBox::NoButton, this);
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());
+}
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
@@ -31,43 +31,45 @@ public:
private:
Page* m_pPage;
};
class PageListView : public QListView
{
public:
PageListView(DrawPadCanvas* drawPadCanvas, QWidget* parent = 0, const char* name = 0);
~PageListView();
void updateView();
+ void select(Page* page);
Page* selected() const;
protected:
void resizeEvent(QResizeEvent* e);
private:
DrawPadCanvas* m_pDrawPadCanvas;
};
class ThumbnailView : public QWidget
{
Q_OBJECT
public:
ThumbnailView(DrawPadCanvas* drawPadCanvas, QWidget* parent = 0, const char* name = 0);
~ThumbnailView();
void hide();
void exec();
public slots:
void deletePage();
+ void changePage();
private:
bool inLoop;
DrawPadCanvas* m_pDrawPadCanvas;
PageListView* m_pPageListView;
};
#endif // THUMBNAILVIEW_H