~ubuntu-branches/ubuntu/intrepid/kdesdk/intrepid-updates

« back to all changes in this revision

Viewing changes to umbrello/umbrello/listpopupmenu.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2008-05-28 10:11:43 UTC
  • mto: This revision was merged to the branch mainline in revision 37.
  • Revision ID: james.westby@ubuntu.com-20080528101143-gzc3styjz1b70zxu
Tags: upstream-4.0.80
ImportĀ upstreamĀ versionĀ 4.0.80

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 *   the Free Software Foundation; either version 2 of the License, or     *
6
6
 *   (at your option) any later version.                                   *
7
7
 *                                                                         *
8
 
 *   copyright (C) 2003-2007                                               *
 
8
 *   copyright (C) 2003-2008                                               *
9
9
 *   Umbrello UML Modeller Authors <uml-devel@uml.sf.net>                  *
10
10
 ***************************************************************************/
11
11
 
12
12
#ifndef LISTPOPUPMENU_H
13
13
#define LISTPOPUPMENU_H
14
14
 
15
 
#include <kpopupmenu.h>
 
15
#include <QtCore/QHash>
 
16
#include <kmenu.h>
 
17
// #include <kaction.h>
 
18
 
16
19
#include "umlnamespace.h"
 
20
#include "icon_utils.h"
17
21
 
18
22
class UMLView;
19
23
class UMLWidget;
20
24
class ClassifierWidget;
 
25
class UMLCategory;
 
26
class UMLObject;
21
27
 
22
28
/**
23
29
 * A popup menu that depending on what type it is set to will
28
34
 * Bugs and comments to uml-devel@lists.sf.net or http://bugs.kde.org
29
35
 */
30
36
 
31
 
class ListPopupMenu : public KPopupMenu {
 
37
class ListPopupMenu : public KMenu {
32
38
public:
33
39
 
34
40
    /// This type hosts all possible menu types.
44
50
        mt_Sequence_Diagram,
45
51
        mt_Class_Diagram,
46
52
        mt_Collaboration_Diagram,
47
 
        mt_State_Diagram,
 
53
        mt_State_Diagram,                                // 10
48
54
        mt_Activity_Diagram,
49
55
        mt_Component_Diagram,
50
56
        mt_Deployment_Diagram,
54
60
        mt_On_Class_Diagram,
55
61
        mt_On_Collaboration_Diagram,
56
62
        mt_On_State_Diagram,
57
 
        mt_On_Activity_Diagram,
 
63
        mt_On_Activity_Diagram,                          // 20
58
64
        mt_On_Component_Diagram,
59
65
        mt_On_Deployment_Diagram,
60
66
        mt_On_EntityRelationship_Diagram,
64
70
        mt_Deployment_Folder,
65
71
        mt_EntityRelationship_Folder,
66
72
        mt_Class,
67
 
        mt_Package,
 
73
        mt_Package,                                      // 30
68
74
        mt_Subsystem,
69
75
        mt_Component,
70
76
        mt_Node,
74
80
        mt_Entity,
75
81
        mt_Datatype,
76
82
        mt_Actor,
77
 
        mt_UseCase,
 
83
        mt_UseCase,                                      // 40
78
84
        mt_Attribute,
79
85
        mt_EntityAttribute,
80
86
        mt_EnumLiteral,
 
87
        mt_UniqueConstraint,
 
88
        mt_PrimaryKeyConstraint,
 
89
        mt_ForeignKeyConstraint,
 
90
        mt_CheckConstraint,
81
91
        mt_Object,
 
92
        mt_Category,
 
93
        mt_DisjointSpecialisation,                       // 50
 
94
        mt_OverlappingSpecialisation,
 
95
        mt_Union,
82
96
        mt_Initial_State,
83
97
        mt_End_State,
84
98
        mt_State,
86
100
        mt_Initial_Activity,
87
101
        mt_End_Activity,
88
102
        mt_Operation,
89
 
