[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdebase/apps/plasma/applets/folderview
From: Fredrik Höglund <fredrik () kde ! org>
Date: 2008-06-12 17:24:35
Message-ID: 1213291475.810509.22026.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 819943 by fredrik:
Implement support for renaming files.
M +42 -1 folderview.cpp
M +4 -0 folderview.h
--- trunk/KDE/kdebase/apps/plasma/applets/folderview/folderview.cpp #819942:819943
@@ -87,6 +87,10 @@
connect(m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), \
SLOT(layoutChanged(QModelIndex,QModelIndex)));
m_delegate = new KFileItemDelegate(this);
+ connect(m_delegate, \
SIGNAL(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)), + \
SLOT(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint))); + \
connect(m_delegate, SIGNAL(commitData(QWidget*)), SLOT(commitData(QWidget*))); +
m_selectionModel = new QItemSelectionModel(m_model, this);
if ( args.count() ) {
@@ -577,9 +581,46 @@
void FolderView::renameSelectedIcon()
{
- // TODO Implement me!
+ QModelIndex index = m_selectionModel->currentIndex();
+ if (!index.isValid())
+ return;
+
+ QStyleOptionViewItemV4 option = viewOptions();
+ option.rect = mapToScene(visualRect(index)).boundingRect().toRect();
+
+ // ### Note that we don't embed the editor in the applet as a
+ // QGraphicsProxyWidget here, because calling setFocus() on the
+ // editor or the proxy doesn't work properly when we do.
+ QWidget *editor = m_delegate->createEditor(view(), option, index);
+ editor->installEventFilter(m_delegate);
+
+ m_delegate->updateEditorGeometry(editor, option, index);
+ m_delegate->setEditorData(editor, index);
+
+ editor->show();
+ editor->setFocus();
+
+ m_editorIndex = index;
}
+void FolderView::commitData(QWidget *editor)
+{
+ m_delegate->setModelData(editor, m_model, m_editorIndex);
+}
+
+void FolderView::closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHint \
hint) +{
+ Q_UNUSED(hint)
+
+ if (editor->hasFocus()) {
+ setFocus();
+ }
+ editor->hide();
+ editor->removeEventFilter(m_delegate);
+ editor->deleteLater();
+ update();
+}
+
void FolderView::moveToTrash(Qt::MouseButtons buttons, Qt::KeyboardModifiers \
modifiers) {
Q_UNUSED(buttons)
--- trunk/KDE/kdebase/apps/plasma/applets/folderview/folderview.h #819942:819943
@@ -77,6 +77,9 @@
void deleteSelectedIcons();
void undoTextChanged(const QString &text);
+ void commitData(QWidget *editor);
+ void closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHint hint);
+
private:
void createActions();
KUrl::List selectedUrls() const;
@@ -117,6 +120,7 @@
mutable bool m_layoutValid;
QPersistentModelIndex m_hoveredIndex;
QPersistentModelIndex m_pressedIndex;
+ QPersistentModelIndex m_editorIndex;
QRect m_rubberBand;
QPointF m_buttonDownPos;
QTime m_pressTime;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic