Computer Assited Medical Intervention Tool Kit  version 3.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules 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 #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 
76 {
77 public:
79 
80  QStringList cursorShapeNames() const;
81  QMap<int, QIcon> cursorShapeIcons() const;
82  QString cursorToShapeName(const QCursor &cursor) const;
83  QIcon cursorToShapeIcon(const QCursor &cursor) const;
84  int cursorToValue(const QCursor &cursor) const;
85 #ifndef QT_NO_CURSOR
86  QCursor valueToCursor(int value) const;
87 #endif
88 private:
89  void appendCursor(Qt::CursorShape shape, const QString &name, const QIcon &icon);
90  QStringList m_cursorNames;
91  QMap<int, QIcon> m_cursorIcons;
92  QMap<int, Qt::CursorShape> m_valueToCursorShape;
93  QMap<Qt::CursorShape, int> m_cursorShapeToValue;
94 };
95 
97 {
98 public:
99  static QPixmap brushValuePixmap(const QBrush &b);
100  static QIcon brushValueIcon(const QBrush &b);
101  static QString colorValueText(const QColor &c);
102  static QPixmap fontValuePixmap(const QFont &f);
103  static QIcon fontValueIcon(const QFont &f);
104  static QString fontValueText(const QFont &f);
105 };
106 
107 class QtBoolEdit : public QWidget {
108  Q_OBJECT
109 public:
110  QtBoolEdit(QWidget *parent = 0);
111 
112  bool textVisible() const { return m_textVisible; }
113  void setTextVisible(bool textVisible);
114 
115  Qt::CheckState checkState() const;
116  void setCheckState(Qt::CheckState state);
117 
118  bool isChecked() const;
119  void setChecked(bool c);
120 
121  bool blockCheckBoxSignals(bool block);
122 
123 Q_SIGNALS:
124  void toggled(bool);
125 
126 protected:
127  void mousePressEvent(QMouseEvent * event);
128  void paintEvent(QPaintEvent *);
129 
130 private:
131  QCheckBox *m_checkBox;
133 };
134 
135 class QtKeySequenceEdit : public QWidget
136 {
137  Q_OBJECT
138 public:
139  QtKeySequenceEdit(QWidget *parent = 0);
140 
141  QKeySequence keySequence() const;
142  bool eventFilter(QObject *o, QEvent *e);
143 public Q_SLOTS:
144  void setKeySequence(const QKeySequence &sequence);
145 Q_SIGNALS:
146  void keySequenceChanged(const QKeySequence &sequence);
147 protected:
148  void focusInEvent(QFocusEvent *e);
149  void focusOutEvent(QFocusEvent *e);
150  void keyPressEvent(QKeyEvent *e);
151  void keyReleaseEvent(QKeyEvent *e);
152  void paintEvent(QPaintEvent *);
153  bool event(QEvent *e);
154 private slots:
155  void slotClearShortcut();
156 private:
157  void handleKeyEvent(QKeyEvent *e);
158  int translateModifiers(Qt::KeyboardModifiers state, const QString &text) const;
159 
160  int m_num;
161  QKeySequence m_keySequence;
162  QLineEdit *m_lineEdit;
163 };
164 
165 #if QT_VERSION >= 0x040400
166 QT_END_NAMESPACE
167 #endif
168 
169 #endif
QCheckBox * m_checkBox
Definition: qtpropertybrowserutils_p.h:131
void keyPressEvent(QKeyEvent *e)
int translateModifiers(Qt::KeyboardModifiers state, const QString &text) const
QKeySequence m_keySequence
Definition: qtpropertybrowserutils_p.h:161
QMap< int, Qt::CursorShape > m_valueToCursorShape
Definition: qtpropertybrowserutils_p.h:92
bool textVisible() const
Definition: qtpropertybrowserutils_p.h:112
void setKeySequence(const QKeySequence &sequence)
QString cursorToShapeName(const QCursor &cursor) const
QMap< int, QIcon > m_cursorIcons
Definition: qtpropertybrowserutils_p.h:91
void keySequenceChanged(const QKeySequence &sequence)
void paintEvent(QPaintEvent *)
QKeySequence keySequence() const
static QIcon fontValueIcon(const QFont &f)
void toggled(bool)
void keyReleaseEvent(QKeyEvent *e)
bool event(QEvent *e)
QLineEdit * m_lineEdit
Definition: qtpropertybrowserutils_p.h:162
void paintEvent(QPaintEvent *)
void handleKeyEvent(QKeyEvent *e)
bool blockCheckBoxSignals(bool block)
QStringList m_cursorNames
Definition: qtpropertybrowserutils_p.h:90
void setTextVisible(bool textVisible)
QIcon cursorToShapeIcon(const QCursor &cursor) const
QtKeySequenceEdit(QWidget *parent=0)
void focusOutEvent(QFocusEvent *e)
void slotClearShortcut()
The description of this class will come soon !
Definition: qtpropertybrowserutils_p.h:75
void mousePressEvent(QMouseEvent *event)
Definition: qtpropertybrowserutils_p.h:107
QtBoolEdit(QWidget *parent=0)
QStringList cursorShapeNames() const
QMap< Qt::CursorShape, int > m_cursorShapeToValue
Definition: qtpropertybrowserutils_p.h:93
bool eventFilter(QObject *o, QEvent *e)
static QString fontValueText(const QFont &f)
QMap< int, QIcon > cursorShapeIcons() const
void focusInEvent(QFocusEvent *e)
void appendCursor(Qt::CursorShape shape, const QString &name, const QIcon &icon)
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:96
Definition: qtpropertybrowserutils_p.h:135
bool m_textVisible
Definition: qtpropertybrowserutils_p.h:132
static QPixmap brushValuePixmap(const QBrush &b)
int m_num
Definition: qtpropertybrowserutils_p.h:160