        mt_Template,
 
103
        mt_Template,                                     // 60
90
104
        mt_New_Parameter,
91
105
        mt_New_Operation,
92
106
        mt_New_Attribute,
93
107
        mt_New_Template,
94
108
        mt_New_EnumLiteral,
95
109
        mt_New_EntityAttribute,
 
110
        mt_New_UniqueConstraint,
 
111
        mt_New_PrimaryKeyConstraint,
 
112
        mt_New_ForeignKeyConstraint,
 
113
        mt_New_CheckConstraint,                          // 70
96
114
        mt_Parameter_Selected,
97
115
        mt_Operation_Selected,
98
116
        mt_Attribute_Selected,
99
117
        mt_Template_Selected,
100
118
        mt_EnumLiteral_Selected,
101
119
        mt_EntityAttribute_Selected,
 
120
        mt_UniqueConstraint_Selected,
 
121
        mt_PrimaryKeyConstraint_Selected,
 
122
        mt_ForeignKeyConstraint_Selected,
 
123
        mt_CheckConstraint_Selected,                     // 80
102
124
        mt_Association_Selected,          // Association without role names
103
125
        mt_Show_Attributes,
104
126
        mt_Show_Attributes_Selection,     //SHOWATTS, multiple items
108
130
        mt_Show_Packages_Selection,       //SHOWPACKAGE, multiple items
109
131
        mt_Show_Stereotypes,
110
132
        mt_Show_Stereotypes_Selection,    //SHOWSTEREOTYPE, multiple items
111
 
        mt_Visibility,
112
 
        mt_Visibility_Selection,               //SCOPE, multiple items
 
133
        mt_Visibility,                                   // 90
 
134
        mt_Visibility_Selection,          //SCOPE, multiple items
113
135
        mt_DrawAsCircle,
114
136
        mt_DrawAsCircle_Selection,        //DRAWASCIRCLE, multiple items
115
137
        mt_ChangeToClass,
118
140
        mt_ChangeToInterface_Selection,
119
141
        mt_Rename_Object,
120
142
        mt_Select_Operation,
121
 
        mt_Anchor,
 
143
        mt_Anchor,                                       // 100
122
144
        mt_Properties,
123
145
        mt_Rename,
124
146
        mt_Delete,
125
147
        mt_Export_Image,
126
148
        mt_Import_Classes,
 
149
        mt_Import_Project,
127
150
        mt_Sequence_Number,
128
151
        mt_Cut,
129
152
        mt_Copy,
130
 
        mt_Paste,
 
153
        mt_Paste,                                        // 110
131
154
        mt_Clear,
132
155
        mt_Redo,
133
156
        mt_Undo,
137
160
        mt_Show_Attribute_Signature,
138
161
        mt_Show_Attribute_Signature_Selection, //SHOWATTSIG, multiple items
139
162
        mt_Message_Text,
140
 
        mt_Collaboration_Message,
 
163
        mt_Collaboration_Message,                        // 120
141
164
        mt_FloatText,
142
165
        mt_MultiA,
143
166
        mt_MultiB,
144
 
        mt_Name,                          //Association name
145
 
        mt_FullAssociation,                 // Association with role names
146
 
        mt_AttributeAssociation,   // Rendering of an attribute as an association
 
167
        mt_Name,                       // Association name
 
168
        mt_FullAssociation,            // Association with role names
 
169
        mt_AttributeAssociation,       // Rendering of an attribute as an association
147
170
        mt_RoleNameA,
148
171
        mt_RoleNameB,
149
172
        mt_Delete_Selection,
150
 
        mt_Reset_Label_Positions,
 
173
        mt_Reset_Label_Positions,                        // 130
151
174
        mt_Line_Color,
152
 
        mt_Line_Color_Selection,          //LINECOLOR, multiple items
153
175
        mt_Fill_Color,
154
 
