addressbook.cpp 1.57 KB
Newer Older
1 2 3 4 5 6 7
#include "addressbook.h"
#include "ui_addressbook.h"

AddressBook::AddressBook(QWidget *parent)
    : QWidget(parent), ui(new Ui::AddressBookClass)
{
    ui->setupUi(this);
8

9 10 11 12 13 14 15 16 17 18
    //! [extract objects]
    nameLine = new QLineEdit;
    nameLine = ui->nameLine;
    nameLine->setReadOnly(true);

    addressText = new QTextEdit;
    addressText = ui->addressText;
    addressText->setReadOnly(true);

    addButton = new QPushButton;
19 20
    addButton = ui->addButton;

21
    submitButton = new QPushButton;
22
    submitButton = ui->submitButton;
23
    submitButton->hide();
24

25
    cancelButton = new QPushButton;
26
    cancelButton = ui->cancelButton;
27 28 29 30 31 32 33 34 35 36 37 38
    cancelButton->hide();
    //! [extract objects]

    //! [signal slot]
    connect(addButton, SIGNAL(clicked()), this,
                SLOT(addContact()));
    connect(submitButton, SIGNAL(clicked()), this,
                SLOT(submitContact()));
    connect(cancelButton, SIGNAL(clicked()), this,
                SLOT(cancel()));
    //! [signal slot]

39
    //! [window title]
40
    setWindowTitle(tr("Simple Address Book"));
41
    //! [window title]
42 43 44 45 46 47
}

AddressBook::~AddressBook()
{
    delete ui;
}
48

49
//! [addContact]
50 51
void AddressBook::addContact()
{
52 53 54 55 56 57 58 59 60 61 62 63 64
    oldName = nameLine->text();
    oldAddress = addressTExt->toPlainText();

    nameLine->clear();
    addressText->clear();

    nameLine->setReadOnly(false);
    nameLine->setFocus(Qt::OtherFocusReason);
    addressText->setReadOnly(false);

    addButton->setEnabled(false);
    submitButton->show();
    cancelButton->show();
65
}
66
//! [addContact]
67 68 69 70 71 72 73 74

void AddressBook::submitContact()
{
}

void AddressBook::cancel()
{
}