itom  3.0.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 #if QT_VERSION < 0x050000
59  #include <QtGui/QWidget>
60 #else
61  #include <QtWidgets/QWidget>
62 #endif
63 #include <QtCore/QStringList>
64 
65 #if QT_VERSION >= 0x040400
66 QT_BEGIN_NAMESPACE
67 #endif
68 
69 class QMouseEvent;
70 class QCheckBox;
71 class QLineEdit;
72 
74 {
75 public:
77 
78  QStringList cursorShapeNames() const;
79  QMap<int, QIcon> cursorShapeIcons() const;
80  QString cursorToShapeName(const QCursor &cursor) const;
81  QIcon cursorToShapeIcon(const QCursor &cursor) const;
82  int cursorToValue(const QCursor &cursor) const;
83 #ifndef QT_NO_CURSOR
84  QCursor valueToCursor(int value) const;
85 #endif
86 private:
87  void appendCursor(Qt::CursorShape shape, const QString &name, const QIcon &icon);
88  QStringList m_cursorNames;
89  QMap<int, QIcon> m_cursorIcons;
90  QMap<int, Qt::CursorShape> m_valueToCursorShape;
91  QMap<Qt::CursorShape, int> m_cursorShapeToValue;
92 };
93 
95 {
96 public:
97  static QPixmap brushValuePixmap(const QBrush &b);
98  static QIcon brushValueIcon(const QBrush &b);
99  static QString colorValueText(const QColor &c);
100  static QPixmap fontValuePixmap(const QFont &f);
101  static QIcon fontValueIcon(const QFont &f);
102  static QString fontValueText(const QFont &f);
103 };
104 
105 class QtBoolEdit : public QWidget {
106  Q_OBJECT
107 public:
108  QtBoolEdit(QWidget *parent = 0);
109 
110  bool textVisible() const { return m_textVisible; }
111  void setTextVisible(bool textVisible);
112 
113  Qt::CheckState checkState() const;
114  void setCheckState(Qt::CheckState state);
115 
116  bool isChecked() const;
117  void setChecked(bool c);
118 
119  bool blockCheckBoxSignals(bool block);
120 
121 Q_SIGNALS:
122  void toggled(bool);
123 
124 protected:
125  void mousePressEvent(QMouseEvent * event);
126  void paintEvent(QPaintEvent *);
127 
128 private:
129  QCheckBox *m_checkBox;
130  bool m_textVisible;
131 };
132 
133 class QtKeySequenceEdit : public QWidget
134 {
135  Q_OBJECT
136 public:
137  QtKeySequenceEdit(QWidget *parent = 0);
138 
139  QKeySequence keySequence() const;
140  bool eventFilter(QObject *o, QEvent *e);
141 public Q_SLOTS:
142  void setKeySequence(const QKeySequence &sequence);
143 Q_SIGNALS:
144  void keySequenceChanged(const QKeySequence &sequence);
145 protected:
146  void focusInEvent(QFocusEvent *e);
147  void focusOutEvent(QFocusEvent *e);
148  void keyPressEvent(QKeyEvent *e);
149  void keyReleaseEvent(QKeyEvent *e);
150  void paintEvent(QPaintEvent *);
151  bool event(QEvent *e);
152 private slots:
153  void slotClearShortcut();
154 private:
155  void handleKeyEvent(QKeyEvent *e);
156  int translateModifiers(Qt::KeyboardModifiers state, const QString &text) const;
157 
158  int m_num;
159  QKeySequence m_keySequence;
160  QLineEdit *m_lineEdit;
161 };
162 
163 #if QT_VERSION >= 0x040400
164 QT_END_NAMESPACE
165 #endif
166 
167 #endif
Definition: qtpropertybrowserutils_p.h:105
Definition: qtpropertybrowserutils_p.h:94
Definition: qtpropertybrowserutils_p.h:133
Definition: qtpropertybrowserutils_p.h:73