summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
Diffstat (limited to 'Swift')
-rw-r--r--Swift/QtUI/QtVCardWidget/QtVCardGeneralField.cpp37
-rw-r--r--Swift/QtUI/QtVCardWidget/QtVCardGeneralField.h34
-rw-r--r--Swift/QtUI/QtVCardWidget/QtVCardHomeWork.cpp40
-rw-r--r--Swift/QtUI/QtVCardWidget/QtVCardHomeWork.h31
-rw-r--r--Swift/QtUI/QtVCardWidget/QtVCardWidget.cpp27
-rw-r--r--Swift/QtUI/SConscript5
6 files changed, 159 insertions, 15 deletions
diff --git a/Swift/QtUI/QtVCardWidget/QtVCardGeneralField.cpp b/Swift/QtUI/QtVCardWidget/QtVCardGeneralField.cpp
index 551f5d3..f78f6bf 100644
--- a/Swift/QtUI/QtVCardWidget/QtVCardGeneralField.cpp
+++ b/Swift/QtUI/QtVCardWidget/QtVCardGeneralField.cpp
@@ -6,11 +6,46 @@
#include "QtVCardGeneralField.h"
+#include <QHBoxLayout>
+
namespace Swift {
-QtVCardGeneralField::QtVCardGeneralField(QWidget* parent) :
+QtVCardGeneralField::QtVCardGeneralField(QWidget* parent, bool editable) :
QWidget(parent) {
+ setEditable(editable);
+}
+
+void QtVCardGeneralField::initialize() {
+ setLayout(new QHBoxLayout);
+ preferredCheckBox = new QCheckBox(this);
+ layout()->addWidget(preferredCheckBox);
+ label = new QLabel(this);
+ layout()->addWidget(label);
+ tagComboBox = new QtTagComboBox(this);
+ setupContentWidgets();
+ layout()->addWidget(tagComboBox);
+
+}
+
+bool QtVCardGeneralField::isEditable() const {
+ return editable;
+}
+
+void QtVCardGeneralField::setEditable(bool editable) {
+ this->editable = editable;
+ editableChanged(this->editable);
+}
+
+void QtVCardGeneralField::setPreferred(const bool preferred) {
+ preferredCheckBox->setChecked(preferred);
+}
+
+bool QtVCardGeneralField::getPreferred() const {
+ return preferredCheckBox->isChecked();
+}
+QtTagComboBox *QtVCardGeneralField::getTagComboBox() {
+ return tagComboBox;
}
}
diff --git a/Swift/QtUI/QtVCardWidget/QtVCardGeneralField.h b/Swift/QtUI/QtVCardWidget/QtVCardGeneralField.h
index ed07d9d..9ffcaea 100644
--- a/Swift/QtUI/QtVCardWidget/QtVCardGeneralField.h
+++ b/Swift/QtUI/QtVCardWidget/QtVCardGeneralField.h
@@ -7,6 +7,10 @@
#pragma once
#include <QWidget>
+#include <QLabel>
+#include <QCheckBox>
+
+#include "QtTagComboBox.h"
namespace Swift {
@@ -17,14 +21,38 @@ namespace Swift {
* - label
*/
class QtVCardGeneralField : public QWidget {
- Q_OBJECT
+ Q_OBJECT
+ Q_PROPERTY(bool editable READ isEditable WRITE setEditable NOTIFY editableChanged)
+ Q_PROPERTY(bool empty READ isEmpty)
+
public:
- explicit QtVCardGeneralField(QWidget* parent = 0);
+ explicit QtVCardGeneralField(QWidget* parent = 0, bool editable = false);
+ void initialize();
+
+ virtual void setupContentWidgets() = 0;
+
+ virtual bool isEditable() const;
+ virtual void setEditable(bool);
+
+ virtual bool isEmpty() const = 0;
+
+ void setPreferred(const bool preferred);
+ bool getPreferred() const;
+
+ protected:
+ QtTagComboBox* getTagComboBox();
+
signals:
+ void editableChanged(bool);
public slots:
-
+
+ private:
+ bool editable;
+ QCheckBox* preferredCheckBox;
+ QLabel* label;
+ QtTagComboBox* tagComboBox;
};
}
diff --git a/Swift/QtUI/QtVCardWidget/QtVCardHomeWork.cpp b/Swift/QtUI/QtVCardWidget/QtVCardHomeWork.cpp
new file mode 100644
index 0000000..825db93
--- /dev/null
+++ b/Swift/QtUI/QtVCardWidget/QtVCardHomeWork.cpp
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2012 Tobias Markmann
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#include "QtVCardHomeWork.h"
+
+namespace Swift {
+
+QtVCardHomeWork::QtVCardHomeWork() {
+}
+
+QtVCardHomeWork::~QtVCardHomeWork() {
+}
+
+void QtVCardHomeWork::setTagComboBox(QtTagComboBox* tagBox) {
+ tagComboBox = tagBox;
+ tagComboBox->addTag("home", QObject::tr("Home"));
+ tagComboBox->addTag("work", QObject::tr("Work"));
+}
+
+void QtVCardHomeWork::setHome(const bool home) {
+ tagComboBox->setTag("home", home);
+}
+
+bool QtVCardHomeWork::getHome() const {
+ return tagComboBox->isTagSet("home");
+}
+
+void QtVCardHomeWork::setWork(const bool work) {
+ tagComboBox->setTag("work", work);
+}
+
+bool QtVCardHomeWork::getWork() const {
+ return tagComboBox->isTagSet("work");
+}
+
+}
+
diff --git a/Swift/QtUI/QtVCardWidget/QtVCardHomeWork.h b/Swift/QtUI/QtVCardWidget/QtVCardHomeWork.h
new file mode 100644
index 0000000..768d984
--- /dev/null
+++ b/Swift/QtUI/QtVCardWidget/QtVCardHomeWork.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2012 Tobias Markmann
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#pragma once
+
+#include <QObject>
+
+#include "QtTagComboBox.h"
+
+namespace Swift {
+
+class QtVCardHomeWork {
+ public:
+ QtVCardHomeWork();
+ virtual ~QtVCardHomeWork();
+
+ void setTagComboBox(QtTagComboBox* tagBox);
+
+ void setHome(const bool home);
+ bool getHome() const;
+ void setWork(const bool work);
+ bool getWork() const;
+
+ private:
+ QtTagComboBox* tagComboBox;
+};
+
+}
diff --git a/Swift/QtUI/QtVCardWidget/QtVCardWidget.cpp b/Swift/QtUI/QtVCardWidget/QtVCardWidget.cpp
index b82aff9..f2aa127 100644
--- a/Swift/QtUI/QtVCardWidget/QtVCardWidget.cpp
+++ b/Swift/QtUI/QtVCardWidget/QtVCardWidget.cpp
@@ -16,7 +16,8 @@
#include "QtVCardAddressLabelField.h"
#include "QtVCardBirthdayField.h"
#include "QtVCardDescriptionField.h"
-#include "QtVCardEMailField.h"
+//#include "QtVCardEMailField.h"
+#include "QtVCardInternetEMailField.h"
#include "QtVCardJIDField.h"
#include "QtVCardOrganisationField.h"
#include "QtVCardRoleField.h"
@@ -42,6 +43,8 @@ QtVCardWidget::QtVCardWidget(QWidget* parent) :
menu->addMenu(ui->photoAndName->getAddFieldMenu());
ui->toolButton->setMenu(menu);
+ addFieldType(menu, boost::make_shared<QtVCardInternetEMailField::FieldInfo>());
+
//addFieldType(menu, boost::make_shared<QtVCardAddressField::FieldInfo>());
//addFieldType(menu, boost::make_shared<QtVCardEMailField::FieldInfo>());
//addFieldType(menu, boost::make_shared<QtVCardJIDField::FieldInfo>());
@@ -103,16 +106,19 @@ void QtVCardWidget::setVCard(VCard::ref vcard) {
ui->photoAndName->setSuffix(P2QSTRING(vcard->getSuffix()));
ui->photoAndName->setAvatar(vcard->getPhoto(), vcard->getPhotoType());
- /*
+
foreach (const VCard::EMailAddress& address, vcard->getEMailAddresses()) {
- QtVCardEMailField* emailField = new QtVCardEMailField(this);
- emailField->setAddress(P2QSTRING(address.address));
- emailField->setType(address.isX400 ? QtVCardEMailField::X_400 : QtVCardEMailField::Internet);
- emailField->setWork(address.isWork);
- emailField->setHome(address.isHome);
- emailField->setPreferred(address.isPreferred);
- ui->cardFields->insertWidget(ui->cardFields->count(), emailField);
+ if (address.isInternet) {
+ QtVCardInternetEMailField* internetEmailField = new QtVCardInternetEMailField(this);
+ internetEmailField->initialize();
+ internetEmailField->setAddress(P2QSTRING(address.address));
+ internetEmailField->setPreferred(address.isPreferred);
+ ui->cardFields->insertWidget(ui->cardFields->count(), internetEmailField);
+ }
+// emailField->setWork(address.isWork);
+// emailField->setHome(address.isHome);
}
+ /*
if (!vcard->getBirthday().is_not_a_date_time()) {
QtVCardBirthdayField* bdayField = new QtVCardBirthdayField(this);
@@ -248,6 +254,7 @@ VCard::ref QtVCardWidget::getVCard() {
for(int n = 0; n < ui->cardFields->count(); n++) {
QWidget* widget = ui->cardFields->itemAt(n)->widget();
+ /*
QtVCardEMailField* emailField;
if ((emailField = dynamic_cast<QtVCardEMailField*>(widget))) {
VCard::EMailAddress address;
@@ -259,7 +266,7 @@ VCard::ref QtVCardWidget::getVCard() {
address.isPreferred = emailField->getPreferred();
vcard->addEMailAddress(address);
continue;
- }
+ }*/
QtVCardJIDField* jidField;
if ((jidField = dynamic_cast<QtVCardJIDField*>(widget))) {
diff --git a/Swift/QtUI/SConscript b/Swift/QtUI/SConscript
index aa18386..3b82f08 100644
--- a/Swift/QtUI/SConscript
+++ b/Swift/QtUI/SConscript
@@ -167,11 +167,14 @@ sources = [
# QtVCardWidget
sources.extend([
"QtVCardWidget/QtResizableLineEdit.cpp",
+ "QtVCardWidget/QtTagComboBox.cpp",
+ "QtVCardWidget/QtVCardHomeWork.cpp",
"QtVCardWidget/QtVCardAddressField.cpp",
"QtVCardWidget/QtVCardAddressLabelField.cpp",
"QtVCardWidget/QtVCardBirthdayField.cpp",
"QtVCardWidget/QtVCardDescriptionField.cpp",
- "QtVCardWidget/QtVCardEMailField.cpp",
+ "QtVCardWidget/QtVCardInternetEMailField.cpp",
+ #"QtVCardWidget/QtVCardEMailField.cpp",
"QtVCardWidget/QtVCardJIDField.cpp",
"QtVCardWidget/QtVCardOrganisationField.cpp",
"QtVCardWidget/QtVCardPhotoAndNameFields.cpp",