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