summaryrefslogtreecommitdiff
path: root/libqtaux/qinputdialog.cpp
Side-by-side diff
Diffstat (limited to 'libqtaux/qinputdialog.cpp') (more/less context) (show 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,234 +1,233 @@
/****************************************************************************
** $Id$
**
** Implementation of QInputDialog class
**
** Created : 991212
**
** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
**
** This file is part of the dialogs module of the Qt GUI Toolkit.
**
** This file may be distributed under the terms of the Q Public License
** as defined by Trolltech AS of Norway and appearing in the file
** LICENSE.QPL included in the packaging of this file.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
** licenses may use this file in accordance with the Qt Commercial License
** Agreement provided with the Software.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
** information about Qt Commercial License Agreements.
** See http://www.trolltech.com/qpl/ for QPL licensing information.
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "qinputdialog.h"
#include <qlayout.h>
#include <qlabel.h>
-#include <qlineedit.h>
#include <qpushbutton.h>
#include <qspinbox.h>
#include <qcombobox.h>
#include <qwidgetstack.h>
#include <qvalidator.h>
#include <qapplication.h>
class QInputDialogPrivate
{
public:
friend class QInputDialog;
QLineEdit *lineEdit;
QSpinBox *spinBox;
QComboBox *comboBox, *editComboBox;
QPushButton *ok;
QWidgetStack *stack;
QInputDialog::Type type;
};
/*!
\class QInputDialog qinputdialog.h
\brief A convenience dialog to get a simple input from the user
\ingroup dialogs
The QInputDialog is a simple dialog which can be used if you
need a simple input from the user. This can be text, a number or
an item from a list. Also a label has to be set to tell the user
what he/she should input.
In this Qt version only the 4 static convenience functions
getText(), getInteger(), getDouble() and getItem() of QInputDialog
are available.
Use it like this:
\code
bool ok = FALSE;
QString text = QInputDialog::getText( tr( "Make an input" ), tr( "Please enter your name" ), QString::null, &ok, this );
if ( ok && !text.isEmpty() )
;// user entered something and pressed ok
else
;// user entered nothing or pressed cancel
\endcode
There are more static convenience methods!
\sa getText(), getInteger(), getDouble(), getItem()
*/
/*!
\enum QInputDialog::Type
This enum type specifies the type of the dialog
(which kind of input can be done):
<ul>
<li>\c LineEdit - A QLineEdit is used for taking the input, so a textual or
(e.g. using a QValidator) a numerical input can be done. Using lineEdit()
the QLineEdit can be accessed.
<li>\c SpinBox - A QSpinBox is used for taking the input, so a decimal
input can be done. Using spinBox() the QSpinBox can be accessed.
<li>\c ComboBox - A read-only QComboBox is used for taking the input,
so one item of a list can be chosen. Using comboBox() the QComboBox
can be accessed.
<li>\c EditableComboBox - An editable QComboBox is used for taking the input,
so either one item of a list can be chosen or a text can be entered. Using
editableComboBox() the QComboBox can be accessed.
</ul>
*/
/*!
Constructs the dialog. \a label is the text which is shown to the user (it should mention
to the user what he/she should input), \a parent the parent widget of the dialog, \a name
the name of it and if you set \a modal to TRUE, the dialog pops up modally, else it pops
up modeless. With \a type you specify the type of the dialog.
\sa getText(), getInteger(), getDouble(), getItem()
*/
QInputDialog::QInputDialog( const QString &label, QWidget* parent, const char* name,
bool modal, Type type)
: QDialog( parent, name, modal )
{
if ( parent && parent->icon() &&!parent->icon()->isNull() )
setIcon( *parent->icon() );
else if ( qApp->mainWidget() && qApp->mainWidget()->icon() && !qApp->mainWidget()->icon()->isNull() )
QDialog::setIcon( *qApp->mainWidget()->icon() );
d = new QInputDialogPrivate;
d->lineEdit = 0;
d->spinBox = 0;
d->comboBox = 0;
QVBoxLayout *vbox = new QVBoxLayout( this, 6, 6 );
QLabel* l = new QLabel( label, this );
vbox->addWidget( l );
d->stack = new QWidgetStack( this );
vbox->addWidget( d->stack );
d->lineEdit = new QLineEdit( d->stack );
d->spinBox = new QSpinBox( d->stack );
d->comboBox = new QComboBox( FALSE, d->stack );
d->editComboBox = new QComboBox( TRUE, d->stack );
QHBoxLayout *hbox = new QHBoxLayout( 6 );
vbox->addLayout( hbox, AlignRight );
d->ok = new QPushButton( tr( "&OK" ), this );
d->ok->setDefault( TRUE );
QPushButton *cancel = new QPushButton( tr( "&Cancel" ), this );
QSize bs( d->ok->sizeHint() );
if ( cancel->sizeHint().width() > bs.width() )
bs.setWidth( cancel->sizeHint().width() );
d->ok->setFixedSize( bs );
cancel->setFixedSize( bs );
hbox->addWidget( new QWidget( this ) );
hbox->addWidget( d->ok );
hbox->addWidget( cancel );
connect( d->lineEdit, SIGNAL( returnPressed() ),
this, SLOT( tryAccept() ) );
connect( d->lineEdit, SIGNAL( textChanged(const QString&) ),
this, SLOT( textChanged(const QString&) ) );
connect( d->ok, SIGNAL( clicked() ), this, SLOT( accept() ) );
connect( cancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
resize( QMAX( sizeHint().width(), 400 ), sizeHint().height() );
setType( type );
}
/*!
Returns the line edit, which is used in the LineEdit mode
*/
QLineEdit *QInputDialog::lineEdit() const
{
return d->lineEdit;
}
/*!
Returns the spinbox, which is used in the SpinBox mode
*/
QSpinBox *QInputDialog::spinBox() const
{
return d->spinBox;
}
/*!
Returns the combobox, which is used in the ComboBox mode
*/
QComboBox *QInputDialog::comboBox() const
{
return d->comboBox;
}
/*!
Returns the combobox, which is used in the EditableComboBox mode
*/
QComboBox *QInputDialog::editableComboBox() const
{
return d->editComboBox;
}
/*!
Sets the input type of the dialog to \a t.
*/
void QInputDialog::setType( Type t )
{
switch ( t ) {
case LineEdit:
d->stack->raiseWidget( d->lineEdit );
d->lineEdit->setFocus();
break;
case SpinBox:
d->stack->raiseWidget( d->spinBox );
d->spinBox->setFocus();
break;
case ComboBox:
d->stack->raiseWidget( d->comboBox );
d->comboBox->setFocus();
break;
case EditableComboBox: