[Uml-devel] KDE/kdesdk/umbrello/umbrello
Andi Fischer
andi.fischer at hispeed.ch
Mon Dec 26 23:07:35 UTC 2011
SVN commit 1270635 by fischer:
More code changes from branch also applied.
M +67 -75 umllistview.cpp
--- trunk/KDE/kdesdk/umbrello/umbrello/umllistview.cpp #1270634:1270635
@@ -149,7 +149,7 @@
{
if (m_editItem) {
DEBUG(DBG_SRC) << item->text(column);
- cancelRename(m_editItem);
+ endRename(static_cast<UMLListViewItem*>(item));
}
}
@@ -158,29 +158,20 @@
*/
void UMLListView::slotItemSelectionChanged()
{
+ UMLListViewItem* currItem = static_cast<UMLListViewItem*>(currentItem());
+ if (currItem && currItem->isSelected()) {
+ DEBUG(DBG_SRC) << currItem->text(0);
if (m_editItem) {
+ if (m_editItem == currItem) {
+ // clicked on the item which is just edited
+ endRename(currItem);
+ }
+ else {
+ // other item was selected during editing
cancelRename(m_editItem);
}
}
-
-/**
- * Calls updateFolder() on the item to update the icon to open.
- */
-void UMLListView::slotExpanded(QTreeWidgetItem * item)
-{
- UMLListViewItem * myItem = static_cast<UMLListViewItem*>(item);
- if (isExpandable(myItem->type()))
- myItem->updateFolder();
}
-
-/**
- * Calls updateFolder() on the item to update the icon to closed.
- */
-void UMLListView::slotCollapsed(QTreeWidgetItem * item)
-{
- UMLListViewItem * myItem = static_cast<UMLListViewItem*>(item);
- if (isExpandable(myItem->type()))
- myItem->updateFolder();
}
/**
@@ -240,7 +231,13 @@
clearSelection();
// Get the UMLListViewItem at the point where the mouse pointer was pressed
- UMLListViewItem * item = (UMLListViewItem*)itemAt(me->pos());
+ UMLListViewItem * item = static_cast<UMLListViewItem*>(itemAt(me->pos()));
+ if (item) {
+ DEBUG(DBG_SRC) << UMLListViewItem::toString(item->type());
+ }
+ else {
+ DEBUG(DBG_SRC) << "item is NULL";
+ }
const Qt::ButtonState button = me->button();
@@ -302,7 +299,7 @@
QTreeWidget::mouseReleaseEvent(me);
return;
}
- UMLListViewItem *item = dynamic_cast<UMLListViewItem*>(itemAt(me->pos()));
+ UMLListViewItem *item = static_cast<UMLListViewItem*>(itemAt(me->pos()));
if (item == 0 || !Model_Utils::typeIsDiagram(item->type())) {
QTreeWidget::mouseReleaseEvent(me);
return;
@@ -325,16 +322,7 @@
// Widgets have been selected in the diagram area,
// assume they handle the keypress.
ke->accept(); // munge and do nothing
- } else if (m_editItem) {
- const int k = ke->key();
- if (k == Qt::Key_Return)
- endRename(m_editItem);
- else {
- QWidget *editor = indexWidget(indexFromItem(m_editItem));
- if (editor)
- QCoreApplication::sendEvent(editor,ke);
}
- }
else {
const int k = ke->key();
if (k == Qt::Key_Delete || k == Qt::Key_Backspace) {
@@ -343,19 +331,7 @@
foreach(UMLListViewItem *item, itemsSelected) {
deleteItem(item);
}
- }
- else if (k == Qt::Key_Up || k == Qt::Key_Down) {
- UMLListViewItem *current = static_cast<UMLListViewItem*>(currentItem());
- UMLListViewItem *item = static_cast<UMLListViewItem*>((k == Qt::Key_Down) ? itemBelow(current) : itemAbove(current));
- if (item) {
- Uml::IDType id = item->getID();
- UMLObject *o = item->umlObject();
- setCurrentItem(item);
- m_doc->changeCurrentView(id);
- UMLApp::app()->docWindow()->showDocumentation(o, false);
- }
- }
- else {
+ } else {
QTreeWidget::keyPressEvent(ke); // let parent handle it
}
}
@@ -792,9 +768,9 @@
return;
}
const Uml::DiagramType dt = v->umlScene()->type();
- UMLListViewItem * temp = 0, *p = findFolderForDiagram(dt);
- temp = new UMLListViewItem(p, v->umlScene()->name(), Model_Utils::convert_DT_LVT(dt), id);
- setSelected(temp, true);
+ UMLListViewItem* p = findFolderForDiagram(dt);
+ UMLListViewItem* item = new UMLListViewItem(p, v->umlScene()->name(), Model_Utils::convert_DT_LVT(dt), id);
+ setSelected(item, true);
UMLApp::app()->docWindow()->showDocumentation(v , false);
}
@@ -1088,13 +1064,13 @@
*/
void UMLListView::slotDiagramRenamed(Uml::IDType id)
{
- UMLListViewItem* temp;
+ UMLListViewItem* item;
UMLView* v = m_doc->findView(id);
- if ((temp = findView(v)) == 0) {
+ if ((item = findView(v)) == 0) {
uError() << "UMLDoc::findView(" << ID2STR(id) << ") returns 0";
return;
}
- temp->setText(v->name());
+ item->setText(v->name());
}
/**
@@ -1267,7 +1243,8 @@
if (foundItem)
return foundItem;
}
- uWarning() << "returning 0 at UMLListView::findView";
+ uWarning() << "returning 0";
+ DEBUG(DBG_SRC) << "but was looking for " << *item;
return 0;
}
@@ -1399,7 +1376,7 @@
UMLApp::app()->docWindow()->updateDocumentation(false);
pView->umlScene()->showPropDialog();
UMLApp::app()->docWindow()->showDocumentation(pView, true);
- item->cancelRename(0);
+//:TODO:delete? item->cancelRename(0);
return;
}
//else see if an object
@@ -1436,10 +1413,11 @@
break;
}
- if (object)
+ if (object) {
object->showPropertiesPagedDialog(page);
- item->cancelRename(0); //double click can cause it to go into rename mode.
}
+//:TODO:delete? item->cancelRename(0); //double click can cause it to go into rename mode.
+}
/**
* Event handler for accepting drag request.
@@ -1595,7 +1573,7 @@
{
UMLCanvasObject *o = static_cast<UMLCanvasObject*>(item->umlObject());
if (o == 0) {
- DEBUG(DBG_SRC) << item->getText() << ": item's UMLObject is 0";
+ DEBUG(DBG_SRC) << item->text(0) << ": item's UMLObject is 0";
} else if (Model_Utils::typeIsContainer(parent->type())) {
/**** TBC: Do this here?
If yes then remove that logic at the callers
@@ -1608,7 +1586,7 @@
o->setUMLPackage(pkg);
pkg->addObject(o);
} else {
- uError() << item->getText() << ": parent type is " << parent->type();
+ uError() << item->text(0) << ": parent type is " << parent->type();
}
UMLView *currentView = UMLApp::app()->currentView();
if (currentView)
@@ -1888,7 +1866,7 @@
return;
}
UMLListViewItem *newParent = (UMLListViewItem*)item;
- DEBUG(DBG_SRC) << "newParent->getText() is " << newParent->getText();
+ DEBUG(DBG_SRC) << "slotDropped: newParent->text(0) is " << newParent->text(0);
UMLDragData::LvTypeAndID_It it(srcList);
UMLDragData::LvTypeAndID * src = 0;
while (it.hasNext()) {
@@ -1912,7 +1890,7 @@
itemList.append(item);
}
}
- DEBUG(DBG_SRC) << "selected items = " << itemList.count();
+ // DEBUG(DBG_SRC) << "selected items = " << itemList.count();
return itemList;
}
@@ -1938,7 +1916,6 @@
}
}
}
- DEBUG(DBG_SRC) << "selected items = " << itemList.count();
return itemList;
}
@@ -2014,13 +1991,13 @@
//it could exist an Item already asocciated if the user chose to reuse an uml object
if(!(item = findItem(newID))) {
pObject = m_doc->findObjectById( IDChanges.findNewID(Data.getID()) );
- item = new UMLListViewItem(parent, Data.getText(), lvt, pObject);
+ item = new UMLListViewItem(parent, Data.text(0), lvt, pObject);
} ***/
pObject = m_doc->findObjectById(Data.getID());
- item = new UMLListViewItem(parent, Data.getText(), lvt, pObject);
+ item = new UMLListViewItem(parent, Data.text(0), lvt, pObject);
break;
case UMLListViewItem::lvt_Datatype_Folder:
- item = new UMLListViewItem(parent, Data.getText(), lvt);
+ item = new UMLListViewItem(parent, Data.text(0), lvt);
break;
case UMLListViewItem::lvt_Attribute:
case UMLListViewItem::lvt_EntityAttribute:
@@ -2035,7 +2012,7 @@
Uml::IDType newID = IDChanges.findNewID(Data.getID());
pObject = pClass->findChildObjectById(newID);
if (pObject) {
- item = new UMLListViewItem(parent, Data.getText(), lvt, pObject);
+ item = new UMLListViewItem(parent, Data.text(0), lvt, pObject);
} else {
item = 0;
}
@@ -2113,18 +2090,10 @@
*/
int UMLListView::selectedItemsCount()
{
- QTreeWidgetItemIterator it(this);
- int count = 0;
- // iterate through all items of the list view
- for (; *it; ++it) {
- if ((*it)->isSelected()) {
- count++;
+ UMLListViewItemList items = selectedItems();
+ return items.count();
}
- }
- return count;
-}
-
/**
* Returns the document pointer. Called by the UMLListViewItem class.
*/
@@ -2198,6 +2167,28 @@
}
/**
+ * Calls updateFolder() on the item to update the icon to open.
+ */
+void UMLListView::slotExpanded(QTreeWidgetItem * item)
+{
+ UMLListViewItem * myItem = static_cast<UMLListViewItem*>(item);
+ if (isExpandable(myItem->type())) {
+ myItem->updateFolder();
+ }
+}
+
+/**
+ * Calls updateFolder() on the item to update the icon to closed.
+ */
+void UMLListView::slotCollapsed(QTreeWidgetItem * item)
+{
+ UMLListViewItem * myItem = static_cast<UMLListViewItem*>(item);
+ if (isExpandable(myItem->type())) {
+ myItem->updateFolder();
+ }
+}
+
+/**
* Connects to the signal that @ref UMLApp emits when a
* cut operation is successful.
*/
@@ -2250,13 +2241,14 @@
} else {
UMLObject::ObjectType ot = Model_Utils::convert_LVT_OT(type);
if (ot == UMLObject::ot_UMLObject) {
- DEBUG(DBG_SRC) << "no UMLObject for listview type " << type;
+ DEBUG(DBG_SRC) << "no UMLObject for type " << UMLListViewItem::toString(type);
return;
}
UMLPackage *parentPkg =
dynamic_cast<UMLPackage*>(parentItem->umlObject());
if (parentPkg == 0) {
- uError() << "type " << type << ": parentPkg is 0";
+ uError() << "UMLListView::addNewItem - "
+ << UMLListViewItem::toString(type) << ": parentPkg is 0";
return;
}
if (Model_Utils::typeIsClassifierList(type)) {
@@ -2265,7 +2257,7 @@
} else {
name = Model_Utils::uniqObjectName(ot, parentPkg);
}
- newItem = new UMLListViewItem(parentItem, name, type, (UMLObject*)0);
+ newItem = new UMLListViewItem(parentItem, name, type, (UMLObject*)parentPkg);
}
m_bIgnoreCancelRename = false;
newItem->setIcon(icon);
More information about the umbrello-devel
mailing list