summaryrefslogtreecommitdiffstats
path: root/parts/documentation/plugins/qt
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 /parts/documentation/plugins/qt
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 'parts/documentation/plugins/qt')
-rw-r--r--parts/documentation/plugins/qt/Makefile.am14
-rw-r--r--parts/documentation/plugins/qt/docqtplugin.cpp339
-rw-r--r--parts/documentation/plugins/qt/docqtplugin.desktop44
-rw-r--r--parts/documentation/plugins/qt/docqtplugin.h56
4 files changed, 453 insertions, 0 deletions
diff --git a/parts/documentation/plugins/qt/Makefile.am b/parts/documentation/plugins/qt/Makefile.am
new file mode 100644
index 00000000..a25419e7
--- /dev/null
+++ b/parts/documentation/plugins/qt/Makefile.am
@@ -0,0 +1,14 @@
+INCLUDES = -I$(top_srcdir)/lib/interfaces -I$(top_srcdir)/lib/util \
+ -I$(top_srcdir)/parts/documentation/interfaces $(all_includes)
+
+METASOURCES = AUTO
+
+kde_module_LTLIBRARIES = libdocqtplugin.la
+
+noinst_HEADERS = docqtplugin.h
+kde_services_DATA = docqtplugin.desktop
+
+libdocqtplugin_la_LDFLAGS = -module -avoid-version -no-undefined $(all_libraries)
+libdocqtplugin_la_SOURCES = docqtplugin.cpp
+libdocqtplugin_la_LIBADD = $(top_builddir)/lib/libkdevelop.la \
+ $(top_builddir)/parts/documentation/interfaces/libdocumentation_interfaces.la
diff --git a/parts/documentation/plugins/qt/docqtplugin.cpp b/parts/documentation/plugins/qt/docqtplugin.cpp
new file mode 100644
index 00000000..ffbce63a
--- /dev/null
+++ b/parts/documentation/plugins/qt/docqtplugin.cpp
@@ -0,0 +1,339 @@
+/***************************************************************************
+ * Copyright (C) 2004 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. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#include "docqtplugin.h"
+
+#include <unistd.h>
+
+#include <qfile.h>
+#include <qfileinfo.h>
+#include <qdialog.h>
+
+#include <kurl.h>
+#include <kaboutdata.h>
+#include <kconfig.h>
+#include <klocale.h>
+#include <klistview.h>
+
+#include <urlutil.h>
+#include <kdevgenericfactory.h>
+#include <kdevplugininfo.h>
+
+#include "../../../../config.h"
+
+class QtDocumentationCatalogItem: public DocumentationCatalogItem
+{
+public:
+ QtDocumentationCatalogItem(const QString &dcfFile, DocumentationPlugin* plugin,
+ KListView *parent, const QString &name)
+ :DocumentationCatalogItem(plugin, parent, name), m_dcfFile(dcfFile)
+ {
+ }
+ QtDocumentationCatalogItem(const QString &dcfFile, DocumentationPlugin* plugin,
+ DocumentationItem *parent, const QString &name)
+ :DocumentationCatalogItem(plugin, parent, name), m_dcfFile(dcfFile)
+ {
+ }
+ QString dcfFile() const { return m_dcfFile; }
+
+private:
+ QString m_dcfFile;
+};
+
+static const KDevPluginInfo data("docqtplugin");
+typedef KDevGenericFactory<DocQtPlugin> DocQtPluginFactory;
+K_EXPORT_COMPONENT_FACTORY( libdocqtplugin, DocQtPluginFactory(data) )
+
+DocQtPlugin::DocQtPlugin(QObject* parent, const char* name, const QStringList)
+ :DocumentationPlugin(DocQtPluginFactory::instance()->config(), parent, name)
+{
+ setCapabilities(Index | FullTextSearch | CustomDocumentationTitles);
+ autoSetup();
+}
+
+DocQtPlugin::~DocQtPlugin()
+{
+}
+
+void DocQtPlugin::createTOC(DocumentationCatalogItem *item)
+{
+ QtDocumentationCatalogItem *qtItem = dynamic_cast<QtDocumentationCatalogItem *>(item);
+ if (!qtItem)
+ return;
+
+ QFileInfo fi(qtItem->dcfFile());
+
+ QFile f(qtItem->dcfFile());
+ if (!f.open(IO_ReadOnly))
+ {
+ kdDebug(9002) << "Could not read" << qtItem->dcfFile() << endl;
+ return;
+ }
+ QDomDocument doc;
+ if (!doc.setContent(&f) || doc.doctype().name() != "DCF")
+ {
+ kdDebug(9002) << "Not a valid DCF file: " << qtItem->dcfFile() << endl;
+ return;
+ }
+ f.close();
+
+ QDomElement docEl = doc.documentElement();
+ QDomElement titleEl = docEl.namedItem("DCF").toElement();
+
+ QDomElement childEl = docEl.lastChild().toElement();
+ while (!childEl.isNull())
+ {
+ if (childEl.tagName() == "section")
+ {
+ QString ref = childEl.attribute("ref");
+ QString title = childEl.attribute("title");
+
+ DocumentationItem *sectionItem = new DocumentationItem(DocumentationItem::Book, item, title);
+ KURL sectionUrl(fi.dirPath(true) + "/" + ref);
+ sectionItem->setURL(sectionUrl);
+
+ QDomElement grandChild = childEl.lastChild().toElement();
+ while(!grandChild.isNull())
+ {
+ if (grandChild.tagName() == "keyword")
+ {
+ QString keyRef = grandChild.attribute("ref");
+ QString keyTitle = grandChild.text();
+
+ DocumentationItem *keyItem = new DocumentationItem(DocumentationItem::Document, sectionItem, keyTitle);
+ KURL keyUrl(fi.dirPath(true) + "/" + keyRef);
+ keyItem->setURL(keyUrl);
+ }
+ if (grandChild.tagName() == "section")
+ {
+ QString keyRef = grandChild.attribute("ref");
+ QString keyTitle = grandChild.attribute("title");
+ DocumentationItem *keyItem = new DocumentationItem(DocumentationItem::Book, sectionItem, keyTitle);
+ KURL keyUrl(fi.dirPath(true) + "/" + keyRef);
+ keyItem->setURL(keyUrl);
+ }
+ grandChild = grandChild.previousSibling().toElement();
+ }
+ }
+ childEl = childEl.previousSibling().toElement();
+ }
+}
+
+void DocQtPlugin::autoSetupPlugin()
+{
+ QString qtDocDir(QT_DOCDIR);
+ qtDocDir = URLUtil::envExpand(qtDocDir);
+ if (qtDocDir.isEmpty())
+ {
+ qtDocDir = getenv("QTDIR");
+ }
+ if (!qtDocDir.isEmpty())
+ {
+ config->setGroup("Search Settings");
+ config->writeEntry("Qt Reference Documentation", true);
+ config->setGroup("Index Settings");
+ config->writeEntry("Qt Reference Documentation", true);
+ config->setGroup("Locations");
+ config->writePathEntry("Qt Reference Documentation", qtDocDir + QString("/qt.dcf"));
+ config->writePathEntry("Qt Assistant Manual", qtDocDir + QString("/assistant.dcf"));
+ config->writePathEntry("Qt Designer Manual", qtDocDir + QString("/designer.dcf"));
+ config->writePathEntry("Guide to the Qt Translation Tools", qtDocDir + QString("/linguist.dcf"));
+ config->writePathEntry("qmake User Guide", qtDocDir + QString("/qmake.dcf"));
+ }
+}
+
+void DocQtPlugin::setCatalogURL(DocumentationCatalogItem *item)
+{
+ QtDocumentationCatalogItem *qtItem = dynamic_cast<QtDocumentationCatalogItem *>(item);
+ if (!qtItem)
+ return;
+
+ QFileInfo fi(qtItem->dcfFile());
+
+ QFile f(qtItem->dcfFile());
+ if (!f.open(IO_ReadOnly))
+ {
+ kdDebug(9002) << "Could not read" << qtItem->dcfFile() << endl;
+ return;
+ }
+ QDomDocument doc;
+ if (!doc.setContent(&f) || doc.doctype().name() != "DCF")
+ {
+ kdDebug(9002) << "Not a valid DCF file: " << qtItem->dcfFile() << endl;
+ return;
+ }
+ f.close();
+
+ QDomElement docEl = doc.documentElement();
+ QDomElement titleEl = docEl.namedItem("DCF").toElement();
+
+ if (item->url().isEmpty())
+ {
+ KURL url(fi.dirPath(true) + "/" + docEl.attribute("ref", QString::null));
+ item->setURL(url);
+ }
+}
+
+QString DocQtPlugin::pluginName() const
+{
+ return i18n("Qt Documentation Collection");
+}
+
+bool DocQtPlugin::needRefreshIndex(DocumentationCatalogItem *item)
+{
+ QtDocumentationCatalogItem *qtItem = dynamic_cast<QtDocumentationCatalogItem *>(item);
+ if (!qtItem)
+ return false;
+
+ QFileInfo fi(qtItem->dcfFile());
+ config->setGroup("Index");
+ if (fi.lastModified() > config->readDateTimeEntry(qtItem->text(0), new QDateTime()))
+ {
+ kdDebug() << "need rebuild index for " << qtItem->text(0) << endl;
+ config->writeEntry(item->text(0), fi.lastModified());
+ return true;
+ }
+ else
+ return false;
+}
+
+void DocQtPlugin::createIndex(IndexBox *index, DocumentationCatalogItem *item)
+{
+ QtDocumentationCatalogItem *qtItem = dynamic_cast<QtDocumentationCatalogItem *>(item);
+ if (!qtItem)
+ return;
+
+ QFileInfo fi(qtItem->dcfFile());
+
+ QFile f(qtItem->dcfFile());
+ if (!f.open(IO_ReadOnly))
+ {
+ kdDebug(9002) << "Could not read" << qtItem->dcfFile() << endl;
+ return;
+ }
+ QDomDocument doc;
+ if (!doc.setContent(&f) || doc.doctype().name() != "DCF")
+ {
+ kdDebug(9002) << "Not a valid DCF file: " << qtItem->dcfFile() << endl;
+ return;
+ }
+ f.close();
+
+ QDomElement docEl = doc.documentElement();
+ QDomElement titleEl = docEl.namedItem("DCF").toElement();
+
+ QDomElement childEl = docEl.firstChild().toElement();
+ while (!childEl.isNull())
+ {
+ if (childEl.tagName() == "section")
+ {
+ createSectionIndex(fi, index, item, childEl);
+ }
+ childEl = childEl.nextSibling().toElement();
+ }
+}
+
+void DocQtPlugin::createSectionIndex(QFileInfo &fi, IndexBox *index, DocumentationCatalogItem *item,
+ QDomElement section)
+{
+ //adymo: do not load section to index for Qt reference documentation
+ QString title = section.attribute("title");
+ if (fi.fileName() != "qt.dcf")
+ {
+ QString ref = section.attribute("ref");
+
+ IndexItemProto *ii = new IndexItemProto(this, item, index, title, item->text(0));
+ ii->addURL(KURL(fi.dirPath(true) + "/" + ref));
+ }
+
+ QDomElement grandChild = section.firstChild().toElement();
+ while(!grandChild.isNull())
+ {
+ if (grandChild.tagName() == "keyword")
+ {
+ QString keyRef = grandChild.attribute("ref");
+ QString keyTitle = grandChild.text();
+
+ //adymo: a little hack to avoid unwanted elements
+ if (keyRef != "qdir-example.html")
+ {
+ IndexItemProto *ii = new IndexItemProto(this, item, index, keyTitle, title);
+ ii->addURL(KURL(fi.dirPath(true) + "/" + keyRef));
+ }
+ }
+ if (grandChild.tagName() == "section")
+ {
+ createSectionIndex(fi, index, item, grandChild);
+ }
+ grandChild = grandChild.nextSibling().toElement();
+ }
+}
+
+QStringList DocQtPlugin::fullTextSearchLocations()
+{
+ QStringList locs;
+
+ QMap<QString, QString> entryMap = config->entryMap("Locations");
+
+ for (QMap<QString, QString>::const_iterator it = entryMap.begin();
+ it != entryMap.end(); ++it)
+ {
+ config->setGroup("Search Settings");
+ if (config->readBoolEntry(it.key(), false))
+ {
+ config->setGroup("Locations");
+ QFileInfo fi(config->readPathEntry(it.key()));
+ locs << fi.dirPath(true);
+ }
+ }
+
+ return locs;
+}
+
+QPair<KFile::Mode, QString> DocQtPlugin::catalogLocatorProps()
+{
+ return QPair<KFile::Mode, QString>(KFile::File, "*.xml *.dcf");
+}
+
+QString DocQtPlugin::catalogTitle(const QString &url)
+{
+ QFileInfo fi(url);
+ if (!fi.exists())
+ return QString::null;
+
+ QFile f(url);
+ if (!f.open(IO_ReadOnly))
+ return QString::null;
+
+ QDomDocument doc;
+ if (!doc.setContent(&f) || (doc.doctype().name() != "DCF"))
+ return QString::null;
+ f.close();
+
+ QDomElement docEl = doc.documentElement();
+
+ return docEl.attribute("title", QString::null);
+}
+
+DocumentationCatalogItem *DocQtPlugin::createCatalog(KListView *contents, const QString &title, const QString &url)
+{
+ return new QtDocumentationCatalogItem(url, this, contents, title);
+}
+
+#include "docqtplugin.moc"
diff --git a/parts/documentation/plugins/qt/docqtplugin.desktop b/parts/documentation/plugins/qt/docqtplugin.desktop
new file mode 100644
index 00000000..1e96eacf
--- /dev/null
+++ b/parts/documentation/plugins/qt/docqtplugin.desktop
@@ -0,0 +1,44 @@
+[Desktop Entry]
+Type=Service
+Name=DocQtPlugin
+Name[da]=DocQt-plugin
+Name[sk]=Doc Qt modul
+Name[sv]=Qt-dokumentationsinsticksmodul
+Name[ta]=DocQt சொருகு
+Name[zh_TW]=Qt 文件外掛程式
+Exec=blubb
+Comment=Documentation plugin for Qt DCF documentation
+Comment[ca]=Connector de documentació per a documentació Qt DCF
+Comment[da]=Dokumentations-plugin for Qt DCF dokumentation
+Comment[de]=Komponente für Qt-DCF-Dokumentation
+Comment[el]=Πρόσθετο τεκμηρίωσης για τεκμηρίωση τύπου Qt DCF
+Comment[es]=Complemento de documentación para Qt DCF
+Comment[et]=Qt DCF dokumentatsiooni plugin
+Comment[eu]=Qt DCF dokumentaziorako dokumentazio plugin-a
+Comment[fa]=وصلۀ مستندسازی برای مستندات Qt DCF
+Comment[fr]=Module externe de documentation pour la documentation Qt DCF
+Comment[gl]=Extensión de documentación para documentación Qt DCF
+Comment[hu]=Dokumentációmodul Qt DCF-dokumentációhoz
+Comment[it]=Plugin di documentazione per file di Qt DCF
+Comment[ja]=Qt DCF ドキュメンテーションのためのドキュメンテーションプラグイン
+Comment[ms]=Plugin dokumentasi untuk dokumentasi Qt DCF
+Comment[nds]=Dokmentatschoon-Moduul för Qt-DCF-Dokmentatschoon
+Comment[ne]=Qt DCF मिसिलीकरणका लागि मिसिलीकरण प्लगइन
+Comment[nl]=Documentatie plugin voor Qt DCF documentatie
+Comment[pl]=Wtyczka dokumentacji dla dokumentacji w formacie Qt DCF
+Comment[pt]='Plugin' para documentação Qt DCF
+Comment[pt_BR]=Plug-in de documentação para documento DCF do Qt
+Comment[ru]=Модуль для просмотра Qt DCF
+Comment[sk]=Dokumentačný modul pre Qt DCF dokumentáciu
+Comment[sl]=Vstavek dokumentacije za Qt DCF
+Comment[sr]=Документациони прикључак за Qt DCF документацију
+Comment[sr@Latn]=Dokumentacioni priključak za Qt DCF dokumentaciju
+Comment[sv]=Dokumentationsinsticksmodul för Qt DCF-dokumentation
+Comment[ta]= Qt DCF ஆவணத்திற்கான ஆவணச் சொருகு
+Comment[tg]=Модул барои наоиши QT DCF
+Comment[tr]=Qt DCF Belgelendirmesi için belgelendirme eklentisi
+Comment[zh_CN]=Qt DCF 文档的文档插件
+Comment[zh_TW]=Qt DCF 文件外掛程式
+ServiceTypes=KDevelop/DocumentationPlugins
+X-KDevelop-Version=5
+X-KDE-Library=libdocqtplugin
diff --git a/parts/documentation/plugins/qt/docqtplugin.h b/parts/documentation/plugins/qt/docqtplugin.h
new file mode 100644
index 00000000..802dd98a
--- /dev/null
+++ b/parts/documentation/plugins/qt/docqtplugin.h
@@ -0,0 +1,56 @@
+/***************************************************************************
+ * Copyright (C) 2004 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. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef DOCQTPLUGIN_H
+#define DOCQTPLUGIN_H
+
+#include <kdevdocumentationplugin.h>
+#include <qdom.h>
+
+class KConfig;
+
+class DocQtPlugin : public DocumentationPlugin
+{
+ Q_OBJECT
+public:
+ DocQtPlugin(QObject* parent, const char* name, const QStringList args = QStringList());
+ ~DocQtPlugin();
+
+ virtual QString pluginName() const;
+
+ virtual DocumentationCatalogItem *createCatalog(KListView *contents, const QString &title, const QString &url);
+
+ virtual void createTOC(DocumentationCatalogItem *item);
+ virtual void setCatalogURL(DocumentationCatalogItem *item);
+
+ virtual bool needRefreshIndex(DocumentationCatalogItem *item);
+ virtual void createIndex(IndexBox *index, DocumentationCatalogItem *item);
+ virtual void createSectionIndex(QFileInfo &fi, IndexBox *index, DocumentationCatalogItem *item,
+ QDomElement section);
+
+ virtual QStringList fullTextSearchLocations();
+
+ virtual QPair<KFile::Mode, QString> catalogLocatorProps();
+ virtual QString catalogTitle(const QString &url);
+
+ virtual void autoSetupPlugin();
+
+};
+
+#endif