summaryrefslogtreecommitdiff
path: root/libqtaux/qinputdialog.cpp
Unidiff
Diffstat (limited to 'libqtaux/qinputdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libqtaux/qinputdialog.cpp1
1 files changed, 0 insertions, 1 deletions
diff --git a/libqtaux/qinputdialog.cpp b/libqtaux/qinputdialog.cpp
index 821c74d..43e243f 100644
--- a/libqtaux/qinputdialog.cpp
+++ b/libqtaux/qinputdialog.cpp
@@ -1,138 +1,137 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Implementation of QInputDialog class 4** Implementation of QInputDialog class
5** 5**
6** Created : 991212 6** Created : 991212
7** 7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. 8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
9** 9**
10** This file is part of the dialogs module of the Qt GUI Toolkit. 10** This file is part of the dialogs module of the Qt GUI Toolkit.
11** 11**
12** This file may be distributed under the terms of the Q Public License 12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file. 14** LICENSE.QPL included in the packaging of this file.
15** 15**
16** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License 22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software. 23** Agreement provided with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37 37
38#include "qinputdialog.h" 38#include "qinputdialog.h"
39 39
40#include <qlayout.h> 40#include <qlayout.h>
41#include <qlabel.h> 41#include <qlabel.h>
42#include <qlineedit.h>
43#include <qpushbutton.h> 42#include <qpushbutton.h>
44#include <qspinbox.h> 43#include <qspinbox.h>
45#include <qcombobox.h> 44#include <qcombobox.h>
46#include <qwidgetstack.h> 45#include <qwidgetstack.h>
47#include <qvalidator.h> 46#include <qvalidator.h>
48#include <qapplication.h> 47#include <qapplication.h>
49 48
50class QInputDialogPrivate 49class QInputDialogPrivate
51{ 50{
52public: 51public:
53 friend class QInputDialog; 52 friend class QInputDialog;
54 QLineEdit *lineEdit; 53 QLineEdit *lineEdit;
55 QSpinBox *spinBox; 54 QSpinBox *spinBox;
56 QComboBox *comboBox, *editComboBox; 55 QComboBox *comboBox, *editComboBox;
57 QPushButton *ok; 56 QPushButton *ok;
58 QWidgetStack *stack; 57 QWidgetStack *stack;
59 QInputDialog::Type type; 58 QInputDialog::Type type;
60}; 59};
61 60
62/*! 61/*!
63 \class QInputDialog qinputdialog.h 62 \class QInputDialog qinputdialog.h
64 \brief A convenience dialog to get a simple input from the user 63 \brief A convenience dialog to get a simple input from the user
65 \ingroup dialogs 64 \ingroup dialogs
66 65
67 The QInputDialog is a simple dialog which can be used if you 66 The QInputDialog is a simple dialog which can be used if you
68 need a simple input from the user. This can be text, a number or 67 need a simple input from the user. This can be text, a number or
69 an item from a list. Also a label has to be set to tell the user 68 an item from a list. Also a label has to be set to tell the user
70 what he/she should input. 69 what he/she should input.
71 70
72 In this Qt version only the 4 static convenience functions 71 In this Qt version only the 4 static convenience functions
73 getText(), getInteger(), getDouble() and getItem() of QInputDialog 72 getText(), getInteger(), getDouble() and getItem() of QInputDialog
74 are available. 73 are available.
75 74
76 Use it like this: 75 Use it like this:
77 76
78 \code 77 \code
79 bool ok = FALSE; 78 bool ok = FALSE;
80 QString text = QInputDialog::getText( tr( "Make an input" ), tr( "Please enter your name" ), QString::null, &ok, this ); 79 QString text = QInputDialog::getText( tr( "Make an input" ), tr( "Please enter your name" ), QString::null, &ok, this );
81 if ( ok && !text.isEmpty() ) 80 if ( ok && !text.isEmpty() )
82 ;// user entered something and pressed ok 81 ;// user entered something and pressed ok
83 else 82 else
84 ;// user entered nothing or pressed cancel 83 ;// user entered nothing or pressed cancel
85 \endcode 84 \endcode
86 85
87 There are more static convenience methods! 86 There are more static convenience methods!
88 87
89 \sa getText(), getInteger(), getDouble(), getItem() 88 \sa getText(), getInteger(), getDouble(), getItem()
90*/ 89*/
91 90
92/*! 91/*!
93 \enum QInputDialog::Type 92 \enum QInputDialog::Type
94 93
95 This enum type specifies the type of the dialog 94 This enum type specifies the type of the dialog
96 (which kind of input can be done): 95 (which kind of input can be done):
97 96
98 <ul> 97 <ul>
99 <li>\c LineEdit - A QLineEdit is used for taking the input, so a textual or 98 <li>\c LineEdit - A QLineEdit is used for taking the input, so a textual or
100 (e.g. using a QValidator) a numerical input can be done. Using lineEdit() 99 (e.g. using a QValidator) a numerical input can be done. Using lineEdit()
101 the QLineEdit can be accessed. 100 the QLineEdit can be accessed.
102 <li>\c SpinBox - A QSpinBox is used for taking the input, so a decimal 101 <li>\c SpinBox - A QSpinBox is used for taking the input, so a decimal
103 input can be done. Using spinBox() the QSpinBox can be accessed. 102 input can be done. Using spinBox() the QSpinBox can be accessed.
104 <li>\c ComboBox - A read-only QComboBox is used for taking the input, 103 <li>\c ComboBox - A read-only QComboBox is used for taking the input,
105 so one item of a list can be chosen. Using comboBox() the QComboBox 104 so one item of a list can be chosen. Using comboBox() the QComboBox
106 can be accessed. 105 can be accessed.
107 <li>\c EditableComboBox - An editable QComboBox is used for taking the input, 106 <li>\c EditableComboBox - An editable QComboBox is used for taking the input,
108 so either one item of a list can be chosen or a text can be entered. Using 107 so either one item of a list can be chosen or a text can be entered. Using
109 editableComboBox() the QComboBox can be accessed. 108 editableComboBox() the QComboBox can be accessed.
110 </ul> 109 </ul>
111*/ 110*/
112 111
113/*! 112/*!
114 Constructs the dialog. \a label is the text which is shown to the user (it should mention 113 Constructs the dialog. \a label is the text which is shown to the user (it should mention
115 to the user what he/she should input), \a parent the parent widget of the dialog, \a name 114 to the user what he/she should input), \a parent the parent widget of the dialog, \a name
116 the name of it and if you set \a modal to TRUE, the dialog pops up modally, else it pops 115 the name of it and if you set \a modal to TRUE, the dialog pops up modally, else it pops
117 up modeless. With \a type you specify the type of the dialog. 116 up modeless. With \a type you specify the type of the dialog.
118 117
119 \sa getText(), getInteger(), getDouble(), getItem() 118 \sa getText(), getInteger(), getDouble(), getItem()
120*/ 119*/
121 120
122QInputDialog::QInputDialog( const QString &label, QWidget* parent, const char* name, 121QInputDialog::QInputDialog( const QString &label, QWidget* parent, const char* name,
123 bool modal, Type type) 122 bool modal, Type type)
124 : QDialog( parent, name, modal ) 123 : QDialog( parent, name, modal )
125{ 124{
126 if ( parent && parent->icon() &&!parent->icon()->isNull() ) 125 if ( parent && parent->icon() &&!parent->icon()->isNull() )
127 setIcon( *parent->icon() ); 126 setIcon( *parent->icon() );
128 else if ( qApp->mainWidget() && qApp->mainWidget()->icon() && !qApp->mainWidget()->icon()->isNull() ) 127 else if ( qApp->mainWidget() && qApp->mainWidget()->icon() && !qApp->mainWidget()->icon()->isNull() )
129 QDialog::setIcon( *qApp->mainWidget()->icon() ); 128 QDialog::setIcon( *qApp->mainWidget()->icon() );
130 129
131 d = new QInputDialogPrivate; 130 d = new QInputDialogPrivate;
132 d->lineEdit = 0; 131 d->lineEdit = 0;
133 d->spinBox = 0; 132 d->spinBox = 0;
134 d->comboBox = 0; 133 d->comboBox = 0;
135 134
136 QVBoxLayout *vbox = new QVBoxLayout( this, 6, 6 ); 135 QVBoxLayout *vbox = new QVBoxLayout( this, 6, 6 );
137 136
138 QLabel* l = new QLabel( label, this ); 137 QLabel* l = new QLabel( label, this );