        mt_Fill_Color_Selection,          //FILLCOLOR, multiple items
155
176
        mt_Use_Fill_Color,
156
177
        mt_Default_Properties,
157
178
        mt_Rename_MultiA,
159
180
        mt_Rename_Name,
160
181
        mt_Rename_RoleAName,
161
182
        mt_Rename_RoleBName,
162
 
        mt_Change_Font,
 
183
        mt_Change_Font,                                  // 140
163
184
        mt_Change_Font_Selection,
164
185
        mt_SnapToGrid,
165
186
        mt_ShowSnapGrid,
170
191
        mt_Branch,
171
192
        mt_Flip,
172
193
 
173
 
        mt_Expand_All,                     //Expand all items in the list
174
 
        mt_Collapse_All,                   //Collapse all items in the list
 
194
        mt_Expand_All,                                        // 150 Expand all items in the list
 
195
        mt_Collapse_All,                                // Collapse all items in the list
175
196
 
176
197
        mt_Refactoring,
177
198
        mt_ViewCode, // view code document contents
181
202
        mt_Externalize_Folder,  // Mark folder for saving as separate submodel
182
203
        mt_Internalize_Folder,  // Reintegrate separate submodel into main model
183
204
 
 
205
        mt_AddInteractionOperand,   // add a dash line to an alternative or a parallel combined fragment
 
206
 
184
207
        mt_Undefined  =  - 1
185
208
    };
186
209
 
187
210
    /**
188
211
     * Constructs the popup menu for a diagram
189
212
     *
190
 
     * @param parent    The parent to ListPopupMenu.
191
 
     * @param type      The type of menu to display.
192
 
     * @param view      The UMLView in which this ListPopupMenu is going to be displayed
 
213
     * @param parent   The parent to ListPopupMenu.
 
214
     * @param type     The type of menu to display.
 
215
     * @param view     The UMLView in which this ListPopupMenu is going to be displayed
193
216
     */
194
217
    explicit ListPopupMenu(QWidget* parent, Menu_Type type = mt_Undefined, UMLView* view = 0);
195
218
 
196
219
    /**
197
220
     * Constructs the popup menu for a list view item.
198
221
     *
199
 
     * @param parent    The parent to ListPopupMenu.
200
 
     * @param type              The type of menu to display.
 
222
     * @param parent   The parent to ListPopupMenu.
 
223
     * @param type     The type of menu to display.
 
224
     * @param object   The UMLObject of the ListViewItem
201
225
     */
202
 
    ListPopupMenu(QWidget* parent, Uml::ListView_Type type);
 
226
    ListPopupMenu(QWidget* parent, Uml::ListView_Type type, UMLObject* object);
203
227
 
204
228
    /**
205
229
     * Constructs the popup menu for a canvas widget.
206
230
     *
207
 
     * @param parent    The parent to ListPopupMenu.
208
 
     * @param object    The UMLWidget to represent a menu for.
209
 
     * @param multi             True if multiple items are selected.
210
 
     * @param unique    True if multiple selected items all have
211
 
     *                  the same type (e.g. Class, Interface)
 
231
     * @param parent   The parent to ListPopupMenu.
 
232
     * @param object   The UMLWidget to represent a menu for.
 
233
     * @param multi    True if multiple items are selected.
 
234
     * @param unique   True if multiple selected items all have
 
235
     *                 the same type (e.g. Class, Interface)
212
236
     */
213
237
    ListPopupMenu(QWidget* parent, UMLWidget* object, bool multi = false, bool unique = false);
214
238
 
227
251
     */
228
252
    static Uml::Diagram_Type convert_MT_DT(Menu_Type mt);
229
253
 
 
254
    /**
 
255
     * Get the action from the menu type as index.
 
256
     */
 
257
//    KAction* getAction(Menu_Type idx);
 
258
    QAction* getAction(Menu_Type idx);
 
259
 
 
260
    /**
 
261
     * Enables the action item.
 
262
     *
 
263
     * @param idx     The Menu_Type for which to enable the menu item.
 
264
     * @param value   The value.
 
265
     */
 
266
    void setActionEnabled(Menu_Type idx, bool value);
 
267
 
 
268
    /**
 
269
     * Get the Menu_Type from the action.
 
270
     */
 
271
//    Menu_Type getMenuType(KAction* action);
 
272
    Menu_Type getMenuType(QAction* action);
 
273
 
230
274
private:
231
 
