summaryrefslogtreecommitdiffstats
path: root/languages/sql
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit114a878c64ce6f8223cfd22d76a20eb16d177e5e (patch)
treeacaf47eb0fa12142d3896416a69e74cbf5a72242 /languages/sql
downloadtdevelop-114a878c64ce6f8223cfd22d76a20eb16d177e5e.tar.gz
tdevelop-114a878c64ce6f8223cfd22d76a20eb16d177e5e.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdevelop@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'languages/sql')
-rw-r--r--languages/sql/Makefile.am20
-rw-r--r--languages/sql/README.dox40
-rw-r--r--languages/sql/app_templates/Makefile.am3
-rw-r--r--languages/sql/app_templates/sql.appwizard2
-rw-r--r--languages/sql/app_templates/sqlsimple/.kdev_ignore0
-rw-r--r--languages/sql/app_templates/sqlsimple/Makefile.am16
-rw-r--r--languages/sql/app_templates/sqlsimple/app.kdevelop84
-rw-r--r--languages/sql/app_templates/sqlsimple/app.sql1
-rw-r--r--languages/sql/app_templates/sqlsimple/sqlsimple7
-rw-r--r--languages/sql/app_templates/sqlsimple/sqlsimple.kdevtemplate106
-rw-r--r--languages/sql/app_templates/sqlsimple/sqlsimple.pngbin0 -> 483 bytes
-rw-r--r--languages/sql/doc/Makefile.am6
-rw-r--r--languages/sql/kdevsqlsupport.desktop85
-rw-r--r--languages/sql/kdevsqlsupport.rc14
-rw-r--r--languages/sql/sqlactions.cpp103
-rw-r--r--languages/sql/sqlactions.h41
-rw-r--r--languages/sql/sqlconfigwidget.ui189
-rw-r--r--languages/sql/sqlconfigwidget.ui.h244
-rw-r--r--languages/sql/sqloutputwidget.cpp127
-rw-r--r--languages/sql/sqloutputwidget.h43
-rw-r--r--languages/sql/sqlsupport_part.cpp284
-rw-r--r--languages/sql/sqlsupport_part.h55
22 files changed, 1470 insertions, 0 deletions
diff --git a/languages/sql/Makefile.am b/languages/sql/Makefile.am
new file mode 100644
index 00000000..68cfbdea
--- /dev/null
+++ b/languages/sql/Makefile.am
@@ -0,0 +1,20 @@
+#Here resides the SQL support part.
+
+INCLUDES = -I$(top_srcdir)/lib/compat -I$(top_srcdir)/lib/interfaces \
+ -I$(top_srcdir)/lib/interfaces/extensions -I$(top_srcdir)/lib/interfaces/external -I$(top_srcdir)/lib/util \
+ $(all_includes)
+SUBDIRS = app_templates doc
+
+kde_module_LTLIBRARIES = libkdevsqlsupport.la
+libkdevsqlsupport_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN)
+libkdevsqlsupport_la_LIBADD = $(top_builddir)/lib/libkdevelop.la
+
+libkdevsqlsupport_la_SOURCES = sqlconfigwidget.ui sqlsupport_part.cpp sqlactions.cpp sqloutputwidget.cpp
+
+METASOURCES = AUTO
+
+servicedir = $(kde_servicesdir)
+service_DATA = kdevsqlsupport.desktop
+
+rcdir = $(kde_datadir)/kdevsqlsupport
+rc_DATA = kdevsqlsupport.rc
diff --git a/languages/sql/README.dox b/languages/sql/README.dox
new file mode 100644
index 00000000..bfa52e2e
--- /dev/null
+++ b/languages/sql/README.dox
@@ -0,0 +1,40 @@
+/** \class SQLSupportPart
+This is a SQL support plugin
+
+\authors <a href="mailto:harry AT kdevelop.org">Harald Fernengel</a>
+
+\maintainer <a href="mailto:harry AT kdevelop.org">Harald Fernengel</a>
+
+\feature SQL language support
+\feature Consult \ref LangSupportStatus for a up to date features/status of this programming language support part.
+
+\bug Describe a the 1st bug that you know of, but probably hasn't been reported yet.
+..
+\bug Describe a the nth bug that you know of, but probably hasn't been reported yet.
+
+\requirement Describe a the 1st requirement of your part.
+\requirement Describe a the 2nd requirement of your part.
+...
+\requirement Describe a the nth requirement of your part.
+
+\todo Describe a the 1st TODO of your part.
+\todo Describe a the 2nd TODO of your part.
+...
+\todo Describe a the nth TODO of your part.
+
+\faq <b>First frequenly asked question about your part ?</b> Answer.
+\faq <b>Second frequenly asked question about your part ?</b> Answer.
+...
+\faq <b>Last frequenly asked question about your part ?</b> Answer.
+
+\note First note text.
+\note Second note text.
+...
+\note Last note text.
+
+\warning First warning text.
+\warning Second warning text.
+...
+\warning Last warning text.
+
+*/
diff --git a/languages/sql/app_templates/Makefile.am b/languages/sql/app_templates/Makefile.am
new file mode 100644
index 00000000..78c56300
--- /dev/null
+++ b/languages/sql/app_templates/Makefile.am
@@ -0,0 +1,3 @@
+SUBDIRS = sqlsimple
+profilesdir = $(kde_datadir)/kdevelop/profiles/IDE/DatabaseIDE
+profiles_DATA = sql.appwizard
diff --git a/languages/sql/app_templates/sql.appwizard b/languages/sql/app_templates/sql.appwizard
new file mode 100644
index 00000000..425f4998
--- /dev/null
+++ b/languages/sql/app_templates/sql.appwizard
@@ -0,0 +1,2 @@
+[General]
+List=sqlsimple
diff --git a/languages/sql/app_templates/sqlsimple/.kdev_ignore b/languages/sql/app_templates/sqlsimple/.kdev_ignore
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/languages/sql/app_templates/sqlsimple/.kdev_ignore
diff --git a/languages/sql/app_templates/sqlsimple/Makefile.am b/languages/sql/app_templates/sqlsimple/Makefile.am
new file mode 100644
index 00000000..f7b5a012
--- /dev/null
+++ b/languages/sql/app_templates/sqlsimple/Makefile.am
@@ -0,0 +1,16 @@
+templateName = sqlsimple
+dataFiles = app.sql app.kdevelop
+
+### no need to change below:
+template_DATA = $(templateName).kdevtemplate
+templatedir = ${appwizarddatadir}/templates
+
+appwizarddatadir = ${kde_datadir}/kdevappwizard
+$(templateName).tar.gz: ${dataFiles}
+ $(TAR) -cf $(templateName).tar -C $(srcdir) ${dataFiles}
+ $(GZIP_COMMAND) -f9 $(templateName).tar
+
+archivedir = ${appwizarddatadir}
+archive_DATA = $(templateName).tar.gz ${templateName}.png
+
+CLEANFILES = *.tar.gz \ No newline at end of file
diff --git a/languages/sql/app_templates/sqlsimple/app.kdevelop b/languages/sql/app_templates/sqlsimple/app.kdevelop
new file mode 100644
index 00000000..78f055cd
--- /dev/null
+++ b/languages/sql/app_templates/sqlsimple/app.kdevelop
@@ -0,0 +1,84 @@
+<?xml version="1.0"?>
+<kdevelop>
+ <general>
+ <author>%{AUTHOR}</author>
+ <email>%{EMAIL}</email>
+ <version>%{VERSION}</version>
+ <projectmanagement>KDevScriptProject</projectmanagement>
+ <primarylanguage>SQL</primarylanguage>
+ <keywords>
+ <keyword>SQL</keyword>
+ </keywords>
+ <ignoreparts>
+ <part>KDevdistpart</part>
+ <part>KDevDebugger</part>
+ </ignoreparts>
+ </general>
+ <kdevscriptproject>
+ <general>
+ <activedir>src</activedir>
+ <includepatterns>*.sql</includepatterns>
+ <excludepatterns>*~</excludepatterns>
+ </general>
+ </kdevscriptproject>
+ <kdevfileview>
+ <groups>
+ <group pattern="*.sql" name="SQL" />
+ </groups>
+ </kdevfileview>
+ <kdevdoctreeview>
+ <ignoretocs>
+ <toc>ada</toc>
+ <toc>ada_bugs_gcc</toc>
+ <toc>bash</toc>
+ <toc>bash_bugs</toc>
+ <toc>c++_bugs_gcc</toc>
+ <toc>clanlib</toc>
+ <toc>w3c-dom-level2-html</toc>
+ <toc>fortran_bugs_gcc</toc>
+ <toc>gnome1</toc>
+ <toc>gnustep</toc>
+ <toc>gtk</toc>
+ <toc>gtk_bugs</toc>
+ <toc>haskell</toc>
+ <toc>haskell_bugs_ghc</toc>
+ <toc>java_bugs_gcc</toc>
+ <toc>java_bugs_sun</toc>
+ <toc>kde2book</toc>
+ <toc>libc</toc>
+ <toc>libstdc++</toc>
+ <toc>opengl</toc>
+ <toc>pascal_bugs_fp</toc>
+ <toc>php</toc>
+ <toc>php_bugs</toc>
+ <toc>perl</toc>
+ <toc>perl_bugs</toc>
+ <toc>python</toc>
+ <toc>python_bugs</toc>
+ <toc>qt-kdev3</toc>
+ <toc>ruby</toc>
+ <toc>ruby_bugs</toc>
+ <toc>sdl</toc>
+ <toc>stl</toc>
+ <toc>w3c-svg</toc>
+ <toc>sw</toc>
+ <toc>w3c-uaag10</toc>
+ <toc>wxwidgets_bugs</toc>
+ </ignoretocs>
+ <ignoreqt_xml>
+ <toc>Guide to the Qt Translation Tools</toc>
+ <toc>Qt Assistant Manual</toc>
+ <toc>Qt Designer Manual</toc>
+ <toc>Qt Reference Documentation</toc>
+ <toc>qmake User Guide</toc>
+ </ignoreqt_xml>
+ <ignoredoxygen>
+ <toc>KDE Libraries (Doxygen)</toc>
+ </ignoredoxygen>
+ </kdevdoctreeview>
+ <kdevfilecreate>
+ <useglobaltypes>
+ <type ext="sql"/>
+ </useglobaltypes>
+ </kdevfilecreate>
+</kdevelop>
diff --git a/languages/sql/app_templates/sqlsimple/app.sql b/languages/sql/app_templates/sqlsimple/app.sql
new file mode 100644
index 00000000..72e73020
--- /dev/null
+++ b/languages/sql/app_templates/sqlsimple/app.sql
@@ -0,0 +1 @@
+select * from foo; \ No newline at end of file
diff --git a/languages/sql/app_templates/sqlsimple/sqlsimple b/languages/sql/app_templates/sqlsimple/sqlsimple
new file mode 100644
index 00000000..e4bee598
--- /dev/null
+++ b/languages/sql/app_templates/sqlsimple/sqlsimple
@@ -0,0 +1,7 @@
+# KDE Config File
+[General]
+Name=Simple SQL Project
+Category=Database
+Comment=Generates a simple SQL project.
+FileTemplates=sql,AdaStyle
+ShowFilesAfterGeneration=APPNAMELC.sql
diff --git a/languages/sql/app_templates/sqlsimple/sqlsimple.kdevtemplate b/languages/sql/app_templates/sqlsimple/sqlsimple.kdevtemplate
new file mode 100644
index 00000000..e3c100d8
--- /dev/null
+++ b/languages/sql/app_templates/sqlsimple/sqlsimple.kdevtemplate
@@ -0,0 +1,106 @@
+# KDE Config File
+[General]
+Name=Simple SQL Project
+Name[ca]=Simple projecte en SQL
+Name[da]=Simpelt SQL-projekt
+Name[de]=Einfaches SQL-Projekt
+Name[el]=Απλό έργο SQL
+Name[es]=Proyecto SQL sencillo
+Name[et]=Lihtne SQL projekt
+Name[eu]=SQL proiektu sinplea
+Name[fa]=پروژۀ سادۀ SQL
+Name[fr]=Projet SQL simple
+Name[ga]=Tionscadal Simplí SQL
+Name[gl]=Proxecto sinxelo en SQL
+Name[hu]=Egyszerű SQL-projekt
+Name[it]=Semplice progetto SQL
+Name[ja]=簡単な SQL プロジェクト
+Name[nds]=Eenfach SQL-Projekt
+Name[ne]=साधारण SQL परियोजना
+Name[nl]=Eenvoudig SQL-project
+Name[pl]=Prosty projekt w SQL-u
+Name[pt]=Projecto Simples em SQL
+Name[pt_BR]=Projecto Simples em SQL
+Name[ru]=Простой проект SQL
+Name[sk]=Jednoduchý SQL projekt
+Name[sr]=Једноставан SQL пројекат
+Name[sr@Latn]=Jednostavan SQL projekat
+Name[sv]=Enkelt SQL-projekt
+Name[tr]=Basit SQL Projesi
+Name[zh_CN]=简单的 SQL 工程
+Name[zh_TW]=簡單的 SQL 專案
+Category=Database
+Comment=Generates a simple SQL project.
+Comment[ca]=Genera un simple projecte en SQL.
+Comment[da]=Genererer et simpelt SQL projekt.
+Comment[de]=Erstellt ein einfaches SQL-Projekt.
+Comment[el]=Δημιουργεί ένα απλό έργο SQL.
+Comment[es]=Genera un sencillo proyecto SQL.
+Comment[et]=Lihtsa SQL projekti loomine.
+Comment[eu]=SQL proiektu sinple bat sortzen du.
+Comment[fa]=یک پروژۀ سادۀ SQL تولید می‌کند.
+Comment[fr]=Génère un projet SQL simple.
+Comment[gl]=Xera un proxecto sinxelo en SQL.
+Comment[hu]=Létrehoz egy egyszerű SQL-projektet.
+Comment[it]=Genera un semplice progetto SQL.
+Comment[ja]=簡単な SQL プロジェクトを作成します
+Comment[nds]=Stellt en eenfach SQL-Projekt op.
+Comment[ne]=साधारण SQL परियोजना उत्पन्न गर्दछ
+Comment[nl]=Genereert een eenvoudig SQL-project.
+Comment[pl]=Generuje prosty projekt w SQL-u.
+Comment[pt]=Gera um projecto simples em SQL.
+Comment[pt_BR]=Gera um projecto simples em SQL.
+Comment[ru]=Простой проект SQL
+Comment[sk]=Vygeneruje jednoduchý SQL projekt.
+Comment[sr]=Прави једноставан SQL пројекат.
+Comment[sr@Latn]=Pravi jednostavan SQL projekat.
+Comment[sv]=Skapar ett enkelt SQL-projekt.
+Comment[tr]=Basit bir SQL Projesi yaratır
+Comment[zh_CN]=生成一个简单的 SQL 工程。
+Comment[zh_TW]=產生一個簡單的 SQL 專案
+FileTemplates=sql,AdaStyle
+ShowFilesAfterGeneration=%{dest}/%{APPNAMELC}.sql
+Archive=sqlsimple.tar.gz
+
+[FILE1]
+Type=install
+EscapeXML=true
+Source=%{src}/app.kdevelop
+Dest=%{dest}/%{APPNAMELC}.kdevelop
+
+[FILE2]
+Type=install
+Source=%{src}/app.sql
+Dest=%{dest}/%{APPNAMELC}.sql
+
+[MSG]
+Type=install
+Comment=A simple SQL project was created in %{dest}
+Comment[ca]=Un simple projecte en SQL ha estat creat en %{dest}
+Comment[da]=Et simpelt SQL projekt blev oprettet i %{dest}
+Comment[de]=Ein einfaches SQL-Projekt wurde in %{dest} erstellt.
+Comment[el]=Ένα απλό έργο SQL δημιουργήθηκε στο %{dest}
+Comment[es]=Un sencillo proyecto SQL ha sido creado en %{dest}
+Comment[et]=Lihtne SQL projekt loodi asukohta %{dest}
+Comment[eu]=SQL proiektu sinple bat sortu da hemen: %{dest}
+Comment[fa]=یک پروژۀ سادۀ SQL در %{dest} ایجاد شد
+Comment[fr]=Un projet SQL simple a été créé dans %{dest}
+Comment[ga]=Cruthaíodh tionscadal simplí SQL i %{dest}
+Comment[gl]=Creouse un proxecto sinxelo en SQL en %{dest}
+Comment[hu]=Létrejött egy egyszerű SQL-projekt itt: %{dest}
+Comment[it]=È stato creato un semplice progetto SQL in %{dest}
+Comment[ja]=簡単な SQL プロジェクトを %{dest} に作成しました
+Comment[nds]=In %{dest} wöör en eenfach SQL-Projekt opstellt.
+Comment[ne]=साधारण SQL परियोजना %{dest} मा सिर्जना गरियो
+Comment[nl]=Een eenvoudig SQL-project is aangemaakt in %{dest}
+Comment[pl]=Prosty projekt w SQL-u został utworzony w %{dest}
+Comment[pt]=Foi criado um projecto simples de SQL em %{dest}
+Comment[pt_BR]=Foi criado um projecto simples de SQL em %{dest}
+Comment[ru]=Простой проект SQL создан в %{dest}
+Comment[sk]=Jednoduchý SQL projekt bol vytvorený v %{dest}
+Comment[sr]=Једноставан SQL пројекат направљен је у %{dest}
+Comment[sr@Latn]=Jednostavan SQL projekat napravljen je u %{dest}
+Comment[sv]=Ett enkelt SQL-projekt skapades i %{dest}
+Comment[tr]=Basit bir SQL projesi %{dest} içinde yaratıldı.
+Comment[zh_CN]=在 %{dest} 中创建了简单的 SQL 工程
+Comment[zh_TW]=一個簡單的 SQL 專案已建立於 %{dest}
diff --git a/languages/sql/app_templates/sqlsimple/sqlsimple.png b/languages/sql/app_templates/sqlsimple/sqlsimple.png
new file mode 100644
index 00000000..840a953c
--- /dev/null
+++ b/languages/sql/app_templates/sqlsimple/sqlsimple.png
Binary files differ
diff --git a/languages/sql/doc/Makefile.am b/languages/sql/doc/Makefile.am
new file mode 100644
index 00000000..d42aec82
--- /dev/null
+++ b/languages/sql/doc/Makefile.am
@@ -0,0 +1,6 @@
+#tocdir = ${kde_datadir}/kdevdoctreeview/tocs
+#toc_DATA =
+
+#indexdir = ${kde_datadir}/devdoctreeview/indices
+#index_DATA =
+
diff --git a/languages/sql/kdevsqlsupport.desktop b/languages/sql/kdevsqlsupport.desktop
new file mode 100644
index 00000000..2880affa
--- /dev/null
+++ b/languages/sql/kdevsqlsupport.desktop
@@ -0,0 +1,85 @@
+[Desktop Entry]
+Type=Service
+Exec=blubb
+Comment=SQL Support
+Comment[ca]=Suport per a SQL
+Comment[da]=SQL-understøttelse
+Comment[de]=Unterstützung für SQL
+Comment[el]=Υποστήριξη SQL
+Comment[es]=Soporte para SQL
+Comment[et]=SQL toetus
+Comment[eu]=SQL euskarria
+Comment[fa]=پشتیبانی SQL
+Comment[fr]=Prise en charge du langage SQL
+Comment[ga]=Tacaíocht SQL
+Comment[gl]=Soporte para SQL
+Comment[hi]=एसक्यूएल समर्थन
+Comment[hu]=SQL-támogatás
+Comment[is]=SQL stuðningur
+Comment[it]=Supporto SQL
+Comment[ja]=SQL サポート
+Comment[nds]=SQL-Ünnerstütten
+Comment[ne]=SQL समर्थन
+Comment[nl]=Ondersteuning voor SQL
+Comment[pl]=Obsługa SQL-a
+Comment[pt]=Suporte a SQL
+Comment[pt_BR]=Suporte ao SQL
+Comment[ru]=Поддержка языка SQL
+Comment[sk]=SQL podpora
+Comment[sl]=Podpora za SQL
+Comment[sr]=Подршка за SQL
+Comment[sr@Latn]=Podrška za SQL
+Comment[sv]=SQL-stöd
+Comment[ta]=SQL ஆதரவு
+Comment[tg]=Ёрӣ намудани забони SQL
+Comment[tr]=SQL Desteği
+Comment[zh_CN]=SQL 语言支持
+Comment[zh_TW]=SQL 支援
+Name=KDevSQLSupport
+Name[da]=KDevelop SQL-understøttelse
+Name[de]=Unterstützung für SQL (KDevelop)
+Name[hi]=के-डेव-एसक्यूएल-समर्थन
+Name[nds]=SQL-Ünnerstütten för KDevelop
+Name[pl]=KDevObsługaSQL
+Name[sk]=KDev SQL podpora
+Name[sv]=KDevelop SQL-stöd
+Name[ta]=கெடெவ் எஸ்கியேல் ஆதரவு
+Name[zh_TW]=KDevelop SQL 支援
+GenericName=SQL Support
+GenericName[ca]=Suport per a SQL
+GenericName[da]=SQL-understøttelse
+GenericName[de]=Unterstützung für SQL
+GenericName[el]=Υποστήριξη SQL
+GenericName[es]=Soporte para SQL
+GenericName[et]=SQL toetus
+GenericName[eu]=SQL euskarria
+GenericName[fa]=پشتیبانی SQL
+GenericName[fr]=Langage SQL
+GenericName[ga]=Tacaíocht SQL
+GenericName[gl]=Soporte para SQL
+GenericName[hi]=एसक्यूएल समर्थन
+GenericName[hu]=SQL-támogatás
+GenericName[it]=Supporto SQL
+GenericName[ja]=SQL サポート
+GenericName[nds]=SQL-Ünnerstütten
+GenericName[ne]=SQL समर्थन
+GenericName[nl]=Ondersteuning voor SQL
+GenericName[pl]=Obsługa SQL-a
+GenericName[pt]=Suporte a SQL
+GenericName[pt_BR]=Suporte ao SQL
+GenericName[ru]=Поддержка языка SQL
+GenericName[sk]=SQL podpora
+GenericName[sl]=Podpora za SQL
+GenericName[sr]=Подршка за SQL
+GenericName[sr@Latn]=Podrška za SQL
+GenericName[sv]=SQL-stöd
+GenericName[ta]=SQL ஆதரவு
+GenericName[tg]=Ёрӣ намудани забони SQL
+GenericName[tr]=SQL Desteği
+GenericName[zh_CN]=SQL 支持
+GenericName[zh_TW]=SQL 支援
+ServiceTypes=KDevelop/LanguageSupport
+X-KDE-Library=libkdevsqlsupport
+X-KDevelop-Version=5
+X-KDevelop-Language=SQL
+X-KDevelop-Args=SQL
diff --git a/languages/sql/kdevsqlsupport.rc b/languages/sql/kdevsqlsupport.rc
new file mode 100644
index 00000000..36b91d7a
--- /dev/null
+++ b/languages/sql/kdevsqlsupport.rc
@@ -0,0 +1,14 @@
+<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
+<kpartgui name="KDevSQLSupport" version="2">
+<MenuBar>
+ <Menu name="build" >
+ <Action name="build_execute" />
+ </Menu>
+</MenuBar>
+<ToolBar name="buildToolBar">
+ <Action name="build_execute" group="build_operations" />
+</ToolBar>
+<ToolBar name="browserToolBar">
+ <Action name="connection_combo" />
+</ToolBar>
+</kpartgui>
diff --git a/languages/sql/sqlactions.cpp b/languages/sql/sqlactions.cpp
new file mode 100644
index 00000000..8cfac095
--- /dev/null
+++ b/languages/sql/sqlactions.cpp
@@ -0,0 +1,103 @@
+/***************************************************************************
+ * Copyright (C) 2003 by Harald Fernengel *
+ * harry@kdevelop.org *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "sqlactions.h"
+
+#include <qpopupmenu.h>
+#include <qstringlist.h>
+#include <qsqldatabase.h>
+
+#include <kdebug.h>
+#include <klocale.h>
+#include <ktoolbar.h>
+#include <kiconloader.h>
+#include <kcombobox.h>
+
+#include "kdevplugin.h"
+#include "kdevlanguagesupport.h"
+#include "sqlsupport_part.h"
+
+SqlListAction::SqlListAction(SQLSupportPart *part, const QString &text,
+ const KShortcut& cut,
+ const QObject *receiver, const char *slot,
+ KActionCollection *parent, const char *name)
+ : KWidgetAction( m_combo = new KComboBox(), text, cut, 0, 0, parent, name), m_part(part)
+{
+#if (QT_VERSION >= 0x030100)
+ m_combo->setEditable( false );
+ m_combo->setAutoCompletion( true );
+#endif
+
+ m_combo->setMinimumWidth( 200 );
+ m_combo->setMaximumWidth( 400 );
+
+ connect( m_combo, SIGNAL(activated(const QString&)), receiver, slot );
+ connect( m_combo, SIGNAL(activated(int)), this, SLOT(activated(int)) );
+
+ setShortcutConfigurable( false );
+ setAutoSized( true );
+
+ refresh();
+}
+
+
+void SqlListAction::setCurrentConnectionName(const QString &name)
+{
+ int idx = m_part->connections().findIndex( name );
+ if ( idx < 0 )
+ m_combo->setCurrentItem( 0 );
+ else
+ m_combo->setCurrentItem( idx + 1 );
+}
+
+
+QString SqlListAction::currentConnectionName() const
+{
+ if ( m_combo->currentItem() <= 0 )
+ return QString::null;
+ return m_part->connections()[ m_combo->currentItem() - 1 ];
+}
+
+void SqlListAction::activated(int idx)
+{
+ if (idx < 1 || (int)m_part->connections().count() <= idx)
+ return;
+ const QSqlDatabase *db = QSqlDatabase::database(m_part->connections()[idx], true);
+ m_combo->changeItem( db->isOpen() ? SmallIcon( "ok" ) : SmallIcon( "no" ),
+ m_combo->text(idx), idx );
+}
+
+void SqlListAction::refresh()
+{
+ const QStringList& dbc = m_part->connections();
+
+ m_combo->clear();
+ m_combo->insertItem( i18n("<no database server>") );
+
+ QString cName;
+ for ( QStringList::ConstIterator it = dbc.begin(); it != dbc.end(); ++it ) {
+
+ QSqlDatabase* db = QSqlDatabase::database( (*it), false );
+ if ( !db ) {
+ kdDebug( 9000 ) << "Could not find database connection " << (*it) << endl;
+ m_combo->insertItem( SmallIcon( "no" ), i18n("<error - no connection %1>").arg( *it ) );
+ continue;
+ }
+ cName = db->driverName();
+ cName.append( "://" ).append( db->userName() ).append( "@" ).append( db->hostName() );
+ cName.append( "/" ).append( db->databaseName() );
+
+ m_combo->insertItem( db->open() ? SmallIcon( "ok" ) : SmallIcon( "no" ), cName );
+ }
+}
+
+
+#include "sqlactions.moc"
diff --git a/languages/sql/sqlactions.h b/languages/sql/sqlactions.h
new file mode 100644
index 00000000..e49794e5
--- /dev/null
+++ b/languages/sql/sqlactions.h
@@ -0,0 +1,41 @@
+/***************************************************************************
+ * Copyright (C) 2003 by Harald Fernengel *
+ * harry@kdevelop.org *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef _SQLACTION_H_
+#define _SQLACTION_H_
+
+#include <kdeversion.h>
+#include <kxmlguiclient.h>
+#include <kaction.h>
+
+class SQLSupportPart;
+class KComboBox;
+
+class SqlListAction : public KWidgetAction
+{
+ Q_OBJECT
+public:
+ SqlListAction( SQLSupportPart *part, const QString &text, const KShortcut& cut,
+ const QObject *receiver, const char *slot,
+ KActionCollection *parent, const char *name );
+ void setCurrentConnectionName(const QString &name);
+ QString currentConnectionName() const;
+ void refresh();
+
+private slots:
+ void activated(int);
+
+private:
+ SQLSupportPart *m_part;
+ KComboBox* m_combo;
+};
+
+#endif
diff --git a/languages/sql/sqlconfigwidget.ui b/languages/sql/sqlconfigwidget.ui
new file mode 100644
index 00000000..e85b09d9
--- /dev/null
+++ b/languages/sql/sqlconfigwidget.ui
@@ -0,0 +1,189 @@
+<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
+<class>SqlConfigWidget</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>SqlConfigWidget</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>578</width>
+ <height>367</height>
+ </rect>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QTable">
+ <column>
+ <property name="text">
+ <string>Plugin</string>
+ </property>
+ <property name="pixmap">
+ <pixmap></pixmap>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Database Name</string>
+ </property>
+ <property name="pixmap">
+ <pixmap></pixmap>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Host</string>
+ </property>
+ <property name="pixmap">
+ <pixmap></pixmap>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Port</string>
+ </property>
+ <property name="pixmap">
+ <pixmap></pixmap>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Username</string>
+ </property>
+ <property name="pixmap">
+ <pixmap></pixmap>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Password</string>
+ </property>
+ <property name="pixmap">
+ <pixmap></pixmap>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>dbTable</cstring>
+ </property>
+ <property name="numRows">
+ <number>0</number>
+ </property>
+ <property name="numCols">
+ <number>6</number>
+ </property>
+ <property name="selectionMode">
+ <enum>SingleRow</enum>
+ </property>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;i&gt;Warning:&lt;/i&gt; password will be saved with weak encryption.</string>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout5</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer4</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>81</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KPushButton">
+ <property name="name">
+ <cstring>removeBtn</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Remove</string>
+ </property>
+ </widget>
+ <widget class="KPushButton">
+ <property name="name">
+ <cstring>testBtn</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Test</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </vbox>
+</widget>
+<connections>
+ <connection>
+ <sender>dbTable</sender>
+ <signal>valueChanged(int,int)</signal>
+ <receiver>SqlConfigWidget</receiver>
+ <slot>valueChanged(int,int)</slot>
+ </connection>
+ <connection>
+ <sender>removeBtn</sender>
+ <signal>clicked()</signal>
+ <receiver>SqlConfigWidget</receiver>
+ <slot>removeDb()</slot>
+ </connection>
+ <connection>
+ <sender>testBtn</sender>
+ <signal>clicked()</signal>
+ <receiver>SqlConfigWidget</receiver>
+ <slot>testDb()</slot>
+ </connection>
+ <connection>
+ <sender>dbTable</sender>
+ <signal>currentChanged(int,int)</signal>
+ <receiver>SqlConfigWidget</receiver>
+ <slot>updateButtons()</slot>
+ </connection>
+</connections>
+<includes>
+ <include location="local" impldecl="in implementation">sqlconfigwidget.ui.h</include>
+</includes>
+<forwards>
+ <forward>class QDomDocument;</forward>
+</forwards>
+<variables>
+ <variable access="private">QDomDocument* doc;</variable>
+ <variable access="private">bool changed;</variable>
+</variables>
+<signals>
+ <signal>newConfigSaved()</signal>
+</signals>
+<slots>
+ <slot>init()</slot>
+ <slot>valueChanged( int, int )</slot>
+ <slot>removeDb()</slot>
+ <slot>updateButtons()</slot>
+ <slot>testDb()</slot>
+ <slot>accept()</slot>
+ <slot>setProjectDom( QDomDocument * doc )</slot>
+ <slot>loadConfig()</slot>
+</slots>
+<layoutdefaults spacing="6" margin="11"/>
+<layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/>
+<includehints>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+</includehints>
+</UI>
diff --git a/languages/sql/sqlconfigwidget.ui.h b/languages/sql/sqlconfigwidget.ui.h
new file mode 100644
index 00000000..c99d8722
--- /dev/null
+++ b/languages/sql/sqlconfigwidget.ui.h
@@ -0,0 +1,244 @@
+/****************************************************************************
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you wish to add, delete or rename functions or slots use
+** Qt Designer which will update this file, preserving your code. Create an
+** init() function in place of a constructor, and a destroy() function in
+** place of a destructor.
+*****************************************************************************/
+
+#include <qsqldatabase.h>
+#include <qcombobox.h>
+#include <qspinbox.h>
+#include <qdom.h>
+#include <qstringlist.h>
+
+#include <klocale.h>
+#include <klineedit.h>
+#include <kmessagebox.h>
+
+#include <domutil.h>
+
+#include "sqlsupport_part.h"
+
+// displays a ComboBox on edit to let the user choose the plugin
+class PluginTableItem: public QTableItem
+{
+public:
+ PluginTableItem( QTable* table, const QString& text = QString::null ): QTableItem( table, QTableItem::OnTyping, text ) {}
+
+ virtual QWidget* createEditor() const
+ {
+ QComboBox* combo = new QComboBox( true, table() );
+ combo->insertStringList( QSqlDatabase::drivers() );
+ if ( !text().isEmpty() )
+ combo->setCurrentText( text() );
+ return combo;
+ }
+
+ virtual void setContentFromEditor( QWidget* w )
+ {
+ if ( w->inherits( "QComboBox" ) )
+ setText( ( (QComboBox*)w )->currentText() );
+ else
+ QTableItem::setContentFromEditor( w );
+ }
+};
+
+// uses a spinbox to let the user choose the port
+class PortTableItem: public QTableItem
+{
+public:
+ PortTableItem( QTable* table, const QString& text = QString::null ): QTableItem( table, QTableItem::OnTyping, text ) {}
+
+ virtual QWidget* createEditor() const
+ {
+ QSpinBox* sb = new QSpinBox( -1, 65535, 1, table() );
+ sb->setSpecialValueText( i18n("Default") );
+ if ( !text().isEmpty() )
+ sb->setValue( text().toInt() );
+ return sb;
+ }
+
+ virtual void setContentFromEditor( QWidget* w )
+ {
+ if ( w->inherits( "QSpinBox" ) )
+ setText( ( (QSpinBox*)w )->text() );
+ else
+ QTableItem::setContentFromEditor( w );
+ }
+};
+
+// uses a spinbox to let the user choose the port
+class PasswordTableItem: public QTableItem
+{
+public:
+ PasswordTableItem( QTable* table, const QString& text = QString::null ): QTableItem( table, QTableItem::OnTyping, text ) {}
+
+ virtual QWidget* createEditor() const
+ {
+ KLineEdit* le = new KLineEdit( table() );
+ le->setEchoMode( QLineEdit::Password );
+ return le;
+ }
+
+ virtual void setContentFromEditor( QWidget* w )
+ {
+ if ( w->inherits( "KLineEdit" ) ) {
+ password = ( (KLineEdit*)w )->text();
+ setText( QString().fill( '*', password.length() ) );
+ } else {
+ QTableItem::setContentFromEditor( w );
+ }
+ }
+
+ virtual void setText(const QString& bogus)
+ {
+ QTableItem::setText(QString().fill('*', bogus.length()));
+ }
+ QString password;
+};
+
+static bool isEmptyRow( QTable* tbl, int row )
+{
+ for ( int i = 0; i < tbl->numCols(); i++ ) {
+ if ( !tbl->text( row, i ).isEmpty() )
+ return false;
+ }
+ return true;
+}
+
+void SqlConfigWidget::init()
+{
+ int w = dbTable->fontMetrics().width( "W" );
+ dbTable->verticalHeader()->hide();
+ dbTable->setLeftMargin( 0 );
+ dbTable->setColumnWidth( 3, w * 5 );
+ updateButtons();
+ valueChanged( 0, 0 );
+ changed = false;
+}
+
+static void addRow( QTable* dbTable )
+{
+ dbTable->insertRows( dbTable->numRows() );
+ dbTable->setItem( dbTable->numRows() - 1, 0,
+ new PluginTableItem( dbTable ) );
+ dbTable->setItem( dbTable->numRows() - 1, 3,
+ new PortTableItem( dbTable ) );
+ dbTable->setItem( dbTable->numRows() - 1, 5,
+ new PasswordTableItem( dbTable ) );
+}
+
+void SqlConfigWidget::valueChanged( int, int )
+{
+ int lrow = dbTable->numRows() - 1;
+ if ( lrow < 0 || !isEmptyRow( dbTable, lrow ) ) {
+ addRow( dbTable );
+ }
+ changed = true;
+}
+
+
+void SqlConfigWidget::removeDb()
+{
+ if ( dbTable->currentRow() >= 0 )
+ dbTable->removeRow( dbTable->currentRow() );
+ valueChanged( 0, 0 );
+ updateButtons();
+}
+
+
+void SqlConfigWidget::updateButtons()
+{
+ if ( dbTable->currentRow() < 0 ) {
+ testBtn->setEnabled( false );
+ removeBtn->setEnabled( false );
+ return;
+ }
+ testBtn->setEnabled( !isEmptyRow( dbTable, dbTable->currentRow() ) );
+ removeBtn->setEnabled( dbTable->currentRow() + 1 < dbTable->numRows() );
+}
+
+
+void SqlConfigWidget::testDb()
+{
+ static const QString cName( "SqlConfigWidgetTest" );
+ int cr = dbTable->currentRow();
+ if (cr < 0)
+ return;
+
+ QSqlDatabase* db = QSqlDatabase::addDatabase( dbTable->text( cr, 0 ), cName );
+ db->setDatabaseName( dbTable->text( cr, 1 ) );
+ db->setHostName( dbTable->text( cr, 2 ) );
+ bool ok;
+ int port = dbTable->text( cr, 3 ).toInt( &ok );
+ if (ok && port >= 0)
+ db->setPort( port );
+ QString pass = ((PasswordTableItem*)dbTable->item( cr, 5 ))->password;
+
+ if ( db->open( dbTable->text( cr, 4 ), pass ) ) {
+ KMessageBox::information( this, i18n("Connection successful") );
+ db->close();
+ } else {
+ KMessageBox::detailedSorry( this, i18n("Unable to connect to database server"),
+ db->lastError().driverText() + "\n" +
+ db->lastError().databaseText() );
+ }
+
+ db = 0;
+ QSqlDatabase::removeDatabase( cName );
+}
+
+
+void SqlConfigWidget::accept()
+{
+ Q_ASSERT( doc );
+
+ QDomElement dbElem = DomUtil::createElementByPath( *doc, "/kdevsqlsupport/servers" );
+ DomUtil::makeEmpty( dbElem );
+
+ for ( int i = 0; i < dbTable->numRows() - 1; i++ ) {
+ QStringList db;
+ db << dbTable->text( i, 0 ) << dbTable->text( i, 1 )
+ << dbTable->text( i, 2 ) << dbTable->text( i, 3 )
+ << dbTable->text( i, 4 )
+ << SQLSupportPart::cryptStr( ((PasswordTableItem*)dbTable->item( i, 5 ))->password );
+
+ DomUtil::writeListEntry( *doc,
+ "/kdevsqlsupport/servers/server" + QString::number( i ),
+ "el", db );
+ }
+ if ( changed )
+ emit newConfigSaved();
+}
+
+
+void SqlConfigWidget::setProjectDom( QDomDocument * doc )
+{
+ this->doc = doc;
+}
+
+
+void SqlConfigWidget::loadConfig()
+{
+ Q_ASSERT( doc );
+
+ QStringList db;
+ int i = 0;
+ while ( true ) {
+ QStringList db = DomUtil::readListEntry( *doc, "kdevsqlsupport/servers/server" + QString::number( i ), "el" );
+ if ( db.isEmpty() )
+ return;
+
+ addRow( dbTable );
+ int row = dbTable->numRows() - 2;
+ for ( int ii = 0; ii < 6; ii++ )
+ dbTable->setText( row, ii, db[ii] );
+ ((PasswordTableItem*)dbTable->item( row, 5 ))->password = SQLSupportPart::cryptStr( db[5] );
+
+ i++;
+ }
+ updateButtons();
+ changed = false;
+}
diff --git a/languages/sql/sqloutputwidget.cpp b/languages/sql/sqloutputwidget.cpp
new file mode 100644
index 00000000..a0d7368d
--- /dev/null
+++ b/languages/sql/sqloutputwidget.cpp
@@ -0,0 +1,127 @@
+/***************************************************************************
+ * Copyright (C) 2003 by Harald Fernengel *
+ * harry@kdevelop.org *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include <qsqldatabase.h>
+#include <qsqlerror.h>
+#include <qsqlcursor.h>
+#include <qsqldriver.h>
+#include <qsqlrecord.h>
+#include <qwidgetstack.h>
+#include <qdatatable.h>
+#include <qtextedit.h>
+#include <qlayout.h>
+#include <qstylesheet.h>
+
+#include <klocale.h>
+
+#include "sqloutputwidget.h"
+
+class QCustomSqlCursor: public QSqlCursor
+{
+public:
+ QCustomSqlCursor( const QString & query = QString::null, bool autopopulate = TRUE, QSqlDatabase* db = 0 ) :
+ QSqlCursor( QString::null, autopopulate, db )
+ {
+ exec( query );
+ if ( isSelect() && autopopulate ) {
+ QSqlRecordInfo inf = ((QSqlQuery*)this)->driver()->recordInfo( *(QSqlQuery*)this );
+ for ( QSqlRecordInfo::iterator it = inf.begin(); it != inf.end(); ++it ) {
+ append( *it );
+ }
+ }
+ setMode( QSqlCursor::ReadOnly );
+ }
+ QCustomSqlCursor( const QCustomSqlCursor & other ): QSqlCursor( other ) {}
+ bool select( const QString & /*filter*/, const QSqlIndex & /*sort*/ = QSqlIndex() )
+ { return exec( lastQuery() ); }
+ QSqlIndex primaryIndex( bool /*prime*/ = TRUE ) const
+ { return QSqlIndex(); }
+ int insert( bool /*invalidate*/ = TRUE )
+ { return FALSE; }
+ int update( bool /*invalidate*/ = TRUE )
+ { return FALSE; }
+ int del( bool /*invalidate*/ = TRUE )
+ { return FALSE; }
+ void setName( const QString& /*name*/, bool /*autopopulate*/ = TRUE ) {}
+};
+
+
+SqlOutputWidget::SqlOutputWidget ( QWidget* parent, const char* name ) :
+ QWidget( parent, name )
+{
+ m_stack = new QWidgetStack( this );
+ m_table = new QDataTable( this );
+ m_textEdit = new QTextEdit( this );
+
+ m_textEdit->setTextFormat( QTextEdit::RichText );
+ m_textEdit->setReadOnly( true );
+
+ m_stack->addWidget( m_textEdit );
+ m_stack->addWidget( m_table );
+
+ QVBoxLayout* layout = new QVBoxLayout( this );
+ layout->addWidget( m_stack );
+}
+
+SqlOutputWidget::~SqlOutputWidget()
+{}
+
+void SqlOutputWidget::showQuery( const QString& connectionName, const QString& query )
+{
+ QSqlDatabase* db = QSqlDatabase::database( connectionName, true );
+ if ( !db ) {
+ showError( i18n("No such connection: %1").arg( connectionName ) );
+ return;
+ }
+ if ( !db->isOpen() ) {
+ showError( db->lastError() );
+ return;
+ }
+
+ QSqlCursor* cur = new QCustomSqlCursor( query, true, db );
+ if ( !cur->isActive() ) {
+ showError( cur->lastError() );
+ } else if ( cur->isSelect() ) {
+ m_table->setSqlCursor( cur, true, true );
+ m_table->refresh( QDataTable::RefreshAll );
+ m_stack->raiseWidget( m_table );
+ } else {
+ showSuccess( cur->numRowsAffected() );
+ }
+}
+
+void SqlOutputWidget::showSuccess( int rowsAffected )
+{
+ m_textEdit->clear();
+ m_textEdit->setText( i18n("Query successful, number of rows affected: %1").arg( rowsAffected ) );
+ m_stack->raiseWidget( m_textEdit );
+}
+
+void SqlOutputWidget::showError( const QString& message )
+{
+ m_textEdit->clear();
+ m_textEdit->setText( "<p><b>" + i18n("An error occurred:") + "</b></p>\n" + message );
+ m_stack->raiseWidget( m_textEdit );
+}
+
+void SqlOutputWidget::showError( const QSqlError& message )
+{
+ m_textEdit->clear();
+ m_textEdit->setText( "<p><b>" + i18n("An error occurred:") +
+ "</b></p>\n<p><i>" + i18n("Driver") + "</i>: " +
+ QStyleSheet::escape( message.driverText() ) +
+ "<br><i>" + i18n("Database") + ":</i>: " +
+ QStyleSheet::escape( message.databaseText() ) );
+ m_stack->raiseWidget( m_textEdit );
+}
+
+#include "sqloutputwidget.moc"
+
diff --git a/languages/sql/sqloutputwidget.h b/languages/sql/sqloutputwidget.h
new file mode 100644
index 00000000..40c8612a
--- /dev/null
+++ b/languages/sql/sqloutputwidget.h
@@ -0,0 +1,43 @@
+/***************************************************************************
+ * Copyright (C) 2003 by Harald Fernengel *
+ * harry@kdevelop.org *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef _SQLOUTPUTWIDGET_H_
+#define _SQLOUTPUTWIDGET_H_
+
+#include <qwidget.h>
+
+class QWidgetStack;
+class QDataTable;
+class QTextEdit;
+class QSqlError;
+
+class SqlOutputWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ SqlOutputWidget( QWidget* parent = 0, const char* name = 0 );
+ virtual ~SqlOutputWidget();
+
+public:
+ void showQuery( const QString& connectionName, const QString& query );
+ void showError( const QSqlError& error );
+
+private:
+ void showError( const QString& msg );
+ void showSuccess( int rowsAffected );
+
+ QWidgetStack* m_stack;
+ QDataTable* m_table;
+ QTextEdit* m_textEdit;
+};
+
+#endif
diff --git a/languages/sql/sqlsupport_part.cpp b/languages/sql/sqlsupport_part.cpp
new file mode 100644
index 00000000..c1e13ac0
--- /dev/null
+++ b/languages/sql/sqlsupport_part.cpp
@@ -0,0 +1,284 @@
+#include "sqlsupport_part.h"
+#include <qwhatsthis.h>
+#include <qstringlist.h>
+#include <qtimer.h>
+#include <qsqldatabase.h>
+#include <qsqlrecord.h>
+
+#include <kapplication.h>
+#include <kiconloader.h>
+#include <klocale.h>
+#include <kdevgenericfactory.h>
+#include <kdebug.h>
+#include <kaction.h>
+#include <kparts/part.h>
+#include <kdialogbase.h>
+#include <ktexteditor/editinterface.h>
+#include <kmessagebox.h>
+
+#include "kdevcore.h"
+#include "kdevmainwindow.h"
+#include "kdevlanguagesupport.h"
+#include "kdevpartcontroller.h"
+#include "kdevproject.h"
+#include "codemodel.h"
+#include "kdevplugininfo.h"
+
+#include "sqlconfigwidget.h"
+#include "sqlactions.h"
+#include "sqloutputwidget.h"
+#include "domutil.h"
+
+typedef KDevGenericFactory<SQLSupportPart> SQLSupportFactory;
+static const KDevPluginInfo data("kdevsqlsupport");
+K_EXPORT_COMPONENT_FACTORY( libkdevsqlsupport, SQLSupportFactory( data ) )
+
+SQLSupportPart::SQLSupportPart( QObject *parent, const char *name, const QStringList& )
+ : KDevLanguageSupport ( &data, parent, name ? name : "SQLSupportPart" )
+{
+ setInstance( SQLSupportFactory::instance() );
+ setXMLFile( "kdevsqlsupport.rc" );
+
+ KAction *action;
+ action = new KAction( i18n( "&Run" ), "exec", Key_F9, this, SLOT( slotRun() ), actionCollection(), "build_execute" );
+ action->setToolTip(i18n("Run"));
+ action->setWhatsThis(i18n("<b>Run</b><p>Executes a SQL script."));
+
+ dbAction = new SqlListAction( this, i18n( "&Database Connections" ), 0, this, SLOT(activeConnectionChanged()), actionCollection(), "connection_combo" );
+
+ kdDebug( 9000 ) << "Creating SQLSupportPart" << endl;
+
+ connect( core(), SIGNAL( projectConfigWidget( KDialogBase* ) ),
+ this, SLOT( projectConfigWidget( KDialogBase* ) ) );
+ connect( core(), SIGNAL(projectOpened()), this, SLOT(projectOpened()) );
+ connect( core(), SIGNAL(projectClosed()), this, SLOT(projectClosed()) );
+ connect( core(), SIGNAL(languageChanged()), this, SLOT(projectOpened()) );
+ connect( partController(), SIGNAL( savedFile( const KURL& ) ), this, SLOT( savedFile( const KURL& ) ) );
+
+ m_widget = new SqlOutputWidget();
+ mainWindow()->embedOutputView( m_widget, i18n( "SQL" ), i18n( "Output of SQL commands" ) );
+ QWhatsThis::add(m_widget, i18n("<b>Output of SQL commands</b><p>This window shows the output of SQL commands being executed. It can display results of SQL \"select\" commands in a table."));
+}
+
+
+SQLSupportPart::~SQLSupportPart()
+{
+ mainWindow()->removeView(m_widget);
+ delete m_widget;
+}
+
+QString SQLSupportPart::cryptStr(const QString& aStr)
+{
+ QString result;
+ for (unsigned int i = 0; i < aStr.length(); i++)
+ result += (aStr[i].unicode() < 0x20) ? aStr[i] :
+ QChar(0x1001F - aStr[i].unicode());
+ return result;
+}
+
+void SQLSupportPart::activeConnectionChanged()
+{
+ updateCatalog();
+}
+
+void SQLSupportPart::clearConfig()
+{
+ for ( QStringList::Iterator it = conNames.begin(); it != conNames.end(); ++it ) {
+ if ( QSqlDatabase::contains( *it ) ) {
+ QSqlDatabase::database( *it, false )->close();
+ QSqlDatabase::removeDatabase( *it );
+ } else {
+ kdDebug( 9000 ) << "Could not find connection named " << (*it) << endl;
+ }
+ }
+ conNames.clear();
+
+ dbAction->refresh();
+}
+
+void SQLSupportPart::loadConfig()
+{
+ clearConfig();
+
+ QDomDocument* doc = projectDom();
+
+ QStringList db;
+ int i = 0;
+ QString conName;
+ while ( true ) {
+ QStringList sdb = DomUtil::readListEntry( *doc, "kdevsqlsupport/servers/server" + QString::number( i ), "el" );
+ if ( (int)sdb.size() < 6 )
+ break;
+
+ conName = "KDEVSQLSUPPORT_";
+ conName += QString::number( i );
+ conNames << conName;
+ QSqlDatabase* db = QSqlDatabase::addDatabase( sdb[0], QString( "KDEVSQLSUPPORT_%1" ).arg( i ) );
+ db->setDatabaseName( sdb[1] );
+ db->setHostName( sdb[2] );
+ bool ok;
+ int port = sdb[3].toInt( &ok );
+ if ( ok )
+ db->setPort( port );
+ db->setUserName( sdb[4] );
+ db->setPassword( cryptStr( sdb[5] ) );
+ db->open();
+
+ i++;
+ }
+
+ dbAction->refresh();
+}
+
+void SQLSupportPart::projectConfigWidget( KDialogBase *dlg )
+{
+ QVBox *vbox = dlg->addVBoxPage( QString( "SQL" ), i18n( "Specify Your Database Connections" ), BarIcon("source", KIcon::SizeMedium) );
+ SqlConfigWidget *w = new SqlConfigWidget( (QWidget*)vbox, "SQL config widget" );
+ w->setProjectDom( projectDom() );
+ w->loadConfig();
+ connect( dlg, SIGNAL(okClicked()), w, SLOT(accept()) );
+ connect( w, SIGNAL(newConfigSaved()), this, SLOT(loadConfig()) );
+}
+
+void SQLSupportPart::projectOpened()
+{
+ connect( project(), SIGNAL( addedFilesToProject( const QStringList & ) ),
+ this, SLOT( addedFilesToProject( const QStringList & ) ) );
+ connect( project(), SIGNAL( removedFilesFromProject( const QStringList & ) ),
+ this, SLOT( removedFilesFromProject( const QStringList & ) ) );
+
+ loadConfig();
+
+ // We want to parse only after all components have been
+ // properly initialized
+ QTimer::singleShot( 0, this, SLOT( parse() ) );
+}
+
+
+void SQLSupportPart::projectClosed()
+{
+ clearConfig();
+}
+
+void SQLSupportPart::slotRun ()
+{
+ QString cName = dbAction->currentConnectionName();
+ if ( cName.isEmpty() ) {
+ KMessageBox::sorry( 0, i18n("Please select a valid database connection.") );
+ return;
+ }
+
+ KTextEditor::EditInterface* doc = dynamic_cast<KTextEditor::EditInterface*>(partController()->activePart());
+ if ( !doc )
+ return; // show error message?
+
+ mainWindow()->raiseView( m_widget );
+ m_widget->showQuery( cName, doc->text() );
+}
+
+#if 0
+static QString dbCaption(const QSqlDatabase* db)
+{
+ QString res;
+ if (!db)
+ return res;
+ res = db->driverName();
+ res += QString::fromLatin1("@");
+ res += db->hostName();
+ if (db->port() >= 0)
+ res += QString::fromLatin1(":") + QString::number(db->port());
+ return res;
+}
+#endif
+
+void SQLSupportPart::parse()
+{
+ // @todo
+}
+
+void SQLSupportPart::updateCatalog()
+{
+ if (!project() || !dbAction)
+ return;
+
+ codeModel()->wipeout();
+
+ QString curConnection = dbAction->currentConnectionName();
+ if (curConnection.isEmpty()) {
+ emit updatedSourceInfo();
+ return;
+ }
+
+ FileDom dbf = codeModel()->create<FileModel>();
+ dbf->setName(dbAction->currentConnectionName());
+ QSqlDatabase *db = QSqlDatabase::database(dbAction->currentConnectionName(), true);
+
+ // tables are classes and fields are methods
+ if (db->isOpen()) {
+ QSqlRecord inf;
+ QStringList tables = db->tables();
+ for (QStringList::Iterator it = tables.begin(); it != tables.end(); ++it) {
+ ClassDom dbc = codeModel()->create<ClassModel>();
+ dbc->setName(*it);
+ inf = db->record(*it);
+ for (int i = 0; i < (int)inf.count(); ++i) {
+ FunctionDom dbv = codeModel()->create<FunctionModel>();
+ dbv->setName(inf.fieldName(i));
+ dbv->setResultType(QVariant::typeToName(inf.field(i)->type()));
+ dbc->addFunction(dbv);
+ }
+ dbf->addClass(dbc);
+ }
+ }
+
+ codeModel()->addFile(dbf);
+
+ emit updatedSourceInfo();
+}
+
+void SQLSupportPart::addedFilesToProject( const QStringList &fileList )
+{
+ QStringList::ConstIterator it;
+
+ for ( it = fileList.begin(); it != fileList.end(); ++it ) {
+// parse( project() ->projectDirectory() + "/" + ( *it ) );
+ }
+
+ emit updatedSourceInfo();
+}
+
+
+void SQLSupportPart::removedFilesFromProject( const QStringList &fileList )
+{
+ QStringList::ConstIterator it;
+
+ for ( it = fileList.begin(); it != fileList.end(); ++it ) {
+// classStore() ->removeWithReferences( project() ->projectDirectory() + "/" + ( *it ) );
+ }
+
+ emit updatedSourceInfo();
+}
+
+void SQLSupportPart::savedFile( const KURL &fileName )
+{
+ if ( project() ->allFiles().contains( fileName.path().mid ( project() ->projectDirectory().length() + 1 ) ) ) {
+// parse( fileName );
+// emit updatedSourceInfo();
+ }
+}
+
+KDevLanguageSupport::Features SQLSupportPart::features()
+{
+ return Features( Classes | Functions );
+}
+
+KMimeType::List SQLSupportPart::mimeTypes( )
+{
+ KMimeType::List list;
+ KMimeType::Ptr mime = KMimeType::mimeType( "text/plain" );
+ if( mime )
+ list << mime;
+ return list;
+}
+
+#include "sqlsupport_part.moc"
diff --git a/languages/sql/sqlsupport_part.h b/languages/sql/sqlsupport_part.h
new file mode 100644
index 00000000..e9ad6dbd
--- /dev/null
+++ b/languages/sql/sqlsupport_part.h
@@ -0,0 +1,55 @@
+#ifndef __KDEVPART_SQLSUPPORT_H__
+#define __KDEVPART_SQLSUPPORT_H__
+
+#include <qguardedptr.h>
+#include <qstringlist.h>
+
+#include <kprocess.h>
+#include <kdialogbase.h>
+
+#include "kdevplugin.h"
+#include "kdevlanguagesupport.h"
+
+class SqlListAction;
+class SqlOutputWidget;
+class CodeModel;
+
+class SQLSupportPart : public KDevLanguageSupport
+{
+ Q_OBJECT
+
+public:
+
+ SQLSupportPart(QObject *parent, const char *name, const QStringList &);
+ virtual ~SQLSupportPart();
+
+ static QString cryptStr(const QString& aStr);
+ const QStringList& connections() const { return conNames; }
+
+
+protected:
+ virtual Features features();
+ virtual KMimeType::List mimeTypes();
+
+private slots:
+ void slotRun();
+ void projectConfigWidget(KDialogBase *dlg);
+ void projectOpened();
+ void projectClosed();
+ void savedFile(const KURL &fileName);
+ void addedFilesToProject(const QStringList &fileList);
+ void removedFilesFromProject(const QStringList &fileList);
+ void parse();
+ void loadConfig();
+ void activeConnectionChanged();
+
+private:
+ void clearConfig();
+ void updateCatalog();
+ SqlListAction* dbAction;
+ SqlOutputWidget* m_widget;
+ QStringList conNames;
+ CodeModel *m_store;
+};
+
+#endif