BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
qdesigner_dnditem_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the Qt Designer of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
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 BORNAGAIN_GUI_COREGUI_VIEWS_WIDGETBOX_QDESIGNER_DNDITEM_P_H
54 #define BORNAGAIN_GUI_COREGUI_VIEWS_WIDGETBOX_QDESIGNER_DNDITEM_P_H
55 
57 #include <QtDesigner/abstractdnditem.h>
58 
59 #include <QtCore/QList>
60 #include <QtCore/QMimeData>
61 #include <QtCore/QPoint>
62 
63 QT_BEGIN_NAMESPACE
64 
65 class QDrag;
66 class QImage;
67 class QDropEvent;
68 
69 namespace qdesigner_internal {
70 
71 class QDESIGNER_SHARED_EXPORT QDesignerDnDItem : public QDesignerDnDItemInterface {
72 public:
73  explicit QDesignerDnDItem(DropType type, QWidget* source = 0);
74  virtual ~QDesignerDnDItem();
75 
76  virtual DomUI* domUi() const;
77  virtual QWidget* decoration() const;
78  virtual QWidget* widget() const;
79  virtual QPoint hotSpot() const;
80  virtual QWidget* source() const;
81 
82  virtual DropType type() const;
83 
84 protected:
85  void setDomUi(DomUI* dom_ui);
86  void init(DomUI* ui, QWidget* widget, QWidget* decoration, const QPoint& global_mouse_pos);
87 
88 private:
89  QWidget* m_source;
90  const DropType m_type;
91  const QPoint m_globalStartPos;
93  QWidget* m_widget;
94  QWidget* m_decoration;
95  QPoint m_hot_spot;
96 
97  Q_DISABLE_COPY(QDesignerDnDItem)
98 };
99 
100 // Mime data for use with designer drag and drop operations.
101 
102 class QDESIGNER_SHARED_EXPORT QDesignerMimeData : public QMimeData {
103  Q_OBJECT
104 
105 public:
106  typedef QList<QDesignerDnDItemInterface*> QDesignerDnDItems;
107 
109 
110  const QDesignerDnDItems& items() const { return m_items; }
111 
112  // Execute a drag and drop operation.
113  static Qt::DropAction execDrag(const QDesignerDnDItems& items, QWidget* dragSource);
114 
115  QPoint hotSpot() const { return m_hotSpot; }
116 
117  // Move the decoration. Required for drops over form windows as the position
118  // is derived from the decoration position.
119  void moveDecoration(const QPoint& globalPos) const;
120 
121  // For a move operation, create the undo command sequence to remove
122  // the widgets from the source form.
124 
125  // Accept an event with the proper action.
126  void acceptEvent(QDropEvent* e) const;
127 
128  // Helper to accept an event with the desired action.
129  static void acceptEventWithAction(Qt::DropAction desiredAction, QDropEvent* e);
130 
131 private:
132  QDesignerMimeData(const QDesignerDnDItems& items, QDrag* drag);
133  Qt::DropAction proposedDropAction() const;
134 
135  static void setImageTransparency(QImage& image, int alpha);
136 
139  QPoint m_hotSpot;
140 };
141 
142 } // namespace qdesigner_internal
143 
144 QT_END_NAMESPACE
145 
146 #endif // BORNAGAIN_GUI_COREGUI_VIEWS_WIDGETBOX_QDESIGNER_DNDITEM_P_H
Definition: ui4_p.h:160
virtual QPoint hotSpot() const
void init(DomUI *ui, QWidget *widget, QWidget *decoration, const QPoint &global_mouse_pos)
QDesignerDnDItem(DropType type, QWidget *source=0)
virtual QWidget * widget() const
virtual QWidget * decoration() const
virtual DropType type() const
virtual DomUI * domUi() const
virtual QWidget * source() const
static void acceptEventWithAction(Qt::DropAction desiredAction, QDropEvent *e)
void acceptEvent(QDropEvent *e) const
void moveDecoration(const QPoint &globalPos) const
static void setImageTransparency(QImage &image, int alpha)
static Qt::DropAction execDrag(const QDesignerDnDItems &items, QWidget *dragSource)
Qt::DropAction proposedDropAction() const
const QDesignerDnDItems & items() const
QList< QDesignerDnDItemInterface * > QDesignerDnDItems
QDesignerMimeData(const QDesignerDnDItems &items, QDrag *drag)
static void removeMovedWidgetsFromSourceForm(const QDesignerDnDItems &items)
#define QDESIGNER_SHARED_EXPORT