┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/kitemviews/kfileitemlistwidget.cpp3
-rw-r--r--src/kitemviews/private/kitemlistroleeditor.cpp18
-rw-r--r--src/kitemviews/private/kitemlistroleeditor.h5
3 files changed, 20 insertions, 6 deletions
diff --git a/src/kitemviews/kfileitemlistwidget.cpp b/src/kitemviews/kfileitemlistwidget.cpp
index 39ed02f07..83df9da70 100644
--- a/src/kitemviews/kfileitemlistwidget.cpp
+++ b/src/kitemviews/kfileitemlistwidget.cpp
@@ -544,6 +544,9 @@ void KFileItemListWidget::editedRoleChanged(const QByteArray& current, const QBy
if (rect.right() > parent->width()) {
rect.setWidth(parent->width() - rect.left());
}
+ if (rect.bottom() > parent->height()) {
+ rect.setHeight(parent->height() - rect.top());
+ }
m_roleEditor->setGeometry(rect.toRect());
m_roleEditor->show();
m_roleEditor->setFocus();
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"
diff --git a/src/kitemviews/private/kitemlistroleeditor.h b/src/kitemviews/private/kitemlistroleeditor.h
index 8a1439565..652bd904c 100644
--- a/src/kitemviews/private/kitemlistroleeditor.h
+++ b/src/kitemviews/private/kitemlistroleeditor.h
@@ -31,8 +31,7 @@
* pressing Escape or when losing the focus) or when the editing
* got finished (e.g. by pressing Enter or Return).
*
- * The width automatically gets increased if the text does not
- * fit into the available width.
+ * The size automatically gets increased if the text does not fit.
*/
class LIBDOLPHINPRIVATE_EXPORT KItemListRoleEditor : public KTextEdit
{
@@ -60,7 +59,7 @@ protected:
private slots:
/**
- * Increases the width of the editor in case if there is not
+ * Increases the size of the editor in case if there is not
* enough room for the text.
*/
void autoAdjustSize();