+
+namespace berry {
+
+struct ExtensionMap {
+ const char *extension;
+ const char *mimeType;
+} extensionMap[] = {
+ { ".bmp", "image/bmp" },
+ { ".css", "text/css" },
+ { ".gif", "image/gif" },
+ { ".html", "text/html" },
+ { ".htm", "text/html" },
+ { ".ico", "image/x-icon" },
+ { ".jpeg", "image/jpeg" },
+ { ".jpg", "image/jpeg" },
+ { ".js", "application/x-javascript" },
+ { ".mng", "video/x-mng" },
+ { ".pbm", "image/x-portable-bitmap" },
+ { ".pgm", "image/x-portable-graymap" },
+ { ".pdf", "application/pdf" },
+ { ".png", "image/png" },
+ { ".ppm", "image/x-portable-pixmap" },
+ { ".rss", "application/rss+xml" },
+ { ".svg", "image/svg+xml" },
+ { ".svgz", "image/svg+xml" },
+ { ".text", "text/plain" },
+ { ".tif", "image/tiff" },
+ { ".tiff", "image/tiff" },
+ { ".txt", "text/plain" },
+ { ".xbm", "image/x-xbitmap" },
+ { ".xml", "text/xml" },
+ { ".xpm", "image/x-xpm" },
+ { ".xsl", "text/xsl" },
+ { ".xhtml", "application/xhtml+xml" },
+ { ".wml", "text/vnd.wap.wml" },
+ { ".wmlc", "application/vnd.wap.wmlc" },
+ { "about:blank", 0 },
+ { 0, 0 }
+};
+
+
+const QString HelpWebView::m_PageNotFoundMessage =
+ QCoreApplication::translate("org.blueberry.ui.qt.help", "Error 404...
The page could not be found
'%1'"
+ "
");
+
+class HelpNetworkReply : public QNetworkReply
+{
+public:
+ HelpNetworkReply(const QNetworkRequest &request, const QByteArray &fileData,
+ const QString &mimeType);
+
+ virtual void abort();
+
+ virtual qint64 bytesAvailable() const
+ { return data.length() + QNetworkReply::bytesAvailable(); }
+
+protected:
+ virtual qint64 readData(char *data, qint64 maxlen);
+
+private:
+ QByteArray data;
+ qint64 origLen;
+};
+
+HelpNetworkReply::HelpNetworkReply(const QNetworkRequest &request,
+ const QByteArray &fileData, const QString& mimeType)
+ : data(fileData), origLen(fileData.length())
+{
+ setRequest(request);
+ setOpenMode(QIODevice::ReadOnly);
+
+ setHeader(QNetworkRequest::ContentTypeHeader, mimeType);
+ setHeader(QNetworkRequest::ContentLengthHeader, QByteArray::number(origLen));
+ QTimer::singleShot(0, this, SIGNAL(metaDataChanged()));
+ QTimer::singleShot(0, this, SIGNAL(readyRead()));
+}
+
+void HelpNetworkReply::abort()
+{
+}
+
+qint64 HelpNetworkReply::readData(char *buffer, qint64 maxlen)
+{
+ qint64 len = qMin(qint64(data.length()), maxlen);
+ if (len) {
+ memcpy(buffer, data.constData(), len);
+ data.remove(0, len);
+ }
+ if (!data.length())
+ QTimer::singleShot(0, this, SIGNAL(finished()));
+ return len;
+}
+
+class HelpNetworkAccessManager : public QNetworkAccessManager
+{
+public:
+ HelpNetworkAccessManager(QObject *parent);
+
+protected:
+ virtual QNetworkReply *createRequest(Operation op,
+ const QNetworkRequest &request,
+ QIODevice *outgoingData = 0);
+};
+
+HelpNetworkAccessManager::HelpNetworkAccessManager(QObject *parent)
+ : QNetworkAccessManager(parent)
+{
+}
+
+QNetworkReply *HelpNetworkAccessManager::createRequest(Operation /*op*/,
+ const QNetworkRequest &request,
+ QIODevice* /*outgoingData*/)
+{
+ QString url = request.url().toString();
+ QHelpEngine& helpEngine = HelpPluginActivator::getInstance()->getQHelpEngine();
+
+ // TODO: For some reason the url to load is already wrong (passed from webkit)
+ // though the css file and the references inside should work that way. One
+ // possible problem might be that the css is loaded at the same level as the
+ // html, thus a path inside the css like (../images/foo.png) might cd out of
+ // the virtual folder
+ // if (!helpEngine.findFile(url).isValid()) {
+ // if (url.startsWith(AbstractHelpWebView::DocPath)) {
+ // QUrl newUrl = request.url();
+ // if (!newUrl.path().startsWith(QLatin1String("/qdoc/"))) {
+ // newUrl.setPath(QLatin1String("qdoc") + newUrl.path());
+ // url = newUrl.toString();
+ // }
+ // }
+ // }
+
+ const QString &mimeType = HelpWebView::mimeFromUrl(url);
+ const QByteArray &data = helpEngine.findFile(url).isValid()
+ ? helpEngine.fileData(url)
+ : HelpWebView::m_PageNotFoundMessage.arg(url).toUtf8();
+ return new HelpNetworkReply(request, data, mimeType.isEmpty()
+ ? QLatin1String("application/octet-stream") : mimeType);
+}
+
+class HelpPage : public QWebPage
+{
+
+public:
+
+ HelpPage(IEditorSite::Pointer editorSite, QObject *parent);
+
+protected:
+
+ virtual QWebPage *createWindow(QWebPage::WebWindowType);
+ virtual void triggerAction(WebAction action, bool checked = false);
+
+ virtual bool acceptNavigationRequest(QWebFrame *frame,
+ const QNetworkRequest &request,
+ NavigationType type);
+
+private:
+
+ IEditorSite::Pointer m_EditorSite;
+ bool m_CloseNewTabIfNeeded;
+
+ friend class HelpWebView;
+ QUrl m_loadingUrl;
+ Qt::MouseButtons m_pressedButtons;
+ Qt::KeyboardModifiers m_keyboardModifiers;
+
+};
+
+HelpPage::HelpPage(IEditorSite::Pointer editorSite, QObject *parent)
+ : QWebPage(parent)
+ , m_EditorSite(editorSite)
+ , m_CloseNewTabIfNeeded(false)
+ , m_pressedButtons(Qt::NoButton)
+ , m_keyboardModifiers(Qt::NoModifier)
+{
+
+}
+
+QWebPage *HelpPage::createWindow(QWebPage::WebWindowType type)
+{
+ IEditorInput::Pointer input(new HelpEditorInput(QUrl()));
+ IEditorPart::Pointer editorPart = m_EditorSite->GetPage()->OpenEditor(input, HelpEditor::EDITOR_ID);
+ HelpEditor::Pointer helpEditor = editorPart.Cast();
+ HelpPage* newPage = static_cast(helpEditor->GetQWebPage());
+ if (newPage)
+ newPage->m_CloseNewTabIfNeeded = m_CloseNewTabIfNeeded;
+ m_CloseNewTabIfNeeded = false;
+ return newPage;
+}
+
+void HelpPage::triggerAction(WebAction action, bool checked)
+{
+ switch (action)
+ {
+ case OpenLinkInNewWindow:
+ m_CloseNewTabIfNeeded = true;
+ default: // fall through
+ QWebPage::triggerAction(action, checked);
+ break;
+ }
+}
+
+bool HelpPage::acceptNavigationRequest(QWebFrame *,
+ const QNetworkRequest &request,
+ QWebPage::NavigationType type)
+{
+ const bool closeNewTab = m_CloseNewTabIfNeeded;
+ m_CloseNewTabIfNeeded = false;
+
+// const QUrl &url = request.url();
+// if (AbstractHelpWebView::launchWithExternalApp(url))
+// {
+// if (closeNewTab)
+// QMetaObject::invokeMethod(centralWidget, "closeTab");
+// return false;
+// }
+
+// if (type == QWebPage::NavigationTypeLinkClicked
+// && (m_keyboardModifiers & Qt::ControlModifier
+// || m_pressedButtons == Qt::MidButton))
+// {
+// if (centralWidget->newEmptyTab())
+// centralWidget->setSource(url);
+// m_pressedButtons = Qt::NoButton;
+// m_keyboardModifiers = Qt::NoModifier;
+// return false;
+// }
+
+// m_loadingUrl = url; // because of async page loading, we will hit some kind
+ // of race condition while using a remote command, like a combination of
+ // SetSource; SyncContent. SetSource would be called and SyncContents shortly
+ // afterwards, but the page might not have finished loading and the old url
+ // would be returned.
+ return true;
+}
+
+// -- HelpWebView
+
+HelpWebView::HelpWebView(IEditorSite::Pointer editorSite, QWidget *parent, qreal zoom)
+ : QWebView(parent)
+ //, parentWidget(parent)
+ , m_LoadFinished(false)
+ , m_HelpEngine(HelpPluginActivator::getInstance()->getQHelpEngine())
+{
+ setAcceptDrops(false);
+
+ setPage(new HelpPage(editorSite, parent));
+
+ page()->setNetworkAccessManager(new HelpNetworkAccessManager(this));
+
+ QAction* action = pageAction(QWebPage::OpenLinkInNewWindow);
+ action->setText(tr("Open Link in New Tab"));
+ if (!parent)
+ action->setVisible(false);
+
+ pageAction(QWebPage::DownloadLinkToDisk)->setVisible(false);
+ pageAction(QWebPage::DownloadImageToDisk)->setVisible(false);
+ pageAction(QWebPage::OpenImageInNewWindow)->setVisible(false);
+
+ connect(pageAction(QWebPage::Copy), SIGNAL(changed()), this,
+ SLOT(actionChanged()));
+ connect(pageAction(QWebPage::Back), SIGNAL(changed()), this,
+ SLOT(actionChanged()));
+ connect(pageAction(QWebPage::Forward), SIGNAL(changed()), this,
+ SLOT(actionChanged()));
+ connect(page(), SIGNAL(linkHovered(QString,QString,QString)), this,
+ SIGNAL(highlighted(QString)));
+ connect(this, SIGNAL(urlChanged(QUrl)), this, SIGNAL(sourceChanged(QUrl)));
+ connect(this, SIGNAL(loadStarted()), this, SLOT(setLoadStarted()));
+ connect(this, SIGNAL(loadFinished(bool)), this, SLOT(setLoadFinished(bool)));
+ connect(page(), SIGNAL(printRequested(QWebFrame*)), this, SIGNAL(printRequested()));
+
+ setFont(viewerFont());
+ setTextSizeMultiplier(zoom == 0.0 ? 1.0 : zoom);
+}
+
+HelpWebView::~HelpWebView()
+{
+}
+
+QFont HelpWebView::viewerFont() const
+{
+ //if (m_HelpEngine.usesBrowserFont())
+ // return m_HelpEngine.browserFont();
+
+ QWebSettings *webSettings = QWebSettings::globalSettings();
+ return QFont(webSettings->fontFamily(QWebSettings::StandardFont),
+ webSettings->fontSize(QWebSettings::DefaultFontSize));
+}
+
+void HelpWebView::setViewerFont(const QFont &font)
+{
+ QWebSettings *webSettings = settings();
+ webSettings->setFontFamily(QWebSettings::StandardFont, font.family());
+ webSettings->setFontSize(QWebSettings::DefaultFontSize, font.pointSize());
+}
+
+void HelpWebView::scaleUp()
+{
+ setTextSizeMultiplier(textSizeMultiplier() + 0.1);
+}
+
+void HelpWebView::scaleDown()
+{
+ setTextSizeMultiplier(qMax(0.0, textSizeMultiplier() - 0.1));
+}
+
+void HelpWebView::resetScale()
+{
+ setTextSizeMultiplier(1.0);
+}
+
+bool HelpWebView::handleForwardBackwardMouseButtons(QMouseEvent *e)
+{
+ if (e->button() == Qt::XButton1)
+ {
+ triggerPageAction(QWebPage::Back);
+ return true;
+ }
+
+ if (e->button() == Qt::XButton2)
+ {
+ triggerPageAction(QWebPage::Forward);
+ return true;
+ }
+
+ return false;
+}
+
+QUrl HelpWebView::source() const
+{
+ HelpPage *currentPage = static_cast (page());
+ if (currentPage && !hasLoadFinished())
+ {
+ // see HelpPage::acceptNavigationRequest(...)
+ return currentPage->m_loadingUrl;
+ }
+ return url();
+}
+
+void HelpWebView::setSource(const QUrl &url)
+{
+ if (m_HelpEngine.findFile(url).isValid())
+ load(url);
+ else
+ setHtml(m_PageNotFoundMessage.arg(url.toString()));
+}
+
+void HelpWebView::wheelEvent(QWheelEvent *e)
+{
+ if (e->modifiers()& Qt::ControlModifier)
+ {
+ e->accept();
+ e->delta() > 0 ? scaleUp() : scaleDown();
+ }
+ else
+ {
+ QWebView::wheelEvent(e);
+ }
+}
+
+void HelpWebView::mouseReleaseEvent(QMouseEvent *e)
+{
+#ifndef Q_OS_LINUX
+ if (handleForwardBackwardMouseButtons(e))
+ return;
+#endif
+
+ QWebView::mouseReleaseEvent(e);
+}
+
+void HelpWebView::actionChanged()
+{
+ QAction *a = qobject_cast(sender());
+ if (a == pageAction(QWebPage::Copy))
+ emit copyAvailable(a->isEnabled());
+ else if (a == pageAction(QWebPage::Back))
+ emit backwardAvailable(a->isEnabled());
+ else if (a == pageAction(QWebPage::Forward))
+ emit forwardAvailable(a->isEnabled());
+}
+
+void HelpWebView::mousePressEvent(QMouseEvent *event)
+{
+#ifdef Q_OS_LINUX
+ if (handleForwardBackwardMouseButtons(event))
+ return;
+#endif
+
+ HelpPage *currentPage = static_cast(page());
+ if (currentPage)
+ {
+ currentPage->m_pressedButtons = event->buttons();
+ currentPage->m_keyboardModifiers = event->modifiers();
+ }
+ QWebView::mousePressEvent(event);
+}
+
+void HelpWebView::setLoadStarted()
+{
+ m_LoadFinished = false;
+}
+
+void HelpWebView::setLoadFinished(bool ok)
+{
+ m_LoadFinished = ok;
+ emit sourceChanged(url());
+}
+
+QString HelpWebView::mimeFromUrl(const QUrl &url)
+{
+ const QString &path = url.path();
+ const int index = path.lastIndexOf(QLatin1Char('.'));
+ const QByteArray &ext = path.mid(index).toUtf8().toLower();
+
+ const ExtensionMap *e = extensionMap;
+ while (e->extension)
+ {
+ if (ext == e->extension)
+ return QLatin1String(e->mimeType);
+ ++e;
+ }
+ return QLatin1String("");
+}
+
+bool HelpWebView::canOpenPage(const QString &url)
+{
+ return !mimeFromUrl(url).isEmpty();
+}
+
+bool HelpWebView::isLocalUrl(const QUrl &url)
+{
+ const QString &scheme = url.scheme();
+ return scheme.isEmpty()
+ || scheme == QLatin1String("file")
+ || scheme == QLatin1String("qrc")
+ || scheme == QLatin1String("data")
+ || scheme == QLatin1String("qthelp")
+ || scheme == QLatin1String("about");
+}
+
+bool HelpWebView::launchWithExternalApp(const QUrl &url)
+{
+ if (isLocalUrl(url))
+ {
+ const QHelpEngine& helpEngine = HelpPluginActivator::getInstance()->getQHelpEngine();
+ const QUrl &resolvedUrl = helpEngine.findFile(url);
+ if (!resolvedUrl.isValid())
+ return false;
+
+ const QString& path = resolvedUrl.path();
+ if (!canOpenPage(path))
+ {
+ QTemporaryFile tmpTmpFile;
+ if (!tmpTmpFile.open())
+ return false;
+
+ const QString &extension = QFileInfo(path).completeSuffix();
+ QFile actualTmpFile(tmpTmpFile.fileName() % QLatin1String(".")
+ % extension);
+ if (!actualTmpFile.open(QIODevice::ReadWrite | QIODevice::Truncate))
+ return false;
+
+ actualTmpFile.write(helpEngine.fileData(resolvedUrl));
+ actualTmpFile.close();
+ return QDesktopServices::openUrl(QUrl(actualTmpFile.fileName()));
+ }
+ }
+ else if (url.scheme() == QLatin1String("http"))
+ {
+ return QDesktopServices::openUrl(url);
+ }
+ return false;
+}
+
+void HelpWebView::home()
+{
+ setSource(m_HelpEngine.homePage());
+}
+
+}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpWebView.h b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpWebView.h
new file mode 100644
index 0000000000..a93a749b4c
--- /dev/null
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryHelpWebView.h
@@ -0,0 +1,109 @@
+/*=========================================================================
+
+Program: BlueBerry Platform
+Language: C++
+Date: $Date$
+Version: $Revision$
+
+Copyright (c) German Cancer Research Center, Division of Medical and
+Biological Informatics. All rights reserved.
+See MITKCopyright.txt or http://www.mitk.org/copyright.html for details.
+
+This software is distributed WITHOUT ANY WARRANTY; without even
+the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*/
+
+
+#ifndef BERRYHELPWEBVIEW_H
+#define BERRYHELPWEBVIEW_H
+
+#include
+#include
+
+#include
+
+#include
+
+
+namespace berry {
+
+class QHelpEngineWrapper;
+
+class HelpWebView : public QWebView
+{
+ Q_OBJECT
+
+public:
+ explicit HelpWebView(IEditorSite::Pointer editorSite, QWidget *parent, qreal zoom = 0.0);
+ ~HelpWebView();
+
+ QFont viewerFont() const;
+ void setViewerFont(const QFont &font);
+
+ qreal scale() const { return textSizeMultiplier(); }
+
+ bool handleForwardBackwardMouseButtons(QMouseEvent *e);
+
+ QUrl source() const;
+ void setSource(const QUrl &url);
+
+ inline QString documentTitle() const
+ { return title(); }
+
+ inline bool hasSelection() const
+ { return !selectedText().isEmpty(); } // ### this is suboptimal
+
+ inline void copy()
+ { return triggerPageAction(QWebPage::Copy); }
+
+ inline bool isForwardAvailable() const
+ { return pageAction(QWebPage::Forward)->isEnabled(); }
+ inline bool isBackwardAvailable() const
+ { return pageAction(QWebPage::Back)->isEnabled(); }
+ inline bool hasLoadFinished() const
+ { return m_LoadFinished; }
+
+ static QString mimeFromUrl(const QUrl &url);
+ static bool canOpenPage(const QString &url);
+ static bool isLocalUrl(const QUrl &url);
+ static bool launchWithExternalApp(const QUrl &url);
+ static const QString m_PageNotFoundMessage;
+
+public Q_SLOTS:
+
+ void backward() { back(); }
+ void home();
+
+ void scaleUp();
+ void scaleDown();
+ void resetScale();
+
+Q_SIGNALS:
+ void copyAvailable(bool enabled);
+ void forwardAvailable(bool enabled);
+ void backwardAvailable(bool enabled);
+ void highlighted(const QString &);
+ void sourceChanged(const QUrl &);
+ void printRequested();
+
+protected:
+ virtual void wheelEvent(QWheelEvent *);
+ void mouseReleaseEvent(QMouseEvent *e);
+ void mousePressEvent(QMouseEvent *event);
+
+private Q_SLOTS:
+ void actionChanged();
+ void setLoadStarted();
+ void setLoadFinished(bool ok);
+
+private:
+
+ bool m_LoadFinished;
+ QHelpEngineWrapper& m_HelpEngine;
+};
+
+}
+
+#endif // BERRYHELPWEBVIEW_H
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryQHelpEngineConfiguration.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryQHelpEngineConfiguration.cpp
new file mode 100644
index 0000000000..ec136dc0f9
--- /dev/null
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryQHelpEngineConfiguration.cpp
@@ -0,0 +1,66 @@
+/*=========================================================================
+
+Program: BlueBerry Platform
+Language: C++
+Date: $Date$
+Version: $Revision$
+
+Copyright (c) German Cancer Research Center, Division of Medical and
+Biological Informatics. All rights reserved.
+See MITKCopyright.txt or http://www.mitk.org/copyright.html for details.
+
+This software is distributed WITHOUT ANY WARRANTY; without even
+the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*/
+
+
+#include "berryQHelpEngineConfiguration.h"
+#include "berryQHelpEngineWrapper.h"
+
+#include
+
+
+namespace berry {
+
+QString QHelpEngineConfiguration::PID = "org.blueberry.services.help";
+
+QHelpEngineConfiguration::QHelpEngineConfiguration(ctkPluginContext* context,
+ QHelpEngineWrapper& helpEngine)
+ : helpEngine(helpEngine)
+{
+ QMutexLocker lock(&mutex);
+ registration = context->registerService(this, getDefaults());
+}
+
+void QHelpEngineConfiguration::updated(const ctkDictionary &properties)
+{
+ if (properties.isEmpty())
+ {
+ QMutexLocker lock(&mutex);
+ registration.setProperties(getDefaults());
+ }
+ else
+ {
+ QMetaObject::invokeMethod(this, "configurationChanged", Q_ARG(ctkDictionary, properties));
+
+ QMutexLocker lock(&mutex);
+ registration.setProperties(properties);
+ }
+}
+
+void QHelpEngineConfiguration::configurationChanged(const ctkDictionary& properties)
+{
+ helpEngine.setHomePage(properties["homePage"].toString());
+}
+
+ctkDictionary QHelpEngineConfiguration::getDefaults() const
+{
+ ctkDictionary defaults;
+ defaults.insert("homePage", "");
+ defaults.insert(ctkPluginConstants::SERVICE_PID, PID);
+ return defaults;
+}
+
+}
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryQHelpEngineConfiguration.h b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryQHelpEngineConfiguration.h
new file mode 100644
index 0000000000..77f0bf1666
--- /dev/null
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryQHelpEngineConfiguration.h
@@ -0,0 +1,63 @@
+/*=========================================================================
+
+Program: BlueBerry Platform
+Language: C++
+Date: $Date$
+Version: $Revision$
+
+Copyright (c) German Cancer Research Center, Division of Medical and
+Biological Informatics. All rights reserved.
+See MITKCopyright.txt or http://www.mitk.org/copyright.html for details.
+
+This software is distributed WITHOUT ANY WARRANTY; without even
+the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*/
+
+
+#ifndef BERRYQHELPENGINECONFIGURATION_H
+#define BERRYQHELPENGINECONFIGURATION_H
+
+#include
+
+#include
+#include
+
+
+namespace berry {
+
+class QHelpEngineWrapper;
+
+class QHelpEngineConfiguration : public QObject, public ctkManagedService
+{
+ Q_OBJECT
+ Q_INTERFACES(ctkManagedService)
+
+public:
+
+ QHelpEngineConfiguration(ctkPluginContext* context, QHelpEngineWrapper& helpEngine);
+
+ void updated(const ctkDictionary &properties);
+
+public Q_SLOTS:
+
+ void configurationChanged(const ctkDictionary &properties);
+
+private:
+
+ Q_DISABLE_COPY(QHelpEngineConfiguration)
+
+ ctkDictionary getDefaults() const;
+
+ static QString PID;
+
+ QMutex mutex;
+ ctkServiceRegistration registration;
+
+ QHelpEngineWrapper& helpEngine;
+};
+
+}
+
+#endif // BERRYQHELPENGINECONFIGURATION_H
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryQHelpEngineWrapper.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryQHelpEngineWrapper.cpp
new file mode 100644
index 0000000000..ae5c1aea94
--- /dev/null
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryQHelpEngineWrapper.cpp
@@ -0,0 +1,65 @@
+/*=========================================================================
+
+ Program: BlueBerry Platform
+ Language: C++
+ Date: $Date$
+ Version: $Revision$
+
+ Copyright (c) German Cancer Research Center, Division of Medical and
+ Biological Informatics. All rights reserved.
+ See MITKCopyright.txt or http://www.mitk.org/copyright.html for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notices for more information.
+
+ =========================================================================*/
+
+#include "berryQHelpEngineWrapper.h"
+
+#include
+
+
+namespace berry {
+
+QHelpEngineWrapper::QHelpEngineWrapper(const QString &collectionFile)
+ : QHelpEngine(collectionFile)
+{
+ /*
+ * Otherwise we will waste time if several new docs are found,
+ * because we will start to index them, only to be interrupted
+ * by the next request. Also, there is a nasty SQLITE bug that will
+ * cause the application to hang for minutes in that case.
+ * This call is reverted by initalDocSetupDone(), which must be
+ * called after the new docs have been installed.
+ */
+ disconnect(this, SIGNAL(setupFinished()),
+ searchEngine(), SLOT(indexDocumentation()));
+}
+
+QHelpEngineWrapper::~QHelpEngineWrapper()
+{
+}
+
+void QHelpEngineWrapper::initialDocSetupDone()
+{
+ connect(this, SIGNAL(setupFinished()),
+ searchEngine(), SLOT(indexDocumentation()));
+ setupData();
+}
+
+const QString QHelpEngineWrapper::homePage() const
+{
+ return m_HomePage;
+}
+
+void QHelpEngineWrapper::setHomePage(const QString &page)
+{
+ if (m_HomePage != page)
+ {
+ m_HomePage = page;
+ emit homePageChanged(page);
+ }
+}
+
+} // end namespace berry
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryQHelpEngineWrapper.h b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryQHelpEngineWrapper.h
new file mode 100644
index 0000000000..436c5473ed
--- /dev/null
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt.help/src/internal/berryQHelpEngineWrapper.h
@@ -0,0 +1,57 @@
+/*=========================================================================
+
+ Program: BlueBerry Platform
+ Language: C++
+ Date: $Date$
+ Version: $Revision$
+
+ Copyright (c) German Cancer Research Center, Division of Medical and
+ Biological Informatics. All rights reserved.
+ See MITKCopyright.txt or http://www.mitk.org/copyright.html for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notices for more information.
+
+ =========================================================================*/
+
+#ifndef BERRYQHELPENGINEWRAPPER_H
+#define BERRYQHELPENGINEWRAPPER_H
+
+#include
+
+
+namespace berry {
+
+class QHelpEngineWrapper : public QHelpEngine
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(QHelpEngineWrapper)
+
+public:
+
+ QHelpEngineWrapper(const QString &collectionFile);
+ ~QHelpEngineWrapper();
+
+ /*
+ * To be called after the initial search for qch files finished.
+ * This will mainly cause the search index to be updated, if necessary.
+ */
+ void initialDocSetupDone();
+
+ const QString homePage() const;
+ void setHomePage(const QString &page);
+
+Q_SIGNALS:
+
+ void homePageChanged(const QString& page);
+
+private:
+
+ QString m_HomePage;
+
+};
+
+} // end namespace berry
+
+#endif // BERRYQHELPENGINEWRAPPER_H
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt.help/target_libraries.cmake b/BlueBerry/Bundles/org.blueberry.ui.qt.help/target_libraries.cmake
new file mode 100644
index 0000000000..9412e38dde
--- /dev/null
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt.help/target_libraries.cmake
@@ -0,0 +1,9 @@
+# See CMake/ctkFunctionGetTargetLibraries.cmake
+#
+# This file should list the libraries required to build the current CTK plugin.
+# For specifying required plugins, see the manifest_headers.cmake file.
+#
+
+SET(target_libraries
+ CTKWidgets
+)
diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtAssistantUtil.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtAssistantUtil.h
index bd1f6068bb..3c0f3c5a31 100644
--- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtAssistantUtil.h
+++ b/BlueBerry/Bundles/org.blueberry.ui.qt/src/berryQtAssistantUtil.h
@@ -1,74 +1,80 @@
/*=========================================================================
Program: BlueBerry Platform
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) German Cancer Research Center, Division of Medical and
Biological Informatics. All rights reserved.
See MITKCopyright.txt or http://www.mitk.org/copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef BERRYQTASSISTANTUTIL_H_
#define BERRYQTASSISTANTUTIL_H_
#include
#include
#include
#include
#include
#include
#include
namespace berry {
+/**
+ * \deprecated
+ *
+ * This class is deprecated. Please use the org.blueberry.ui.qt.help
+ * plug-in if you want to access help contents in your application.
+ */
class BERRY_UI_QT QtAssistantUtil
{
public:
static void OpenAssistant(const QString& startPage = "");
static void CloseAssistant();
/**
* @brief With this method you can open the help-page of the active bundle.
*/
static void OpenActivePartHelp();
// for legacy BlueBerry bundle support
static bool RegisterQCHFiles(const std::vector& bundles);
static bool RegisterQCHFiles(const QStringList& qchFiles);
static bool UnregisterQCHFiles(const QStringList& qchFiles);
static void SetHelpCollectionFile(const QString& file);
static QString GetHelpCollectionFile();
static void SetDefaultHelpUrl(const QString& defaultUrl);
private:
static QProcess* assistantProcess;
static QString helpCollectionFile;
static QString defaultHelpUrl;
static QSet registeredBundles;
static QString GetAssistantExecutable();
static QStringList ExtractQCHFiles(const std::vector& bundles);
static bool CallQtAssistant(const QStringList& qchFiles, bool registerFile = true);
};
}
#endif /* BERRYQTASSISTANTUTIL_H_ */
diff --git a/BlueBerry/CMakeLists.txt b/BlueBerry/CMakeLists.txt
index 7bd929fd2e..335a90b3a6 100644
--- a/BlueBerry/CMakeLists.txt
+++ b/BlueBerry/CMakeLists.txt
@@ -1,297 +1,298 @@
PROJECT(BlueBerry)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.4)
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/CMake/")
INCLUDE(MacroParseArguments)
INCLUDE(MacroConvertSchema)
INCLUDE(MacroOrganizeSources)
INCLUDE(berryPluginHelpers)
INCLUDE(MacroCollectPlugins)
INCLUDE(MacroParseManifest)
INCLUDE(MacroCreatePlugin)
INCLUDE(MacroCreateCTKPlugin)
INCLUDE(MacroCreateQtHelp)
INCLUDE(MacroInstallPlugin)
INCLUDE(MacroInstallCTKPlugin)
INCLUDE(FunctionCreateProvisioningFile)
IF(MSVC)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4250 /wd4275 /wd4251 /wd4503")
ENDIF()
IF (NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
ENDIF ()
FIND_PACKAGE(mbilog REQUIRED)
INCLUDE_DIRECTORIES(${mbilog_INCLUDE_DIRS})
OPTION(BLUEBERRY_USE_QT "Use the Qt GUI toolkit" OFF)
IF(NOT DESIRED_QT_VERSION)
SET(DESIRED_QT_VERSION 4 CACHE STRING "Desired Qt version" FORCE)
MARK_AS_ADVANCED(DESIRED_QT_VERSION)
ENDIF()
IF(BLUEBERRY_USE_QT AND NOT DESIRED_QT_VERSION EQUAL 4)
MESSAGE("Attention: Qt4 GUI libraries are required to build the BlueBerry Qt plug-ins.")
ENDIF()
IF(BLUEBERRY_USE_QT AND DESIRED_QT_VERSION EQUAL 4)
SET(BUILD_QT_PLUGINS 1)
FIND_PACKAGE(Qt4 4.6.2 REQUIRED)
IF(QT_QMAKE_CHANGED)
SET(QT_HELPGENERATOR_EXECUTABLE NOTFOUND)
SET(QT_COLLECTIONGENERATOR_EXECUTABLE NOTFOUND)
SET(QT_ASSISTANT_EXECUTABLE NOTFOUND)
ENDIF()
FIND_PROGRAM(QT_HELPGENERATOR_EXECUTABLE
NAMES qhelpgenerator qhelpgenerator-qt4 qhelpgenerator4
PATHS ${QT_BINARY_DIR}
NO_DEFAULT_PATH
)
FIND_PROGRAM(QT_COLLECTIONGENERATOR_EXECUTABLE
NAMES qcollectiongenerator qcollectiongenerator-qt4 qcollectiongenerator4
PATHS ${QT_BINARY_DIR}
NO_DEFAULT_PATH
)
FIND_PROGRAM(QT_ASSISTANT_EXECUTABLE
NAMES assistant-qt4 assistant4 assistant
PATHS ${QT_BINARY_DIR}
NO_DEFAULT_PATH
)
OPTION(BLUEBERRY_USE_QT_HELP "Enable support for integrating bundle documentation into Qt Help" ON)
MARK_AS_ADVANCED(BLUEBERRY_USE_QT_HELP
QT_HELPGENERATOR_EXECUTABLE
QT_COLLECTIONGENERATOR_EXECUTABLE
QT_ASSISTANT_EXECUTABLE)
SET(_doxygen_too_old 1)
IF(BLUEBERRY_USE_QT_HELP)
FIND_PACKAGE(Doxygen)
IF(DOXYGEN_FOUND)
EXECUTE_PROCESS(COMMAND ${DOXYGEN_EXECUTABLE} --version
OUTPUT_VARIABLE _doxygen_version)
IF(${_doxygen_version} VERSION_GREATER 1.6.0 OR
${_doxygen_version} VERSION_EQUAL 1.6.0)
SET(_doxygen_too_old 0)
ENDIF()
ENDIF()
ELSE(BLUEBERRY_USE_QT_HELP)
CONFIGURE_FILE(../Documentation/pregenerated/MITKBlankPage.qch
${MITK_BINARY_DIR}/bin/ExtBundles/org.mitk.gui.qt.extapplication/resources/MITKBlankPage.qch
COPYONLY)
CONFIGURE_FILE(../Documentation/pregenerated/MitkExtQtHelpCollection.qhc
${MITK_BINARY_DIR}/bin/ExtBundles/org.mitk.gui.qt.extapplication/resources/MitkExtQtHelpCollection.qhc
COPYONLY)
ENDIF(BLUEBERRY_USE_QT_HELP)
IF (BLUEBERRY_USE_QT_HELP AND _doxygen_too_old)
MESSAGE("Doxygen was not found or is too old. Version 1.6.0 or later is needed if BLUEBERRY_USE_QT_HELP is ON")
SET(BLUEBERRY_USE_QT_HELP OFF CACHE BOOL "Enable support for integrating bundle documentation into Qt Help" FORCE)
ENDIF()
IF(BLUEBERRY_USE_QT_HELP AND NOT QT_HELPGENERATOR_EXECUTABLE)
MESSAGE("You have enabled Qt Help support, but QT_HELPGENERATOR_EXECUTABLE is empty")
SET(BLUEBERRY_USE_QT_HELP OFF CACHE BOOL "Enable support for integrating bundle documentation into Qt Help" FORCE)
ENDIF()
INCLUDE(${QT_USE_FILE})
ELSE()
FIND_PACKAGE(Qt4 4.6.2 COMPONENTS QtCore REQUIRED)
INCLUDE(${QT_USE_FILE})
ENDIF()
# ========= CTK specific CMake stuff ============
CMAKE_POLICY(SET CMP0012 NEW)
FIND_PACKAGE(CTK REQUIRED)
# Extract all library names starting with org_blueberry_
MACRO(GetMyTargetLibraries all_target_libraries varname)
SET(re_ctkplugin "^org_blueberry_[a-zA-Z0-9_]+$")
SET(_tmp_list)
LIST(APPEND _tmp_list ${all_target_libraries})
ctkMacroListFilter(_tmp_list re_ctkplugin OUTPUT_VARIABLE ${varname})
ENDMACRO()
# ================================================
OPTION(BLUEBERRY_BUILD_ALL_PLUGINS "Build all BlueBerry plugins (overriding selection)" OFF)
MARK_AS_ADVANCED(BLUEBERRY_BUILD_ALL_PLUGINS)
IF(BLUEBERRY_BUILD_ALL_PLUGINS)
SET(BLUEBERRY_BUILD_ALL_PLUGINS_OPTION "FORCE_BUILD_ALL")
ENDIF()
OPTION(BLUEBERRY_STATIC "Build all plugins as static libraries" OFF)
MARK_AS_ADVANCED(BLUEBERRY_STATIC)
OPTION(BLUEBERRY_DEBUG_SMARTPOINTER "Enable code for debugging smart pointers" OFF)
MARK_AS_ADVANCED(BLUEBERRY_DEBUG_SMARTPOINTER)
FIND_PACKAGE(Poco REQUIRED)
FIND_PACKAGE(Ant)
FIND_PACKAGE(Eclipse)
SET(BLUEBERRY_SOURCE_DIR ${BlueBerry_SOURCE_DIR})
SET(BLUEBERRY_BINARY_DIR ${BlueBerry_BINARY_DIR})
SET(BLUEBERRY_PLUGINS_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Bundles)
SET(BLUEBERRY_PLUGINS_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/Bundles)
SET(OSGI_APP solstice)
SET(OSGI_UI_APP solstice_ui)
# Force should be removed after everybody has configured their old binary tree
SET(BLUEBERRY_PLUGINS_OUTPUT_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/BlueBerry CACHE PATH "Directory where to build the BlueBerry Bundles" FORCE)
MARK_AS_ADVANCED(BLUEBERRY_PLUGINS_OUTPUT_DIR)
# Clear the cache variables
SET(BLUEBERRY_PLUGIN_SOURCE_DIRS "" CACHE INTERNAL "List of base plugin source directories" FORCE)
SET(BLUEBERRY_PLUGIN_BINARY_DIRS "" CACHE INTERNAL "List of base plugin binary directories" FORCE)
IF (Eclipse_DIR)
SET(BLUEBERRY_DOC_TOOLS_DIR "${Eclipse_DIR}" CACHE PATH "Directory containing additional tools needed for generating the documentation")
ELSE ()
SET(BLUEBERRY_DOC_TOOLS_DIR "" CACHE PATH "Directory containing additional tools needed for generating the documentation")
ENDIF ()
SET(BLUEBERRY_DEBUG_POSTFIX d)
# Testing options
OPTION(BLUEBERRY_BUILD_TESTING "Build the BlueBerry tests." ${BUILD_TESTING})
IF(WIN32)
SET(_gui_testing_default "ON")
ELSE()
SET(_gui_testing_default "OFF")
ENDIF()
OPTION(BLUEBERRY_ENABLE_GUI_TESTING "Enable the BlueBerry GUI tests" ${_gui_testing_default})
MARK_AS_ADVANCED(BLUEBERRY_ENABLE_GUI_TESTING)
IF(BLUEBERRY_BUILD_TESTING)
ENABLE_TESTING()
ENDIF()
# Add CTK plugins
SET(_ctk_plugins
Bundles/org.blueberry.osgi:ON
Bundles/org.blueberry.compat:OFF
Bundles/org.blueberry.core.runtime:OFF
Bundles/org.blueberry.core.expressions:OFF
Bundles/org.blueberry.solstice.common:OFF
Bundles/org.blueberry.core.commands:OFF
Bundles/org.blueberry.core.jobs:OFF
Bundles/org.blueberry.ui:OFF
Bundles/org.blueberry.ui.qt:OFF
+ Bundles/org.blueberry.ui.qt.help:OFF
Bundles/org.blueberry.ui.qt.log:OFF
Bundles/org.blueberry.ui.qt.objectinspector:OFF
)
SET(_ctk_test_plugins )
SET(_ctk_plugins_include_dirs
${Poco_INCLUDE_DIRS}
)
SET(_ctk_plugins_link_dirs
${Poco_LIBRARY_DIR}
)
INCLUDE_DIRECTORIES(${_ctk_plugins_include_dirs})
LINK_DIRECTORIES(${_ctk_plugins_link_dirs})
IF(BLUEBERRY_BUILD_TESTING)
INCLUDE(berryTestingHelpers)
SET(BLUEBERRY_TEST_APP "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${OSGI_APP}")
GET_TARGET_PROPERTY(_is_macosx_bundle ${OSGI_APP} MACOSX_BUNDLE)
IF(APPLE AND _is_macosx_bundle)
SET(BLUEBERRY_TEST_APP "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${OSGI_APP}.app/Contents/MacOS/${OSGI_APP}")
ENDIF()
SET(_ctk_testinfrastructure_plugins
Bundles/org.blueberry.test:ON
Bundles/org.blueberry.uitest:ON
)
SET(_ctk_test_plugins
# Testing/org.blueberry.core.runtime.tests:ON
# Testing/org.blueberry.osgi.tests:ON
)
IF(BLUEBERRY_ENABLE_GUI_TESTING)
# LIST(APPEND _ctk_test_plugins Testing/org.blueberry.ui.tests:ON)
SET(BLUEBERRY_UI_TEST_APP "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${OSGI_UI_APP}")
GET_TARGET_PROPERTY(_is_macosx_bundle ${OSGI_UI_APP} MACOSX_BUNDLE)
IF(APPLE AND _is_macosx_bundle)
SET(BLUEBERRY_UI_TEST_APP "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${OSGI_UI_APP}.app/Contents/MacOS/${OSGI_UI_APP}")
ENDIF()
ENDIF()
ENDIF()
SET(BLUEBERRY_TESTING_PROVISIONING_FILE "${BlueBerry_BINARY_DIR}/BlueBerryTesting.provisioning")
ADD_CUSTOM_TARGET(BlueBerry)
ctkMacroSetupPlugins(${_ctk_plugins} ${_ctk_testinfrastructure_plugins} ${_ctk_test_plugins}
BUILD_OPTION_PREFIX BLUEBERRY_BUILD_
BUILD_ALL ${BLUEBERRY_BUILD_ALL_PLUGINS}
COMPACT_OPTIONS)
SET(BLUEBERRY_PROVISIONING_FILE "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/BlueBerry.provisioning")
FunctionCreateProvisioningFile(
FILE ${BLUEBERRY_PROVISIONING_FILE}
PLUGINS ${_ctk_plugins}
)
FunctionCreateProvisioningFile(
FILE ${BLUEBERRY_TESTING_PROVISIONING_FILE}
INCLUDE ${BLUEBERRY_PROVISIONING_FILE}
PLUGINS ${_ctk_testinfrastructure_plugins} ${_ctk_test_plugins}
)
if(${CMAKE_PROJECT_NAME}_PLUGIN_LIBRARIES)
add_dependencies(BlueBerry ${${CMAKE_PROJECT_NAME}_PLUGIN_LIBRARIES})
endif()
set_property(TARGET ${${CMAKE_PROJECT_NAME}_PLUGIN_LIBRARIES} PROPERTY LABELS BlueBerry)
SET(BB_PLUGIN_USE_FILE "${BlueBerry_BINARY_DIR}/BlueBerryPluginUseFile.cmake")
IF(${PROJECT_NAME}_PLUGIN_LIBRARIES)
ctkFunctionGeneratePluginUseFile(${BB_PLUGIN_USE_FILE})
ELSE()
FILE(REMOVE ${BB_PLUGIN_USE_FILE})
SET(BB_PLUGIN_USE_FILE )
ENDIF()
# CTK Plugin Exports
SET(BB_PLUGIN_EXPORTS_FILE "${CMAKE_CURRENT_BINARY_DIR}/BlueBerryPluginExports.cmake")
GetMyTargetLibraries("${${PROJECT_NAME}_PLUGIN_LIBRARIES}" my_plugin_targets)
SET(additional_export_targets mbilog PocoFoundation PocoUtil PocoXML)
IF(BLUEBERRY_BUILD_TESTING)
LIST(APPEND additional_export_targets CppUnit)
ENDIF()
export(TARGETS ${my_plugin_targets} ${additional_export_targets}
FILE ${BB_PLUGIN_EXPORTS_FILE})
ADD_SUBDIRECTORY(Documentation)
CONFIGURE_FILE(BlueBerryConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/BlueBerryConfig.cmake @ONLY)
diff --git a/BlueBerry/Documentation/snippets/org.blueberry.ui.qt.help-config/main.cpp b/BlueBerry/Documentation/snippets/org.blueberry.ui.qt.help-config/main.cpp
new file mode 100644
index 0000000000..044238921f
--- /dev/null
+++ b/BlueBerry/Documentation/snippets/org.blueberry.ui.qt.help-config/main.cpp
@@ -0,0 +1,115 @@
+
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+class MyApplicationPlugin : public QObject, public ctkPluginActivator
+{
+ Q_OBJECT
+ Q_INTERFACES(ctkPluginActivator)
+
+public:
+
+ MyApplicationPlugin();
+ ~MyApplicationPlugin();
+
+ //! [0]
+ void start(ctkPluginContext* context)
+ {
+ // Get a service reference for the Config Admin service
+ ctkServiceReference cmRef = context->getServiceReference();
+ ctkConfigurationAdmin* configAdmin = 0;
+ if (cmRef)
+ {
+ configAdmin = context->getService(cmRef);
+ }
+
+ // Use the CTK Configuration Admin service to configure the BlueBerry help system.
+ // This assumes that the plug-in providing the Config Admin implementation is
+ // already active.
+ if (configAdmin)
+ {
+ // Get a ctkConfiguration object for the PID "org.blueberry.services.help"
+ // (or create an unbound instance if it does not exist yet).
+ ctkConfigurationPtr conf = configAdmin->getConfiguration("org.blueberry.services.help", QString());
+
+ // Configure the help system using a custom home page
+ ctkDictionary helpProps;
+ helpProps.insert("homePage", "qthelp://org.company.plugin/bundle/index.html");
+ conf->update(helpProps);
+
+ // Unget the service
+ context->ungetService(cmRef);
+ }
+ else
+ {
+ // Warn that the Config Admin service is unavailable
+ }
+ }
+ //! [0]
+
+ void stop(ctkPluginContext *context);
+
+ //! [1]
+ void requestHelp(ctkPluginContext* context)
+ {
+ if (context == 0)
+ {
+ // Warn that the plugin context is zero
+ return;
+ }
+
+ // Check if the org.blueberry.ui.qt.help plug-in is installed and started
+ QList > plugins = context->getPlugins();
+ foreach(QSharedPointer p, plugins)
+ {
+ if (p->getSymbolicName() == "org.blueberry.ui.qt.help" &&
+ p->getState() != ctkPlugin::ACTIVE)
+ {
+ // The plug-in is in RESOLVED state but is not started yet.
+ // Try to activate the plug-in explicitly, so that it can react
+ // to events send via the CTK Event Admin.
+ try
+ {
+ p->start(ctkPlugin::START_TRANSIENT);
+ }
+ catch (const ctkPluginException& pe)
+ {
+ // Warn that activating the org.blueberry.ui.qt.help plug-in failed
+ return;
+ }
+ }
+ }
+
+ ctkServiceReference eventAdminRef = context->getServiceReference();
+ ctkEventAdmin* eventAdmin = 0;
+ if (eventAdminRef)
+ {
+ eventAdmin = context->getService(eventAdminRef);
+ }
+
+ if (eventAdmin == 0)
+ {
+ // Warn that the ctkEventAdmin service was not found
+ }
+ else
+ {
+ // Create the event and send it asynchronuously
+ ctkEvent ev("org/blueberry/ui/help/CONTEXTHELP_REQUESTED");
+ eventAdmin->postEvent(ev);
+ }
+ }
+ //! [1]
+
+private:
+
+};
+
+int main(int argc, char* argv[])
+{
+ return 0;
+}
diff --git a/CMakeExternals/CTK.cmake b/CMakeExternals/CTK.cmake
index 76234df9cf..afb4863bcf 100644
--- a/CMakeExternals/CTK.cmake
+++ b/CMakeExternals/CTK.cmake
@@ -1,63 +1,64 @@
#-----------------------------------------------------------------------------
# CTK
#-----------------------------------------------------------------------------
IF(MITK_USE_CTK)
# Sanity checks
IF(DEFINED CTK_DIR AND NOT EXISTS ${CTK_DIR})
MESSAGE(FATAL_ERROR "CTK_DIR variable is defined but corresponds to non-existing directory")
ENDIF()
SET(proj CTK)
SET(proj_DEPENDENCIES )
SET(CTK_DEPENDS ${proj})
IF(NOT DEFINED CTK_DIR)
- SET(revision_tag 6f26c34)
+ SET(revision_tag 34a638b)
IF(${proj}_REVISION_TAG)
SET(revision_tag ${${proj}_REVISION_TAG})
ENDIF()
SET(ctk_optional_cache_args )
IF(MITK_USE_Python)
LIST(APPEND ctk_optional_cache_args
-DCTK_LIB_Scripting/Python/Widgets:BOOL=ON
)
ENDIF()
FOREACH(type RUNTIME ARCHIVE LIBRARY)
IF(DEFINED CTK_PLUGIN_${type}_OUTPUT_DIRECTORY)
LIST(APPEND mitk_optional_cache_args -DCTK_PLUGIN_${type}_OUTPUT_DIRECTORY:PATH=${CTK_PLUGIN_${type}_OUTPUT_DIRECTORY})
ENDIF()
ENDFOREACH()
ExternalProject_Add(${proj}
GIT_REPOSITORY http://github.com/commontk/CTK.git
GIT_TAG ${revision_tag}
BINARY_DIR ${proj}-build
UPDATE_COMMAND ""
INSTALL_COMMAND ""
CMAKE_GENERATOR ${gen}
CMAKE_ARGS
${ep_common_args}
${ctk_optional_cache_args}
-DDESIRED_QT_VERSION:STRING=4
-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}
-DGit_EXECUTABLE:FILEPATH=${GIT_EXECUTABLE}
-DGIT_EXECUTABLE:FILEPATH=${GIT_EXECUTABLE}
-DCTK_LIB_PluginFramework:BOOL=ON
-DCTK_LIB_DICOM/Widgets:BOOL=ON
-DCTK_PLUGIN_org.commontk.eventadmin:BOOL=ON
+ -DCTK_PLUGIN_org.commontk.configadmin:BOOL=ON
-DCTK_USE_GIT_PROTOCOL:BOOL=OFF
DEPENDS ${proj_DEPENDENCIES}
)
SET(CTK_DIR ${CMAKE_CURRENT_BINARY_DIR}/${proj}-build)
ELSE()
mitkMacroEmptyExternalProject(${proj} "${proj_DEPENDENCIES}")
ENDIF()
ENDIF()