diff --git a/doc/addressbook-sdk.qdoc b/doc/addressbook-sdk.qdoc index 2ca6e9746d1..f7f40121632 100644 --- a/doc/addressbook-sdk.qdoc +++ b/doc/addressbook-sdk.qdoc @@ -575,6 +575,15 @@ \section1 Placing Widgets on the Form + To edit and remove contacts, we need two push buttons. Drag them and name + them accordingly. Their \c objectName properties should be \c editButton + and \c removeButton, respectively. The quickest way to place these two + buttons into our existing layout, is to simply drag and drop them. Use the + screenshot below as a guide: + + \image addressbook-tutorial-part4-drop-in-gridlayout.png + + \section1 The AddressBook Class We update the header file to contain the \c Mode enum: @@ -586,6 +595,26 @@ \snippet examples/addressbook-sdk/part4/addressbook.h slot definition + In order to switch between modes, we introduce the \c updateInterface() + function to control the enabling and disabling of all push buttons. We also + add two new push buttons, \c editButton and \c removeButton, for the edit + and remove functions mentioned earlier. + + \snippet examples/addressbook-sdk/part4/adressbook.h updateInterface + \dots + \snippet examples/addressbook-sdk/part4/addressbook.h members + + Lastly, we declare \c currentMode to keep track of the enum's current mode. + + \snippet examples/addressbook-sdk/part4/addressbook.h current mode + + Let's begin by implementing the mode-changing features of the address book + application. The \c editButton and \c removeButton are extracted and + disabled by default, as the address book starts up with zero contacts in + memory. + + + */ /*! diff --git a/doc/examples/addressbook-sdk/part3/addressbook.h b/doc/examples/addressbook-sdk/part3/addressbook.h index dd18d85512e..7d42d0c0531 100644 --- a/doc/examples/addressbook-sdk/part3/addressbook.h +++ b/doc/examples/addressbook-sdk/part3/addressbook.h @@ -1,4 +1,3 @@ -//! [class definition] #ifndef ADDRESSBOOK_H #define ADDRESSBOOK_H @@ -50,4 +49,3 @@ private: }; #endif // ADDRESSBOOK_H -//! [class definition] diff --git a/doc/examples/addressbook-sdk/part4/addressbook.cpp b/doc/examples/addressbook-sdk/part4/addressbook.cpp index e14c86f4260..7dda52ce0fc 100644 --- a/doc/examples/addressbook-sdk/part4/addressbook.cpp +++ b/doc/examples/addressbook-sdk/part4/addressbook.cpp @@ -31,7 +31,15 @@ AddressBook::AddressBook(QWidget *parent) previousButton = new QPushButton; previousButton = ui->previousButton; - nextButton->setEnabled(false); + previousButton->setEnabled(false); + + editButton = new QPushButton; + editButton = ui->editButton; + editButton->setEnabled(false); + + removeButton = new QPushButton; + removeButton = ui->removeButton; + removeButton->setEnabled(false); connect(addButton, SIGNAL(clicked()), this, SLOT(addContact())); diff --git a/doc/examples/addressbook-sdk/part4/addressbook.h b/doc/examples/addressbook-sdk/part4/addressbook.h index 7bc76f45f73..467932c2640 100644 --- a/doc/examples/addressbook-sdk/part4/addressbook.h +++ b/doc/examples/addressbook-sdk/part4/addressbook.h @@ -1,4 +1,3 @@ -//! [class definition] #ifndef ADDRESSBOOK_H #define ADDRESSBOOK_H @@ -39,20 +38,27 @@ public slots: private: Ui::AddressBook *ui; +//! [updateInterface] + void updateInterface(Mode mode); +//! [updateInterface] QPushButton *addButton; QPushButton *submitButton; QPushButton *cancelButton; +//! [members] + QPushButton *editButton; + QPushButton *removeButton; //! [members] QPushButton *nextButton; QPushButton *previousButton; -//! [members] QLineEdit *nameLine; QTextEdit *addressText; QMap contacts; QString oldName; QString oldAddress; +//! [current mode] + Mode currentMode; +//! [current mode] }; #endif // ADDRESSBOOK_H -//! [class definition] diff --git a/doc/examples/addressbook-sdk/part4/addressbook.ui b/doc/examples/addressbook-sdk/part4/addressbook.ui index ee9bbe4d65b..44b4940ac98 100644 --- a/doc/examples/addressbook-sdk/part4/addressbook.ui +++ b/doc/examples/addressbook-sdk/part4/addressbook.ui @@ -6,104 +6,112 @@ 0 0 - 600 - 400 + 472 + 294 AddressBook - - - - 10 - 10 - 413 - 260 - - - - - - - Name: - - - - - - - - - - Address: - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - - - - - - Add - - - - - - - Submit - - - - - - - Cancel - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - Previous - - - - - - - Next - - - - - - - + + + + + + + Name: + + + + + + + + + + Address: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + + + + + Add + + + + + + + Submit + + + + + + + Cancel + + + + + + + Edit + + + + + + + Remove + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + Previous + + + + + + + Next + + + + + + + + diff --git a/doc/images/addressbook-tutorial-part4-drop-in-gridlayout.png b/doc/images/addressbook-tutorial-part4-drop-in-gridlayout.png new file mode 100644 index 00000000000..1969294ba14 Binary files /dev/null and b/doc/images/addressbook-tutorial-part4-drop-in-gridlayout.png differ