summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2013-10-16 18:41:41 (GMT)
committerSwift Review <review@swift.im>2013-10-26 15:33:27 (GMT)
commit806157b94327f8c41f5e4402a73608cd9e5225b0 (patch)
tree287d0c5f73c21d189db3eea485621a9c784bf1c8 /Swift/QtUI
parentf7a239f06131bdad9ca7c11e88496de1d7b5a9f9 (diff)
downloadswift-806157b94327f8c41f5e4402a73608cd9e5225b0.zip
swift-806157b94327f8c41f5e4402a73608cd9e5225b0.tar.bz2
VCard: Remove name fields from field menu. They're always displayed in edit mode now.
Change-Id: I9ee5faae53e9300300e01a1782b51645399f1669 License: This patch is BSD-licensed, see Documentation/Licenses/BSD-simplified.txt for details.
Diffstat (limited to 'Swift/QtUI')
-rw-r--r--Swift/QtUI/QtVCardWidget/QtVCardPhotoAndNameFields.cpp40
-rw-r--r--Swift/QtUI/QtVCardWidget/QtVCardPhotoAndNameFields.h13
-rw-r--r--Swift/QtUI/QtVCardWidget/QtVCardWidget.cpp34
3 files changed, 15 insertions, 72 deletions
diff --git a/Swift/QtUI/QtVCardWidget/QtVCardPhotoAndNameFields.cpp b/Swift/QtUI/QtVCardWidget/QtVCardPhotoAndNameFields.cpp
index 4ad12c8..aaea194 100644
--- a/Swift/QtUI/QtVCardWidget/QtVCardPhotoAndNameFields.cpp
+++ b/Swift/QtUI/QtVCardWidget/QtVCardPhotoAndNameFields.cpp
@@ -33,17 +33,10 @@ QtVCardPhotoAndNameFields::QtVCardPhotoAndNameFields(QWidget* parent) :
ui->lineEditSUFFIX->setPlaceholderText(tr("Suffix"));
#endif
- addFieldMenu = new QMenu("Name", this);
-
- actionSignalMapper = new QSignalMapper(this);
-
- connect(actionSignalMapper, SIGNAL(mapped(const QString &)), this, SLOT(showField(const QString &)));
- prepareAddFieldMenu();
}
QtVCardPhotoAndNameFields::~QtVCardPhotoAndNameFields() {
delete ui;
- delete actionSignalMapper;
}
bool QtVCardPhotoAndNameFields::isEditable() const {
@@ -75,12 +68,6 @@ void QtVCardPhotoAndNameFields::setEditable(bool editable) {
fullname << ui->lineEditFAMILY->text() << ui->lineEditSUFFIX->text();
fullname = fullname.filter(".*\\S.*");
ui->labelFULLNAME->setText(fullname.join(" "));
-
- prepareAddFieldMenu();
-}
-
-QMenu* QtVCardPhotoAndNameFields::getAddFieldMenu() const {
- return addFieldMenu;
}
void QtVCardPhotoAndNameFields::setAvatar(const ByteArray &data, const std::string &type) {
@@ -151,31 +138,4 @@ QString QtVCardPhotoAndNameFields::getSuffix() const {
return ui->lineEditSUFFIX->text();
}
-void QtVCardPhotoAndNameFields::prepareAddFieldMenu() {
- foreach(QAction* action, addFieldMenu->actions()) {
- actionSignalMapper->removeMappings(action);
- }
-
- addFieldMenu->clear();
- foreach(QObject* obj, children()) {
- QLineEdit* lineEdit = 0;
- if (!(lineEdit = dynamic_cast<QLineEdit*>(obj))) continue;
- if (lineEdit->isHidden()) {
-#if QT_VERSION >= 0x040700
- QAction* action = addFieldMenu->addAction(QString("Add ") + lineEdit->placeholderText(), actionSignalMapper, SLOT(map()));
-#else
- QAction* action = addFieldMenu->addAction(QString("Add ") + lineEdit->toolTip(), actionSignalMapper, SLOT(map()));
-#endif
- actionSignalMapper->setMapping(action, lineEdit->objectName());
- }
- }
-}
-
-void QtVCardPhotoAndNameFields::showField(const QString& widgetName) {
- QLineEdit* lineEditToShow = findChild<QLineEdit*>(widgetName);
- if (lineEditToShow) lineEditToShow->show();
-
- prepareAddFieldMenu();
-}
-
}
diff --git a/Swift/QtUI/QtVCardWidget/QtVCardPhotoAndNameFields.h b/Swift/QtUI/QtVCardWidget/QtVCardPhotoAndNameFields.h
index f279701..6a5ae46 100644
--- a/Swift/QtUI/QtVCardWidget/QtVCardPhotoAndNameFields.h
+++ b/Swift/QtUI/QtVCardWidget/QtVCardPhotoAndNameFields.h
@@ -7,8 +7,8 @@
#pragma once
#include <QMenu>
-#include <QSignalMapper>
#include <QWidget>
+
#include <Swiften/Base/ByteArray.h>
namespace Ui {
@@ -29,8 +29,6 @@ namespace Swift {
bool isEditable() const;
void setEditable(bool);
- QMenu* getAddFieldMenu() const;
-
void setAvatar(const ByteArray& data, const std::string& type);
ByteArray getAvatarData() const;
std::string getAvatarType() const;
@@ -56,18 +54,9 @@ namespace Swift {
void setSuffix(const QString suffix);
QString getSuffix() const;
- public slots:
- void showField(const QString& widgetName);
-
- private:
- void prepareAddFieldMenu();
-
private:
Ui::QtVCardPhotoAndNameFields* ui;
bool editable;
-
- QMenu* addFieldMenu;
- QSignalMapper* actionSignalMapper;
};
}
diff --git a/Swift/QtUI/QtVCardWidget/QtVCardWidget.cpp b/Swift/QtUI/QtVCardWidget/QtVCardWidget.cpp
index 1c80fa4..160482e 100644
--- a/Swift/QtUI/QtVCardWidget/QtVCardWidget.cpp
+++ b/Swift/QtUI/QtVCardWidget/QtVCardWidget.cpp
@@ -4,30 +4,27 @@
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
-#include "QtVCardWidget.h"
-#include "ui_QtVCardWidget.h"
+#include <Swift/QtUI/QtVCardWidget/QtVCardWidget.h>
#include <QDebug>
#include <QLineEdit>
#include <QMenu>
-#include "QtVCardAddressField.h"
-#include "QtVCardAddressLabelField.h"
-#include "QtVCardBirthdayField.h"
-#include "QtVCardDescriptionField.h"
-#include "QtVCardGeneralField.h"
-#include "QtVCardInternetEMailField.h"
-#include "QtVCardJIDField.h"
-#include "QtVCardOrganizationField.h"
-#include "QtVCardRoleField.h"
-#include "QtVCardTelephoneField.h"
-#include "QtVCardTitleField.h"
-#include "QtVCardURLField.h"
-
+#include <Swift/QtUI/QtVCardWidget/ui_QtVCardWidget.h>
+#include <Swift/QtUI/QtVCardWidget/QtVCardAddressField.h>
+#include <Swift/QtUI/QtVCardWidget/QtVCardAddressLabelField.h>
+#include <Swift/QtUI/QtVCardWidget/QtVCardBirthdayField.h>
+#include <Swift/QtUI/QtVCardWidget/QtVCardDescriptionField.h>
+#include <Swift/QtUI/QtVCardWidget/QtVCardGeneralField.h>
+#include <Swift/QtUI/QtVCardWidget/QtVCardInternetEMailField.h>
+#include <Swift/QtUI/QtVCardWidget/QtVCardJIDField.h>
+#include <Swift/QtUI/QtVCardWidget/QtVCardOrganizationField.h>
+#include <Swift/QtUI/QtVCardWidget/QtVCardRoleField.h>
+#include <Swift/QtUI/QtVCardWidget/QtVCardTelephoneField.h>
+#include <Swift/QtUI/QtVCardWidget/QtVCardTitleField.h>
+#include <Swift/QtUI/QtVCardWidget/QtVCardURLField.h>
#include <Swift/QtUI/QtSwiftUtil.h>
-#include <Swiften/Base/Log.h>
-
namespace Swift {
QtVCardWidget::QtVCardWidget(QWidget* parent) :
@@ -42,7 +39,6 @@ QtVCardWidget::QtVCardWidget(QWidget* parent) :
ui->cardFields->setColumnStretch(4,2);
menu = new QMenu(this);
- menu->addMenu(ui->photoAndName->getAddFieldMenu());
ui->toolButton->setMenu(menu);
addFieldType(menu, boost::make_shared<QtVCardInternetEMailField::FieldInfo>());
@@ -89,7 +85,6 @@ void QtVCardWidget::setEditable(bool editable) {
}
void QtVCardWidget::setVCard(VCard::ref vcard) {
- SWIFT_LOG(debug) << std::endl;
clearFields();
this->vcard = vcard;
ui->photoAndName->setFormattedName(P2QSTRING(vcard->getFullName()));
@@ -184,7 +179,6 @@ void QtVCardWidget::setVCard(VCard::ref vcard) {
}
VCard::ref QtVCardWidget::getVCard() {
- SWIFT_LOG(debug) << std::endl;
clearEmptyFields();
vcard->setFullName(Q2PSTRING(ui->photoAndName->getFormattedName()));
vcard->setNickname(Q2PSTRING(ui->photoAndName->getNickname()));