From a5ad58de5a21d689bf400bbcef4031ce905a491d Mon Sep 17 00:00:00 2001 From: Kavindra Devi Palaraja <kavindra.palaraja@nokia.com> Date: Mon, 8 Jun 2009 17:17:20 +0200 Subject: [PATCH] Doc - fixing up Part 4 and some doc changes RevBy: TrustMe --- doc/addressbook-sdk.qdoc | 6 ++++ .../addressbook-sdk/part4/addressbook.cpp | 30 +++++-------------- 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/doc/addressbook-sdk.qdoc b/doc/addressbook-sdk.qdoc index 346d7ae4d4a..fc8bc7b29c0 100644 --- a/doc/addressbook-sdk.qdoc +++ b/doc/addressbook-sdk.qdoc @@ -696,6 +696,12 @@ in the same function, we avoid the possibility of the user interface getting "out of sync" with the internal state of the application. + To maintain consistency, we need to modify our \c addContact() and + \c cancel() functions respectively. Below is the code: + + \snippet examples/addressbook-sdk/part4/addressbook.cpp addContact + \dots + \snippet examples/addressbook-sdk/part4/addressbook.cpp cancel */ /*! diff --git a/doc/examples/addressbook-sdk/part4/addressbook.cpp b/doc/examples/addressbook-sdk/part4/addressbook.cpp index e403f9713fd..0c49404e9ae 100644 --- a/doc/examples/addressbook-sdk/part4/addressbook.cpp +++ b/doc/examples/addressbook-sdk/part4/addressbook.cpp @@ -68,6 +68,7 @@ AddressBook::~AddressBook() delete ui; } +//! [addContact] void AddressBook::addContact() { oldName = nameLine->text(); @@ -76,16 +77,9 @@ void AddressBook::addContact() nameLine->clear(); addressText->clear(); - nameLine->setReadOnly(false); - nameLine->setFocus(Qt::OtherFocusReason); - addressText->setReadOnly(false); - - addButton->setEnabled(false); - nextButton->setEnabled(false); - previousButton->setEnabled(false); - submitButton->show(); - cancelButton->show(); + updateInterface(AddingMode); } +//! [addContact] //! [submitContact part1] void AddressBook::submitContact() @@ -130,28 +124,20 @@ void AddressBook::submitContact() tr("\"%1\" has been edited in your address book.").arg(name)); contacts[name] = address; } - - updateInterface(NavigationMode); } + updateInterface(NavigationMode); } //! [submitContact part3] +//! [cancel] void AddressBook::cancel() { nameLine->setText(oldName); nameLine->setReadOnly(true); - addressText->setText(oldAddress); - addressText->setReadOnly(true); - addButton->setEnabled(true); - - int number = contacts.size(); - nextButton->setEnabled(number > 1); - previousButton->setEnabled(number > 1); - - submitButton->hide(); - cancelButton->hide(); + updateInterface(NavigationMode); } +//! [cancel] void AddressBook::next() { @@ -233,7 +219,7 @@ void AddressBook::updateInterface(Mode mode) nameLine->setReadOnly(false); nameLine->setFocus(Qt::OtherFocusReason); - addressTExt->setReadOnly(false); + addressText->setReadOnly(false); addButton->setEnabled(false); editButton->setEnabled(false); -- GitLab