summaryrefslogtreecommitdiffstats
path: root/languages/cpp/pcsimporter/customimporter
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/cpp/pcsimporter/customimporter
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/cpp/pcsimporter/customimporter')
-rw-r--r--languages/cpp/pcsimporter/customimporter/Makefile.am12
-rw-r--r--languages/cpp/pcsimporter/customimporter/kdevcustomimporter.cpp118
-rw-r--r--languages/cpp/pcsimporter/customimporter/kdevcustomimporter.h40
-rw-r--r--languages/cpp/pcsimporter/customimporter/kdevpcscustomimporter.desktop44
-rw-r--r--languages/cpp/pcsimporter/customimporter/settingsdialog.cpp107
-rw-r--r--languages/cpp/pcsimporter/customimporter/settingsdialog.h48
-rw-r--r--languages/cpp/pcsimporter/customimporter/settingsdialogbase.ui62
7 files changed, 431 insertions, 0 deletions
diff --git a/languages/cpp/pcsimporter/customimporter/Makefile.am b/languages/cpp/pcsimporter/customimporter/Makefile.am
new file mode 100644
index 00000000..5a630be9
--- /dev/null
+++ b/languages/cpp/pcsimporter/customimporter/Makefile.am
@@ -0,0 +1,12 @@
+INCLUDES = -I$(top_srcdir)/languages/lib/interfaces \
+ -I$(top_srcdir)/lib/interfaces $(all_includes)
+METASOURCES = AUTO
+kde_module_LTLIBRARIES = libkdevcustompcsimporter.la
+
+
+noinst_HEADERS = kdevcustomimporter.h
+libkdevcustompcsimporter_la_SOURCES = kdevcustomimporter.cpp settingsdialog.cpp settingsdialogbase.ui
+libkdevcustompcsimporter_la_LIBADD = $(top_builddir)/lib/libkdevelop.la \
+ $(top_builddir)/languages/lib/interfaces/liblang_interfaces.la
+libkdevcustompcsimporter_la_LDFLAGS = -module $(all_libraries) $(KDE_PLUGIN)
+kde_services_DATA = kdevpcscustomimporter.desktop
diff --git a/languages/cpp/pcsimporter/customimporter/kdevcustomimporter.cpp b/languages/cpp/pcsimporter/customimporter/kdevcustomimporter.cpp
new file mode 100644
index 00000000..c3e5cb43
--- /dev/null
+++ b/languages/cpp/pcsimporter/customimporter/kdevcustomimporter.cpp
@@ -0,0 +1,118 @@
+/***************************************************************************
+* Copyright (C) 2003 by Alexander Dymo *
+* cloudtemple@mksat.net *
+* *
+* 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 "kdevcustomimporter.h"
+
+#include "settingsdialog.h"
+
+#include <qvaluestack.h>
+#include <qdir.h>
+
+#include <kdebug.h>
+#include <kgenericfactory.h>
+
+K_EXPORT_COMPONENT_FACTORY( libkdevcustompcsimporter, KGenericFactory<KDevCustomImporter>( "kdevcustompcsimporter" ) )
+
+KDevCustomImporter::KDevCustomImporter( QObject* parent, const char* name, const QStringList & // args
+ )
+ : KDevPCSImporter( parent, name )
+{}
+
+
+KDevCustomImporter::~KDevCustomImporter()
+{}
+
+
+QString KDevCustomImporter::dbName() const
+{
+ return m_settings->dbName();
+}
+
+QStringList KDevCustomImporter::fileList( const QString& path )
+{
+ QDir dir( path );
+ if ( !dir.exists() )
+ return QStringList();
+// QStringList lst = dir.entryList( "*.h;*.H;*.hh;*.hxx;*.hpp;*.tlh" );
+ QStringList lst = dir.entryList( m_settings->filePattern() );
+ QStringList fileList;
+ for ( QStringList::Iterator it = lst.begin(); it != lst.end(); ++it )
+ {
+ fileList.push_back( dir.absPath() + "/" + ( *it ) );
+ }
+ return fileList;
+}
+
+QStringList KDevCustomImporter::fileList()
+{
+ if ( !m_settings )
+ return QStringList();
+
+ QStringList lst = m_settings->dirs();
+ QStringList files;
+ for ( QStringList::Iterator it = lst.begin(); it != lst.end(); ++it )
+ {
+ if ( !m_settings->recursive() )
+ files += fileList( *it );
+ else
+ processDir( *it, files );
+ }
+
+ return files;
+}
+
+QStringList KDevCustomImporter::includePaths()
+{
+ if ( !m_settings )
+ return QStringList();
+
+ return m_settings->dirs();
+}
+
+QWidget* KDevCustomImporter::createSettingsPage( QWidget* parent, const char* name )
+{
+ m_settings = new SettingsDialog( parent, name );
+ return m_settings;
+}
+
+void KDevCustomImporter::processDir( const QString path, QStringList & files )
+{
+ QValueStack<QString> s;
+ s.push( path );
+ files += fileList( path );
+
+ QDir dir;
+ do
+ {
+ dir.setPath( s.pop() );
+ if (!dir.exists())
+ continue;
+ kdDebug( 9015 ) << "Examining: " << dir.path() << endl;
+ const QFileInfoList *dirEntries = dir.entryInfoList();
+ if ( !dirEntries ) continue;
+ QPtrListIterator<QFileInfo> it( *dirEntries );
+ for ( ; dirEntries && it.current(); ++it )
+ {
+ QString fileName = it.current() ->fileName();
+ if ( fileName == "." || fileName == ".." )
+ continue;
+ if ( it.current() ->isDir() )
+ {
+ QString tmpPath = it.current() ->absFilePath();
+ kdDebug( 9015 ) << "Pushing: " << tmpPath << endl;
+ s.push( tmpPath );
+ files += fileList( tmpPath );
+ }
+ }
+ }
+ while ( !s.isEmpty() );
+}
+
+#include "kdevcustomimporter.moc"
+//kate: indent-mode csands; tab-width 4; space-indent off;
diff --git a/languages/cpp/pcsimporter/customimporter/kdevcustomimporter.h b/languages/cpp/pcsimporter/customimporter/kdevcustomimporter.h
new file mode 100644
index 00000000..5a522785
--- /dev/null
+++ b/languages/cpp/pcsimporter/customimporter/kdevcustomimporter.h
@@ -0,0 +1,40 @@
+/***************************************************************************
+* Copyright (C) 2003 by Alexander Dymo *
+* cloudtemple@mksat.net *
+* *
+* 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 KDEVCUSTOMIMPORTER_H
+#define KDEVCUSTOMIMPORTER_H
+
+#include "kdevpcsimporter.h"
+
+#include <qguardedptr.h>
+
+class SettingsDialog;
+
+class KDevCustomImporter : public KDevPCSImporter
+{
+Q_OBJECT
+public:
+ KDevCustomImporter(QObject* parent = 0, const char* name = 0, const QStringList &args = QStringList());
+
+ ~KDevCustomImporter();
+
+ virtual QString dbName() const;
+ virtual QStringList fileList();
+ virtual QStringList includePaths();
+ virtual QWidget* createSettingsPage(QWidget* parent, const char* name);
+
+protected:
+ QStringList fileList( const QString& path );
+ void processDir(const QString path, QStringList &files );
+
+private:
+ QGuardedPtr<SettingsDialog> m_settings;
+};
+
+#endif
diff --git a/languages/cpp/pcsimporter/customimporter/kdevpcscustomimporter.desktop b/languages/cpp/pcsimporter/customimporter/kdevpcscustomimporter.desktop
new file mode 100644
index 00000000..2e331977
--- /dev/null
+++ b/languages/cpp/pcsimporter/customimporter/kdevpcscustomimporter.desktop
@@ -0,0 +1,44 @@
+[Desktop Entry]
+Type=Service
+Name=KDevPCSCustomImporter
+Name[da]=KDevelop brugerdefineret PCS-importør
+Name[nds]=EgenPCS-Import för KDevelop
+Name[pl]=KDevWłasnyImportPCS
+Name[sk]=KDev PCS vlastný import
+Name[sv]=KDevelop egen import av PCS
+Name[zh_TW]=KDevelop PCS 自訂匯入器
+Comment=KDevelop Custom Directory PCS Importer
+Comment[ca]=Importador PCS de directori personalitzat per a KDevelop
+Comment[da]=KDevelop brugerdefineret mappe-PCS-importør
+Comment[de]=Import für persistenten Klassenspeicher aus benutzerdefinierten Ordnern
+Comment[el]=Εισαγωγέας PCS προσαρμοσμένου καταλόγου του KDevelop
+Comment[es]=Importador PCS de carpeta personalizada de KDevelop
+Comment[et]=KDevelopi kohandatud kataloogi PCS importija
+Comment[eu]=KDevelop-en direktorio pertsonalizatuko PCS inportatzailea
+Comment[fa]=واردکنندۀ PCS فهرست سفارشی KDevelop
+Comment[fr]=Importation PCS de dossiers personnalisés pour KDevelop
+Comment[gl]=Importador PCS de directorios personalizados para KDevelop
+Comment[hi]=के-डेवलप मनपसंद डिरेक्ट्री पीसीएस आयातक
+Comment[hu]=KDevelop egyéni könyvtár PCS-importáló
+Comment[it]=Cartella per l'importatore personalizzato PCS di KDevelop
+Comment[ja]=KDevelop カスタムディレクトリ PCS インポータ
+Comment[nds]=Import för duerhaftig Klassenspieker ut Bruker-Ornern
+Comment[ne]=केडीई विकास अनुकूल डाइरेक्टरी PCS आयातकर्ता
+Comment[nl]=KDevelop PCS Importer voor eigen mappen
+Comment[pl]=Własny program do importowania PCS dla KDevelopa
+Comment[pt]=Importador de PCS com Directoria Personalizada do KDevelop
+Comment[pt_BR]=Importador de Diretório PCS Personalizado para o KDevelop
+Comment[ru]=Загрузка символов из любого каталога в хранилище классов
+Comment[sk]=KDevelop vlastný PCS import priečinkov
+Comment[sr]=KDevelop-ов PCS увозник прилагођеног директоријума
+Comment[sr@Latn]=KDevelop-ov PCS uvoznik prilagođenog direktorijuma
+Comment[sv]=KDevelop PCS-import för egen katalog
+Comment[ta]=கெடெவலப் கஸ்டம் டைரக்ட்ரி இறக்குமதியாளர்
+Comment[tg]=Пурборкунии нишонаҳо аз анбори синфҳои каталог
+Comment[tr]=KDevelop Özel Dizin PCS Aktarıcısı
+Comment[zh_CN]=KDevelop 自定义目录的 PCS 导入器
+Comment[zh_TW]=KDevelop 自訂目錄 PCS 匯入器
+Icon=gear
+ServiceTypes=KDevelop/PCSImporter
+X-KDE-Library=libkdevcustompcsimporter
+X-KDevelop-PCSImporter=
diff --git a/languages/cpp/pcsimporter/customimporter/settingsdialog.cpp b/languages/cpp/pcsimporter/customimporter/settingsdialog.cpp
new file mode 100644
index 00000000..f6df0902
--- /dev/null
+++ b/languages/cpp/pcsimporter/customimporter/settingsdialog.cpp
@@ -0,0 +1,107 @@
+/***************************************************************************
+* Copyright (C) 2003 by Roberto Raggi *
+* roberto@kdevelop.org *
+* *
+* Copyright (C) 2006 by Jens Dagerbo *
+* jens.dagerbo@swipnet.se *
+* *
+* 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 <qdir.h>
+
+#include <klistbox.h>
+#include <kcombobox.h>
+#include <kurlrequester.h>
+#include <kdeversion.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <klineedit.h>
+
+#include <keditlistbox.h>
+
+// should be included after possible KEditListBox redefinition
+#include "settingsdialog.h"
+
+#include <qfile.h>
+#include <qregexp.h>
+#include <qlayout.h>
+#include <qcheckbox.h>
+
+#include <cstdlib>
+
+SettingsDialog::SettingsDialog( QWidget* parent, const char* name, WFlags fl )
+ : SettingsDialogBase( parent, name, fl )
+{
+ KURLRequester * req = new KURLRequester( this );
+ req->setMode( KFile::Directory );
+ KEditListBox::CustomEditor pCustomEditor;
+ pCustomEditor = req->customEditor();
+ elb = new KEditListBox( i18n( "Directories to Parse" ), pCustomEditor, this );
+
+ grid->addMultiCellWidget( elb, 3, 3, 0, grid->numCols() );
+
+ // connect( dbName_edit, SIGNAL( textChanged( const QString& ) ), this, SLOT( validate() ) );
+ connect( elb->addButton(), SIGNAL( clicked() ), this, SLOT( validate() ) );
+ connect( elb->removeButton(), SIGNAL( clicked() ), this, SLOT( validate() ) );
+ connect( elb, SIGNAL( added( const QString& ) ), this, SLOT( validateDirectory( const QString& ) ) );
+}
+
+SettingsDialog::~SettingsDialog()
+{}
+
+QString SettingsDialog::dbName( ) const
+{
+ return QString();
+// return dbName_edit->text();
+}
+
+QStringList SettingsDialog::dirs( ) const
+{
+ return elb->items();
+}
+
+QString SettingsDialog::filePattern( ) const
+{
+ return pattern_edit->text();
+}
+
+bool SettingsDialog::recursive( ) const
+{
+ return recursive_box->isChecked();
+}
+
+void SettingsDialog::validate()
+{
+// emit enabled( !dbName_edit->text().isEmpty() && elb->listBox() ->count() > 0 );
+ emit enabled( elb->listBox()->count() > 0 );
+}
+
+void SettingsDialog::validateDirectory( const QString & dir )
+{
+ QDir d( dir, QString::null, QDir::DefaultSort, QDir::Dirs );
+ if ( !d.exists() )
+ {
+ elb->lineEdit() ->setText( dir );
+
+ if ( QListBoxItem * item = elb->listBox() ->findItem( dir, Qt::ExactMatch ) )
+ {
+ elb->listBox() ->removeItem( elb->listBox() ->index( item ) );
+ }
+
+ QString errormsg = QString( "<qt><b>%1</b> is not a directory</qt>" ).arg( dir );
+ KMessageBox::error( 0, errormsg, "Couldn't find directory" );
+ }
+ emit enabled( elb->listBox()->count() > 0 );
+}
+
+#include "settingsdialog.moc"
+//kate: indent-mode csands; tab-width 4; space-indent off;
+
+
+
+
diff --git a/languages/cpp/pcsimporter/customimporter/settingsdialog.h b/languages/cpp/pcsimporter/customimporter/settingsdialog.h
new file mode 100644
index 00000000..309df8ab
--- /dev/null
+++ b/languages/cpp/pcsimporter/customimporter/settingsdialog.h
@@ -0,0 +1,48 @@
+/***************************************************************************
+ * Copyright (C) 2003 by Roberto Raggi *
+ * roberto@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 SETTINGSDIALOG_H
+#define SETTINGSDIALOG_H
+
+#include "settingsdialogbase.h"
+
+class KEditListBox;
+
+class SettingsDialog : public SettingsDialogBase
+{
+ Q_OBJECT
+
+public:
+ SettingsDialog(QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
+ ~SettingsDialog();
+
+ bool isValidQtDir( const QString& path ) const;
+
+ QString qtDir() const;
+ QString configuration() const;
+
+ QString dbName() const;
+ QStringList dirs() const;
+ bool recursive() const;
+ QString filePattern() const;
+
+private slots:
+ void validate();
+ void validateDirectory( const QString & dir );
+
+private:
+ KEditListBox *elb;
+
+};
+
+#endif
+
+
diff --git a/languages/cpp/pcsimporter/customimporter/settingsdialogbase.ui b/languages/cpp/pcsimporter/customimporter/settingsdialogbase.ui
new file mode 100644
index 00000000..b9faadb1
--- /dev/null
+++ b/languages/cpp/pcsimporter/customimporter/settingsdialogbase.ui
@@ -0,0 +1,62 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>SettingsDialogBase</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>SettingsDialogBase</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>510</width>
+ <height>501</height>
+ </rect>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>grid</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KLineEdit" row="1" column="0">
+ <property name="name">
+ <cstring>pattern_edit</cstring>
+ </property>
+ <property name="text">
+ <string>*.h;*.H;*.hh;*.hxx;*.hpp;*.tlh</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1_2</cstring>
+ </property>
+ <property name="text">
+ <string>Filename pattern:</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="2" column="0">
+ <property name="name">
+ <cstring>recursive_box</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Recursive</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </vbox>
+</widget>
+<signals>
+ <signal>enabled(int)</signal>
+</signals>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>