qinputdialog.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
00004 ** All rights reserved.
00005 ** Contact: Nokia Corporation (qt-info@nokia.com)
00006 **
00007 ** This file is part of the QtGui module of the Qt Toolkit.
00008 **
00009 ** $QT_BEGIN_LICENSE:LGPL$
00010 ** Commercial Usage
00011 ** Licensees holding valid Qt Commercial licenses may use this file in
00012 ** accordance with the Qt Commercial License Agreement provided with the
00013 ** Software or, alternatively, in accordance with the terms contained in
00014 ** a written agreement between you and Nokia.
00015 **
00016 ** GNU Lesser General Public License Usage
00017 ** Alternatively, this file may be used under the terms of the GNU Lesser
00018 ** General Public License version 2.1 as published by the Free Software
00019 ** Foundation and appearing in the file LICENSE.LGPL included in the
00020 ** packaging of this file.  Please review the following information to
00021 ** ensure the GNU Lesser General Public License version 2.1 requirements
00022 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
00023 **
00024 ** In addition, as a special exception, Nokia gives you certain additional
00025 ** rights.  These rights are described in the Nokia Qt LGPL Exception
00026 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this module.
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 ** If you have questions regarding the use of this file, please contact
00037 ** Nokia at qt-info@nokia.com.
00038 ** $QT_END_LICENSE$
00039 **
00040 ****************************************************************************/
00041 
00042 #ifndef QINPUTDIALOG_H
00043 #define QINPUTDIALOG_H
00044 
00045 #include <QtGui/qdialog.h>
00046 #include <QtCore/qstring.h>
00047 #include <QtGui/qlineedit.h>
00048 
00049 QT_BEGIN_HEADER
00050 
00051 QT_BEGIN_NAMESPACE
00052 
00053 QT_MODULE(Gui)
00054 
00055 #ifndef QT_NO_INPUTDIALOG
00056 
00057 class QInputDialogPrivate;
00058 
00059 class Q_GUI_EXPORT QInputDialog : public QDialog
00060 {
00061     Q_OBJECT
00062     Q_DECLARE_PRIVATE(QInputDialog)
00063 //  Q_ENUMS(InputMode InputDialogOption)
00064     QDOC_PROPERTY(InputMode inputMode READ inputMode WRITE setInputMode)
00065     QDOC_PROPERTY(QString labelText READ labelText WRITE setLabelText)
00066     QDOC_PROPERTY(InputDialogOptions options READ options WRITE setOptions)
00067     QDOC_PROPERTY(QString textValue READ textValue WRITE setTextValue NOTIFY textValueChanged)
00068     QDOC_PROPERTY(int intValue READ intValue WRITE setIntValue NOTIFY intValueChanged)
00069     QDOC_PROPERTY(int doubleValue READ doubleValue WRITE setDoubleValue NOTIFY doubleValueChanged)
00070     QDOC_PROPERTY(QLineEdit::EchoMode textEchoMode READ textEchoMode WRITE setTextEchoMode)
00071     QDOC_PROPERTY(bool comboBoxEditable READ isComboBoxEditable WRITE setComboBoxEditable)
00072     QDOC_PROPERTY(QStringList comboBoxItems READ comboBoxItems WRITE setComboBoxItems)
00073     QDOC_PROPERTY(int intMinimum READ intMinimum WRITE setIntMinimum)
00074     QDOC_PROPERTY(int intMaximum READ intMaximum WRITE setIntMaximum)
00075     QDOC_PROPERTY(int intStep READ intStep WRITE setIntStep)
00076     QDOC_PROPERTY(double doubleMinimum READ doubleMinimum WRITE setDoubleMinimum)
00077     QDOC_PROPERTY(double doubleMaximum READ doubleMaximum WRITE setDoubleMaximum)
00078     QDOC_PROPERTY(int doubleDecimals READ doubleDecimals WRITE setDoubleDecimals)
00079     QDOC_PROPERTY(QString okButtonText READ okButtonText WRITE setOkButtonText)
00080     QDOC_PROPERTY(QString cancelButtonText READ cancelButtonText WRITE setCancelButtonText)
00081 
00082 public:
00083     enum InputDialogOption {
00084         NoButtons                   = 0x00000001,
00085         UseListViewForComboBoxItems = 0x00000002
00086     };
00087 
00088     Q_DECLARE_FLAGS(InputDialogOptions, InputDialogOption)
00089 
00090     enum InputMode {
00091         TextInput,
00092         IntInput,
00093         DoubleInput
00094     };
00095 
00096     QInputDialog(QWidget *parent = 0, Qt::WindowFlags flags = 0);
00097     ~QInputDialog();
00098 
00099     void setInputMode(InputMode mode);
00100     InputMode inputMode() const;
00101 
00102     void setLabelText(const QString &text);
00103     QString labelText() const;
00104 
00105     void setOption(InputDialogOption option, bool on = true);
00106     bool testOption(InputDialogOption option) const;
00107     void setOptions(InputDialogOptions options);
00108     InputDialogOptions options() const;
00109 
00110     void setTextValue(const QString &text);
00111     QString textValue() const;
00112 
00113     void setTextEchoMode(QLineEdit::EchoMode mode);
00114     QLineEdit::EchoMode textEchoMode() const;
00115 
00116     void setComboBoxEditable(bool editable);
00117     bool isComboBoxEditable() const;
00118 
00119     void setComboBoxItems(const QStringList &items);
00120     QStringList comboBoxItems() const;
00121 
00122     void setIntValue(int value);
00123     int intValue() const;
00124 
00125     void setIntMinimum(int min);
00126     int intMinimum() const;
00127 
00128     void setIntMaximum(int max);
00129     int intMaximum() const;
00130 
00131     void setIntRange(int min, int max);
00132 
00133     void setIntStep(int step);
00134     int intStep() const;
00135 
00136     void setDoubleValue(double value);
00137     double doubleValue() const;
00138 
00139     void setDoubleMinimum(double min);
00140     double doubleMinimum() const;
00141 
00142     void setDoubleMaximum(double max);
00143     double doubleMaximum() const;
00144 
00145     void setDoubleRange(double min, double max);
00146 
00147     void setDoubleDecimals(int decimals);
00148     int doubleDecimals() const;
00149 
00150     void setOkButtonText(const QString &text);
00151     QString okButtonText() const;
00152 
00153     void setCancelButtonText(const QString &text);
00154     QString cancelButtonText() const;
00155 
00156 #ifdef Q_NO_USING_KEYWORD
00157 #ifndef Q_QDOC
00158     void open() { QDialog::open(); }
00159 #endif
00160 #else
00161     using QDialog::open;
00162 #endif
00163     void open(QObject *receiver, const char *member);
00164 
00165     QSize minimumSizeHint() const;
00166     QSize sizeHint() const;
00167 
00168     void setVisible(bool visible);
00169 
00170     static QString getText(QWidget *parent, const QString &title, const QString &label,
00171                            QLineEdit::EchoMode echo = QLineEdit::Normal,
00172                            const QString &text = QString(), bool *ok = 0, Qt::WindowFlags flags = 0);
00173     static int getInt(QWidget *parent, const QString &title, const QString &label, int value = 0,
00174                       int minValue = -2147483647, int maxValue = 2147483647,
00175                       int step = 1, bool *ok = 0, Qt::WindowFlags flags = 0);
00176     static double getDouble(QWidget *parent, const QString &title, const QString &label, double value = 0,
00177                             double minValue = -2147483647, double maxValue = 2147483647,
00178                             int decimals = 1, bool *ok = 0, Qt::WindowFlags flags = 0);
00179     static QString getItem(QWidget *parent, const QString &title, const QString &label,
00180                            const QStringList &items, int current = 0, bool editable = true,
00181                            bool *ok = 0, Qt::WindowFlags flags = 0);
00182 
00183     // obsolete
00184     static int getInteger(QWidget *parent, const QString &title, const QString &label, int value = 0,
00185                           int minValue = -2147483647, int maxValue = 2147483647,
00186                           int step = 1, bool *ok = 0, Qt::WindowFlags flags = 0);
00187 
00188 #ifdef QT3_SUPPORT
00189     inline static QT3_SUPPORT QString getText(const QString &title, const QString &label,
00190                                               QLineEdit::EchoMode echo = QLineEdit::Normal,
00191                                               const QString &text = QString(), bool *ok = 0,
00192                                               QWidget *parent = 0, const char * = 0, Qt::WindowFlags flags = 0)
00193         { return getText(parent, title, label, echo, text, ok, flags); }
00194     inline static QT3_SUPPORT int getInteger(const QString &title, const QString &label, int value = 0,
00195                                              int minValue = -2147483647, int maxValue = 2147483647,
00196                                              int step = 1, bool *ok = 0,
00197                                              QWidget *parent = 0, const char * = 0, Qt::WindowFlags flags = 0)
00198         { return getInteger(parent, title, label, value, minValue, maxValue, step, ok, flags); }
00199     inline static QT3_SUPPORT double getDouble(const QString &title, const QString &label, double value = 0,
00200                                                double minValue = -2147483647, double maxValue = 2147483647,
00201                                                int decimals = 1, bool *ok = 0,
00202                                                QWidget *parent = 0, const char * = 0, Qt::WindowFlags flags = 0)
00203         { return getDouble(parent, title, label, value, minValue, maxValue, decimals, ok, flags); }
00204     inline static QT3_SUPPORT QString getItem(const QString &title, const QString &label, const QStringList &list,
00205                                               int current = 0, bool editable = true, bool *ok = 0,
00206                                               QWidget *parent = 0, const char * = 0, Qt::WindowFlags flags = 0)
00207         { return getItem(parent, title, label, list, current, editable, ok, flags); }
00208 #endif
00209 
00210 Q_SIGNALS:
00211     // ### emit signals!
00212     void textValueChanged(const QString &text);
00213     void textValueSelected(const QString &text);
00214     void intValueChanged(int value);
00215     void intValueSelected(int value);
00216     void doubleValueChanged(double value);
00217     void doubleValueSelected(double value);
00218 
00219 
00220 public:
00221     void done(int result); // ### Qt 5: Make protected.
00222 
00223 private:
00224     Q_DISABLE_COPY(QInputDialog)
00225     Q_PRIVATE_SLOT(d_func(), void _q_textChanged(const QString&))
00226     Q_PRIVATE_SLOT(d_func(), void _q_currentRowChanged(const QModelIndex&, const QModelIndex&))
00227 };
00228 
00229 Q_DECLARE_OPERATORS_FOR_FLAGS(QInputDialog::InputDialogOptions)
00230 
00231 #endif // QT_NO_INPUTDIALOG
00232 
00233 QT_END_NAMESPACE
00234 
00235 QT_END_HEADER
00236 
00237 #endif // QINPUTDIALOG_H