AddressBook::AddressBook(QWidget *parent) : QWidget(parent), ui(new Ui::AddressBook) { ui->setupUi(this); ui->nameLine->setReadOnly(true); ui->addressText->setReadOnly(true); ui->submitButton->hide(); ui->cancelButton->hide(); ui->nextButton->setEnabled(false); ui->previousButton->setEnabled(false); ui->editButton->setEnabled(false); ui->removeButton->setEnabled(false); connect(ui->addButton, SIGNAL(clicked()), this, SLOT(addContact())); connect(ui->submitButton, SIGNAL(clicked()), this, SLOT(submitContact())); connect(ui->cancelButton, SIGNAL(clicked()), this, SLOT(cancel())); connect(ui->nextButton, SIGNAL(clicked()), this, SLOT(next())); connect(ui->previousButton, SIGNAL(clicked()), this, SLOT(previous())); connect(ui->editButton, SIGNAL(clicked()), this, SLOT(editContact())); connect(ui->removeButton, SIGNAL(clicked()), this, SLOT(removeContact())); connect(ui->findButton, SIGNAL(clicked()), this, SLOT(findContact())); connect(ui->exportButton, SIGNAL(clicked()), this, SLOT(exportAsVCard())); setWindowTitle(tr("Simple Address Book")); }
AddressBook::AddressBook(QWidget *parent) : QWidget(parent) { QLabel *nameLabel = new QLabel(tr("Name:")); nameLine = new QLineEdit; nameLine->setReadOnly(true); QLabel *addressLabel = new QLabel(tr("Address:")); addressText = new QTextEdit; addressText->setReadOnly(true); addButton = new QPushButton(tr("&Add")); editButton = new QPushButton(tr("&Edit")); editButton->setEnabled(false); removeButton = new QPushButton(tr("&Remove")); removeButton->setEnabled(false); findButton = new QPushButton(tr("&Find")); findButton->setEnabled(false); submitButton = new QPushButton(tr("&Submit")); submitButton->hide(); cancelButton = new QPushButton(tr("&Cancel")); cancelButton->hide(); nextButton = new QPushButton(tr("&Next")); nextButton->setEnabled(false); previousButton = new QPushButton(tr("&Previous")); previousButton->setEnabled(false); loadButton = new QPushButton(tr("&Load...")); loadButton->setToolTip(tr("Load contacts from a file")); saveButton = new QPushButton(tr("Sa&ve...")); saveButton->setToolTip(tr("Save contacts to a file")); saveButton->setEnabled(false); exportButton = new QPushButton(tr("E&xport")); exportButton->setToolTip(tr("Export as vCard")); exportButton->setEnabled(false); dialog = new FindDialog; connect(addButton, SIGNAL(clicked()), this, SLOT(addContact())); connect(submitButton, SIGNAL(clicked()), this, SLOT(submitContact())); connect(editButton, SIGNAL(clicked()), this, SLOT(editContact())); connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancel())); connect(removeButton, SIGNAL(clicked()), this, SLOT(removeContact())); connect(findButton, SIGNAL(clicked()), this, SLOT(findContact())); connect(nextButton, SIGNAL(clicked()), this, SLOT(next())); connect(previousButton, SIGNAL(clicked()), this, SLOT(previous())); connect(loadButton, SIGNAL(clicked()), this, SLOT(loadFromFile())); connect(saveButton, SIGNAL(clicked()), this, SLOT(saveToFile())); connect(exportButton, SIGNAL(clicked()), this, SLOT(exportAsVCard())); QVBoxLayout *buttonLayout1 = new QVBoxLayout; buttonLayout1->addWidget(addButton); buttonLayout1->addWidget(editButton); buttonLayout1->addWidget(removeButton); buttonLayout1->addWidget(findButton); buttonLayout1->addWidget(submitButton); buttonLayout1->addWidget(cancelButton); buttonLayout1->addWidget(loadButton); buttonLayout1->addWidget(saveButton); buttonLayout1->addWidget(exportButton); buttonLayout1->addStretch(); QHBoxLayout *buttonLayout2 = new QHBoxLayout; buttonLayout2->addWidget(previousButton); buttonLayout2->addWidget(nextButton); QGridLayout *mainLayout = new QGridLayout; mainLayout->addWidget(nameLabel, 0, 0); mainLayout->addWidget(nameLine, 0, 1); mainLayout->addWidget(addressLabel, 1, 0, Qt::AlignTop); mainLayout->addWidget(addressText, 1, 1); mainLayout->addLayout(buttonLayout1, 1, 2); mainLayout->addLayout(buttonLayout2, 2, 1); setLayout(mainLayout); setWindowTitle(tr("Simple Address Book")); }