1
/* This file is part of the KDE project
2
Copyright (C) 2002 Lucijan Busch <lucijan@gmx.at>
4
This program 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 program 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 program; see the file COPYING. If not, write to
16
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
Boston, MA 02111-1307, USA.
24
#include <qpushbutton.h>
31
#include <kcombobox.h>
32
#include <ktextbrowser.h>
34
#include <kiconloader.h>
35
#include <kapplication.h>
37
#include <kexidb/drivermanager.h>
38
#include "kexicreateprojectpageengine.h"
39
#include "kexiproject.h"
41
#include "kexi_version.h"
43
//! Small extension: list item that can be shown as disabled, but still selectable
44
class KexiListBoxItem : public QListBoxPixmap {
46
KexiListBoxItem( QListBox * listbox, const QPixmap & pix, const QString & text, bool enabled=true )
47
: QListBoxPixmap(listbox, pix, text ), m_enabled(enabled)
50
virtual void paint( QPainter * painter ) {
51
QPen p = painter->pen();
52
if (!m_enabled && !isSelected())
53
p.setColor( qApp->palette().disabled().text() );
54
// if (listBox()->currentItem()==this)
55
// ;//p.setColor( isSelected() && listBox()->hasFocus() ? qApp->palette().disabled().highlightedText() : qApp->palette().disabled().text() );
57
//kdDebug() << isSelected() << " " << listBox()->hasFocus() << endl;
58
// p.setColor( isSelected() && listBox()->hasFocus() ? qApp->palette().disabled().highlightedText() : qApp->palette().disabled().text() );
61
QListBoxPixmap::paint(painter);
66
KexiCreateProjectPageEngine::KexiCreateProjectPageEngine(KexiCreateProject *parent, QPixmap *wpic, const char *name)
67
: KexiCreateProjectPage(parent, wpic, name)
69
QLabel *lEngine = new QLabel(i18n("Driver: "), m_contents);
71
m_engine = new KComboBox(m_contents);
72
m_engine->setMaxCount(8);
73
connect(m_engine, SIGNAL(activated(int)), this, SLOT(slotActivated(int)));
75
m_summary = new KTextBrowser(m_contents);
77
QGridLayout *g = new QGridLayout(m_contents);
78
g->addWidget(lEngine, 0, 0);
79
g->addWidget(m_engine, 0, 1);
80
g->addMultiCellWidget(m_summary,1, 1, 0, 1);
81
g->setSpacing(KDialog::spacingHint());
85
setProperty("section", QVariant("Both"));
86
setProperty("caption", QVariant(i18n("Engine")));
92
KexiCreateProjectPageEngine::fill()
94
if (m_engine->count()>0)
96
QStringList drivers = project()->manager()->driverNames();
97
for(QStringList::Iterator it = drivers.begin(); it != drivers.end(); ++it)
99
m_engine->insertItem( kapp->iconLoader()->loadIcon("exec", KIcon::Small), *it);
101
#ifdef KEXI_ADD_EXAMPLE_ENGINES
102
m_first_example_engine_nr = m_engine->count();
104
<< i18n("Default Kexi embedded engine")
106
<< "Interbase/Firebird"
111
<< "Sybase/Adaptive Server Enterprise"
116
//(uniwersalne polaczenie do baz)
118
QPixmap icon = kapp->iconLoader()->loadIcon("exec", KIcon::Small);
119
for ( QStringList::Iterator it = m_example_engines.begin(); it != m_example_engines.end(); ++it ) {
120
m_engine->listBox()->insertItem( new KexiListBoxItem( 0, icon, *it, false ) );
121
// m_engine->insertItem( kapp->iconLoader()->loadIcon("exec", KIcon::Small), *it);
125
if(!m_engine->currentText().isEmpty())
127
setProperty("engine", QVariant(m_engine->currentText()));
128
setProperty("continue", QVariant(true));
135
KexiCreateProjectPageEngine::fillSummary()
137
QString engineSummary;
139
#ifdef KEXI_ADD_EXAMPLE_ENGINES
140
if (m_engine->currentItem()>=m_first_example_engine_nr) {
141
engineSummary = i18n("Sorry, this driver is not available with current version of %1.").arg(KEXI_APP_NAME);
142
if (m_engine->currentText()=="ODBC") {
143
engineSummary += i18n("<p>ODBC is an open specification for accessing data sources more easily; data sources include both SQL databases available with Kexi drivers and others, like Microsoft SQL Server and Microsoft Access.");
149
KService *ptr=project()->manager()->serviceInfo(m_engine->currentText());
151
engineSummary = ptr->comment();
152
location = project()->manager()->serviceInfo(m_engine->currentText())->property("X-Kexi-Location");
153
setProperty("location", location);
154
} else engineSummary=i18n("Internal error while retrieving information. (No driver installed ?)");
155
// userSummary = QString("<b>" + m_engine->currentText() + "</b><br><hr><br>" + engineSummary);
159
if(!m_engine->currentText().isEmpty())
161
m_summary->setText( QString("<b>") + m_engine->currentText() + "</b><br><hr><br>" + engineSummary );
167
KexiCreateProjectPageEngine::slotActivated(int idx)
169
bool continue_enabled;
170
#ifdef KEXI_ADD_EXAMPLE_ENGINES
171
continue_enabled = idx<m_first_example_engine_nr;
173
continue_enabled=true;
176
setProperty("continue", continue_enabled);
177
setProperty("engine", QVariant(m_engine->text(idx)));
181
KexiCreateProjectPageEngine::~KexiCreateProjectPageEngine()
185
#include "kexicreateprojectpageengine.moc"