diff --git a/Plugins/org.mitk.gui.qt.viewbrowser/files.cmake b/Plugins/org.mitk.gui.qt.viewbrowser/files.cmake index bf01787e06..bedc1fb12f 100644 --- a/Plugins/org.mitk.gui.qt.viewbrowser/files.cmake +++ b/Plugins/org.mitk.gui.qt.viewbrowser/files.cmake @@ -1,42 +1,42 @@ set(SRC_CPP_FILES - PluginsTreeViewModel.cpp + ) 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 ) # 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 47e7f60a87..e3a566837a 100644 --- a/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/ViewBrowserView.cpp +++ b/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/ViewBrowserView.cpp @@ -1,138 +1,156 @@ /*=================================================================== 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" // Qt #include - #include - #include - #include +#include +#include -//mitk image -#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_Controls.m_PluginTreeView->setModel(&m_TreeModel); - //m_Controls.m_PluginTreeView->show(); -} - -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() && dynamic_cast(node->GetData()) ) - { - return; - } - } -} - - -void ViewBrowserView::DoSomething() -{ - m_TreeModel = new QStandardItemModel ; + m_TreeModel = new QStandardItemModel(); QStandardItem *item = m_TreeModel->invisibleRootItem(); berry::IPerspectiveRegistry* perspRegistry = berry::PlatformUI::GetWorkbench()->GetPerspectiveRegistry(); -// QActionGroup* perspGroup = new QActionGroup(menuBar); - 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())); item->appendRow(preparedRow); for (unsigned int i=0; i secondRow; secondRow << new QStandardItem(QString::fromStdString(w->GetLabel())); secondRow << new QStandardItem(QString::fromStdString(w->GetId())); 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)); + // 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); + // 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(); +} + +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) +// { + try + { + std::vector perspectives(berry::PlatformUI::GetWorkbench()->GetPerspectiveRegistry()->GetPerspectives()); + berry::PlatformUI::GetWorkbench()->ShowPerspective( perspectives.at(index.row())->GetId(), berry::PlatformUI::GetWorkbench()->GetWorkbenchWindows().at(0) ); + } + catch (...) + { + QMessageBox::critical(0, "Opening Perspective Failed", QString("The requested perspective could not be opened.\nSee the log for details.")); + } +// } +} + +void ViewBrowserView::CustomMenuRequested(QPoint pos) +{ + // m_ContextMenu->popup(m_Controls.m_PerspectiveTree->viewport()->mapToGlobal(pos)); +} - //QList secondRow =prepareRow("111", "222", "333"); - // adding a row to an item starts a subtree - //preparedRow.first()->appendRow(secondRow); +void ViewBrowserView::DoSomething() +{ - m_Controls.m_PluginTreeView->setModel(m_TreeModel); - m_Controls.m_PluginTreeView->expandAll(); -} \ 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 2d779f9444..a91073e818 100644 --- a/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/ViewBrowserView.h +++ b/Plugins/org.mitk.gui.qt.viewbrowser/src/internal/ViewBrowserView.h @@ -1,67 +1,68 @@ /*=================================================================== 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 "ui_ViewBrowserViewControls.h" - #include +#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