Computer Assited Medical Intervention Tool Kit  version 5.0
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 <QMap>
56 #include <QIcon>
57 #include <QWidget>
58 #include <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 public:
78 
79  QStringList cursorShapeNames() const;
80  QMap<int, QIcon> cursorShapeIcons() const;
81  QString cursorToShapeName(const QCursor& cursor) const;
82  QIcon cursorToShapeIcon(const QCursor& cursor) const;
83  int cursorToValue(const QCursor& cursor) const;
84 #ifndef QT_NO_CURSOR
85  QCursor valueToCursor(int value) const;
86 #endif
87 private:
88  void appendCursor(Qt::CursorShape shape, const QString& name, const QIcon& icon);
89  QStringList m_cursorNames;
90  QMap<int, QIcon> m_cursorIcons;
91  QMap<int, Qt::CursorShape> m_valueToCursorShape;
92  QMap<Qt::CursorShape, int> m_cursorShapeToValue;
93 };
94 
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 = nullptr);
109 
110  bool textVisible() const {
111  return m_textVisible;
112  }
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) override;
128  void paintEvent(QPaintEvent*) override;
129 
130 private:
131  QCheckBox* m_checkBox;
132  bool m_textVisible{true};
133 };
134 
135 class QtKeySequenceEdit : public QWidget {
136  Q_OBJECT
137 public:
138  QtKeySequenceEdit(QWidget* parent = nullptr);
139 
140  QKeySequence keySequence() const;
141  bool eventFilter(QObject* o, QEvent* e) override;
142 public Q_SLOTS:
143  void setKeySequence(const QKeySequence& sequence);
144 Q_SIGNALS:
145  void keySequenceChanged(const QKeySequence& sequence);
146 protected:
147  void focusInEvent(QFocusEvent* e) override;
148  void focusOutEvent(QFocusEvent* e) override;
149  void keyPressEvent(QKeyEvent* e) override;
150  void keyReleaseEvent(QKeyEvent* e) override;
151  void paintEvent(QPaintEvent*) override;
152  bool event(QEvent* e) override;
153 private slots:
154  void slotClearShortcut();
155 private:
156  void handleKeyEvent(QKeyEvent* e);
157  int translateModifiers(Qt::KeyboardModifiers state, const QString& text) const;
158 
159  int m_num{0};
160  QKeySequence m_keySequence;
161  QLineEdit* m_lineEdit;
162 };
163 
164 #if QT_VERSION >= 0x040400
165 QT_END_NAMESPACE
166 #endif
167 
168 #endif
QtKeySequenceEdit::m_keySequence
QKeySequence m_keySequence
Definition: qtpropertybrowserutils_p.h:160
QtBoolEdit
Definition: qtpropertybrowserutils_p.h:105
QtPropertyBrowserUtils
Definition: qtpropertybrowserutils_p.h:95
QtPropertyBrowserUtils::colorValueText
static QString colorValueText(const QColor &c)
Definition: qtpropertybrowserutils.cpp:151
QtKeySequenceEdit::focusInEvent
void focusInEvent(QFocusEvent *e) override
Definition: qtpropertybrowserutils.cpp:388
QtBoolEdit::setChecked
void setChecked(bool c)
Definition: qtpropertybrowserutils.cpp:228
qtpropertybrowserutils_p.h
QtKeySequenceEdit::paintEvent
void paintEvent(QPaintEvent *) override
Definition: qtpropertybrowserutils.cpp:409
QtPropertyBrowserUtils::brushValuePixmap
static QPixmap brushValuePixmap(const QBrush &b)
Definition: qtpropertybrowserutils.cpp:128
QtCursorDatabase::m_cursorShapeToValue
QMap< Qt::CursorShape, int > m_cursorShapeToValue
Definition: qtpropertybrowserutils_p.h:92
QtBoolEdit::toggled
void toggled(bool)
QtCursorDatabase::appendCursor
void appendCursor(Qt::CursorShape shape, const QString &name, const QIcon &icon)
Definition: qtpropertybrowserutils.cpp:77
QtKeySequenceEdit::keySequence
QKeySequence keySequence() const
Definition: qtpropertybrowserutils.cpp:367
QtCursorDatabase::valueToCursor
QCursor valueToCursor(int value) const
Definition: qtpropertybrowserutils.cpp:120
QtBoolEdit::setTextVisible
void setTextVisible(bool textVisible)
Definition: qtpropertybrowserutils.cpp:202
QtKeySequenceEdit
Definition: qtpropertybrowserutils_p.h:135
camitk::mousePressEvent
void mousePressEvent(QMouseEvent *event) override
mouse press handler overriden to manage different version of VTK
QtKeySequenceEdit::setKeySequence
void setKeySequence(const QKeySequence &sequence)
Definition: qtpropertybrowserutils.cpp:358
QtKeySequenceEdit::keySequenceChanged
void keySequenceChanged(const QKeySequence &sequence)
QtPropertyBrowserUtils::fontValueText
static QString fontValueText(const QFont &f)
Definition: qtpropertybrowserutils.cpp:178
QtKeySequenceEdit::event
bool event(QEvent *e) override
Definition: qtpropertybrowserutils.cpp:416
QtKeySequenceEdit::slotClearShortcut
void slotClearShortcut()
Definition: qtpropertybrowserutils.cpp:305
QtCursorDatabase::cursorShapeNames
QStringList cursorShapeNames() const
Definition: qtpropertybrowserutils.cpp:88
QtCursorDatabase::cursorToShapeIcon
QIcon cursorToShapeIcon(const QCursor &cursor) const
Definition: qtpropertybrowserutils.cpp:104
QtKeySequenceEdit::focusOutEvent
void focusOutEvent(QFocusEvent *e) override
Definition: qtpropertybrowserutils.cpp:394
QtKeySequenceEdit::handleKeyEvent
void handleKeyEvent(QKeyEvent *e)
Definition: qtpropertybrowserutils.cpp:313
QtKeySequenceEdit::keyReleaseEvent
void keyReleaseEvent(QKeyEvent *e) override
Definition: qtpropertybrowserutils.cpp:405
QtCursorDatabase
The description of this class will come soon !
Definition: qtpropertybrowserutils_p.h:75
QtCursorDatabase::QtCursorDatabase
QtCursorDatabase()
Definition: qtpropertybrowserutils.cpp:55
QtKeySequenceEdit::m_lineEdit
QLineEdit * m_lineEdit
Definition: qtpropertybrowserutils_p.h:161
QtCursorDatabase::cursorShapeIcons
QMap< int, QIcon > cursorShapeIcons() const
Definition: qtpropertybrowserutils.cpp:92
QtBoolEdit::QtBoolEdit
QtBoolEdit(QWidget *parent=nullptr)
Definition: qtpropertybrowserutils.cpp:185
QtKeySequenceEdit::keyPressEvent
void keyPressEvent(QKeyEvent *e) override
Definition: qtpropertybrowserutils.cpp:400
QtKeySequenceEdit::QtKeySequenceEdit
QtKeySequenceEdit(QWidget *parent=nullptr)
Definition: qtpropertybrowserutils.cpp:259
QtKeySequenceEdit::eventFilter
bool eventFilter(QObject *o, QEvent *e) override
Definition: qtpropertybrowserutils.cpp:271
QtBoolEdit::paintEvent
void paintEvent(QPaintEvent *) override
Definition: qtpropertybrowserutils.cpp:250
QtKeySequenceEdit::translateModifiers
int translateModifiers(Qt::KeyboardModifiers state, const QString &text) const
Definition: qtpropertybrowserutils.cpp:371
QtCursorDatabase::m_cursorIcons
QMap< int, QIcon > m_cursorIcons
Definition: qtpropertybrowserutils_p.h:90
QtCursorDatabase::m_valueToCursorShape
QMap< int, Qt::CursorShape > m_valueToCursorShape
Definition: qtpropertybrowserutils_p.h:91
QtBoolEdit::checkState
Qt::CheckState checkState() const
Definition: qtpropertybrowserutils.cpp:216
QtBoolEdit::m_textVisible
bool m_textVisible
Definition: qtpropertybrowserutils_p.h:132
QtBoolEdit::blockCheckBoxSignals
bool blockCheckBoxSignals(bool block)
Definition: qtpropertybrowserutils.cpp:236
QtBoolEdit::mousePressEvent
void mousePressEvent(QMouseEvent *event) override
Definition: qtpropertybrowserutils.cpp:240
QtBoolEdit::textVisible
bool textVisible() const
Definition: qtpropertybrowserutils_p.h:110
QtCursorDatabase::cursorToShapeName
QString cursorToShapeName(const QCursor &cursor) const
Definition: qtpropertybrowserutils.cpp:96
QtBoolEdit::isChecked
bool isChecked() const
Definition: qtpropertybrowserutils.cpp:224
QtPropertyBrowserUtils::brushValueIcon
static QIcon brushValueIcon(const QBrush &b)
Definition: qtpropertybrowserutils.cpp:147
QtCursorDatabase::m_cursorNames
QStringList m_cursorNames
Definition: qtpropertybrowserutils_p.h:89
QtPropertyBrowserUtils::fontValuePixmap
static QPixmap fontValuePixmap(const QFont &f)
Definition: qtpropertybrowserutils.cpp:159
QtCursorDatabase::cursorToValue
int cursorToValue(const QCursor &cursor) const
Definition: qtpropertybrowserutils.cpp:109
QtKeySequenceEdit::m_num
int m_num
Definition: qtpropertybrowserutils_p.h:159
QtBoolEdit::m_checkBox
QCheckBox * m_checkBox
Definition: qtpropertybrowserutils_p.h:131
QtBoolEdit::setCheckState
void setCheckState(Qt::CheckState state)
Definition: qtpropertybrowserutils.cpp:220
QtPropertyBrowserUtils::fontValueIcon
static QIcon fontValueIcon(const QFont &f)
Definition: qtpropertybrowserutils.cpp:174