diff options
| author | Peter Penz <[email protected]> | 2012-04-18 01:14:41 +0200 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2012-04-18 01:15:49 +0200 |
| commit | 7afd2f0ae10f1af594cb83f2ff34161baccf67cc (patch) | |
| tree | 5fd89d5777a378fd0a001159984f134d12e69081 /src/kitemviews/private/kitemlistroleeditor.cpp | |
| parent | beeb9078f543af84e6364f1f5fe214453388f1b9 (diff) | |
Inline renaming fixes
- Increase the editor-height in the icons-view if required
- Don't try to react on resizings of the parent, just finish
the renaming
Diffstat (limited to 'src/kitemviews/private/kitemlistroleeditor.cpp')
| -rw-r--r-- | src/kitemviews/private/kitemlistroleeditor.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/kitemviews/private/kitemlistroleeditor.cpp b/src/kitemviews/private/kitemlistroleeditor.cpp index 55af6a9c7..815da4c70 100644 --- a/src/kitemviews/private/kitemlistroleeditor.cpp +++ b/src/kitemviews/private/kitemlistroleeditor.cpp @@ -63,7 +63,7 @@ QByteArray KItemListRoleEditor::role() const bool KItemListRoleEditor::eventFilter(QObject* watched, QEvent* event) { if (watched == parentWidget() && event->type() == QEvent::Resize) { - autoAdjustSize(); + emit roleEditingFinished(m_index, m_role, toPlainText()); } return KTextEdit::eventFilter(watched, event); @@ -99,15 +99,27 @@ void KItemListRoleEditor::keyPressEvent(QKeyEvent* event) void KItemListRoleEditor::autoAdjustSize() { + const qreal frameBorder = 2 * frameWidth(); + const qreal requiredWidth = document()->size().width(); - const qreal availableWidth = size().width() - 2 * frameWidth(); + const qreal availableWidth = size().width() - frameBorder; if (requiredWidth > availableWidth) { - qreal newWidth = requiredWidth + 2 * frameWidth(); + qreal newWidth = requiredWidth + frameBorder; if (parentWidget() && pos().x() + newWidth > parentWidget()->width()) { newWidth = parentWidget()->width() - pos().x(); } resize(newWidth, size().height()); } + + const qreal requiredHeight = document()->size().height(); + const qreal availableHeight = size().height() - frameBorder; + if (requiredHeight > availableHeight) { + qreal newHeight = requiredHeight + frameBorder; + if (parentWidget() && pos().y() + newHeight > parentWidget()->height()) { + newHeight = parentWidget()->height() - pos().y(); + } + resize(size().width(), newHeight); + } } #include "kitemlistroleeditor.moc" |
