Commit 422aeee5 authored by Ralf Habacker's avatar Ralf Habacker

Reenable routing of in place list item rename to related UML objects.

CCBUG: 328973
(cherry picked from commit 86a1b2a5)
parent 456651dd
......@@ -3091,6 +3091,34 @@ void UMLListView::dropEvent(QDropEvent* event)
QTreeWidget::dropEvent(event);
}
void UMLListView::commitData(QWidget *editor)
{
if (!editor)
return;
QModelIndex index = currentIndex();
if (!index.isValid())
return;
QAbstractItemDelegate *delegate = itemDelegate(index);
editor->removeEventFilter(delegate);
QByteArray n = editor->metaObject()->userProperty().name();
if (n.isEmpty()) {
DEBUG(DBG_SRC) << "no name property found in list view item editor";
return;
}
QString newText = editor->property(n).toString();
UMLListViewItem *item = dynamic_cast<UMLListViewItem *>(currentItem());
if (!item) {
DEBUG(DBG_SRC) << "no item found after editing model index" << index;
return;
}
item->slotEditFinished(newText);
editor->installEventFilter(delegate);
}
/**
* Set the background color.
* @param color the new background color
......
......@@ -137,6 +137,7 @@ protected:
void dragEnterEvent(QDragEnterEvent* event);
void dragMoveEvent(QDragMoveEvent* event);
void dropEvent(QDropEvent* event);
void commitData(QWidget *editor);
UMLListViewItem * findUMLObjectInFolder(UMLListViewItem *folder, UMLObject *obj);
......
......@@ -456,24 +456,15 @@ void UMLListViewItem::setIcon(Icon_Utils::IconType iconType)
}
/**
* Start the rename process.
* This slot is called to finish item editing
*/
void UMLListViewItem::startRename(int col)
void UMLListViewItem::slotEditFinished(const QString &newText)
{
DEBUG(DBG_LVI) << this << " - column=" << col << ", text=" << text(col);
m_label = text(col); // keep the old text
}
m_label = text(0);
/**
* This function is called if the user presses Enter during in-place renaming
* of the item in column col.
*/
void UMLListViewItem::okRename(int col)
{
DEBUG(DBG_LVI) << this << " - column=" << col << ", text=" << text(col);
DEBUG(DBG_LVI) << this << "text=" << newText;
UMLListView* listView = static_cast<UMLListView*>(treeWidget());
UMLDoc* doc = listView->document();
QString newText = text(col);
if (newText == m_label) {
return;
}
......
......@@ -121,9 +121,6 @@ public:
void setIcon(Icon_Utils::IconType iconType);
void startRename(int col);
void okRename(int col);
void addClassifierListItem(UMLClassifierListItem *child, UMLListViewItem *childItem);
void deleteChildItem(UMLClassifierListItem *child);
......@@ -144,6 +141,9 @@ public:
bool isOpen() { return isExpanded(); }
void setOpen(bool state);
public slots:
void slotEditFinished(const QString &newText);
protected:
void init();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment