05fc3aef53
Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
60 lines
1.6 KiB
C++
60 lines
1.6 KiB
C++
// Copyright (C) 2016 The Qt Company Ltd.
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
|
|
|
#include "adddialog.h"
|
|
|
|
#include <QtWidgets>
|
|
|
|
//! [0]
|
|
AddDialog::AddDialog(QWidget *parent)
|
|
: QDialog(parent),
|
|
nameText(new QLineEdit),
|
|
addressText(new QTextEdit)
|
|
{
|
|
auto nameLabel = new QLabel(tr("Name"));
|
|
auto addressLabel = new QLabel(tr("Address"));
|
|
auto okButton = new QPushButton(tr("OK"));
|
|
auto cancelButton = new QPushButton(tr("Cancel"));
|
|
|
|
auto gLayout = new QGridLayout;
|
|
gLayout->setColumnStretch(1, 2);
|
|
gLayout->addWidget(nameLabel, 0, 0);
|
|
gLayout->addWidget(nameText, 0, 1);
|
|
|
|
gLayout->addWidget(addressLabel, 1, 0, Qt::AlignLeft|Qt::AlignTop);
|
|
gLayout->addWidget(addressText, 1, 1, Qt::AlignLeft);
|
|
|
|
auto buttonLayout = new QHBoxLayout;
|
|
buttonLayout->addWidget(okButton);
|
|
buttonLayout->addWidget(cancelButton);
|
|
|
|
gLayout->addLayout(buttonLayout, 2, 1, Qt::AlignRight);
|
|
|
|
auto mainLayout = new QVBoxLayout;
|
|
mainLayout->addLayout(gLayout);
|
|
setLayout(mainLayout);
|
|
|
|
connect(okButton, &QAbstractButton::clicked, this, &QDialog::accept);
|
|
connect(cancelButton, &QAbstractButton::clicked, this, &QDialog::reject);
|
|
|
|
setWindowTitle(tr("Add a Contact"));
|
|
}
|
|
|
|
QString AddDialog::name() const
|
|
{
|
|
return nameText->text();
|
|
}
|
|
|
|
QString AddDialog::address() const
|
|
{
|
|
return addressText->toPlainText();
|
|
}
|
|
|
|
void AddDialog::editAddress(const QString &name, const QString &address)
|
|
{
|
|
nameText->setReadOnly(true);
|
|
nameText->setText(name);
|
|
addressText->setPlainText(address);
|
|
}
|
|
//! [0]
|