From 114a878c64ce6f8223cfd22d76a20eb16d177e5e Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: 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 --- languages/sql/Makefile.am | 20 ++ languages/sql/README.dox | 40 +++ languages/sql/app_templates/Makefile.am | 3 + languages/sql/app_templates/sql.appwizard | 2 + languages/sql/app_templates/sqlsimple/.kdev_ignore | 0 languages/sql/app_templates/sqlsimple/Makefile.am | 16 ++ languages/sql/app_templates/sqlsimple/app.kdevelop | 84 ++++++ languages/sql/app_templates/sqlsimple/app.sql | 1 + languages/sql/app_templates/sqlsimple/sqlsimple | 7 + .../app_templates/sqlsimple/sqlsimple.kdevtemplate | 106 ++++++++ .../sql/app_templates/sqlsimple/sqlsimple.png | Bin 0 -> 483 bytes languages/sql/doc/Makefile.am | 6 + languages/sql/kdevsqlsupport.desktop | 85 ++++++ languages/sql/kdevsqlsupport.rc | 14 + languages/sql/sqlactions.cpp | 103 ++++++++ languages/sql/sqlactions.h | 41 +++ languages/sql/sqlconfigwidget.ui | 189 ++++++++++++++ languages/sql/sqlconfigwidget.ui.h | 244 ++++++++++++++++++ languages/sql/sqloutputwidget.cpp | 127 +++++++++ languages/sql/sqloutputwidget.h | 43 ++++ languages/sql/sqlsupport_part.cpp | 284 +++++++++++++++++++++ languages/sql/sqlsupport_part.h | 55 ++++ 22 files changed, 1470 insertions(+) create mode 100644 languages/sql/Makefile.am create mode 100644 languages/sql/README.dox create mode 100644 languages/sql/app_templates/Makefile.am create mode 100644 languages/sql/app_templates/sql.appwizard create mode 100644 languages/sql/app_templates/sqlsimple/.kdev_ignore create mode 100644 languages/sql/app_templates/sqlsimple/Makefile.am create mode 100644 languages/sql/app_templates/sqlsimple/app.kdevelop create mode 100644 languages/sql/app_templates/sqlsimple/app.sql create mode 100644 languages/sql/app_templates/sqlsimple/sqlsimple create mode 100644 languages/sql/app_templates/sqlsimple/sqlsimple.kdevtemplate create mode 100644 languages/sql/app_templates/sqlsimple/sqlsimple.png create mode 100644 languages/sql/doc/Makefile.am create mode 100644 languages/sql/kdevsqlsupport.desktop create mode 100644 languages/sql/kdevsqlsupport.rc create mode 100644 languages/sql/sqlactions.cpp create mode 100644 languages/sql/sqlactions.h create mode 100644 languages/sql/sqlconfigwidget.ui create mode 100644 languages/sql/sqlconfigwidget.ui.h create mode 100644 languages/sql/sqloutputwidget.cpp create mode 100644 languages/sql/sqloutputwidget.h create mode 100644 languages/sql/sqlsupport_part.cpp create mode 100644 languages/sql/sqlsupport_part.h (limited to 'languages/sql') 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 Harald Fernengel + +\maintainer Harald Fernengel + +\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 First frequenly asked question about your part ? Answer. +\faq Second frequenly asked question about your part ? Answer. +... +\faq Last frequenly asked question about your part ? 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 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 @@ + + + + %{AUTHOR} + %{EMAIL} + %{VERSION} + KDevScriptProject + SQL + + SQL + + + KDevdistpart + KDevDebugger + + + + + src + *.sql + *~ + + + + + + + + + + ada + ada_bugs_gcc + bash + bash_bugs + c++_bugs_gcc + clanlib + w3c-dom-level2-html + fortran_bugs_gcc + gnome1 + gnustep + gtk + gtk_bugs + haskell + haskell_bugs_ghc + java_bugs_gcc + java_bugs_sun + kde2book + libc + libstdc++ + opengl + pascal_bugs_fp + php + php_bugs + perl + perl_bugs + python + python_bugs + qt-kdev3 + ruby + ruby_bugs + sdl + stl + w3c-svg + sw + w3c-uaag10 + wxwidgets_bugs + + + Guide to the Qt Translation Tools + Qt Assistant Manual + Qt Designer Manual + Qt Reference Documentation + qmake User Guide + + + KDE Libraries (Doxygen) + + + + + + + + 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 Binary files /dev/null and b/languages/sql/app_templates/sqlsimple/sqlsimple.png 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 @@ + + + + + + + + + + + + + + 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 +#include +#include + +#include +#include +#include +#include +#include + +#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("") ); + + 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("").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 +#include +#include + +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 @@ + +SqlConfigWidget + + + SqlConfigWidget + + + + 0 + 0 + 578 + 367 + + + + + unnamed + + + + + Plugin + + + + + + + + Database Name + + + + + + + + Host + + + + + + + + Port + + + + + + + + Username + + + + + + + + Password + + + + + + + dbTable + + + 0 + + + 6 + + + SingleRow + + + + + textLabel1 + + + <i>Warning:</i> password will be saved with weak encryption. + + + + + layout5 + + + + unnamed + + + + spacer4 + + + Horizontal + + + Expanding + + + + 81 + 20 + + + + + + removeBtn + + + &Remove + + + + + testBtn + + + &Test + + + + + + + + + dbTable + valueChanged(int,int) + SqlConfigWidget + valueChanged(int,int) + + + removeBtn + clicked() + SqlConfigWidget + removeDb() + + + testBtn + clicked() + SqlConfigWidget + testDb() + + + dbTable + currentChanged(int,int) + SqlConfigWidget + updateButtons() + + + + sqlconfigwidget.ui.h + + + class QDomDocument; + + + QDomDocument* doc; + bool changed; + + + newConfigSaved() + + + init() + valueChanged( int, int ) + removeDb() + updateButtons() + testDb() + accept() + setProjectDom( QDomDocument * doc ) + loadConfig() + + + + + kpushbutton.h + kpushbutton.h + + 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 +#include +#include +#include +#include + +#include +#include +#include + +#include + +#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 +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#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( "

" + i18n("An error occurred:") + "

\n" + message ); + m_stack->raiseWidget( m_textEdit ); +} + +void SqlOutputWidget::showError( const QSqlError& message ) +{ + m_textEdit->clear(); + m_textEdit->setText( "

" + i18n("An error occurred:") + + "

\n

" + i18n("Driver") + ": " + + QStyleSheet::escape( message.driverText() ) + + "
" + i18n("Database") + ":: " + + 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 + +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 +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#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 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("Run

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("Output of SQL commands

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(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(); + 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(); + dbc->setName(*it); + inf = db->record(*it); + for (int i = 0; i < (int)inf.count(); ++i) { + FunctionDom dbv = codeModel()->create(); + 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 +#include + +#include +#include + +#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 -- cgit v1.2.1