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