summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Heinecke <[email protected]>2018-02-21 23:57:01 +0100
committerAlbert Astals Cid <[email protected]>2018-02-22 00:13:25 +0100
commitf0a80a675f3596ea2b6e89042982d3a8a348a2a3 (patch)
tree8f1582b7c0c25999067b960c000407b1ffa1dab4
parent5f05e4a1fccee394ac527b0eb87893fc1080c441 (diff)
Recalculate forms after command form changes
Summary: notifyFormChanged is called by documentcommands when Form fields are changed. E.g. by Undo / Redo. We need to recalculate after such changes. Test Plan: Tested with simple_calculate example. Run the unit test with the added line commented out and it failed, with the added line it passes. Reviewers: #okular Subscribers: aacid, ltoscano Tags: #okular Maniphest Tasks: T7805 Differential Revision: https://phabricator.kde.org/D10547
-rw-r--r--autotests/calculatetexttest.cpp9
-rw-r--r--core/document.cpp1
2 files changed, 10 insertions, 0 deletions
diff --git a/autotests/calculatetexttest.cpp b/autotests/calculatetexttest.cpp
index d313367..f105dab 100644
--- a/autotests/calculatetexttest.cpp
+++ b/autotests/calculatetexttest.cpp
@@ -91,6 +91,15 @@ void CalculateTextTest::testSimpleCalculate()
// Test that updating the field also worked with sum
QCOMPARE (fields[QStringLiteral ("Sum")]->text(), QStringLiteral( "40" ));
+
+ // Test that undo / redo works
+ QVERIFY( m_document->canUndo() );
+ m_document->undo();
+ QCOMPARE( fields[QStringLiteral ("Sum")]->text(), QStringLiteral( "60" ) );
+
+ QVERIFY( m_document->canRedo() );
+ m_document->redo();
+ QCOMPARE( fields[QStringLiteral ("Sum")]->text(), QStringLiteral( "40" ) );
}
QTEST_MAIN( CalculateTextTest )
diff --git a/core/document.cpp b/core/document.cpp
index 33ac210..571099d 100644
--- a/core/document.cpp
+++ b/core/document.cpp
@@ -3406,6 +3406,7 @@ void DocumentPrivate::notifyAnnotationChanges( int page )
void DocumentPrivate::notifyFormChanges( int /*page*/ )
{
+ recalculateForms();
}
void Document::addPageAnnotation( int page, Annotation * annotation )