• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdesdk API Reference
  • KDE Home
  • Contact Us
 

umbrello/umbrello

  • sources
  • kde-4.12
  • kdesdk
  • umbrello
  • umbrello
umllistview.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * This program is free software; you can redistribute it and/or modify *
3  * it under the terms of the GNU General Public License as published by *
4  * the Free Software Foundation; either version 2 of the License, or *
5  * (at your option) any later version. *
6  * *
7  * copyright (C) 2002-2013 *
8  * Umbrello UML Modeller Authors <umbrello-devel@kde.org> *
9  ***************************************************************************/
10 
11 // own header
12 #include "umllistview.h"
13 
14 // app includes
15 #include "actor.h"
16 #include "classifier.h"
17 #include "debug_utils.h"
18 #include "package.h"
19 #include "folder.h"
20 #include "component.h"
21 #include "node.h"
22 #include "artifact.h"
23 #include "enum.h"
24 #include "enumliteral.h"
25 #include "entity.h"
26 #include "category.h"
27 #include "docwindow.h"
28 #include "layoutgenerator.h"
29 #include "listpopupmenu.h"
30 #include "template.h"
31 #include "operation.h"
32 #include "attribute.h"
33 #include "entityattribute.h"
34 #include "uniqueconstraint.h"
35 #include "foreignkeyconstraint.h"
36 #include "checkconstraint.h"
37 #include "uml.h"
38 #include "umldoc.h"
39 #include "umllistviewitemlist.h"
40 #include "umllistviewitem.h"
41 #include "umlscene.h"
42 #include "umlview.h"
43 #include "umlviewimageexporter.h"
44 #include "usecase.h"
45 #include "model_utils.h"
46 #include "uniqueid.h"
47 #include "idchangelog.h"
48 #include "umldragdata.h"
49 #include "classpropdlg.h"
50 #include "umlattributedialog.h"
51 #include "umlentityattributedialog.h"
52 #include "umloperationdialog.h"
53 #include "umltemplatedialog.h"
54 #include "umluniqueconstraintdialog.h"
55 #include "umlforeignkeyconstraintdialog.h"
56 #include "umlcheckconstraintdialog.h"
57 
58 // kde includes
59 #include <kfiledialog.h>
60 #include <klocale.h>
61 #include <kmessagebox.h>
62 #include <kinputdialog.h>
63 #include <kapplication.h>
64 
65 // qt includes
66 #include <QDropEvent>
67 #include <QEvent>
68 #include <QFocusEvent>
69 #include <QKeyEvent>
70 #include <QMouseEvent>
71 #include <QPointer>
72 #include <QRegExp>
73 #include <QPoint>
74 #include <QRect>
75 #include <QToolTip>
76 
77 DEBUG_REGISTER(UMLListView)
78 
79 
84 UMLListView::UMLListView(QWidget *parent)
85  : QTreeWidget(parent),
86  m_rv(0),
87  m_datatypeFolder(0),
88  m_doc(UMLApp::app()->document()),
89  m_bStartedCut(false),
90  m_bStartedCopy(false),
91  m_bCreatingChildObject(false),
92  m_dragStartPosition(QPoint())
93 {
94  // setup list view
95  setAcceptDrops(true);
96  //setDropVisualizer(false);
97  //setItemsMovable(true);
98  //setItemsRenameable(true);
99  //setSelectionModeExt(FileManager);
100  setFocusPolicy(Qt::StrongFocus);
101  setDragEnabled(true);
102  //setColumnWidthMode(0, Manual);
103  //setDefaultRenameAction(Accept);
104  //setResizeMode(LastColumn);
105  //header()->setClickEnabled(true);
106  //add columns and initial items
107  //addColumn(m_doc->name());
108  setSortingEnabled(true);
109  sortByColumn(0, Qt::AscendingOrder);
110 
111  setEditTriggers(QAbstractItemView::EditKeyPressed);
112 
113  for (int i = 0; i < Uml::ModelType::N_MODELTYPES; ++i) {
114  m_lv[i] = 0;
115  }
116 
117  //setup slots/signals
118  connect(this, SIGNAL(itemCollapsed(QTreeWidgetItem*)), this, SLOT(slotCollapsed(QTreeWidgetItem*)));
119  connect(this, SIGNAL(itemExpanded(QTreeWidgetItem*)), this, SLOT(slotExpanded(QTreeWidgetItem*)));
120  connect(UMLApp::app(), SIGNAL(sigCutSuccessful()), this, SLOT(slotCutSuccessful()));
121  connect(this, SIGNAL(itemSelectionChanged()), this, SLOT(slotItemSelectionChanged()));
122 }
123 
127 UMLListView::~UMLListView()
128 {
129  delete m_datatypeFolder;
130 }
131 
137 void UMLListView::setTitle(int column, const QString &text)
138 {
139  headerItem()->setText(column, text);
140 }
141 
145 void UMLListView::slotItemSelectionChanged()
146 {
147  UMLListViewItem* currItem = static_cast<UMLListViewItem*>(currentItem());
148  if (currItem && currItem->isSelected()) {
149  DEBUG(DBG_SRC) << currItem->text(0);
150  // Update current view to selected object's view
151  if (Model_Utils::typeIsDiagram(currItem->type())) {
152  // If the user navigates to a diagram, load the diagram just like what
153  // would happen when clicking on it (includes saving/showing the documentation)
154  m_doc->changeCurrentView(currItem->ID());
155  } else {
156  // If the user navigates to any other item, save the current object's
157  // documentation and show selected object's documentation
158  UMLApp::app()->docWindow()->showDocumentation(currItem->umlObject(), true);
159  }
160  }
161 }
162 
167 bool UMLListView::event(QEvent *e)
168 {
169  if (e->type() == QEvent::ToolTip) {
170  QHelpEvent *helpEvent = static_cast<QHelpEvent *>(e);
171  UMLListViewItem * item = static_cast<UMLListViewItem*>(itemAt(helpEvent->pos()));
172  if (item) {
173  QToolTip::showText(helpEvent->globalPos(), item->toolTip());
174  } else {
175  QToolTip::hideText();
176  e->ignore();
177  }
178  return true;
179  }
180  return QTreeWidget::event(e);
181 }
182 
187 void UMLListView::mousePressEvent(QMouseEvent *me)
188 {
189  UMLView *currentView = UMLApp::app()->currentView();
190  Q_ASSERT(currentView);
191  UMLScene *scene = currentView->umlScene();
192  Q_ASSERT(scene);
193  scene->clearSelected();
194  if (me->modifiers() != Qt::ShiftModifier)
195  clearSelection();
196 
197  // Get the UMLListViewItem at the point where the mouse pointer was pressed
198  UMLListViewItem * item = static_cast<UMLListViewItem*>(itemAt(me->pos()));
199  if (item) {
200  DEBUG(DBG_SRC) << UMLListViewItem::toString(item->type());
201  }
202  else {
203  DEBUG(DBG_SRC) << "item is NULL";
204  }
205 
206  const Qt::MouseButton button = me->button();
207 
208  if (!item || (button != Qt::RightButton && button != Qt::LeftButton)) {
209  UMLApp::app()->docWindow()->updateDocumentation(true);
210  return;
211  }
212 
213  if (button == Qt::LeftButton) {
214  UMLObject *o = item->umlObject();
215  if (o)
216  UMLApp::app()->docWindow()->showDocumentation(o, false);
217  else
218  UMLApp::app()->docWindow()->updateDocumentation(true);
219 
220  m_dragStartPosition = me->pos();
221  }
222 
223  QTreeWidget::mousePressEvent(me);
224 }
225 
230 void UMLListView::mouseMoveEvent(QMouseEvent* me)
231 {
232  if (!(me->buttons() & Qt::LeftButton)) {
233  DEBUG(DBG_SRC) << "not LeftButton (no action)";
234  return;
235  }
236  if ((me->pos() - m_dragStartPosition).manhattanLength()
237  < QApplication::startDragDistance()) {
238  DEBUG(DBG_SRC) << "pos change since dragStart is below startDragDistance threshold (no action)";
239  return;
240  }
241 
242  DEBUG(DBG_SRC) << "initiating drag";
243  QDrag* drag = new QDrag(this);
244  drag->setMimeData(getDragData());
245  drag->exec(Qt::CopyAction);
246 }
247 
252 void UMLListView::mouseReleaseEvent(QMouseEvent *me)
253 {
254  if (me->button() != Qt::LeftButton) {
255  QTreeWidget::mouseReleaseEvent(me);
256  return;
257  }
258  UMLListViewItem *item = static_cast<UMLListViewItem*>(itemAt(me->pos()));
259  if (item == 0 || !Model_Utils::typeIsDiagram(item->type())) {
260  QTreeWidget::mouseReleaseEvent(me);
261  return;
262  }
263  // Switch to diagram on mouse release - not on mouse press
264  // because the user might intend a drag-to-note.
265  m_doc->changeCurrentView(item->ID());
266  UMLView *view = m_doc->findView(item->ID());
267  if (view && view->umlScene())
268  UMLApp::app()->docWindow()->showDocumentation(view->umlScene(), false);
269  QTreeWidget::mouseReleaseEvent(me);
270 }
271 
276 void UMLListView::keyPressEvent(QKeyEvent *ke)
277 {
278  QTreeWidget::keyPressEvent(ke); // let parent handle it
279  const int k = ke->key();
280  if (k == Qt::Key_Delete || k == Qt::Key_Backspace) {
281  slotDeleteSelectedItems();
282  } else if (k == Qt::Key_F3) {
283  // prelimary support for layout generator
284  LayoutGenerator r;
285  if (!r.generate(UMLApp::app()->currentView()->umlScene()))
286  return;
287  r.apply(UMLApp::app()->currentView()->umlScene());
288  }
289 }
290 
295 void UMLListView::slotMenuSelection(QAction* action)
296 {
297  UMLListViewItem * currItem = static_cast<UMLListViewItem*>(currentItem());
298  if (!currItem) {
299  DEBUG(DBG_SRC) << "Invoked without currently selectedItem!";
300  return;
301  }
302  UMLListViewItem::ListViewType lvt = currItem->type();
303  UMLObject::ObjectType umlType = UMLObject::ot_UMLObject;
304  ListPopupMenu::MenuType menuType = ListPopupMenu::typeFromAction(action);
305  QString name;
306 
307  switch (menuType) {
308  case ListPopupMenu::mt_Class:
309  addNewItem(currItem, UMLListViewItem::lvt_Class);
310  break;
311 
312  case ListPopupMenu::mt_Package:
313  addNewItem(currItem, UMLListViewItem::lvt_Package);
314  break;
315 
316  case ListPopupMenu::mt_Subsystem:
317  addNewItem(currItem, UMLListViewItem::lvt_Subsystem);
318  break;
319 
320  case ListPopupMenu::mt_Component:
321  addNewItem(currItem, UMLListViewItem::lvt_Component);
322  break;
323 
324  case ListPopupMenu::mt_Node:
325  addNewItem(currItem, UMLListViewItem::lvt_Node);
326  break;
327 
328  case ListPopupMenu::mt_Artifact:
329  addNewItem(currItem, UMLListViewItem::lvt_Artifact);
330  break;
331 
332  case ListPopupMenu::mt_Interface:
333  addNewItem(currItem, UMLListViewItem::lvt_Interface);
334  break;
335 
336  case ListPopupMenu::mt_Enum:
337  addNewItem(currItem, UMLListViewItem::lvt_Enum);
338  break;
339 
340  case ListPopupMenu::mt_EnumLiteral:
341  addNewItem(currItem, UMLListViewItem::lvt_EnumLiteral);
342  break;
343 
344  case ListPopupMenu::mt_Template:
345  addNewItem(currItem, UMLListViewItem::lvt_Template);
346  break;
347 
348  case ListPopupMenu::mt_Entity:
349  addNewItem(currItem, UMLListViewItem::lvt_Entity);
350  break;
351 
352  case ListPopupMenu::mt_Category:
353  addNewItem(currItem, UMLListViewItem::lvt_Category);
354  break;
355 
356  case ListPopupMenu::mt_DisjointSpecialisation:
357  {
358  UMLCategory* catObj = static_cast<UMLCategory*>(currItem->umlObject());
359  catObj->setType(UMLCategory::ct_Disjoint_Specialisation);
360  }
361  break;
362 
363  case ListPopupMenu::mt_OverlappingSpecialisation:
364  {
365  UMLCategory* catObj = static_cast<UMLCategory*>(currItem->umlObject());
366  catObj->setType(UMLCategory::ct_Overlapping_Specialisation);
367  }
368  break;
369 
370  case ListPopupMenu::mt_Union:
371  {
372  UMLCategory* catObj = static_cast<UMLCategory*>(currItem->umlObject());
373  catObj->setType(UMLCategory::ct_Union);
374  }
375  break;
376 
377  case ListPopupMenu::mt_Datatype:
378  addNewItem(currItem, UMLListViewItem::lvt_Datatype);
379  break;
380 
381  case ListPopupMenu::mt_Actor:
382  addNewItem(currItem, UMLListViewItem::lvt_Actor);
383  break;
384 
385  case ListPopupMenu::mt_UseCase:
386  addNewItem(currItem, UMLListViewItem::lvt_UseCase);
387  break;
388 
389  case ListPopupMenu::mt_Attribute:
390  addNewItem(currItem, UMLListViewItem::lvt_Attribute);
391  break;
392 
393  case ListPopupMenu::mt_EntityAttribute:
394  addNewItem(currItem, UMLListViewItem::lvt_EntityAttribute);
395  break;
396 
397  case ListPopupMenu::mt_Operation:
398  addNewItem(currItem, UMLListViewItem::lvt_Operation);
399  break;
400 
401  case ListPopupMenu::mt_UniqueConstraint:
402  addNewItem(currItem, UMLListViewItem::lvt_UniqueConstraint);
403  break;
404 
405  case ListPopupMenu::mt_PrimaryKeyConstraint:
406  addNewItem(currItem, UMLListViewItem::lvt_PrimaryKeyConstraint);
407  break;
408 
409  case ListPopupMenu::mt_ForeignKeyConstraint:
410  addNewItem(currItem, UMLListViewItem::lvt_ForeignKeyConstraint);
411  break;
412 
413  case ListPopupMenu::mt_CheckConstraint:
414  addNewItem(currItem, UMLListViewItem::lvt_CheckConstraint);
415  break;
416 
417  case ListPopupMenu::mt_Expand_All:
418  expandAll(currItem);
419  break;
420 
421  case ListPopupMenu::mt_Collapse_All:
422  collapseAll(currItem);
423  break;
424 
425  case ListPopupMenu::mt_Export_Image:
426  m_doc->findView(currItem->ID())->umlScene()->getImageExporter()->exportView();
427  break;
428 
429  case ListPopupMenu::mt_Externalize_Folder:
430  {
431  UMLListViewItem *current = static_cast<UMLListViewItem*>(currentItem());
432  UMLFolder *modelFolder = dynamic_cast<UMLFolder*>(current->umlObject());
433  if (modelFolder == 0) {
434  uError() << "modelFolder is 0";
435  return;
436  }
437  // configure & show the file dialog
438  const QString rootDir(m_doc->url().directory());
439  QPointer<KFileDialog> fileDialog = new KFileDialog(rootDir, "*.xml", this);
440  fileDialog->setCaption(i18n("Externalize Folder"));
441  fileDialog->setOperationMode(KFileDialog::Other);
442  // set a sensible default filename
443  QString defaultFilename = current->text(0).toLower();
444  defaultFilename.replace(QRegExp("\\W+"), "_");
445  defaultFilename.append(".xml"); // default extension
446  fileDialog->setSelection(defaultFilename);
447  KUrl selURL;
448  if (fileDialog->exec() == QDialog::Accepted) {
449  selURL = fileDialog->selectedUrl();
450  }
451  delete fileDialog;
452  if (selURL.isEmpty())
453  return;
454  QString path = selURL.toLocalFile();
455  QString fileName = path;
456  if (fileName.startsWith(rootDir)) {
457  fileName.remove(rootDir);
458  } else {
459  KMessageBox::error(
460  0,
461  i18n("Folder %1 must be relative to the main model directory, %2.", path, rootDir),
462  i18n("Path Error"));
463  return;
464  }
465  QFile file(path);
466  // Warn if file exists.
467  if (file.exists()) {
468  KMessageBox::error(
469  0,
470  i18n("File %1 already exists!\nThe existing file will be overwritten.", fileName),
471  i18n("File Exist"));
472  }
473  // Test if file is writable.
474  if (file.open(QIODevice::WriteOnly)) {
475  file.close();
476  } else {
477  KMessageBox::error(
478  0,
479  i18n("There was a problem saving file: %1", fileName),
480  i18n("Save Error"));
481  return;
482  }
483  modelFolder->setFolderFile(fileName);
484  // Recompute text of the folder
485  QString folderText = current->text(0);
486  folderText.remove(QRegExp("\\s*\\(.*$"));
487  folderText.append(" (" + fileName + ')');
488  current->setText(folderText);
489  break;
490  }
491 
492  case ListPopupMenu::mt_Internalize_Folder:
493  {
494  UMLListViewItem *current = static_cast<UMLListViewItem*>(currentItem());
495  UMLFolder *modelFolder = dynamic_cast<UMLFolder*>(current->umlObject());
496  if (modelFolder == 0) {
497  uError() << "modelFolder is 0";
498  return;
499  }
500  modelFolder->setFolderFile(QString());
501  // Recompute text of the folder
502  QString folderText = current->text(0);
503  folderText.remove(QRegExp("\\s*\\(.*$"));
504  current->setText(folderText);
505  break;
506  }
507 
508  case ListPopupMenu::mt_Model:
509  {
510  bool ok = false;
511  QString name = KInputDialog::getText(i18n("Enter Model Name"),
512  i18n("Enter the new name of the model:"),
513  m_doc->name(), &ok, UMLApp::app());
514  if (ok) {
515  setTitle(0, name);
516  m_doc->setName(name);
517  }
518  break;
519  }
520 
521  case ListPopupMenu::mt_Rename:
522  edit(currentIndex());
523  break;
524 
525  case ListPopupMenu::mt_Delete:
526  deleteItem(currItem);
527  break;
528 
529  case ListPopupMenu::mt_Properties:
530  // first check if we are on a diagram
531  if (Model_Utils::typeIsDiagram(lvt)) {
532  UMLView * pView = m_doc->findView(currItem->ID());
533  if (pView) {
534  UMLApp::app()->docWindow()->updateDocumentation(false);
535  pView->showPropDialog();
536  UMLApp::app()->docWindow()->showDocumentation(pView->umlScene(), true);
537  }
538  return;
539  }
540 
541  { // ok, we are on another object, so find out on which one
542  UMLObject * object = currItem->umlObject();
543  if (!object) {
544  uError() << "UMLObject of ... is null! Doing nothing.";
545  return;
546  }
547  umlType = object->baseType();
548 
549  if (Model_Utils::typeIsCanvasWidget(lvt)) {
550  object->showPropertiesPagedDialog(ClassPropDlg::page_gen);
551  } else if (umlType == UMLObject::ot_EnumLiteral) {
552  // Show the Enum Literal Dialog
553  UMLEnumLiteral* selectedEnumLiteral = static_cast<UMLEnumLiteral*>(object);
554  selectedEnumLiteral->showPropertiesDialog(this);
555 
556  } else if (umlType == UMLObject::ot_Attribute) {
557  // show the attribute dialog
558  UMLAttribute* selectedAttribute = static_cast<UMLAttribute*>(object);
559  QPointer<UMLAttributeDialog> dialog = new UMLAttributeDialog(this, selectedAttribute);
560  dialog->exec();
561  delete dialog;
562  } else if (umlType == UMLObject::ot_EntityAttribute) {
563  // show the attribute dialog
564  UMLEntityAttribute* selectedAttribute = static_cast<UMLEntityAttribute*>(object);
565  QPointer<UMLEntityAttributeDialog> dialog = new UMLEntityAttributeDialog(this, selectedAttribute);
566  dialog->exec();
567  delete dialog;
568  } else if (umlType == UMLObject::ot_Operation) {
569  // show the operation dialog
570  UMLOperation* selectedOperation = static_cast<UMLOperation*>(object);
571  QPointer<UMLOperationDialog> dialog = new UMLOperationDialog(this, selectedOperation);
572  dialog->exec();
573  delete dialog;
574  } else if (umlType == UMLObject::ot_Template) {
575  // show the template dialog
576  UMLTemplate* selectedTemplate = static_cast<UMLTemplate*>(object);
577  QPointer<UMLTemplateDialog> dialog = new UMLTemplateDialog(this, selectedTemplate);
578  dialog->exec();
579  delete dialog;
580  } else if (umlType == UMLObject::ot_UniqueConstraint) {
581  // show the Unique Constraint dialog
582  UMLUniqueConstraint* selectedUniqueConstraint = static_cast<UMLUniqueConstraint*>(object);
583  QPointer<UMLUniqueConstraintDialog> dialog = new UMLUniqueConstraintDialog(this, selectedUniqueConstraint);
584  dialog->exec();
585  delete dialog;
586  } else if (umlType == UMLObject::ot_ForeignKeyConstraint) {
587  // show the Unique Constraint dialog
588  UMLForeignKeyConstraint* selectedForeignKeyConstraint = static_cast<UMLForeignKeyConstraint*>(object);
589  QPointer<UMLForeignKeyConstraintDialog> dialog = new UMLForeignKeyConstraintDialog(this, selectedForeignKeyConstraint);
590  dialog->exec();
591  delete dialog;
592  } else if (umlType == UMLObject::ot_CheckConstraint) {
593  // show the Check Constraint dialog
594  UMLCheckConstraint* selectedCheckConstraint = static_cast<UMLCheckConstraint*>(object);
595  QPointer<UMLCheckConstraintDialog> dialog = new UMLCheckConstraintDialog(this, selectedCheckConstraint);
596  dialog->exec();
597  delete dialog;
598  } else {
599  uWarning() << "calling properties on unknown type";
600  }
601  }
602  break;
603 
604  case ListPopupMenu::mt_Logical_Folder:
605  addNewItem(currItem, UMLListViewItem::lvt_Logical_Folder);
606  break;
607 
608  case ListPopupMenu::mt_UseCase_Folder:
609  addNewItem(currItem, UMLListViewItem::lvt_UseCase_Folder);
610  break;
611 
612  case ListPopupMenu::mt_Component_Folder:
613  addNewItem(currItem, UMLListViewItem::lvt_Component_Folder);
614  break;
615 
616  case ListPopupMenu::mt_Deployment_Folder:
617  addNewItem(currItem, UMLListViewItem::lvt_Deployment_Folder);
618  break;
619 
620  case ListPopupMenu::mt_EntityRelationship_Folder:
621  addNewItem(currItem, UMLListViewItem::lvt_EntityRelationship_Folder);
622  break;
623 
624  case ListPopupMenu::mt_Cut:
625  m_bStartedCut = true;
626  m_bStartedCopy = false;
627  UMLApp::app()->slotEditCut();
628  break;
629 
630  case ListPopupMenu::mt_Copy:
631  m_bStartedCut = false;
632  m_bStartedCopy = true;
633  UMLApp::app()->slotEditCopy();
634  break;
635 
636  case ListPopupMenu::mt_Paste:
637  UMLApp::app()->slotEditPaste();
638  break;
639 
640  default:
641  {
642  Uml::DiagramType::Enum dt = ListPopupMenu::convert_MT_DT(menuType);
643  if (dt == Uml::DiagramType::Undefined) {
644  uWarning() << "unknown type" << menuType;
645  } else {
646  UMLObject* object = currItem->umlObject();
647  UMLFolder* f = dynamic_cast<UMLFolder*>(object);
648  if (f == 0) {
649  uError() << "menuType=" << menuType
650  << ": current item's UMLObject is not a UMLFolder";
651  }
652  else {
653  QString name = m_doc->createDiagramName(dt);
654  m_doc->createDiagram(f, dt, name);
655  }
656  }
657  }
658  break;
659  }//end switch
660 }
661 
674 UMLListViewItem *UMLListView::findFolderForDiagram(Uml::DiagramType::Enum dt)
675 {
676  UMLListViewItem *p = static_cast<UMLListViewItem*>(currentItem());
677  if (p && Model_Utils::typeIsFolder(p->type())
678  && !Model_Utils::typeIsRootView(p->type())) {
679  return p;
680  }
681  switch (dt) {
682  case Uml::DiagramType::UseCase:
683  p = m_lv[Uml::ModelType::UseCase];
684  break;
685  case Uml::DiagramType::Component:
686  p = m_lv[Uml::ModelType::Component];
687  break;
688  case Uml::DiagramType::Deployment:
689  p = m_lv[Uml::ModelType::Deployment];
690  break;
691  case Uml::DiagramType::EntityRelationship:
692  p = m_lv[Uml::ModelType::EntityRelationship];
693  break;
694  default:
695  p = m_lv[Uml::ModelType::Logical];
696  break;
697  }
698  return p;
699 }
700 
705 void UMLListView::slotDiagramCreated(Uml::ID::Type id)
706 {
707  if (m_doc->loading()) {
708  return;
709  }
710  UMLView *v = m_doc->findView(id);
711  if (v) {
712  UMLScene *scene = v->umlScene();
713  if (scene) {
714  const Uml::DiagramType::Enum dt = scene->type();
715  UMLListViewItem* p = findFolderForDiagram(dt);
716  UMLListViewItem* item = new UMLListViewItem(p, scene->name(), Model_Utils::convert_DT_LVT(dt), id);
717  setSelected(item, true);
718  UMLApp::app()->docWindow()->showDocumentation(scene, false);
719  }
720  }
721 }
722 
730 UMLListViewItem* UMLListView::determineParentItem(UMLObject* object) const
731 {
732  UMLListViewItem* parentItem = 0;
733  UMLListViewItem* current = (UMLListViewItem*) currentItem();
734  UMLListViewItem::ListViewType lvt = UMLListViewItem::lvt_Unknown;
735  if (current)
736  lvt = current->type();
737  UMLObject::ObjectType t = object->baseType();
738 
739  switch (t) {
740  case UMLObject::ot_Attribute:
741  case UMLObject::ot_Operation:
742  case UMLObject::ot_Template:
743  case UMLObject::ot_EnumLiteral:
744  case UMLObject::ot_EntityAttribute:
745  case UMLObject::ot_UniqueConstraint:
746  case UMLObject::ot_ForeignKeyConstraint:
747  case UMLObject::ot_CheckConstraint:
748  //this will be handled by childObjectAdded
749  return 0;
750  break;
751  case UMLObject::ot_Association:
752  case UMLObject::ot_Role:
753  case UMLObject::ot_Stereotype:
754  return 0; // currently no representation in list view
755  break;
756  default: {
757  UMLPackage *pkg = object->umlPackage();
758  if (pkg) {
759  UMLListViewItem* pkgItem = findUMLObject(pkg);
760  if (pkgItem == 0)
761  uError() << "could not find parent package " << pkg->name();
762  else
763  parentItem = pkgItem;
764  } else if ((lvt == UMLListViewItem::lvt_UseCase_Folder &&
765  (t == UMLObject::ot_Actor || t == UMLObject::ot_UseCase))
766  || (lvt == UMLListViewItem::lvt_Component_Folder && t == UMLObject::ot_Component)
767  || (lvt == UMLListViewItem::lvt_Deployment_Folder && t == UMLObject::ot_Node)
768  || (lvt == UMLListViewItem::lvt_EntityRelationship_Folder && t == UMLObject::ot_Entity)) {
769  parentItem = current;
770  } else if (t == UMLObject::ot_Datatype) {
771  parentItem = m_datatypeFolder;
772  } else {
773  Uml::ModelType::Enum guess = Model_Utils::guessContainer(object);
774  parentItem = m_lv[guess];
775  }
776  }
777  break;
778  }
779  return parentItem;
780 }
781 
787 bool UMLListView::mayHaveChildItems(UMLObject::ObjectType type)
788 {
789  bool retval = false;
790  switch (type) {
791  case UMLObject::ot_Class:
792  case UMLObject::ot_Interface:
793  case UMLObject::ot_Enum:
794  case UMLObject::ot_Entity: // CHECK: more?
795  retval = true;
796  break;
797  default:
798  break;
799  }
800  return retval;
801 }
802 
807 void UMLListView::slotObjectCreated(UMLObject* object)
808 {
809  if (m_bCreatingChildObject) {
810  // @todo eliminate futile signal traffic
811  // e.g. we get here thru various indirections from
812  // ClassifierListPage::slot{Up, Down}Clicked()
813  return;
814  }
815  UMLListViewItem* newItem = findUMLObject(object);
816 
817  if (newItem) {
818  DEBUG(DBG_SRC) << newItem->type();
819  DEBUG(DBG_SRC) << object->name() << ", id= " << Uml::ID::toString(object->id())
820  << ": item already exists.";
821  Icon_Utils::IconType icon = Model_Utils::convert_LVT_IT(newItem->type());
822  newItem->setIcon(icon);
823  return;
824  }
825  UMLListViewItem* parentItem = determineParentItem(object);
826  if (parentItem == 0)
827  return;
828  UMLObject::ObjectType type = object->baseType();
829 
830  connectNewObjectsSlots(object);
831  const UMLListViewItem::ListViewType lvt = Model_Utils::convert_OT_LVT(object);
832  QString name = object->name();
833  if (type == UMLObject::ot_Folder) {
834  UMLFolder *f = static_cast<UMLFolder*>(object);
835  QString folderFile = f->folderFile();
836  if (!folderFile.isEmpty())
837  name.append(" (" + folderFile + ')');
838  }
839  newItem = new UMLListViewItem(parentItem, name, lvt, object);
840  if (mayHaveChildItems(type)) {
841  UMLClassifier *c = static_cast<UMLClassifier*>(object);
842  UMLClassifierListItemList cListItems = c->getFilteredList(UMLObject::ot_UMLObject);
843  foreach(UMLClassifierListItem *cli, cListItems)
844  childObjectAdded(cli, c);
845  }
846  if (m_doc->loading())
847  return;
848  scrollToItem(newItem);
849  newItem->setOpen(true);
850  clearSelection();
851  setSelected(newItem, true);
852  UMLApp::app()->docWindow()->showDocumentation(object, false);
853 }
854 
858 void UMLListView::connectNewObjectsSlots(UMLObject* object)
859 {
860  UMLObject::ObjectType type = object->baseType();
861  switch (type) {
862  case UMLObject::ot_Class:
863  case UMLObject::ot_Interface: {
864  UMLClassifier *c = static_cast<UMLClassifier*>(object);
865  connect(c, SIGNAL(attributeAdded(UMLClassifierListItem*)),
866  this, SLOT(childObjectAdded(UMLClassifierListItem*)));
867  connect(c, SIGNAL(attributeRemoved(UMLClassifierListItem*)),
868  this, SLOT(childObjectRemoved(UMLClassifierListItem*)));
869  connect(c, SIGNAL(operationAdded(UMLClassifierListItem*)),
870  this, SLOT(childObjectAdded(UMLClassifierListItem*)));
871  connect(c, SIGNAL(operationRemoved(UMLClassifierListItem*)),
872  this, SLOT(childObjectRemoved(UMLClassifierListItem*)));
873  connect(c, SIGNAL(templateAdded(UMLClassifierListItem*)),
874  this, SLOT(childObjectAdded(UMLClassifierListItem*)));
875  connect(c, SIGNAL(templateRemoved(UMLClassifierListItem*)),
876  this, SLOT(childObjectRemoved(UMLClassifierListItem*)));
877  connect(object, SIGNAL(modified()), this, SLOT(slotObjectChanged()));
878  }
879  break;
880  case UMLObject::ot_Enum: {
881  UMLEnum *e = static_cast<UMLEnum*>(object);
882  connect(e, SIGNAL(enumLiteralAdded(UMLClassifierListItem*)),
883  this, SLOT(childObjectAdded(UMLClassifierListItem*)));
884  connect(e, SIGNAL(enumLiteralRemoved(UMLClassifierListItem*)),
885  this, SLOT(childObjectRemoved(UMLClassifierListItem*)));
886  }
887  connect(object, SIGNAL(modified()), this, SLOT(slotObjectChanged()));
888  break;
889  case UMLObject::ot_Entity: {
890  UMLEntity *ent = static_cast<UMLEntity*>(object);
891  connect(ent, SIGNAL(entityAttributeAdded(UMLClassifierListItem*)),
892  this, SLOT(childObjectAdded(UMLClassifierListItem*)));
893  connect(ent, SIGNAL(entityAttributeRemoved(UMLClassifierListItem*)),
894  this, SLOT(childObjectRemoved(UMLClassifierListItem*)));
895  connect(ent, SIGNAL(entityConstraintAdded(UMLClassifierListItem*)),
896  this, SLOT(childObjectAdded(UMLClassifierListItem*)));
897  connect(ent, SIGNAL(entityConstraintRemoved(UMLClassifierListItem*)),
898  this, SLOT(childObjectRemoved(UMLClassifierListItem*)));
899  }
900  connect(object, SIGNAL(modified()), this, SLOT(slotObjectChanged()));
901  break;
902  case UMLObject::ot_Datatype:
903  case UMLObject::ot_Attribute:
904  case UMLObject::ot_Operation:
905  case UMLObject::ot_Template:
906  case UMLObject::ot_EnumLiteral:
907  case UMLObject::ot_EntityAttribute:
908  case UMLObject::ot_UniqueConstraint:
909  case UMLObject::ot_ForeignKeyConstraint:
910  case UMLObject::ot_CheckConstraint:
911  case UMLObject::ot_Package:
912  case UMLObject::ot_Actor:
913  case UMLObject::ot_UseCase:
914  case UMLObject::ot_Component:
915  case UMLObject::ot_Artifact:
916  case UMLObject::ot_Node:
917  case UMLObject::ot_Folder:
918  case UMLObject::ot_Category:
919  connect(object, SIGNAL(modified()), this, SLOT(slotObjectChanged()));
920  break;
921  case UMLObject::ot_UMLObject:
922  case UMLObject::ot_Association:
923  case UMLObject::ot_Stereotype:
924  break;
925  default:
926  uWarning() << "unknown type in connectNewObjectsSlots";
927  break;
928  }
929 }
930 
935 void UMLListView::slotObjectChanged()
936 {
937  if (m_doc->loading()) { //needed for class wizard
938  return;
939  }
940  UMLObject* obj = const_cast<UMLObject*>(dynamic_cast<const UMLObject*>(sender()));
941  UMLListViewItem* item = findUMLObject(obj);
942  if (item) {
943  item->updateObject();
944  }
945 }
946 
951 void UMLListView::childObjectAdded(UMLClassifierListItem* obj)
952 {
953  UMLClassifier *parent = const_cast<UMLClassifier*>(dynamic_cast<const UMLClassifier*>(sender()));
954  childObjectAdded(obj, parent);
955 }
956 
963 void UMLListView::childObjectAdded(UMLClassifierListItem* child, UMLClassifier* parent)
964 {
965  if (m_bCreatingChildObject)
966  return;
967  const QString text = child->toString(Uml::SignatureType::SigNoVis);
968  UMLListViewItem *childItem = 0;
969  UMLListViewItem *parentItem = findUMLObject(parent);
970  if (parentItem == 0) {
971  DEBUG(DBG_SRC) << child->name() << ": parent " << parent->name()
972  << " does not yet exist, creating it now.";
973  const UMLListViewItem::ListViewType lvt = Model_Utils::convert_OT_LVT(parent);
974  parentItem = new UMLListViewItem(m_lv[Uml::ModelType::Logical], parent->name(), lvt, parent);
975  } else {
976  childItem = parentItem->findChildObject(child);
977  }
978  if (childItem) {
979  childItem->setText(text);
980  } else {
981  const UMLListViewItem::ListViewType lvt = Model_Utils::convert_OT_LVT(child);
982  childItem = new UMLListViewItem(parentItem, text, lvt, child);
983  if (! m_doc->loading()) {
984  scrollToItem(childItem);
985  clearSelection();
986  setSelected(childItem, true);
987  }
988  connectNewObjectsSlots(child);
989  }
990 }
991 
996 void UMLListView::childObjectRemoved(UMLClassifierListItem* obj)
997 {
998  UMLClassifier *parent = const_cast<UMLClassifier*>(dynamic_cast<const UMLClassifier*>(sender()));
999  UMLListViewItem *parentItem = findUMLObject(parent);
1000  if (parentItem == 0) {
1001  uError() << obj->name() << ": cannot find parent UMLListViewItem";
1002  return;
1003  }
1004  parentItem->deleteChildItem(obj);
1005 }
1006 
1011 void UMLListView::slotDiagramRenamed(Uml::ID::Type id)
1012 {
1013  UMLListViewItem* item;
1014  UMLView* v = m_doc->findView(id);
1015  if ((item = findView(v)) == 0) {
1016  uError() << "UMLDoc::findView(" << Uml::ID::toString(id) << ") returns 0";
1017  return;
1018  }
1019  item->setText(v->umlScene()->name());
1020 }
1021 
1028 void UMLListView::setDocument(UMLDoc *doc)
1029 {
1030  if (m_doc && m_doc != doc) {
1031  //disconnect signals from old doc and reset view
1032  }
1033  m_doc = doc;
1034 
1035  connect(m_doc, SIGNAL(sigDiagramCreated(Uml::ID::Type)), this, SLOT(slotDiagramCreated(Uml::ID::Type)));
1036  connect(m_doc, SIGNAL(sigDiagramRemoved(Uml::ID::Type)), this, SLOT(slotDiagramRemoved(Uml::ID::Type)));
1037  connect(m_doc, SIGNAL(sigDiagramRenamed(Uml::ID::Type)), this, SLOT(slotDiagramRenamed(Uml::ID::Type)));
1038  connect(m_doc, SIGNAL(sigObjectCreated(UMLObject*)), this, SLOT(slotObjectCreated(UMLObject*)));
1039  connect(m_doc, SIGNAL(sigObjectRemoved(UMLObject*)), this, SLOT(slotObjectRemoved(UMLObject*)));
1040 }
1041 
1046 void UMLListView::slotObjectRemoved(UMLObject* object)
1047 {
1048  if (m_doc->loading()) { //needed for class wizard
1049  return;
1050  }
1051  disconnect(object, SIGNAL(modified()), this, SLOT(slotObjectChanged()));
1052  UMLListViewItem* item = findItem(object->id());
1053  delete item;
1054  UMLApp::app()->docWindow()->updateDocumentation(true);
1055 }
1056 
1061 void UMLListView::slotDiagramRemoved(Uml::ID::Type id)
1062 {
1063  UMLListViewItem* item = findItem(id);
1064  delete item;
1065  UMLApp::app()->docWindow()->updateDocumentation(true);
1066 }
1067 
1071 UMLDragData* UMLListView::getDragData()
1072 {
1073  UMLListViewItemList itemsSelected = selectedItems();
1074 
1075  UMLListViewItemList list;
1076  foreach(UMLListViewItem* item, itemsSelected) {
1077  UMLListViewItem::ListViewType type = item->type();
1078  if (!Model_Utils::typeIsCanvasWidget(type) && !Model_Utils::typeIsDiagram(type)
1079  && !Model_Utils::typeIsClassifierList(type)) {
1080  return 0;
1081  }
1082  list.append(item);
1083  }
1084 
1085  UMLDragData *t = new UMLDragData(list, this);
1086 
1087  return t;
1088 }
1089 
1096 UMLListViewItem * UMLListView::findUMLObjectInFolder(UMLListViewItem* folder, UMLObject* obj)
1097 {
1098  for (int i=0; i < folder->childCount(); ++i) {
1099  UMLListViewItem *item = folder->childItem(i);
1100  switch (item->type()) {
1101  case UMLListViewItem::lvt_Actor :
1102  case UMLListViewItem::lvt_UseCase :
1103  case UMLListViewItem::lvt_Class :
1104  case UMLListViewItem::lvt_Package :
1105  case UMLListViewItem::lvt_Subsystem :
1106  case UMLListViewItem::lvt_Component :
1107  case UMLListViewItem::lvt_Node :
1108  case UMLListViewItem::lvt_Artifact :
1109  case UMLListViewItem::lvt_Interface :
1110  case UMLListViewItem::lvt_Datatype :
1111  case UMLListViewItem::lvt_Enum :
1112  case UMLListViewItem::lvt_Entity :
1113  case UMLListViewItem::lvt_Category:
1114  if (item->umlObject() == obj)
1115  return item;
1116  break;
1117  case UMLListViewItem::lvt_Logical_Folder :
1118  case UMLListViewItem::lvt_UseCase_Folder :
1119  case UMLListViewItem::lvt_Component_Folder :
1120  case UMLListViewItem::lvt_Deployment_Folder :
1121  case UMLListViewItem::lvt_EntityRelationship_Folder :
1122  case UMLListViewItem::lvt_Datatype_Folder : {
1123  UMLListViewItem *temp = findUMLObjectInFolder(item, obj);
1124  if (temp)
1125  return temp;
1126  }
1127  default:
1128  break;
1129  }
1130  }
1131  return 0;
1132 }
1133 
1140 UMLListViewItem * UMLListView::findUMLObject(const UMLObject *p) const
1141 {
1142  for (int i=0; i < topLevelItemCount(); ++i) {
1143  UMLListViewItem *item = static_cast<UMLListViewItem*>(topLevelItem(i));
1144  UMLListViewItem *testItem = item->findUMLObject(p);
1145  if (testItem)
1146  return testItem;
1147  }
1148  return 0;
1149 }
1150 
1154 void UMLListView::changeIconOf(UMLObject *o, Icon_Utils::IconType to)
1155 {
1156  UMLListViewItem *item = findUMLObject(o);
1157  if (item)
1158  item->setIcon(to);
1159 }
1160 
1166 UMLListViewItem* UMLListView::findView(UMLView* v)
1167 {
1168  if (!v) {
1169  uWarning() << "returning 0 - param is 0.";
1170  return 0;
1171  }
1172  UMLListViewItem* item;
1173  Uml::DiagramType::Enum dType = v->umlScene()->type();
1174  UMLListViewItem::ListViewType type = Model_Utils::convert_DT_LVT(dType);
1175  Uml::ID::Type id = v->umlScene()->ID();
1176  if (dType == Uml::DiagramType::UseCase) {
1177  item = m_lv[Uml::ModelType::UseCase];
1178  } else if (dType == Uml::DiagramType::Component) {
1179  item = m_lv[Uml::ModelType::Component];
1180  } else if (dType == Uml::DiagramType::Deployment) {
1181  item = m_lv[Uml::ModelType::Deployment];
1182  } else if (dType == Uml::DiagramType::EntityRelationship) {
1183  item = m_lv[Uml::ModelType::EntityRelationship];
1184  } else {
1185  item = m_lv[Uml::ModelType::Logical];
1186  }
1187  for (int i=0; i < item->childCount(); i++) {
1188  UMLListViewItem* foundItem = recursiveSearchForView(item->childItem(i), type, id);
1189  if (foundItem) {
1190  return foundItem;
1191  }
1192  }
1193  if (m_doc->loading()) {
1194  DEBUG(DBG_SRC) << "could not find " << v->umlScene()->name() << " in " << *item;
1195  } else {
1196  uWarning() << "could not find " << v->umlScene()->name() << " in " << *item;
1197  }
1198  return 0;
1199 }
1200 
1206 UMLListViewItem* UMLListView::recursiveSearchForView(UMLListViewItem* listViewItem,
1207  UMLListViewItem::ListViewType type, Uml::ID::Type id)
1208 {
1209  if (!listViewItem)
1210  return 0;
1211 
1212  if (Model_Utils::typeIsFolder(listViewItem->type())) {
1213  for (int i=0; i < listViewItem->childCount(); i++) {
1214  UMLListViewItem* child = listViewItem->childItem(i);
1215  UMLListViewItem* resultListViewItem = recursiveSearchForView(child, type, id);
1216  if (resultListViewItem)
1217  return resultListViewItem;
1218  }
1219  } else {
1220  if (listViewItem->type() == type && listViewItem->ID() == id)
1221  return listViewItem;
1222  }
1223  return 0;
1224 }
1225 
1232 UMLListViewItem* UMLListView::findItem(Uml::ID::Type id)
1233 {
1234  UMLListViewItem *topLevel = static_cast<UMLListViewItem*>(topLevelItem(0));
1235  UMLListViewItem *item = topLevel->findItem(id);
1236  if (item)
1237  return item;
1238  return 0;
1239 }
1240 
1247 void UMLListView::init()
1248 {
1249  if (m_rv == 0) {
1250  m_rv = new UMLListViewItem(this, i18n("Views"), UMLListViewItem::lvt_View);
1251  m_rv->setID("Views");
1252  //m_rv->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicator);
1253 
1254  for (int i = 0; i < Uml::ModelType::N_MODELTYPES; ++i) {
1255  Uml::ModelType::Enum mt = Uml::ModelType::fromInt(i);
1256  UMLFolder *sysFolder = m_doc->rootFolder(mt);
1257  UMLListViewItem::ListViewType lvt = Model_Utils::convert_MT_LVT(mt);
1258  m_lv[i] = new UMLListViewItem(m_rv, sysFolder->localName(), lvt, sysFolder);
1259  }
1260  } else {
1261  clean();
1262  }
1263  UMLFolder *datatypeFolder = m_doc->datatypeFolder();
1264  if (!m_datatypeFolder) {
1265  m_datatypeFolder = new UMLListViewItem(m_lv[Uml::ModelType::Logical], datatypeFolder->localName(),
1266  UMLListViewItem::lvt_Datatype_Folder, datatypeFolder);
1267  }
1268  m_rv->setOpen(true);
1269  for (int i = 0; i < Uml::ModelType::N_MODELTYPES; ++i) {
1270  m_lv[i]->setOpen(true);
1271  }
1272  m_datatypeFolder->setOpen(false);
1273 
1274  //setup misc.
1275  m_bStartedCut = m_bStartedCopy = false;
1276  m_bCreatingChildObject = false;
1277  headerItem()->setHidden(true);
1278 }
1279 
1284 void UMLListView::clean()
1285 {
1286  for (int i = 0; i < Uml::ModelType::N_MODELTYPES; ++i) {
1287  deleteChildrenOf(m_lv[i]);
1288  }
1289  //deleteChildrenOf(m_datatypeFolder);
1290 }
1291 
1297 void UMLListView::setView(UMLView * view)
1298 {
1299  if (!view)
1300  return;
1301  UMLListViewItem * temp = findView(view);
1302  if (temp)
1303  setSelected(temp, true);
1304 }
1305 
1309 void UMLListView::mouseDoubleClickEvent(QMouseEvent * me)
1310 {
1311  UMLListViewItem * item = static_cast<UMLListViewItem *>(currentItem());
1312  if (!item || me->button() != Qt::LeftButton)
1313  return;
1314  //see if on view
1315  UMLListViewItem::ListViewType lvType = item->type();
1316  if (Model_Utils::typeIsDiagram(lvType)) {
1317  UMLView * pView = m_doc->findView(item->ID());
1318  if (pView) {
1319  UMLApp::app()->docWindow()->updateDocumentation(false);
1320  pView->showPropDialog();
1321  UMLApp::app()->docWindow()->showDocumentation(pView->umlScene(), true);
1322  }
1323  return;
1324  }
1325  //else see if an object
1326  UMLObject * object = item->umlObject();
1327  //continue only if we are on a UMLObject
1328  if (!object) {
1329  return;
1330  }
1331 
1332  UMLObject::ObjectType type = object->baseType();
1333  int page = ClassPropDlg::page_gen;
1334  if (Model_Utils::isClassifierListitem(type)) {
1335  object = (UMLObject *)object->parent();
1336  }
1337  //set what page to show
1338  switch (type) {
1339 
1340  case UMLObject::ot_Attribute:
1341  page = ClassPropDlg::page_att;
1342  break;
1343  case UMLObject::ot_Operation:
1344  page = ClassPropDlg::page_op;
1345  break;
1346  case UMLObject::ot_EntityAttribute:
1347  page = ClassPropDlg::page_entatt;
1348  break;
1349  case UMLObject::ot_UniqueConstraint:
1350  case UMLObject::ot_ForeignKeyConstraint:
1351  case UMLObject::ot_CheckConstraint:
1352  page = ClassPropDlg::page_constraint;
1353  break;
1354  default:
1355  page = ClassPropDlg::page_gen;
1356  break;
1357  }
1358 
1359  if (object) {
1360  object->showPropertiesPagedDialog(page);
1361  }
1362 }
1363 
1369 bool UMLListView::acceptDrag(QDropEvent* event) const
1370 {
1371  UMLListViewItem* item = (UMLListViewItem*)itemAt(event->pos());
1372  if (!item) {
1373  DEBUG(DBG_SRC) << "itemAt(mouse position) returns 0";
1374  return false;
1375  }
1376  ((QTreeWidget*)this)->setCurrentItem((QTreeWidgetItem*)item);
1377 
1378  UMLDragData::LvTypeAndID_List list;
1379  if (! UMLDragData::getClip3TypeAndID(event->mimeData(), list)) {
1380  DEBUG(DBG_SRC) << "UMLDragData::getClip3TypeAndID returns false";
1381  return false;
1382  }
1383 
1384  UMLDragData::LvTypeAndID_It it(list);
1385  UMLDragData::LvTypeAndID * data = 0;
1386  UMLListViewItem::ListViewType dstType = item->type();
1387  bool accept = true;
1388  while (accept && it.hasNext()) {
1389  data = it.next();
1390  UMLListViewItem::ListViewType srcType = data->type;
1391  switch (srcType) {
1392  case UMLListViewItem::lvt_Class:
1393  case UMLListViewItem::lvt_Package:
1394  case UMLListViewItem::lvt_Interface:
1395  case UMLListViewItem::lvt_Enum:
1396  if (dstType == UMLListViewItem::lvt_Logical_View ||
1397  dstType == UMLListViewItem::lvt_Class ||
1398  dstType == UMLListViewItem::lvt_Package) {
1399  accept = !item->isOwnParent(data->id);
1400  } else {
1401  accept = (dstType == UMLListViewItem::lvt_Logical_Folder);
1402  }
1403  break;
1404  case UMLListViewItem::lvt_Attribute:
1405  if (dstType == UMLListViewItem::lvt_Class) {
1406  accept = !item->isOwnParent(data->id);
1407  }
1408  break;
1409  case UMLListViewItem::lvt_EntityAttribute:
1410  if (dstType == UMLListViewItem::lvt_Entity) {
1411  accept = !item->isOwnParent(data->id);
1412  }
1413  break;
1414  case UMLListViewItem::lvt_Operation:
1415  if (dstType == UMLListViewItem::lvt_Class ||
1416  dstType == UMLListViewItem::lvt_Interface) {
1417  accept = !item->isOwnParent(data->id);
1418  }
1419  break;
1420  case UMLListViewItem::lvt_Datatype:
1421  accept = (dstType == UMLListViewItem::lvt_Logical_Folder ||
1422  dstType == UMLListViewItem::lvt_Datatype_Folder ||
1423  dstType == UMLListViewItem::lvt_Class ||
1424  dstType == UMLListViewItem::lvt_Interface ||
1425  dstType == UMLListViewItem::lvt_Package);
1426  break;
1427  case UMLListViewItem::lvt_Class_Diagram:
1428  case UMLListViewItem::lvt_Collaboration_Diagram:
1429  case UMLListViewItem::lvt_State_Diagram:
1430  case UMLListViewItem::lvt_Activity_Diagram:
1431  case UMLListViewItem::lvt_Sequence_Diagram:
1432  accept = (dstType == UMLListViewItem::lvt_Logical_Folder ||
1433  dstType == UMLListViewItem::lvt_Logical_View);
1434  break;
1435  case UMLListViewItem::lvt_Logical_Folder:
1436  if (dstType == UMLListViewItem::lvt_Logical_Folder) {
1437  accept = !item->isOwnParent(data->id);
1438  } else {
1439  accept = (dstType == UMLListViewItem::lvt_Logical_View);
1440  }
1441  break;
1442  case UMLListViewItem::lvt_UseCase_Folder:
1443  if (dstType == UMLListViewItem::lvt_UseCase_Folder) {
1444  accept = !item->isOwnParent(data->id);
1445  } else {
1446  accept = (dstType == UMLListViewItem::lvt_UseCase_View);
1447  }
1448  break;
1449  case UMLListViewItem::lvt_Component_Folder:
1450  if (dstType == UMLListViewItem::lvt_Component_Folder) {
1451  accept = !item->isOwnParent(data->id);
1452  } else {
1453  accept = (dstType == UMLListViewItem::lvt_Component_View);
1454  }
1455  break;
1456  case UMLListViewItem::lvt_Deployment_Folder:
1457  if (dstType == UMLListViewItem::lvt_Deployment_Folder) {
1458  accept = !item->isOwnParent(data->id);
1459  } else {
1460  accept = (dstType == UMLListViewItem::lvt_Deployment_View);
1461  }
1462  break;
1463  case UMLListViewItem::lvt_EntityRelationship_Folder:
1464  if (dstType == UMLListViewItem::lvt_EntityRelationship_Folder) {
1465  accept = !item->isOwnParent(data->id);
1466  } else {
1467  accept = (dstType == UMLListViewItem::lvt_EntityRelationship_Model);
1468  }
1469  break;
1470  case UMLListViewItem::lvt_Actor:
1471  case UMLListViewItem::lvt_UseCase:
1472  case UMLListViewItem::lvt_UseCase_Diagram:
1473  accept = (dstType == UMLListViewItem::lvt_UseCase_Folder ||
1474  dstType == UMLListViewItem::lvt_UseCase_View);
1475  break;
1476  case UMLListViewItem::lvt_Subsystem:
1477  accept = (dstType == UMLListViewItem::lvt_Component_Folder ||
1478  dstType == UMLListViewItem::lvt_Subsystem);
1479  break;
1480  case UMLListViewItem::lvt_Component:
1481  accept = (dstType == UMLListViewItem::lvt_Component_Folder ||
1482  dstType == UMLListViewItem::lvt_Component ||
1483  dstType == UMLListViewItem::lvt_Subsystem);
1484  break;
1485  case UMLListViewItem::lvt_Artifact:
1486  case UMLListViewItem::lvt_Component_Diagram:
1487  accept = (dstType == UMLListViewItem::lvt_Component_Folder ||
1488  dstType == UMLListViewItem::lvt_Component_View);
1489  break;
1490  case UMLListViewItem::lvt_Node:
1491  case UMLListViewItem::lvt_Deployment_Diagram:
1492  accept = (dstType == UMLListViewItem::lvt_Deployment_Folder);
1493  break;
1494  case UMLListViewItem::lvt_Entity:
1495  case UMLListViewItem::lvt_EntityRelationship_Diagram:
1496  case UMLListViewItem::lvt_Category:
1497  accept = (dstType == UMLListViewItem::lvt_EntityRelationship_Folder);
1498  break;
1499  default:
1500  accept = false;
1501  break;
1502  }
1503  }
1504 
1505  DEBUG(DBG_SRC) << "dstType = " << dstType << ", accept=" << accept;
1506  return accept;
1507 }
1508 
1514 void UMLListView::addAtContainer(UMLListViewItem *item, UMLListViewItem *parent)
1515 {
1516  UMLCanvasObject *o = static_cast<UMLCanvasObject*>(item->umlObject());
1517  if (o == 0) {
1518  DEBUG(DBG_SRC) << item->text(0) << ": item's UMLObject is 0";
1519  } else if (Model_Utils::typeIsContainer(parent->type())) {
1520  /**** TBC: Do this here?
1521  If yes then remove that logic at the callers
1522  and rename this method to moveAtContainer()
1523  UMLPackage *oldPkg = o->getUMLPackage();
1524  if (oldPkg)
1525  oldPkg->removeObject(o);
1526  *********/
1527  UMLPackage *pkg = static_cast<UMLPackage*>(parent->umlObject());
1528  o->setUMLPackage(pkg);
1529  pkg->addObject(o);
1530  } else {
1531  uError() << item->text(0) << ": parent type is " << parent->type();
1532  }
1533  UMLView *currentView = UMLApp::app()->currentView();
1534  if (currentView)
1535  currentView->umlScene()->updateContainment(o);
1536 }
1537 
1543 UMLListViewItem * UMLListView::moveObject(Uml::ID::Type srcId, UMLListViewItem::ListViewType srcType,
1544  UMLListViewItem *newParent)
1545 {
1546  if (newParent == 0)
1547  return 0;
1548  UMLListViewItem * move = findItem(srcId);
1549  if (move == 0)
1550  return 0;
1551 
1552  UMLObject *newParentObj = 0;
1553  // Remove the source object at the old parent package.
1554  UMLObject *srcObj = m_doc->findObjectById(srcId);
1555  if (srcObj) {
1556  newParentObj = newParent->umlObject();
1557  if (srcObj == newParentObj) {
1558  uError() << srcObj->name() << ": Cannot move onto self";
1559  return 0;
1560  }
1561  UMLPackage *srcPkg = srcObj->umlPackage();
1562  if (srcPkg) {
1563  if (srcPkg == newParentObj) {
1564  uError() << srcObj->name() << ": Object is already in target package";
1565  return 0;
1566  }
1567  srcPkg->removeObject(srcObj);
1568  }
1569  }
1570 
1571  UMLListViewItem::ListViewType newParentType = newParent->type();
1572  DEBUG(DBG_SRC) << "newParentType is " << newParentType;
1573  UMLListViewItem *newItem = 0;
1574 
1575  //make sure trying to place in correct location
1576  switch (srcType) {
1577  case UMLListViewItem::lvt_UseCase_Folder:
1578  case UMLListViewItem::lvt_Actor:
1579  case UMLListViewItem::lvt_UseCase:
1580  case UMLListViewItem::lvt_UseCase_Diagram:
1581  if (newParentType == UMLListViewItem::lvt_UseCase_Folder ||
1582  newParentType == UMLListViewItem::lvt_UseCase_View) {
1583  newItem = move->deepCopy(newParent);
1584  if (m_doc->loading()) // deletion is not safe while loading
1585  move->setVisible(false); // (the <listview> XMI may be corrupted)
1586  else
1587  delete move;
1588  addAtContainer(newItem, newParent);
1589  }
1590  break;
1591  case UMLListViewItem::lvt_Component_Folder:
1592  case UMLListViewItem::lvt_Artifact:
1593  case UMLListViewItem::lvt_Component_Diagram:
1594  if (newParentType == UMLListViewItem::lvt_Component_Folder ||
1595  newParentType == UMLListViewItem::lvt_Component_View) {
1596  newItem = move->deepCopy(newParent);
1597  if (m_doc->loading()) // deletion is not safe while loading
1598  move->setVisible(false); // (the <listview> XMI may be corrupted)
1599  else
1600  delete move;
1601  addAtContainer(newItem, newParent);
1602  }
1603  break;
1604  case UMLListViewItem::lvt_Subsystem:
1605  if (newParentType == UMLListViewItem::lvt_Component_Folder ||
1606  newParentType == UMLListViewItem::lvt_Component_View ||
1607  newParentType == UMLListViewItem::lvt_Subsystem) {
1608  newItem = move->deepCopy(newParent);
1609  if (m_doc->loading()) // deletion is not safe while loading
1610  move->setVisible(false); // (the <listview> XMI may be corrupted)
1611  else
1612  delete move;
1613  addAtContainer(newItem, newParent);
1614  }
1615  break;
1616  case UMLListViewItem::lvt_Component:
1617  if (newParentType == UMLListViewItem::lvt_Component_Folder ||
1618  newParentType == UMLListViewItem::lvt_Component_View ||
1619  newParentType == UMLListViewItem::lvt_Component ||
1620  newParentType == UMLListViewItem::lvt_Subsystem) {
1621  newItem = move->deepCopy(newParent);
1622  if (m_doc->loading()) // deletion is not safe while loading
1623  move->setVisible(false); // (the <listview> XMI may be corrupted)
1624  else
1625  delete move;
1626  addAtContainer(newItem, newParent);
1627  }
1628  break;
1629  case UMLListViewItem::lvt_Deployment_Folder:
1630  case UMLListViewItem::lvt_Node:
1631  case UMLListViewItem::lvt_Deployment_Diagram:
1632  if (newParentType == UMLListViewItem::lvt_Deployment_Folder ||
1633  newParentType == UMLListViewItem::lvt_Deployment_View) {
1634  newItem = move->deepCopy(newParent);
1635  if (m_doc->loading()) // deletion is not safe while loading
1636  move->setVisible(false); // (the <listview> XMI may be corrupted)
1637  else
1638  delete move;
1639  addAtContainer(newItem, newParent);
1640  }
1641  break;
1642  case UMLListViewItem::lvt_EntityRelationship_Folder:
1643  case UMLListViewItem::lvt_Entity:
1644  case UMLListViewItem::lvt_Category:
1645  case UMLListViewItem::lvt_EntityRelationship_Diagram:
1646  if (newParentType == UMLListViewItem::lvt_EntityRelationship_Folder ||
1647  newParentType == UMLListViewItem::lvt_EntityRelationship_Model) {
1648  newItem = move->deepCopy(newParent);
1649  if (m_doc->loading()) // deletion is not safe while loading
1650  move->setVisible(false); // (the <listview> XMI may be corrupted)
1651  else
1652  delete move;
1653  addAtContainer(newItem, newParent);
1654  }
1655  break;
1656  case UMLListViewItem::lvt_Collaboration_Diagram:
1657  case UMLListViewItem::lvt_Class_Diagram:
1658  case UMLListViewItem::lvt_State_Diagram:
1659  case UMLListViewItem::lvt_Activity_Diagram:
1660  case UMLListViewItem::lvt_Sequence_Diagram:
1661  case UMLListViewItem::lvt_Logical_Folder:
1662  if (newParentType == UMLListViewItem::lvt_Logical_Folder ||
1663  newParentType == UMLListViewItem::lvt_Logical_View) {
1664  newItem = move->deepCopy(newParent);
1665  if (m_doc->loading()) // deletion is not safe while loading
1666  move->setVisible(false); // (the <listview> XMI may be corrupted)
1667  else
1668  delete move;
1669  addAtContainer(newItem, newParent);
1670  }
1671  break;
1672  case UMLListViewItem::lvt_Class:
1673  case UMLListViewItem::lvt_Package:
1674  case UMLListViewItem::lvt_Interface:
1675  case UMLListViewItem::lvt_Enum:
1676  case UMLListViewItem::lvt_Datatype:
1677  if (newParentType == UMLListViewItem::lvt_Logical_Folder ||
1678  newParentType == UMLListViewItem::lvt_Datatype_Folder ||
1679  newParentType == UMLListViewItem::lvt_Logical_View ||
1680  newParentType == UMLListViewItem::lvt_Class ||
1681  newParentType == UMLListViewItem::lvt_Interface ||
1682  newParentType == UMLListViewItem::lvt_Package) {
1683  newItem = move->deepCopy(newParent);
1684  if (m_doc->loading()) // deletion is not safe while loading
1685  move->setVisible(false); // (the <listview> XMI may be corrupted)
1686  else
1687  delete move;
1688  UMLCanvasObject *o = static_cast<UMLCanvasObject*>(newItem->umlObject());
1689  if (o == 0) {
1690  DEBUG(DBG_SRC) << "moveObject: newItem's UMLObject is 0";
1691  } else if (newParentObj == 0) {
1692  uError() << o->name() << ": newParentObj is 0";
1693  } else {
1694  UMLPackage *pkg = static_cast<UMLPackage*>(newParentObj);
1695  o->setUMLPackage(pkg);
1696  pkg->addObject(o);
1697  }
1698  UMLView *currentView = UMLApp::app()->currentView();
1699  if (currentView)
1700  currentView->umlScene()->updateContainment(o);
1701  }
1702  break;
1703  case UMLListViewItem::lvt_Attribute:
1704  case UMLListViewItem::lvt_Operation:
1705  if (newParentType == UMLListViewItem::lvt_Class ||
1706  newParentType == UMLListViewItem::lvt_Interface) {
1707  // update list view
1708 
1709  newItem = move->deepCopy(newParent);
1710  // we don't delete move right away, it will be deleted in slots,
1711  // called by subsequent steps
1712  //delete move;
1713 
1714  // update model objects
1715  m_bCreatingChildObject = true;
1716 
1717  UMLClassifier *oldParentClassifier = dynamic_cast<UMLClassifier*>(srcObj->parent());
1718  UMLClassifier *newParentClassifier = dynamic_cast<UMLClassifier*>(newParentObj);
1719  if (srcType == UMLListViewItem::lvt_Attribute) {
1720  UMLAttribute *att = dynamic_cast<UMLAttribute*>(srcObj);
1721  // We can't use the existing 'att' directly
1722  // because its parent is fixed to the old classifier
1723  // and we have no way of changing that:
1724  // QObject does not permit changing the parent().
1725  if (att == 0) {
1726  uError() << "moveObject internal error: srcObj "
1727  << srcObj->name() << " is not a UMLAttribute";
1728  } else if (oldParentClassifier->takeItem(att) == -1) {
1729  uError() << "moveObject: oldParentClassifier->takeItem(att "
1730  << att->name() << ") returns 0";
1731  } else {
1732  const QString& nm = att->name();
1733  UMLAttribute *newAtt = newParentClassifier->createAttribute(nm,
1734  att->getType(),
1735  att->visibility(),
1736  att->getInitialValue());
1737  newItem->setUMLObject(newAtt);
1738  newParent->addClassifierListItem(newAtt, newItem);
1739 
1740  connectNewObjectsSlots(newAtt);
1741  // Let's not forget to update the DocWindow::m_pObject
1742  // because the old one is about to be physically deleted !
1743  UMLApp::app()->docWindow()->showDocumentation(newAtt, true);
1744  delete att;
1745  }
1746  } else {
1747  UMLOperation *op = dynamic_cast<UMLOperation*>(srcObj);
1748  // We can't use the existing 'op' directly
1749  // because its parent is fixed to the old classifier
1750  // and we have no way of changing that:
1751  // QObject does not permit changing the parent().
1752  if (op && oldParentClassifier->takeItem(op) != -1) {
1753  bool isExistingOp;
1754  Model_Utils::NameAndType_List ntDummyList;
1755  // We need to provide a dummy NameAndType_List
1756  // else UMLClassifier::createOperation will
1757  // bring up an operation dialog.
1758  UMLOperation *newOp = newParentClassifier->createOperation(
1759  op->name(), &isExistingOp, &ntDummyList);
1760  newOp->setType(op->getType());
1761  newOp->setVisibility(op->visibility());
1762  UMLAttributeList parmList = op->getParmList();
1763  foreach(UMLAttribute* parm, parmList) {
1764  UMLAttribute *newParm = new UMLAttribute(newParentClassifier,
1765  parm->name(),
1766  Uml::ID::None,
1767  parm->visibility(),
1768  parm->getType(),
1769  parm->getInitialValue());
1770  newParm->setParmKind(parm->getParmKind());
1771  newOp->addParm(newParm);
1772  }
1773  newItem->setUMLObject(newOp);
1774  newParent->addClassifierListItem(newOp, newItem);
1775 
1776  connectNewObjectsSlots(newOp);
1777 
1778  // Let's not forget to update the DocWindow::m_pObject
1779  // because the old one is about to be physically deleted !
1780  UMLApp::app()->docWindow()->showDocumentation(newOp, true);
1781  delete op;
1782  } else {
1783  uError() << "moveObject: oldParentClassifier->takeItem(op) returns 0";
1784  }
1785  }
1786  m_bCreatingChildObject = false;
1787  }
1788  break;
1789  default:
1790  break;
1791  }
1792  return newItem;
1793 }
1794 
1798 void UMLListView::slotDropped(QDropEvent* de, UMLListViewItem* parent, UMLListViewItem* item)
1799 {
1800  Q_UNUSED(parent);
1801  item = (UMLListViewItem *)currentItem();
1802  if (!item) {
1803  DEBUG(DBG_SRC) << "item is 0 - doing nothing";
1804  return;
1805  }
1806  UMLDragData::LvTypeAndID_List srcList;
1807  if (! UMLDragData::getClip3TypeAndID(de->mimeData(), srcList)) {
1808  return;
1809  }
1810  UMLListViewItem *newParent = (UMLListViewItem*)item;
1811  DEBUG(DBG_SRC) << "slotDropped: newParent->text(0) is " << newParent->text(0);
1812  UMLDragData::LvTypeAndID_It it(srcList);
1813  UMLDragData::LvTypeAndID * src = 0;
1814  while (it.hasNext()) {
1815  src = it.next();
1816  moveObject(src->id, src->type, newParent);
1817  }
1818 }
1819 
1824 UMLListViewItemList UMLListView::selectedItems()
1825 {
1826  UMLListViewItemList itemList;
1827  UMLListViewItemIterator it(this);
1828  // iterate through all items of the list view
1829  for (; *it; ++it) {
1830  if ((*it)->isSelected()) {
1831  UMLListViewItem *item = (UMLListViewItem*)*it;
1832  itemList.append(item);
1833  }
1834  }
1835  // DEBUG(DBG_SRC) << "selected items = " << itemList.count();
1836 
1837  return itemList;
1838 }
1839 
1844 UMLListViewItemList UMLListView::selectedItemsRoot()
1845 {
1846  UMLListViewItemList itemList;
1847  QTreeWidgetItemIterator it(this);
1848 
1849  // iterate through all items of the list view
1850  for (; *it; ++it) {
1851  if ((*it)->isSelected()) {
1852  UMLListViewItem *item = (UMLListViewItem*)*it;
1853  // this is the trick, we select only the item with a parent unselected
1854  // since we can't select a child and its grandfather without its parent
1855  // we would be able to delete each item individually, without an invalid iterator
1856  if (item && item->parent() && item->parent()->isSelected() == false) {
1857  itemList.append(item);
1858  }
1859  }
1860  }
1861 
1862  return itemList;
1863 }
1864 
1870 UMLListViewItem* UMLListView::createDiagramItem(UMLView *view)
1871 {
1872  if (!view) {
1873  return 0;
1874  }
1875  UMLListViewItem::ListViewType lvt = Model_Utils::convert_DT_LVT(view->umlScene()->type());
1876  UMLListViewItem *parent = 0;
1877  UMLFolder *f = view->umlScene()->folder();
1878  if (f) {
1879  parent = findUMLObject(f);
1880  if (parent == 0)
1881  uError() << view->umlScene()->name() << ": findUMLObject(" << f->name() << ") returns 0";
1882  } else {
1883  DEBUG(DBG_SRC) << view->umlScene()->name() << ": no parent folder set, using predefined folder";
1884  }
1885  if (parent == 0) {
1886  parent = determineParentItem(lvt);
1887  lvt = Model_Utils::convert_DT_LVT(view->umlScene()->type());
1888  }
1889  UMLListViewItem *item = new UMLListViewItem(parent, view->umlScene()->name(), lvt, view->umlScene()->ID());
1890  return item;
1891 }
1892 
1900 UMLListViewItem* UMLListView::determineParentItem(UMLListViewItem::ListViewType lvt) const
1901 {
1902  UMLListViewItem* parent = 0;
1903  switch (lvt) {
1904  case UMLListViewItem::lvt_Datatype:
1905  parent = m_datatypeFolder;
1906  break;
1907  case UMLListViewItem::lvt_Actor:
1908  case UMLListViewItem::lvt_UseCase:
1909  case UMLListViewItem::lvt_UseCase_Folder:
1910  case UMLListViewItem::lvt_UseCase_Diagram:
1911  parent = m_lv[Uml::ModelType::UseCase];
1912  break;
1913  case UMLListViewItem::lvt_Component_Diagram:
1914  case UMLListViewItem::lvt_Component:
1915  case UMLListViewItem::lvt_Artifact:
1916  parent = m_lv[Uml::ModelType::Component];
1917  break;
1918  case UMLListViewItem::lvt_Deployment_Diagram:
1919  case UMLListViewItem::lvt_Node:
1920  parent = m_lv[Uml::ModelType::Deployment];
1921  break;
1922  case UMLListViewItem::lvt_EntityRelationship_Diagram:
1923  case UMLListViewItem::lvt_Entity:
1924  case UMLListViewItem::lvt_Category:
1925  parent = m_lv[Uml::ModelType::EntityRelationship];
1926  break;
1927  default:
1928  if (Model_Utils::typeIsDiagram(lvt) || !Model_Utils::typeIsClassifierList(lvt))
1929  parent = m_lv[Uml::ModelType::Logical];
1930  break;
1931  }
1932  return parent;
1933 }
1934 
1938 int UMLListView::selectedItemsCount()
1939 {
1940  UMLListViewItemList items = selectedItems();
1941  return items.count();
1942 }
1943 
1947 UMLDoc * UMLListView::document() const
1948 {
1949  return m_doc;
1950 }
1951 
1956 void UMLListView::focusOutEvent(QFocusEvent * fe)
1957 {
1958  Qt::FocusReason reason = fe->reason();
1959  if (reason != Qt::PopupFocusReason && reason != Qt::MouseFocusReason) {
1960  clearSelection();
1961  //triggerUpdate();
1962  }
1963  //repaint();
1964 
1965  QTreeWidget::focusOutEvent(fe);
1966 }
1967 
1968 void UMLListView::contextMenuEvent(QContextMenuEvent *me)
1969 {
1970  // Get the UMLListViewItem at the point where the mouse pointer was pressed
1971  UMLListViewItem * item = static_cast<UMLListViewItem*>(itemAt(me->pos()));
1972  if (item) {
1973  const UMLListViewItem::ListViewType type = item->type();
1974  ListPopupMenu popup(this, type, item->umlObject());
1975  QAction *triggered = popup.exec(me->globalPos());
1976  slotMenuSelection(triggered);
1977  me->accept();
1978  }
1979 
1980  QTreeWidget::contextMenuEvent(me);
1981 }
1982 
1992 UMLListViewItem::ListViewType UMLListView::rootViewType(UMLListViewItem *item)
1993 {
1994  if (item == m_rv)
1995  return UMLListViewItem::lvt_View;
1996  if (item == m_lv[Uml::ModelType::Logical])
1997  return UMLListViewItem::lvt_Logical_View;
1998  if (item == m_lv[Uml::ModelType::UseCase])
1999  return UMLListViewItem::lvt_UseCase_View;
2000  if (item == m_lv[Uml::ModelType::Component])
2001  return UMLListViewItem::lvt_Component_View;
2002  if (item == m_lv[Uml::ModelType::Deployment])
2003  return UMLListViewItem::lvt_Deployment_View;
2004  if (item == m_lv[Uml::ModelType::EntityRelationship])
2005  return UMLListViewItem::lvt_EntityRelationship_Model;
2006  UMLListViewItem *parent = dynamic_cast<UMLListViewItem*>(item->parent());
2007  if (parent)
2008  return rootViewType(parent);
2009  return UMLListViewItem::lvt_Unknown;
2010 }
2011 
2015 bool UMLListView::isExpandable(UMLListViewItem::ListViewType lvt)
2016 {
2017  if (Model_Utils::typeIsRootView(lvt) || Model_Utils::typeIsFolder(lvt))
2018  return true;
2019  switch (lvt) {
2020  case UMLListViewItem::lvt_Package:
2021  case UMLListViewItem::lvt_Component:
2022  case UMLListViewItem::lvt_Subsystem:
2023  return true;
2024  break;
2025  default:
2026  break;
2027  }
2028  return false;
2029 }
2030 
2034 void UMLListView::slotExpanded(QTreeWidgetItem * item)
2035 {
2036  UMLListViewItem * myItem = static_cast<UMLListViewItem*>(item);
2037  if (isExpandable(myItem->type())) {
2038  myItem->updateFolder();
2039  }
2040 }
2041 
2045 void UMLListView::slotCollapsed(QTreeWidgetItem * item)
2046 {
2047  UMLListViewItem * myItem = static_cast<UMLListViewItem*>(item);
2048  if (isExpandable(myItem->type())) {
2049  myItem->updateFolder();
2050  }
2051 }
2052 
2057 void UMLListView::slotCutSuccessful()
2058 {
2059  if (m_bStartedCut) {
2060  UMLListViewItem* item = static_cast<UMLListViewItem*>(currentItem());
2061  deleteItem(item);
2062 
2063  m_bStartedCut = false;
2064  }
2065 }
2066 
2070 void UMLListView::slotDeleteSelectedItems()
2071 {
2072  UMLListViewItemList itemsSelected = selectedItemsRoot();
2073  foreach(UMLListViewItem *item, itemsSelected) {
2074  deleteItem(item);
2075  }
2076 }
2077 
2083 void UMLListView::addNewItem(UMLListViewItem *parentItem, UMLListViewItem::ListViewType type)
2084 {
2085  UMLListViewItem *newItem;
2086  if (type == UMLListViewItem::lvt_Datatype) {
2087  parentItem = m_datatypeFolder;
2088  }
2089 
2090  blockSignals(true);
2091  parentItem->setOpen(true);
2092 
2093  Icon_Utils::IconType icon = Model_Utils::convert_LVT_IT(type);
2094 
2095  QString name;
2096  if (Model_Utils::typeIsDiagram(type)) {
2097  Uml::DiagramType::Enum dt = Model_Utils::convert_LVT_DT(type);
2098  name = uniqueDiagramName(dt);
2099  newItem = new UMLListViewItem(parentItem, name, type, Uml::ID::None);
2100  } else {
2101  UMLObject::ObjectType ot = Model_Utils::convert_LVT_OT(type);
2102  if (ot == UMLObject::ot_UMLObject) {
2103  DEBUG(DBG_SRC) << "no UMLObject for type " << UMLListViewItem::toString(type);
2104  return;
2105  }
2106  UMLPackage *parentPkg =
2107  dynamic_cast<UMLPackage*>(parentItem->umlObject());
2108  if (parentPkg == 0) {
2109  uError() << "UMLListView::addNewItem - "
2110  << UMLListViewItem::toString(type) << ": parentPkg is 0";
2111  return;
2112  }
2113  if (Model_Utils::typeIsClassifierList(type)) {
2114  UMLClassifier *parent = static_cast<UMLClassifier*>(parentPkg);
2115  name = parent->uniqChildName(ot);
2116  } else {
2117  name = Model_Utils::uniqObjectName(ot, parentPkg);
2118  }
2119  newItem = new UMLListViewItem(parentItem, name, type, (UMLObject *)0);
2120  }
2121  newItem->setIcon(icon);
2122  newItem->setOpen(true);
2123  blockSignals(false);
2124  createItem(newItem);
2125 }
2126 
2130 bool UMLListView::itemRenamed(UMLListViewItem * item, int col)
2131 {
2132  DEBUG(DBG_SRC) << item->text(col);
2133  UMLListViewItem * renamedItem = static_cast< UMLListViewItem *>(item) ;
2134  UMLListViewItem::ListViewType type = renamedItem->type();
2135  QString newText = renamedItem->text(col);
2136 
2137  // If the type is empty then delete it.
2138  if (newText.isEmpty() || newText.contains(QRegExp("^\\s+$"))) {
2139  KMessageBox::error(
2140  0,
2141  i18n("The name you entered was invalid.\nCreation process has been canceled."),
2142  i18n("Name Not Valid"));
2143  return false;
2144  }
2145 
2146  if (!isUnique(renamedItem, newText)) {
2147  //if operation ask if ok not to be unique i.e overloading
2148  if (type == UMLListViewItem::lvt_Operation) {
2149  if (KMessageBox::warningYesNo(
2150  0,
2151  i18n("The name you entered was not unique.\nIs this what you wanted?"),
2152  i18n("Name Not Unique"), KGuiItem(i18n("Use Name")), KGuiItem(i18n("Enter New Name"))) == KMessageBox::No) {
2153  return false;
2154  }
2155  } else {
2156  KMessageBox::error(
2157  0,
2158  i18n("The name you entered was not unique.\nCreation process has been canceled."),
2159  i18n("Name Not Unique"));
2160  return false;
2161  }
2162  }
2163  return createItem(renamedItem);
2164 }
2165 
2166 bool UMLListView::createItem(UMLListViewItem *item)
2167 {
2168  const UMLListViewItem::ListViewType type = item->type();
2169  switch (type) {
2170  case UMLListViewItem::lvt_Actor:
2171  case UMLListViewItem::lvt_Class:
2172  case UMLListViewItem::lvt_Package:
2173  case UMLListViewItem::lvt_Logical_Folder:
2174  case UMLListViewItem::lvt_UseCase_Folder:
2175  case UMLListViewItem::lvt_Component_Folder:
2176  case UMLListViewItem::lvt_Deployment_Folder:
2177  case UMLListViewItem::lvt_EntityRelationship_Folder:
2178  case UMLListViewItem::lvt_Subsystem:
2179  case UMLListViewItem::lvt_Component:
2180  case UMLListViewItem::lvt_Node:
2181  case UMLListViewItem::lvt_Artifact:
2182  case UMLListViewItem::lvt_Interface:
2183  case UMLListViewItem::lvt_Datatype:
2184  case UMLListViewItem::lvt_Enum:
2185  case UMLListViewItem::lvt_Entity:
2186  case UMLListViewItem::lvt_UseCase:
2187  case UMLListViewItem::lvt_Category: {
2188  UMLObject::ObjectType ot = Model_Utils::convert_LVT_OT(type);
2189  if (! ot) {
2190  uError() << "internal error";
2191  return false;
2192  }
2193  UMLObject *o = createUMLObject(item, ot);
2194  if (type == UMLListViewItem::lvt_Subsystem)
2195  o->setStereotype("subsystem");
2196  else if (Model_Utils::typeIsFolder(type))
2197  o->setStereotype("folder");
2198  }
2199  break;
2200 
2201  case UMLListViewItem::lvt_Attribute:
2202  case UMLListViewItem::lvt_EntityAttribute:
2203  case UMLListViewItem::lvt_Operation:
2204  case UMLListViewItem::lvt_Template:
2205  case UMLListViewItem::lvt_EnumLiteral:
2206  case UMLListViewItem::lvt_UniqueConstraint:
2207  case UMLListViewItem::lvt_ForeignKeyConstraint:
2208  case UMLListViewItem::lvt_CheckConstraint:
2209  return createChildUMLObject(item, Model_Utils::convert_LVT_OT(type));
2210  break;
2211 
2212  case UMLListViewItem::lvt_PrimaryKeyConstraint: {
2213  bool result = createChildUMLObject(item, Model_Utils::convert_LVT_OT(type));
2214  UMLObject* obj = item->umlObject();
2215  UMLUniqueConstraint* uuc = static_cast<UMLUniqueConstraint*>(obj);
2216  UMLEntity* ent = static_cast<UMLEntity*>(uuc->parent());
2217  if (ent)
2218  ent->setAsPrimaryKey(uuc);
2219 
2220  return result;
2221  }
2222  break;
2223 
2224  case UMLListViewItem::lvt_Class_Diagram:
2225  createDiagram(item, Uml::DiagramType::Class);
2226  break;
2227 
2228  case UMLListViewItem::lvt_UseCase_Diagram:
2229  createDiagram(item, Uml::DiagramType::UseCase);
2230  break;
2231 
2232  case UMLListViewItem::lvt_Sequence_Diagram:
2233  createDiagram(item, Uml::DiagramType::Sequence);
2234  break;
2235 
2236  case UMLListViewItem::lvt_Collaboration_Diagram:
2237  createDiagram(item, Uml::DiagramType::Collaboration);
2238  break;
2239 
2240  case UMLListViewItem::lvt_State_Diagram:
2241  createDiagram(item, Uml::DiagramType::State);
2242  break;
2243 
2244  case UMLListViewItem::lvt_Activity_Diagram:
2245  createDiagram(item, Uml::DiagramType::Activity);
2246  break;
2247 
2248  case UMLListViewItem::lvt_Component_Diagram:
2249  createDiagram(item, Uml::DiagramType::Component);
2250  break;
2251 
2252  case UMLListViewItem::lvt_Deployment_Diagram:
2253  createDiagram(item, Uml::DiagramType::Deployment);
2254  break;
2255 
2256  case UMLListViewItem::lvt_EntityRelationship_Diagram:
2257  createDiagram(item, Uml::DiagramType::EntityRelationship);
2258  break;
2259 
2260  default:
2261  break;
2262  }
2263  return true;
2264 }
2265 
2269 UMLObject *UMLListView::createUMLObject(UMLListViewItem * item, UMLObject::ObjectType type)
2270 {
2271  QString name = item->text(0);
2272  UMLObject * object = 0;
2273  switch (type) {
2274  case UMLObject::ot_UseCase:
2275  object = new UMLUseCase(name);
2276  break;
2277 
2278  case UMLObject::ot_Actor:
2279  object = new UMLActor(name);
2280  break;
2281 
2282  case UMLObject::ot_Class:
2283  object = new UMLClassifier(name);
2284  break;
2285 
2286  case UMLObject::ot_Package:
2287  object = new UMLPackage(name);
2288  break;
2289 
2290  case UMLObject::ot_Folder:
2291  object = new UMLFolder(name);
2292  break;
2293 
2294  case UMLObject::ot_Component:
2295  object = new UMLComponent(name);
2296  break;
2297 
2298  case UMLObject::ot_Node:
2299  object = new UMLNode(name);
2300  break;
2301 
2302  case UMLObject::ot_Artifact:
2303  object = new UMLArtifact(name);
2304  break;
2305 
2306  case UMLObject::ot_Interface: {
2307  UMLClassifier *c = new UMLClassifier(name);
2308  c->setBaseType(UMLObject::ot_Interface);
2309  object = c;
2310  }
2311  break;
2312 
2313  case UMLObject::ot_Datatype: {
2314  UMLClassifier *c = new UMLClassifier(name);
2315  c->setBaseType(UMLObject::ot_Datatype);
2316  object = c;
2317  }
2318  break;
2319 
2320  case UMLObject::ot_Enum:
2321  object = new UMLEnum(name);
2322  break;
2323 
2324  case UMLObject::ot_Entity:
2325  object = new UMLEntity(name);
2326  break;
2327 
2328  case UMLObject::ot_Category:
2329  object = new UMLCategory(name);
2330  break;
2331 
2332  default:
2333  uWarning() << "creating UML Object of unknown type";
2334  return 0;
2335  }
2336 
2337  UMLListViewItem * parentItem = static_cast<UMLListViewItem *>(item->parent());
2338  const UMLListViewItem::ListViewType lvt = parentItem->type();
2339  if (! Model_Utils::typeIsContainer(lvt)) {
2340  uError() << object->name() << ": parentItem (" << lvt << " is not a container";
2341  delete object;
2342  return 0;
2343  }
2344  UMLPackage *pkg = static_cast<UMLPackage*>(parentItem->umlObject());
2345  object->setUMLPackage(pkg);
2346  pkg->addObject(object);
2347  connectNewObjectsSlots(object);
2348  item->setUMLObject(object);
2349  item->setText(name);
2350  return object;
2351 }
2352 
2356 bool UMLListView::createChildUMLObject(UMLListViewItem * item, UMLObject::ObjectType type)
2357 {
2358  m_bCreatingChildObject = true;
2359  QString text = item->text(0);
2360  UMLObject* parent = static_cast<UMLListViewItem *>(item->parent())->umlObject();
2361  if (!parent) {
2362  uError() << "parent UMLObject is 0";
2363  m_bCreatingChildObject = false;
2364  return false;
2365  }
2366 
2367  UMLObject* newObject = 0;
2368  if (type == UMLObject::ot_EnumLiteral) {
2369  UMLEnum *owningEnum = static_cast<UMLEnum*>(parent);
2370  newObject = owningEnum->createEnumLiteral(text);
2371 
2372  UMLEnumLiteral* enumLiteral = static_cast<UMLEnumLiteral*>(newObject);
2373  text = enumLiteral->toString(Uml::SignatureType::SigNoVis);
2374  } else if (type == UMLObject::ot_Template) {
2375  UMLClassifier *owningClassifier = static_cast<UMLClassifier*>(parent);
2376  Model_Utils::NameAndType nt;
2377  Model_Utils::Parse_Status st = Model_Utils::parseTemplate(text, nt, owningClassifier);
2378  if (st) {
2379  KMessageBox::error(0,
2380  Model_Utils::psText(st),
2381  i18n("Creation canceled"));
2382  m_bCreatingChildObject = false;
2383  return false;
2384  }
2385  newObject = owningClassifier->createTemplate(nt.m_name);
2386  UMLTemplate *tmplParm = static_cast<UMLTemplate*>(newObject);
2387  tmplParm->setType(nt.m_type);
2388  text = tmplParm->toString(Uml::SignatureType::SigNoVis);
2389  } else if (type == UMLObject::ot_Attribute || type == UMLObject::ot_EntityAttribute) {
2390  UMLClassifier *owningClass = static_cast<UMLClassifier*>(parent);
2391  Model_Utils::NameAndType nt;
2392  Uml::Visibility::Enum vis;
2393  Model_Utils::Parse_Status st;
2394  st = Model_Utils::parseAttribute(text, nt, owningClass, &vis);
2395  if (st) {
2396  KMessageBox::error(0,
2397  Model_Utils::psText(st),
2398  i18n("Creation canceled"));
2399  m_bCreatingChildObject = false;
2400  return false;
2401  }
2402  newObject = owningClass->createAttribute(nt.m_name, nt.m_type, vis, nt.m_initialValue);
2403  UMLAttribute *att = static_cast<UMLAttribute*>(newObject);
2404  att->setParmKind(nt.m_direction);
2405  text = att->toString(Uml::SignatureType::SigNoVis);
2406  } else if (type == UMLObject::ot_Operation) {
2407  UMLClassifier *owningClassifier = static_cast<UMLClassifier*>(parent);
2408  Model_Utils::OpDescriptor od;
2409  Model_Utils::Parse_Status st = Model_Utils::parseOperation(text, od, owningClassifier);
2410  if (st) {
2411  KMessageBox::error(0,
2412  Model_Utils::psText(st),
2413  i18n("Creation canceled"));
2414  m_bCreatingChildObject = false;
2415  return false;
2416  }
2417  bool isExistingOp = false;
2418  newObject = owningClassifier->createOperation(od.m_name, &isExistingOp, &od.m_args);
2419  if (newObject == 0 || isExistingOp) {
2420  if (isExistingOp)
2421  KMessageBox::error(
2422  0,
2423  i18n("The name you entered was not unique.\nCreation process has been canceled."),
2424  i18n("Name Not Unique"));
2425  m_bCreatingChildObject = false;
2426  return false;
2427  }
2428  UMLOperation *op = static_cast<UMLOperation*>(newObject);
2429  if (od.m_pReturnType) {
2430  op->setType(od.m_pReturnType);
2431  }
2432  text = op->toString(Uml::SignatureType::SigNoVis);
2433  } else if (type == UMLObject::ot_UniqueConstraint || type == UMLObject::ot_ForeignKeyConstraint
2434  || type == UMLObject::ot_CheckConstraint) {
2435 
2436  UMLEntity *owningEntity = static_cast<UMLEntity*>(parent);
2437 
2438  QString name;
2439  Model_Utils::Parse_Status st = Model_Utils::parseConstraint(text, name, owningEntity);
2440  if (st) {
2441  KMessageBox::error(0,
2442  Model_Utils::psText(st),
2443  i18n("Creation canceled"));
2444  m_bCreatingChildObject = false;
2445  return false;
2446  }
2447 
2448  switch (type) {
2449  case UMLObject::ot_UniqueConstraint:
2450  newObject = owningEntity->createUniqueConstraint(name);
2451  break;
2452  case UMLObject::ot_ForeignKeyConstraint:
2453  newObject = owningEntity->createForeignKeyConstraint(name);
2454  break;
2455  case UMLObject::ot_CheckConstraint:
2456  newObject = owningEntity->createCheckConstraint(name);
2457  break;
2458  default:
2459  break;
2460  }
2461 
2462  UMLEntityConstraint* uec = static_cast<UMLEntityConstraint*>(newObject);
2463 
2464  text = uec->toString(Uml::SignatureType::SigNoVis);
2465  } else {
2466  uError() << "called for type " << type << " (ignored)";
2467  m_bCreatingChildObject = false;
2468  return false;
2469  }
2470 
2471  // make changes to the object visible to this umllistviewitem
2472  connectNewObjectsSlots(newObject);
2473  item->setUMLObject(newObject);
2474  item->setText(text);
2475  scrollToItem(item);
2476 
2477  // as it's a ClassifierListItem add it to the childObjectMap of the parent
2478  UMLClassifierListItem* classifierListItem = static_cast<UMLClassifierListItem*>(newObject);
2479  static_cast<UMLListViewItem*>(item->parent())->addClassifierListItem(classifierListItem, item);
2480 
2481  m_bCreatingChildObject = false;
2482 
2483  if (! m_doc->loading())
2484  m_doc->setModified();
2485  return true;
2486 }
2487 
2491 UMLView* UMLListView::createDiagram(UMLListViewItem * item, Uml::DiagramType::Enum type)
2492 {
2493  QString name = item->text(0);
2494  DEBUG(DBG_SRC) << name << " / type=" << Uml::DiagramType::toString(type);
2495  UMLView * view = m_doc->findView(type, name);
2496  if (view) {
2497  delete item;
2498  return view;
2499  }
2500  UMLListViewItem *parentItem = static_cast<UMLListViewItem*>(item->parent());
2501  UMLFolder *parentFolder = dynamic_cast<UMLFolder*>(parentItem->umlObject());
2502  if (parentFolder == 0) {
2503  uError() << name << ": parent UMLObject is not a UMLFolder";
2504  delete item;
2505  return 0;
2506  }
2507  view = new UMLView(parentFolder);
2508  view->umlScene()->setName(name);
2509  view->umlScene()->setType(type);
2510  view->umlScene()->setID(UniqueID::gen());
2511  m_doc->addView(view);
2512  view->umlScene()->setOptionState(Settings::optionState());
2513  item->setID(view->umlScene()->ID());
2514  item->setText(0, name);
2515  view->umlScene()->activate();
2516  m_doc->changeCurrentView(view->umlScene()->ID());
2517 
2518  return view;
2519 }
2520 
2524 QString UMLListView::uniqueDiagramName(Uml::DiagramType::Enum type)
2525 {
2526  return m_doc->uniqueViewName(type);
2527 }
2528 
2532 bool UMLListView::isUnique(UMLListViewItem * item, const QString &name)
2533 {
2534  UMLListViewItem * parentItem = static_cast<UMLListViewItem *>(item->parent());
2535  UMLListViewItem::ListViewType type = item->type();
2536  switch (type) {
2537  case UMLListViewItem::lvt_Class_Diagram:
2538  return !m_doc->findView(Uml::DiagramType::Class, name);
2539  break;
2540 
2541  case UMLListViewItem::lvt_Sequence_Diagram:
2542  return !m_doc->findView(Uml::DiagramType::Sequence, name);
2543  break;
2544 
2545  case UMLListViewItem::lvt_UseCase_Diagram:
2546  return !m_doc->findView(Uml::DiagramType::UseCase, name);
2547  break;
2548 
2549  case UMLListViewItem::lvt_Collaboration_Diagram:
2550  return !m_doc->findView(Uml::DiagramType::Collaboration, name);
2551  break;
2552 
2553  case UMLListViewItem::lvt_State_Diagram:
2554  return !m_doc->findView(Uml::DiagramType::State, name);
2555  break;
2556 
2557  case UMLListViewItem::lvt_Activity_Diagram:
2558  return !m_doc->findView(Uml::DiagramType::Activity, name);
2559  break;
2560 
2561  case UMLListViewItem::lvt_Component_Diagram:
2562  return !m_doc->findView(Uml::DiagramType::Component, name);
2563  break;
2564 
2565  case UMLListViewItem::lvt_Deployment_Diagram:
2566  return !m_doc->findView(Uml::DiagramType::Deployment, name);
2567  break;
2568 
2569  case UMLListViewItem::lvt_EntityRelationship_Diagram:
2570  return !m_doc->findView(Uml::DiagramType::EntityRelationship, name);
2571  break;
2572 
2573  case UMLListViewItem::lvt_Actor:
2574  case UMLListViewItem::lvt_UseCase:
2575  case UMLListViewItem::lvt_Node:
2576  case UMLListViewItem::lvt_Artifact:
2577  case UMLListViewItem::lvt_Category:
2578  return !m_doc->findUMLObject(name, Model_Utils::convert_LVT_OT(type));
2579  break;
2580 
2581  case UMLListViewItem::lvt_Class:
2582  case UMLListViewItem::lvt_Package:
2583  case UMLListViewItem::lvt_Interface:
2584  case UMLListViewItem::lvt_Datatype:
2585  case UMLListViewItem::lvt_Enum:
2586  case UMLListViewItem::lvt_Entity:
2587  case UMLListViewItem::lvt_Component:
2588  case UMLListViewItem::lvt_Subsystem:
2589  case UMLListViewItem::lvt_Logical_Folder:
2590  case UMLListViewItem::lvt_UseCase_Folder:
2591  case UMLListViewItem::lvt_Component_Folder:
2592  case UMLListViewItem::lvt_Deployment_Folder:
2593  case UMLListViewItem::lvt_EntityRelationship_Folder: {
2594  UMLListViewItem::ListViewType lvt = parentItem->type();
2595  if (!Model_Utils::typeIsContainer(lvt))
2596  return (m_doc->findUMLObject(name) == 0);
2597  UMLPackage *pkg = static_cast<UMLPackage*>(parentItem->umlObject());
2598  if (pkg == 0) {
2599  uError() << "internal error - "
2600  << "parent listviewitem is package but has no UMLObject";
2601  return true;
2602  }
2603  return (pkg->findObject(name) == 0);
2604  break;
2605  }
2606 
2607  case UMLListViewItem::lvt_Template:
2608  case UMLListViewItem::lvt_Attribute:
2609  case UMLListViewItem::lvt_EntityAttribute:
2610  case UMLListViewItem::lvt_Operation:
2611  case UMLListViewItem::lvt_EnumLiteral:
2612  case UMLListViewItem::lvt_UniqueConstraint:
2613  case UMLListViewItem::lvt_PrimaryKeyConstraint:
2614  case UMLListViewItem::lvt_ForeignKeyConstraint:
2615  case UMLListViewItem::lvt_CheckConstraint: {
2616  UMLClassifier *parent = static_cast<UMLClassifier*>(parentItem->umlObject());
2617  return (parent->findChildObject(name) == 0);
2618  break;
2619  }
2620 
2621  default:
2622  break;
2623  }
2624  return false;
2625 }
2626 
2630 void UMLListView::saveToXMI(QDomDocument & qDoc, QDomElement & qElement)
2631 {
2632  QDomElement listElement = qDoc.createElement("listview");
2633  m_rv->saveToXMI(qDoc, listElement);
2634  qElement.appendChild(listElement);
2635 }
2636 
2640 bool UMLListView::loadFromXMI(QDomElement & element)
2641 {
2642  QDomNode node = element.firstChild();
2643  QDomElement domElement = node.toElement();
2644  m_doc->writeToStatusBar(i18n("Loading listview..."));
2645  while (!domElement.isNull()) {
2646  if (domElement.tagName() == "listitem") {
2647  QString type = domElement.attribute("type", "-1");
2648  if (type == "-1")
2649  return false;
2650  UMLListViewItem::ListViewType lvType = (UMLListViewItem::ListViewType)type.toInt();
2651  if (lvType == UMLListViewItem::lvt_View) {
2652  if (!loadChildrenFromXMI(m_rv, domElement))
2653  return false;
2654  } else
2655  return false;
2656  }
2657  node = node.nextSibling();
2658  domElement = node.toElement();
2659 
2660  }//end while
2661  return true;
2662 }
2663 
2667 bool UMLListView::loadChildrenFromXMI(UMLListViewItem * parent, QDomElement & element)
2668 {
2669  QDomNode node = element.firstChild();
2670  QDomElement domElement = node.toElement();
2671  while (!domElement.isNull()) {
2672  node = domElement.nextSibling();
2673  if (domElement.tagName() != "listitem") {
2674  domElement = node.toElement();
2675  continue;
2676  }
2677  QString id = domElement.attribute("id", "-1");
2678  QString type = domElement.attribute("type", "-1");
2679  QString label = domElement.attribute("label", "");
2680  QString open = domElement.attribute("open", "1");
2681  if (type == "-1")
2682  return false;
2683  UMLListViewItem::ListViewType lvType = (UMLListViewItem::ListViewType)type.toInt();
2684  bool bOpen = (bool)open.toInt();
2685  Uml::ID::Type nID = Uml::ID::fromString(id);
2686  UMLObject * pObject = 0;
2687  UMLListViewItem * item = 0;
2688  if (nID != Uml::ID::None) {
2689  // The following is an ad hoc hack for the copy/paste code.
2690  // The clip still contains the old children although new
2691  // UMLCLassifierListItems have already been created.
2692  // If the IDChangeLog finds new IDs this means we are in
2693  // copy/paste and need to adjust the child listitems to the
2694  // new UMLCLassifierListItems.
2695  IDChangeLog *idchanges = m_doc->changeLog();
2696  if (idchanges) {
2697  Uml::ID::Type newID = idchanges->findNewID(nID);
2698  if (newID != Uml::ID::None) {
2699  DEBUG(DBG_SRC) << " using id " << Uml::ID::toString(newID)
2700  << " instead of " << Uml::ID::toString(nID);
2701  nID = newID;
2702  }
2703  }
2704  /************ End of hack for copy/paste code ************/
2705 
2706  pObject = m_doc->findObjectById(nID);
2707  if (pObject) {
2708  if (label.isEmpty())
2709  label = pObject->name();
2710  } else if (Model_Utils::typeIsFolder(lvType)) {
2711  // Synthesize the UMLFolder here
2712  UMLObject *umlParent = parent->umlObject();
2713  UMLPackage *parentPkg = dynamic_cast<UMLPackage*>(umlParent);
2714  if (parentPkg == 0) {
2715  uError() << "umlParent(" << umlParent << ") is not a UMLPackage";
2716  domElement = node.toElement();
2717  continue;
2718  }
2719  UMLFolder *f = new UMLFolder(label, nID);
2720  f->setUMLPackage(parentPkg);
2721  parentPkg->addObject(f);
2722  pObject = f;
2723  item = new UMLListViewItem(parent, label, lvType, pObject);
2724  // Moving all relevant UMLObjects to the new UMLFolder is done below,
2725  // in the switch(lvType)
2726  }
2727  } else if (Model_Utils::typeIsRootView(lvType)) {
2728  // Predefined folders did not have their ID set.
2729  const Uml::ModelType::Enum mt = Model_Utils::convert_LVT_MT(lvType);
2730  nID = m_doc->rootFolder(mt)->id();
2731  } else if (Model_Utils::typeIsFolder(lvType)) {
2732  // Pre-1.2 format: Folders did not have their ID set.
2733  // Pull a new ID now.
2734  nID = UniqueID::get();
2735  } else {
2736  uError() << "item of type " << type << " has no ID, skipping.";
2737  domElement = node.toElement();
2738  continue;
2739  }
2740 
2741  switch (lvType) {
2742  case UMLListViewItem::lvt_Actor:
2743  case UMLListViewItem::lvt_UseCase:
2744  case UMLListViewItem::lvt_Class:
2745  case UMLListViewItem::lvt_Interface:
2746  case UMLListViewItem::lvt_Datatype:
2747  case UMLListViewItem::lvt_Enum:
2748  case UMLListViewItem::lvt_Entity:
2749  case UMLListViewItem::lvt_Package:
2750  case UMLListViewItem::lvt_Subsystem:
2751  case UMLListViewItem::lvt_Component:
2752  case UMLListViewItem::lvt_Node:
2753  case UMLListViewItem::lvt_Artifact:
2754  case UMLListViewItem::lvt_Logical_Folder:
2755  case UMLListViewItem::lvt_UseCase_Folder:
2756  case UMLListViewItem::lvt_Component_Folder:
2757  case UMLListViewItem::lvt_Deployment_Folder:
2758  case UMLListViewItem::lvt_EntityRelationship_Folder:
2759  case UMLListViewItem::lvt_Category:
2760  item = findItem(nID);
2761  if (item == 0) {
2762  uError() << "INTERNAL ERROR: "
2763  << "findItem(id " << Uml::ID::toString(nID) << ") returns 0";
2764  /*
2765  if (pObject && pObject->getUMLPackage() &&
2766  parent->type() != UMLListViewItem::lvt_Package) {
2767  // Pre-1.2 file format:
2768  // Objects were not nested in their packages.
2769  // Synthesize the nesting here.
2770  UMLPackage *umlpkg = pObject->getUMLPackage();
2771  UMLListViewItem *pkgItem = findUMLObject(umlpkg);
2772  if (pkgItem == 0) {
2773  DEBUG(DBG_SRC) << "synthesizing ListViewItem for package "
2774  << Uml::ID::toString(umlpkg->ID());
2775  pkgItem = new UMLListViewItem(parent, umlpkg->getName(),
2776  UMLListViewItem::lvt_Package, umlpkg);
2777  pkgItem->setOpen(true);
2778  }
2779  item = new UMLListViewItem(pkgItem, label, lvType, pObject);
2780  } else {
2781  item = new UMLListViewItem(parent, label, lvType, pObject);
2782  }
2783  */
2784  } else if (parent != item->parent()) {
2785  // The existing item was created by the slot event triggered
2786  // by the loading of the corresponding model object from the
2787  // XMI file.
2788  // This early creation is done in order to support the loading
2789  // of foreign XMI files that do not have the umbrello specific
2790  // <listview> tag.
2791  // However, now that we encountered the real <listview> info,
2792  // we need to delete the existing item: Its parent is always
2793  // one of the default predefined folders, but the actual
2794  // listview item might be located in a user created folder.
2795  // Thanks to Achim Spangler for spotting the problem.
2796  UMLListViewItem *itmParent = dynamic_cast<UMLListViewItem*>(item->parent());
2797  DEBUG(DBG_SRC) << item->text(0) << " parent "
2798  << parent->text(0) << " (" << parent << ") != "
2799  << itmParent->text(0) << " (" << itmParent << ")";
2800  if (item == m_datatypeFolder && itmParent == m_lv[Uml::ModelType::Logical]) {
2801  DEBUG(DBG_SRC) << "Reparenting the Datatypes folder is prohibited";
2802  } else {
2803  UMLListViewItem *newItem = moveObject(nID, lvType, parent);
2804  item = newItem;
2805  if (item) {
2806  DEBUG(DBG_SRC) << "Attempted reparenting of " << item->text(0)
2807  << "(current parent: " << (itmParent ? itmParent->text(0) : "0")
2808  << ", new parent: " << parent->text(0) << ")";
2809  }
2810  }
2811  }
2812  break;
2813  case UMLListViewItem::lvt_Attribute:
2814  case UMLListViewItem::lvt_EntityAttribute:
2815  case UMLListViewItem::lvt_Template:
2816  case UMLListViewItem::lvt_Operation:
2817  case UMLListViewItem::lvt_EnumLiteral:
2818  case UMLListViewItem::lvt_UniqueConstraint:
2819  case UMLListViewItem::lvt_PrimaryKeyConstraint:
2820  case UMLListViewItem::lvt_ForeignKeyConstraint:
2821  case UMLListViewItem::lvt_CheckConstraint:
2822  item = findItem(nID);
2823  if (item == 0) {
2824  DEBUG(DBG_SRC) << "item " << Uml::ID::toString(nID) << " (of type "
2825  << UMLListViewItem::toString(lvType) << ") does not yet exist...";
2826  UMLObject* umlObject = parent->umlObject();
2827  if (!umlObject) {
2828  DEBUG(DBG_SRC) << "And also the parent->umlObject() does not exist";
2829  return false;
2830  }
2831  if (nID == Uml::ID::None) {
2832  uWarning() << "lvtype " << UMLListViewItem::toString(lvType) << " has id -1";
2833  } else {
2834  UMLClassifier *classifier = dynamic_cast<UMLClassifier*>(umlObject);
2835  if (classifier) {
2836  umlObject = classifier->findChildObjectById(nID);
2837  if (umlObject) {
2838  connectNewObjectsSlots(umlObject);
2839  label = umlObject->name();
2840  item = new UMLListViewItem(parent, label, lvType, umlObject);
2841  } else {
2842  DEBUG(DBG_SRC) << "lvtype " << UMLListViewItem::toString(lvType)
2843  << " child object " << Uml::ID::toString(nID) << " not found";
2844  }
2845  } else {
2846  DEBUG(DBG_SRC) << "cast to classifier object failed";
2847  }
2848  }
2849  }
2850  break;
2851  case UMLListViewItem::lvt_Logical_View:
2852  item = m_lv[Uml::ModelType::Logical];
2853  break;
2854  case UMLListViewItem::lvt_Datatype_Folder:
2855  item = m_datatypeFolder;
2856  break;
2857  case UMLListViewItem::lvt_UseCase_View:
2858  item = m_lv[Uml::ModelType::UseCase];
2859  break;
2860  case UMLListViewItem::lvt_Component_View:
2861  item = m_lv[Uml::ModelType::Component];
2862  break;
2863  case UMLListViewItem::lvt_Deployment_View:
2864  item = m_lv[Uml::ModelType::Deployment];
2865  break;
2866  case UMLListViewItem::lvt_EntityRelationship_Model:
2867  item = m_lv[Uml::ModelType::EntityRelationship];
2868  break;
2869  default:
2870  if (Model_Utils::typeIsDiagram(lvType)) {
2871  item = new UMLListViewItem(parent, label, lvType, nID);
2872  } else {
2873  uError() << "INTERNAL ERROR: unexpected listview type "
2874  << UMLListViewItem::toString(lvType) << " (ID " << Uml::ID::toString(nID) << ")";
2875  }
2876  break;
2877  }//end switch
2878 
2879  if (item) {
2880  item->setOpen((bool)bOpen);
2881  if (!loadChildrenFromXMI(item, domElement)) {
2882  return false;
2883  }
2884  } else {
2885  uWarning() << "unused list view item " << Uml::ID::toString(nID)
2886  << " of lvtype " << UMLListViewItem::toString(lvType);
2887  }
2888  domElement = node.toElement();
2889  }//end while
2890  return true;
2891 }
2892 
2896 void UMLListView::expandAll(UMLListViewItem *item)
2897 {
2898  if (!item) item = static_cast<UMLListViewItem*>(topLevelItem(0));
2899  for (int i = 0; i < item->childCount(); i++) {
2900  expandAll(item->childItem(i));
2901  }
2902  item->setExpanded(true);
2903 }
2904 
2908 void UMLListView::collapseAll(UMLListViewItem *item)
2909 {
2910  if (!item) item = static_cast<UMLListViewItem*>(topLevelItem(0));
2911  for (int i = 0; i < item->childCount(); i++) {
2912  collapseAll(item->childItem(i));
2913  }
2914  item->setExpanded(false);
2915 }
2916 
2922 void UMLListView::setStartedCut(bool startedCut)
2923 {
2924  m_bStartedCut = startedCut;
2925 }
2926 
2932 void UMLListView::setStartedCopy(bool startedCopy)
2933 {
2934  m_bStartedCopy = startedCopy;
2935 }
2936 
2940 bool UMLListView::startedCopy() const
2941 {
2942  return m_bStartedCopy;
2943 }
2944 
2949 UMLListViewItem *UMLListView::rootView(UMLListViewItem::ListViewType type)
2950 {
2951  UMLListViewItem *theView = 0;
2952  switch (type) {
2953  case UMLListViewItem::lvt_View:
2954  theView = m_rv;
2955  break;
2956  case UMLListViewItem::lvt_Logical_View:
2957  theView = m_lv[Uml::ModelType::Logical];
2958  break;
2959  case UMLListViewItem::lvt_UseCase_View:
2960  theView = m_lv[Uml::ModelType::UseCase];
2961  break;
2962  case UMLListViewItem::lvt_Component_View:
2963  theView = m_lv[Uml::ModelType::Component];
2964  break;
2965  case UMLListViewItem::lvt_Deployment_View:
2966  theView = m_lv[Uml::ModelType::Deployment];
2967  break;
2968  case UMLListViewItem::lvt_EntityRelationship_Model:
2969  theView = m_lv[Uml::ModelType::EntityRelationship];
2970  break;
2971  case UMLListViewItem::lvt_Datatype_Folder: // @todo fix asymmetric naming
2972  theView = m_datatypeFolder;
2973  break;
2974  default:
2975  break;
2976  }
2977  return theView;
2978 }
2979 
2984 void UMLListView::deleteChildrenOf(UMLListViewItem* parent)
2985 {
2986  if (!parent) {
2987  return;
2988  }
2989  if (parent == m_lv[Uml::ModelType::Logical]) {
2990  delete m_datatypeFolder;
2991  m_datatypeFolder = 0;
2992  }
2993  for (int i = parent->childCount() - 1; i >= 0; --i)
2994  parent->removeChild(parent->child(i));
2995 }
2996 
3000 void UMLListView::closeDatatypesFolder()
3001 {
3002  m_datatypeFolder->setOpen(false);
3003 }
3004 
3010 bool UMLListView::deleteItem(UMLListViewItem *temp)
3011 {
3012  if (!temp)
3013  return false;
3014  UMLObject *object = temp->umlObject();
3015  UMLListViewItem::ListViewType lvt = temp->type();
3016  if (Model_Utils::typeIsDiagram(lvt)) {
3017  m_doc->removeDiagram(temp->ID());
3018  } else if (temp == m_datatypeFolder) {
3019  // we can't delete the datatypeFolder because umbrello will crash without a special handling
3020  return false;
3021  } else if (Model_Utils::typeIsCanvasWidget(lvt) || Model_Utils::typeIsClassifierList(lvt)) {
3022  UMLPackage *nmSpc = dynamic_cast<UMLPackage*>(object);
3023  if (nmSpc) {
3024  UMLObjectList contained = nmSpc->containedObjects();
3025  if (contained.count()) {
3026  KMessageBox::error(
3027  0,
3028  i18n("The folder must be emptied before it can be deleted."),
3029  i18n("Folder Not Empty"));
3030  return false;
3031  }
3032  }
3033  UMLCanvasObject *canvasObj = dynamic_cast<UMLCanvasObject*>(object);
3034  if (canvasObj) {
3035  // We cannot just delete canvasObj here: What if the object
3036  // is still being used by others (for example, as a parameter
3037  // or return type of an operation) ?
3038  // Deletion should not have been permitted in the first place
3039  // if the object still has users - but Umbrello is lacking
3040  // that logic.
3041  canvasObj->removeAllChildObjects();
3042  }
3043  if (object) {
3044  m_doc->removeUMLObject(object);
3045  // Physical deletion of `temp' will be done by Qt signal, see
3046  // UMLDoc::removeUMLObject()
3047  } else {
3048  delete temp;
3049  }
3050  } else {
3051  uWarning() << "mt_Delete called with unknown type";
3052  }
3053  return true;
3054 }
3055 
3059 void UMLListView::dragEnterEvent(QDragEnterEvent* event)
3060 {
3061  event->accept();
3062  QTreeWidget::dragEnterEvent(event);
3063 }
3064 
3068 void UMLListView::dragMoveEvent(QDragMoveEvent* event)
3069 {
3070  event->accept();
3071  QTreeWidget::dragMoveEvent(event);
3072 }
3073 
3077 void UMLListView::dropEvent(QDropEvent* event)
3078 {
3079  if (!acceptDrag(event)) {
3080  event->ignore();
3081  }
3082  else {
3083  UMLListViewItem* item = static_cast<UMLListViewItem*>(itemAt(event->pos()));
3084  if (!item) {
3085  DEBUG(DBG_SRC) << "itemAt(mousePoint) returns 0";
3086  event->ignore();
3087  return;
3088  }
3089  slotDropped(event, 0, item);
3090  }
3091  QTreeWidget::dropEvent(event);
3092 }
3093 
3094 void UMLListView::commitData(QWidget *editor)
3095 {
3096  if (!editor)
3097  return;
3098 
3099  QModelIndex index = currentIndex();
3100  if (!index.isValid())
3101  return;
3102 
3103  QAbstractItemDelegate *delegate = itemDelegate(index);
3104  editor->removeEventFilter(delegate);
3105  QByteArray n = editor->metaObject()->userProperty().name();
3106  if (n.isEmpty()) {
3107  DEBUG(DBG_SRC) << "no name property found in list view item editor";
3108  return;
3109  }
3110 
3111  QString newText = editor->property(n).toString();
3112 
3113  UMLListViewItem *item = dynamic_cast<UMLListViewItem *>(currentItem());
3114  if (!item) {
3115  DEBUG(DBG_SRC) << "no item found after editing model index" << index;
3116  return;
3117  }
3118  item->slotEditFinished(newText);
3119  editor->installEventFilter(delegate);
3120 }
3121 
3126 void UMLListView::setBackgroundColor(const QColor & color)
3127 {
3128  QPalette palette;
3129  palette.setColor(backgroundRole(), color);
3130  setPalette(palette);
3131 }
3132 
3136 QDebug operator<<(QDebug out, const UMLListView& view)
3137 {
3138  UMLListViewItem* header = static_cast<UMLListViewItem*>(view.headerItem());
3139  if (header) {
3140  out << *header;
3141  for(int indx = 0; indx < header->childCount(); ++indx) {
3142  UMLListViewItem* item = static_cast<UMLListViewItem*>(header->child(indx));
3143  if (item) {
3144  out << indx << " - " << *item << endl;
3145  }
3146  else {
3147  out << indx << " - " << "<null>" << endl;
3148  }
3149  }
3150  }
3151  else {
3152  out << "<null>";
3153  }
3154  return out.space();
3155 }
3156 
3157 #include "umllistview.moc"
ListPopupMenu::mt_Class
Definition: listpopupmenu.h:78
UMLListViewItem::childItem
UMLListViewItem * childItem(int i)
Definition: umllistviewitem.cpp:934
UMLListViewItem::setText
void setText(int column, const QString &text)
Changes the current text.
Definition: umllistviewitem.cpp:435
UMLListView::setStartedCut
void setStartedCut(bool startedCut)
Set the variable m_bStartedCut to indicate that selection should be deleted in slotCutSuccessful().
Definition: umllistview.cpp:2922
UMLEntityAttributeDialog
Definition: umlentityattributedialog.h:28
Model_Utils::isClassifierListitem
bool isClassifierListitem(UMLObject::ObjectType type)
Return true if the given object type is a classifier list item type.
Definition: model_utils.cpp:550
UMLListViewItem::deepCopy
UMLListViewItem * deepCopy(UMLListViewItem *newParent)
Overrides the default sorting to sort by item type.
Definition: umllistviewitem.cpp:790
Uml::ModelType::EntityRelationship
Definition: basictypes.h:43
UMLListViewItem::lvt_UseCase_View
Definition: umllistviewitem.h:47
Model_Utils::typeIsClassifierList
bool typeIsClassifierList(UMLListViewItem::ListViewType type)
Return true if the listview type is an attribute, operation, or template.
Definition: model_utils.cpp:983
UMLDragData::LvTypeAndID
Definition: umldragdata.h:67
UMLListViewItem
Items used by the class UMLListView.
Definition: umllistviewitem.h:38
UMLListViewItem::lvt_EntityRelationship_Diagram
Definition: umllistviewitem.h:79
entity.h
UMLObject::ot_EnumLiteral
Definition: umlobject.h:60
UMLListView::commitData
void commitData(QWidget *editor)
Definition: umllistview.cpp:3094
UMLPackage
This class contains the non-graphical information required for a UML Package.
Definition: package.h:32
UMLObject::ot_Component
Definition: umlobject.h:62
UMLEntity::createCheckConstraint
UMLCheckConstraint * createCheckConstraint(const QString &name=QString())
Creates a Check Constraint for this Entity.
Definition: entity.cpp:254
UMLListViewItem::lvt_CheckConstraint
Definition: umllistviewitem.h:88
ClassPropDlg::page_att
Definition: classpropdlg.h:44
UMLClassifierListItemList
This sub-class adds copyInto and clone to the QPtrList base class...
Definition: umlclassifierlistitemlist.h:26
UMLListViewItem::setOpen
void setOpen(bool state)
Overrides default method.
Definition: umllistviewitem.cpp:418
UMLListViewItem::saveToXMI
void saveToXMI(QDomDocument &qDoc, QDomElement &qElement)
Saves the listview item to a "listitem" tag.
Definition: umllistviewitem.cpp:866
UMLListView::slotDeleteSelectedItems
void slotDeleteSelectedItems()
Delete every selected item.
Definition: umllistview.cpp:2070
UMLClassifier
This class defines the non-graphical information required for a UML Classifier (ie a class or interfa...
Definition: classifier.h:39
IDChangeLog::findNewID
Uml::ID::Type findNewID(Uml::ID::Type OldID)
Returns the new assigned ID of the object that had OldID as its previous id.
Definition: idchangelog.cpp:62
UMLListViewItem::lvt_Package
Definition: umllistviewitem.h:63
UMLListView::slotItemSelectionChanged
void slotItemSelectionChanged()
Handler for item selection changed signals.
Definition: umllistview.cpp:145
UMLListView::createChildUMLObject
bool createChildUMLObject(UMLListViewItem *item, UMLObject::ObjectType type)
Creates a child UMLObject out of the given list view item.
Definition: umllistview.cpp:2356
UMLClassifierListItem::getType
UMLClassifier * getType() const
Returns the type of the UMLClassifierListItem.
Definition: classifierlistitem.cpp:100
UMLListViewItem::umlObject
UMLObject * umlObject() const
Return the UMLObject associated with this instance.
Definition: umllistviewitem.cpp:309
UMLListViewItem::lvt_EntityRelationship_Folder
Definition: umllistviewitem.h:80
umlattributedialog.h
UniqueID::gen
Uml::ID::Type gen()
MAIN FUNCTION: Return a new unique ID.
Definition: uniqueid.cpp:26
UMLListView::deleteChildrenOf
void deleteChildrenOf(UMLListViewItem *parent)
Deletes all child-items of parent.
Definition: umllistview.cpp:2984
UMLListView::slotObjectRemoved
void slotObjectRemoved(UMLObject *object)
Disconnects signals and removes the list view item.
Definition: umllistview.cpp:1046
umlentityattributedialog.h
Model_Utils::typeIsDiagram
bool typeIsDiagram(UMLListViewItem::ListViewType type)
Return true if the listview type is a diagram.
Definition: model_utils.cpp:1017
node.h
UMLClassifierListItem
Classifiers (classes, interfaces) have lists of operations, attributes, templates and others...
Definition: classifierlistitem.h:29
UMLListViewItem::updateFolder
void updateFolder()
Updates the icon on a folder.
Definition: umllistviewitem.cpp:404
Settings::optionState
OptionState & optionState()
Definition: optionstate.cpp:25
UMLForeignKeyConstraintDialog
A dialog page to display foreignkey constraint properties.
Definition: umlforeignkeyconstraintdialog.h:39
UMLAttribute::getInitialValue
QString getInitialValue() const
Returns The initial value of the UMLAttribute.
Definition: attribute.cpp:98
Uml::DiagramType::toString
QString toString(Enum item)
Convert DiagramType item into QString representation.
Definition: basictypes.cpp:158
Uml::Visibility::Enum
Enum
Definition: basictypes.h:56
UMLClassifierListItem::setType
virtual void setType(UMLObject *type)
Sets the type of the UMLAttribute.
Definition: classifierlistitem.cpp:125
UMLObject::ot_Role
Definition: umlobject.h:66
UMLAttribute::getParmKind
Uml::ParameterDirection::Enum getParmKind() const
Definition: attribute.cpp:121
UMLObject::visibility
Uml::Visibility::Enum visibility() const
Returns the visibility of the object.
Definition: umlobject.cpp:435
idchangelog.h
UMLDoc::setName
void setName(const QString &name)
Set the name of this model.
Definition: umldoc.cpp:1633
UMLScene::name
QString name() const
Return the name of the diagram.
Definition: umlscene.cpp:240
UMLEntity::createUniqueConstraint
UMLUniqueConstraint * createUniqueConstraint(const QString &name=QString())
Creates a Unique Constraint for this Entity.
Definition: entity.cpp:151
QTreeWidget
UMLApp::slotEditCut
void slotEditCut()
Put the marked text/object into the clipboard and remove it from the document.
Definition: uml.cpp:1441
ListPopupMenu::mt_Copy
Definition: listpopupmenu.h:162
Uml::DiagramType::Undefined
Definition: basictypes.h:76
UMLEntity::setAsPrimaryKey
bool setAsPrimaryKey(UMLUniqueConstraint *uconstr)
Sets the UniqueConstraint passed as the Primary Key of this Entity If the UniqueConstraint exists...
Definition: entity.cpp:510
UMLClassifier::getFilteredList
virtual UMLClassifierListItemList getFilteredList(UMLObject::ObjectType ot) const
Returns the entries in m_List that are of the requested type.
Definition: classifier.cpp:1019
UMLListView::saveToXMI
void saveToXMI(QDomDocument &qDoc, QDomElement &qElement)
Definition: umllistview.cpp:2630
UMLListViewItem::lvt_Datatype_Folder
Definition: umllistviewitem.h:75
Model_Utils::Parse_Status
Parse_Status
Definition: model_utils.h:91
umlview.h
UMLListViewItem::lvt_UseCase_Folder
Definition: umllistviewitem.h:49
category.h
UMLListViewItem::lvt_Interface
Definition: umllistviewitem.h:62
UMLObject::ot_Enum
Definition: umlobject.h:55
Model_Utils::OpDescriptor
Definition: model_utils.h:112
UMLClassifier::createAttribute
virtual UMLAttribute * createAttribute(const QString &name=QString(), UMLObject *type=0, Uml::Visibility::Enum vis=Uml::Visibility::Private, const QString &init=QString())
Creates an attribute for the class.
Definition: classifier.cpp:756
DocWindow::showDocumentation
void showDocumentation(UMLObject *object, bool overwrite=false)
Called when a widget wishes to display its documentation in the doc window.
Definition: docwindow.cpp:87
Uml::ModelType::Component
Definition: basictypes.h:41
UMLListViewItem::isOwnParent
bool isOwnParent(Uml::ID::Type listViewItemID)
Returns true if the UMLListViewItem of the given ID is a parent of this UMLListViewItem.
Definition: umllistviewitem.cpp:318
UMLComponent
This class contains the non-graphical information required for a UML Component.
Definition: component.h:27
UMLListView::slotDropped
void slotDropped(QDropEvent *de, UMLListViewItem *parent, UMLListViewItem *item)
Something has been dragged and dropped onto the list view.
Definition: umllistview.cpp:1798
UMLObject::setVisibility
void setVisibility(Uml::Visibility::Enum visibility)
Sets the visibility of the object.
Definition: umlobject.cpp:445
umlcheckconstraintdialog.h
UMLListViewItem::lvt_Subsystem
Definition: umllistviewitem.h:82
entityattribute.h
UMLListViewItem::lvt_Node
Definition: umllistviewitem.h:73
UMLObject::ot_UseCase
Definition: umlobject.h:51
IDChangeLog
This class contains all the ID translations done for each UMLObject pasted.
Definition: idchangelog.h:26
ListPopupMenu::mt_UseCase
Definition: listpopupmenu.h:89
umlscene.h
UMLListViewItem::lvt_Deployment_View
Definition: umllistviewitem.h:72
Model_Utils::parseConstraint
Parse_Status parseConstraint(QString m, QString &name, UMLEntity *owningScope)
Parses a constraint.
Definition: model_utils.cpp:863
UMLClassifier::createOperation
UMLOperation * createOperation(const QString &name=QString(), bool *isExistingOp=NULL, Model_Utils::NameAndType_List *params=NULL)
Creates an operation in the current document.
Definition: classifier.cpp:238
UMLScene::setType
void setType(Uml::DiagramType::Enum type)
Set the type of diagram.
Definition: umlscene.cpp:264
ListPopupMenu::mt_Paste
Definition: listpopupmenu.h:163
UMLListView::contextMenuEvent
void contextMenuEvent(QContextMenuEvent *me)
Definition: umllistview.cpp:1968
UMLListView::~UMLListView
~UMLListView()
Standard destructor.
Definition: umllistview.cpp:127
UMLApp::currentView
UMLView * currentView() const
Get the current view.
Definition: uml.cpp:2847
UMLDoc::writeToStatusBar
void writeToStatusBar(const QString &text)
Write text to the status bar.
Definition: umldoc.cpp:946
UMLView
UMLView instances represent diagrams.
Definition: umlview.h:32
UMLListViewItemIterator
QTreeWidgetItemIterator UMLListViewItemIterator
Definition: umllistviewitem.h:25
ListPopupMenu::mt_Operation
Definition: listpopupmenu.h:114
QWidget
ListPopupMenu::MenuType
MenuType
< This type hosts all possible menu types.
Definition: listpopupmenu.h:47
UMLApp::app
static UMLApp * app()
Get the last created instance of this class.
Definition: uml.cpp:206
UMLListViewItem::lvt_Unknown
Definition: umllistviewitem.h:90
Model_Utils::NameAndType_List
QLinkedList< NameAndType > NameAndType_List
Auxiliary type for OpDescriptor.
Definition: model_utils.h:109
UMLListView::findFolderForDiagram
UMLListViewItem * findFolderForDiagram(Uml::DiagramType::Enum dt)
Find the parent folder for a diagram.
Definition: umllistview.cpp:674
foreignkeyconstraint.h
ListPopupMenu::mt_Rename
Definition: listpopupmenu.h:157
umloperationdialog.h
UMLListViewItem::slotEditFinished
void slotEditFinished(const QString &newText)
This slot is called to finish item editing.
Definition: umllistviewitem.cpp:461
UMLAttribute
This class is used to set up information for an attribute.
Definition: attribute.h:27
UMLListViewItem::findUMLObject
UMLListViewItem * findUMLObject(const UMLObject *o)
Find the UMLListViewItem that is related to the given UMLObject in the tree rooted at the current UML...
Definition: umllistviewitem.cpp:812
UMLFolder::setFolderFile
void setFolderFile(const QString &fileName)
Set the folder file name for a separate submodel.
Definition: folder.cpp:245
UMLDoc::uniqueViewName
QString uniqueViewName(const Uml::DiagramType::Enum type)
Returns a name for the new object, appended with a number if the default name is taken e...
Definition: umldoc.cpp:1195
UMLListView::clean
void clean()
Remove all items and subfolders of the main folders.
Definition: umllistview.cpp:1284
UMLClassifier::setBaseType
void setBaseType(UMLObject::ObjectType ot)
Reimplementation of method from class UMLObject for controlling the exact type of this classifier: cl...
Definition: classifier.cpp:82
UMLListViewItem::lvt_Artifact
Definition: umllistviewitem.h:69
UMLAttributeList
This sub-class adds copyInto and clone to the QPtrList base class.
Definition: umlattributelist.h:26
DocWindow::updateDocumentation
void updateDocumentation(bool clear=false, bool startup=false)
Call when you wish move changes in the doc window back into the members documentation.
Definition: docwindow.cpp:205
UMLListViewItem::toolTip
QString toolTip()
Returns the signature of items that are operations.
Definition: umllistviewitem.cpp:200
UMLListViewItem::lvt_Collaboration_Diagram
Definition: umllistviewitem.h:51
UMLDoc::url
const KUrl & url() const
Returns the KUrl of the document.
Definition: umldoc.cpp:257
UMLCanvasObject
This class contains the non-graphical information required for UMLObjects which appear as moveable wi...
Definition: umlcanvasobject.h:33
UMLListView::createDiagram
UMLView * createDiagram(UMLListViewItem *item, Uml::DiagramType::Enum type)
Creates a diagram out of the given list view item.
Definition: umllistview.cpp:2491
Uml::DiagramType::Deployment
Definition: basictypes.h:84
UMLListViewItem::lvt_UseCase
Definition: umllistviewitem.h:57
UMLListView::dragEnterEvent
void dragEnterEvent(QDragEnterEvent *event)
Definition: umllistview.cpp:3059
UMLListView::addAtContainer
void addAtContainer(UMLListViewItem *item, UMLListViewItem *parent)
Auxiliary method for moveObject(): Adds the model object at the proper new container (package if nest...
Definition: umllistview.cpp:1514
UMLObject::ot_UniqueConstraint
Definition: umlobject.h:71
UMLListView::mouseDoubleClickEvent
void mouseDoubleClickEvent(QMouseEvent *me)
Event handler for mouse double click.
Definition: umllistview.cpp:1309
UMLAttributeDialog
Definition: umlattributedialog.h:28
UMLListView::selectedItemsRoot
UMLListViewItemList selectedItemsRoot()
Get selected items, but only root elements selected (without children).
Definition: umllistview.cpp:1844
UMLListView::mayHaveChildItems
static bool mayHaveChildItems(UMLObject::ObjectType type)
Return true if the given ObjectType permits child items.
Definition: umllistview.cpp:787
UMLListViewItem::lvt_Class_Diagram
Definition: umllistviewitem.h:52
UMLListView::childObjectRemoved
void childObjectRemoved(UMLClassifierListItem *obj)
Deletes the list view item.
Definition: umllistview.cpp:996
UMLListView::determineParentItem
UMLListViewItem * determineParentItem(UMLObject *object) const
Determine the parent ListViewItem given an UMLObject.
Definition: umllistview.cpp:730
UMLTemplate
This class holds information used by template classes, called paramaterised class in UML and a generi...
Definition: template.h:26
UMLListViewItem::lvt_Sequence_Diagram
Definition: umllistviewitem.h:55
Uml::DiagramType::Collaboration
Definition: basictypes.h:80
UMLObject::ot_Operation
Definition: umlobject.h:59
ListPopupMenu::mt_Template
Definition: listpopupmenu.h:115
UMLListViewItem::lvt_Template
Definition: umllistviewitem.h:61
UMLObject::ot_Template
Definition: umlobject.h:61
UMLListViewItem::lvt_Attribute
Definition: umllistviewitem.h:59
UMLListView::findUMLObjectInFolder
UMLListViewItem * findUMLObjectInFolder(UMLListViewItem *folder, UMLObject *obj)
This methods looks for a object in a folder an its subfolders recursive.
Definition: umllistview.cpp:1096
uWarning
#define uWarning()
Definition: debug_utils.h:97
UMLListView::init
void init()
Carries out initalisation of attributes in class.
Definition: umllistview.cpp:1247
UMLCategory::ct_Disjoint_Specialisation
Definition: category.h:33
UMLOperationDialog
Definition: umloperationdialog.h:37
UMLListViewItem::lvt_Actor
Definition: umllistviewitem.h:56
UMLListViewItem::lvt_ForeignKeyConstraint
Definition: umllistviewitem.h:87
UMLScene::setOptionState
void setOptionState(const Settings::OptionState &options)
Sets the options to be used.
Definition: umlscene.cpp:408
UMLScene::updateContainment
void updateContainment(UMLCanvasObject *self)
Refreshes containment association, i.e.
Definition: umlscene.cpp:2389
classifier.h
UMLScene::setID
void setID(Uml::ID::Type id)
Sets the ID of the diagram.
Definition: umlscene.cpp:280
UMLListViewItem::lvt_Enum
Definition: umllistviewitem.h:76
UMLDragData::getClip3TypeAndID
static bool getClip3TypeAndID(const QMimeData *mimeData, LvTypeAndID_List &typeAndIdList)
Return just the LvTypeAndID of a Clip3.
Definition: umldragdata.cpp:474
UMLListViewItem::deleteChildItem
void deleteChildItem(UMLClassifierListItem *child)
Deletes the child listview item representing the given UMLClassifierListItem.
Definition: umllistviewitem.cpp:247
UMLListView::dropEvent
void dropEvent(QDropEvent *event)
Definition: umllistview.cpp:3077
UMLListView::slotDiagramRenamed
void slotDiagramRenamed(Uml::ID::Type id)
Renames a diagram in the list view.
Definition: umllistview.cpp:1011
UMLFolder::localName
QString localName() const
Return the localized name of this folder.
Definition: folder.cpp:78
ListPopupMenu::mt_CheckConstraint
Definition: listpopupmenu.h:96
model_utils.h
UMLCheckConstraint
This class is used to set up information for a unique entity constraint.
Definition: checkconstraint.h:25
debug_utils.h
UMLOperation::toString
QString toString(Uml::SignatureType::Enum sig=Uml::SignatureType::NoSig)
Returns a string representation of the operation.
Definition: operation.cpp:198
Model_Utils::convert_MT_LVT
UMLListViewItem::ListViewType convert_MT_LVT(Uml::ModelType::Enum mt)
Return the ListViewType which corresponds to the given Model_Type.
Definition: model_utils.cpp:1071
UMLListView::expandAll
void expandAll(UMLListViewItem *item)
Open all items in the list view.
Definition: umllistview.cpp:2896
UMLForeignKeyConstraint
This class is used to set up information for a foreign key entity constraint.
Definition: foreignkeyconstraint.h:32
UMLListViewItem::ID
Uml::ID::Type ID() const
Returns the id this class represents.
Definition: umllistviewitem.cpp:268
ClassPropDlg::page_gen
Definition: classpropdlg.h:44
UMLObject
This class is the non-graphical version of UMLWidget.
Definition: umlobject.h:41
ListPopupMenu::mt_OverlappingSpecialisation
Definition: listpopupmenu.h:100
UMLDoc::loading
bool loading() const
Returns true when loading a document file.
Definition: umldoc.cpp:1241
UMLListView::uniqueDiagramName
QString uniqueDiagramName(Uml::DiagramType::Enum type)
Returns a unique name for a diagram.
Definition: umllistview.cpp:2524
UMLListView::focusOutEvent
void focusOutEvent(QFocusEvent *fe)
Event handler for lost focus.
Definition: umllistview.cpp:1956
UMLListViewItem::setUMLObject
void setUMLObject(UMLObject *obj)
Set the UMLObject associated with this instance.
Definition: umllistviewitem.cpp:299
UMLNode
This class contains the non-graphical information required for a UML Node.
Definition: node.h:26
UMLOperation::setType
void setType(UMLObject *type)
Reimplement method from UMLClassifierListItem.
Definition: operation.cpp:87
UMLDoc::datatypeFolder
UMLFolder * datatypeFolder() const
Returns the datatype folder.
Definition: umldoc.cpp:2451
docwindow.h
UMLListView::event
bool event(QEvent *e)
Event handler for the tool tip event.
Definition: umllistview.cpp:167
UMLClassifierListItem::toString
virtual QString toString(Uml::SignatureType::Enum sig=Uml::SignatureType::NoSig)
Returns a string representation of the list item.
Definition: classifierlistitem.cpp:89
UMLListView::slotDiagramRemoved
void slotDiagramRemoved(Uml::ID::Type id)
Removes the item representing a diagram.
Definition: umllistview.cpp:1061
ListPopupMenu::mt_EnumLiteral
Definition: listpopupmenu.h:92
UMLDoc::findView
UMLView * findView(Uml::ID::Type id)
Finds a view (diagram) by the ID given to method.
Definition: umldoc.cpp:733
UMLDoc::createDiagramName
QString createDiagramName(Uml::DiagramType::Enum type, bool askForName=true)
Creates the name of the given diagram type.
Definition: umldoc.cpp:1271
UMLListViewItem::lvt_Logical_Folder
Definition: umllistviewitem.h:48
UMLListView
This is one of the main classes used in this program.
Definition: umllistview.h:48
UMLScene::type
Uml::DiagramType::Enum type() const
Returns the type of the diagram.
Definition: umlscene.cpp:256
Uml::SignatureType::SigNoVis
Definition: basictypes.h:137
Uml::DiagramType::Sequence
Definition: basictypes.h:79
UMLListView::setStartedCopy
void setStartedCopy(bool startedCopy)
Set the variable m_bStartedCopy.
Definition: umllistview.cpp:2932
Uml::DiagramType::Activity
Definition: basictypes.h:82
Model_Utils::typeIsRootView
bool typeIsRootView(UMLListViewItem::ListViewType type)
Return true if the listview type is one of the predefined root views (root, logical, usecase, component, deployment, datatype, or entity- relationship view.)
Definition: model_utils.cpp:898
ListPopupMenu::mt_Actor
Definition: listpopupmenu.h:88
LayoutGenerator::generate
bool generate(UMLScene *scene, const QString &variant=QString())
generate layout and apply it to the given diagram.
Definition: layoutgenerator.h:156
UMLListViewItem::type
ListViewType type() const
Returns the type this instance represents.
Definition: umllistviewitem.cpp:231
Model_Utils::NameAndType::m_name
QString m_name
< Data structure filled by parseAttribute().
Definition: model_utils.h:97
ListPopupMenu::mt_Expand_All
Definition: listpopupmenu.h:208
UMLTemplateDialog
A dialog to edit the properties of a class template (paramaterised class)
Definition: umltemplatedialog.h:28
UMLListViewItem::lvt_Entity
Definition: umllistviewitem.h:77
UMLOperation::addParm
void addParm(UMLAttribute *parameter, int position=-1)
Add a parameter to the operation.
Definition: operation.cpp:259
UMLApp::docWindow
DocWindow * docWindow() const
Returns the doc window used.
Definition: uml.cpp:1673
listpopupmenu.h
UMLListView::addNewItem
void addNewItem(UMLListViewItem *parent, UMLListViewItem::ListViewType type)
Adds a new item to the tree of the given type under the given parent.
Definition: umllistview.cpp:2083
Model_Utils::uniqObjectName
QString uniqObjectName(UMLObject::ObjectType type, UMLPackage *parentPkg, QString prefix)
Returns a name for the new object, appended with a number if the default name is taken e...
Definition: model_utils.cpp:452
attribute.h
Uml::DiagramType::Component
Definition: basictypes.h:83
UMLListViewItem::lvt_EntityAttribute
Definition: umllistviewitem.h:78
ListPopupMenu::mt_EntityAttribute
Definition: listpopupmenu.h:91
enum.h
Uml::DiagramType::Enum
Enum
Definition: basictypes.h:73
ListPopupMenu::mt_Enum
Definition: listpopupmenu.h:85
ListPopupMenu::mt_Internalize_Folder
Definition: listpopupmenu.h:217
UMLCanvasObject::removeAllChildObjects
virtual void removeAllChildObjects()
Remove all child objects.
Definition: umlcanvasobject.cpp:166
UMLListViewItem::lvt_Deployment_Diagram
Definition: umllistviewitem.h:70
Model_Utils::typeIsCanvasWidget
bool typeIsCanvasWidget(UMLListViewItem::ListViewType type)
Return true if the listview type also has a widget representation in diagrams.
Definition: model_utils.cpp:918
Model_Utils::NameAndType::m_direction
Uml::ParameterDirection::Enum m_direction
Definition: model_utils.h:99
UMLObject::setUMLPackage
bool setUMLPackage(UMLPackage *pPkg)
Sets the UMLPackage in which this class is located.
Definition: umlobject.cpp:545
UMLListView::isUnique
bool isUnique(UMLListViewItem *item, const QString &name)
Returns if the given name is unique for the given items type.
Definition: umllistview.cpp:2532
ListPopupMenu::mt_Delete
Definition: listpopupmenu.h:158
UMLListView::acceptDrag
bool acceptDrag(QDropEvent *event) const
Event handler for accepting drag request.
Definition: umllistview.cpp:1369
UMLListView::closeDatatypesFolder
void closeDatatypesFolder()
Definition: umllistview.cpp:3000
UMLPackage::removeObject
void removeObject(UMLObject *pObject)
Removes an object from this package.
Definition: package.cpp:193
UMLListViewItem::lvt_UseCase_Diagram
Definition: umllistviewitem.h:50
UMLDoc::changeCurrentView
void changeCurrentView(Uml::ID::Type id)
Changes the current view (diagram) to the view with the given ID.
Definition: umldoc.cpp:1438
ListPopupMenu::mt_UseCase_Folder
Definition: listpopupmenu.h:74
UMLListView::slotCollapsed
void slotCollapsed(QTreeWidgetItem *item)
Calls updateFolder() on the item to update the icon to closed.
Definition: umllistview.cpp:2045
Model_Utils::typeIsContainer
bool typeIsContainer(UMLListViewItem::ListViewType type)
Return true if the listview type may act as a container for other objects, i.e.
Definition: model_utils.cpp:969
UMLObject::ot_Folder
Definition: umlobject.h:69
UMLListView::selectedItems
UMLListViewItemList selectedItems()
Get selected items.
Definition: umllistview.cpp:1824
template.h
umldragdata.h
UMLListView::slotCutSuccessful
void slotCutSuccessful()
Connects to the signal that UMLApp emits when a cut operation is successful.
Definition: umllistview.cpp:2057
UMLListView::createItem
bool createItem(UMLListViewItem *item)
Definition: umllistview.cpp:2166
UMLListViewItem::toString
static QString toString(ListViewType type)
Definition: umllistviewitem.cpp:939
uniqueconstraint.h
Uml::DiagramType::EntityRelationship
Definition: basictypes.h:85
UMLListViewItem::setID
void setID(Uml::ID::Type id)
Sets the id this class represents.
Definition: umllistviewitem.cpp:282
ListPopupMenu::mt_UniqueConstraint
Definition: listpopupmenu.h:93
UMLListViewItem::lvt_Operation
Definition: umllistviewitem.h:60
ListPopupMenu::convert_MT_DT
static Uml::DiagramType::Enum convert_MT_DT(MenuType mt)
Utility: Convert a MenuType value to a Diagram_Type value.
Definition: listpopupmenu.cpp:1152
UMLListView::rootView
UMLListViewItem * rootView(UMLListViewItem::ListViewType type)
Returns the corresponding view if the listview type is one of the root views, Root/Logical/UseCase/Co...
Definition: umllistview.cpp:2949
umlviewimageexporter.h
UMLObject::ot_CheckConstraint
Definition: umlobject.h:73
UMLListView::itemRenamed
bool itemRenamed(UMLListViewItem *item, int col)
Called for informing the list view that an item was renamed.
Definition: umllistview.cpp:2130
ListPopupMenu::mt_PrimaryKeyConstraint
Definition: listpopupmenu.h:94
DEBUG
#define DEBUG(src)
Definition: debug_utils.h:101
ListPopupMenu::mt_Cut
Definition: listpopupmenu.h:161
UMLDoc::removeUMLObject
void removeUMLObject(UMLObject *umlobject)
Removes an UMLObject from the current file.
Definition: umldoc.cpp:1527
UMLListViewItem::lvt_UniqueConstraint
Definition: umllistviewitem.h:85
UMLApp
The base class for UML application windows.
Definition: uml.h:81
ListPopupMenu::mt_Category
Definition: listpopupmenu.h:98
UMLCanvasObject::findChildObject
virtual UMLObject * findChildObject(const QString &n, UMLObject::ObjectType t=UMLObject::ot_UMLObject)
Find a child object with the given name.
Definition: umlcanvasobject.cpp:240
umllistviewitemlist.h
UMLDoc::addView
void addView(UMLView *view)
Adds a view to the document which represents the document contents.
Definition: umldoc.cpp:159
umltemplatedialog.h
Model_Utils::NameAndType::m_initialValue
QString m_initialValue
Definition: model_utils.h:100
UMLListView::findItem
UMLListViewItem * findItem(Uml::ID::Type id)
Searches through the tree for the item with the given ID.
Definition: umllistview.cpp:1232
UMLListViewItem::lvt_Component
Definition: umllistviewitem.h:67
UMLObject::ot_Category
Definition: umlobject.h:74
ListPopupMenu::mt_Component_Folder
Definition: listpopupmenu.h:75
UMLObject::ot_Entity
Definition: umlobject.h:67
UMLFolder
This class manages the UMLObjects and UMLViews of a Folder.
Definition: folder.h:34
ListPopupMenu::mt_Artifact
Definition: listpopupmenu.h:83
Uml::ModelType::UseCase
Definition: basictypes.h:40
UMLListView::getDragData
UMLDragData * getDragData()
Definition: umllistview.cpp:1071
ListPopupMenu::mt_Component
Definition: listpopupmenu.h:81
UMLListView::loadFromXMI
bool loadFromXMI(QDomElement &element)
Definition: umllistview.cpp:2640
UMLDoc::setModified
void setModified(bool modified=true)
Sets the modified flag for the document after a modifying action on the view connected to the documen...
Definition: umldoc.cpp:2607
UMLEnumLiteral
This class is used to set up information for an enum literal.
Definition: enumliteral.h:25
UMLScene::activate
void activate()
Activate all the objects and associations after a load from the clipboard.
Definition: umlscene.cpp:1779
UMLDragData::LvTypeAndID_It
QListIterator< LvTypeAndID * > LvTypeAndID_It
Definition: umldragdata.h:72
usecase.h
Model_Utils::convert_LVT_IT
Icon_Utils::IconType convert_LVT_IT(UMLListViewItem::ListViewType lvt)
Return the IconType which corresponds to the given listview type.
Definition: model_utils.cpp:1428
UMLScene::folder
UMLFolder * folder() const
Return the UMLFolder in which this diagram lives.
Definition: umlscene.cpp:177
UMLObject::ot_ForeignKeyConstraint
Definition: umlobject.h:72
Model_Utils::NameAndType
Definition: model_utils.h:96
UMLListView::createUMLObject
UMLObject * createUMLObject(UMLListViewItem *item, UMLObject::ObjectType type)
Creates a UMLObject out of the given list view item.
Definition: umllistview.cpp:2269
Uml::DiagramType::State
Definition: basictypes.h:81
Model_Utils::OpDescriptor::m_name
QString m_name
< Data structure filled by parseOperation().
Definition: model_utils.h:113
ListPopupMenu::mt_Node
Definition: listpopupmenu.h:82
UMLCheckConstraintDialog
A dialog page to display check constraint properties.
Definition: umlcheckconstraintdialog.h:30
ListPopupMenu::mt_Logical_Folder
Definition: listpopupmenu.h:73
UMLListViewItem::lvt_Logical_View
Definition: umllistviewitem.h:46
UMLListView::startedCopy
bool startedCopy() const
Return the variable m_bStartedCopy.
Definition: umllistview.cpp:2940
UMLListViewItem::lvt_Component_View
Definition: umllistviewitem.h:66
QTreeWidgetItem
ListPopupMenu::mt_ForeignKeyConstraint
Definition: listpopupmenu.h:95
Uml::DiagramType::UseCase
Definition: basictypes.h:78
enumliteral.h
checkconstraint.h
Uml::ID::Type
std::string Type
Definition: basictypes.h:317
UMLClassifier::findChildObjectById
virtual UMLObject * findChildObjectById(Uml::ID::Type id, bool considerAncestors=false)
Find the child object by the given id.
Definition: classifier.cpp:553
Model_Utils::psText
QString psText(Parse_Status value)
Returns the Parse_Status as a text.
Definition: model_utils.cpp:883
Model_Utils::convert_LVT_OT
UMLObject::ObjectType convert_LVT_OT(UMLListViewItem::ListViewType lvt)
Converts a list view type enum to the equivalent object type.
Definition: model_utils.cpp:1324
Model_Utils::convert_LVT_MT
Uml::ModelType::Enum convert_LVT_MT(UMLListViewItem::ListViewType lvt)
Return the Model_Type which corresponds to the given ListViewType.
Definition: model_utils.cpp:1101
UMLListView::collapseAll
void collapseAll(UMLListViewItem *item)
Close all items in the list view.
Definition: umllistview.cpp:2908
UMLCategory::ct_Union
Definition: category.h:35
Model_Utils::parseOperation
Parse_Status parseOperation(QString m, OpDescriptor &desc, UMLClassifier *owningScope)
Parses an operation given in UML syntax.
Definition: model_utils.cpp:793
UMLListView::moveObject
UMLListViewItem * moveObject(Uml::ID::Type srcId, UMLListViewItem::ListViewType srcType, UMLListViewItem *newParent)
Moves an object given is unique ID and listview type to an other listview parent item.
Definition: umllistview.cpp:1543
folder.h
UMLObject::ot_Attribute
Definition: umlobject.h:58
ListPopupMenu::mt_Deployment_Folder
Definition: listpopupmenu.h:76
UniqueID::get
Uml::ID::Type get()
Return the last generated unique ID without generating a new one.
Definition: uniqueid.cpp:45
UMLObject::baseType
ObjectType baseType() const
Returns the type of the object.
Definition: umlobject.cpp:366
Uml::ModelType::fromInt
Enum fromInt(int item)
Convert a integer item into ModelType representation.
Definition: basictypes.cpp:80
UMLEntityConstraint
This class is used to set up information for a entity constraint.
Definition: entityconstraint.h:26
UMLListViewItem::lvt_View
Definition: umllistviewitem.h:45
umluniqueconstraintdialog.h
UMLEnum
This class contains the non-graphical information required for a UML Enum.
Definition: enum.h:28
LayoutGenerator::apply
bool apply(UMLScene *scene)
apply auto layout to the given scene
Definition: layoutgenerator.h:229
UMLObject::ot_Interface
Definition: umlobject.h:53
UMLListView::slotMenuSelection
void slotMenuSelection(QAction *action)
Called when a right mouse button menu has an item selected.
Definition: umllistview.cpp:295
UMLTemplate::toString
QString toString(Uml::SignatureType::Enum sig=Uml::SignatureType::NoSig)
Returns a string representation of the list item.
Definition: template.cpp:54
actor.h
UMLObject::ot_Actor
Definition: umlobject.h:50
UMLListViewItem::lvt_Datatype
Definition: umllistviewitem.h:74
Uml::ID::toString
QString toString(const ID::Type &id)
Definition: basictypes.cpp:1048
UMLCategory::setType
void setType(Category_Type type)
Set the category type.
Definition: category.cpp:95
UMLDoc::findObjectById
UMLObject * findObjectById(Uml::ID::Type id)
Used to find a reference to a UMLObject by its ID.
Definition: umldoc.cpp:766
UMLDragData::LvTypeAndID::id
Uml::ID::Type id
Definition: umldragdata.h:69
UMLPackage::addObject
bool addObject(UMLObject *pObject)
Adds an object in this package.
Definition: package.cpp:130
layoutgenerator.h
UMLObject::ot_Artifact
Definition: umlobject.h:63
ListPopupMenu::mt_Entity
Definition: listpopupmenu.h:86
UMLObject::ot_Association
Definition: umlobject.h:57
Model_Utils::parseAttribute
Parse_Status parseAttribute(QString a, NameAndType &nmTp, UMLClassifier *owningScope, Uml::Visibility::Enum *vis)
Parses an attribute given in UML syntax.
Definition: model_utils.cpp:718
ListPopupMenu::mt_Package
Definition: listpopupmenu.h:79
UMLArtifact
This class contains the non-graphical information required for a UML Artifact.
Definition: artifact.h:27
operation.h
UMLListView::slotDiagramCreated
void slotDiagramCreated(Uml::ID::Type id)
Creates a new item to represent a new diagram.
Definition: umllistview.cpp:705
umldoc.h
UMLView::umlScene
UMLScene * umlScene() const
Getter for the scene.
Definition: umlview.cpp:58
UMLUniqueConstraintDialog
A dialog page to display unique constraint properties.
Definition: umluniqueconstraintdialog.h:36
UMLDragData::LvTypeAndID::type
UMLListViewItem::ListViewType type
Definition: umldragdata.h:68
UMLListView::connectNewObjectsSlots
void connectNewObjectsSlots(UMLObject *object)
Connect some signals into slots in the list view for newly created UMLObjects.
Definition: umllistview.cpp:858
ListPopupMenu::mt_Union
Definition: listpopupmenu.h:101
UMLObject::umlPackage
UMLPackage * umlPackage()
Returns the UMLPackage that this class is located in.
Definition: umlobject.cpp:641
UMLListView::document
UMLDoc * document() const
Returns the document pointer.
Definition: umllistview.cpp:1947
UMLListView::dragMoveEvent
void dragMoveEvent(QDragMoveEvent *event)
Definition: umllistview.cpp:3068
Model_Utils::parseTemplate
Parse_Status parseTemplate(QString t, NameAndType &nmTp, UMLClassifier *owningScope)
Parses a template parameter given in UML syntax.
Definition: model_utils.cpp:678
UMLOperation
This class represents an operation in the UML model.
Definition: operation.h:24
UMLObject::ObjectType
ObjectType
Definition: umlobject.h:47
UMLUniqueConstraint
This class is used to set up information for a unique entity constraint.
Definition: uniqueconstraint.h:28
UMLEntityAttribute
This class is used to set up information for an entityattribute.
Definition: entityattribute.h:25
Uml::DiagramType::Class
Definition: basictypes.h:77
Uml::ModelType::N_MODELTYPES
Definition: basictypes.h:44
UMLDoc::createDiagram
UMLView * createDiagram(UMLFolder *folder, Uml::DiagramType::Enum type, const QString &name)
Creates a diagram of the given type.
Definition: umldoc.cpp:1310
UMLObject::ot_Class
Definition: umlobject.h:56
UMLListViewItem::lvt_EntityRelationship_Model
Definition: umllistviewitem.h:81
ListPopupMenu::mt_Properties
Definition: listpopupmenu.h:156
UMLListView::deleteItem
bool deleteItem(UMLListViewItem *temp)
Delete a listview item.
Definition: umllistview.cpp:3010
UMLListView::slotObjectChanged
void slotObjectChanged()
Calls updateObject() on the item representing the sending object no parameters, uses sender() to work...
Definition: umllistview.cpp:935
ListPopupMenu::mt_Subsystem
Definition: listpopupmenu.h:80
UMLObjectList
This sub-class adds copyInto and clone to the QList base class.
Definition: umlobjectlist.h:26
package.h
UMLScene::clearSelected
void clearSelected()
Clear the selected widgets list.
Definition: umlscene.cpp:1291
UMLListViewItem::lvt_Deployment_Folder
Definition: umllistviewitem.h:71
UMLListView::findView
UMLListViewItem * findView(UMLView *v)
Searches through the tree for the item which represents the diagram given.
Definition: umllistview.cpp:1166
ListPopupMenu::mt_Attribute
Definition: listpopupmenu.h:90
UMLCategory
This class contains the non-graphical information required for a UML Category.
Definition: category.h:28
UMLListViewItem::lvt_State_Diagram
Definition: umllistviewitem.h:53
UMLClassifier::createTemplate
UMLObject * createTemplate(const QString &name=QString())
Create and add a just created template.
Definition: classifier.cpp:387
UMLDoc::removeDiagram
void removeDiagram(Uml::ID::Type id)
Deletes a diagram from the current file.
Definition: umldoc.cpp:1463
UMLObject::ot_UMLObject
Definition: umlobject.h:49
UMLListViewItem::updateObject
void updateObject()
Updates the representation of the object.
Definition: umllistviewitem.cpp:336
UMLListViewItem::lvt_Category
Definition: umllistviewitem.h:89
UMLListView::setView
void setView(UMLView *view)
Set the current view to the given view.
Definition: umllistview.cpp:1297
ListPopupMenu::mt_Interface
Definition: listpopupmenu.h:84
UMLListViewItem::lvt_EnumLiteral
Definition: umllistviewitem.h:84
UMLFolder::folderFile
QString folderFile() const
Get the folder file name for a separate submodel.
Definition: folder.cpp:253
Model_Utils::OpDescriptor::m_args
NameAndType_List m_args
Definition: model_utils.h:114
UMLListView::isExpandable
static bool isExpandable(UMLListViewItem::ListViewType lvt)
Return true if the given list view type can be expanded/collapsed.
Definition: umllistview.cpp:2015
UMLEnumLiteral::showPropertiesDialog
bool showPropertiesDialog(QWidget *parent)
Display the properties configuration dialog for the enum literal.
Definition: enumliteral.cpp:101
Model_Utils::NameAndType::m_type
UMLObject * m_type
Definition: model_utils.h:98
ListPopupMenu
A popup menu that depending on what type is set to will display a different menu. ...
Definition: listpopupmenu.h:40
UMLUseCase
This class contains the non-graphical information required for a UML UseCase.
Definition: usecase.h:24
UMLListViewItem::addClassifierListItem
void addClassifierListItem(UMLClassifierListItem *child, UMLListViewItem *childItem)
Adds the child listview item representing the given UMLClassifierListItem.
Definition: umllistviewitem.cpp:239
Uml::ModelType::Logical
Definition: basictypes.h:39
UMLListViewItem::lvt_PrimaryKeyConstraint
Definition: umllistviewitem.h:86
UMLListViewItem::findItem
UMLListViewItem * findItem(Uml::ID::Type id)
Find the UMLListViewItem of the given ID in the tree rooted at the current UMLListViewItem.
Definition: umllistviewitem.cpp:848
UMLListView::findUMLObject
UMLListViewItem * findUMLObject(const UMLObject *p) const
Find an UMLObject in the listview.
Definition: umllistview.cpp:1140
UMLListView::changeIconOf
void changeIconOf(UMLObject *o, Icon_Utils::IconType to)
Changes the icon for the given UMLObject to the given icon.
Definition: umllistview.cpp:1154
ListPopupMenu::mt_Model
Definition: listpopupmenu.h:49
UMLListViewItem::findChildObject
UMLListViewItem * findChildObject(UMLClassifierListItem *cli)
Find the UMLListViewItem that represents the given UMLClassifierListItem in the children of the curre...
Definition: umllistviewitem.cpp:831
UMLListViewItem::lvt_Class
Definition: umllistviewitem.h:58
ListPopupMenu::mt_EntityRelationship_Folder
Definition: listpopupmenu.h:77
umllistview.h
Model_Utils::OpDescriptor::m_pReturnType
UMLObject * m_pReturnType
Definition: model_utils.h:115
ClassPropDlg::page_constraint
Definition: classpropdlg.h:44
uError
#define uError()
Definition: debug_utils.h:96
classpropdlg.h
UMLListView::mouseMoveEvent
void mouseMoveEvent(QMouseEvent *me)
Handler for mouse move events.
Definition: umllistview.cpp:230
DEBUG_REGISTER
#define DEBUG_REGISTER(src)
Definition: debug_utils.h:102
component.h
UMLPackage::findObject
UMLObject * findObject(const QString &name)
Find the object of the given name in the list of contained objects.
Definition: package.cpp:241
Model_Utils::convert_DT_LVT
UMLListViewItem::ListViewType convert_DT_LVT(Uml::DiagramType::Enum dt)
Convert a diagram type enum to the equivalent list view type.
Definition: model_utils.cpp:1129
ListPopupMenu::mt_Collapse_All
Definition: listpopupmenu.h:209
UMLObject::name
QString name() const
Returns a copy of m_name.
Definition: umlobject.cpp:185
UMLActor
This class contains the non-graphical information required for a UML Actor.
Definition: actor.h:27
ListPopupMenu::mt_Export_Image
Definition: listpopupmenu.h:159
UMLListView::slotExpanded
void slotExpanded(QTreeWidgetItem *item)
Calls updateFolder() on the item to update the icon to open.
Definition: umllistview.cpp:2034
uniqueid.h
UMLListView::setSelected
void setSelected(UMLListViewItem *item, bool state)
Definition: umllistview.h:98
UMLObject::ot_Stereotype
Definition: umlobject.h:65
Model_Utils::convert_LVT_DT
Uml::DiagramType::Enum convert_LVT_DT(UMLListViewItem::ListViewType lvt)
Return the DiagramType which corresponds to the given listview type.
Definition: model_utils.cpp:1562
UMLListViewItem::lvt_Component_Folder
Definition: umllistviewitem.h:65
UMLListViewItem::lvt_Activity_Diagram
Definition: umllistviewitem.h:54
ListPopupMenu::mt_Datatype
Definition: listpopupmenu.h:87
ClassPropDlg::page_entatt
Definition: classpropdlg.h:44
umllistviewitem.h
UMLCategory::ct_Overlapping_Specialisation
Definition: category.h:34
UMLListViewItem::setIcon
void setIcon(Icon_Utils::IconType iconType)
Set the pixmap corresponding to the given IconType.
Definition: umllistviewitem.cpp:452
UMLListView::setTitle
void setTitle(int column, const QString &text)
Sets the title.
Definition: umllistview.cpp:137
UMLCanvasObject::uniqChildName
virtual QString uniqChildName(const UMLObject::ObjectType type, const QString &prefix=QString())
Returns a name for the new association, operation, template or attribute appended with a number if th...
Definition: umlcanvasobject.cpp:185
UMLObject::ot_Package
Definition: umlobject.h:52
ListPopupMenu::mt_Externalize_Folder
Definition: listpopupmenu.h:216
UMLListViewItem::ListViewType
ListViewType
Definition: umllistviewitem.h:41
ListPopupMenu::typeFromAction
static MenuType typeFromAction(QAction *action)
Convenience method to extract the ListPopupMenu type from an action.
Definition: listpopupmenu.cpp:1122
UMLView::showPropDialog
bool showPropDialog()
Shows the properties dialog for the view.
Definition: umlview.cpp:101
UMLListView::selectedItemsCount
int selectedItemsCount()
Return the amount of items selected.
Definition: umllistview.cpp:1938
UMLDragData
This class provides encoding and decoding for the uml data that will be used in a drag and drop opera...
Definition: umldragdata.h:36
Icon_Utils::IconType
IconType
Definition: icon_utils.h:38
Uml::ModelType::Enum
Enum
Definition: basictypes.h:38
Uml::ID::fromString
ID::Type fromString(const QString &id)
Definition: basictypes.cpp:1053
UMLEnum::createEnumLiteral
UMLObject * createEnumLiteral(const QString &name=QString())
Creates a literal for the enum.
Definition: enum.cpp:85
LayoutGenerator
The class LayoutGenerator provides calculated layouts of diagrams.
Definition: layoutgenerator.h:89
UMLDoc::changeLog
virtual IDChangeLog * changeLog()
Read property of IDChangeLog* m_pChangeLog.
Definition: umldoc.cpp:2707
Model_Utils::guessContainer
Uml::ModelType::Enum guessContainer(UMLObject *o)
Try to guess the correct container folder type of an UMLObject.
Definition: model_utils.cpp:572
UMLListView::mouseReleaseEvent
void mouseReleaseEvent(QMouseEvent *me)
Handler for mouse release event.
Definition: umllistview.cpp:252
QEvent
UMLApp::slotEditCopy
void slotEditCopy()
Put the marked text/object into the clipboard.
Definition: uml.cpp:1464
UMLListViewItemList
QList< UMLListViewItem * > UMLListViewItemList
Definition: umllistviewitemlist.h:24
UMLClassifier::takeItem
int takeItem(UMLClassifierListItem *item)
Take and return a subordinate item from this classifier.
Definition: classifier.cpp:1186
UMLDoc::name
QString name() const
Return the name of this model.
Definition: umldoc.cpp:1641
UMLListView::slotObjectCreated
void slotObjectCreated(UMLObject *object)
Creates a new list view item and connects the appropriate signals/slots.
Definition: umllistview.cpp:807
UMLAttribute::toString
QString toString(Uml::SignatureType::Enum sig=Uml::SignatureType::NoSig)
Returns a string representation of the UMLAttribute.
Definition: attribute.cpp:132
Model_Utils::convert_OT_LVT
UMLListViewItem::ListViewType convert_OT_LVT(UMLObject *o)
Convert an object's type to the equivalent list view type.
Definition: model_utils.cpp:1186
Uml::ID::None
const Type None
special value for uninitialized ID
Definition: basictypes.h:319
UMLDoc::findUMLObject
UMLObject * findUMLObject(const QString &name, UMLObject::ObjectType type=UMLObject::ot_UMLObject, UMLObject *currentObj=0)
Used to find a UMLObject by its type and name.
Definition: umldoc.cpp:809
operator<<
QDebug operator<<(QDebug out, const UMLListView &view)
Overloading operator for debugging output.
Definition: umllistview.cpp:3136
UMLEntity::createForeignKeyConstraint
UMLForeignKeyConstraint * createForeignKeyConstraint(const QString &name=QString())
Creates a Foreign Key Constraint for this Entity.
Definition: entity.cpp:205
Uml::ModelType::Deployment
Definition: basictypes.h:42
umlforeignkeyconstraintdialog.h
ListPopupMenu::mt_DisjointSpecialisation
Definition: listpopupmenu.h:99
UMLObject::setStereotype
void setStereotype(const QString &_name)
Sets the classes stereotype name.
Definition: umlobject.cpp:494
UMLListViewItem::setVisible
void setVisible(bool state)
Definition: umllistviewitem.cpp:258
UMLObject::ot_Datatype
Definition: umlobject.h:54
UMLPackage::containedObjects
UMLObjectList containedObjects()
Returns the list of objects contained in this package.
Definition: package.cpp:230
UMLApp::slotEditPaste
void slotEditPaste()
Paste the clipboard into the document.
Definition: uml.cpp:1476
ClassPropDlg::page_op
Definition: classpropdlg.h:44
UMLListView::mousePressEvent
void mousePressEvent(QMouseEvent *me)
Handler for mouse press events.
Definition: umllistview.cpp:187
artifact.h
UMLObject::ot_EntityAttribute
Definition: umlobject.h:68
UMLScene::setName
void setName(const QString &name)
Set the name of the diagram.
Definition: umlscene.cpp:248
UMLScene
UMLScene instances represent diagrams.
Definition: umlscene.h:70
UMLListView::setDocument
void setDocument(UMLDoc *doc)
Sets the document his is associated with.
Definition: umllistview.cpp:1028
UMLListView::rootViewType
UMLListViewItem::ListViewType rootViewType(UMLListViewItem *item)
Determines the root listview type of the given UMLListViewItem.
Definition: umllistview.cpp:1992
UMLEntity
This class contains the non-graphical information required for a UML Entity.
Definition: entity.h:34
UMLAttribute::setParmKind
void setParmKind(Uml::ParameterDirection::Enum pk)
Definition: attribute.cpp:116
UMLListView::loadChildrenFromXMI
bool loadChildrenFromXMI(UMLListViewItem *parent, QDomElement &element)
Definition: umllistview.cpp:2667
uml.h
UMLObject::ot_Node
Definition: umlobject.h:64
QList
UMLDoc::rootFolder
UMLFolder * rootFolder(Uml::ModelType::Enum mt)
Return the predefined root folder of the given type.
Definition: umldoc.cpp:2676
DBG_SRC
#define DBG_SRC
Definition: import_utils.cpp:42
UMLOperation::getParmList
UMLAttributeList getParmList() const
Returns a list of parameters.
Definition: operation.cpp:171
UMLListView::createDiagramItem
UMLListViewItem * createDiagramItem(UMLView *view)
Create a listview item for an existing diagram.
Definition: umllistview.cpp:1870
Model_Utils::typeIsFolder
bool typeIsFolder(UMLListViewItem::ListViewType type)
Return true if the listview type is a logical, usecase or component folder.
Definition: model_utils.cpp:950
UMLListView::childObjectAdded
void childObjectAdded(UMLClassifierListItem *child, UMLClassifier *parent)
Adds a new operation, attribute or template item to a classifier, identical to childObjectAdded(obj) ...
Definition: umllistview.cpp:963
UMLListView::keyPressEvent
void keyPressEvent(QKeyEvent *ke)
Handler for key press events.
Definition: umllistview.cpp:276
UMLScene::ID
Uml::ID::Type ID() const
Returns the ID of the diagram.
Definition: umlscene.cpp:272
UMLListViewItem::lvt_Component_Diagram
Definition: umllistviewitem.h:64
UMLDoc
UMLDoc provides a document object for a document-view model.
Definition: umldoc.h:63
UMLObject::id
virtual Uml::ID::Type id() const
Returns the ID of the object.
Definition: umlobject.cpp:394
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:06:00 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

umbrello/umbrello

Skip menu "umbrello/umbrello"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdesdk API Reference

Skip menu "kdesdk API Reference"
  • kapptemplate
  • kcachegrind
  • kompare
  • lokalize
  • okteta
  • umbrello
  •   umbrello

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal