diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 114a878c64ce6f8223cfd22d76a20eb16d177e5e (patch) | |
tree | acaf47eb0fa12142d3896416a69e74cbf5a72242 /languages/cpp/pcsimporter/qt4importer | |
download | tdevelop-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/qt4importer')
7 files changed, 431 insertions, 0 deletions
diff --git a/languages/cpp/pcsimporter/qt4importer/Makefile.am b/languages/cpp/pcsimporter/qt4importer/Makefile.am new file mode 100644 index 00000000..b0b4a622 --- /dev/null +++ b/languages/cpp/pcsimporter/qt4importer/Makefile.am @@ -0,0 +1,11 @@ +INCLUDES = -I$(top_srcdir)/languages/lib/interfaces \ + -I$(top_srcdir)/lib/interfaces $(all_includes) +METASOURCES = AUTO +kde_module_LTLIBRARIES = libkdevqt4importer.la + +noinst_HEADERS = kdevqt4importer.h settingsdialog.h +libkdevqt4importer_la_SOURCES = kdevqt4importer.cpp settingsdialogbase.ui settingsdialog.cpp +kde_services_DATA = kdevqt4importer.desktop +libkdevqt4importer_la_LIBADD = $(top_builddir)/lib/libkdevelop.la \ + $(top_builddir)/languages/lib/interfaces/liblang_interfaces.la +libkdevqt4importer_la_LDFLAGS = -module $(all_libraries) $(KDE_PLUGIN) diff --git a/languages/cpp/pcsimporter/qt4importer/kdevqt4importer.cpp b/languages/cpp/pcsimporter/qt4importer/kdevqt4importer.cpp new file mode 100644 index 00000000..f4fedea0 --- /dev/null +++ b/languages/cpp/pcsimporter/qt4importer/kdevqt4importer.cpp @@ -0,0 +1,107 @@ +/*************************************************************************** + * 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. * + * * + ***************************************************************************/ + +#include "kdevqt4importer.h" +#include "kdevqt4importer.moc" +#include "settingsdialog.h" + +#include <kgenericfactory.h> +#include <ktempfile.h> +#include <kprocess.h> +#include <kdebug.h> + +#include <qtextstream.h> +#include <qlabel.h> +#include <qdir.h> + +K_EXPORT_COMPONENT_FACTORY( libkdevqt4importer, KGenericFactory<KDevQt4Importer>( "kdevqt4importer" ) ) + +KDevQt4Importer::KDevQt4Importer( QObject * parent, const char * name, const QStringList& ) + : KDevPCSImporter( parent, name ) +{ + m_qtfile = 0; +} + +KDevQt4Importer::~KDevQt4Importer() +{ + if (m_qtfile) + delete m_qtfile; + + m_qtfile = 0; +} + +QStringList KDevQt4Importer::fileList() +{ + if( !m_settings ) + return QStringList(); + + if (m_qtfile) + delete m_qtfile; + + KTempFile ifile; + QTextStream &is = *ifile.textStream(); + + is << "#include <QtCore/qobjectdefs.h>\n" + << "#undef Q_SLOTS\n#undef Q_SIGNALS\n#undef slots\n#undef signals" + << "#define Q_SLOTS slots\n" + << "#define Q_SIGNALS signals\n" + << "#include <QtCore/QtCore>\n" + << "#include <QtGui/QtGui>\n" + << "#include <QtNetwork/QtNetwork>\n" + << "#include <QtXml/QtXml>\n" + << "#include <Qt3Support/Qt3Support>\n" + << "#include <QtSql/QtSql>\n" + << "#include <QtTest/QtTest>\n" + << "#include <QtOpenGL/QtOpenGL>\n"; + + + + KProcess proc; + proc << "cpp" << "-nostdinc" << "-xc++"; + + m_qtfile = new KTempFile(); + + // include paths + QStringList paths = includePaths(); + for (QStringList::Iterator it = paths.begin(); it != paths.end(); ++it) + proc << "-I" << *it; + + ifile.close(); + + QString o; + o += "-o"; + o += m_qtfile->name(); + + proc << ifile.name() << o; + proc.start(KProcess::Block); + + return m_qtfile->name(); +} + +QStringList KDevQt4Importer::includePaths() +{ + if( !m_settings || !m_qtfile) + return QStringList(); + + QStringList includePaths; + includePaths.push_back( m_settings->qtDir() ); + includePaths.push_back( m_settings->qtDir() + "/Qt" ); + + /// @todo add mkspec + return includePaths; +} + +QWidget * KDevQt4Importer::createSettingsPage( QWidget * parent, const char * name ) +{ + m_settings = new SettingsDialog( parent, name ); + return m_settings; +} + diff --git a/languages/cpp/pcsimporter/qt4importer/kdevqt4importer.desktop b/languages/cpp/pcsimporter/qt4importer/kdevqt4importer.desktop new file mode 100644 index 00000000..d1003610 --- /dev/null +++ b/languages/cpp/pcsimporter/qt4importer/kdevqt4importer.desktop @@ -0,0 +1,34 @@ +[Desktop Entry] +Type=Service +Name=KDevQt4Importer +Name[de]=Qt4-PCS-Import (KDevelop) +Name[fr]=KDevQtImporter +Name[nds]=Qt4-PCS-Import (KDevelop) +Name[ru]=KDevQt 4Importer +Name[sv]=KDevelop QT4-import +Comment=KDevelop Qt4 PCS Importer +Comment[ca]=Importador PCS de Qt4 per a KDevelop +Comment[da]=KDevelop Qt4 PCS importør +Comment[de]=Qt4-Import für persistenten Klassenspeicher +Comment[el]=Εισαγωγέας PCS KDevelop Qt4 +Comment[es]=Importador PCS de Qt4 de KDevelop +Comment[et]=KDevelopi Qt4 PCS importija +Comment[fr]=Importation PCS de Qt4 pour KDevelop +Comment[hu]=KDevelop Qt4 PCS-importáló +Comment[it]=Importatore PCS di Qt4 di KDevelop +Comment[ja]=KDevelop Qt4 PCS インポータ +Comment[nds]=Qt4-Import för duerhaftig Klassenspieker +Comment[pl]=KDevelop: importowanie PCS Qt4 +Comment[pt]=Importador de PCS para Qt4 do KDevelop +Comment[pt_BR]=Importador de PCS para Qt4 do KDevelop +Comment[ru]=Импорт Qt 4 PCS в KDevelop +Comment[sk]=KDevelop Qt4 PCS import +Comment[sr]=KDevelop-ов Qt4 PCS увозник +Comment[sr@Latn]=KDevelop-ov Qt4 PCS uvoznik +Comment[sv]=KDevelop QT4 PCS-import +Comment[zh_TW]=KDevelop Qt4 PCS 匯入器 +Icon=gear +ServiceTypes=KDevelop/PCSImporter +X-KDE-Library=libkdevqt4importer +X-KDevelop-PCSImporter= +X-KDevelop-Version=5 diff --git a/languages/cpp/pcsimporter/qt4importer/kdevqt4importer.h b/languages/cpp/pcsimporter/qt4importer/kdevqt4importer.h new file mode 100644 index 00000000..821e6fef --- /dev/null +++ b/languages/cpp/pcsimporter/qt4importer/kdevqt4importer.h @@ -0,0 +1,39 @@ +/*************************************************************************** + * 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 KDEVQTIMPORTER_H +#define KDEVQTIMPORTER_H + +#include <kdevpcsimporter.h> +#include <qguardedptr.h> + +class SettingsDialog; +class KTempFile; + +class KDevQt4Importer : public KDevPCSImporter +{ + Q_OBJECT +public: + KDevQt4Importer( QObject* parent=0, const char* name=0, const QStringList& args=QStringList() ); + virtual ~KDevQt4Importer(); + + virtual QString dbName() const { return QString::fromLatin1("Qt4"); } + virtual QStringList fileList(); + virtual QStringList includePaths(); + + virtual QWidget* createSettingsPage( QWidget* parent, const char* name=0 ); + +private: + QGuardedPtr<SettingsDialog> m_settings; + KTempFile *m_qtfile; +}; + +#endif diff --git a/languages/cpp/pcsimporter/qt4importer/settingsdialog.cpp b/languages/cpp/pcsimporter/qt4importer/settingsdialog.cpp new file mode 100644 index 00000000..cc59c6e9 --- /dev/null +++ b/languages/cpp/pcsimporter/qt4importer/settingsdialog.cpp @@ -0,0 +1,115 @@ +/*************************************************************************** + * 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 <klistbox.h> +#include <kcombobox.h> +#include <kurlrequester.h> +#include <kdebug.h> +#include <klineedit.h> +#include <kmessagebox.h> +#include <klocale.h> + +#include <qfile.h> +#include <qdir.h> +#include <qregexp.h> +#include <cstdlib> + +#include "settingsdialog.h" + +QListBoxItem* QListBox_selectedItem(QListBox* cpQListBox) +{ + if ( cpQListBox->selectionMode() != QListBox::Single ) + return 0; + if ( cpQListBox->isSelected( cpQListBox->currentItem() ) ) + return cpQListBox->item(cpQListBox->currentItem()); + return 0; +} + +SettingsDialog::SettingsDialog(QWidget* parent, const char* name, WFlags fl) + : SettingsDialogBase(parent,name,fl) +{ + QStringList qtdirs; + qtdirs.push_back( ::getenv("QTDIR") + QString("/include") ); + qtdirs.push_back( QString::fromLocal8Bit(::getenv("HOME")) + "/dev/qt/include" ); + qtdirs.push_back( QString::fromLocal8Bit(::getenv("HOME")) + "/dev/qt-main/include" ); + qtdirs.push_back( "/usr/qt/4/include" ); + + for( QStringList::Iterator it=qtdirs.begin(); it!=qtdirs.end(); ++it ) + { + QString qtdir = *it; + if( !qtdir.isEmpty() && isValidQtDir(qtdir) ) + if (!qtListBox->findItem(qtdir, ExactMatch)) + qtListBox->insertItem( qtdir ); + } + + qtUrl->setMode( KFile::Directory | KFile::ExistingOnly | KFile::LocalOnly ); + + connect( addUrlButton, SIGNAL(clicked()), this, SLOT(addUrlButton_clicked()) ); +} + +SettingsDialog::~SettingsDialog() +{ +} + +void SettingsDialog::slotSelectionChanged(QListBoxItem* item) +{ + if( !qtListBox->selectedItem() ) + { + emit enabled( false ); + return; + } + + + emit enabled( true ); +} + +bool SettingsDialog::isValidQtDir( const QString & path ) const +{ + return QFile::exists( path + "/QtCore/QtCore" ); +} + +QString SettingsDialog::qtDir( ) const +{ + return qtListBox->currentText(); +} + +QString SettingsDialog::configuration( ) const +{ + return ""; +} + +void SettingsDialog::addUrlButton_clicked( ) +{ + kdDebug(9000) << k_funcinfo << endl; + + if ( isValidQtDir( qtUrl->url() ) ) + { + qtListBox->insertItem( qtUrl->url() ); + if ( QListBoxItem * item = qtListBox->findItem( qtUrl->url(), ExactMatch ) ) + { + qtListBox->setSelected( item, true ); + } + qtUrl->lineEdit()->clear(); + } + else + { + KMessageBox::error( this, i18n("This does not appear to be a valid Qt4 include directory.\nPlease select a different directory."), i18n("Invalid Directory") ); + } +} + + +#include "settingsdialog.moc" +//kate: indent-mode csands; tab-width 4; space-indent off; + + diff --git a/languages/cpp/pcsimporter/qt4importer/settingsdialog.h b/languages/cpp/pcsimporter/qt4importer/settingsdialog.h new file mode 100644 index 00000000..1ec5663e --- /dev/null +++ b/languages/cpp/pcsimporter/qt4importer/settingsdialog.h @@ -0,0 +1,46 @@ +/*************************************************************************** + * 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 SettingsDialog : public SettingsDialogBase +{ + Q_OBJECT + +public: + SettingsDialog(QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~SettingsDialog(); + /*$PUBLIC_FUNCTIONS$*/ + + bool isValidQtDir( const QString& path ) const; + + QString qtDir() const; + QString configuration() const; + +public slots: + /*$PUBLIC_SLOTS$*/ + virtual void slotSelectionChanged(QListBoxItem*); + +protected: + /*$PROTECTED_FUNCTIONS$*/ + +protected slots: + /*$PROTECTED_SLOTS$*/ + void addUrlButton_clicked(); + +}; + +#endif + + diff --git a/languages/cpp/pcsimporter/qt4importer/settingsdialogbase.ui b/languages/cpp/pcsimporter/qt4importer/settingsdialogbase.ui new file mode 100644 index 00000000..f655e4f9 --- /dev/null +++ b/languages/cpp/pcsimporter/qt4importer/settingsdialogbase.ui @@ -0,0 +1,79 @@ +<!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>346</width> + <height>275</height> + </rect> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel" row="0" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>textLabel1_2</cstring> + </property> + <property name="text"> + <string>Qt4 include directories: +Only the selected entry will be used</string> + </property> + </widget> + <widget class="QPushButton" row="2" column="1"> + <property name="name"> + <cstring>addUrlButton</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>&Add</string> + </property> + </widget> + <widget class="KURLRequester" row="2" column="0"> + <property name="name"> + <cstring>qtUrl</cstring> + </property> + </widget> + <widget class="KListBox" row="1" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>qtListBox</cstring> + </property> + </widget> + </grid> +</widget> +<customwidgets> +</customwidgets> +<connections> + <connection> + <sender>qtListBox</sender> + <signal>selectionChanged(QListBoxItem*)</signal> + <receiver>SettingsDialogBase</receiver> + <slot>slotSelectionChanged(QListBoxItem*)</slot> + </connection> +</connections> +<signals> + <signal>enabled(int)</signal> +</signals> +<slots> + <slot>slotSelectionChanged(QListBoxItem*)</slot> +</slots> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>kurlrequester.h</includehint> + <includehint>klineedit.h</includehint> + <includehint>kpushbutton.h</includehint> + <includehint>klistbox.h</includehint> +</includehints> +</UI> |