summaryrefslogtreecommitdiffstats
path: root/parts/filter
diff options
context:
space:
mode:
Diffstat (limited to 'parts/filter')
-rw-r--r--parts/filter/Makefile.am17
-rw-r--r--parts/filter/README.dox52
-rw-r--r--parts/filter/filterpart.cpp160
-rw-r--r--parts/filter/filterpart.h41
-rw-r--r--parts/filter/kdevfilter.desktop82
-rw-r--r--parts/filter/kdevfilter.rc10
-rw-r--r--parts/filter/kdevfilterIface.cpp35
-rw-r--r--parts/filter/kdevfilterIface.h26
-rw-r--r--parts/filter/shellfilterdlg.cpp128
-rw-r--r--parts/filter/shellfilterdlg.h52
-rw-r--r--parts/filter/shellinsertdlg.cpp125
-rw-r--r--parts/filter/shellinsertdlg.h49
12 files changed, 777 insertions, 0 deletions
diff --git a/parts/filter/Makefile.am b/parts/filter/Makefile.am
new file mode 100644
index 00000000..5a447405
--- /dev/null
+++ b/parts/filter/Makefile.am
@@ -0,0 +1,17 @@
+# Here resides the filter part
+
+INCLUDES = -I$(top_srcdir)/lib/interfaces -I$(top_srcdir)/lib/util $(all_includes)
+
+kde_module_LTLIBRARIES = libkdevfilter.la
+libkdevfilter_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN)
+libkdevfilter_la_LIBADD = $(top_builddir)/lib/libkdevelop.la
+
+libkdevfilter_la_SOURCES = filterpart.cpp shellfilterdlg.cpp shellinsertdlg.cpp kdevfilterIface.cpp kdevfilterIface.skel
+
+METASOURCES = AUTO
+
+servicedir = $(kde_servicesdir)
+service_DATA = kdevfilter.desktop
+
+rcdir = $(kde_datadir)/kdevfilter
+rc_DATA = kdevfilter.rc
diff --git a/parts/filter/README.dox b/parts/filter/README.dox
new file mode 100644
index 00000000..452db8ca
--- /dev/null
+++ b/parts/filter/README.dox
@@ -0,0 +1,52 @@
+/** \class FilterPart
+Put a brief description here, the brief description ends at the first dot.
+Put a more detailed description of your part in these lines. It can span
+over several lines. You can even use some html commands in these lines like:
+<code>This is code</code>, html links <a href="http://somelocation">link text</a>,
+and images.
+
+\authors <a href="mailto:$EMAIL$">$AUTHOR$</a>
+\authors <a href="mailto:2nd author AT provider.com">2nd author full name</a>
+...
+\authors <a href="mailto:nth author AT provider.com">nth author full name</a>
+
+\maintainer <a href="mailto:$EMAIL$">$AUTHOR$</a>
+\maintainer <a href="mailto:2nd maintainer AT provider.com">2nd maintainer full name</a>
+...
+\maintainer <a href="mailto:nth maintainer AT provider.com">nth maintainer full name</a>
+
+\feature Describe the first feature
+\feature Describe the second feature
+...
+\feature Describe the last feature
+
+\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/parts/filter/filterpart.cpp b/parts/filter/filterpart.cpp
new file mode 100644
index 00000000..8804e701
--- /dev/null
+++ b/parts/filter/filterpart.cpp
@@ -0,0 +1,160 @@
+/***************************************************************************
+ * Copyright (C) 2002 by Bernd Gehrmann *
+ * bernd@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 "filterpart.h"
+
+#include <kaction.h>
+#include <kdebug.h>
+#include <klocale.h>
+#include <kparts/part.h>
+#include <ktexteditor/editinterface.h>
+#include <ktexteditor/selectioninterface.h>
+#include <ktexteditor/viewcursorinterface.h>
+
+#include "kdevcore.h"
+#include "kdevpartcontroller.h"
+#include "kdevplugininfo.h"
+#include "shellfilterdlg.h"
+#include "shellinsertdlg.h"
+#include "kdevfilterIface.h"
+
+static const KDevPluginInfo data("kdevfilter");
+K_EXPORT_COMPONENT_FACTORY( libkdevfilter, FilterFactory( data ) )
+
+FilterPart::FilterPart(QObject *parent, const char *name, const QStringList &)
+ : KDevPlugin(&data, parent, name ? name : "FilterPart")
+{
+ setInstance(FilterFactory::instance());
+ setXMLFile("kdevfilter.rc");
+
+ KAction *action;
+
+ action = new KAction( i18n("Execute Command..."), 0,
+ this, SLOT(slotShellInsert()),
+ actionCollection(), "tools_insertshell" );
+ action->setToolTip(i18n("Execute shell command"));
+ action->setWhatsThis(i18n("<b>Execute shell command</b><p>Executes a shell command and outputs its result into the current document."));
+
+ action = new KAction( i18n("Filter Selection Through Command..."), 0,
+ this, SLOT(slotShellFilter()),
+ actionCollection(), "tools_filtershell" );
+ action->setToolTip(i18n("Filter selection through a shell command"));
+ action->setWhatsThis(i18n("<b>Filter selection through shell command</b><p>Filters selection through a shell command and outputs its result into the current document."));
+
+ m_insertDialog = 0;
+ m_filterDialog = 0;
+
+ new KDevFilterIface( this );
+ // (void) dcopClient();
+}
+
+
+FilterPart::~FilterPart()
+{
+ delete m_insertDialog;
+ delete m_filterDialog;
+}
+
+
+void FilterPart::slotShellInsert()
+{
+ /// @todo Disable menu item if no active part
+
+ KParts::ReadWritePart *part
+ = dynamic_cast<KParts::ReadWritePart*>(partController()->activePart());
+ QWidget *view = partController()->activeWidget();
+ if (!part || !view) {
+ kdDebug(9029) << "no rw part" << endl;
+ return;
+ }
+
+ KTextEditor::EditInterface *editiface
+ = dynamic_cast<KTextEditor::EditInterface*>(part);
+ if (!editiface) {
+ kdDebug(9029) << "no edit" << endl;
+ return;
+ }
+
+ KTextEditor::ViewCursorInterface *cursoriface
+ = dynamic_cast<KTextEditor::ViewCursorInterface*>(view);
+ if (!cursoriface) {
+ kdDebug(9029) << "no viewcursor" << endl;
+ return;
+ }
+
+ if (!m_insertDialog)
+ {
+ m_insertDialog = new ShellInsertDialog();
+ m_insertDialog->setCaption(i18n("Execute Command"));
+ }
+ if (m_insertDialog->exec()) {
+ uint line, col;
+ cursoriface->cursorPositionReal(&line, &col);
+ editiface->insertText(line, col, m_insertDialog->text());
+ }
+}
+
+
+void FilterPart::slotShellFilter()
+{
+ /// @todo Disable menu item if no active part
+
+ KParts::ReadWritePart *part
+ = dynamic_cast<KParts::ReadWritePart*>(partController()->activePart());
+ QWidget *view = partController()->activeWidget();
+ if (!part || !view) {
+ kdDebug(9029) << "no rw part" << endl;
+ return;
+ }
+
+ KTextEditor::EditInterface *editiface
+ = dynamic_cast<KTextEditor::EditInterface*>(part);
+ if (!editiface) {
+ kdDebug(9029) << "no edit" << endl;
+ return;
+ }
+
+ KTextEditor::ViewCursorInterface *cursoriface
+ = dynamic_cast<KTextEditor::ViewCursorInterface*>(view);
+ if (!cursoriface) {
+ kdDebug(9029) << "no viewcursor" << endl;
+ return;
+ }
+
+ KTextEditor::SelectionInterface *selectioniface
+ = dynamic_cast<KTextEditor::SelectionInterface*>(part);
+ if (!selectioniface) {
+ kdDebug(9029) << "no selection" << endl;
+ return;
+ }
+
+ if (!m_filterDialog)
+ {
+ m_filterDialog = new ShellFilterDialog();
+ m_filterDialog->setCaption(i18n("Filter Selection Through Command"));
+ }
+
+ kdDebug(9029) << "Old text: " << selectioniface->selection()<< endl;
+
+ m_filterDialog->setText(selectioniface->selection());
+
+ if (m_filterDialog->exec()) {
+ uint line, col;
+ // OUCH: KTextEditor doesn't allow to find out
+ // where the selection is
+ selectioniface->removeSelectedText();
+ cursoriface->cursorPositionReal(&line, &col);
+ kdDebug(9029) << "New text: " << m_filterDialog->text() << endl;
+ editiface->insertText(line, col, m_filterDialog->text());
+ }
+}
+
+#include "filterpart.moc"
diff --git a/parts/filter/filterpart.h b/parts/filter/filterpart.h
new file mode 100644
index 00000000..ec731f12
--- /dev/null
+++ b/parts/filter/filterpart.h
@@ -0,0 +1,41 @@
+/***************************************************************************
+ * Copyright (C) 2002 by Bernd Gehrmann *
+ * bernd@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 _FILTERPART_H_
+#define _FILTERPART_H_
+
+#include <kdevgenericfactory.h>
+#include "kdevplugin.h"
+
+class ShellInsertDialog;
+class ShellFilterDialog;
+
+
+class FilterPart : public KDevPlugin
+{
+ Q_OBJECT
+
+public:
+ FilterPart( QObject *parent, const char *name, const QStringList & );
+ ~FilterPart();
+
+public slots:
+ void slotShellInsert();
+ void slotShellFilter();
+
+private:
+ ShellInsertDialog *m_insertDialog;
+ ShellFilterDialog *m_filterDialog;
+};
+
+typedef KDevGenericFactory<FilterPart> FilterFactory;
+
+#endif
diff --git a/parts/filter/kdevfilter.desktop b/parts/filter/kdevfilter.desktop
new file mode 100644
index 00000000..294ae55e
--- /dev/null
+++ b/parts/filter/kdevfilter.desktop
@@ -0,0 +1,82 @@
+[Desktop Entry]
+Type=Service
+Exec=blubb
+Comment=Provides a way of manipulating editor text using commandline tools. Appears in the Tools menu.
+Comment[ca]=Proporciona un mètode per a manipular text a l'editor emprant eines de la línia de comandaments. Apareix al menú Eines.
+Comment[da]=Sørger for en måde at manipulere editortekst ved brug af kommandolinje værktøjer. Viser sig i værktøjsmenuen.
+Comment[de]=Ermöglicht die Bearbeitung von Editorinhalten mit Konsolenanwendungen. Erscheint im Menü Werkzeuge.
+Comment[el]=Προσφέρει μια μέθοδο διαχείρισης κειμένου επεξεργαστή χρησιμοποιώντας εργαλεία γραμμής εντολών. Εμφανίζεται στο μενού εργαλείων.
+Comment[es]=Proporciona un método para manipular texto del editor utilizando herramientas de la línea de órdenes. Aparece en el menú Herramientas.
+Comment[et]=Võimaldab käsureavahendite abil käsitleda redaktoris olevat teksti. Kättesaadav tööriistade menüüst.
+Comment[eu]=Komando-lerro tresnak erabiliz editore testua manipulatzeko aukera ematen dizu. Tresnak menuan dago.
+Comment[fa]=راهی برای دستکاری متن ویرایشگر، با استفاده از ابزار خط فرمان فراهم می‌کند. در گزینگان ابزار ظاهر می‌شود.
+Comment[fr]=Fournit un moyen de manipuler le texte de l'éditeur à l'aide d'outils en ligne de commande. Cette fonction apparaît dans le menu « Outils ».
+Comment[gl]=Proporciona unha maneira para manipular o texto do editor usando ferramentas da liña de comandos. Aparece no menú Ferramentas.
+Comment[hu]=Lehetővé teszi a szerkesztett szövegek kezelését parancssoros programokból (az Eszközök menüből érhető el)
+Comment[it]=Offre un modo per manipolare il testo utilizzando strumenti a riga di comando. Appare nel menu degli strumenti.
+Comment[ja]=コマンドラインツールを使用して、エディタテキストを操作する方法を提供します。ツールメニューに現れます。
+Comment[ms]=Menyediakan cara untuk memanipulasi teks penyunting menggunakan alatan arahan baris. Muncul didalam menu Alatan.
+Comment[nds]=Stellt dat Ännern vun Editorinholden mit Befehlsreeg-Warktüüch praat. Dukt in't Menü "Warktüüch" op.
+Comment[ne]=आदेशरेखा उपकरण प्रयोग गरेर सम्पादक चलाउने तरिका प्रदान गर्दछ ।
+Comment[nl]=Maakt het mogelijk de tekstinhoud van de editor met externe commandoregeltools te bewerken. Verschijnt in het menu Gereedschap.
+Comment[pl]=Umożliwia manipulowanie tekstem w edytorze za pomocą narzędzi linii komend. Pojawia się w menu Narzędzia.
+Comment[pt]=Oferece uma forma de manipular o texto do edito com as ferramentas da linha de comandos. Aparece no menu de Ferramentas.
+Comment[pt_BR]=Fornece uma maneira de manipular o editor de texto usando ferramentas de linha de comando. Aparece no menu Ferramentas.
+Comment[ru]=Предоставляет функции работы с текстом в редакторе с использованием утилит командной строки.
+Comment[sk]=Umožní manipuláciu s textom editora s použitím nástrojov príkazového riadku. Objaví sa v menu Nástroje.
+Comment[sr]=Обезбеђује начин манипулисања текстом уређивача коришћењем алата командне линије. Појављује се у менију „Алати“.
+Comment[sr@Latn]=Obezbeđuje način manipulisanja tekstom uređivača korišćenjem alata komandne linije. Pojavljuje se u meniju „Alati“.
+Comment[sv]=Erbjuder ett sätt att behandla editortext med kommandoradsverktyg. Finns i verktygsmenyn.
+Comment[ta]=கட்டளை கருவி உபயோகித்து தொகுப்பான் உறைகளை கையாள இது வழி அளிக்கும். கருவிப்பட்டியலில் இது தோன்றும்
+Comment[tg]=Вазифаи корҳо бо матнҳои дар муҳаррир буда бо истифодаи фармони сатр гузориш менамояд.
+Comment[tr]=Komut satırı araçlarını kullanarak düzenleyici metni işlemek için bir yol sunar. Araçlar menüsünde durur.
+Comment[zh_CN]=使用命令行工具操作编辑器文字。显示在工具菜单中。
+Comment[zh_TW]=提供使用命令列工具操作編輯器文字的方法。會出現在工具選單中。
+Name=KDevFilter
+Name[da]=KDevelop filter
+Name[de]=Filter (KDevelop)
+Name[hi]=के-डेव-फ़िल्टर
+Name[nds]=KDevelop-Filter
+Name[pl]=KDevFiltr
+Name[sk]=KDev filter
+Name[sv]=KDevelop filter
+Name[ta]=KDev வடிகட்டல்
+Name[tg]=Филтри KDev
+Name[zh_TW]=KDevelop 過濾器
+GenericName=Shell Filtering and Insertion
+GenericName[ca]=Inserció i filtrat de la línia de comandaments
+GenericName[da]=Skal-filtrering og indsætning
+GenericName[de]=Filtern und Einfügen über Shell-Befehle
+GenericName[el]=Εισαγωγή και φιλτράρισμα κελύφους
+GenericName[es]=Inserción y filtrado en línea de órdenes
+GenericName[et]=Shellifiltrid ja lisamine
+GenericName[eu]=Shell iragazte eta txertatzea
+GenericName[fa]=پالایش و درج پوسته
+GenericName[fr]=Filtrage et insertion dans le shell
+GenericName[gl]=Inserción e filtrado shell
+GenericName[hi]=शेल फ़िल्टरिंग तथा प्रविष्टि
+GenericName[hu]=Szűrés és beszúrás
+GenericName[it]=Inserimento e filtraggio da shell
+GenericName[ja]=シェルフィルタリングと挿入
+GenericName[nds]=Filtern un Infögen mit Konsool-Befehlen
+GenericName[ne]=शेल फिल्टरिङ र घुसाइ
+GenericName[nl]=Filteren en invoegen met shellcommando's
+GenericName[pl]=Filtrowanie i wstawianie za pomocą powłoki
+GenericName[pt]=Filtragem e Inserção por 'Shell'
+GenericName[pt_BR]=Shell de Filtro e Inserção
+GenericName[ru]=Фильтрация и вставка с помощью команд оболочки
+GenericName[sk]=Shell filtrovanie a vkladanie
+GenericName[sl]=Filtriranje lupine in vstavljanje
+GenericName[sr]=Филтрирање и убацивање шкољке
+GenericName[sr@Latn]=Filtriranje i ubacivanje školjke
+GenericName[sv]=Skalfiltrering och infogning
+GenericName[ta]=உறையகத்தை வடிகட்ட மற்றும் சேர்க்க
+GenericName[tg]=Бо пӯсти фармон филтр ва мондан
+GenericName[tr]=Kabuk filtreleme ve Ekleme
+GenericName[zh_CN]=Shell 过滤和插入
+GenericName[zh_TW]=Shell 過濾與插入
+ServiceTypes=KDevelop/Plugin
+X-KDE-Library=libkdevfilter
+X-KDevelop-Version=5
+X-KDevelop-Scope=Global
+X-KDevelop-Properties=OptionalCodeEditing
diff --git a/parts/filter/kdevfilter.rc b/parts/filter/kdevfilter.rc
new file mode 100644
index 00000000..6f7f9053
--- /dev/null
+++ b/parts/filter/kdevfilter.rc
@@ -0,0 +1,10 @@
+<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
+<kpartgui name="KDevFilter" version="1">
+<MenuBar>
+ <Menu name="tools" >
+ <Action name="tools_insertshell" group="tools_file_operations"/>
+ <Action name="tools_filtershell" group="tools_file_operations"/>
+ </Menu>
+</MenuBar>
+</kpartgui>
+
diff --git a/parts/filter/kdevfilterIface.cpp b/parts/filter/kdevfilterIface.cpp
new file mode 100644
index 00000000..55a0421a
--- /dev/null
+++ b/parts/filter/kdevfilterIface.cpp
@@ -0,0 +1,35 @@
+//
+//
+// C++ Implementation: cpp
+//
+// Description:
+//
+//
+// Author: KDevelop Authors <kdevelop-devel@kdevelop.org>, (C) 2003
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include "kdevfilterIface.h"
+#include "filterpart.h"
+
+KDevFilterIface::KDevFilterIface( FilterPart* part )
+ : QObject( part ), DCOPObject( "KDevFilter" ), m_part( part )
+{
+}
+
+KDevFilterIface::~KDevFilterIface()
+{
+}
+
+void KDevFilterIface::shellInsert()
+{
+ m_part->slotShellInsert();
+}
+
+void KDevFilterIface::shellFilter()
+{
+ m_part->slotShellFilter();
+}
+
+#include "kdevfilterIface.moc"
diff --git a/parts/filter/kdevfilterIface.h b/parts/filter/kdevfilterIface.h
new file mode 100644
index 00000000..46a14277
--- /dev/null
+++ b/parts/filter/kdevfilterIface.h
@@ -0,0 +1,26 @@
+
+#ifndef KDEVFILTERIFACE_H
+#define KDEVFILTERIFACE_H
+
+#include <qobject.h>
+#include <dcopobject.h>
+
+class FilterPart;
+
+class KDevFilterIface : public QObject, public DCOPObject
+{
+ Q_OBJECT
+ K_DCOP
+public:
+ KDevFilterIface( FilterPart* part );
+ ~KDevFilterIface();
+
+k_dcop:
+ void shellInsert();
+ void shellFilter();
+
+private:
+ FilterPart* m_part;
+};
+
+#endif
diff --git a/parts/filter/shellfilterdlg.cpp b/parts/filter/shellfilterdlg.cpp
new file mode 100644
index 00000000..7e967cda
--- /dev/null
+++ b/parts/filter/shellfilterdlg.cpp
@@ -0,0 +1,128 @@
+/***************************************************************************
+ * Copyright (C) 2002 by Bernd Gehrmann *
+ * bernd@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 "shellfilterdlg.h"
+
+#include <qcombobox.h>
+#include <qlayout.h>
+#include <qpushbutton.h>
+#include <kbuttonbox.h>
+#include <kconfig.h>
+#include <kdebug.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <kprocess.h>
+#include <kstdguiitem.h>
+#include <kdeversion.h>
+
+#include "kdevplugin.h"
+#include "domutil.h"
+#include "filterpart.h"
+
+
+ShellFilterDialog::ShellFilterDialog()
+ : QDialog(0, "shell filter dialog", true)
+{
+ QVBoxLayout *layout = new QVBoxLayout(this, 10, 4);
+
+ combo = new QComboBox(true, this);
+ combo->setDuplicatesEnabled(false);
+ layout->addWidget(combo);
+
+ KButtonBox *buttonbox = new KButtonBox(this);
+ start_button = buttonbox->addButton(i18n("&Start"));
+ start_button->setDefault(true);
+ cancel_button = buttonbox->addButton(KStdGuiItem::cancel());
+ buttonbox->layout();
+ layout->addWidget(buttonbox);
+
+ connect( start_button, SIGNAL(clicked()),
+ this, SLOT(slotStartClicked()) );
+ connect( cancel_button, SIGNAL(clicked()),
+ this, SLOT(reject()) );
+
+ m_proc = 0;
+
+ KConfig *config = FilterFactory::instance()->config();
+ config->setGroup("General");
+ combo->insertStringList(config->readListEntry("filteritems"));
+}
+
+
+ShellFilterDialog::~ShellFilterDialog()
+{
+ kdDebug(9029) << "~ShellFilterDialog" << endl;
+ delete m_proc;
+
+ // QComboBox API is a bit incomplete :-(
+ QStringList list;
+ for (int i=0; i < combo->count(); ++i)
+ list << combo->text(i);
+
+ KConfig *config = FilterFactory::instance()->config();
+ config->setGroup("General");
+ config->writeEntry("filteritems", list);
+}
+
+
+void ShellFilterDialog::slotStartClicked()
+{
+ start_button->setEnabled(false);
+ m_outstr = QCString();
+
+ delete m_proc;
+ m_proc = new KShellProcess("/bin/sh");
+ (*m_proc) << combo->currentText();
+ connect( m_proc, SIGNAL(receivedStdout(KProcess*, char *, int)),
+ this, SLOT(slotReceivedStdout(KProcess*, char *, int)) );
+ connect( m_proc, SIGNAL(wroteStdin(KProcess*)),
+ this, SLOT(slotWroteStdin(KProcess*)) );
+ connect( m_proc, SIGNAL(processExited(KProcess*)),
+ this, SLOT(slotProcessExited(KProcess*)) );
+ m_proc->start(KProcess::NotifyOnExit, KProcess::All);
+ m_proc->writeStdin(m_instr, m_instr.length());
+}
+
+
+int ShellFilterDialog::exec()
+{
+ start_button->setEnabled(true);
+ return QDialog::exec();
+}
+
+
+void ShellFilterDialog::slotReceivedStdout(KProcess *, char *text, int len)
+{
+ m_outstr += QString::fromLocal8Bit(text, len+1);
+ kdDebug(9029) << "outstr " << m_outstr << endl;
+}
+
+
+void ShellFilterDialog::slotWroteStdin(KProcess *)
+{
+ m_proc->closeStdin();
+ kdDebug(9029) << "close stdin " << m_outstr << endl;
+}
+
+
+void ShellFilterDialog::slotProcessExited(KProcess *)
+{
+ kdDebug(9029) << "process exit " << m_proc->normalExit() << endl;
+ if (m_proc->normalExit()) {
+ accept();
+ } else {
+ KMessageBox::error(this, i18n("Process exited with status %1")
+ .arg(m_proc->exitStatus()));
+ reject();
+ }
+}
+
+#include "shellfilterdlg.moc"
diff --git a/parts/filter/shellfilterdlg.h b/parts/filter/shellfilterdlg.h
new file mode 100644
index 00000000..3307c060
--- /dev/null
+++ b/parts/filter/shellfilterdlg.h
@@ -0,0 +1,52 @@
+/***************************************************************************
+ * Copyright (C) 2002 by Bernd Gehrmann *
+ * bernd@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 _SHELLFILTERDLG_H_
+#define _SHELLFILTERDLG_H_
+
+#include <qdialog.h>
+
+class QComboBox;
+class QPushButton;
+class KDevPlugin;
+class KProcess;
+
+
+class ShellFilterDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ ShellFilterDialog();
+ ~ShellFilterDialog();
+
+ virtual int exec();
+
+ void setText(const QString &str)
+ { m_instr = str.local8Bit(); }
+ QString text() const
+ { return m_outstr; }
+
+private slots:
+ void slotStartClicked();
+ void slotReceivedStdout(KProcess *, char *text, int len);
+ void slotWroteStdin(KProcess *);
+ void slotProcessExited(KProcess *);
+
+private:
+ QPushButton *start_button, *cancel_button;
+ QComboBox *combo;
+ KProcess *m_proc;
+ QCString m_instr;
+ QString m_outstr;
+};
+
+#endif
diff --git a/parts/filter/shellinsertdlg.cpp b/parts/filter/shellinsertdlg.cpp
new file mode 100644
index 00000000..a1474ed2
--- /dev/null
+++ b/parts/filter/shellinsertdlg.cpp
@@ -0,0 +1,125 @@
+/***************************************************************************
+ * Copyright (C) 2002 by Bernd Gehrmann *
+ * bernd@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 "shellinsertdlg.h"
+
+#include <qcombobox.h>
+#include <qlayout.h>
+#include <qpushbutton.h>
+#include <kconfig.h>
+#include <kbuttonbox.h>
+#include <kdebug.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <kprocess.h>
+#include <klineedit.h>
+#include <kstdguiitem.h>
+#include <kdeversion.h>
+
+#include "kdevplugin.h"
+#include "domutil.h"
+#include "filterpart.h"
+
+
+ShellInsertDialog::ShellInsertDialog()
+ : QDialog(0, "shell filter dialog", true)
+{
+ QVBoxLayout *layout = new QVBoxLayout(this, 10, 4);
+
+ combo = new QComboBox(true, this);
+ combo->setDuplicatesEnabled(false);
+ layout->addWidget(combo);
+
+ KButtonBox *buttonbox = new KButtonBox(this);
+ start_button = buttonbox->addButton(i18n("&Start"));
+ start_button->setDefault(true);
+ cancel_button = buttonbox->addButton(KStdGuiItem::cancel());
+ buttonbox->layout();
+ layout->addWidget(buttonbox);
+
+ connect( start_button, SIGNAL(clicked()),
+ this, SLOT(slotStartClicked()) );
+ connect( cancel_button, SIGNAL(clicked()),
+ this, SLOT(reject()) );
+ connect( combo->lineEdit(), SIGNAL(textChanged( const QString &)), this, SLOT(executeTextChanged( const QString &)));
+ m_proc = 0;
+
+ KConfig *config = FilterFactory::instance()->config();
+ config->setGroup("General");
+ QStringList items = config->readListEntry("InsertItems");
+ combo->insertStringList(items);
+ executeTextChanged( combo->lineEdit()->text());
+
+}
+
+
+ShellInsertDialog::~ShellInsertDialog()
+{
+ kdDebug(9029) << "~ShellInsertDialog" << endl;
+ delete m_proc;
+
+ // QComboBox API is a bit incomplete :-(
+ QStringList list;
+ for (int i=0; i < combo->count(); ++i)
+ list << combo->text(i);
+
+ KConfig *config = FilterFactory::instance()->config();
+ config->setGroup("General");
+ config->writeEntry("InsertItems", list);
+}
+
+
+void ShellInsertDialog::executeTextChanged( const QString &text)
+{
+ start_button->setEnabled(!text.isEmpty());
+}
+
+int ShellInsertDialog::exec()
+{
+ start_button->setEnabled(true);
+ return QDialog::exec();
+}
+
+
+void ShellInsertDialog::slotStartClicked()
+{
+ start_button->setEnabled(false);
+ m_str = QCString();
+
+ delete m_proc;
+ m_proc = new KShellProcess("/bin/sh");
+ (*m_proc) << combo->currentText();
+ connect( m_proc, SIGNAL(receivedStdout(KProcess*, char *, int)),
+ this, SLOT(slotReceivedStdout(KProcess*, char *, int)) );
+ connect( m_proc, SIGNAL(processExited(KProcess*)),
+ this, SLOT(slotProcessExited(KProcess*)) );
+ m_proc->start(KProcess::NotifyOnExit, KProcess::AllOutput);
+}
+
+
+void ShellInsertDialog::slotReceivedStdout(KProcess *, char *text, int len)
+{
+ m_str += QCString(text, len+1);
+}
+
+
+void ShellInsertDialog::slotProcessExited(KProcess *)
+{
+ if (m_proc->normalExit()) {
+ accept();
+ } else {
+ KMessageBox::error(this, i18n("Process exited with status %1")
+ .arg(m_proc->exitStatus()));
+ reject();
+ }
+}
+
+#include "shellinsertdlg.moc"
diff --git a/parts/filter/shellinsertdlg.h b/parts/filter/shellinsertdlg.h
new file mode 100644
index 00000000..c6f0696b
--- /dev/null
+++ b/parts/filter/shellinsertdlg.h
@@ -0,0 +1,49 @@
+/***************************************************************************
+ * Copyright (C) 2002 by Bernd Gehrmann *
+ * bernd@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 _SHELLINSERTDLG_H_
+#define _SHELLINSERTDLG_H_
+
+#include <qdialog.h>
+
+class QComboBox;
+class QPushButton;
+class KDevPlugin;
+class KProcess;
+
+
+class ShellInsertDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ ShellInsertDialog();
+ ~ShellInsertDialog();
+
+ virtual int exec();
+
+ QString text() const
+ { return QString::fromLocal8Bit(m_str); }
+
+private slots:
+ void slotStartClicked();
+ void slotReceivedStdout(KProcess *, char *text, int len);
+ void slotProcessExited(KProcess *);
+ void executeTextChanged( const QString &text);
+
+private:
+ QPushButton *start_button, *cancel_button;
+ QComboBox *combo;
+ KProcess *m_proc;
+ QCString m_str;
+};
+
+#endif