]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Inline renaming fixes
authorPeter Penz <peter.penz19@gmail.com>
Tue, 17 Apr 2012 23:14:41 +0000 (01:14 +0200)
committerPeter Penz <peter.penz19@gmail.com>
Tue, 17 Apr 2012 23:15:49 +0000 (01:15 +0200)
- Increase the editor-height in the icons-view if required
- Don't try to react on resizings of the parent, just finish
  the renaming

src/kitemviews/kfileitemlistwidget.cpp
src/kitemviews/private/kitemlistroleeditor.cpp
src/kitemviews/private/kitemlistroleeditor.h

index 39ed02f07672699e6a5633abd2661ba68a255649..83df9da702e1a75a2abe42dc5a123d987ebe4477 100644 (file)
@@ -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.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();
     m_roleEditor->setGeometry(rect.toRect());
     m_roleEditor->show();
     m_roleEditor->setFocus();
index 55af6a9c7747e752e22867548032410bbe72231a..815da4c70e5ebe454d5c2a4c6fe1fff9b172fa81 100644 (file)
@@ -63,7 +63,7 @@ QByteArray KItemListRoleEditor::role() const
 bool  KItemListRoleEditor::eventFilter(QObject* watched, QEvent* event)
 {
     if (watched == parentWidget() && event->type() == QEvent::Resize) {
 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);
     }
 
     return KTextEdit::eventFilter(watched, event);
@@ -99,15 +99,27 @@ void KItemListRoleEditor::keyPressEvent(QKeyEvent* event)
 
 void KItemListRoleEditor::autoAdjustSize()
 {
 
 void KItemListRoleEditor::autoAdjustSize()
 {
+    const qreal frameBorder = 2 * frameWidth();
+
     const qreal requiredWidth = document()->size().width();
     const qreal requiredWidth = document()->size().width();
-    const qreal availableWidth = size().width() - 2 * frameWidth();
+    const qreal availableWidth = size().width() - frameBorder;
     if (requiredWidth > availableWidth) {
     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());
     }
         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"
 }
 
 #include "kitemlistroleeditor.moc"
index 8a14395659ee3efea4c98121eb122ae233a5890e..652bd904c32dd4265ac1f4a38a4ec91ad85ca0ed 100644 (file)
@@ -31,8 +31,7 @@
  * pressing Escape or when losing the focus) or when the editing
  * got finished (e.g. by pressing Enter or Return).
  *
  * 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
 {
  */
 class LIBDOLPHINPRIVATE_EXPORT KItemListRoleEditor : public KTextEdit
 {
@@ -60,7 +59,7 @@ protected:
 
 private slots:
     /**
 
 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();
      * enough room for the text.
      */
     void autoAdjustSize();