-/*******************************************************************************
-
- This file is part of mDictionary.
-
- mDictionary is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- mDictionary is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with mDictionary. If not, see <http://www.gnu.org/licenses/>.
-
- Copyright 2010 Comarch S.A.
-
-*******************************************************************************/
-//! \file TranslationWidgetAutoResizer.h
-//! \brief Implements translation widget auto resizer
-//! \author Mateusz Półrola <mateusz.polrola@comarch.pl>a
-
-#ifndef TRANSLATIONWIDGETAUTORESIZER_H
-#define TRANSLATIONWIDGETAUTORESIZER_H
-
-#include <QtGui/qtextedit.h>
-class TranslationWidgetAutoResizer : public QObject
-{
- Q_OBJECT
-
-public:
- TranslationWidgetAutoResizer(QWidget *parent) :QObject(parent),
- textEdit(qobject_cast<QTextEdit* >((parent))),
- edit(qobject_cast<QFrame* >((parent))) {
-
- // connect(parent, SIGNAL(textChanged()), this,
- // SLOT(textEditChanged()));
- // connect(parent, SIGNAL(cursorPositionChanged()),
- // this, SLOT(textEditChanged()));
- }
-
-public Q_SLOTS:
- inline void textEditChanged();
-
-private:
- QTextEdit *textEdit;
- QFrame *edit;
-};
-
-void TranslationWidgetAutoResizer::textEditChanged() {
- QTextDocument *doc = textEdit->document();
-
- QSize s = doc->size().toSize();
-
- const QRect fr = edit->frameRect();
- const QRect cr = edit->contentsRect();
-
- edit->setMinimumHeight(qMax(70, s.height() + (fr.height() - cr.height()) -
- 1));
-
- edit->setMinimumHeight(qMax(70, s.height() + (fr.height() - cr.height()) -
- 1));
-}
-
-#endif // TRANSLATIONWIDGETAUTORESIZER_H