00001 /**************************************************************************** 00002 ** 00003 ** This file is part of a Qt Solutions component. 00004 ** 00005 ** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 00006 ** 00007 ** Contact: Qt Software Information (qt-info@nokia.com) 00008 ** 00009 ** Commercial Usage 00010 ** Licensees holding valid Qt Commercial licenses may use this file in 00011 ** accordance with the Qt Solutions Commercial License Agreement provided 00012 ** with the Software or, alternatively, in accordance with the terms 00013 ** contained in a written agreement between you and Nokia. 00014 ** 00015 ** GNU Lesser General Public License Usage 00016 ** Alternatively, this file may be used under the terms of the GNU Lesser 00017 ** General Public License version 2.1 as published by the Free Software 00018 ** Foundation and appearing in the file LICENSE.LGPL included in the 00019 ** packaging of this file. Please review the following information to 00020 ** ensure the GNU Lesser General Public License version 2.1 requirements 00021 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 00022 ** 00023 ** In addition, as a special exception, Nokia gives you certain 00024 ** additional rights. These rights are described in the Nokia Qt LGPL 00025 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 00026 ** package. 00027 ** 00028 ** GNU General Public License Usage 00029 ** Alternatively, this file may be used under the terms of the GNU 00030 ** General Public License version 3.0 as published by the Free Software 00031 ** Foundation and appearing in the file LICENSE.GPL included in the 00032 ** packaging of this file. Please review the following information to 00033 ** ensure the GNU General Public License version 3.0 requirements will be 00034 ** met: http://www.gnu.org/copyleft/gpl.html. 00035 ** 00036 ** Please note Third Party Software included with Qt Solutions may impose 00037 ** additional restrictions and it is the user's responsibility to ensure 00038 ** that they have met the licensing requirements of the GPL, LGPL, or Qt 00039 ** Solutions Commercial license and the relevant license of the Third 00040 ** Party Software they are using. 00041 ** 00042 ** If you are unsure which license is appropriate for your use, please 00043 ** contact the sales department at qt-sales@nokia.com. 00044 ** 00045 ****************************************************************************/ 00046 00047 /**************************************************************************** 00048 ** 00049 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 00050 ** Contact: Qt Software Information (qt-info@nokia.com) 00051 ** 00052 ** This file is part of the tools applications of the Qt Toolkit. 00053 ** 00054 ** $QT_BEGIN_LICENSE:LGPL$ 00055 ** No Commercial Usage 00056 ** This file contains pre-release code and may not be distributed. 00057 ** You may use this file in accordance with the terms and conditions 00058 ** contained in the either Technology Preview License Agreement or the 00059 ** Beta Release License Agreement. 00060 ** 00061 ** GNU Lesser General Public License Usage 00062 ** Alternatively, this file may be used under the terms of the GNU Lesser 00063 ** General Public License version 2.1 as published by the Free Software 00064 ** Foundation and appearing in the file LICENSE.LGPL included in the 00065 ** packaging of this file. Please review the following information to 00066 ** ensure the GNU Lesser General Public License version 2.1 requirements 00067 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 00068 ** 00069 ** In addition, as a special exception, Nokia gives you certain 00070 ** additional rights. These rights are described in the Nokia Qt LGPL 00071 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 00072 ** package. 00073 ** 00074 ** GNU General Public License Usage 00075 ** Alternatively, this file may be used under the terms of the GNU 00076 ** General Public License version 3.0 as published by the Free Software 00077 ** Foundation and appearing in the file LICENSE.GPL included in the 00078 ** packaging of this file. Please review the following information to 00079 ** ensure the GNU General Public License version 3.0 requirements will be 00080 ** met: http://www.gnu.org/copyleft/gpl.html. 00081 ** 00082 ** If you are unsure which license is appropriate for your use, please 00083 ** contact the sales department at qt-sales@nokia.com. 00084 ** $QT_END_LICENSE$ 00085 ** 00086 ****************************************************************************/ 00087 00088 // 00089 // W A R N I N G 00090 // ------------- 00091 // 00092 // This file is not part of the Qt API. It exists for the convenience 00093 // of Qt Designer. This header 00094 // file may change from version to version without notice, or even be removed. 00095 // 00096 // We mean it. 00097 // 00098 00099 #ifndef QTPROPERTYBROWSERUTILS_H 00100 #define QTPROPERTYBROWSERUTILS_H 00101 00102 #include <QtCore/QMap> 00103 #include <QtGui/QIcon> 00104 #include <QtGui/QWidget> 00105 #include <QtCore/QStringList> 00106 00107 #if QT_VERSION >= 0x040400 00108 QT_BEGIN_NAMESPACE 00109 #endif 00110 00111 class QMouseEvent; 00112 class QCheckBox; 00113 class QLineEdit; 00114 00115 class QtCursorDatabase 00116 { 00117 public: 00118 QtCursorDatabase(); 00119 00120 QStringList cursorShapeNames() const; 00121 QMap<int, QIcon> cursorShapeIcons() const; 00122 QString cursorToShapeName(const QCursor &cursor) const; 00123 QIcon cursorToShapeIcon(const QCursor &cursor) const; 00124 int cursorToValue(const QCursor &cursor) const; 00125 #ifndef QT_NO_CURSOR 00126 QCursor valueToCursor(int value) const; 00127 #endif 00128 private: 00129 void appendCursor(Qt::CursorShape shape, const QString &name, const QIcon &icon); 00130 QStringList m_cursorNames; 00131 QMap<int, QIcon> m_cursorIcons; 00132 QMap<int, Qt::CursorShape> m_valueToCursorShape; 00133 QMap<Qt::CursorShape, int> m_cursorShapeToValue; 00134 }; 00135 00136 class QtPropertyBrowserUtils 00137 { 00138 public: 00139 static QPixmap brushValuePixmap(const QBrush &b); 00140 static QIcon brushValueIcon(const QBrush &b); 00141 static QString colorValueText(const QColor &c); 00142 static QPixmap fontValuePixmap(const QFont &f); 00143 static QIcon fontValueIcon(const QFont &f); 00144 static QString fontValueText(const QFont &f); 00145 }; 00146 00147 class QtBoolEdit : public QWidget { 00148 Q_OBJECT 00149 public: 00150 QtBoolEdit(QWidget *parent = 0); 00151 00152 bool textVisible() const { return m_textVisible; } 00153 void setTextVisible(bool textVisible); 00154 00155 Qt::CheckState checkState() const; 00156 void setCheckState(Qt::CheckState state); 00157 00158 bool isChecked() const; 00159 void setChecked(bool c); 00160 00161 bool blockCheckBoxSignals(bool block); 00162 00163 Q_SIGNALS: 00164 void toggled(bool); 00165 00166 protected: 00167 void mousePressEvent(QMouseEvent * event); 00168 00169 private: 00170 QCheckBox *m_checkBox; 00171 bool m_textVisible; 00172 }; 00173 00174 class QtKeySequenceEdit : public QWidget 00175 { 00176 Q_OBJECT 00177 public: 00178 QtKeySequenceEdit(QWidget *parent = 0); 00179 00180 QKeySequence keySequence() const; 00181 bool eventFilter(QObject *o, QEvent *e); 00182 public Q_SLOTS: 00183 void setKeySequence(const QKeySequence &sequence); 00184 Q_SIGNALS: 00185 void keySequenceChanged(const QKeySequence &sequence); 00186 protected: 00187 void focusInEvent(QFocusEvent *e); 00188 void focusOutEvent(QFocusEvent *e); 00189 void keyPressEvent(QKeyEvent *e); 00190 void keyReleaseEvent(QKeyEvent *e); 00191 bool event(QEvent *e); 00192 private slots: 00193 void slotClearShortcut(); 00194 private: 00195 void handleKeyEvent(QKeyEvent *e); 00196 int translateModifiers(Qt::KeyboardModifiers state, const QString &text) const; 00197 00198 int m_num; 00199 QKeySequence m_keySequence; 00200 QLineEdit *m_lineEdit; 00201 }; 00202 00203 #if QT_VERSION >= 0x040400 00204 QT_END_NAMESPACE 00205 #endif 00206 00207 #endif