summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/graphics/drawpad/drawpadcanvas.cpp18
-rw-r--r--noncore/graphics/drawpad/drawpadcanvas.h2
-rw-r--r--noncore/graphics/drawpad/thumbnailview.cpp43
-rw-r--r--noncore/graphics/drawpad/thumbnailview.h9
4 files changed, 64 insertions, 8 deletions
diff --git a/noncore/graphics/drawpad/drawpadcanvas.cpp b/noncore/graphics/drawpad/drawpadcanvas.cpp
index c23ee34..bcb6877 100644
--- a/noncore/graphics/drawpad/drawpadcanvas.cpp
+++ b/noncore/graphics/drawpad/drawpadcanvas.cpp
@@ -416,12 +416,30 @@ void DrawPadCanvas::deletePage()
viewport()->update();
emit pagesChanged();
emit pageBackupsChanged();
}
+void DrawPadCanvas::movePageUp()
+{
+ int index = m_pages.at();
+ Page* page = m_pages.take();
+ m_pages.insert(index - 1, page);
+
+ emit pagesChanged();
+}
+
+void DrawPadCanvas::movePageDown()
+{
+ int index = m_pages.at();
+ Page* page = m_pages.take();
+ m_pages.insert(index + 1, page);
+
+ emit pagesChanged();
+}
+
bool DrawPadCanvas::undoEnabled()
{
return (m_pageBackups.current() != m_pageBackups.getFirst());
}
bool DrawPadCanvas::redoEnabled()
diff --git a/noncore/graphics/drawpad/drawpadcanvas.h b/noncore/graphics/drawpad/drawpadcanvas.h
index d74d425..39cf752 100644
--- a/noncore/graphics/drawpad/drawpadcanvas.h
+++ b/noncore/graphics/drawpad/drawpadcanvas.h
@@ -52,12 +52,14 @@ public:
public slots:
void deleteAll();
void newPage(uint width, uint height, const QColor& color);
void clearPage();
void deletePage();
+ void movePageUp();
+ void movePageDown();
void undo();
void redo();
void goFirstPage();
void goPreviousPage();
diff --git a/noncore/graphics/drawpad/thumbnailview.cpp b/noncore/graphics/drawpad/thumbnailview.cpp
index 0c7934e..428e008 100644
--- a/noncore/graphics/drawpad/thumbnailview.cpp
+++ b/noncore/graphics/drawpad/thumbnailview.cpp
@@ -167,42 +167,52 @@ ThumbnailView::ThumbnailView(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas, QWi
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);
+ m_pMovePageUpButton = new QToolButton(this);
+ m_pMovePageUpButton->setIconSet(Resource::loadIconSet("up"));
+ m_pMovePageUpButton->setAutoRaise(true);
+ connect(m_pMovePageUpButton, SIGNAL(clicked()), this, SLOT(movePageUp()));
- QToolButton* movePageDownButton = new QToolButton(this);
- movePageDownButton->setIconSet(Resource::loadIconSet("down"));
- movePageDownButton->setAutoRaise(true);
+ m_pMovePageDownButton = new QToolButton(this);
+ m_pMovePageDownButton->setIconSet(Resource::loadIconSet("down"));
+ m_pMovePageDownButton->setAutoRaise(true);
+ connect(m_pMovePageDownButton, SIGNAL(clicked()), this, SLOT(movePageDown()));
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);
+ buttonLayout->addWidget(m_pMovePageUpButton);
+ buttonLayout->addWidget(m_pMovePageDownButton);
mainLayout->addLayout(buttonLayout);
mainLayout->addWidget(m_pPageListView);
+
+ updateView();
}
ThumbnailView::~ThumbnailView()
{
hide();
}
+void ThumbnailView::updateView()
+{
+ m_pMovePageUpButton->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled());
+ m_pMovePageDownButton->setEnabled(m_pDrawPadCanvas->goNextPageEnabled());
+}
+
void ThumbnailView::hide()
{
QWidget::hide();
if (inLoop) {
inLoop = false;
@@ -228,12 +238,13 @@ void ThumbnailView::newPage()
m_pDrawPad->brush().color(), this);
if (newPageDialog.exec() == QDialog::Accepted) {
m_pDrawPadCanvas->newPage(newPageDialog.selectedWidth(), newPageDialog.selectedHeight(),
newPageDialog.selectedColor());
m_pPageListView->updateView();
+ updateView();
}
}
void ThumbnailView::clearPage()
{
QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe selected page?"),
@@ -260,13 +271,29 @@ 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();
+ updateView();
+ }
+}
+
+void ThumbnailView::movePageUp()
+{
+ m_pDrawPadCanvas->movePageUp();
+ m_pPageListView->updateView();
+ updateView();
}
+
+void ThumbnailView::movePageDown()
+{
+ m_pDrawPadCanvas->movePageDown();
+ m_pPageListView->updateView();
+ updateView();
}
void ThumbnailView::changePage()
{
m_pDrawPadCanvas->selectPage(m_pPageListView->selected());
+ updateView();
}
diff --git a/noncore/graphics/drawpad/thumbnailview.h b/noncore/graphics/drawpad/thumbnailview.h
index 1fdb168..eb748fa 100644
--- a/noncore/graphics/drawpad/thumbnailview.h
+++ b/noncore/graphics/drawpad/thumbnailview.h
@@ -18,12 +18,14 @@
#include <qlistview.h>
class DrawPad;
class DrawPadCanvas;
class Page;
+class QToolButton;
+
class PageListViewItem : public QListViewItem
{
public:
PageListViewItem(Page* page, QListView* parent);
~PageListViewItem();
@@ -56,25 +58,32 @@ class ThumbnailView : public QWidget
Q_OBJECT
public:
ThumbnailView(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas, QWidget* parent = 0, const char* name = 0);
~ThumbnailView();
+ void updateView();
+
void hide();
void exec();
public slots:
void newPage();
void clearPage();
void deletePage();
+ void movePageUp();
+ void movePageDown();
void changePage();
private:
bool inLoop;
DrawPad* m_pDrawPad;
DrawPadCanvas* m_pDrawPadCanvas;
+ QToolButton* m_pMovePageUpButton;
+ QToolButton* m_pMovePageDownButton;
+
PageListView* m_pPageListView;
};
#endif // THUMBNAILVIEW_H