diff options
Diffstat (limited to 'Swift')
-rw-r--r-- | Swift/QtUI/QtVCardWidget/QtVCardWidget.cpp | 22 | ||||
-rw-r--r-- | Swift/QtUI/QtVCardWidget/QtVCardWidget.h | 20 |
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); |