Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-7071

address book tutorial improvement

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Done
    • P3: Somewhat important
    • 4.7.0
    • 4.6.0
    • Documentation
    • None
    • 14e17d5fe5f925a768aab9db9401e04bbaca224d

    Description

      In addressbook tutorial
      (link http://doc.trolltech.com/4.6/tutorials-addressbook-part4-addressbook-cpp.html)
      we have several IF statments, example below:

      ??
      void AddressBook::submitContact()
      {
      QString name = nameLine->text();
      QString address = addressText->toPlainText();

      if (name == "" || address == "")

      { QMessageBox::information(this, tr("Empty Field"), tr("Please enter a name and address.")); }

      if (currentMode == AddingMode) {

      if (!contacts.contains(name))

      { contacts.insert(name, address); QMessageBox::information(this, tr("Add Successful"), tr("\"%1\" has been added to your address book.").arg(name)); }

      else

      { QMessageBox::information(this, tr("Add Unsuccessful"), tr("Sorry, \"%1\" is already in your address book.").arg(name)); }

      ??
      Fist IF statement should prevent from adding new entry in address book without some text in nameLine and in addressText.
      But even it wrong condition function doesn't stops, e.g. I can add entry with for example empty address. Therefore I recomend to add return if first condition is met:

      void AddressBook::submitContact()
      {
      QString name = nameLine->text();
      QString address = addressText->toPlainText();

      if (name == "" || address == "")

      { QMessageBox::information(this, tr("Empty Field"), tr("Please enter a name and address.")); *return*; }

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            jerome.pasion Jerome Pasion
            borys86 Boris Zhurkevich
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes