summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2015-05-31 09:03:46 (GMT)
committerKevin Smith <kevin.smith@isode.com>2015-05-31 16:51:34 (GMT)
commitc62f1fc1006474809597a75ed920795da38e4113 (patch)
tree5324b2e9079b5610dfcc3e8444a5cd9f01fa3ce0 /Swift
parente677a606d5f3d4ef5b0e6a29ec8eb996f197600b (diff)
downloadswift-c62f1fc1006474809597a75ed920795da38e4113.zip
swift-c62f1fc1006474809597a75ed920795da38e4113.tar.bz2
Overriding QtVCardWidget::sizeHint() so ideally there is no scrolling
Test-Information: Tested on OS X 10.9.5 with Qt 5.4.1. Change-Id: I27ba80b9799fd8177a291ec0b8eeb0c2168e2f04
Diffstat (limited to 'Swift')
-rw-r--r--Swift/QtUI/QtVCardWidget/QtVCardWidget.cpp22
-rw-r--r--Swift/QtUI/QtVCardWidget/QtVCardWidget.h20
2 files changed, 33 insertions, 9 deletions
diff --git a/Swift/QtUI/QtVCardWidget/QtVCardWidget.cpp b/Swift/QtUI/QtVCardWidget/QtVCardWidget.cpp
index 6b80084..e202de5 100644
--- a/Swift/QtUI/QtVCardWidget/QtVCardWidget.cpp
+++ b/Swift/QtUI/QtVCardWidget/QtVCardWidget.cpp
@@ -5,18 +5,19 @@
*/
/*
- * Copyright (c) 2014 Isode Limited.
+ * Copyright (c) 2014-2015 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Swift/QtUI/QtVCardWidget/QtVCardWidget.h>
+#include <Swift/QtUI/QtVCardWidget/ui_QtVCardWidget.h>
#include <QDebug>
#include <QLineEdit>
#include <QMenu>
-#include <Swift/QtUI/QtVCardWidget/ui_QtVCardWidget.h>
+#include <Swift/QtUI/QtSwiftUtil.h>
#include <Swift/QtUI/QtVCardWidget/QtVCardAddressField.h>
#include <Swift/QtUI/QtVCardWidget/QtVCardAddressLabelField.h>
#include <Swift/QtUI/QtVCardWidget/QtVCardBirthdayField.h>
@@ -29,7 +30,6 @@
#include <Swift/QtUI/QtVCardWidget/QtVCardTelephoneField.h>
#include <Swift/QtUI/QtVCardWidget/QtVCardTitleField.h>
#include <Swift/QtUI/QtVCardWidget/QtVCardURLField.h>
-#include <Swift/QtUI/QtSwiftUtil.h>
namespace Swift {
@@ -66,12 +66,27 @@ QtVCardWidget::QtVCardWidget(QWidget* parent) :
addFieldType(menu, boost::make_shared<QtVCardURLField::FieldInfo>());
setEditable(false);
+ setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
}
QtVCardWidget::~QtVCardWidget() {
delete ui;
}
+QSize QtVCardWidget::sizeHint() const {
+ QSize newSizeHint = ui->photoAndName->sizeHint();
+
+ // use mininmal size that does not require scrolling
+ QSize fieldsWidgetSize = ui->scrollArea->widget()->minimumSize();
+ fieldsWidgetSize.setWidth(ui->scrollArea->widget()->sizeHint().width());
+
+ newSizeHint += QSize(0, ui->line->height());
+
+ newSizeHint = QSize(std::max(newSizeHint.width(), fieldsWidgetSize.width()), newSizeHint.height() + fieldsWidgetSize.height());
+
+ return newSizeHint;
+}
+
bool QtVCardWidget::isEditable() const {
return editable;
}
@@ -182,7 +197,6 @@ void QtVCardWidget::setVCard(VCard::ref vcard) {
relayoutToolButton();
setEditable(editable);
- window()->resize(sizeHint().width(), size().height() < 200 ? 200 : size().height());
}
VCard::ref QtVCardWidget::getVCard() {
diff --git a/Swift/QtUI/QtVCardWidget/QtVCardWidget.h b/Swift/QtUI/QtVCardWidget/QtVCardWidget.h
index 29ed499..8c0ff31 100644
--- a/Swift/QtUI/QtVCardWidget/QtVCardWidget.h
+++ b/Swift/QtUI/QtVCardWidget/QtVCardWidget.h
@@ -4,16 +4,24 @@
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
+/*
+ * Copyright (c) 2015 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+
#pragma once
-#include <QWidget>
+#include <boost/smart_ptr/make_shared.hpp>
+
#include <QToolButton>
+#include <QWidget>
+
#include <Swiften/Elements/VCard.h>
-#include <boost/smart_ptr/make_shared.hpp>
-#include "QtVCardFieldInfo.h"
-#include "QtVCardGeneralField.h"
-#include "QtVCardPhotoAndNameFields.h"
+#include <Swift/QtUI/QtVCardWidget/QtVCardFieldInfo.h>
+#include <Swift/QtUI/QtVCardWidget/QtVCardGeneralField.h>
+#include <Swift/QtUI/QtVCardWidget/QtVCardPhotoAndNameFields.h>
namespace Ui {
class QtVCardWidget;
@@ -35,6 +43,8 @@ namespace Swift {
void setVCard(VCard::ref vcard);
VCard::ref getVCard();
+ virtual QSize sizeHint() const;
+
signals:
void editableChanged(bool editable);