itom  4.1.0
qtpropertybrowserutils_p.h
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 Solutions component.
7 **
8 ** $QT_BEGIN_LICENSE:BSD$
9 ** You may use this file under the terms of the BSD license as follows:
10 **
11 ** "Redistribution and use in source and binary forms, with or without
12 ** modification, are permitted provided that the following conditions are
13 ** met:
14 ** * Redistributions of source code must retain the above copyright
15 ** notice, this list of conditions and the following disclaimer.
16 ** * Redistributions in binary form must reproduce the above copyright
17 ** notice, this list of conditions and the following disclaimer in
18 ** the documentation and/or other materials provided with the
19 ** distribution.
20 ** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
21 ** of its contributors may be used to endorse or promote products derived
22 ** from this software without specific prior written permission.
23 **
24 **
25 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
36 **
37 ** $QT_END_LICENSE$
38 **
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 QTPROPERTYBROWSERUTILS_H
54 #define QTPROPERTYBROWSERUTILS_H
55 
56 #include <QtCore/QMap>
57 #include <QtGui/QIcon>
58 #include <QtWidgets/QWidget>
59 #include <QtCore/QStringList>
60 
61 #if QT_VERSION >= 0x040400
62 QT_BEGIN_NAMESPACE
63 #endif
64 
65 class QMouseEvent;
66 class QCheckBox;
67 class QLineEdit;
68 
70 {
71 public:
73 
74  QStringList cursorShapeNames() const;
75  QMap<int, QIcon> cursorShapeIcons() const;
76  QString cursorToShapeName(const QCursor &cursor) const;
77  QIcon cursorToShapeIcon(const QCursor &cursor) const;
78  int cursorToValue(const QCursor &cursor) const;
79 #ifndef QT_NO_CURSOR
80  QCursor valueToCursor(int value) const;
81 #endif
82 private:
83  void appendCursor(Qt::CursorShape shape, const QString &name, const QIcon &icon);
84  QStringList m_cursorNames;
85  QMap<int, QIcon> m_cursorIcons;
86  QMap<int, Qt::CursorShape> m_valueToCursorShape;
87  QMap<Qt::CursorShape, int> m_cursorShapeToValue;
88 };
89 
91 {
92 public:
93  static QPixmap brushValuePixmap(const QBrush &b);
94  static QIcon brushValueIcon(const QBrush &b);
95  static QString colorValueText(const QColor &c);
96  static QPixmap fontValuePixmap(const QFont &f);
97  static QIcon fontValueIcon(const QFont &f);
98  static QString fontValueText(const QFont &f);
99 };
100 
101 class QtBoolEdit : public QWidget {
102  Q_OBJECT
103 public:
104  QtBoolEdit(QWidget *parent = 0);
105 
106  bool textVisible() const { return m_textVisible; }
107  void setTextVisible(bool textVisible);
108 
109  Qt::CheckState checkState() const;
110  void setCheckState(Qt::CheckState state);
111 
112  bool isChecked() const;
113  void setChecked(bool c);
114 
115  bool blockCheckBoxSignals(bool block);
116 
117 Q_SIGNALS:
118  void toggled(bool);
119 
120 protected:
121  void mousePressEvent(QMouseEvent * event);
122  void paintEvent(QPaintEvent *);
123 
124 private:
125  QCheckBox *m_checkBox;
126  bool m_textVisible;
127 };
128 
129 class QtKeySequenceEdit : public QWidget
130 {
131  Q_OBJECT
132 public:
133  QtKeySequenceEdit(QWidget *parent = 0);
134 
135  QKeySequence keySequence() const;
136  bool eventFilter(QObject *o, QEvent *e);
137 public Q_SLOTS:
138  void setKeySequence(const QKeySequence &sequence);
139 Q_SIGNALS:
140  void keySequenceChanged(const QKeySequence &sequence);
141 protected:
142  void focusInEvent(QFocusEvent *e);
143  void focusOutEvent(QFocusEvent *e);
144  void keyPressEvent(QKeyEvent *e);
145  void keyReleaseEvent(QKeyEvent *e);
146  void paintEvent(QPaintEvent *);
147  bool event(QEvent *e);
148 private slots:
149  void slotClearShortcut();
150 private:
151  void handleKeyEvent(QKeyEvent *e);
152  int translateModifiers(Qt::KeyboardModifiers state, const QString &text) const;
153 
154  int m_num;
155  QKeySequence m_keySequence;
156  QLineEdit *m_lineEdit;
157 };
158 
159 #if QT_VERSION >= 0x040400
160 QT_END_NAMESPACE
161 #endif
162 
163 #endif
Definition: qtpropertybrowserutils_p.h:101
Definition: qtpropertybrowserutils_p.h:90
Definition: qtpropertybrowserutils_p.h:129
Definition: qtpropertybrowserutils_p.h:69