~ubuntu-branches/debian/sid/kdevelop/sid

« back to all changes in this revision

Viewing changes to kdevdesigner/designer/menubareditor.h

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Lainé
  • Date: 2010-05-05 07:21:55 UTC
  • mfrom: (1.2.3 upstream) (5.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100505072155-h78lx19pu04sbhtn
Tags: 4:4.0.0-2
* Upload to unstable (Closes: #579947, #481832).
* Acknowledge obsolete NMU fixes (Closes: #562410, #546961).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**********************************************************************
2
 
** Copyright (C) 2003 Trolltech AS.  All rights reserved.
3
 
**
4
 
** This file is part of Qt Designer.
5
 
**
6
 
** This file may be distributed and/or modified under the terms of the
7
 
** GNU General Public License version 2 as published by the Free Software
8
 
** Foundation and appearing in the file LICENSE.GPL included in the
9
 
** packaging of this file.
10
 
**
11
 
** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
12
 
** licenses may use this file in accordance with the Qt Commercial License
13
 
** Agreement provided with the Software.
14
 
**
15
 
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16
 
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17
 
**
18
 
** See http://www.trolltech.com/gpl/ for GPL licensing information.
19
 
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
20
 
**   information about Qt Commercial License Agreements.
21
 
**
22
 
** Contact info@trolltech.com if any conditions of this licensing are
23
 
** not clear to you.
24
 
**
25
 
**********************************************************************/
26
 
 
27
 
#ifndef MENUBAREDITOR_H
28
 
#define MENUBAREDITOR_H
29
 
 
30
 
#include <qmenubar.h>
31
 
#include <qptrlist.h>
32
 
 
33
 
class PopupMenuEditor;
34
 
class MenuBarEditor;
35
 
class QActionGroup;
36
 
 
37
 
class MenuBarEditorItem : public QObject
38
 
{
39
 
    Q_OBJECT
40
 
 
41
 
    friend class MenuBarEditor;
42
 
 
43
 
    MenuBarEditorItem( MenuBarEditor * bar = 0, QObject * parent = 0, const char * name = 0 );
44
 
    
45
 
public:
46
 
    MenuBarEditorItem( PopupMenuEditor * menu, MenuBarEditor * bar,
47
 
                       QObject * parent = 0, const char * name = 0);
48
 
    MenuBarEditorItem( QActionGroup * actionGroup, MenuBarEditor * bar,
49
 
                       QObject * parent = 0, const char * name = 0);
50
 
    MenuBarEditorItem( MenuBarEditorItem * item,
51
 
                       QObject * parent = 0, const char * name = 0);
52
 
    ~MenuBarEditorItem() { };
53
 
 
54
 
    PopupMenuEditor * menu() { return popupMenu; }
55
 
 
56
 
    void setMenuText( const QString t ) { text = t; };
57
 
    QString menuText() { return text; }
58
 
 
59
 
    void setVisible( bool enable ) { visible = enable; }
60
 
    bool isVisible() { return visible; }
61
 
 
62
 
    void setRemovable( bool enable ) { removable = enable; }
63
 
    bool isRemovable() { return removable; }
64
 
 
65
 
    bool isSeparator() { return separator; }
66
 
protected:
67
 
    void setSeparator( bool enable ) { separator = enable; }
68
 
    
69
 
private:
70
 
    MenuBarEditor * menuBar;
71
 
    PopupMenuEditor * popupMenu;
72
 
    QString text;
73
 
    uint visible : 1;
74
 
    uint separator : 1;
75
 
    uint removable : 1;
76
 
};
77
 
 
78
 
class QLineEdit;
79
 
class FormWindow;
80
 
 
81
 
class MenuBarEditor : public QMenuBar
82
 
{
83
 
    Q_OBJECT
84
 
    
85
 
public:
86
 
    MenuBarEditor( FormWindow * fw, QWidget * parent = 0, const char * name = 0 );
87
 
    ~MenuBarEditor();
88
 
 
89
 
    FormWindow * formWindow();
90
 
 
91
 
    MenuBarEditorItem * createItem( int index = -1, bool addToCmdStack = TRUE );
92
 
    void insertItem( MenuBarEditorItem * item, int index = -1 );
93
 
    void insertItem( QString text, PopupMenuEditor * menu, int index = -1 );
94
 
    void insertItem( QString text, QActionGroup * group, int index = -1 );
95
 
 
96
 
    void insertSeparator( int index = -1 );
97
 
    
98
 
    void removeItemAt( int index );
99
 
    void removeItem( MenuBarEditorItem * item );
100
 
    
101
 
    int findItem( MenuBarEditorItem * item );
102
 
    int findItem( PopupMenuEditor * menu );
103
 
    int findItem( QPoint & pos );
104
 
    
105
 
    MenuBarEditorItem * item( int index = -1 );
106
 
 
107
 
    int count();
108
 
    int current();
109
 
 
110
 
    void cut( int index );
111
 
    void copy( int index );
112
 
    void paste( int index );
113
 
    void exchange( int a, int b );
114
 
 
115
 
    void showLineEdit( int index = -1);
116
 
    void showItem( int index = -1 );
117
 
    void hideItem( int index = -1 );
118
 
    void focusItem( int index = -1 );
119
 
    void deleteItem( int index = -1 );
120
 
 
121
 
    QSize sizeHint() const;
122
 
    QSize minimumSize() const { return sizeHint(); }
123
 
    QSize minimumSizeHint() const { return sizeHint(); }
124
 
    int heightForWidth( int max_width ) const;
125
 
 
126
 
    void show();
127
 
 
128
 
    void checkAccels( QMap<QChar, QWidgetList > &accels );
129
 
 
130
 
public slots:
131
 
    void cut();
132
 
    void copy();
133
 
    void paste();
134
 
    
135
 
protected:
136
 
    bool eventFilter( QObject * o, QEvent * e );
137
 
    void paintEvent( QPaintEvent * e );
138
 
    void mousePressEvent( QMouseEvent * e );
139
 
    void mouseDoubleClickEvent( QMouseEvent * e );
140
 
    void mouseMoveEvent( QMouseEvent * e );
141
 
    void dragEnterEvent( QDragEnterEvent * e );
142
 
    void dragLeaveEvent( QDragLeaveEvent * e );
143
 
    void dragMoveEvent( QDragMoveEvent * e );
144
 
    void dropEvent( QDropEvent * e );
145
 
    void keyPressEvent( QKeyEvent * e );
146
 
    void focusOutEvent( QFocusEvent * e );
147
 
    void resizeEvent( QResizeEvent * e ) { QFrame::resizeEvent( e ); }
148
 
 
149
 
    void resizeInternals();
150
 
    
151
 
    void drawItems( QPainter & p );
152
 
    void drawItem( QPainter & p, MenuBarEditorItem * i, int idx, QPoint & pos );
153
 
    void drawSeparator( QPainter & p, QPoint & pos );
154
 
    
155
 
    QSize itemSize( MenuBarEditorItem * i );
156
 
    void addItemSizeToCoords( MenuBarEditorItem * i, int & x, int & y, int w );
157
 
 
158
 
    QPoint itemPos( int index );
159
 
    QPoint snapToItem( const QPoint & pos );
160
 
    void dropInPlace( MenuBarEditorItem * i, const QPoint & pos );
161
 
 
162
 
    void safeDec();
163
 
    void safeInc();
164
 
 
165
 
    void navigateLeft( bool ctrl );
166
 
    void navigateRight( bool ctrl );
167
 
    void enterEditMode();
168
 
    void leaveEditMode();
169
 
 
170
 
    QPixmap createTextPixmap( const QString &text );
171
 
    int borderSize() const { return margin() + 4; } // add 4 pixels to the margin
172
 
    
173
 
private:
174
 
    FormWindow * formWnd;
175
 
    QLineEdit * lineEdit;
176
 
    QWidget * dropLine;
177
 
    QPtrList<MenuBarEditorItem> itemList;
178
 
    MenuBarEditorItem addItem;
179
 
    MenuBarEditorItem addSeparator;
180
 
    MenuBarEditorItem * draggedItem;
181
 
    QPoint mousePressPos;
182
 
    int currentIndex;
183
 
    int itemHeight;
184
 
    int separatorWidth;
185
 
    bool hideWhenEmpty;
186
 
    bool hasSeparator;
187
 
    bool dropConfirmed;
188
 
    
189
 
    enum ClipboardOperation {
190
 
        None = 0,
191
 
        Cut = 1,
192
 
        Copy = 2
193
 
    };
194
 
    static int clipboardOperation;
195
 
    static MenuBarEditorItem * clipboardItem;
196
 
};
197
 
 
198
 
#endif //MENUBAREDITOR_H