diff options
author | Tobias Markmann <tm@ayena.de> | 2015-05-31 09:03:46 (GMT) |
---|---|---|
committer | Kevin Smith <kevin.smith@isode.com> | 2015-05-31 16:51:34 (GMT) |
commit | c62f1fc1006474809597a75ed920795da38e4113 (patch) | |
tree | 5324b2e9079b5610dfcc3e8444a5cd9f01fa3ce0 /Swift | |
parent | e677a606d5f3d4ef5b0e6a29ec8eb996f197600b (diff) | |
download | swift-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.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); |