umbrello API Documentation

refactoringassistant.cpp

00001 /***************************************************************************
00002     copyright            : (C) 2003 Luis De la Parra
00003  ***************************************************************************/
00004 /***************************************************************************
00005  *                                                                         *
00006  *   This program is free software; you can redistribute it and/or modify  *
00007  *   it under the terms of the GNU General Public License as published by  *
00008  *   the Free Software Foundation; either version 2 of the License, or     *
00009  *   (at your option) any later version.                                   *
00010  *                                                                         *
00011  *   copyright (C) 2004-2007                                               *
00012  *   Umbrello UML Modeller Authors <uml-devel@uml.sf.net>                  *
00013  ***************************************************************************/
00014 
00015 #include "refactoringassistant.h"
00016 
00017 #include "../umlnamespace.h"
00018 #include "../umldoc.h"
00019 #include "../classifier.h"
00020 #include "../attribute.h"
00021 #include "../operation.h"
00022 #include "../dialogs/classpropdlg.h"
00023 #include "../dialogs/umloperationdialog.h"
00024 #include "../dialogs/umlattributedialog.h"
00025 #include "../object_factory.h"
00026 
00027 #include <qpoint.h>
00028 #include <qpopupmenu.h>
00029 
00030 #include <typeinfo>
00031 #include <kstandarddirs.h>
00032 #include <kiconloader.h>
00033 #include <klocale.h>
00034 #include <kmessagebox.h>
00035 #include <kdebug.h>
00036 
00037 using std::type_info;
00038 
00039 
00040 RefactoringAssistant::RefactoringAssistant( UMLDoc *doc, UMLClassifier *obj, QWidget *parent, const char *name ):
00041         KListView( parent, name ), m_doc( doc )
00042 {
00043     loadPixmaps();
00044 
00045     setRootIsDecorated( true );
00046     setAcceptDrops( true );
00047     setDropVisualizer( false );
00048     setItemsMovable( true );
00049     setSelectionModeExt( Single );
00050     setShowToolTips( true );
00051     setTooltipColumn( 0 );
00052     setDragEnabled( true );
00053     setDropHighlighter( true );
00054     setFullWidth( true );
00055     setSorting( -1 );
00056 
00057     addColumn("Name ");
00058 
00059     m_menu = new QPopupMenu(this);
00060 
00061     connect(this,SIGNAL(doubleClicked(QListViewItem*)),this,SLOT(itemExecuted(QListViewItem*)));
00062     connect(this,SIGNAL(contextMenu(KListView*, QListViewItem*, const QPoint&)),
00063             this,SLOT(showContextMenu(KListView*,QListViewItem*,const QPoint&)));
00064 
00065     resize(300,400);
00066 
00067     refactor( obj );
00068 }
00069 
00070 RefactoringAssistant::~RefactoringAssistant()
00071 {
00072     m_umlObjectMap.clear();
00073     clear();
00074 }
00075 
00076 void RefactoringAssistant::refactor( UMLClassifier *obj )
00077 {
00078     clear();
00079     m_umlObjectMap.clear();
00080     m_umlObject = obj;
00081     if (! m_umlObject )
00082     {
00083         return;
00084     }
00085 
00086     addClassifier( obj, 0, true, true, true );
00087     QListViewItem *item = firstChild();
00088     item->setOpen(true);
00089     for( item = item->firstChild(); item ; item = item->nextSibling() )
00090         item->setOpen(true);
00091 }
00092 
00093 
00094 UMLObject* RefactoringAssistant::findUMLObject( const QListViewItem *item )
00095 {
00096     QListViewItem *i = const_cast<QListViewItem*>(item);
00097     if( m_umlObjectMap.find(i) == m_umlObjectMap.end() )
00098     {
00099         kWarning()<<"RefactoringAssistant::findUMLObject( QListViewItem *item )"
00100         <<"item with text "<<item->text(0)<<"not found in uml map!"<<endl;
00101         return 0L;
00102     }
00103     return m_umlObjectMap[i];
00104 
00105 }
00106 
00107 QListViewItem* RefactoringAssistant::findListViewItem( const UMLObject *obj )
00108 {
00109     UMLObjectMap::iterator end(m_umlObjectMap.end());
00110     for( UMLObjectMap::iterator it(m_umlObjectMap.begin()) ; it != end ; ++it )
00111         if( (*it).second == obj )
00112             return (*it).first;
00113     kWarning() << "RefactoringAssistant::findListViewItem:"
00114     << "object id " << ID2STR(obj->getID())
00115     << "does not have a ListItem" << endl;
00116     return 0L;
00117 }
00118 
00119 
00120 void RefactoringAssistant::itemExecuted( QListViewItem *item )
00121 {
00122     UMLObject *o = findUMLObject( item );
00123     if(o) editProperties( );
00124 }
00125 
00126 void RefactoringAssistant::setVisibilityIcon( QListViewItem *item , const UMLObject *obj )
00127 {
00128     switch(obj->getVisibility())
00129     {
00130       case Uml::Visibility::Public:
00131         item->setPixmap(0,m_pixmaps.Public);
00132         break;
00133       case Uml::Visibility::Protected:
00134         item->setPixmap(0,m_pixmaps.Protected);
00135         break;
00136       case Uml::Visibility::Private:
00137         item->setPixmap(0,m_pixmaps.Private);
00138         break;
00139       case Uml::Visibility::Implementation:
00140         item->setPixmap(0,m_pixmaps.Implementation);
00141         break;
00142         break;
00143     }
00144 }
00145 
00146 void RefactoringAssistant::umlObjectModified( const UMLObject *obj )
00147 {
00148     if( !obj )
00149         obj = dynamic_cast<const UMLObject*>(sender());
00150     QListViewItem *item = findListViewItem( obj );
00151     if( !item )
00152         return;
00153     item->setText( 0, obj->getName() );
00154     if( typeid(*obj) == typeid(UMLOperation) ||
00155             typeid(*obj) == typeid(UMLAttribute) )
00156     {
00157         setVisibilityIcon( item, obj );
00158     }
00159 }
00160 
00161 void RefactoringAssistant::operationAdded( UMLClassifierListItem *o )
00162 {
00163     UMLOperation *op = static_cast<UMLOperation*>(o);
00164     UMLClassifier *c = dynamic_cast<UMLClassifier*>(op->parent());
00165     if(!c)
00166     {
00167         kWarning() << "RefactoringAssistant::operationAdded(" << op->getName()
00168             << ") - Parent of operation is not a classifier!" << endl;
00169         return;
00170     }
00171     QListViewItem *item = findListViewItem( c );
00172     if( !item )
00173     {
00174         return;
00175     }
00176     for( QListViewItem *folder = item->firstChild(); folder; folder = folder->nextSibling() )
00177     {
00178         if( folder->text(1) == "operations" )
00179         {
00180             item = new KListViewItem( folder, op->getName() );
00181             m_umlObjectMap[item] = op;
00182             connect( op, SIGNAL( modified() ), this, SLOT( umlObjectModified() ) );
00183             setVisibilityIcon( item, op );
00184             break;
00185         }
00186     }
00187 }
00188 
00189 void RefactoringAssistant::operationRemoved( UMLClassifierListItem *o )
00190 {
00191     UMLOperation *op = static_cast<UMLOperation*>(o);
00192     QListViewItem *item = findListViewItem( op );
00193     if( !item )
00194     {
00195         return;
00196     }
00197     disconnect( op, SIGNAL( modified() ), this, SLOT( umlObjectModified() ) );
00198     m_umlObjectMap.erase(item);
00199     delete item;
00200 }
00201 
00202 
00203 void RefactoringAssistant::attributeAdded( UMLClassifierListItem *a )
00204 {
00205     UMLAttribute *att = static_cast<UMLAttribute*>(a);
00206     UMLClassifier *c = dynamic_cast<UMLClassifier*>(att->parent());
00207     if(!c)
00208     {
00209         kWarning() << "RefactoringAssistant::attributeAdded(" << att->getName()
00210             << ") - Parent is not a class!" << endl;
00211         return;
00212     }
00213     QListViewItem *item = findListViewItem( c );
00214     if( !item )
00215     {
00216         return;
00217     }
00218     for( QListViewItem *folder = item->firstChild(); folder; folder = folder->nextSibling() )
00219     {
00220         if( folder->text(1) == "attributes" )
00221         {
00222             item = new KListViewItem( folder, att->getName() );
00223             m_umlObjectMap[item] = att;
00224             connect( att, SIGNAL( modified() ), this, SLOT( umlObjectModified() ) );
00225             setVisibilityIcon( item, att );
00226             break;
00227         }
00228     }
00229 }
00230 
00231 void RefactoringAssistant::attributeRemoved( UMLClassifierListItem *a )
00232 {
00233     UMLAttribute *att = static_cast<UMLAttribute*>(a);
00234     QListViewItem *item = findListViewItem( att );
00235     if( !item )
00236     {
00237         return;
00238     }
00239     disconnect( att, SIGNAL( modified() ), this, SLOT( umlObjectModified() ) );
00240     m_umlObjectMap.erase(item);
00241     delete item;
00242 }
00243 
00244 void RefactoringAssistant::editProperties( )
00245 {
00246     QListViewItem *item = selectedItem();
00247     if( item )
00248     {
00249         UMLObject *o = findUMLObject( item );
00250         if( o ) editProperties( o );
00251     }
00252 }
00253 
00254 void RefactoringAssistant::editProperties( UMLObject *obj )
00255 {
00256     KDialogBase *dia(0);
00257     Uml::Object_Type t = obj->getBaseType();
00258     if (t == Uml::ot_Class || t == Uml::ot_Interface)
00259     {
00260         dia = new ClassPropDlg(this,obj,0,true);
00261     }
00262     else if (t == Uml::ot_Operation)
00263     {
00264         dia = new UMLOperationDialog(this,static_cast<UMLOperation*>(obj));
00265     }
00266     else if (t == Uml::ot_Attribute)
00267     {
00268         dia = new UMLAttributeDialog(this,static_cast<UMLAttribute*>(obj));
00269     }
00270     else
00271     {
00272         kWarning()<<"RefactoringAssistant::editProperties( UMLObject *o ) caled for unknown type "<<typeid(*obj).name()<<endl;
00273         return;
00274     }
00275     if( dia && dia->exec() )
00276     {
00277         // need to update something?
00278     }
00279     delete dia;
00280 }
00281 
00282 void RefactoringAssistant::showContextMenu(KListView* ,QListViewItem *item, const QPoint &p)
00283 {
00284     m_menu->clear();
00285     UMLObject *obj = findUMLObject( item );
00286     if(obj)
00287     {// Menu for UMLObjects
00288         Uml::Object_Type t = obj->getBaseType();
00289         if (t == Uml::ot_Class)
00290         {
00291             m_menu->insertItem(i18n("Add Base Class"),this,SLOT(addBaseClassifier()));
00292             m_menu->insertItem(i18n("Add Derived Class"),this,SLOT(addDerivedClassifier()));
00293             //          m_menu->insertItem(i18n("Add Interface Implementation"),this,SLOT(addInterfaceImplementation()));
00294             m_menu->insertItem(i18n("Add Operation"),this,SLOT(createOperation()));
00295             m_menu->insertItem(i18n("Add Attribute"),this,SLOT(createAttribute()));
00296         }
00297         else if (t == Uml::ot_Interface)
00298         {
00299             m_menu->insertItem(i18n("Add Base Interface"),this,SLOT(addSuperClassifier()));
00300             m_menu->insertItem(i18n("Add Derived Interface"),this,SLOT(addDerivedClassifier()));
00301             m_menu->insertItem(i18n("Add Operation"),this,SLOT(createOperation()));
00302         }
00303         //              else
00304         //              {
00305         //              kDebug()<<"No context menu for objects of type "<<typeid(*obj).name()<<endl;
00306         //              return;
00307         //              }
00308         m_menu->insertSeparator();
00309         m_menu->insertItem(i18n("Properties"),this,SLOT(editProperties()));
00310     }
00311     else
00312     {//menu for other ViewItems
00313         if( item->text(1) == "operations" )
00314         {
00315             m_menu->insertItem(i18n("Add Operation"),this,SLOT(createOperation()));
00316         }
00317         else if( item->text(1) == "attributes" )
00318         {
00319             m_menu->insertItem(i18n("Add Attribute"),this,SLOT(createAttribute()));
00320         }
00321         else
00322         {
00323             kWarning()<<"RefactoringAssistant::showContextMenu() "
00324             <<"called for extraneous item"<<endl;
00325             return;
00326         }
00327     }
00328     m_menu->exec(p);
00329 }
00330 
00331 void RefactoringAssistant::addBaseClassifier()
00332 {
00333     QListViewItem *item = selectedItem();
00334     if(!item)
00335     {
00336         kWarning()<<"RefactoringAssistant::addBaseClassifier() "
00337         <<"called with no item selected"<<endl;
00338         return;
00339     }
00340     UMLObject *obj = findUMLObject( item );
00341     if( !dynamic_cast<UMLClassifier*>(obj) )
00342     {
00343         kWarning()<<"RefactoringAssistant::addBaseClassifier() "
00344         <<"called for a non-classifier object"<<endl;
00345         return;
00346     }
00347 
00348     //classes have classes and interfaces interfaces as super/derived classifiers
00349     Uml::Object_Type t = obj->getBaseType();
00350     UMLClassifier *super = static_cast<UMLClassifier*>(Object_Factory::createUMLObject(t));
00351     if(!super)
00352         return;
00353     m_doc->createUMLAssociation( obj, super, Uml::at_Generalization );
00356     QListViewItem *baseFolder = item->firstChild();
00357     while( baseFolder->text(0) != i18n("Base Classifiers") )
00358         baseFolder = baseFolder->nextSibling();
00359     if(!baseFolder)
00360     {
00361         kWarning()<<"Cannot find Base Folder"<<endl;
00362         return;
00363     }
00364     item = new KListViewItem( baseFolder, super->getName() );
00365     item->setPixmap(0,m_pixmaps.Generalization);
00366     item->setExpandable( true );
00367     m_umlObjectMap[item] = super;
00368     addClassifier( super, item, true, false, true);
00370 }
00371 
00372 void RefactoringAssistant::addDerivedClassifier()
00373 {
00374     QListViewItem *item = selectedItem();
00375     if(!item)
00376     {
00377         kWarning()<<"RefactoringAssistant::addDerivedClassifier() "
00378         <<"called with no item selected"<<endl;
00379         return;
00380     }
00381     UMLObject *obj = findUMLObject( item );
00382     if( !dynamic_cast<UMLClassifier*>(obj) )
00383     {
00384         kWarning()<<"RefactoringAssistant::addDerivedClassifier() "
00385         <<"called for a non-classifier object"<<endl;
00386         return;
00387     }
00388 
00389     //classes have classes and interfaces interfaces as super/derived classifiers
00390     Uml::Object_Type t = obj->getBaseType();
00391     UMLClassifier *derived = static_cast<UMLClassifier*>(Object_Factory::createUMLObject(t));
00392     if(!derived)
00393         return;
00394     m_doc->createUMLAssociation( derived, obj, Uml::at_Generalization );
00395 
00398     QListViewItem *derivedFolder = item->firstChild();
00399     while( derivedFolder->text(0) != i18n("Derived Classifiers") )
00400         derivedFolder = derivedFolder->nextSibling();
00401     if(!derivedFolder)
00402     {
00403         kWarning()<<"Cannot find Derived Folder"<<endl;
00404         return;
00405     }
00406     item = new KListViewItem( derivedFolder, derived->getName() );
00407     item->setPixmap(0,m_pixmaps.Subclass);
00408     item->setExpandable( true );
00409     m_umlObjectMap[item] = derived;
00410     addClassifier( derived, item, false, true, true);
00412 }
00413 
00414 void RefactoringAssistant::addInterfaceImplementation()
00415 {
00416     kWarning()<<"RefactoringAssistant::addInterfaceImplementation()"
00417     <<"not implemented... finish addSuperClassifier() first!!"<<endl;
00418     return;
00419     //  QListViewItem *item = selectedListViewItem( );
00420     //  UMLObject *obj = findUMLObject( item );
00421     //  if( !dynamic_cast<UMLClassifier*>(obj) )
00422     //          return;
00423     //  UMLObject *n = Object_Factory::createUMLObject( Uml::ot_Interface) );
00424     //  if(!n)
00425     //          return;
00426     //  m_doc->createUMLAssociation( n, obj, Uml::at_Realization );
00427     //  //refresh, add classifier to assistant
00428 }
00429 
00430 void RefactoringAssistant::createOperation()
00431 {
00432     QListViewItem *item = selectedItem();
00433     if(!item)
00434     {
00435         kWarning()<<"RefactoringAssistant::createOperation() "
00436         <<"called with no item selected"<<endl;
00437         return;
00438     }
00439     UMLClassifier *c = dynamic_cast<UMLClassifier*>(findUMLObject( item ));
00440     if( !c )
00441         return;
00442     c->createOperation();
00443 }
00444 
00445 void RefactoringAssistant::createAttribute()
00446 {
00447     QListViewItem *item = selectedItem();
00448     if(!item)
00449     {
00450         kWarning()<<"RefactoringAssistant::createAttribute() "
00451         <<"called with no item selected"<<endl;
00452         return;
00453     }
00454     UMLClassifier *c = dynamic_cast<UMLClassifier*>(findUMLObject( item ));
00455     if( !c )
00456         return;
00457     c->createAttribute();
00458 }
00459 
00460 
00461 void RefactoringAssistant::addClassifier( UMLClassifier *classifier, QListViewItem *parent, bool addSuper, bool addSub, bool recurse)
00462 {
00463     QListViewItem *classifierItem, *item;
00464     if( parent )
00465     {
00466         classifierItem = parent;
00467     }
00468     else
00469     {
00470         classifierItem= new KListViewItem( this, classifier->getName() );
00471         m_umlObjectMap[classifierItem] = classifier;
00472     }
00473 
00474     connect( classifier, SIGNAL( modified() ), this, SLOT( umlObjectModified() ) );
00475 
00476     UMLClassifier *klass = dynamic_cast<UMLClassifier*>(classifier);
00477     if( klass )
00478     {// only Classes have attributes...
00479         connect( classifier, SIGNAL(attributeAdded(UMLClassifierListItem*)),
00480                  this, SLOT(attributeAdded(UMLClassifierListItem*)));
00481         connect( classifier, SIGNAL(attributeRemoved(UMLClassifierListItem*)),
00482                  this, SLOT(attributeRemoved(UMLClassifierListItem*)));
00483 
00484         QListViewItem *attsFolder = new KListViewItem( classifierItem, i18n("Attributes"), "attributes" );
00485         attsFolder->setPixmap(0,SmallIcon("folder_green_open"));
00486         attsFolder->setExpandable( true );
00487         UMLAttributeList atts = klass->getAttributeList();
00488         for( UMLAttribute *att = atts.first(); att; att = atts.next() )
00489         {
00490             attributeAdded( att );
00491         }
00492 
00493     }
00494 
00495     // add operations
00496     connect( classifier, SIGNAL(operationAdded(UMLClassifierListItem*)),
00497              this, SLOT(operationAdded(UMLClassifierListItem*)));
00498     connect( classifier, SIGNAL(operationRemoved(UMLClassifierListItem*)),
00499              this, SLOT(operationRemoved(UMLClassifierListItem*)));
00500 
00501     QListViewItem *opsFolder = new KListViewItem( classifierItem, i18n("Operations"), "operations" );
00502     opsFolder->setPixmap(0,SmallIcon("folder_blue_open"));
00503     opsFolder->setExpandable( true );
00504     UMLOperationList ops(classifier->getOpList());
00505     for( UMLOperation *op = ops.first(); op ; op = ops.next() )
00506     {
00507         operationAdded( op );
00508     }
00509 
00510     //if add parents
00511     if(addSuper)
00512     {
00513         QListViewItem *superFolder = new KListViewItem( classifierItem, i18n("Base Classifiers") );
00514         superFolder->setExpandable( true );
00515         UMLClassifierList super = classifier->findSuperClassConcepts();
00516         for( UMLClassifier *cl = super.first(); cl ; cl = super.next() )
00517         {
00518             item = new KListViewItem( superFolder, cl->getName() );
00519             item->setPixmap(0,m_pixmaps.Generalization);
00520             item->setExpandable( true );
00521             m_umlObjectMap[item] = cl;
00522             if( recurse )
00523             {
00524                 addClassifier( cl, item, true, false, true);
00525             }
00526 
00527         }
00528     }
00529     if(addSub)
00530     {
00531         //add derived classifiers
00532         QListViewItem *derivedFolder = new KListViewItem( classifierItem, i18n("Derived Classifiers") );
00533         derivedFolder->setExpandable( true );
00534         UMLClassifierList derived = classifier->findSubClassConcepts();
00535         for( UMLClassifier *d = derived.first(); d ; d = derived.next() )
00536         {
00537             item = new KListViewItem( derivedFolder, d->getName() );
00538             item->setPixmap(0,m_pixmaps.Subclass);
00539             item->setExpandable( true );
00540             m_umlObjectMap[item] = d;
00541             if( recurse )
00542             {
00543                 addClassifier( d, item, false, true, true);
00544             }
00545 
00546         }
00547     }
00548 }
00549 
00550 
00551 bool RefactoringAssistant::acceptDrag(QDropEvent *event) const
00552 {
00553     //first check if we can accept drops at all, and if the operation
00554     // is a move within the list itself
00555     if( !acceptDrops() || !itemsMovable() || (event->source()!=viewport()))
00556     {
00557         return false;
00558     }
00559 
00560     RefactoringAssistant *me = const_cast<RefactoringAssistant*>(this);
00561 
00562     //ok, check if the move is valid
00563     QListViewItem *movingItem = 0, *afterme = 0, *parentItem = 0;
00564     me->findDrop(event->pos(), parentItem, afterme);
00565     for( movingItem = firstChild(); movingItem != 0; movingItem = movingItem->itemBelow() )
00566     {
00567         if( movingItem->isSelected() )
00568             break;
00569     }
00570     if(!movingItem || !parentItem)
00571     {   kDebug()<<"moving/parent items not found - can't accept drag!"<<endl;
00572         return false;
00573     }
00574 
00575     UMLObject *movingObject;
00576     if( !(movingObject = me->findUMLObject(movingItem)) )
00577     {
00578         kDebug()<<"Moving object not found in uml map!"<<movingItem->text(0)<<endl;
00579         return false;
00580     }
00581     Uml::Object_Type t = movingObject->getBaseType();
00582     if (t != Uml::ot_Attribute && t != Uml::ot_Operation)
00583     {
00584         kDebug()<<"only operations and attributes are movable! - return false"<<endl;
00585         return false;
00586     }
00587 
00588     kDebug()<<"parent item is "<<parentItem->text(0)<<endl;
00589     UMLObject *parentObject = me->findUMLObject(parentItem);
00590     if( parentObject && dynamic_cast<UMLClassifier*>(parentObject) )
00591     {
00592         //droping to a classifier, ok
00593     }
00594     else
00595     {//parent is not a classifier, so maybe  it's a folder.. check types
00596         if( (parentItem->text(1) == "operations" && t == Uml::ot_Operation)
00597                 || (parentItem->text(1) == "attributes" && t == Uml::ot_Attribute))
00598         {
00599             parentObject = me->findUMLObject( parentItem->parent() );
00600         }
00601         else
00602         {
00603             kDebug()<<"moving to item "<<parentItem->text(0)<<" -- "<<parentItem->text(1)<<" not valid"<<endl;
00604             return false;
00605         }
00606     }
00607     if (dynamic_cast<UMLClassifier*>(parentObject) &&
00608             (t == Uml::ot_Attribute || t == Uml::ot_Operation))
00609     {
00610         return true;
00611     }
00612 
00613     kDebug()<<"how did I get here? return false!!"<<endl;
00614     return false;
00615 }
00616 
00617 
00618 void RefactoringAssistant::movableDropEvent (QListViewItem* parentItem, QListViewItem* afterme)
00619 {
00620     //when dropping on a class, we have to put the item in the appropriate folder!
00621     UMLObject *movingObject;
00622     UMLClassifier *newClassifier;
00623     QListViewItem *movingItem;
00624 
00625     for( movingItem = firstChild(); movingItem != 0; movingItem = movingItem->itemBelow() )
00626     {
00627         if( movingItem->isSelected() )
00628             break;
00629     }
00630     if( !movingItem || (movingItem == afterme) || !(movingObject = findUMLObject(movingItem)) )
00631     {
00632         kWarning()<<"Moving item not found or dropping after itself or item not found in uml obj map. aborting. (drop had already been accepted)"<<endl;
00633         return;
00634     }
00635     Uml::Object_Type t = movingObject->getBaseType();
00636     newClassifier = dynamic_cast<UMLClassifier*>( findUMLObject( parentItem ) );
00637     if(!newClassifier)
00638     {
00639         if ((parentItem->text(1) == "operations" && t == Uml::ot_Operation)
00640                 || (parentItem->text(1) == "attributes" && t == Uml::ot_Attribute))
00641         {
00642             newClassifier = dynamic_cast<UMLClassifier*>( findUMLObject( parentItem->parent() ) );
00643         }
00644         if(!newClassifier)
00645         {
00646             kWarning()<<"New parent of object is not a Classifier - Drop had already been accepted - check!"<<endl;
00647             return;
00648         }
00649     }
00650     if (t == Uml::ot_Operation)
00651     {kDebug()<<"moving operation"<<endl;
00652         UMLOperation *op = static_cast<UMLOperation*>(movingObject);
00653         if(newClassifier->checkOperationSignature(op->getName(), op->getParmList()))
00654         {
00655             QString msg = QString(i18n("An operation with that signature already exists in %1.\n")).arg(newClassifier->getName())
00656                           +
00657                           QString(i18n("Choose a different name or parameter list." ));
00658             KMessageBox::error(this, msg, i18n("Operation Name Invalid"), false);
00659             return;
00660         }
00661         UMLClassifier *oldClassifier = dynamic_cast<UMLClassifier*>(op->parent());
00662         if(oldClassifier)
00663             oldClassifier->removeOperation( op );
00664         newClassifier->addOperation( op );
00665     }
00666     else if (t == Uml::ot_Attribute)
00667     {kDebug()<<"moving attribute - not implemented"<<endl;
00668         //              UMLAttribute *att = static_cast<UMLAttribute*>(movingObject);
00669         //              if(!newClassifier->checkAttributeSignature(att))
00670         //              {
00671         //                      QString msg = QString(i18n("An attribute with that signature already exists in %1.\n")).arg(newClassifier->getName())
00672         //                              +
00673         //                            QString(i18n("Choose a different name or parameter list." ));
00674         //                      KMessageBox::error(this, msg, i18n("Operation Name Invalid"), false);
00675         //                      return;
00676         //              }
00677         //              oldClassifier->removeAttribute( att );
00678         //              newClassifier->addAttribute( att );
00679     }
00680     //emit moved(moving, afterFirst, afterme);
00681     emit moved();
00682 }
00683 
00684 void RefactoringAssistant::loadPixmaps()
00685 {
00686     KStandardDirs *dirs = KGlobal::dirs();
00687     QString dataDir = dirs -> findResourceDir( "data", "umbrello/pics/object.png" );
00688     dataDir += "/umbrello/pics/";
00689 
00690     m_pixmaps.Public.load( dataDir + "CVpublic_var.png" );
00691     m_pixmaps.Protected.load( dataDir + "CVprotected_var.png" );
00692     m_pixmaps.Private.load( dataDir + "CVprivate_var.png" );
00693     m_pixmaps.Implementation.load( dataDir + "CVimplementation_var.png" );
00694     m_pixmaps.Generalization.load( dataDir + "generalisation.png" );
00695     m_pixmaps.Subclass.load( dataDir + "uniassociation.png" );
00696 
00697 
00698 }
00699 
00700 
00701 
00702 
00703 #include "refactoringassistant.moc"
KDE Logo
This file is part of the documentation for umbrello Version 3.1.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Jun 26 08:07:59 2007 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003