diff --git a/Plugins/org.mitk.gui.qt.viewbrowser/files.cmake b/Plugins/org.mitk.gui.qt.viewbrowser/files.cmake index 970d65e561..43e5215452 100644 --- a/Plugins/org.mitk.gui.qt.viewbrowser/files.cmake +++ b/Plugins/org.mitk.gui.qt.viewbrowser/files.cmake @@ -1,46 +1,49 @@ set(SRC_CPP_FILES - ) set(INTERNAL_CPP_FILES org_mitk_gui_qt_viewbrowser_Activator.cpp ViewBrowserView.cpp QmitkNewPerspectiveDialog.cpp + + ViewTagsRegistry.cpp + ViewTagsDescriptor.cpp + ExtensionPointDefinitionConstants.cpp ) set(UI_FILES src/internal/ViewBrowserViewControls.ui ) set(MOC_H_FILES src/internal/org_mitk_gui_qt_viewbrowser_Activator.h src/internal/ViewBrowserView.h src/internal/mitkQtPerspectiveItem.h src/internal/mitkQtViewItem.h src/internal/QmitkNewPerspectiveDialog.h ) # list of resource files which can be used by the plug-in # system without loading the plug-ins shared library, # for example the icon used in the menu and tabs for the # plug-in views in the workbench set(CACHED_RESOURCE_FILES resources/icon.xpm plugin.xml ) # list of Qt .qrc files which contain additional resources # specific to this plugin set(QRC_FILES ) set(CPP_FILES ) foreach(file ${SRC_CPP_FILES}) set(CPP_FILES ${CPP_FILES} src/${file}) endforeach(file ${SRC_CPP_FILES}) foreach(file ${INTERNAL_CPP_FILES}) set(CPP_FILES ${CPP_FILES} src/internal/${file}) endforeach(file ${INTERNAL_CPP_FILES}) diff --git a/Plugins/org.mitk.gui.qt.viewbrowser/plugin.xml b/Plugins/org.mitk.gui.qt.viewbrowser/plugin.xml index 64158fd637..003ee7c99f 100644 --- a/Plugins/org.mitk.gui.qt.viewbrowser/plugin.xml +++ b/Plugins/org.mitk.gui.qt.viewbrowser/plugin.xml @@ -1,11 +1,19 @@ - + + + + + Tag A + Tag B + Tag V + + diff --git a/Plugins/org.mitk.gui.qt.viewbrowser/schema/taglist.exsd b/Plugins/org.mitk.gui.qt.viewbrowser/schema/taglist.exsd new file mode 100644 index 0000000000..5816f273f1 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.viewbrowser/schema/taglist.exsd @@ -0,0 +1,91 @@ + + + + + + + + This extension point is used as an example for the extension point declaration (BlueBerry examples). + + + + + + + + + + + + a fully qualified identifier of the target extension point + + + + + + + an optional identifier of the extension instance + + + + + + + an optional name of the extension instance + + + + + + + + + + + + + + + + + + the identifier of the text changer + + + + + + + + + + + + + An optional subelement whose body should contain text providing a short description. + + + + + + + + + + The value of the <samp>class</samp> attribute must be a +fully qualified name of the class that implements +<samp>Inewchangetext</samp>. + + + + + + + + + Copyright (c) 2012 Medical and Biological Informatics, DKFZ<br> +All rights reserved. + + + + diff --git a/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/mitkQtViewItem.h b/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/ExtensionPointDefinitionConstants.cpp similarity index 55% copy from Plugins/org.mitk.gui.qt.viewbrowser/src/internal/mitkQtViewItem.h copy to Plugins/org.mitk.gui.qt.viewbrowser/src/internal/ExtensionPointDefinitionConstants.cpp index c0a5c5ab8a..c92dba6e4e 100644 --- a/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/mitkQtViewItem.h +++ b/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/ExtensionPointDefinitionConstants.cpp @@ -1,47 +1,23 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ -#ifndef _ViewItem -#define _ViewItem +#include "ExtensionPointDefinitionConstants.h" -#include -#include +#include "ViewTagsRegistry.h" -namespace mitk -{ - -class QtViewItem : public QStandardItem -{ -public: - QtViewItem(QString string) : - QStandardItem(string) - { - } - QtViewItem(const QIcon& icon, QString string) : - QStandardItem(icon, string) - { - } - - berry::IViewDescriptor::Pointer m_View; - -private: - - -}; - -} - -#endif +const std::string ExtensionPointDefinitionConstants::VIEWTAGS_XP_NAME = "org.mitk.views.viewbrowser.textlists"; +const std::string ExtensionPointDefinitionConstants::VIEWTAGS_CHILD_TAG = "tag"; +const std::string ExtensionPointDefinitionConstants::VIEWTAGS_XMLATTRIBUTE_ID = "id"; \ No newline at end of file diff --git a/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/ExtensionPointDefinitionConstants.h b/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/ExtensionPointDefinitionConstants.h new file mode 100644 index 0000000000..f03a0794cd --- /dev/null +++ b/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/ExtensionPointDefinitionConstants.h @@ -0,0 +1,40 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +#ifndef EXTENSIONPOINTDEFINITIONCONSTANTS_H_ +#define EXTENSIONPOINTDEFINITIONCONSTANTS_H_ + +#include + +/** + * The ExtensionPointDefinitionConstants contains a list of unique ids in the + * following form:
+ * "org.mitk.mybundle.mytype.propername"
+ * + * This ids have the purpose of connecting the plugin.xml of each bundle to the + * appropriate classes. + * + * Additionally it includes names of tags, which are used in XML files
+ * regarding the BlueBerry example. + */ +struct ExtensionPointDefinitionConstants +{ + static const std::string VIEWTAGS_XP_NAME; + static const std::string VIEWTAGS_CHILD_TAG; + static const std::string VIEWTAGS_XMLATTRIBUTE_ID; +}; + +#endif /*EXTENSIONPOINTDEFINITIONCONSTANTS_H_*/ diff --git a/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/ViewBrowserView.cpp b/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/ViewBrowserView.cpp index c0eb1cf2ae..46388facfa 100644 --- a/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/ViewBrowserView.cpp +++ b/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/ViewBrowserView.cpp @@ -1,430 +1,448 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ // Blueberry #include #include #include #include #include // Qmitk #include "ViewBrowserView.h" #include #include #include // Qt #include #include #include #include class ClassFilterProxyModel : public QSortFilterProxyModel { private : bool hasToBeDisplayed(const QModelIndex index) const; bool displayElement(const QModelIndex index) const; public: ClassFilterProxyModel(QObject *parent = NULL); bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; }; ClassFilterProxyModel::ClassFilterProxyModel(QObject *parent): QSortFilterProxyModel(parent) { } bool ClassFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const { QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent); return hasToBeDisplayed(index); } bool ClassFilterProxyModel::displayElement(const QModelIndex index) const { - bool result; + bool result = false; QString type = sourceModel()->data(index, Qt::DisplayRole).toString(); - if ( ! type.contains(filterRegExp())) + QStandardItem * item = dynamic_cast(sourceModel())->itemFromIndex(index); + + if (type.contains(filterRegExp())) { - result = false; + return true; } - else + mitk::QtViewItem* viewItem = dynamic_cast(item); + if (viewItem) { - result = true; + for (int i = 0; i < viewItem->m_Tags.size(); ++i) + { + if (viewItem->m_Tags[i].contains(filterRegExp())) + { + return true; + } + } } + return result; } bool ClassFilterProxyModel::hasToBeDisplayed(const QModelIndex index) const { bool result = false; // How many child this element have if ( sourceModel()->rowCount(index) > 0 ) { for( int ii = 0; ii < sourceModel()->rowCount(index); ii++) { QModelIndex childIndex = sourceModel()->index(ii,0,index); if ( ! childIndex.isValid() ) break; result = hasToBeDisplayed(childIndex); result |= displayElement(index); if (result) { // there is atless one element to display break; } } } else { result = displayElement(index); } return result; } const std::string ViewBrowserView::VIEW_ID = "org.mitk.views.viewbrowser"; bool compareViews(berry::IViewDescriptor::Pointer a, berry::IViewDescriptor::Pointer b) { if (a.IsNull() || b.IsNull()) return false; return a->GetLabel().compare(b->GetLabel()) < 0; } void ViewBrowserView::SetFocus() { } void ViewBrowserView::CreateQtPartControl( QWidget *parent ) { // create GUI widgets from the Qt Designer's .ui file m_Parent = parent; m_Controls.setupUi( parent ); connect( m_Controls.m_PluginTreeView, SIGNAL(customContextMenuRequested(QPoint)), SLOT(CustomMenuRequested(QPoint))); connect( m_Controls.m_PluginTreeView, SIGNAL(doubleClicked(const QModelIndex&)), SLOT(ItemClicked(const QModelIndex&))); connect( m_Controls.pushButton, SIGNAL(clicked()), SLOT(ButtonClicked()) ); connect( m_Controls.lineEdit, SIGNAL(textChanged(QString)), SLOT(FilterChanged())); m_ContextMenu = new QMenu(m_Controls.m_PluginTreeView); m_Controls.m_PluginTreeView->setContextMenuPolicy(Qt::CustomContextMenu); // Create a new TreeModel for the data m_TreeModel = new QStandardItemModel(); m_FilterProxyModel = new ClassFilterProxyModel(this); m_FilterProxyModel->setSourceModel(m_TreeModel); //proxyModel->setFilterFixedString("Diff"); m_Controls.m_PluginTreeView->setModel(m_FilterProxyModel); FillTreeList(); + + QList additions = m_Registry.GetViewTags(); + foreach (const ViewTagsDescriptor::Pointer& var, additions) + { + MITK_INFO << var->GetID().toStdString(); + } } void ViewBrowserView::ButtonClicked() { FillTreeList(); } void ViewBrowserView::FillTreeList() { m_TreeModel->clear(); QStandardItem *treeRootItem = m_TreeModel->invisibleRootItem(); // Get all available views and create a map of all views std::map viewMap; berry::IViewRegistry* viewRegistry = berry::PlatformUI::GetWorkbench()->GetViewRegistry(); std::vector views(viewRegistry->GetViews()); for (unsigned int i=0; iGetId()] = views[i]; } std::sort(views.begin(), views.end(), compareViews); // Get all available perspectives berry::IPerspectiveRegistry* perspRegistry = berry::PlatformUI::GetWorkbench()->GetPerspectiveRegistry(); std::vector perspectives(perspRegistry->GetPerspectives()); // workbench window available? if (berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow().IsNull()) return; // Fill the TreeModel berry::IWorkbenchPage::Pointer page = berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage(); if (page.IsNull()) { return; } QModelIndex currentIndex; berry::IPerspectiveDescriptor::Pointer currentPersp = page->GetPerspective(); std::vector perspectiveExcludeList = berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetPerspectiveExcludeList(); std::vector viewExcludeList = berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetViewExcludeList(); QStandardItem *perspectiveRootItem = new QStandardItem("Perspectives"); treeRootItem->appendRow(perspectiveRootItem); for (unsigned int i=0; iGetId()) { skipPerspective = true; break; } if (skipPerspective) continue; QList< QStandardItem*> preparedRow; QIcon* pIcon = static_cast(p->GetImageDescriptor()->CreateImage()); mitk::QtPerspectiveItem* pItem = new mitk::QtPerspectiveItem(*pIcon, QString::fromStdString(p->GetLabel())); pItem->m_Perspective = p; preparedRow << pItem; perspectiveRootItem->appendRow(preparedRow); if (currentPersp->GetId()==p->GetId()) currentIndex = pItem->index(); } // Add a list with all available views QList< QStandardItem*> preparedRow; QStandardItem* pItem = new QStandardItem(QIcon(),"Views"); preparedRow << pItem; treeRootItem->appendRow(preparedRow); for (unsigned int i = 0; i < views.size(); ++i) { + ViewTagsDescriptor::Pointer tags = m_Registry.Find(views[i]->GetId()); QList secondRow; QIcon* icon = static_cast(views[i]->GetImageDescriptor()->CreateImage()); mitk::QtViewItem* vItem = new mitk::QtViewItem(*icon, QString::fromStdString(views[i]->GetLabel())); vItem->m_View = views[i]; + vItem->m_Tags = tags->GetTags(); secondRow << vItem; preparedRow.first()->appendRow(secondRow); } QModelIndex correctedIndex = m_FilterProxyModel->mapFromSource(currentIndex); m_Controls.m_PluginTreeView->setCurrentIndex(correctedIndex); } void ViewBrowserView::OnSelectionChanged( berry::IWorkbenchPart::Pointer /*source*/, const QList& nodes ) { } void ViewBrowserView::FilterChanged() { QString filterString = m_Controls.lineEdit->text(); if (filterString.size() > 0 ) { m_Controls.m_PluginTreeView->expandAll(); } QRegExp::PatternSyntax syntax = QRegExp::RegExp; Qt::CaseSensitivity caseSensitivity = Qt::CaseInsensitive; QString strPattern = "^*" + filterString; QRegExp regExp(strPattern, caseSensitivity); m_FilterProxyModel->setFilterRegExp(regExp); } void ViewBrowserView::ItemClicked(const QModelIndex &index) { QStandardItem* item = m_TreeModel->itemFromIndex(m_FilterProxyModel->mapToSource(index)); if ( dynamic_cast< mitk::QtPerspectiveItem* >(item) ) { try { mitk::QtPerspectiveItem* pItem = dynamic_cast< mitk::QtPerspectiveItem* >(item); berry::PlatformUI::GetWorkbench()->ShowPerspective( pItem->m_Perspective->GetId(), berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow() ); } catch (...) { QMessageBox::critical(0, "Opening Perspective Failed", QString("The requested perspective could not be opened.\nSee the log for details.")); } } else if ( dynamic_cast< mitk::QtViewItem* >(item) ) { berry::IWorkbenchPage::Pointer page = berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage(); if (page.IsNotNull()) { try { mitk::QtViewItem* vItem = dynamic_cast< mitk::QtViewItem* >(item); page->ShowView(vItem->m_View->GetId()); } catch (berry::PartInitException e) { BERRY_ERROR << "Error: " << e.displayText() << std::endl; } } } } void ViewBrowserView::AddPerspective() { QmitkNewPerspectiveDialog* dialog = new QmitkNewPerspectiveDialog( m_Parent ); int dialogReturnValue = dialog->exec(); if ( dialogReturnValue == QDialog::Rejected ) return; berry::IPerspectiveRegistry* perspRegistry = berry::PlatformUI::GetWorkbench()->GetPerspectiveRegistry(); try { perspRegistry->CreatePerspective(dialog->GetPerspectiveName().toStdString(), perspRegistry->FindPerspectiveWithId(perspRegistry->GetDefaultPerspective())); } catch(...) { QMessageBox::warning(m_Parent, "Error", "Duplication of selected perspective failed. Please make sure the specified perspective name is not already in use!"); } FillTreeList(); } void ViewBrowserView::ClonePerspective() { if (m_RegisteredPerspective.IsNotNull()) { QmitkNewPerspectiveDialog* dialog = new QmitkNewPerspectiveDialog( m_Parent ); QString defaultName(m_RegisteredPerspective->GetLabel().c_str()); defaultName.append(" Copy"); dialog->SetPerspectiveName(defaultName); int dialogReturnValue = dialog->exec(); if ( dialogReturnValue == QDialog::Rejected ) return; berry::IPerspectiveRegistry* perspRegistry = berry::PlatformUI::GetWorkbench()->GetPerspectiveRegistry(); try { perspRegistry->ClonePerspective(dialog->GetPerspectiveName().toStdString(), dialog->GetPerspectiveName().toStdString(), m_RegisteredPerspective); } catch(...) { QMessageBox::warning(m_Parent, "Error", "Duplication of selected perspective failed. Please make sure the specified perspective name is not already in use!"); } FillTreeList(); } } void ViewBrowserView::ResetPerspective() { if (QMessageBox::Yes == QMessageBox(QMessageBox::Question, "Please confirm", "Do you really want to reset the curent perspective?", QMessageBox::Yes|QMessageBox::No).exec()) berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->ResetPerspective(); } void ViewBrowserView::DeletePerspective() { if (m_RegisteredPerspective.IsNotNull()) { QString question = "Do you really want to remove the perspective '"; question.append(m_RegisteredPerspective->GetLabel().c_str()); question.append("'?"); if (QMessageBox::Yes == QMessageBox(QMessageBox::Question, "Please confirm", question, QMessageBox::Yes|QMessageBox::No).exec()) { berry::IPerspectiveRegistry* perspRegistry = berry::PlatformUI::GetWorkbench()->GetPerspectiveRegistry(); perspRegistry->DeletePerspective(m_RegisteredPerspective); FillTreeList(); } } } void ViewBrowserView::ClosePerspective() { if (QMessageBox::Yes == QMessageBox(QMessageBox::Question, "Please confirm", "Do you really want to close the curent perspective?", QMessageBox::Yes|QMessageBox::No).exec()) { berry::IWorkbenchPage::Pointer page = berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage(); page->CloseCurrentPerspective(true, true); if ( page->GetPerspective().IsNull() ) { berry::IPerspectiveRegistry* perspRegistry = berry::PlatformUI::GetWorkbench()->GetPerspectiveRegistry(); berry::PlatformUI::GetWorkbench()->ShowPerspective( perspRegistry->GetDefaultPerspective(), berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow() ); } } } void ViewBrowserView::ClosePerspectives() { if (QMessageBox::Yes == QMessageBox(QMessageBox::Question, "Please confirm", "Do you really want to close all perspectives?", QMessageBox::Yes|QMessageBox::No).exec()) { berry::IWorkbenchPage::Pointer page = berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage(); page->CloseAllPerspectives(true, true); berry::IPerspectiveRegistry* perspRegistry = berry::PlatformUI::GetWorkbench()->GetPerspectiveRegistry(); berry::PlatformUI::GetWorkbench()->ShowPerspective( perspRegistry->GetDefaultPerspective(), berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow() ); } } void ViewBrowserView::CustomMenuRequested(QPoint pos) { QModelIndex index = m_Controls.m_PluginTreeView->indexAt(pos); QStandardItem* item = m_TreeModel->itemFromIndex(m_FilterProxyModel->mapToSource(index)); if (m_ContextMenu==NULL || item==NULL) return; m_ContextMenu->clear(); m_RegisteredPerspective = NULL; bool showMenu = false; if (item->text()=="Perspectives") { QAction* addAction = new QAction("Create new perspective", this); m_ContextMenu->addAction(addAction); connect(addAction, SIGNAL(triggered()), SLOT(AddPerspective())); m_ContextMenu->addSeparator(); QAction* resetAction = new QAction("Reset current perspective", this); m_ContextMenu->addAction(resetAction); connect(resetAction, SIGNAL(triggered()), SLOT(ResetPerspective())); QAction* closeAction = new QAction("Close current perspective", this); m_ContextMenu->addAction(closeAction); connect(closeAction, SIGNAL(triggered()), SLOT(ClosePerspective())); m_ContextMenu->addSeparator(); QAction* closeAllAction = new QAction("Close all perspectives", this); m_ContextMenu->addAction(closeAllAction); connect(closeAllAction, SIGNAL(triggered()), SLOT(ClosePerspectives())); showMenu = true; } if (dynamic_cast< mitk::QtPerspectiveItem* >(item) ) { m_RegisteredPerspective = dynamic_cast< mitk::QtPerspectiveItem* >(item)->m_Perspective; //m_ContextMenu->addSeparator(); QAction* cloneAction = new QAction("Duplicate perspective", this); m_ContextMenu->addAction(cloneAction); connect(cloneAction, SIGNAL(triggered()), SLOT(ClonePerspective())); if (!m_RegisteredPerspective->IsPredefined()) { QAction* deleteAction = new QAction("Remove perspective", this); m_ContextMenu->addAction(deleteAction); connect(deleteAction, SIGNAL(triggered()), SLOT(DeletePerspective())); } showMenu = true; } if (showMenu) m_ContextMenu->popup(m_Controls.m_PluginTreeView->viewport()->mapToGlobal(pos)); } \ No newline at end of file diff --git a/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/ViewBrowserView.h b/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/ViewBrowserView.h index 2f9320a8bf..e646e845f7 100644 --- a/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/ViewBrowserView.h +++ b/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/ViewBrowserView.h @@ -1,97 +1,101 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef ViewBrowserView_h #define ViewBrowserView_h #include #include #include #include #include #include #include "ui_ViewBrowserViewControls.h" #include #include #include #include #include +#include "ViewTagsRegistry.h" + /** \brief ViewBrowserView \warning This class is not yet documented. Use "git blame" and ask the author to provide basic documentation. \sa QmitkAbstractView \ingroup ${plugin_target}_internal */ class ClassFilterProxyModel; class ViewBrowserView : public QmitkAbstractView { // this is needed for all Qt objects that should have a Qt meta-object // (everything that derives from QObject and wants to have signal/slots) Q_OBJECT public: static const std::string VIEW_ID; /// \brief Fills the TreeList with the available perspectives and views. void FillTreeList(); protected slots: /// \brief Called when the user clicks the GUI button void CustomMenuRequested(QPoint pos); void ItemClicked(const QModelIndex &index); void AddPerspective(); void ClonePerspective(); void ResetPerspective(); void DeletePerspective(); void ClosePerspectives(); void ClosePerspective(); void ButtonClicked(); void FilterChanged(); protected: virtual void CreateQtPartControl(QWidget *parent); virtual void SetFocus(); /// \brief called by QmitkFunctionality when DataManager's selection has changed virtual void OnSelectionChanged( berry::IWorkbenchPart::Pointer source, const QList& nodes ); QWidget* m_Parent; Ui::ViewBrowserViewControls m_Controls; QStandardItemModel* m_TreeModel; ClassFilterProxyModel* m_FilterProxyModel; QMenu* m_ContextMenu; berry::IPerspectiveDescriptor::Pointer m_RegisteredPerspective; friend struct ViewBrowserViewListener; + + ViewTagsRegistry m_Registry; }; #endif // ViewBrowserView_h diff --git a/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/ViewTagsDescriptor.cpp b/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/ViewTagsDescriptor.cpp new file mode 100644 index 0000000000..e079be9b52 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/ViewTagsDescriptor.cpp @@ -0,0 +1,74 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +#include "ViewTagsDescriptor.h" +#include "ExtensionPointDefinitionConstants.h" + +#include "berryPlatformException.h" + +ViewTagsDescriptor::ViewTagsDescriptor(QString id) +{ + this->m_Id = id; + m_Tags.clear(); +} +ViewTagsDescriptor::ViewTagsDescriptor(berry::IConfigurationElement::Pointer changeTextExtensionPoint) + : m_ChangeTextExtensionPoint(changeTextExtensionPoint) +{ + std::string id; + std::string name; + + // Check if the "id" and "name" attributes are available + if (!this->m_ChangeTextExtensionPoint->GetAttribute(ExtensionPointDefinitionConstants::VIEWTAGS_XMLATTRIBUTE_ID, id)) + { + throw berry::CoreException("Invalid changetext configuration element (missing id) from: " + + m_ChangeTextExtensionPoint->GetContributor()); + } + + this->m_Id = QString::fromStdString(id); + + // Get the optional "description" child element + std::vector tags( + this->m_ChangeTextExtensionPoint->GetChildren(ExtensionPointDefinitionConstants::VIEWTAGS_CHILD_TAG)); + + for (int i = 0; i < tags.size(); ++i) + { + std::string tmpTag = tags[i]->GetValue(); + m_Tags.push_back(QString::fromStdString(tmpTag)); + } +} + +ViewTagsDescriptor::~ViewTagsDescriptor() +{ +} + +std::vector ViewTagsDescriptor::GetTags() +{ + return m_Tags; +} + +QString ViewTagsDescriptor::GetID() const +{ + return this->m_Id; +} + +bool ViewTagsDescriptor::operator==(const Object* object) const +{ + if (const ViewTagsDescriptor* other = dynamic_cast(object)) + { + return this->GetID() == other->GetID(); + } + return false; +} \ No newline at end of file diff --git a/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/ViewTagsDescriptor.h b/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/ViewTagsDescriptor.h new file mode 100644 index 0000000000..ced8786754 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/ViewTagsDescriptor.h @@ -0,0 +1,70 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +#ifndef VIEWTAGSDESCRIPTOR_H_ +#define VIEWTAGSDESCRIPTOR_H_ + +#include +#include + +class ViewTagsDescriptor : public berry::Object +{ +public: + + berryObjectMacro(ViewTagsDescriptor); + + /** + * Initialize the "ChangeText" Descriptor with the given extension point. + * + * @param changeTextExtensionPoint + * element, that refers to a extension point (type, id, name, class) + */ + ViewTagsDescriptor(berry::IConfigurationElement::Pointer changeTextExtensionPoint); + ViewTagsDescriptor(QString id); + + /** + * Default destructor + */ + ~ViewTagsDescriptor(); + + /** + * Returns the id of this "ChangeText". + * + * @return the id + */ + QString GetID() const; + + + std::vector GetTags(); + /** + * Equals this class with the given parameter. + * + * @param object + * the object for the equation + * @return true, if the objects are equal :: false, if they differ in any way + */ + bool operator==(const Object* object) const; + +private: + + // IConfigurationElements are used to access xml files (here: plugin.xml) + berry::IConfigurationElement::Pointer m_ChangeTextExtensionPoint; + + QString m_Id; + std::vector m_Tags; +}; + +#endif /*VIEWTAGSDESCRIPTOR_H_*/ diff --git a/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/ViewTagsRegistry.cpp b/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/ViewTagsRegistry.cpp new file mode 100644 index 0000000000..5ea40a1e5e --- /dev/null +++ b/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/ViewTagsRegistry.cpp @@ -0,0 +1,70 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +#include +#include +#include +#include "ViewTagsRegistry.h" +#include "ExtensionPointDefinitionConstants.h" + +ViewTagsRegistry::ViewTagsRegistry() +{ + //initialize the registry by copying all available extension points into a local variable + berry::IExtensionPointService::Pointer extensionPointService = berry::Platform::GetExtensionPointService(); + std::vector allExtensionsChangeTexts + = extensionPointService->GetConfigurationElementsFor(ExtensionPointDefinitionConstants::VIEWTAGS_XP_NAME); + + for(std::vector::const_iterator it = allExtensionsChangeTexts.begin(); + it != allExtensionsChangeTexts.end();++it) + { + ViewTagsDescriptor::Pointer temp(new ViewTagsDescriptor(*it)); + + if(!this->m_ListRegisteredViewTags.contains(temp->GetID())) + { + m_ListRegisteredViewTags.insert(temp->GetID(),temp); + } + else + { + BERRY_WARN << "The ChangeText ID: " << qPrintable(temp->GetID()) << " is already registered."; + } + } +} + +ViewTagsRegistry::~ViewTagsRegistry() +{ +} + +ViewTagsDescriptor::Pointer ViewTagsRegistry::Find(const std::string &id) const +{ + return this->Find(QString::fromStdString(id)); +} +ViewTagsDescriptor::Pointer ViewTagsRegistry::Find(const QString &id) const +{ + if (this->m_ListRegisteredViewTags.contains(id)) + { + return this->m_ListRegisteredViewTags.value(id); + } + else + { + ViewTagsDescriptor::Pointer tmp(new ViewTagsDescriptor(id)); + return tmp; + } +} + +QList ViewTagsRegistry::GetViewTags() const +{ + return m_ListRegisteredViewTags.values(); +} \ No newline at end of file diff --git a/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/ViewTagsRegistry.h b/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/ViewTagsRegistry.h new file mode 100644 index 0000000000..eadc2d6b72 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/ViewTagsRegistry.h @@ -0,0 +1,54 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +#ifndef VIEWTAGSREGISTRY_H +#define VIEWTAGSREGISTRY_H + +#include + +#include "ViewTagsDescriptor.h" + +class ViewTagsRegistry : public berry::Object +{ +public: + + ViewTagsRegistry(); + ~ViewTagsRegistry(); + + /** + * Return an "change text" descriptor with the given extension id. If no "change text" exists, + * with the id return null. + * + * @param id + * the id to search for + * @return the descriptor or null + */ + ViewTagsDescriptor::Pointer Find(const QString& id) const; + ViewTagsDescriptor::Pointer Find(const std::string& id) const; + + /** + * Return a list of "change texts" defined in the registry. + * + * @return the change texts. + */ + QList GetViewTags() const; + +private: + + QHash m_ListRegisteredViewTags; +}; + +#endif /*VIEWTAGSREGISTRY_H*/ diff --git a/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/mitkQtViewItem.h b/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/mitkQtViewItem.h index c0a5c5ab8a..7a363264d9 100644 --- a/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/mitkQtViewItem.h +++ b/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/mitkQtViewItem.h @@ -1,47 +1,48 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef _ViewItem #define _ViewItem #include +#include #include namespace mitk { class QtViewItem : public QStandardItem { public: QtViewItem(QString string) : QStandardItem(string) { } QtViewItem(const QIcon& icon, QString string) : QStandardItem(icon, string) { } berry::IViewDescriptor::Pointer m_View; + std::vector m_Tags; private: - }; } #endif