umbrello API Documentation

widget_utils.cpp

00001 /***************************************************************************
00002  *                                                                         *
00003  *   This program is free software; you can redistribute it and/or modify  *
00004  *   it under the terms of the GNU General Public License as published by  *
00005  *   the Free Software Foundation; either version 2 of the License, or     *
00006  *   (at your option) any later version.                                   *
00007  *                                                                         *
00008  *   copyright (C) 2004-2006                                               *
00009  *   Umbrello UML Modeller Authors <uml-devel@uml.sf.net>                  *
00010  ***************************************************************************/
00011 
00012 // own header
00013 #include "widget_utils.h"
00014 
00015 // qt/kde includes
00016 #include <qcanvas.h>
00017 #include <qbrush.h>
00018 #include <qpen.h>
00019 #include <kiconloader.h>
00020 #include <kdebug.h>
00021 
00022 // app includes
00023 #include "uml.h"
00024 #include "umlview.h"
00025 #include "umlwidget.h"
00026 #include "objectwidget.h"
00027 
00028 namespace Widget_Utils {
00029 
00030 UMLWidget* findWidget(Uml::IDType id,
00031                       const UMLWidgetList& widgets,
00032                       const MessageWidgetList* pMessages /* = NULL */)
00033 {
00034     UMLWidgetListIt it( widgets );
00035     UMLWidget * obj = NULL;
00036     while ( (obj = it.current()) != NULL ) {
00037         ++it;
00038         if (obj->getBaseType() == Uml::wt_Object) {
00039             if (static_cast<ObjectWidget *>(obj)->getLocalID() == id)
00040                 return obj;
00041         } else if (obj->getID() == id) {
00042             return obj;
00043         }
00044     }
00045 
00046     if (pMessages == NULL)
00047         return NULL;
00048 
00049     MessageWidgetListIt mit( *pMessages );
00050     while ( (obj = (UMLWidget*)mit.current()) != NULL ) {
00051         ++mit;
00052         if( obj -> getID() == id )
00053             return obj;
00054     }
00055     return NULL;
00056 }
00057 
00058 QIconSet iconSet(Uml::Diagram_Type dt) {
00059     QIconSet diagramIconSet;
00060     switch (dt) {
00061     case Uml::dt_UseCase:
00062         diagramIconSet = BarIconSet("umbrello_diagram_usecase");
00063         break;
00064     case Uml::dt_Collaboration:
00065         diagramIconSet = BarIconSet("umbrello_diagram_collaboration");
00066         break;
00067     case Uml::dt_Class:
00068         diagramIconSet = BarIconSet("umbrello_diagram_class");
00069         break;
00070     case Uml::dt_Sequence:
00071         diagramIconSet = BarIconSet("umbrello_diagram_sequence");
00072         break;
00073     case Uml::dt_State:
00074         diagramIconSet = BarIconSet("umbrello_diagram_state");
00075         break;
00076     case Uml::dt_Activity:
00077         diagramIconSet = BarIconSet("umbrello_diagram_activity");
00078         break;
00079     case Uml::dt_Component:
00080         diagramIconSet = BarIconSet("umbrello_diagram_component");
00081         break;
00082     case Uml::dt_Deployment:
00083         diagramIconSet = BarIconSet("umbrello_diagram_deployment");
00084         break;
00085     case Uml::dt_EntityRelationship:
00086         diagramIconSet = BarIconSet("umbrello_diagram_entityrelationship");
00087         break;
00088     default:
00089         kDebug() << "Widget_Utils::iconSet: unknown diagram type " << dt << endl;
00090         diagramIconSet = BarIconSet("unknown");
00091     }
00092     return diagramIconSet;
00093 }
00094 
00095 QCanvasRectangle *decoratePoint(QPoint p) {
00096     const int SIZE = 4;
00097     UMLView *currentView = UMLApp::app()->getCurrentView();
00098     QCanvasRectangle *rect;
00099     rect = new QCanvasRectangle(p.x() - SIZE / 2,
00100                                 p.y() - SIZE / 2,
00101                                 SIZE, SIZE, currentView->canvas());
00102     rect->setBrush( QBrush(Qt::blue) );
00103     rect->setPen( QPen(Qt::blue) );
00104     rect->setVisible(true);
00105     return rect;
00106 }
00107 
00108 
00109 }  // namespace Widget_Utils
00110 
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:08:03 2007 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003