diff --git a/Plugins/org.mitk.gui.qt.viewbrowser/files.cmake b/Plugins/org.mitk.gui.qt.viewbrowser/files.cmake index bedc1fb12f..1cc24065b6 100644 --- a/Plugins/org.mitk.gui.qt.viewbrowser/files.cmake +++ b/Plugins/org.mitk.gui.qt.viewbrowser/files.cmake @@ -1,42 +1,44 @@ set(SRC_CPP_FILES ) set(INTERNAL_CPP_FILES org_mitk_gui_qt_viewbrowser_Activator.cpp ViewBrowserView.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 ) # 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/src/internal/ViewBrowserView.cpp b/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/ViewBrowserView.cpp index e3a566837a..0eeeaa260a 100644 --- a/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/ViewBrowserView.cpp +++ b/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/ViewBrowserView.cpp @@ -1,156 +1,172 @@ /*=================================================================== 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 // Qt #include #include #include const std::string ViewBrowserView::VIEW_ID = "org.mitk.views.viewbrowser"; void ViewBrowserView::SetFocus() { - m_Controls.buttonPerformImageProcessing->setFocus(); + } void ViewBrowserView::CreateQtPartControl( QWidget *parent ) { // create GUI widgets from the Qt Designer's .ui file m_Controls.setupUi( parent ); - connect( m_Controls.buttonPerformImageProcessing, SIGNAL(clicked()), this, SLOT(DoSomething()) ); connect( m_Controls.m_PluginTreeView, SIGNAL(customContextMenuRequested(QPoint)), SLOT(CustomMenuRequested(QPoint))); connect( m_Controls.m_PluginTreeView, SIGNAL(clicked(const QModelIndex&)), SLOT(ItemClicked(const QModelIndex&))); m_TreeModel = new QStandardItemModel(); QStandardItem *item = m_TreeModel->invisibleRootItem(); berry::IPerspectiveRegistry* perspRegistry = berry::PlatformUI::GetWorkbench()->GetPerspectiveRegistry(); std::vector perspectives(perspRegistry->GetPerspectives()); bool skip = false; berry::IViewRegistry* viewRegistry = berry::PlatformUI::GetWorkbench()->GetViewRegistry(); std::vector views(viewRegistry->GetViews()); MITK_INFO << "PERSPECTIVES"; for (unsigned int i=0; i preparedRow =prepareRow("first", "second", "third"); berry::IPerspectiveDescriptor::Pointer p = perspectives.at(i); - MITK_INFO << p->GetId(); - QList preparedRow; - preparedRow << new QStandardItem(QString::fromStdString(p->GetLabel())); - preparedRow << new QStandardItem(QString::fromStdString(p->GetId())); + QList< QStandardItem*> preparedRow; + mitk::QtPerspectiveItem* pItem = new mitk::QtPerspectiveItem(QString::fromStdString(p->GetLabel())); + pItem->m_Perspective = p; + preparedRow << pItem; item->appendRow(preparedRow); for (unsigned int i=0; i secondRow; - secondRow << new QStandardItem(QString::fromStdString(w->GetLabel())); - secondRow << new QStandardItem(QString::fromStdString(w->GetId())); + + mitk::QtViewItem* vItem = new mitk::QtViewItem(QString::fromStdString(v->GetLabel())); + vItem->m_View = v; + secondRow << vItem; preparedRow.first()->appendRow(secondRow); } // if perspectiveExcludeList is set, it contains the id-strings of perspectives, which // should not appear as an menu-entry in the perspective menu // if (perspectiveExcludeList.size() > 0) // { // for (unsigned int i=0; iGetId()) // { // skip = true; // break; // } // } // if (skip) // { // skip = false; // continue; // } // } // QAction* perspAction = new berry::QtOpenPerspectiveAction(window, // *perspIt, perspGroup); // mapPerspIdToAction.insert(std::make_pair((*perspIt)->GetId(), perspAction)); } - MITK_INFO << "VIEWS"; - //berry::QTOpenPers // adding a row to the invisible root item produces a root element //item->appendRow(preparedRow); //QList secondRow =prepareRow("111", "222", "333"); // adding a row to an item starts a subtree //preparedRow.first()->appendRow(secondRow); m_Controls.m_PluginTreeView->setModel(m_TreeModel); - m_Controls.m_PluginTreeView->expandAll(); +// m_Controls.m_PluginTreeView->expandAll(); } void ViewBrowserView::OnSelectionChanged( berry::IWorkbenchPart::Pointer /*source*/, const QList& nodes ) { // iterate all selected objects, adjust warning visibility foreach( mitk::DataNode::Pointer node, nodes ) { if( node.IsNotNull() ) { return; } } } void ViewBrowserView::ItemClicked(const QModelIndex &index) { - MITK_INFO << index.row() << "-" << index.column(); -// if (index.column()==0) -// { + QStandardItem* item = m_TreeModel->itemFromIndex(index); + if ( dynamic_cast< mitk::QtPerspectiveItem* >(item) ) + { try { - std::vector perspectives(berry::PlatformUI::GetWorkbench()->GetPerspectiveRegistry()->GetPerspectives()); - berry::PlatformUI::GetWorkbench()->ShowPerspective( perspectives.at(index.row())->GetId(), berry::PlatformUI::GetWorkbench()->GetWorkbenchWindows().at(0) ); +// berry::IWorkbenchPage::Pointer page = berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage(); +// page->CloseAllPerspectives(false, false); + mitk::QtPerspectiveItem* pItem = dynamic_cast< mitk::QtPerspectiveItem* >(item); +// page->ClosePerspective( pItem->m_Perspective, true, false ); + 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::CustomMenuRequested(QPoint pos) { // m_ContextMenu->popup(m_Controls.m_PerspectiveTree->viewport()->mapToGlobal(pos)); } - -void ViewBrowserView::DoSomething() -{ - -} 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 a91073e818..69ed283a58 100644 --- a/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/ViewBrowserView.h +++ b/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/ViewBrowserView.h @@ -1,68 +1,67 @@ /*=================================================================== 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 "ui_ViewBrowserViewControls.h" #include /** \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 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; protected slots: /// \brief Called when the user clicks the GUI button - void DoSomething(); void CustomMenuRequested(QPoint pos); void ItemClicked(const QModelIndex &index); 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 ); Ui::ViewBrowserViewControls m_Controls; QStandardItemModel* m_TreeModel; }; #endif // ViewBrowserView_h diff --git a/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/ViewBrowserViewControls.ui b/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/ViewBrowserViewControls.ui index 2f87993cfa..b563b0e280 100644 --- a/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/ViewBrowserViewControls.ui +++ b/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/ViewBrowserViewControls.ui @@ -1,57 +1,47 @@ ViewBrowserViewControls 0 0 752 974 0 0 QmitkTemplate - - - - Do image processing - - - Do Something - - - Qt::Vertical QSizePolicy::Expanding 20 220 diff --git a/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/mitkQtPerspectiveItem.h b/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/mitkQtPerspectiveItem.h new file mode 100644 index 0000000000..3f6ed38bb7 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/mitkQtPerspectiveItem.h @@ -0,0 +1,38 @@ +/*=================================================================== + +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 _PerspectiveItem +#define _PerspectiveItem + +#include +#include + +namespace mitk +{ + +class QtPerspectiveItem : public QStandardItem +{ +public: + using QStandardItem::QStandardItem; + berry::IPerspectiveDescriptor::Pointer m_Perspective; + +private: + +}; + +} + +#endif diff --git a/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/mitkQtViewItem.h b/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/mitkQtViewItem.h new file mode 100644 index 0000000000..1a342c7c9c --- /dev/null +++ b/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/mitkQtViewItem.h @@ -0,0 +1,39 @@ +/*=================================================================== + +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 + +namespace mitk +{ + +class QtViewItem : public QStandardItem +{ +public: + using QStandardItem::QStandardItem; + berry::IViewDescriptor::Pointer m_View; + +private: + + +}; + +} + +#endif