summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI')
-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;