summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI/QtVCardWidget/QtVCardAddressLabelField.cpp')
-rw-r--r--Swift/QtUI/QtVCardWidget/QtVCardAddressLabelField.cpp108
1 files changed, 54 insertions, 54 deletions
diff --git a/Swift/QtUI/QtVCardWidget/QtVCardAddressLabelField.cpp b/Swift/QtUI/QtVCardWidget/QtVCardAddressLabelField.cpp
index 64d2533..e4a75cd 100644
--- a/Swift/QtUI/QtVCardWidget/QtVCardAddressLabelField.cpp
+++ b/Swift/QtUI/QtVCardWidget/QtVCardAddressLabelField.cpp
@@ -5,7 +5,7 @@
*/
/*
- * Copyright (c) 2015 Isode Limited.
+ * Copyright (c) 2015-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -22,86 +22,86 @@
namespace Swift {
QtVCardAddressLabelField::QtVCardAddressLabelField(QWidget* parent, QGridLayout *layout, bool editable) :
- QtVCardGeneralField(parent, layout, editable, layout->rowCount(), tr("Address Label")), addressLabelPlainTextEdit(NULL), deliveryTypeLabel(NULL), domesticRadioButton(NULL), internationalRadioButton(NULL), buttonGroup(NULL) {
- connect(this, SIGNAL(editableChanged(bool)), SLOT(handleEditibleChanged(bool)));
+ QtVCardGeneralField(parent, layout, editable, layout->rowCount(), tr("Address Label")), addressLabelPlainTextEdit(nullptr), deliveryTypeLabel(nullptr), domesticRadioButton(nullptr), internationalRadioButton(nullptr), buttonGroup(nullptr) {
+ connect(this, SIGNAL(editableChanged(bool)), SLOT(handleEditibleChanged(bool)));
}
QtVCardAddressLabelField::~QtVCardAddressLabelField() {
- disconnect(this, SLOT(handleEditibleChanged(bool)));
+ disconnect(this, SLOT(handleEditibleChanged(bool)));
}
void QtVCardAddressLabelField::setupContentWidgets() {
- addressLabelPlainTextEdit = new QPlainTextEdit(this);
- addressLabelPlainTextEdit->setTabChangesFocus(true);
- getGridLayout()->addWidget(addressLabelPlainTextEdit, getGridLayout()->rowCount()-1, 2, 3, 2, Qt::AlignVCenter);
+ addressLabelPlainTextEdit = new QPlainTextEdit(this);
+ addressLabelPlainTextEdit->setTabChangesFocus(true);
+ getGridLayout()->addWidget(addressLabelPlainTextEdit, getGridLayout()->rowCount()-1, 2, 3, 2, Qt::AlignVCenter);
- deliveryTypeLabel = new QtElidingLabel(this);
- deliveryTypeLabel->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard);
- getGridLayout()->addWidget(deliveryTypeLabel, getGridLayout()->rowCount()-2, 4, Qt::AlignVCenter);
+ deliveryTypeLabel = new QtElidingLabel(this);
+ deliveryTypeLabel->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard);
+ getGridLayout()->addWidget(deliveryTypeLabel, getGridLayout()->rowCount()-2, 4, Qt::AlignVCenter);
- domesticRadioButton = new QRadioButton(tr("Domestic Delivery"), this);
- getGridLayout()->addWidget(domesticRadioButton, getGridLayout()->rowCount()-2, 4, Qt::AlignVCenter);
+ domesticRadioButton = new QRadioButton(tr("Domestic Delivery"), this);
+ getGridLayout()->addWidget(domesticRadioButton, getGridLayout()->rowCount()-2, 4, Qt::AlignVCenter);
- internationalRadioButton = new QRadioButton(tr("International Delivery"), this);
- getGridLayout()->addWidget(internationalRadioButton, getGridLayout()->rowCount()-1, 4, Qt::AlignVCenter);
+ internationalRadioButton = new QRadioButton(tr("International Delivery"), this);
+ getGridLayout()->addWidget(internationalRadioButton, getGridLayout()->rowCount()-1, 4, Qt::AlignVCenter);
- buttonGroup = new QButtonGroup(this);
- buttonGroup->addButton(domesticRadioButton);
- buttonGroup->addButton(internationalRadioButton);
+ buttonGroup = new QButtonGroup(this);
+ buttonGroup->addButton(domesticRadioButton);
+ buttonGroup->addButton(internationalRadioButton);
- setTabOrder(internationalRadioButton, getTagComboBox());
- getTagComboBox()->addTag("postal", tr("Postal"));
- getTagComboBox()->addTag("parcel", tr("Parcel"));
+ setTabOrder(internationalRadioButton, getTagComboBox());
+ getTagComboBox()->addTag("postal", tr("Postal"));
+ getTagComboBox()->addTag("parcel", tr("Parcel"));
- QtVCardHomeWork::setTagComboBox(getTagComboBox());
- deliveryTypeLabel->hide();
- childWidgets << addressLabelPlainTextEdit << deliveryTypeLabel << domesticRadioButton << internationalRadioButton;
+ QtVCardHomeWork::setTagComboBox(getTagComboBox());
+ deliveryTypeLabel->hide();
+ childWidgets << addressLabelPlainTextEdit << deliveryTypeLabel << domesticRadioButton << internationalRadioButton;
}
bool QtVCardAddressLabelField::isEmpty() const {
- return addressLabelPlainTextEdit->toPlainText().isEmpty();
+ return addressLabelPlainTextEdit->toPlainText().isEmpty();
}
void QtVCardAddressLabelField::setAddressLabel(const VCard::AddressLabel& addressLabel) {
- setPreferred(addressLabel.isPreferred);
- setHome(addressLabel.isHome);
- setWork(addressLabel.isWork);
- getTagComboBox()->setTag("postal", addressLabel.isPostal);
- getTagComboBox()->setTag("parcel", addressLabel.isParcel);
- domesticRadioButton->setChecked(addressLabel.deliveryType == VCard::DomesticDelivery);
- internationalRadioButton->setChecked(addressLabel.deliveryType == VCard::InternationalDelivery);
- std::string joinedLines = boost::algorithm::join(addressLabel.lines, "\n");
- addressLabelPlainTextEdit->setPlainText(P2QSTRING(joinedLines));
+ setPreferred(addressLabel.isPreferred);
+ setHome(addressLabel.isHome);
+ setWork(addressLabel.isWork);
+ getTagComboBox()->setTag("postal", addressLabel.isPostal);
+ getTagComboBox()->setTag("parcel", addressLabel.isParcel);
+ domesticRadioButton->setChecked(addressLabel.deliveryType == VCard::DomesticDelivery);
+ internationalRadioButton->setChecked(addressLabel.deliveryType == VCard::InternationalDelivery);
+ std::string joinedLines = boost::algorithm::join(addressLabel.lines, "\n");
+ addressLabelPlainTextEdit->setPlainText(P2QSTRING(joinedLines));
}
VCard::AddressLabel QtVCardAddressLabelField::getAddressLabel() const {
- VCard::AddressLabel addressLabel;
- addressLabel.isPreferred = getPreferred();
- addressLabel.isHome = getHome();
- addressLabel.isWork = getWork();
- addressLabel.deliveryType = domesticRadioButton->isChecked() ? VCard::DomesticDelivery : (internationalRadioButton->isChecked() ? VCard::InternationalDelivery : VCard::None);
- addressLabel.isPostal = getTagComboBox()->isTagSet("postal");
- addressLabel.isParcel = getTagComboBox()->isTagSet("parcel");
-
- std::string lines = Q2PSTRING(addressLabelPlainTextEdit->toPlainText());
- boost::split(addressLabel.lines, lines, boost::is_any_of("\n"));
- return addressLabel;
+ VCard::AddressLabel addressLabel;
+ addressLabel.isPreferred = getPreferred();
+ addressLabel.isHome = getHome();
+ addressLabel.isWork = getWork();
+ addressLabel.deliveryType = domesticRadioButton->isChecked() ? VCard::DomesticDelivery : (internationalRadioButton->isChecked() ? VCard::InternationalDelivery : VCard::None);
+ addressLabel.isPostal = getTagComboBox()->isTagSet("postal");
+ addressLabel.isParcel = getTagComboBox()->isTagSet("parcel");
+
+ std::string lines = Q2PSTRING(addressLabelPlainTextEdit->toPlainText());
+ boost::split(addressLabel.lines, lines, boost::is_any_of("\n"));
+ return addressLabel;
}
void QtVCardAddressLabelField::handleEditibleChanged(bool isEditable) {
- assert(addressLabelPlainTextEdit);
- assert(deliveryTypeLabel);
- assert(domesticRadioButton);
- assert(internationalRadioButton);
+ assert(addressLabelPlainTextEdit);
+ assert(deliveryTypeLabel);
+ assert(domesticRadioButton);
+ assert(internationalRadioButton);
- addressLabelPlainTextEdit->setReadOnly(!isEditable);
- addressLabelPlainTextEdit->setStyleSheet(isEditable ? "" : "QPlainTextEdit { background: transparent; }");
+ addressLabelPlainTextEdit->setReadOnly(!isEditable);
+ addressLabelPlainTextEdit->setStyleSheet(isEditable ? "" : "QPlainTextEdit { background: transparent; }");
- deliveryTypeLabel->setText(buttonGroup->checkedButton() == 0 ? "" : buttonGroup->checkedButton()->text());
- deliveryTypeLabel->setVisible(!isEditable);
+ deliveryTypeLabel->setText(buttonGroup->checkedButton() == nullptr ? "" : buttonGroup->checkedButton()->text());
+ deliveryTypeLabel->setVisible(!isEditable);
- domesticRadioButton->setVisible(isEditable);
- internationalRadioButton->setVisible(isEditable);
+ domesticRadioButton->setVisible(isEditable);
+ internationalRadioButton->setVisible(isEditable);
}
}