~ubuntu-branches/ubuntu/warty/koffice/warty

« back to all changes in this revision

Viewing changes to kword/mailmerge/sql/qtsqlopeneditor.cc

  • Committer: Bazaar Package Importer
  • Author(s): Ben Burton
  • Date: 2004-05-09 11:33:00 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040509113300-vfrdadqsvjfuhn3b
Tags: 1:1.3.1-1
* New upstream bugfix release.
* Built against newer imagemagick (closes: #246623).
* Made koffice-libs/kformula recommend/depend on latex-xft-fonts, which
  provides mathematical fonts that the formula editor can use.  Also
  patched the kformula part to make these fonts the default.
* Changed kword menu hint from "WordProcessors" to "Word processors"
  (closes: #246209).
* Spellchecker configuration is now fixed (closes: #221256, #227568).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of the KDE project
 
2
   Copyright (C) 2001 Joseph Wenninger <jowenn@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., 59 Temple Place - Suite 330,
 
17
   Boston, MA 02111-1307, USA.
 
18
*/
 
19
 
 
20
#include "qtsqlopeneditor.h"
 
21
#include "qtsqlopeneditor.moc"
 
22
#include <kcombobox.h>
 
23
#include <klineedit.h>
 
24
#include <kdebug.h>
 
25
#include <qlayout.h>
 
26
#include <kconfig.h>
 
27
#include <kpushbutton.h>
 
28
#include <klineeditdlg.h>
 
29
#include <kiconloader.h>
 
30
#include <qsqldatabase.h>
 
31
#include <qguardedptr.h>
 
32
#include <klocale.h>
 
33
 
 
34
/******************************************************************
 
35
 *
 
36
 * Class: KWQTSQLMailMergeOpen
 
37
 *
 
38
 ******************************************************************/
 
39
 
 
40
KWQTSQLMailMergeOpen::KWQTSQLMailMergeOpen( QWidget *parent, KWQTSQLSerialDataSourceBase *db_ )
 
41
        :KDialogBase( Plain, i18n( "Mail Merge - Setup Database Connection" ), Ok | Cancel, Ok, parent, "", true ), db( db_ ){
 
42
        (new QVBoxLayout(plainPage()))->setAutoAdd(true);
 
43
        setMainWidget(widget=new KWQTSQLOpenWidget(plainPage()));
 
44
        widget->drivers->insertStringList(QSqlDatabase::drivers());
 
45
        widget->hostname->setText(db->hostname);
 
46
        widget->username->setText(db->username);
 
47
        widget->port->setText(db->port);
 
48
        widget->databasename->setText(db->databasename);
 
49
        fillSavedProperties();
 
50
        connect(this,SIGNAL(okClicked()),this,SLOT(handleOk()));
 
51
        connect(widget->savedProperties,SIGNAL(activated(const QString&)),
 
52
                this, SLOT(savedPropertiesChanged(const QString&)));
 
53
        connect(widget->rememberButton,SIGNAL(clicked()),
 
54
                this, SLOT(slotSave()));
 
55
}
 
56
 
 
57
KWQTSQLMailMergeOpen::~KWQTSQLMailMergeOpen(){;}
 
58
 
 
59
void KWQTSQLMailMergeOpen::savedPropertiesChanged(const QString& name)
 
60
{
 
61
        if (name!=i18n("<not saved>"))
 
62
        {
 
63
                KConfig conf("kwmailmergerc");
 
64
                conf.setGroup("KWSLQTDB:"+name);
 
65
                widget->hostname->setText(conf.readEntry("hostname",""));
 
66
                widget->username->setText(conf.readEntry("username",""));
 
67
                widget->port->setText(conf.readEntry("port",""));
 
68
                widget->databasename->setText(conf.readEntry("databasename",""));
 
69
        }
 
70
        else
 
71
        {
 
72
                widget->hostname->setText("");
 
73
                widget->username->setText("");
 
74
                widget->port->setText(i18n("default"));
 
75
                widget->databasename->setText("");
 
76
        }
 
77
 
 
78
}
 
79
 
 
80
void KWQTSQLMailMergeOpen::fillSavedProperties()
 
81
{
 
82
        widget->savedProperties->clear();
 
83
        widget->savedProperties->insertItem(i18n("<not saved>"));
 
84
        //Read data from configuration file and add entries
 
85
        KConfig conf("kwmailmergerc");
 
86
        QStringList list=conf.groupList();
 
87
        for (QStringList::Iterator it=list.begin();it!=list.end();++it)
 
88
        {
 
89
                if ((*it).startsWith("KWSLQTDB:"))
 
90
                widget->savedProperties->insertItem((*it).right((*it).length()-9));
 
91
        }
 
92
}
 
93
 
 
94
void KWQTSQLMailMergeOpen::slotSave()
 
95
{
 
96
        QString value;
 
97
        bool ok;
 
98
        value=KLineEditDlg::getText(i18n("Store Settings"),i18n("Name:"),
 
99
                QString::null, &ok,this);
 
100
        if (!ok) kdDebug()<<"Cancel was pressed"<<endl;
 
101
        if (value.isEmpty()) kdDebug()<<"Name value was empty"<<endl;
 
102
        if ((ok) && (!value.isEmpty()))
 
103
        {
 
104
                KConfig conf("kwmailmergerc");
 
105
                conf.setGroup("KWSLQTDB:"+value);
 
106
                conf.writeEntry("hostname",widget->hostname->text());
 
107
                conf.writeEntry("username",widget->username->text());
 
108
                conf.writeEntry("port",widget->port->text());
 
109
                conf.writeEntry("databasename",widget->databasename->text());
 
110
                conf.sync();
 
111
                fillSavedProperties();
 
112
                widget->savedProperties->setCurrentText(value);
 
113
        }
 
114
}
 
115
 
 
116
void KWQTSQLMailMergeOpen::handleOk()
 
117
{
 
118
        db->hostname=widget->hostname->text();
 
119
        db->username=widget->username->text();
 
120
        db->port=widget->port->text();
 
121
        db->databasename=widget->databasename->text();
 
122
        db->driver=widget->drivers->currentText();
 
123
}