[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice-devel
Subject:    [patch] enable/disable qaction delete_page
From:       Tony Wolf <wolf () os-forge ! net>
Date:       2008-08-08 14:51:47
Message-ID: 489C5D83.6080602 () os-forge ! net
[Download RAW message or body]

Hi all,

I haven't that much time but I hope it's okay that I submit patches 
sometimes.

So here is another patch. This lets the QAction "delete_page" be 
disabled if there is only one page available and enabled if there are 
more then one page.

I have split this into 2 patches for better review. One for the cpp-file 
and one for the header - of course they are very small.

Should I continue splitting patches or would it be better for you if I 
merge them?

Keep on the good work guys!

Regards

Tony

PS.: Seems to work, compiles and some tests were successful...

["action_delete_page_cpp.patch" (text/x-diff)]

diff --git a/kword/part/KWView.cpp b/kword/part/KWView.cpp
index c161e10..4be3173 100644
--- a/kword/part/KWView.cpp
+++ b/kword/part/KWView.cpp
@@ -264,6 +264,8 @@ void KWView::setupActions() {
     action = new QAction( i18n( "Delete Page" ), this);
     actionCollection()->addAction("delete_page", action);
     connect(action, SIGNAL(triggered()), this, SLOT( deletePage() ));
+    handleDeletePageAction(); //decide if we enable or disable this action
+    connect(m_document, SIGNAL( pageSetupChanged() ), this, SLOT( handleDeletePageAction() ));
 
     action = new QAction( i18n( "Formatting Characters" ), this);
     action->setCheckable(true);
@@ -1083,6 +1085,16 @@ void KWView::deletePage()
     m_document->removePage( m_currentPage->pageNumber() );
 }
 
+void KWView::handleDeletePageAction()
+{
+    Q_ASSERT(m_document);
+    
+    QAction *action = actionCollection()->action("delete_page");
+    if( action ) {
+        action->setEnabled( m_document->pageCount() > 1 );
+    }
+}
+
 void KWView::setShowFormattingChars(bool on) {
     KoCanvasResourceProvider *provider = m_canvas->resourceProvider();
     provider->setResource(KoText::ShowSpaces, on);

["action_delete_page_h.patch" (text/x-diff)]

diff --git a/kword/part/KWView.h b/kword/part/KWView.h
index 6251d19..bf91f8a 100644
--- a/kword/part/KWView.h
+++ b/kword/part/KWView.h
@@ -129,6 +129,8 @@ private slots:
     void viewGrid(bool);
     /// create a KWOutlineShape for the selected frame(s).
     void createCustomOutline();
+    /** decide if we enable or disable the action "delete_page" uppon m_document->page_count() */
+    void handleDeletePageAction();
 
 private:
     /// helper method for the raiseFrame/lowerFrame/bringToFront/sendToBack methods


_______________________________________________
koffice-devel mailing list
koffice-devel@kde.org
https://mail.kde.org/mailman/listinfo/koffice-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic