don't override minimum and maximum sizes so often

svn path=/trunk/KDE/kdelibs/; revision=948218
This commit is contained in:
Marco Martin 2009-04-02 15:16:53 +00:00
parent 7e2bf0f2b7
commit c7aa7e7a6a

View File

@ -37,7 +37,10 @@ class TextBrowserPrivate
public: public:
TextBrowserPrivate(TextBrowser *browser) TextBrowserPrivate(TextBrowser *browser)
: q(browser), : q(browser),
native(0) native(0),
savedMinimumHeight(0),
savedMaximumHeight(QWIDGETSIZE_MAX),
wasNotFixed(true)
{ {
} }
@ -48,11 +51,17 @@ public:
native->verticalScrollBarPolicy() == Qt::ScrollBarAlwaysOff) { native->verticalScrollBarPolicy() == Qt::ScrollBarAlwaysOff) {
native->document()->setTextWidth(q->size().width()); native->document()->setTextWidth(q->size().width());
QSize s = native->document()->size().toSize(); QSize s = native->document()->size().toSize();
if (wasNotFixed) {
savedMinimumHeight = q->minimumHeight();
savedMaximumHeight = q->maximumHeight();
wasNotFixed = false;
}
q->setMinimumHeight(s.height()); q->setMinimumHeight(s.height());
q->setMaximumHeight(s.height()); q->setMaximumHeight(s.height());
} else { } else if (!wasNotFixed) {
q->setMinimumHeight(0); q->setMinimumHeight(savedMinimumHeight);
q->setMaximumHeight(QWIDGETSIZE_MAX); q->setMaximumHeight(savedMaximumHeight);
wasNotFixed = true;
} }
} }
@ -60,6 +69,9 @@ public:
TextBrowser *q; TextBrowser *q;
KTextBrowser *native; KTextBrowser *native;
Plasma::Style::Ptr style; Plasma::Style::Ptr style;
int savedMinimumHeight;
int savedMaximumHeight;
bool wasNotFixed;
}; };
TextBrowser::TextBrowser(QGraphicsWidget *parent) TextBrowser::TextBrowser(QGraphicsWidget *parent)