summaryrefslogtreecommitdiffstats
path: root/umbrello/umbrello/listpopupmenu.h
blob: 0ceddb50b138828bfde89a58a55f43f9652025fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
/***************************************************************************
 *                                                                         *
 *   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) 2003-2007                                               *
 *   Umbrello UML Modeller Authors <uml-devel@uml.sf.net>                  *
 ***************************************************************************/

#ifndef LISTPOPUPMENU_H
#define LISTPOPUPMENU_H

#include <tdepopupmenu.h>
#include "umlnamespace.h"

class UMLView;
class UMLWidget;
class ClassifierWidget;

/**
 * A popup menu that depending on what type it is set to will
 * display a different menu.
 *
 * @short Displays a popup menu.
 * @author Paul Hensgen <phensgen@techie.com>
 * Bugs and comments to uml-devel@lists.sf.net or http://bugs.kde.org
 */

class ListPopupMenu : public TDEPopupMenu {
public:

    /// This type hosts all possible menu types.
    enum Menu_Type
    {
        mt_Model,
        mt_Logical_View,
        mt_UseCase_View,
        mt_Component_View,
        mt_Deployment_View,
        mt_EntityRelationship_Model,
        mt_UseCase_Diagram,
        mt_Sequence_Diagram,
        mt_Class_Diagram,
        mt_Collaboration_Diagram,
        mt_State_Diagram,
        mt_Activity_Diagram,
        mt_Component_Diagram,
        mt_Deployment_Diagram,
        mt_EntityRelationship_Diagram,
        mt_On_UseCase_Diagram,
        mt_On_Sequence_Diagram,
        mt_On_Class_Diagram,
        mt_On_Collaboration_Diagram,
        mt_On_State_Diagram,
        mt_On_Activity_Diagram,
        mt_On_Component_Diagram,
        mt_On_Deployment_Diagram,
        mt_On_EntityRelationship_Diagram,
        mt_Logical_Folder,
        mt_UseCase_Folder,
        mt_Component_Folder,
        mt_Deployment_Folder,
        mt_EntityRelationship_Folder,
        mt_Class,
        mt_Package,
        mt_Subsystem,
        mt_Component,
        mt_Node,
        mt_Artifact,
        mt_Interface,
        mt_Enum,
        mt_Entity,
        mt_Datatype,
        mt_Actor,
        mt_UseCase,
        mt_Attribute,
        mt_EntityAttribute,
        mt_EnumLiteral,
        mt_Object,
        mt_Initial_State,
        mt_End_State,
        mt_State,
        mt_Activity,
        mt_Initial_Activity,
        mt_End_Activity,
        mt_Operation,
        mt_Template,
        mt_New_Parameter,
        mt_New_Operation,
        mt_New_Attribute,
        mt_New_Template,
        mt_New_EnumLiteral,
        mt_New_EntityAttribute,
        mt_Parameter_Selected,
        mt_Operation_Selected,
        mt_Attribute_Selected,
        mt_Template_Selected,
        mt_EnumLiteral_Selected,
        mt_EntityAttribute_Selected,
        mt_Association_Selected,          // Association without role names
        mt_Show_Attributes,
        mt_Show_Attributes_Selection,     //SHOWATTS, multiple items
        mt_Show_Operations,
        mt_Show_Operations_Selection,     //SHOWOPS, multiple items
        mt_Show_Packages,
        mt_Show_Packages_Selection,       //SHOWPACKAGE, multiple items
        mt_Show_Stereotypes,
        mt_Show_Stereotypes_Selection,    //SHOWSTEREOTYPE, multiple items
        mt_Visibility,
        mt_Visibility_Selection,               //SCOPE, multiple items
        mt_DrawAsCircle,
        mt_DrawAsCircle_Selection,        //DRAWASCIRCLE, multiple items
        mt_ChangeToClass,
        mt_ChangeToClass_Selection,
        mt_ChangeToInterface,
        mt_ChangeToInterface_Selection,
        mt_Rename_Object,
        mt_Select_Operation,
        mt_Anchor,
        mt_Properties,
        mt_Rename,
        mt_Delete,
        mt_Export_Image,
        mt_Import_Classes,
        mt_Sequence_Number,
        mt_Cut,
        mt_Copy,
        mt_Paste,
        mt_Clear,
        mt_Redo,
        mt_Undo,
        mt_Link_Docs,
        mt_Show_Operation_Signature,
        mt_Show_Operation_Signature_Selection, //SHOWOPSIG, multiple items
        mt_Show_Attribute_Signature,
        mt_Show_Attribute_Signature_Selection, //SHOWATTSIG, multiple items
        mt_Message_Text,
        mt_Collaboration_Message,
        mt_FloatText,
        mt_MultiA,
        mt_MultiB,
        mt_Name,                          //Association name
        mt_FullAssociation,                 // Association with role names
        mt_AttributeAssociation,   // Rendering of an attribute as an association
        mt_RoleNameA,
        mt_RoleNameB,
        mt_Delete_Selection,
        mt_Reset_Label_Positions,
        mt_Line_Color,
        mt_Line_Color_Selection,          //LINECOLOR, multiple items
        mt_Fill_Color,
        mt_Fill_Color_Selection,          //FILLCOLOR, multiple items
        mt_Use_Fill_Color,
        mt_Default_Properties,
        mt_Rename_MultiA,
        mt_Rename_MultiB,
        mt_Rename_Name,
        mt_Rename_RoleAName,
        mt_Rename_RoleBName,
        mt_Change_Font,
        mt_Change_Font_Selection,
        mt_SnapToGrid,
        mt_ShowSnapGrid,
        mt_Activity_Selected,
        mt_New_Activity,
        mt_Up,
        mt_Down,
        mt_Branch,
        mt_Flip,