    /**
232
 
     * Basic initialization - common to all constructors.
233
 
     */
234
 
    void init();
235
 
 
236
 
    /**
237
 
     * Shortcut for inserting a "File->New" choice.
238
 
     */
239
 
    void insertFileNew();
240
 
 
241
 
    /**
242
 
     * Shortcut for the most frequently used insertItem() calls.
243
 
     *
244
 
     * @param m The Menu_Type for which to insert a menu item.
245
 
     */
246
 
    void insertStdItem(Menu_Type m);
 
275
 
 
276
    /**
 
277
     * Shortcut for the most frequently used addAction() calls.
 
278
     *
 
279
     * @param m   The Menu_Type for which to insert a menu item.
 
280
     */
 
281
    void insert(Menu_Type m);
 
282
 
 
283
    /**
 
284
     * Shortcut for the frequently used addAction() calls.
 
285
     *
 
286
     * @param m      The Menu_Type for which to insert a menu item.
 
287
     * @param menu   The KMenu for which to insert a menu item.
 
288
     */
 
289
    void insert(const Menu_Type m, KMenu* menu);
 
290
 
 
291
    /**
 
292
     * Shortcut for the frequently used addAction() calls.
 
293
     *
 
294
     * @param m      The Menu_Type for which to insert a menu item.
 
295
     * @param icon   The icon for this action.
 
296
     * @param text   The text for this action.
 
297
     */
 
298
    void insert(const Menu_Type m, const QIcon & icon, const QString & text);
 
299
 
 
300
    /**
 
301
     * Shortcut for the frequently used addAction() calls.
 
302
     *
 
303
     * @param m           The Menu_Type for which to insert a menu item.
 
304
     * @param text        The text for this action.
 
305
     * @param checkable   Sets the action to checkable.
 
306
     */
 
307
    void insert(const Menu_Type m, const QString & text, const bool checkable = false);
 
308
 
 
309
    /**
 
310
     * Shortcut for the frequently used addAction() calls.
 
311
     *
 
312
     * @param m      The Menu_Type for which to insert a menu item.
 
313
     * @param menu   The KMenu for which to insert a menu item.
 
314
     * @param icon   The icon for this action.
 
315
     * @param text   The text for this action.
 
316
     */
 
317
    void insert(const Menu_Type m, KMenu* menu, const QIcon & icon, const QString & text);
 
318
 
 
319
    /**
 
320
     * Shortcut for the frequently used addAction() calls.
 
321
     *
 
322
     * @param m      The Menu_Type for which to insert a menu item.
 
323
     * @param menu   The KMenu for which to insert a menu item.
 
324
     * @param text   The text for this action.
 
325
     */
 
326
    void insert(const Menu_Type m, KMenu* menu, const QString & text, const bool checkable = false);
247
327
 
248
328
    /**
249
329
     * Shortcut for the most frequently used insertStdItem() calls.
250
330
     *
251
 
     * @param insertLeadingSeparator  Set this true if the group shall
252
 
     *                            start with a separator.
 
331
     * @param insertLeadingSeparator   Set this true if the group shall
 
332
     *                                 start with a separator.
253
333
     * @param type      The Widget_Type for which to insert the menu items.
254
 
     *          If no argument is supplied then a Rename item will be
255
 
     *          included.
 
334
     *                  If no argument is supplied then a Rename item will be
 
335
     *                  included.
256
336
     */
257
337
    void insertStdItems(bool insertLeadingSeparator = true,
258
338
                        Uml::Widget_Type type = Uml::wt_UMLWidget);
270
350
     * Inserts a menu item for an association related text
271
351
     * (such as name, role, multiplicity etc.)
272
352
     *
273
 
     * @param label             The menu text.
274
 
