~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to kexi/main/kexinamedialog.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-09-21 15:36:35 UTC
  • mfrom: (1.4.1 upstream) (60.2.11 maverick)
  • Revision ID: james.westby@ubuntu.com-20100921153635-6tejqkiro2u21ydi
Tags: 1:2.2.2-0ubuntu3
Add kubuntu_03_fix-crash-on-closing-sqlite-connection-2.2.2.diff and
kubuntu_04_support-large-memo-values-for-msaccess-2.2.2.diff as
recommended by upstream http://kexi-
project.org/wiki/wikiview/index.php@Kexi2.2_Patches.html#sqlite_stab
ility

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of the KDE project
 
2
   Copyright (C) 2004 Jarosław Staniek <staniek@kde.org>
 
3
 
 
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.
 
8
 
 
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.
 
13
 
 
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.
 
18
*/
 
19
 
 
20
#include "kexinamedialog.h"
 
21
#include <QPixmap>
 
22
#include <QGridLayout>
 
23
#include <QLabel>
 
24
 
 
25
KexiNameDialog::KexiNameDialog(
 
26
    const QString& message, QWidget * parent)
 
27
        : KDialog(parent)
 
28
{
 
29
    setMainWidget(new QWidget(this));
 
30
    m_widget = new KexiNameWidget(message, mainWidget());
 
31
    init();
 
32
}
 
33
 
 
34
KexiNameDialog::KexiNameDialog(const QString& message,
 
35
                               const QString& nameLabel, const QString& nameText,
 
36
                               const QString& captionLabel, const QString& captionText,
 
37
                               QWidget * parent)
 
38
        : KDialog(parent)
 
39
{
 
40
    setMainWidget(new QWidget(this));
 
41
    m_widget = new KexiNameWidget(message, nameLabel, nameText,
 
42
                                  captionLabel, captionText, mainWidget());
 
43
    init();
 
44
}
 
45
 
 
46
KexiNameDialog::~KexiNameDialog()
 
47
{
 
48
}
 
49
 
 
50
void KexiNameDialog::init()
 
51
{
 
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);
 
61
 
 
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()));
 
71
    updateSize();
 
72
    enableButtonOk(true);
 
73
    slotTextChanged();
 
74
    connect(m_widget, SIGNAL(textChanged()), this, SLOT(slotTextChanged()));
 
75
}
 
76
 
 
77
void KexiNameDialog::updateSize()
 
78
{
 
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()));
 
82
// updateGeometry();
 
83
}
 
84
 
 
85
void KexiNameDialog::slotTextChanged()
 
86
{
 
87
    bool enable = true;
 
88
    if (   (m_widget->isNameRequired() && m_widget->nameText().isEmpty())
 
89
        || (m_widget->isCaptionRequired() && m_widget->captionText().isEmpty()) )
 
90
    {
 
91
        enable = false;
 
92
    }
 
93
    enableButtonOk(enable);
 
94
}
 
95
 
 
96
void KexiNameDialog::accept()
 
97
{
 
98
    if (!m_widget->checkValidity())
 
99
        return;
 
100
    KDialog::accept();
 
101
}
 
102
 
 
103
void KexiNameDialog::setDialogIcon(const QPixmap& icon)
 
104
{
 
105
    m_icon->setPixmap(icon);
 
106
}
 
107
 
 
108
void KexiNameDialog::showEvent(QShowEvent * event)
 
109
{
 
110
    m_widget->captionLineEdit()->selectAll();
 
111
    m_widget->captionLineEdit()->setFocus();
 
112
    KDialog::showEvent(event);
 
113
}
 
114
 
 
115
#include "kexinamedialog.moc"