diff options
Diffstat (limited to 'Swift/QtUI/QtVCardWidget/QtVCardAddressLabelField.cpp')
-rw-r--r-- | Swift/QtUI/QtVCardWidget/QtVCardAddressLabelField.cpp | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/Swift/QtUI/QtVCardWidget/QtVCardAddressLabelField.cpp b/Swift/QtUI/QtVCardWidget/QtVCardAddressLabelField.cpp new file mode 100644 index 0000000..79e4440 --- /dev/null +++ b/Swift/QtUI/QtVCardWidget/QtVCardAddressLabelField.cpp @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2012 Tobias Markmann + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#include "QtVCardAddressLabelField.h" +#include "ui_QtVCardAddressLabelField.h" + +#define GETTER_SETTER_CHECKBOX_IMPL( METHOD_NAME, UI_NAME ) \ + void QtVCardAddressLabelField::set##METHOD_NAME(const bool METHOD_NAME) { \ + ui->checkBox##UI_NAME->setChecked(METHOD_NAME); \ + } \ + \ + bool QtVCardAddressLabelField::get##METHOD_NAME() const { \ + return ui->checkBox##UI_NAME->checkState() == Qt::Checked; \ + } + +namespace Swift { + +QtVCardAddressLabelField::QtVCardAddressLabelField(QWidget* parent, bool editable) : + QWidget(parent), + ui(new Ui::QtVCardAddressLabelField) { + ui->setupUi(this); + setEditable(editable); +} + +QtVCardAddressLabelField::~QtVCardAddressLabelField() { + delete ui; +} + +bool QtVCardAddressLabelField::isEditable() const { + return editable; +} + +void QtVCardAddressLabelField::setEditable(bool editable) { + this->editable = editable; + ui->plainTextEditLINES->setReadOnly(!editable); +} + +bool QtVCardAddressLabelField::isEmpty() const { + return false; +} + +GETTER_SETTER_CHECKBOX_IMPL(Home, HOME) +GETTER_SETTER_CHECKBOX_IMPL(Work, WORK) +GETTER_SETTER_CHECKBOX_IMPL(Postal, POSTAL) +GETTER_SETTER_CHECKBOX_IMPL(Parcel, PARCEL) +GETTER_SETTER_CHECKBOX_IMPL(Preferred, PREF) + +void QtVCardAddressLabelField::setDeliveryType(DeliveryType type) { + ui->comboBoxDOM_INTL->setCurrentIndex(type); +} + +QtVCardAddressLabelField::DeliveryType QtVCardAddressLabelField::getDeliveryType() const { + return ui->comboBoxDOM_INTL->currentIndex() == 1 ? InternationalDelivery : DomesticDelivery; +} + +void QtVCardAddressLabelField::setLines(const QString& lines) { + ui->plainTextEditLINES->setPlainText(lines); +} + +QString QtVCardAddressLabelField::getLines() const { + return ui->plainTextEditLINES->toPlainText(); +} + +} |