        mt_Expand_All,                     //Expand all items in the list
        mt_Collapse_All,                   //Collapse all items in the list

        mt_Refactoring,
        mt_ViewCode, // view code document contents
        mt_Clone, // Create a deep copy of the object.
        mt_Show_Public_Only, // (not currently used)
        mt_Show_Public_Only_Selection,  // Show public operations/attributes only.
        mt_Externalize_Folder,  // Mark folder for saving as separate submodel
        mt_Internalize_Folder,  // Reintegrate separate submodel into main model

        mt_Undefined  =  - 1
    };

    /**
     * Constructs the popup menu for a diagram
     *
     * @param parent    The parent to ListPopupMenu.
     * @param type      The type of menu to display.
     * @param view      The UMLView in which this ListPopupMenu is going to be displayed
     */
    explicit ListPopupMenu(TQWidget* parent, Menu_Type type = mt_Undefined, UMLView* view = 0);

    /**
     * Constructs the popup menu for a list view item.
     *
     * @param parent    The parent to ListPopupMenu.
     * @param type              The type of menu to display.
     */
    ListPopupMenu(TQWidget* parent, Uml::ListView_Type type);

    /**
     * Constructs the popup menu for a canvas widget.
     *
     * @param parent    The parent to ListPopupMenu.
     * @param object    The UMLWidget to represent a menu for.
     * @param multi             True if multiple items are selected.
     * @param unique    True if multiple selected items all have
     *                  the same type (e.g. Class, Interface)
     */
    ListPopupMenu(TQWidget* parent, UMLWidget* object, bool multi = false, bool unique = false);

    /**
     * Standard deconstructor.
     */
    ~ListPopupMenu();

    /**
     * Utility: Convert a Menu_Type value to an Object_Type value.
     */
    static Uml::Object_Type convert_MT_OT(Menu_Type mt);

    /**
     * Utility: Convert a Menu_Type value to a Diagram_Type value.
     */
    static Uml::Diagram_Type convert_MT_DT(Menu_Type mt);

private:
    /**
     * Basic initialization - common to all constructors.
     */
    void init();

    /**
     * Shortcut for inserting a "File->New" choice.
     */
    void insertFileNew();

    /**
     * Shortcut for the most frequently used insertItem() calls.
     *
     * @param m The Menu_Type for which to insert a menu item.
     */
    void insertStdItem(Menu_Type m);

    /**
     * Shortcut for the most frequently used insertStdItem() calls.
     *
     * @param insertLeadingSeparator  Set this true if the group shall
     *                            start with a separator.
     * @param type      The Widget_Type for which to insert the menu items.
     *          If no argument is supplied then a Rename item will be
     *          included.
     */
    void insertStdItems(bool insertLeadingSeparator = true,
                        Uml::Widget_Type type = Uml::wt_UMLWidget);

    /**
     * Shortcut for inserting standard model items (Class, Interface,
     * Datatype, Enum, Package) as well as diagram choices.
     *
     * @param folderAndDiagrams Set this true if folders and diagram
     *                          types shall be included as choices.
     */
    void insertContainerItems(bool folderAndDiagrams);

    /**
     * Inserts a menu item for an association related text
     * (such as name, role, multiplicity etc.)
     *
     * @param label             The menu text.
     * @param mt                The menu type.
     */
    void insertAssocItem(const TQString &label, Menu_Type mt);

    /**
     * Inserts a menu item for externalization/de-externalization
     * of a folder.
     */
    void insertSubmodelAction();

    /**
     * Creates a popup menu for a multiple selection of class and
     * interface widgets.
     */
    void makeMultiClassifierPopup(ClassifierWidget *c);

    /**
     * Creates a popup menu for a single class or interface widgets.
     */
    void makeClassifierPopup(ClassifierWidget *c);

    /**
     * Shortcut for commonly used menu initializations.
     *
     * @param type      The Menu_Type for which to set up the menu.
     * @param view      The UMLView parent of the menu.
     */
    void setupMenu(Menu_Type type, UMLView * view = 0);

    enum PixMap_Type {
        pm_Class,
        pm_Package,
        pm_Interface,
        pm_Datatype,
        pm_Enum,
        pm_Actor,
        pm_Usecase,
        pm_InitialState,
        pm_EndState,
        pm_Branch,
        pm_Object,
        pm_Component,
        pm_Node,
        pm_Artifact,
        pm_Text,
        pm_Entity,
        pm_Subsystem,
        pm_NUMBER_OF_PIXMAPS
    };
    TQPixmap m_pixmap[pm_NUMBER_OF_PIXMAPS];
    TDEPopupMenu * m_pInsert, * m_pShow, * m_pColor;
    void setupColor(bool fc);
    void setupColorSelection(bool fc);
    void setupDiagramMenu(UMLView* view);
};

#endif