author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 19 Feb 2010 23:40:16 +0200 | |
branch | RCL_3 |
changeset 4 | 3b1da2848fc7 |
parent 0 | 1918ee327afb |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the Qt Designer of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
// |
|
43 |
// W A R N I N G |
|
44 |
// ------------- |
|
45 |
// |
|
46 |
// This file is not part of the Qt API. It exists for the convenience |
|
47 |
// of Qt Designer. This header |
|
48 |
// file may change from version to version without notice, or even be removed. |
|
49 |
// |
|
50 |
// We mean it. |
|
51 |
// |
|
52 |
||
53 |
#ifndef QDESIGNER_TOOLBAR_H |
|
54 |
#define QDESIGNER_TOOLBAR_H |
|
55 |
||
56 |
#include "shared_global_p.h" |
|
57 |
||
58 |
#include <QtGui/QAction> |
|
59 |
#include <QtGui/QToolButton> |
|
60 |
||
61 |
#include <QtCore/QList> |
|
62 |
#include <QtCore/QPoint> |
|
63 |
||
64 |
QT_BEGIN_NAMESPACE |
|
65 |
||
66 |
class QDesignerFormWindowInterface; |
|
67 |
class QToolBar; |
|
68 |
class QRect; |
|
69 |
class QAction; |
|
70 |
||
71 |
namespace qdesigner_internal { |
|
72 |
||
73 |
class PromotionTaskMenu; |
|
74 |
||
75 |
// Special event filter for tool bars in designer. |
|
76 |
// Handles drag and drop to and from. Ensures that each |
|
77 |
// child widget is WA_TransparentForMouseEvents to enable drag and drop. |
|
78 |
||
79 |
class QDESIGNER_SHARED_EXPORT ToolBarEventFilter : public QObject { |
|
80 |
Q_OBJECT |
|
81 |
||
82 |
public: |
|
83 |
static void install(QToolBar *tb); |
|
84 |
||
85 |
// Find action by position. Note that QToolBar::actionAt() will |
|
86 |
// not work as designer sets WA_TransparentForMouseEvents on its tool bar buttons |
|
87 |
// to be able to drag them. This function will return the dummy |
|
88 |
// sentinel action when applied to tool bars created by designer if the position matches. |
|
89 |
static QAction *actionAt(const QToolBar *tb, const QPoint &pos); |
|
90 |
||
91 |
static bool withinHandleArea(const QToolBar *tb, const QPoint &pos); |
|
92 |
static QRect handleArea(const QToolBar *tb); |
|
93 |
static QRect freeArea(const QToolBar *tb); |
|
94 |
||
95 |
// Utility to create an action |
|
96 |
static QAction *createAction(QDesignerFormWindowInterface *fw, const QString &objectName, bool separator); |
|
97 |
||
98 |
virtual bool eventFilter (QObject *watched, QEvent *event); |
|
99 |
||
100 |
// Helper for task menu extension |
|
101 |
QList<QAction *> contextMenuActions(const QPoint &globalPos = QPoint(-1, -1)); |
|
102 |
||
103 |
static ToolBarEventFilter *eventFilterOf(const QToolBar *tb); |
|
104 |
||
105 |
private slots: |
|
106 |
void slotRemoveSelectedAction(); |
|
107 |
void slotRemoveToolBar(); |
|
108 |
void slotInsertSeparator(); |
|
109 |
||
110 |
private: |
|
111 |
explicit ToolBarEventFilter(QToolBar *tb); |
|
112 |
||
113 |
bool handleContextMenuEvent(QContextMenuEvent * event); |
|
114 |
bool handleDragEnterMoveEvent(QDragMoveEvent *event); |
|
115 |
bool handleDragLeaveEvent(QDragLeaveEvent *); |
|
116 |
bool handleDropEvent(QDropEvent *event); |
|
117 |
bool handleMousePressEvent(QMouseEvent *event); |
|
118 |
bool handleMouseReleaseEvent(QMouseEvent *event); |
|
119 |
bool handleMouseMoveEvent(QMouseEvent *event); |
|
120 |
||
121 |
QDesignerFormWindowInterface *formWindow() const; |
|
122 |
void adjustDragIndicator(const QPoint &pos); |
|
123 |
void hideDragIndicator(); |
|
124 |
void startDrag(const QPoint &pos, Qt::KeyboardModifiers modifiers); |
|
125 |
bool withinHandleArea(const QPoint &pos) const; |
|
126 |
||
127 |
QToolBar *m_toolBar; |
|
128 |
PromotionTaskMenu *m_promotionTaskMenu; |
|
129 |
QPoint m_startPosition; |
|
130 |
}; |
|
131 |
} // namespace qdesigner_internal |
|
132 |
||
133 |
QT_END_NAMESPACE |
|
134 |
||
135 |
#endif // QDESIGNER_TOOLBAR_H |