     * @param mt                The menu type.
 
353
     * @param label   The menu text.
 
354
     * @param mt      The menu type.
275
355
     */
276
356
    void insertAssocItem(const QString &label, Menu_Type mt);
277
357
 
293
373
    void makeClassifierPopup(ClassifierWidget *c);
294
374
 
295
375
    /**
 
376
     * Creates a popup menu for a single category Object
 
377
     * @param category The UMLCategory for which the category menu is created
 
378
     */
 
379
    KMenu* makeCategoryTypeMenu(UMLCategory* category);
 
380
 
 
381
    /**
 
382
     * Shortcut for commonly used sub menu initializations.
 
383
     *
 
384
     * @param type   The Menu_Type for which to set up the menu.
 
385
     */
 
386
    void insertSubMenuNew(Menu_Type type);
 
387
 
 
388
    /**
 
389
     * Shortcut for commonly used sub menu initializations.
 
390
     *
 
391
     * @param fc   The "Use Fill Color" is checked.
 
392
     */
 
393
    void insertSubMenuColor(bool fc);
 
394
 
 
395
    /**
 
396
     *
 
397
     */
 
398
    void setupDiagramMenu(UMLView* view);
 
399
 
 
400
    /**
296
401
     * Shortcut for commonly used menu initializations.
297
402
     *
298
 
     * @param type      The Menu_Type for which to set up the menu.
299
 
     * @param view      The UMLView parent of the menu.
300
 
     */
301
 
    void setupMenu(Menu_Type type, UMLView * view = 0);
302
 
 
303
 
    enum PixMap_Type {
304
 
        pm_Class,
305
 
        pm_Package,
306
 
        pm_Interface,
307
 
        pm_Datatype,
308
 
        pm_Enum,
309
 
        pm_Actor,
310
 
        pm_Usecase,
311
 
        pm_InitialState,
312
 
        pm_EndState,
313
 
        pm_Branch,
314
 
        pm_Object,
315
 
        pm_Component,
316
 
        pm_Node,
317
 
        pm_Artifact,
318
 
        pm_Text,
319
 
        pm_Entity,
320
 
        pm_Subsystem,
321
 
        pm_NUMBER_OF_PIXMAPS
322
 
    };
323
 
    QPixmap m_pixmap[pm_NUMBER_OF_PIXMAPS];
324
 
    KPopupMenu * m_pInsert, * m_pShow, * m_pColor;
325
 
    void setupColor(bool fc);
326
 
    void setupColorSelection(bool fc);
327
 
    void setupDiagramMenu(UMLView* view);
 
403
     * @param type   The Menu_Type for which to set up the menu.
 
404
     */
 
405
    void setupMenu(Menu_Type type);
 
406
 
 
407
    /**
 
408
     * Checks the action item.
 
409
     *
 
410
     * @param idx     The Menu_Type for which to check the menu item.
 
411
     * @param value   The value.
 
412
     */
 
413
    void setActionChecked(Menu_Type idx, bool value);
 
414
 
 
415
    /**
 
416
     * The List Popup Menu is triggered by either by right clicking on the
 
417
     * View, a ListViewItem ( Object ) , or a widget
 
418
     */
 
419
    union TriggerObject{
 
420
        UMLView* m_View;
 
421
        UMLObject* m_Object;
 
422
        UMLWidget* m_Widget;
 
423
    };
 
424
 
 
425
    /**
 
426
     * Enum to keep track on TriggerObject Type
 
427
     */
 
428
    enum TriggerObjectType {
 
429
        tot_View,
 
430
        tot_Object,
 
431
        tot_Widget
 
432
    };
 
433
 
 
434
    TriggerObject m_TriggerObject;
 
435
    TriggerObjectType m_TriggerObjectType;
 
436
 
 
437
//    QHash<Menu_Type, KAction*> m_actions;
 
438
    QHash<Menu_Type, QAction*> m_actions;
 
439
 
328
440
};
329
441
 
330
442
#endif