1
/* This file is part of the KDE project
2
Copyright (C) 2004 Jarosław Staniek <staniek@kde.org>
4
This library is free software; you can redistribute it and/or
5
modify it under the terms of the GNU Library General Public
6
License as published by the Free Software Foundation; either
7
version 2 of the License, or (at your option) any later version.
9
This library is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
Library General Public License for more details.
14
You should have received a copy of the GNU Library General Public License
15
along with this library; see the file COPYING.LIB. If not, write to
16
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17
* Boston, MA 02110-1301, USA.
20
#include "kexinamedialog.h"
22
#include <QGridLayout>
25
KexiNameDialog::KexiNameDialog(
26
const QString& message, QWidget * parent)
29
setMainWidget(new QWidget(this));
30
m_widget = new KexiNameWidget(message, mainWidget());
34
KexiNameDialog::KexiNameDialog(const QString& message,
35
const QString& nameLabel, const QString& nameText,
36
const QString& captionLabel, const QString& captionText,
40
setMainWidget(new QWidget(this));
41
m_widget = new KexiNameWidget(message, nameLabel, nameText,
42
captionLabel, captionText, mainWidget());
46
KexiNameDialog::~KexiNameDialog()
50
void KexiNameDialog::init()
52
setButtons(Ok | Cancel | Help);
53
QGridLayout *lyr = new QGridLayout(mainWidget());
54
m_icon = new QLabel(mainWidget());
55
m_icon->setAlignment(Qt::AlignTop | Qt::AlignLeft);
56
QSizePolicy sp(QSizePolicy::Fixed, QSizePolicy::Preferred);
57
sp.setHorizontalStretch(1);
58
m_icon->setSizePolicy(sp);
59
m_icon->setFixedWidth(50);
60
lyr->addWidget(m_icon, 0, 0);
62
sp = QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
63
sp.setHorizontalStretch(1);
64
m_widget->setSizePolicy(sp);
65
lyr->addWidget(m_widget, 0, 1);
66
lyr->addItem(new QSpacerItem(25, 10, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 2);
67
lyr->addItem(new QSpacerItem(5, 10, QSizePolicy::Minimum, QSizePolicy::Expanding), 1, 1);
68
// m_widget->captionLineEdit()->selectAll();
69
// m_widget->captionLineEdit()->setFocus();
70
connect(m_widget, SIGNAL(messageChanged()), this, SLOT(updateSize()));
74
connect(m_widget, SIGNAL(textChanged()), this, SLOT(slotTextChanged()));
77
void KexiNameDialog::updateSize()
79
// resize( QSize(400, 140 + (m_widget->lbl_message->isVisible()?m_widget->lbl_message->height():0) )
80
resize(QSize(400, 140 + (!m_widget->lbl_message->text().isEmpty() ? m_widget->lbl_message->height() : 0))
81
.expandedTo(minimumSizeHint()));
85
void KexiNameDialog::slotTextChanged()
88
if ( (m_widget->isNameRequired() && m_widget->nameText().isEmpty())
89
|| (m_widget->isCaptionRequired() && m_widget->captionText().isEmpty()) )
93
enableButtonOk(enable);
96
void KexiNameDialog::accept()
98
if (!m_widget->checkValidity())
103
void KexiNameDialog::setDialogIcon(const QPixmap& icon)
105
m_icon->setPixmap(icon);
108
void KexiNameDialog::showEvent(QShowEvent * event)
110
m_widget->captionLineEdit()->selectAll();
111
m_widget->captionLineEdit()->setFocus();
112
KDialog::showEvent(event);
115
#include "kexinamedialog.moc"