OSDN Git Service

It's 2011 now.
[qt-creator-jp/qt-creator-jp.git] / src / plugins / debugger / watchdelegatewidgets.h
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
8 **
9 ** No Commercial Usage
10 **
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
14 ** this package.
15 **
16 ** GNU Lesser General Public License Usage
17 **
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file.  Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights.  These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
31 **
32 **************************************************************************/
33
34 #ifndef WATCHDELEGATEEDITS_H
35 #define WATCHDELEGATEEDITS_H
36
37 #include <QtGui/QLineEdit>
38 #include <QtGui/QComboBox>
39 #include <QtCore/QVariant>
40
41 namespace Debugger {
42 namespace Internal {
43 class IntegerValidator;
44
45 /* Watch edit widgets. The logic is based on the QVariant 'modelData' property,
46  * which is accessed by the WatchDelegate. */
47
48 /* WatchLineEdit: Base class for Watch delegate line edits with
49  * ready-made accessors for the model's QVariants for QString-text use. */
50 class WatchLineEdit : public QLineEdit
51 {
52     Q_OBJECT
53     Q_PROPERTY(QString text READ text WRITE setText USER false)
54     Q_PROPERTY(QVariant modelData READ modelData WRITE setModelData DESIGNABLE false USER true)
55 public:
56     explicit WatchLineEdit(QWidget *parent = 0);
57
58     // Ready-made accessors for item views passing QVariants around
59     virtual QVariant modelData() const;
60     virtual void setModelData(const QVariant &);
61
62     static WatchLineEdit *create(QVariant::Type t, QWidget *parent = 0);
63 };
64
65 /* Watch delegate line edit for integer numbers based on quint64/qint64.
66  * Does validation using the given number base (10, 16, 8, 2) and signedness.
67  * isBigInt() indicates that no checking for number conversion is to be performed
68  * (that is, value cannot be handled as quint64/qint64, for 128bit registers, etc). */
69 class IntegerWatchLineEdit : public WatchLineEdit
70 {
71     Q_OBJECT
72     Q_PROPERTY(int base READ base WRITE setBase DESIGNABLE true)
73     Q_PROPERTY(bool Signed READ isSigned WRITE setSigned DESIGNABLE true)
74     Q_PROPERTY(bool bigInt READ isBigInt WRITE setBigInt DESIGNABLE true)
75 public:
76     explicit IntegerWatchLineEdit(QWidget *parent = 0);
77
78     // Ready-made accessors for item views passing QVariants around
79     virtual QVariant modelData() const;
80     virtual void setModelData(const QVariant &);
81
82     int base() const;
83     void setBase(int b);
84     bool isSigned() const;
85     void setSigned(bool s);
86     bool isBigInt() const;
87     void setBigInt(bool b);
88
89     static bool isUnsignedHexNumber(const QString &v);
90
91 private:
92     void setNumberText(const QString &);
93     inline QVariant modelDataI() const;
94     IntegerValidator *m_validator;
95 };
96
97 /* Float line edit */
98 class FloatWatchLineEdit : public WatchLineEdit
99 {
100 public:
101     explicit FloatWatchLineEdit(QWidget *parent = 0);
102
103     virtual QVariant modelData() const;
104     virtual void setModelData(const QVariant &);
105 };
106
107 /* Combo box for booleans */
108 class BooleanComboBox : public QComboBox
109 {
110     Q_OBJECT
111     Q_PROPERTY(QVariant modelData READ modelData WRITE setModelData DESIGNABLE false USER true)
112 public:
113     explicit BooleanComboBox(QWidget *parent = 0);
114
115     virtual QVariant modelData() const;
116     virtual void setModelData(const QVariant &);
117 };
118
119 } // namespace Internal
120 } // namespace Debugger
121
122 #endif // WATCHDELEGATEEDITS_H