summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2014-09-29 14:54:48 (GMT)
committerTobias Markmann <tm@ayena.de>2014-10-07 07:06:14 (GMT)
commit80addba4a31fcb09a9703778e1ea9b984593bfd5 (patch)
tree3ca602f8ff7c490a7cad4f85f5a9c4c8800745df /Swift/QtUI/QtVCardWidget/QtVCardWidget.cpp
parent80b60a71936d0e029893958938df6e3d38cecf8b (diff)
downloadswift-contrib-80addba4a31fcb09a9703778e1ea9b984593bfd5.zip
swift-contrib-80addba4a31fcb09a9703778e1ea9b984593bfd5.tar.bz2
Hide unchecked preferred stars in profile editor where there is only one field.
Hide the preferred stars in profile editor if it is not checked and there is only one field of a field type in the vCard. Example: If you have only one eMail in your vCard it does not make much sense to mark it preferred. If it is already marked as preferred we will still display it as such. Test-Information: Manually tested it via editing a vCard of a test account. On addition or deletion of fields other fields are checked and stars hidden/shown on demand. Change-Id: I4704d52518e662f7e3a168ed2b42602383b2153f
Diffstat (limited to 'Swift/QtUI/QtVCardWidget/QtVCardWidget.cpp')
-rw-r--r--Swift/QtUI/QtVCardWidget/QtVCardWidget.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/Swift/QtUI/QtVCardWidget/QtVCardWidget.cpp b/Swift/QtUI/QtVCardWidget/QtVCardWidget.cpp
index d681fe9..7dfc06a 100644
--- a/Swift/QtUI/QtVCardWidget/QtVCardWidget.cpp
+++ b/Swift/QtUI/QtVCardWidget/QtVCardWidget.cpp
@@ -4,6 +4,12 @@
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
+/*
+ * Copyright (c) 2014 Kevin Smith and Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
#include <Swift/QtUI/QtVCardWidget/QtVCardWidget.h>
#include <QDebug>
@@ -299,6 +305,19 @@ void QtVCardWidget::addField() {
}
void QtVCardWidget::removeField(QtVCardGeneralField *field) {
+ int sameFields = 0;
+ QtVCardGeneralField* fieldToChange = NULL;
+ foreach (QtVCardGeneralField* vcardField, fields) {
+ if ((vcardField != field) && (typeid(*vcardField) == typeid(*field))) {
+ sameFields++;
+ fieldToChange = vcardField;
+ }
+ }
+
+ if ((sameFields == 1) && fieldToChange) {
+ fieldToChange->setStarVisible(false);
+ }
+
fields.remove(field);
delete field;
}
@@ -364,6 +383,20 @@ void QtVCardWidget::clearEmptyFields() {
void QtVCardWidget::appendField(QtVCardGeneralField *field) {
connect(field, SIGNAL(deleteField(QtVCardGeneralField*)), SLOT(removeField(QtVCardGeneralField*)));
+
+ QtVCardGeneralField* fieldToChange = NULL;
+ foreach (QtVCardGeneralField* vcardField, fields) {
+ if (typeid(*vcardField) == typeid(*field)) {
+ fieldToChange = vcardField;
+ break;
+ }
+ }
+
+ if (fieldToChange) {
+ fieldToChange->setStarVisible(true);
+ field->setStarVisible(true);
+ }
+
fields.push_back(field);
}