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/cpp/pcsimporter/qt4importer/Makefile.am | 11 ++ .../pcsimporter/qt4importer/kdevqt4importer.cpp | 107 +++++++++++++++++++ .../qt4importer/kdevqt4importer.desktop | 34 ++++++ .../cpp/pcsimporter/qt4importer/kdevqt4importer.h | 39 +++++++ .../cpp/pcsimporter/qt4importer/settingsdialog.cpp | 115 +++++++++++++++++++++ .../cpp/pcsimporter/qt4importer/settingsdialog.h | 46 +++++++++ .../pcsimporter/qt4importer/settingsdialogbase.ui | 79 ++++++++++++++ 7 files changed, 431 insertions(+) create mode 100644 languages/cpp/pcsimporter/qt4importer/Makefile.am create mode 100644 languages/cpp/pcsimporter/qt4importer/kdevqt4importer.cpp create mode 100644 languages/cpp/pcsimporter/qt4importer/kdevqt4importer.desktop create mode 100644 languages/cpp/pcsimporter/qt4importer/kdevqt4importer.h create mode 100644 languages/cpp/pcsimporter/qt4importer/settingsdialog.cpp create mode 100644 languages/cpp/pcsimporter/qt4importer/settingsdialog.h create mode 100644 languages/cpp/pcsimporter/qt4importer/settingsdialogbase.ui (limited to 'languages/cpp/pcsimporter/qt4importer') 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 +#include +#include +#include + +#include +#include +#include + +K_EXPORT_COMPONENT_FACTORY( libkdevqt4importer, KGenericFactory( "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 \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 \n" + << "#include \n" + << "#include \n" + << "#include \n" + << "#include \n" + << "#include \n" + << "#include \n" + << "#include \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 +#include + +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 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 +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#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 @@ + +SettingsDialogBase + + + SettingsDialogBase + + + + 0 + 0 + 346 + 275 + + + + + unnamed + + + + textLabel1_2 + + + Qt4 include directories: +Only the selected entry will be used + + + + + addUrlButton + + + + 0 + 0 + 0 + 0 + + + + &Add + + + + + qtUrl + + + + + qtListBox + + + + + + + + + qtListBox + selectionChanged(QListBoxItem*) + SettingsDialogBase + slotSelectionChanged(QListBoxItem*) + + + + enabled(int) + + + slotSelectionChanged(QListBoxItem*) + + + + kurlrequester.h + klineedit.h + kpushbutton.h + klistbox.h + + -- cgit v1.2.1