From 94258a77f48a82bb083c1d4c20003a7936a333c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sl=C3=A1vek=20Banko?= Date: Tue, 26 Feb 2013 17:52:52 +0100 Subject: Fix unintended rename of worktoolbar --- umbrello/umbrello/CMakeLists.txt | 2 +- umbrello/umbrello/Makefile.am | 2 +- umbrello/umbrello/activitywidget.h | 2 +- umbrello/umbrello/statewidget.h | 2 +- umbrello/umbrello/toolbarstatearrow.h | 2 +- umbrello/umbrello/toolbarstatefactory.h | 2 +- umbrello/umbrello/toolbarstatepool.h | 2 +- umbrello/umbrello/uml.cpp | 2 +- umbrello/umbrello/umlview.h | 2 +- umbrello/umbrello/worktoolbar.cpp | 315 ++++++++++++++++++++++++++++++++ umbrello/umbrello/worktoolbar.h | 184 +++++++++++++++++++ umbrello/umbrello/wortdetoolbar.cpp | 315 -------------------------------- umbrello/umbrello/wortdetoolbar.h | 184 ------------------- umbrello/uml.kdevprj | 6 +- 14 files changed, 511 insertions(+), 511 deletions(-) create mode 100644 umbrello/umbrello/worktoolbar.cpp create mode 100644 umbrello/umbrello/worktoolbar.h delete mode 100644 umbrello/umbrello/wortdetoolbar.cpp delete mode 100644 umbrello/umbrello/wortdetoolbar.h (limited to 'umbrello') diff --git a/umbrello/umbrello/CMakeLists.txt b/umbrello/umbrello/CMakeLists.txt index 5080dcc2..7329dec6 100644 --- a/umbrello/umbrello/CMakeLists.txt +++ b/umbrello/umbrello/CMakeLists.txt @@ -77,7 +77,7 @@ tde_add_executable( umbrello AUTOMOC umlviewimageexporter.cpp umlviewimageexporterall.cpp umlviewimageexportermodel.cpp umlwidget.cpp umlwidgetcontroller.cpp uniqueid.cpp usecase.cpp usecasewidget.cpp widgetbase.cpp - widget_factory.cpp widget_utils.cpp wortdetoolbar.cpp + widget_factory.cpp widget_utils.cpp worktoolbar.cpp LINK refactoring-static codeimport-static kdevcppparser-static clipboard-static codegenerator-static docgenerators-static dialogs-static diff --git a/umbrello/umbrello/Makefile.am b/umbrello/umbrello/Makefile.am index 25d90fe9..b19ecb18 100644 --- a/umbrello/umbrello/Makefile.am +++ b/umbrello/umbrello/Makefile.am @@ -111,7 +111,7 @@ usecasewidget.cpp \ widgetbase.cpp \ widget_factory.cpp \ widget_utils.cpp \ -wortdetoolbar.cpp +worktoolbar.cpp #umbrello_LDADD = ./refactoring/librefactoring.la ./codeimport/libcodeimport.la ./codeimport/kdevcppparser/libkdevcppparser.la ./clipboard/libclipboard.la ./dialogs/libdialogs.la ./codegenerators/libcodegenerator.la $(AUTOLAYOUT_LIBS) $(LIB_TDEPRINT) $(LIB_KIO) umbrello_LDADD = ./refactoring/librefactoring.la ./codeimport/libcodeimport.la ./codeimport/kdevcppparser/libkdevcppparser.la ./clipboard/libclipboard.la ./dialogs/libdialogs.la ./codegenerators/libcodegenerator.la ./docgenerators/libdocgenerators.la $(LIB_TDEPRINT) $(LIB_KIO) diff --git a/umbrello/umbrello/activitywidget.h b/umbrello/umbrello/activitywidget.h index 68b1384e..f34b7df9 100644 --- a/umbrello/umbrello/activitywidget.h +++ b/umbrello/umbrello/activitywidget.h @@ -13,7 +13,7 @@ #define ACTIVITYWIDGET_H #include "umlwidget.h" -#include "wortdetoolbar.h" +#include "worktoolbar.h" #define ACTIVITY_MARGIN 5 #define ACTIVITY_WIDTH 30 diff --git a/umbrello/umbrello/statewidget.h b/umbrello/umbrello/statewidget.h index 5aec4396..f4a8008a 100644 --- a/umbrello/umbrello/statewidget.h +++ b/umbrello/umbrello/statewidget.h @@ -14,7 +14,7 @@ #include #include #include "umlwidget.h" -#include "wortdetoolbar.h" +#include "worktoolbar.h" #define STATE_MARGIN 5 #define STATE_WIDTH 30 diff --git a/umbrello/umbrello/toolbarstatearrow.h b/umbrello/umbrello/toolbarstatearrow.h index 43938573..89597211 100644 --- a/umbrello/umbrello/toolbarstatearrow.h +++ b/umbrello/umbrello/toolbarstatearrow.h @@ -15,7 +15,7 @@ #include "toolbarstate.h" -#include "wortdetoolbar.h" +#include "worktoolbar.h" class TQMouseEvent; class UMLView; diff --git a/umbrello/umbrello/toolbarstatefactory.h b/umbrello/umbrello/toolbarstatefactory.h index 2f7eb058..b5c1ee4c 100644 --- a/umbrello/umbrello/toolbarstatefactory.h +++ b/umbrello/umbrello/toolbarstatefactory.h @@ -14,7 +14,7 @@ #include "toolbarstate.h" -#include "wortdetoolbar.h" +#include "worktoolbar.h" #define NR_OF_TOOLBAR_STATES 4 diff --git a/umbrello/umbrello/toolbarstatepool.h b/umbrello/umbrello/toolbarstatepool.h index d7629a49..9989d98e 100644 --- a/umbrello/umbrello/toolbarstatepool.h +++ b/umbrello/umbrello/toolbarstatepool.h @@ -14,7 +14,7 @@ #include "toolbarstate.h" -#include "wortdetoolbar.h" +#include "worktoolbar.h" /** * Base class for tools that can use the same state but with different button. diff --git a/umbrello/umbrello/uml.cpp b/umbrello/umbrello/uml.cpp index a472cbff..7b491208 100644 --- a/umbrello/umbrello/uml.cpp +++ b/umbrello/umbrello/uml.cpp @@ -53,7 +53,7 @@ #include "umldoc.h" #include "umllistview.h" #include "umlviewlist.h" -#include "wortdetoolbar.h" +#include "worktoolbar.h" #ifdef HAVE_DOT # include "autotqlayout/autolayoutdlg.h" //dimitri #endif diff --git a/umbrello/umbrello/umlview.h b/umbrello/umbrello/umlview.h index 856f4e49..805c28af 100644 --- a/umbrello/umbrello/umlview.h +++ b/umbrello/umbrello/umlview.h @@ -27,7 +27,7 @@ #include "associationwidgetlist.h" #include "messagewidgetlist.h" #include "optionstate.h" -#include "wortdetoolbar.h" +#include "worktoolbar.h" // forward declarations class ClassOptionsPage; diff --git a/umbrello/umbrello/worktoolbar.cpp b/umbrello/umbrello/worktoolbar.cpp new file mode 100644 index 00000000..f1af2dbd --- /dev/null +++ b/umbrello/umbrello/worktoolbar.cpp @@ -0,0 +1,315 @@ +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * copyright (C) 2002-2007 * + * Umbrello UML Modeller Authors * + ***************************************************************************/ + +// own header +#include "worktoolbar.h" + +// qt/kde include files +#include +#include +#include +#include +#include + +// application specific includes +#include "uml.h" +#include "umldoc.h" +#include "umlview.h" +#include "worktoolbar.h" + + +WorkToolBar::WorkToolBar(TQMainWindow *parentWindow, const char*name) + : TDEToolBar(parentWindow,TQt::DockRight,false,name) { + m_CurrentButtonID = tbb_Undefined; + loadPixmaps(); + m_Type = Uml::dt_Class; /* first time in just want it to load arrow, + needs anything but dt_Undefined */ + setOrientation( Qt::Vertical ); + setVerticalStretchable( true ); + // initialize old tool map, everything starts with select tool (arrow) + m_map.insert(Uml::dt_UseCase,tbb_Arrow); + m_map.insert(Uml::dt_Collaboration,tbb_Arrow); + m_map.insert(Uml::dt_Class,tbb_Arrow); + m_map.insert(Uml::dt_Sequence,tbb_Arrow); + m_map.insert(Uml::dt_State,tbb_Arrow); + m_map.insert(Uml::dt_Activity,tbb_Arrow); + m_map.insert(Uml::dt_Undefined,tbb_Arrow); + + slotCheckToolBar( Uml::dt_Undefined ); + connect( this, TQT_SIGNAL( released( int ) ), this, TQT_SLOT( buttonChanged (int ) ) ); +} + +WorkToolBar::~WorkToolBar() { + disconnect(this, TQT_SIGNAL(released(int)),this,TQT_SLOT(buttonChanged(int))); +} + +void WorkToolBar::insertHotBtn(ToolBar_Buttons tbb) { + insertButton(m_ToolButtons[tbb].Symbol, tbb, true, m_ToolButtons[tbb].Label); + setToggle(tbb, true); +} + +void WorkToolBar::insertBasicAssociations() { + insertHotBtn(tbb_Association); + if (m_Type == Uml::dt_Class || m_Type == Uml::dt_UseCase) { + insertHotBtn(tbb_UniAssociation); + } + insertHotBtn(tbb_Dependency); + insertHotBtn(tbb_Generalization); +} + +void WorkToolBar::slotCheckToolBar(Uml::Diagram_Type dt) { + if ( dt == m_Type ) + return; + clear(); + m_Type = dt; + + if ( m_Type == Uml::dt_Undefined ) + return; + + //insert note, anchor and lines of text on all diagrams + insertHotBtn(tbb_Arrow); + toggleButton(tbb_Arrow); + m_CurrentButtonID = tbb_Arrow; + + insertHotBtn(tbb_Note); + insertHotBtn(tbb_Anchor); + insertHotBtn(tbb_Text); + insertHotBtn(tbb_Box); + + //insert diagram specific tools + switch (m_Type) { + case Uml::dt_UseCase: + insertHotBtn(tbb_Actor); + insertHotBtn(tbb_UseCase); + insertBasicAssociations(); + break; + + case Uml::dt_Class: + insertHotBtn(tbb_Class); + insertHotBtn(tbb_Interface); + insertHotBtn(tbb_Datatype); + insertHotBtn(tbb_Enum); + insertHotBtn(tbb_Package); + insertBasicAssociations(); + insertHotBtn(tbb_Composition); + insertHotBtn(tbb_Aggregation); + insertHotBtn(tbb_Containment); + break; + + case Uml::dt_Sequence: + insertHotBtn(tbb_Object); + insertHotBtn(tbb_Seq_Message_Synchronous); + insertHotBtn(tbb_Seq_Message_Asynchronous); + break; + + case Uml::dt_Collaboration: + insertHotBtn(tbb_Object); + insertHotBtn(tbb_Coll_Message); + break; + + case Uml::dt_State: + insertHotBtn(tbb_Initial_State); + insertHotBtn(tbb_State); + insertHotBtn(tbb_End_State); + insertHotBtn(tbb_State_Transition); + //insertHotBtn(tbb_DeepHistory); //NotYetImplemented + //insertHotBtn(tbb_ShallowHistory); //NotYetImplemented + //insertHotBtn(tbb_Join); //NotYetImplemented + insertHotBtn(tbb_StateFork); + //insertHotBtn(tbb_Junction); //NotYetImplemented + //insertHotBtn(tbb_Choice); //NotYetImplemented + //insertHotBtn(tbb_Andline); //NotYetImplemented + break; + + case Uml::dt_Activity: + insertHotBtn(tbb_Initial_Activity); + insertHotBtn(tbb_Activity); + insertHotBtn(tbb_End_Activity); + insertHotBtn(tbb_Branch); + insertHotBtn(tbb_Fork); + insertHotBtn(tbb_Activity_Transition); + break; + + case Uml::dt_Component: + insertHotBtn(tbb_Interface); + insertHotBtn(tbb_Component); + insertHotBtn(tbb_Artifact); + insertBasicAssociations(); + break; + + case Uml::dt_Deployment: + insertHotBtn(tbb_Object); + insertHotBtn(tbb_Interface); + insertHotBtn(tbb_Component); + insertHotBtn(tbb_Node); + insertBasicAssociations(); + break; + + case Uml::dt_EntityRelationship: + insertHotBtn(tbb_Entity); + insertHotBtn(tbb_Relationship); + break; + + default: + kWarning() << "slotCheckToolBar() on unknown diagram type:" + << m_Type << endl; + break; + } +} + +void WorkToolBar::buttonChanged(int b) { + UMLView* view = UMLApp::app()->getCurrentView(); + + //if trying to turn off arrow - stop it + ToolBar_Buttons tbb = (ToolBar_Buttons)b; + if (tbb == tbb_Arrow && m_CurrentButtonID == tbb_Arrow) { + toggleButton(tbb_Arrow); + + // signal needed, in the case ( when switching diagrams ) that + // Arrow Button gets activated, but the toolBarState of the Views may be different + emit sigButtonChanged( m_CurrentButtonID ); + + view->setCursor( currentCursor() ); + return; + } + + //if toggling off a button set to arrow + if (tbb == m_CurrentButtonID) { + m_map[m_Type] = m_CurrentButtonID; // store old tool for this diagram type + toggleButton(tbb_Arrow); + m_CurrentButtonID = tbb_Arrow; + emit sigButtonChanged(m_CurrentButtonID); + view->setCursor( currentCursor() ); + return; + } + m_map[m_Type] = m_CurrentButtonID; + toggleButton(m_CurrentButtonID); + m_CurrentButtonID = tbb; + emit sigButtonChanged(m_CurrentButtonID); + view->setCursor( currentCursor() ); +} + +TQCursor WorkToolBar::currentCursor() { + return m_ToolButtons[m_CurrentButtonID].Cursor; +} + +void WorkToolBar::slotResetToolBar() { + if (m_CurrentButtonID == tbb_Arrow) + return;//really shouldn't occur + toggleButton(m_CurrentButtonID); + m_CurrentButtonID = tbb_Arrow; + toggleButton(m_CurrentButtonID); + emit sigButtonChanged(m_CurrentButtonID); + + TQCursor curs; + curs.setShape(Qt::ArrowCursor); + + UMLView* view = UMLApp::app()->getCurrentView(); + if (view != NULL) { + view -> setCursor(curs); + } +} + +void WorkToolBar::setOldTool() { + TDEToolBarButton *b = (TDEToolBarButton*) getWidget(m_map[m_Type]); + if (b) + b -> animateClick(); +} + +void WorkToolBar::setDefaultTool() { + TDEToolBarButton *b = (TDEToolBarButton*) getWidget(tbb_Arrow); + if (b) + b -> animateClick(); +} + +TQPixmap WorkToolBar::load(const TQString & fileName) { + TQPixmap pxm; + pxm.load(fileName); + return pxm; +} + +void WorkToolBar::loadPixmaps() { + const struct ButtonInfo { + const ToolBar_Buttons tbb; + const TQString btnName; + const char *pngName; + } buttonInfo[] = { + { tbb_Object, i18n("Object"), "object.png" }, + { tbb_Seq_Message_Synchronous, i18n("Synchronous Message"), "message-synchronous.png" }, + { tbb_Seq_Message_Asynchronous, i18n("Asynchronous Message"), "message-asynchronous.png" }, + { tbb_Association, i18n("Association"), "association.png" }, + { tbb_Containment, i18n("Containment"), "containment.png" }, + { tbb_Anchor, i18n("Anchor"), "anchor.png" }, + { tbb_Text, i18n("Label"), "text.png" }, + { tbb_Note, i18n("Note"), "note.png" }, + { tbb_Box, i18n("Box"), "box.png" }, + { tbb_Actor, i18n("Actor"), "actor.png" }, + { tbb_Dependency, i18n("Dependency"), "dependency.png" }, + { tbb_Aggregation, i18n("Aggregation"), "aggregation.png" }, + { tbb_Relationship, i18n("Relationship"), "relationship.png" }, + { tbb_UniAssociation, i18n("Directional Association"), "uniassociation.png" }, + { tbb_Generalization, i18n("Implements (Generalisation/Realisation)"), "generalisation.png" }, + { tbb_Composition, i18n("Composition"), "composition.png" }, + { tbb_UseCase, i18n("Use Case"), "usecase.png" }, + { tbb_Class, i18n("Class"), "class.png" }, + { tbb_Initial_State, i18n("Initial State"), "initial_state.png" }, + { tbb_End_State, i18n("End State"), "end_state.png" }, + { tbb_Branch, i18n("Branch/Merge"), "branch.png" }, + { tbb_Fork, i18n("Fork/Join"), "fork.png" }, + { tbb_Package, i18n("Package"), "package.png" }, + { tbb_Component, i18n("Component"), "component.png" }, + { tbb_Node, i18n("Node"), "node.png" }, + { tbb_Artifact, i18n("Artifact"), "artifact.png" }, + { tbb_Interface, i18n("Interface"), "interface.png" }, + { tbb_Datatype, i18n("Datatype"), "datatype.png" }, + { tbb_Enum, i18n("Enum"), "enum.png" }, + { tbb_Entity, i18n("Entity"), "entity.png" }, + { tbb_DeepHistory, i18n("Deep History"), "deep-history.png" }, //NotYetImplemented + { tbb_ShallowHistory, i18n("Shallow History"), "shallow-history.png" }, //NotYetImplemented + { tbb_Join, i18n("Join"), "join.png" }, //NotYetImplemented + { tbb_StateFork, i18n("Fork"), "state-fork.png" }, + { tbb_Junction, i18n("Junction"), "junction.png" }, //NotYetImplemented + { tbb_Choice, i18n("Choice"), "choice-round.png" }, //NotYetImplemented + //:TODO: let the user decide which symbol he wants (setting an option) + // { tbb_Choice, i18n("Choice"), "choice-rhomb.png" }, //NotYetImplemented + //{ tbb_Andline, i18n("And Line"), "andline.png" }, //NotYetImplemented + { tbb_State_Transition, i18n("State Transition"), "uniassociation.png" }, + { tbb_Activity_Transition, i18n("Activity Transition"), "uniassociation.png" }, + { tbb_Activity, i18n("Activity"), "usecase.png" }, + { tbb_State, i18n("State"), "usecase.png" }, + { tbb_End_Activity, i18n("End Activity"), "end_state.png" }, + { tbb_Initial_Activity, i18n("Initial Activity"), "initial_state.png" }, + { tbb_Coll_Message, i18n("Message"), "message-asynchronous.png" } + }; + TDEStandardDirs * dirs = TDEGlobal::dirs(); + TQString dataDir = dirs->findResourceDir( "data", "umbrello/pics/object.png" ); + dataDir += "/umbrello/pics/"; + const size_t n_buttonInfos = sizeof(buttonInfo) / sizeof(ButtonInfo); + + m_ToolButtons.insert(tbb_Undefined, + ToolButton(i18n("UNDEFINED"), + 0, + TQCursor()) ); + m_ToolButtons.insert(tbb_Arrow, + ToolButton(i18n("Select"), + load(dataDir + "arrow.png"), + TQCursor()) ); + kDebug() << "WorkToolBar::loadPixmaps: n_buttonInfos = " << n_buttonInfos << endl; + for (uint i = 0; i < n_buttonInfos; i++) { + const ButtonInfo& info = buttonInfo[i]; + m_ToolButtons.insert(info.tbb, + ToolButton(info.btnName, + load(dataDir + info.pngName), + TQCursor(load(dataDir + "cursor-" + info.pngName), 9, 9))); + } +} + +#include "worktoolbar.moc" diff --git a/umbrello/umbrello/worktoolbar.h b/umbrello/umbrello/worktoolbar.h new file mode 100644 index 00000000..f3b2b815 --- /dev/null +++ b/umbrello/umbrello/worktoolbar.h @@ -0,0 +1,184 @@ +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * copyright (C) 2002-2007 * + * Umbrello UML Modeller Authors * + ***************************************************************************/ + +#ifndef WORKTOOLBAR_H +#define WORKTOOLBAR_H + +#include +#include +#include +#include + +#include "umlnamespace.h" + +class TQMainWindow; + + +/** + * This is the toolbar that is displayed on the right-hand side of the program + * window. For each type of diagram it will change to suit that document. + * + * To add a new tool button do the following: + * - create a button pixmap (symbol) + * - create a cursor pixmap + * - add an element to the ToolBar_Buttons enum + * - adjust function loadPixmaps + * - adjust function slotCheckToolBar + * + * @short The toolbar that is different for each type of diagram. + * @author Paul Hensgen + * Bugs and comments to uml-devel@lists.sf.net or http://bugs.kde.org + */ + + +class WorkToolBar : public TDEToolBar { + Q_OBJECT + +public: + + /** + * Creates a work tool bar. + * + * @param parentWindow The parent of the toolbar. + */ + WorkToolBar(TQMainWindow *parentWindow, const char *name); + + /** + * Standard deconstructor. + */ + ~WorkToolBar(); + + /** + * Sets the current tool to the previously used Tool. This is just + * as if the user had pressed the button for the other tool. + */ + void setOldTool(); + + /** + * Sets the current tool to the default tool. (select tool) + * Calling this function is as if the user had pressed the "arrow" + * button on the toolbar. + */ + void setDefaultTool(); + + /** + * Enumeration of all available toolbar buttons. + */ + enum ToolBar_Buttons + { + tbb_Undefined = -1, + tbb_Arrow, + tbb_Generalization, + tbb_Aggregation, + tbb_Dependency, + tbb_Association, + tbb_Containment, + tbb_Coll_Message, + tbb_Seq_Message_Synchronous, + tbb_Seq_Message_Asynchronous, + tbb_Composition, + tbb_Relationship, + tbb_UniAssociation, + tbb_State_Transition, + tbb_Activity_Transition, + tbb_Anchor,//keep anchor as last association until code uses better algorithm for testing + tbb_Note, + tbb_Box, + tbb_Text, + tbb_Actor, + tbb_UseCase, + tbb_Class, + tbb_Interface, + tbb_Datatype, + tbb_Enum, + tbb_Entity, + tbb_Package, + tbb_Component, + tbb_Node, + tbb_Artifact, + tbb_Object, + tbb_Initial_State, + tbb_State, + tbb_End_State, + tbb_Initial_Activity, + tbb_Activity, + tbb_End_Activity, + tbb_Branch, + tbb_Fork, + tbb_DeepHistory, + tbb_ShallowHistory, + tbb_Join, + tbb_StateFork, + tbb_Junction, + tbb_Choice, + tbb_Andline + }; + +private: + + typedef TQMap OldToolMap; + + /** + * This inner class holds label, symbol, and cursor of a tool button. + */ + class ToolButton { + public: + TQString Label; + TQPixmap Symbol; + TQCursor Cursor; + ToolButton() : Label(TQString("?")), Symbol(TQPixmap()), Cursor(TQCursor()) { } + ToolButton(const TQString& lbl, const TQPixmap& smb, const TQCursor& cur) : + Label(lbl), Symbol(smb), Cursor(cur) { } + }; + + typedef TQMap ToolButtonMap; + + ToolBar_Buttons m_CurrentButtonID; + OldToolMap m_map; + Uml::Diagram_Type m_Type; + ToolButtonMap m_ToolButtons; + + /** + * Loads a pixmap from file + */ + TQPixmap load(const TQString &fileName); + + /** + * Loads toolbar icon and mouse cursor images from disk + */ + void loadPixmaps(); + + /** + * Returns the current cursor depending on m_CurrentButtonID + */ + TQCursor currentCursor(); + + /** + * Inserts the button corresponding to the tbb value given + * and activates the toggle. + */ + void insertHotBtn(ToolBar_Buttons tbb); + + /** + * Inserts most associations, just reduces some string + * duplication (nice to translators) + */ + void insertBasicAssociations(); + +signals: + void sigButtonChanged(int); +public slots: + void slotCheckToolBar(Uml::Diagram_Type dt); + void buttonChanged(int b); + void slotResetToolBar(); +}; + +#endif diff --git a/umbrello/umbrello/wortdetoolbar.cpp b/umbrello/umbrello/wortdetoolbar.cpp deleted file mode 100644 index c3aa3be4..00000000 --- a/umbrello/umbrello/wortdetoolbar.cpp +++ /dev/null @@ -1,315 +0,0 @@ -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * copyright (C) 2002-2007 * - * Umbrello UML Modeller Authors * - ***************************************************************************/ - -// own header -#include "wortdetoolbar.h" - -// qt/kde include files -#include -#include -#include -#include -#include - -// application specific includes -#include "uml.h" -#include "umldoc.h" -#include "umlview.h" -#include "wortdetoolbar.h" - - -WorkToolBar::WorkToolBar(TQMainWindow *parentWindow, const char*name) - : TDEToolBar(parentWindow,TQt::DockRight,false,name) { - m_CurrentButtonID = tbb_Undefined; - loadPixmaps(); - m_Type = Uml::dt_Class; /* first time in just want it to load arrow, - needs anything but dt_Undefined */ - setOrientation( Qt::Vertical ); - setVerticalStretchable( true ); - // initialize old tool map, everything starts with select tool (arrow) - m_map.insert(Uml::dt_UseCase,tbb_Arrow); - m_map.insert(Uml::dt_Collaboration,tbb_Arrow); - m_map.insert(Uml::dt_Class,tbb_Arrow); - m_map.insert(Uml::dt_Sequence,tbb_Arrow); - m_map.insert(Uml::dt_State,tbb_Arrow); - m_map.insert(Uml::dt_Activity,tbb_Arrow); - m_map.insert(Uml::dt_Undefined,tbb_Arrow); - - slotCheckToolBar( Uml::dt_Undefined ); - connect( this, TQT_SIGNAL( released( int ) ), this, TQT_SLOT( buttonChanged (int ) ) ); -} - -WorkToolBar::~WorkToolBar() { - disconnect(this, TQT_SIGNAL(released(int)),this,TQT_SLOT(buttonChanged(int))); -} - -void WorkToolBar::insertHotBtn(ToolBar_Buttons tbb) { - insertButton(m_ToolButtons[tbb].Symbol, tbb, true, m_ToolButtons[tbb].Label); - setToggle(tbb, true); -} - -void WorkToolBar::insertBasicAssociations() { - insertHotBtn(tbb_Association); - if (m_Type == Uml::dt_Class || m_Type == Uml::dt_UseCase) { - insertHotBtn(tbb_UniAssociation); - } - insertHotBtn(tbb_Dependency); - insertHotBtn(tbb_Generalization); -} - -void WorkToolBar::slotCheckToolBar(Uml::Diagram_Type dt) { - if ( dt == m_Type ) - return; - clear(); - m_Type = dt; - - if ( m_Type == Uml::dt_Undefined ) - return; - - //insert note, anchor and lines of text on all diagrams - insertHotBtn(tbb_Arrow); - toggleButton(tbb_Arrow); - m_CurrentButtonID = tbb_Arrow; - - insertHotBtn(tbb_Note); - insertHotBtn(tbb_Anchor); - insertHotBtn(tbb_Text); - insertHotBtn(tbb_Box); - - //insert diagram specific tools - switch (m_Type) { - case Uml::dt_UseCase: - insertHotBtn(tbb_Actor); - insertHotBtn(tbb_UseCase); - insertBasicAssociations(); - break; - - case Uml::dt_Class: - insertHotBtn(tbb_Class); - insertHotBtn(tbb_Interface); - insertHotBtn(tbb_Datatype); - insertHotBtn(tbb_Enum); - insertHotBtn(tbb_Package); - insertBasicAssociations(); - insertHotBtn(tbb_Composition); - insertHotBtn(tbb_Aggregation); - insertHotBtn(tbb_Containment); - break; - - case Uml::dt_Sequence: - insertHotBtn(tbb_Object); - insertHotBtn(tbb_Seq_Message_Synchronous); - insertHotBtn(tbb_Seq_Message_Asynchronous); - break; - - case Uml::dt_Collaboration: - insertHotBtn(tbb_Object); - insertHotBtn(tbb_Coll_Message); - break; - - case Uml::dt_State: - insertHotBtn(tbb_Initial_State); - insertHotBtn(tbb_State); - insertHotBtn(tbb_End_State); - insertHotBtn(tbb_State_Transition); - //insertHotBtn(tbb_DeepHistory); //NotYetImplemented - //insertHotBtn(tbb_ShallowHistory); //NotYetImplemented - //insertHotBtn(tbb_Join); //NotYetImplemented - insertHotBtn(tbb_StateFork); - //insertHotBtn(tbb_Junction); //NotYetImplemented - //insertHotBtn(tbb_Choice); //NotYetImplemented - //insertHotBtn(tbb_Andline); //NotYetImplemented - break; - - case Uml::dt_Activity: - insertHotBtn(tbb_Initial_Activity); - insertHotBtn(tbb_Activity); - insertHotBtn(tbb_End_Activity); - insertHotBtn(tbb_Branch); - insertHotBtn(tbb_Fork); - insertHotBtn(tbb_Activity_Transition); - break; - - case Uml::dt_Component: - insertHotBtn(tbb_Interface); - insertHotBtn(tbb_Component); - insertHotBtn(tbb_Artifact); - insertBasicAssociations(); - break; - - case Uml::dt_Deployment: - insertHotBtn(tbb_Object); - insertHotBtn(tbb_Interface); - insertHotBtn(tbb_Component); - insertHotBtn(tbb_Node); - insertBasicAssociations(); - break; - - case Uml::dt_EntityRelationship: - insertHotBtn(tbb_Entity); - insertHotBtn(tbb_Relationship); - break; - - default: - kWarning() << "slotCheckToolBar() on unknown diagram type:" - << m_Type << endl; - break; - } -} - -void WorkToolBar::buttonChanged(int b) { - UMLView* view = UMLApp::app()->getCurrentView(); - - //if trying to turn off arrow - stop it - ToolBar_Buttons tbb = (ToolBar_Buttons)b; - if (tbb == tbb_Arrow && m_CurrentButtonID == tbb_Arrow) { - toggleButton(tbb_Arrow); - - // signal needed, in the case ( when switching diagrams ) that - // Arrow Button gets activated, but the toolBarState of the Views may be different - emit sigButtonChanged( m_CurrentButtonID ); - - view->setCursor( currentCursor() ); - return; - } - - //if toggling off a button set to arrow - if (tbb == m_CurrentButtonID) { - m_map[m_Type] = m_CurrentButtonID; // store old tool for this diagram type - toggleButton(tbb_Arrow); - m_CurrentButtonID = tbb_Arrow; - emit sigButtonChanged(m_CurrentButtonID); - view->setCursor( currentCursor() ); - return; - } - m_map[m_Type] = m_CurrentButtonID; - toggleButton(m_CurrentButtonID); - m_CurrentButtonID = tbb; - emit sigButtonChanged(m_CurrentButtonID); - view->setCursor( currentCursor() ); -} - -TQCursor WorkToolBar::currentCursor() { - return m_ToolButtons[m_CurrentButtonID].Cursor; -} - -void WorkToolBar::slotResetToolBar() { - if (m_CurrentButtonID == tbb_Arrow) - return;//really shouldn't occur - toggleButton(m_CurrentButtonID); - m_CurrentButtonID = tbb_Arrow; - toggleButton(m_CurrentButtonID); - emit sigButtonChanged(m_CurrentButtonID); - - TQCursor curs; - curs.setShape(Qt::ArrowCursor); - - UMLView* view = UMLApp::app()->getCurrentView(); - if (view != NULL) { - view -> setCursor(curs); - } -} - -void WorkToolBar::setOldTool() { - TDEToolBarButton *b = (TDEToolBarButton*) getWidget(m_map[m_Type]); - if (b) - b -> animateClick(); -} - -void WorkToolBar::setDefaultTool() { - TDEToolBarButton *b = (TDEToolBarButton*) getWidget(tbb_Arrow); - if (b) - b -> animateClick(); -} - -TQPixmap WorkToolBar::load(const TQString & fileName) { - TQPixmap pxm; - pxm.load(fileName); - return pxm; -} - -void WorkToolBar::loadPixmaps() { - const struct ButtonInfo { - const ToolBar_Buttons tbb; - const TQString btnName; - const char *pngName; - } buttonInfo[] = { - { tbb_Object, i18n("Object"), "object.png" }, - { tbb_Seq_Message_Synchronous, i18n("Synchronous Message"), "message-synchronous.png" }, - { tbb_Seq_Message_Asynchronous, i18n("Asynchronous Message"), "message-asynchronous.png" }, - { tbb_Association, i18n("Association"), "association.png" }, - { tbb_Containment, i18n("Containment"), "containment.png" }, - { tbb_Anchor, i18n("Anchor"), "anchor.png" }, - { tbb_Text, i18n("Label"), "text.png" }, - { tbb_Note, i18n("Note"), "note.png" }, - { tbb_Box, i18n("Box"), "box.png" }, - { tbb_Actor, i18n("Actor"), "actor.png" }, - { tbb_Dependency, i18n("Dependency"), "dependency.png" }, - { tbb_Aggregation, i18n("Aggregation"), "aggregation.png" }, - { tbb_Relationship, i18n("Relationship"), "relationship.png" }, - { tbb_UniAssociation, i18n("Directional Association"), "uniassociation.png" }, - { tbb_Generalization, i18n("Implements (Generalisation/Realisation)"), "generalisation.png" }, - { tbb_Composition, i18n("Composition"), "composition.png" }, - { tbb_UseCase, i18n("Use Case"), "usecase.png" }, - { tbb_Class, i18n("Class"), "class.png" }, - { tbb_Initial_State, i18n("Initial State"), "initial_state.png" }, - { tbb_End_State, i18n("End State"), "end_state.png" }, - { tbb_Branch, i18n("Branch/Merge"), "branch.png" }, - { tbb_Fork, i18n("Fork/Join"), "fork.png" }, - { tbb_Package, i18n("Package"), "package.png" }, - { tbb_Component, i18n("Component"), "component.png" }, - { tbb_Node, i18n("Node"), "node.png" }, - { tbb_Artifact, i18n("Artifact"), "artifact.png" }, - { tbb_Interface, i18n("Interface"), "interface.png" }, - { tbb_Datatype, i18n("Datatype"), "datatype.png" }, - { tbb_Enum, i18n("Enum"), "enum.png" }, - { tbb_Entity, i18n("Entity"), "entity.png" }, - { tbb_DeepHistory, i18n("Deep History"), "deep-history.png" }, //NotYetImplemented - { tbb_ShallowHistory, i18n("Shallow History"), "shallow-history.png" }, //NotYetImplemented - { tbb_Join, i18n("Join"), "join.png" }, //NotYetImplemented - { tbb_StateFork, i18n("Fork"), "state-fork.png" }, - { tbb_Junction, i18n("Junction"), "junction.png" }, //NotYetImplemented - { tbb_Choice, i18n("Choice"), "choice-round.png" }, //NotYetImplemented - //:TODO: let the user decide which symbol he wants (setting an option) - // { tbb_Choice, i18n("Choice"), "choice-rhomb.png" }, //NotYetImplemented - //{ tbb_Andline, i18n("And Line"), "andline.png" }, //NotYetImplemented - { tbb_State_Transition, i18n("State Transition"), "uniassociation.png" }, - { tbb_Activity_Transition, i18n("Activity Transition"), "uniassociation.png" }, - { tbb_Activity, i18n("Activity"), "usecase.png" }, - { tbb_State, i18n("State"), "usecase.png" }, - { tbb_End_Activity, i18n("End Activity"), "end_state.png" }, - { tbb_Initial_Activity, i18n("Initial Activity"), "initial_state.png" }, - { tbb_Coll_Message, i18n("Message"), "message-asynchronous.png" } - }; - TDEStandardDirs * dirs = TDEGlobal::dirs(); - TQString dataDir = dirs->findResourceDir( "data", "umbrello/pics/object.png" ); - dataDir += "/umbrello/pics/"; - const size_t n_buttonInfos = sizeof(buttonInfo) / sizeof(ButtonInfo); - - m_ToolButtons.insert(tbb_Undefined, - ToolButton(i18n("UNDEFINED"), - 0, - TQCursor()) ); - m_ToolButtons.insert(tbb_Arrow, - ToolButton(i18n("Select"), - load(dataDir + "arrow.png"), - TQCursor()) ); - kDebug() << "WorkToolBar::loadPixmaps: n_buttonInfos = " << n_buttonInfos << endl; - for (uint i = 0; i < n_buttonInfos; i++) { - const ButtonInfo& info = buttonInfo[i]; - m_ToolButtons.insert(info.tbb, - ToolButton(info.btnName, - load(dataDir + info.pngName), - TQCursor(load(dataDir + "cursor-" + info.pngName), 9, 9))); - } -} - -#include "wortdetoolbar.moc" diff --git a/umbrello/umbrello/wortdetoolbar.h b/umbrello/umbrello/wortdetoolbar.h deleted file mode 100644 index f3b2b815..00000000 --- a/umbrello/umbrello/wortdetoolbar.h +++ /dev/null @@ -1,184 +0,0 @@ -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * copyright (C) 2002-2007 * - * Umbrello UML Modeller Authors * - ***************************************************************************/ - -#ifndef WORKTOOLBAR_H -#define WORKTOOLBAR_H - -#include -#include -#include -#include - -#include "umlnamespace.h" - -class TQMainWindow; - - -/** - * This is the toolbar that is displayed on the right-hand side of the program - * window. For each type of diagram it will change to suit that document. - * - * To add a new tool button do the following: - * - create a button pixmap (symbol) - * - create a cursor pixmap - * - add an element to the ToolBar_Buttons enum - * - adjust function loadPixmaps - * - adjust function slotCheckToolBar - * - * @short The toolbar that is different for each type of diagram. - * @author Paul Hensgen - * Bugs and comments to uml-devel@lists.sf.net or http://bugs.kde.org - */ - - -class WorkToolBar : public TDEToolBar { - Q_OBJECT - -public: - - /** - * Creates a work tool bar. - * - * @param parentWindow The parent of the toolbar. - */ - WorkToolBar(TQMainWindow *parentWindow, const char *name); - - /** - * Standard deconstructor. - */ - ~WorkToolBar(); - - /** - * Sets the current tool to the previously used Tool. This is just - * as if the user had pressed the button for the other tool. - */ - void setOldTool(); - - /** - * Sets the current tool to the default tool. (select tool) - * Calling this function is as if the user had pressed the "arrow" - * button on the toolbar. - */ - void setDefaultTool(); - - /** - * Enumeration of all available toolbar buttons. - */ - enum ToolBar_Buttons - { - tbb_Undefined = -1, - tbb_Arrow, - tbb_Generalization, - tbb_Aggregation, - tbb_Dependency, - tbb_Association, - tbb_Containment, - tbb_Coll_Message, - tbb_Seq_Message_Synchronous, - tbb_Seq_Message_Asynchronous, - tbb_Composition, - tbb_Relationship, - tbb_UniAssociation, - tbb_State_Transition, - tbb_Activity_Transition, - tbb_Anchor,//keep anchor as last association until code uses better algorithm for testing - tbb_Note, - tbb_Box, - tbb_Text, - tbb_Actor, - tbb_UseCase, - tbb_Class, - tbb_Interface, - tbb_Datatype, - tbb_Enum, - tbb_Entity, - tbb_Package, - tbb_Component, - tbb_Node, - tbb_Artifact, - tbb_Object, - tbb_Initial_State, - tbb_State, - tbb_End_State, - tbb_Initial_Activity, - tbb_Activity, - tbb_End_Activity, - tbb_Branch, - tbb_Fork, - tbb_DeepHistory, - tbb_ShallowHistory, - tbb_Join, - tbb_StateFork, - tbb_Junction, - tbb_Choice, - tbb_Andline - }; - -private: - - typedef TQMap OldToolMap; - - /** - * This inner class holds label, symbol, and cursor of a tool button. - */ - class ToolButton { - public: - TQString Label; - TQPixmap Symbol; - TQCursor Cursor; - ToolButton() : Label(TQString("?")), Symbol(TQPixmap()), Cursor(TQCursor()) { } - ToolButton(const TQString& lbl, const TQPixmap& smb, const TQCursor& cur) : - Label(lbl), Symbol(smb), Cursor(cur) { } - }; - - typedef TQMap ToolButtonMap; - - ToolBar_Buttons m_CurrentButtonID; - OldToolMap m_map; - Uml::Diagram_Type m_Type; - ToolButtonMap m_ToolButtons; - - /** - * Loads a pixmap from file - */ - TQPixmap load(const TQString &fileName); - - /** - * Loads toolbar icon and mouse cursor images from disk - */ - void loadPixmaps(); - - /** - * Returns the current cursor depending on m_CurrentButtonID - */ - TQCursor currentCursor(); - - /** - * Inserts the button corresponding to the tbb value given - * and activates the toggle. - */ - void insertHotBtn(ToolBar_Buttons tbb); - - /** - * Inserts most associations, just reduces some string - * duplication (nice to translators) - */ - void insertBasicAssociations(); - -signals: - void sigButtonChanged(int); -public slots: - void slotCheckToolBar(Uml::Diagram_Type dt); - void buttonChanged(int b); - void slotResetToolBar(); -}; - -#endif diff --git a/umbrello/uml.kdevprj b/umbrello/uml.kdevprj index aeba8483..6f584c8d 100644 --- a/umbrello/uml.kdevprj +++ b/umbrello/uml.kdevprj @@ -437,7 +437,7 @@ install_location= type=DATA [uml/Makefile.am] -files=uml/actor.h,uml/actorwidgetdata.h,uml/actorwidget.h,uml/associationwidgetdata.h,uml/associationwidgetdatalist.h,uml/associationwidget.h,uml/assocrules.h,uml/attribute.h,uml/concept.h,uml/conceptwidgetdata.h,uml/conceptwidget.h,uml/docwindow.h,uml/floatingtextdata.h,uml/floatingtext.h,uml/infowidget.h,uml/kstartuplogo.h,uml/linepath.h,uml/listpopupmenu.h,uml/messagewidgetdata.h,uml/messagewidget.h,uml/actor.cpp,uml/actorwidget.cpp,uml/actorwidgetdata.cpp,uml/associationwidget.cpp,uml/associationwidgetdata.cpp,uml/assocrules.cpp,uml/attribute.cpp,uml/concept.cpp,uml/conceptwidget.cpp,uml/conceptwidgetdata.cpp,uml/docwindow.cpp,uml/floatingtext.cpp,uml/floatingtextdata.cpp,uml/infowidget.cpp,uml/kstartuplogo.cpp,uml/linepath.cpp,uml/listpopupmenu.cpp,uml/main.cpp,uml/messagewidget.cpp,uml/messagewidgetdata.cpp,uml/notewidget.cpp,uml/notewidgetdata.cpp,uml/notewidgetdata.h,uml/notewidget.h,uml/objectwidget.cpp,uml/objectwidgetdata.cpp,uml/objectwidgetdata.h,uml/objectwidget.h,uml/operation.cpp,uml/operation.h,uml/statewidget.cpp,uml/statewidgetdata.cpp,uml/statewidgetdata.h,uml/statewidget.h,uml/uml.cpp,uml/umldoc.cpp,uml/umldoc.h,uml/uml.h,uml/umlnamespace.cpp,uml/umlnamespace.h,uml/umlobject.cpp,uml/umlobject.h,uml/umlobjectlist.h,uml/umlviewcanvas.cpp,uml/umlviewcanvas.h,uml/umlview.cpp,uml/umlviewdata.cpp,uml/umlviewdata.h,uml/umlview.h,uml/umlviewlist.h,uml/umlwidget.cpp,uml/umlwidgetdata.cpp,uml/umlwidgetdata.h,uml/umlwidget.h,uml/umlwidgetlist.h,uml/usecase.cpp,uml/usecase.h,uml/usecasewidget.cpp,uml/usecasewidgetdata.cpp,uml/usecasewidgetdata.h,uml/usecasewidget.h,uml/wortdetoolbar.cpp,uml/wortdetoolbar.h,uml/hi16-app-uml.png,uml/hi32-app-uml.png,uml/lo16-app-uml.png,uml/lo32-app-uml.png,uml/tips,uml/uml.desktop,uml/umlui.rc,uml/x-uml.desktop,uml/activitywidgetdata.cpp,uml/activitywidgetdata.h,uml/activitywidget.cpp,uml/activitywidget.h,uml/codegenerator.cpp,uml/codegenerator.h,uml/seqlinewidget.cpp,uml/seqlinewidget.h,uml/umllistview.cpp,uml/umllistview.h,uml/umllistviewitem.cpp,uml/umllistviewitem.h,uml/umllistviewitemdata.cpp,uml/umllistviewitemdata.h,uml/umllistviewitemdatalist.h,uml/classimport.cpp,uml/classimport.h,uml/umllistviewitemlist.h +files=uml/actor.h,uml/actorwidgetdata.h,uml/actorwidget.h,uml/associationwidgetdata.h,uml/associationwidgetdatalist.h,uml/associationwidget.h,uml/assocrules.h,uml/attribute.h,uml/concept.h,uml/conceptwidgetdata.h,uml/conceptwidget.h,uml/docwindow.h,uml/floatingtextdata.h,uml/floatingtext.h,uml/infowidget.h,uml/kstartuplogo.h,uml/linepath.h,uml/listpopupmenu.h,uml/messagewidgetdata.h,uml/messagewidget.h,uml/actor.cpp,uml/actorwidget.cpp,uml/actorwidgetdata.cpp,uml/associationwidget.cpp,uml/associationwidgetdata.cpp,uml/assocrules.cpp,uml/attribute.cpp,uml/concept.cpp,uml/conceptwidget.cpp,uml/conceptwidgetdata.cpp,uml/docwindow.cpp,uml/floatingtext.cpp,uml/floatingtextdata.cpp,uml/infowidget.cpp,uml/kstartuplogo.cpp,uml/linepath.cpp,uml/listpopupmenu.cpp,uml/main.cpp,uml/messagewidget.cpp,uml/messagewidgetdata.cpp,uml/notewidget.cpp,uml/notewidgetdata.cpp,uml/notewidgetdata.h,uml/notewidget.h,uml/objectwidget.cpp,uml/objectwidgetdata.cpp,uml/objectwidgetdata.h,uml/objectwidget.h,uml/operation.cpp,uml/operation.h,uml/statewidget.cpp,uml/statewidgetdata.cpp,uml/statewidgetdata.h,uml/statewidget.h,uml/uml.cpp,uml/umldoc.cpp,uml/umldoc.h,uml/uml.h,uml/umlnamespace.cpp,uml/umlnamespace.h,uml/umlobject.cpp,uml/umlobject.h,uml/umlobjectlist.h,uml/umlviewcanvas.cpp,uml/umlviewcanvas.h,uml/umlview.cpp,uml/umlviewdata.cpp,uml/umlviewdata.h,uml/umlview.h,uml/umlviewlist.h,uml/umlwidget.cpp,uml/umlwidgetdata.cpp,uml/umlwidgetdata.h,uml/umlwidget.h,uml/umlwidgetlist.h,uml/usecase.cpp,uml/usecase.h,uml/usecasewidget.cpp,uml/usecasewidgetdata.cpp,uml/usecasewidgetdata.h,uml/usecasewidget.h,uml/worktoolbar.cpp,uml/worktoolbar.h,uml/hi16-app-uml.png,uml/hi32-app-uml.png,uml/lo16-app-uml.png,uml/lo32-app-uml.png,uml/tips,uml/uml.desktop,uml/umlui.rc,uml/x-uml.desktop,uml/activitywidgetdata.cpp,uml/activitywidgetdata.h,uml/activitywidget.cpp,uml/activitywidget.h,uml/codegenerator.cpp,uml/codegenerator.h,uml/seqlinewidget.cpp,uml/seqlinewidget.h,uml/umllistview.cpp,uml/umllistview.h,uml/umllistviewitem.cpp,uml/umllistviewitem.h,uml/umllistviewitemdata.cpp,uml/umllistviewitemdata.h,uml/umllistviewitemdatalist.h,uml/classimport.cpp,uml/classimport.h,uml/umllistviewitemlist.h sub_dirs=classparser,clipboard,dialogs,pics,codegenerators,headings type=prog_main @@ -2135,13 +2135,13 @@ install=false install_location= type=HEADER -[uml/wortdetoolbar.cpp] +[uml/worktoolbar.cpp] dist=true install=false install_location= type=SOURCE -[uml/wortdetoolbar.h] +[uml/worktoolbar.h] dist=true install=false install_location= -- cgit v1.2.1