diff --git a/documentation/qthelp/qthelpproviderabstract.cpp b/documentation/qthelp/qthelpproviderabstract.cpp index a115aca190..7f67fa47d7 100644 --- a/documentation/qthelp/qthelpproviderabstract.cpp +++ b/documentation/qthelp/qthelpproviderabstract.cpp @@ -1,112 +1,117 @@ /* This file is part of KDevelop Copyright 2009 Aleix Pol Copyright 2009 David Nolden Copyright 2010 Benjamin Port This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "qthelpprovider.h" #include #include #include #include #include #include #include #include #include "qthelpdocumentation.h" #include "debug.h" using namespace KDevelop; QtHelpProviderAbstract::QtHelpProviderAbstract(QObject *parent, const QString &collectionFileName, const QVariantList &args) : QObject(parent) , m_engine(QStandardPaths::writableLocation(QStandardPaths::DataLocation)+'/'+collectionFileName) { Q_UNUSED(args); if( !m_engine.setupData() ) { qWarning() << "Couldn't setup QtHelp Collection file"; } } + +QtHelpProviderAbstract::~QtHelpProviderAbstract() +{ +} + IDocumentation::Ptr QtHelpProviderAbstract::documentationForDeclaration(Declaration* dec) const { QtHelpDocumentation::s_provider = const_cast(this); if(dec) { static const IndexedString qmlJs("QML/JS"); bool isQML; QStringList idParts; { DUChainReadLocker lock; isQML = dec->topContext()->parsingEnvironmentFile()->language() == qmlJs; idParts = dec->qualifiedIdentifier().toStringList(); } QString id; if(isQML && !idParts.isEmpty()) { id = QLatin1String("QML."); } if(!idParts.isEmpty()) { id += idParts.join(QLatin1String("::")); QMap links=m_engine.linksForIdentifier(id); if(!links.isEmpty()) return IDocumentation::Ptr(new QtHelpDocumentation(id, links)); } } return {}; } QAbstractListModel* QtHelpProviderAbstract::indexModel() const { QtHelpDocumentation::s_provider = const_cast(this); return m_engine.indexModel(); } IDocumentation::Ptr QtHelpProviderAbstract::documentationForIndex(const QModelIndex& idx) const { QtHelpDocumentation::s_provider = const_cast(this); QString name=idx.data(Qt::DisplayRole).toString(); return IDocumentation::Ptr(new QtHelpDocumentation(name, m_engine.indexModel()->linksForKeyword(name))); } void QtHelpProviderAbstract::jumpedTo(const QUrl& newUrl) const { QtHelpDocumentation::s_provider = const_cast(this); QMap info; info.insert(newUrl.toString(), newUrl); IDocumentation::Ptr doc(new QtHelpDocumentation(newUrl.toString(), info)); emit addHistory(doc); } IDocumentation::Ptr QtHelpProviderAbstract::homePage() const { QtHelpDocumentation::s_provider = const_cast(this); return IDocumentation::Ptr(new HomeDocumentation); } bool QtHelpProviderAbstract::isValid() const { return !m_engine.registeredDocumentations().isEmpty(); } diff --git a/documentation/qthelp/qthelpproviderabstract.h b/documentation/qthelp/qthelpproviderabstract.h index 550b4cabcb..1f5f1b28fb 100644 --- a/documentation/qthelp/qthelpproviderabstract.h +++ b/documentation/qthelp/qthelpproviderabstract.h @@ -1,58 +1,58 @@ /* This file is part of KDevelop Copyright 2009 Aleix Pol Copyright 2009 David Nolden Copyright 2010 Benjamin Port This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef QTHELPPROVIDERABSTRACT_H #define QTHELPPROVIDERABSTRACT_H #include #include #include #include #include #include - class QtHelpProviderAbstract : public QObject, public KDevelop::IDocumentationProvider { Q_OBJECT Q_INTERFACES( KDevelop::IDocumentationProvider ) public: QtHelpProviderAbstract(QObject *parent, const QString &collectionFileName, const QVariantList & args); + virtual ~QtHelpProviderAbstract(); KDevelop::IDocumentation::Ptr documentationForDeclaration (KDevelop::Declaration*) const override; KDevelop::IDocumentation::Ptr documentationForIndex(const QModelIndex& idx) const override; QAbstractListModel* indexModel() const override; KDevelop::IDocumentation::Ptr homePage() const override; /// @return False in case we failed to load any documentation files, else true bool isValid() const; QHelpEngine* engine() { return &m_engine; } public slots: void jumpedTo(const QUrl& newUrl) const; signals: void addHistory(const KDevelop::IDocumentation::Ptr& doc) const override; protected: QHelpEngine m_engine; }; #endif // QTHELPPROVIDERABSTRACT_H