summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2013-10-16 10:33:29 (GMT)
committerSwift Review <review@swift.im>2013-10-26 15:30:39 (GMT)
commitef23be16e875d8dbc5aae58c191b09ada94776af (patch)
tree907a3f382d1d815901df3904865f19afc00fcdca /Swift/QtUI/QtVCardWidget
parent60c5c9f13b97c25e3b73f57fc107622d483d5160 (diff)
downloadswift-ef23be16e875d8dbc5aae58c191b09ada94776af.zip
swift-ef23be16e875d8dbc5aae58c191b09ada94776af.tar.bz2
VCard: Guarantee an empty row when editing organisation units, so the user can add new units.
Change-Id: Ibdc132467e69ff906c4b4bea2d12f8b5704cf74c License: This patch is BSD-licensed, see Documentation/Licenses/BSD-simplified.txt for details.
Diffstat (limited to 'Swift/QtUI/QtVCardWidget')
-rw-r--r--Swift/QtUI/QtVCardWidget/QtVCardOrganizationField.cpp16
-rw-r--r--Swift/QtUI/QtVCardWidget/QtVCardOrganizationField.h16
2 files changed, 23 insertions, 9 deletions
diff --git a/Swift/QtUI/QtVCardWidget/QtVCardOrganizationField.cpp b/Swift/QtUI/QtVCardWidget/QtVCardOrganizationField.cpp
index 7f6c23d..99e5f0b 100644
--- a/Swift/QtUI/QtVCardWidget/QtVCardOrganizationField.cpp
+++ b/Swift/QtUI/QtVCardWidget/QtVCardOrganizationField.cpp
@@ -4,12 +4,13 @@
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
-#include "QtVCardOrganizationField.h"
+#include <Swift/QtUI/QtVCardWidget/QtVCardOrganizationField.h>
+
+#include <boost/algorithm/string.hpp>
#include <QGridLayout>
#include <QHBoxLayout>
#include <QHeaderView>
-#include <boost/algorithm/string.hpp>
#include <Swift/QtUI/QtSwiftUtil.h>
@@ -37,6 +38,7 @@ void QtVCardOrganizationField::setupContentWidgets() {
itemDelegate = new QtRemovableItemDelegate(style());
unitsTreeWidget = new QTreeWidget(this);
+ connect(unitsTreeWidget->model(), SIGNAL(rowsRemoved(QModelIndex, int, int)), SLOT(handleRowsRemoved(QModelIndex,int,int)));
unitsTreeWidget->setColumnCount(2);
unitsTreeWidget->header()->setStretchLastSection(false);
int closeIconWidth = style()->pixelMetric(QStyle::PM_TabCloseIndicatorWidth, 0, 0);
@@ -117,6 +119,14 @@ void QtVCardOrganizationField::handleEditibleChanged(bool isEditable) {
}
void QtVCardOrganizationField::handleItemChanged(QTreeWidgetItem *, int) {
+ guaranteeEmptyRow();
+}
+
+void QtVCardOrganizationField::handleRowsRemoved(const QModelIndex&, int, int) {
+ guaranteeEmptyRow();
+}
+
+void QtVCardOrganizationField::guaranteeEmptyRow() {
bool hasEmptyRow = false;
QList<QTreeWidgetItem*> rows = unitsTreeWidget->findItems("", Qt::MatchFixedString);
foreach(QTreeWidgetItem* row, rows) {
@@ -129,8 +139,8 @@ void QtVCardOrganizationField::handleItemChanged(QTreeWidgetItem *, int) {
QTreeWidgetItem* item = new QTreeWidgetItem(QStringList("") << "");
item->setFlags(item->flags() | Qt::ItemIsEditable);
unitsTreeWidget->addTopLevelItem(item);
+ unitsTreeWidget->setCurrentItem(item);
}
- getTagComboBox()->hide();
}
}
diff --git a/Swift/QtUI/QtVCardWidget/QtVCardOrganizationField.h b/Swift/QtUI/QtVCardWidget/QtVCardOrganizationField.h
index 917e22a..47868a7 100644
--- a/Swift/QtUI/QtVCardWidget/QtVCardOrganizationField.h
+++ b/Swift/QtUI/QtVCardWidget/QtVCardOrganizationField.h
@@ -6,14 +6,14 @@
#pragma once
-#include <Swiften/Elements/VCard.h>
-
#include <QTreeWidget>
-#include "QtRemovableItemDelegate.h"
-#include "QtResizableLineEdit.h"
-#include "QtVCardFieldInfo.h"
-#include "QtVCardGeneralField.h"
+#include <Swiften/Elements/VCard.h>
+
+#include <Swift/QtUI/QtVCardWidget/QtRemovableItemDelegate.h>
+#include <Swift/QtUI/QtVCardWidget/QtResizableLineEdit.h>
+#include <Swift/QtUI/QtVCardWidget/QtVCardFieldInfo.h>
+#include <Swift/QtUI/QtVCardWidget/QtVCardGeneralField.h>
namespace Swift {
@@ -39,6 +39,10 @@ class QtVCardOrganizationField : public QtVCardGeneralField {
private slots:
void handleItemChanged(QTreeWidgetItem*, int);
+ void handleRowsRemoved(const QModelIndex&, int, int);
+
+ private:
+ void guaranteeEmptyRow();
private:
QLabel* organizationLabel;