Medical Imaging Interaction Toolkit  2018.4.99-3e3f1a6e
Medical Imaging Interaction Toolkit
QmitkViewNavigatorWidget.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 //Qmitk headers
15 
16 // Blueberry
17 #include <berryISelectionService.h>
18 #include <berryIWorkbenchWindow.h>
20 #include <berryPlatformUI.h>
21 #include <berryPlatform.h>
22 #include <berryIWorkbenchPage.h>
24 #include <berryIHandlerService.h>
26 #include <berryUIElement.h>
27 
28 // MITK
29 #include <mitkLogMacros.h>
30 
31 // Qt
32 #include <QHash>
33 #include <QMessageBox>
34 #include <QTreeView>
35 #include <QStandardItem>
36 #include <QSortFilterProxyModel>
37 
38 class KeywordRegistry
39 {
40 public:
41  KeywordRegistry()
42  {
44  auto keywordExts = extensionPointService->GetConfigurationElementsFor("org.blueberry.ui.keywords");
45  for (auto keywordExtsIt = keywordExts.begin(); keywordExtsIt != keywordExts.end(); ++keywordExtsIt)
46  {
47  QString keywordId = (*keywordExtsIt)->GetAttribute("id");
48  QString keywordLabels = (*keywordExtsIt)->GetAttribute("label");
49  m_Keywords[keywordId].push_back(keywordLabels);
50  }
51  }
52 
53  QStringList GetKeywords(const QString& id)
54  {
55  return m_Keywords[id];
56  }
57 
58  QStringList GetKeywords(const QStringList& ids)
59  {
60  QStringList result;
61  for (int i = 0; i < ids.size(); ++i)
62  {
63  result.append(this->GetKeywords(ids[i]));
64  }
65  return result;
66  }
67 
68 private:
69  QHash<QString, QStringList> m_Keywords;
70 };
71 
72 
73 class ClassFilterProxyModel : public QSortFilterProxyModel
74 {
75 private :
76  bool hasToBeDisplayed(const QModelIndex index) const;
77  bool displayElement(const QModelIndex index) const;
78 public:
79  ClassFilterProxyModel(QObject *parent = nullptr);
80  bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
81 };
82 ClassFilterProxyModel::ClassFilterProxyModel(QObject *parent):
83  QSortFilterProxyModel(parent)
84 {
85 }
86 
87 bool ClassFilterProxyModel::filterAcceptsRow(int sourceRow,
88  const QModelIndex &sourceParent) const
89 {
90  QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
91 
92  return hasToBeDisplayed(index);
93 }
94 
95 bool ClassFilterProxyModel::displayElement(const QModelIndex index) const
96 {
97  bool result = false;
98  QString type = sourceModel()->data(index, Qt::DisplayRole).toString();
99  QStandardItem * item = dynamic_cast<QStandardItemModel*>(sourceModel())->itemFromIndex(index);
100 
101  if (type.contains(filterRegExp()))
102  {
103  return true;
104  }
105  {
106  mitk::QtViewItem* viewItem = dynamic_cast<mitk::QtViewItem*>(item);
107  if (viewItem)
108  {
109  for (int i = 0; i < viewItem->m_Tags.size(); ++i)
110  {
111  if (viewItem->m_Tags[i].contains(filterRegExp()))
112  {
113  return true;
114  }
115  }
116  if (viewItem->m_Description.contains(filterRegExp()))
117  {
118  return true;
119  }
120  }
121  }
122  {
123  mitk::QtPerspectiveItem* viewItem = dynamic_cast<mitk::QtPerspectiveItem*>(item);
124  if (viewItem)
125  {
126  for (int i = 0; i < viewItem->m_Tags.size(); ++i)
127  {
128  if (viewItem->m_Tags[i].contains(filterRegExp()))
129  {
130  return true;
131  }
132  }
133  if (viewItem->m_Description.contains(filterRegExp()))
134  {
135  return true;
136  }
137  }
138  }
139 
140  return result;
141 }
142 
143 bool ClassFilterProxyModel::hasToBeDisplayed(const QModelIndex index) const
144 {
145  bool result = false;
146  if ( sourceModel()->rowCount(index) > 0 )
147  {
148  for( int ii = 0; ii < sourceModel()->rowCount(index); ii++)
149  {
150  QModelIndex childIndex = sourceModel()->index(ii,0,index);
151  if ( ! childIndex.isValid() )
152  break;
153  result = hasToBeDisplayed(childIndex);
154  result |= displayElement(index);
155  if (result)
156  {
157  break;
158  }
159  }
160  }
161  else
162  {
163  result = displayElement(index);
164  }
165  return result;
166 }
167 
168 class ViewNavigatorPerspectiveListener: public berry::IPerspectiveListener
169 {
170 public:
171 
172  ViewNavigatorPerspectiveListener(QmitkViewNavigatorWidget* p) :
173  parentWidget(p)
174  {
175  }
176 
177  Events::Types GetPerspectiveEventTypes() const override
178  {
179  return Events::ACTIVATED | Events::SAVED_AS | Events::DEACTIVATED
180  // remove the following line when command framework is finished
181  | Events::CLOSED | Events::OPENED | Events::PART_CHANGED;
182  }
183 
184  void PerspectiveActivated(const berry::IWorkbenchPage::Pointer& /*page*/,
186  {
187  parentWidget->m_ActivePerspective = perspective;
188  parentWidget->UpdateTreeList();
189  }
190 
191  void PerspectiveSavedAs(const berry::IWorkbenchPage::Pointer& /*page*/,
192  const berry::IPerspectiveDescriptor::Pointer& /*oldPerspective*/,
193  const berry::IPerspectiveDescriptor::Pointer& newPerspective) override
194  {
195  parentWidget->m_ActivePerspective = newPerspective;
196  parentWidget->UpdateTreeList();
197  }
198 
199  void PerspectiveDeactivated(const berry::IWorkbenchPage::Pointer& /*page*/,
200  const berry::IPerspectiveDescriptor::Pointer& /*perspective*/) override
201  {
202  parentWidget->m_ActivePerspective = nullptr;
203  parentWidget->UpdateTreeList();
204  }
205 
206  void PerspectiveOpened(const berry::IWorkbenchPage::Pointer& /*page*/,
207  const berry::IPerspectiveDescriptor::Pointer& /*perspective*/) override
208  {
209  parentWidget->UpdateTreeList();
210  }
211 
212  void PerspectiveClosed(const berry::IWorkbenchPage::Pointer& /*page*/,
213  const berry::IPerspectiveDescriptor::Pointer& /*perspective*/) override
214  {
215  parentWidget->m_ActivePerspective = nullptr;
216  parentWidget->UpdateTreeList();
217  }
218 
219  using IPerspectiveListener::PerspectiveChanged;
220 
221  void PerspectiveChanged(const berry::IWorkbenchPage::Pointer&,
223  const berry::IWorkbenchPartReference::Pointer& partRef, const std::string& changeId)
224  {
225  if (changeId=="viewHide" && partRef->GetId()=="org.mitk.views.viewnavigatorview")
226  berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->RemovePerspectiveListener(parentWidget->m_PerspectiveListener.data());
227  else
228  parentWidget->UpdateTreeList(nullptr, partRef.GetPointer(), changeId);
229  }
230 
231 private:
232  QmitkViewNavigatorWidget* parentWidget;
233 };
234 
236 {
237  if (a.IsNull() || b.IsNull())
238  return false;
239  return a->GetLabel().compare(b->GetLabel()) < 0;
240 }
241 
243 {
244  if (a.IsNull() || b.IsNull())
245  return false;
246  return a->GetLabel().compare(b->GetLabel()) < 0;
247 }
248 
249 bool compareQStandardItems(const QStandardItem* a, const QStandardItem* b)
250 {
251  if (a==nullptr || b==nullptr)
252  return false;
253  return a->text().compare(b->text()) < 0;
254 }
255 
257  QWidget * parent, Qt::WindowFlags )
258  : QWidget(parent)
259  , m_Window(window)
260 {
261  m_Generated = false;
262  this->CreateQtPartControl(this);
263 }
264 
266 {
267  m_Window->RemovePerspectiveListener(m_PerspectiveListener.data());
268 }
269 
271 {
272  m_Controls.lineEdit->setFocus();
273 }
274 
276 {
277  // create GUI widgets from the Qt Designer's .ui file
279  m_Window->AddPerspectiveListener(m_PerspectiveListener.data());
280 
281  m_Parent = parent;
282  m_Controls.setupUi( parent );
283  connect( m_Controls.m_PluginTreeView, SIGNAL(customContextMenuRequested(QPoint)), SLOT(CustomMenuRequested(QPoint)));
284  connect( m_Controls.m_PluginTreeView, SIGNAL(doubleClicked(const QModelIndex&)), SLOT(ItemClicked(const QModelIndex&)));
285  connect( m_Controls.lineEdit, SIGNAL(textChanged(QString)), SLOT(FilterChanged()));
286 
287  m_ContextMenu = new QMenu(m_Controls.m_PluginTreeView);
288  m_Controls.m_PluginTreeView->setContextMenuPolicy(Qt::CustomContextMenu);
289 
290  // Create a new TreeModel for the data
291  m_TreeModel = new QStandardItemModel();
292  m_FilterProxyModel = new ClassFilterProxyModel(this);
293  m_FilterProxyModel->setSourceModel(m_TreeModel);
294  //proxyModel->setFilterFixedString("Diff");
295  m_Controls.m_PluginTreeView->setModel(m_FilterProxyModel);
296 
297  this->UpdateTreeList();
298 }
299 
300 void QmitkViewNavigatorWidget::UpdateTreeList(QStandardItem* root, berry::IWorkbenchPartReference *partRef, const std::string &changeId)
301 {
302  berry::IWorkbenchPage::Pointer page = m_Window->GetActivePage();
303  if (page.IsNull())
304  return;
305 
306  if( !m_Generated )
307  {
309  }
310 
311  if (root==nullptr)
312  root = m_TreeModel->invisibleRootItem();
313  for (int i=0; i<root->rowCount(); i++)
314  {
315  QStandardItem* item = root->child(i);
316  QFont font;
317  if (dynamic_cast<mitk::QtPerspectiveItem*>(item))
318  {
319  mitk::QtPerspectiveItem* pItem = dynamic_cast<mitk::QtPerspectiveItem*>(item);
320  berry::IPerspectiveDescriptor::Pointer currentPersp = page->GetPerspective();
321 
322  if (currentPersp.IsNotNull() && currentPersp->GetId()==pItem->m_Perspective->GetId())
323  font.setBold(true);
324  pItem->setFont(font);
325  }
326  mitk::QtViewItem* vItem = dynamic_cast<mitk::QtViewItem*>(item);
327  if (vItem)
328  {
329  QList<berry::IViewPart::Pointer> viewParts(page->GetViews());
330  for (int i=0; i<viewParts.size(); i++)
331  if(viewParts[i]->GetPartName()==vItem->m_View->GetLabel())
332  {
333  font.setBold(true);
334  break;
335  }
336 
337  if( partRef!=nullptr && partRef->GetId()==vItem->m_View->GetId() && changeId=="viewHide")
338  font.setBold(false);
339 
340  vItem->setFont(font);
341  }
342  UpdateTreeList(item, partRef, changeId);
343  }
344 }
345 
347 {
348  // active workbench window available?
349  if (m_Window.IsNull())
350  return false;
351 
352  // active page available?
353  berry::IWorkbenchPage::Pointer page = m_Window->GetActivePage();
354  if (page.IsNull())
355  return false;
356 
357  // everything is fine and we can remove the window listener
358  if (m_WindowListener != nullptr)
360 
361  // initialize tree model
362  m_TreeModel->clear();
363  QStandardItem *treeRootItem = m_TreeModel->invisibleRootItem();
364 
365  // get all available perspectives
367  QList<berry::IPerspectiveDescriptor::Pointer> perspectiveDescriptors(perspRegistry->GetPerspectives());
368  qSort(perspectiveDescriptors.begin(), perspectiveDescriptors.end(), comparePerspectives);
369 
370  // get all Keywords
371  KeywordRegistry keywordRegistry;
372 
373  berry::IPerspectiveDescriptor::Pointer currentPersp = page->GetPerspective();
374  //QStringList perspectiveExcludeList = berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetPerspectiveExcludeList();
375 
376  std::vector< QStandardItem* > categoryItems;
377  QStandardItem *perspectiveRootItem = new QStandardItem("Perspectives");
378  perspectiveRootItem->setEditable(false);
379  perspectiveRootItem->setFont(QFont("", 12, QFont::Normal));
380  treeRootItem->appendRow(perspectiveRootItem);
381 
382  for (int i=0; i<perspectiveDescriptors.size(); i++)
383  {
384  berry::IPerspectiveDescriptor::Pointer p = perspectiveDescriptors.at(i);
385 /*
386  bool skipPerspective = false;
387  for(int e=0; e<perspectiveExcludeList.size(); e++)
388  if(perspectiveExcludeList.at(e)==p->GetId())
389  {
390  skipPerspective = true;
391  break;
392  }
393  if (skipPerspective)
394  continue;
395 */
396  //QIcon* pIcon = static_cast<QIcon*>(p->GetImageDescriptor()->CreateImage());
397  mitk::QtPerspectiveItem* pItem = new mitk::QtPerspectiveItem(p->GetLabel());
398  pItem->m_Perspective = p;
399  pItem->m_Description = p->GetDescription();
400  QStringList keylist = p->GetKeywordReferences();
401  pItem->m_Tags = keywordRegistry.GetKeywords(keylist);
402  pItem->setEditable(false);
403 
404  QFont font; font.setBold(true);
405  if (currentPersp.IsNotNull() && currentPersp->GetId()==p->GetId())
406  pItem->setFont(font);
407 
408  QStringList catPath = p->GetCategoryPath();
409  if (catPath.isEmpty())
410  {
411  perspectiveRootItem->appendRow(pItem);
412  }
413  else
414  {
415  QStandardItem* categoryItem = nullptr;
416 
417  for (unsigned int c=0; c<categoryItems.size(); c++)
418  {
419  if (categoryItems.at(c)->text() == catPath.front())
420  {
421  categoryItem = categoryItems.at(c);
422  break;
423  }
424  }
425 
426  if (categoryItem==nullptr)
427  {
428  categoryItem = new QStandardItem(QIcon(),catPath.front());
429  categoryItems.push_back(categoryItem);
430  }
431  categoryItem->setEditable(false);
432  categoryItem->appendRow(pItem);
433  categoryItem->setFont(QFont("", 12, QFont::Normal));
434  }
435  }
436  std::sort(categoryItems.begin(), categoryItems.end(), compareQStandardItems);
437  for (unsigned int i=0; i<categoryItems.size(); i++)
438  perspectiveRootItem->appendRow(categoryItems.at(i));
439 
440  // get all available views
442  QList<berry::IViewDescriptor::Pointer> viewDescriptors(viewRegistry->GetViews());
443  QList<berry::IViewPart::Pointer> viewParts(page->GetViews());
444  qSort(viewDescriptors.begin(), viewDescriptors.end(), compareViews);
445  auto emptyItem = new QStandardItem();
446  emptyItem->setFlags(Qt::ItemIsEnabled);
447  treeRootItem->appendRow(emptyItem);
448  //QStringList viewExcludeList = berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetViewExcludeList();
449 
450  //There currently is no way to get the list of excluded views at application start
451  QStringList viewExcludeList;
452  // internal view used for the intro screen, will crash when opened directly, see T22352
453  viewExcludeList.append(QString("org.blueberry.ui.internal.introview"));
454  viewExcludeList.append(QString("org.mitk.views.controlvisualizationpropertiesview"));
455  viewExcludeList.append(QString("org.mitk.views.modules"));
456  viewExcludeList.append(QString("org.mitk.views.viewnavigatorview"));
457 
458  QStandardItem* viewRootItem = new QStandardItem(QIcon(),"Views");
459  viewRootItem->setFont(QFont("", 12, QFont::Normal));
460  viewRootItem->setEditable(false);
461  treeRootItem->appendRow(viewRootItem);
462 
463  categoryItems.clear();
464  QStandardItem* noCategoryItem = new QStandardItem(QIcon(),"Miscellaneous");
465  noCategoryItem->setEditable(false);
466  noCategoryItem->setFont(QFont("", 12, QFont::Normal));
467 
468  for (int i = 0; i < viewDescriptors.size(); ++i)
469  {
470  berry::IViewDescriptor::Pointer v = viewDescriptors[i];
471  bool skipView = false;
472  for(int e=0; e<viewExcludeList.size(); e++)
473  if(viewExcludeList.at(e)==v->GetId())
474  {
475  skipView = true;
476  break;
477  }
478  if (skipView)
479  continue;
480 
481  QStringList catPath = v->GetCategoryPath();
482 
483  QIcon icon = v->GetImageDescriptor();
484  mitk::QtViewItem* vItem = new mitk::QtViewItem(icon, v->GetLabel());
485  vItem->m_View = v;
486  vItem->setToolTip(v->GetDescription());
487  vItem->m_Description = v->GetDescription();
488 
489  QStringList keylist = v->GetKeywordReferences();
490  vItem->m_Tags = keywordRegistry.GetKeywords(keylist);
491  vItem->setEditable(false);
492 
493  for (int i=0; i<viewParts.size(); i++)
494  if(viewParts[i]->GetPartName()==v->GetLabel())
495  {
496  QFont font; font.setBold(true);
497  vItem->setFont(font);
498  break;
499  }
500 
501  if (catPath.empty())
502  noCategoryItem->appendRow(vItem);
503  else
504  {
505  QStandardItem* categoryItem = nullptr;
506 
507  for (unsigned int c=0; c<categoryItems.size(); c++)
508  if (categoryItems.at(c)->text() == catPath.front())
509  {
510  categoryItem = categoryItems.at(c);
511  break;
512  }
513 
514  if (categoryItem==nullptr)
515  {
516  categoryItem = new QStandardItem(QIcon(),catPath.front());
517  categoryItems.push_back(categoryItem);
518  }
519  categoryItem->setEditable(false);
520  categoryItem->appendRow(vItem);
521  categoryItem->setFont(QFont("", 12, QFont::Normal));
522  }
523  }
524  std::sort(categoryItems.begin(), categoryItems.end(), compareQStandardItems);
525 
526  for (unsigned int i=0; i<categoryItems.size(); i++)
527  viewRootItem->appendRow(categoryItems.at(i));
528  if (noCategoryItem->hasChildren())
529  viewRootItem->appendRow(noCategoryItem);
530 
531  m_Controls.m_PluginTreeView->expandAll();
532 
533  return true;
534 }
535 
537 {
538  QString filterString = m_Controls.lineEdit->text();
539 // if (filterString.size() > 0 )
540  m_Controls.m_PluginTreeView->expandAll();
541 // else
542 // m_Controls.m_PluginTreeView->collapseAll();
543  // QRegExp::PatternSyntax syntax = QRegExp::RegExp;
544 
545  Qt::CaseSensitivity caseSensitivity = Qt::CaseInsensitive;
546  QString strPattern = "^*" + filterString;
547  QRegExp regExp(strPattern, caseSensitivity);
548 
549  m_FilterProxyModel->setFilterRegExp(regExp);
550 }
551 
552 void QmitkViewNavigatorWidget::ItemClicked(const QModelIndex &index)
553 {
554  QStandardItem* item = m_TreeModel->itemFromIndex(m_FilterProxyModel->mapToSource(index));
555 
556  if ( dynamic_cast< mitk::QtPerspectiveItem* >(item) )
557  {
558  try
559  {
560  mitk::QtPerspectiveItem* pItem = dynamic_cast< mitk::QtPerspectiveItem* >(item);
562  }
563  catch (...)
564  {
565  QMessageBox::critical(nullptr, "Opening Perspective Failed", QString("The requested perspective could not be opened.\nSee the log for details."));
566  }
567  }
568  else if ( dynamic_cast< mitk::QtViewItem* >(item) )
569  {
571 
572  if (page.IsNotNull())
573  {
574  try
575  {
576  mitk::QtViewItem* vItem = dynamic_cast< mitk::QtViewItem* >(item);
577  page->ShowView(vItem->m_View->GetId());
578  }
579  catch (const berry::PartInitException& e)
580  {
581  BERRY_ERROR << "Error: " << e.what() << std::endl;
582  }
583  }
584  }
585 }
586 
588 {
589  berry::IHandlerService* handlerService = m_Window->GetService<berry::IHandlerService>();
590  try
591  {
594  FillTreeList();
595  }
596  catch(const berry::NotHandledException&)
597  {}
598  catch(const berry::CommandException& e)
599  {
600  MITK_ERROR << e.what();
601  }
602 }
603 
605 {
606  if (QMessageBox::Yes == QMessageBox(QMessageBox::Question, "Please confirm", "Do you really want to reset the current perspective?", QMessageBox::Yes|QMessageBox::No).exec())
607  berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->ResetPerspective();
608 }
609 
611 {
612  if (QMessageBox::Yes == QMessageBox(QMessageBox::Question, "Please confirm", "Do you really want to close the current perspective?", QMessageBox::Yes|QMessageBox::No).exec())
613  {
614  berry::IWorkbenchPage::Pointer page = m_Window->GetActivePage();
615  page->ClosePerspective(page->GetPerspective(), true, true);
616 
617  // if ( page->GetPerspective().IsNull() )
618  // {
619  // berry::IPerspectiveRegistry* perspRegistry = berry::PlatformUI::GetWorkbench()->GetPerspectiveRegistry();
620  // berry::PlatformUI::GetWorkbench()->ShowPerspective( perspRegistry->GetDefaultPerspective(), berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow() );
621  // }
622  }
623 }
624 
626 {
627  if (QMessageBox::Yes == QMessageBox(QMessageBox::Question, "Please confirm", "Do you really want to close all perspectives?", QMessageBox::Yes|QMessageBox::No).exec())
628  {
630  page->CloseAllPerspectives(true, true);
631 
632  // berry::IPerspectiveRegistry* perspRegistry = berry::PlatformUI::GetWorkbench()->GetPerspectiveRegistry();
633  // berry::PlatformUI::GetWorkbench()->ShowPerspective( perspRegistry->GetDefaultPerspective(), berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow() );
634  }
635 }
636 
638 {
639  m_Controls.m_PluginTreeView->expandAll();
640 }
641 
643 {
644  m_Controls.m_PluginTreeView->collapseAll();
645 }
646 
648 {
649  QModelIndex index = m_Controls.m_PluginTreeView->indexAt(pos);
650  QStandardItem* item = m_TreeModel->itemFromIndex(m_FilterProxyModel->mapToSource(index));
651 
652  if (m_ContextMenu==nullptr)
653  return;
654 
655  m_ContextMenu->clear();
656 
657  QAction* expandAction = new QAction("Expand tree", this);
658  m_ContextMenu->addAction(expandAction);
659  connect(expandAction, SIGNAL(triggered()), SLOT(ExpandAll()));
660 
661  QAction* collapseAction = new QAction("Collapse tree", this);
662  m_ContextMenu->addAction(collapseAction);
663  connect(collapseAction, SIGNAL(triggered()), SLOT(CollapseAll()));
664 
665  m_ContextMenu->addSeparator();
666 
667 
668  if ( item!=nullptr && dynamic_cast< mitk::QtPerspectiveItem* >(item) )
669  {
670  berry::IPerspectiveDescriptor::Pointer persp = dynamic_cast< mitk::QtPerspectiveItem* >(item)->m_Perspective;
671  if (this->m_ActivePerspective.IsNotNull() && this->m_ActivePerspective == persp)
672  {
673  //m_ContextMenu->addSeparator();
674 
675  QAction* saveAsAction = new QAction("Save As...", this);
676  m_ContextMenu->addAction(saveAsAction);
677  connect(saveAsAction, SIGNAL(triggered()), SLOT(SaveCurrentPerspectiveAs()));
678  m_ContextMenu->addSeparator();
679  }
680  }
681 
682  QAction* resetAction = new QAction("Reset current perspective", this);
683  m_ContextMenu->addAction(resetAction);
684  connect(resetAction, SIGNAL(triggered()), SLOT(ResetCurrentPerspective()));
685 
686  QAction* closeAction = new QAction("Close perspective", this);
687  m_ContextMenu->addAction(closeAction);
688  connect(closeAction, SIGNAL(triggered()), SLOT(ClosePerspective()));
689 
690  m_ContextMenu->addSeparator();
691 
692  QAction* closeAllAction = new QAction("Close all perspectives", this);
693  m_ContextMenu->addAction(closeAllAction);
694  connect(closeAllAction, SIGNAL(triggered()), SLOT(CloseAllPerspectives()));
695 
696  m_ContextMenu->popup(m_Controls.m_PluginTreeView->viewport()->mapToGlobal(pos));
697 }
berry::IViewDescriptor::Pointer m_View
virtual IPerspectiveRegistry * GetPerspectiveRegistry() const =0
#define MITK_ERROR
Definition: mitkLogMacros.h:20
virtual QString GetId() const =0
virtual void RemoveWindowListener(IWindowListener *listener)=0
virtual QList< IPerspectiveDescriptor::Pointer > GetPerspectives()=0
bool compareQStandardItems(const QStandardItem *a, const QStandardItem *b)
virtual Object::Pointer ExecuteCommand(const QString &commandId, const SmartPointer< const UIElement > &uielement)=0
#define BERRY_ERROR
Definition: berryLog.h:22
berry::IPerspectiveDescriptor::Pointer m_Perspective
QScopedPointer< berry::IWindowListener > m_WindowListener
void ItemClicked(const QModelIndex &index)
virtual void CreateQtPartControl(QWidget *parent)
virtual QList< IViewDescriptor::Pointer > GetViews() const =0
QmitkViewNavigatorWidget(berry::IWorkbenchWindow::Pointer window, QWidget *parent=nullptr, Qt::WindowFlags f=nullptr)
Ui::QmitkViewNavigatorWidgetControls m_Controls
static IWorkbench * GetWorkbench()
virtual QList< SmartPointer< IConfigurationElement > > GetConfigurationElementsFor(const QString &extensionPointId) const =0
static IExtensionRegistry * GetExtensionRegistry()
QStandardItemModel * m_TreeModel
virtual IWorkbenchWindow::Pointer GetActiveWorkbenchWindow() const =0
QStringList m_Tags
void UpdateTreeList(QStandardItem *item=nullptr, berry::IWorkbenchPartReference *partRef=nullptr, const std::string &changeId="")
The custom viewer plugin implements simple viewer functionality presented in a customized look and feel It was developed to demonstrate extensibility and customizability of the blueberry application framework As an example for the GUI customization capabilities provided by the BlueBerry application the custom viewer plugin was developed It features simple viewer functionality presented in a customized look and feel The custom viewer consists of two i e a viewer perspective and a DICOM perspective As part of the viewer perspective
bool compareViews(const berry::IViewDescriptor::Pointer &a, const berry::IViewDescriptor::Pointer &b)
berry::IPerspectiveDescriptor::Pointer m_ActivePerspective
ClassFilterProxyModel * m_FilterProxyModel
QScopedPointer< berry::IPerspectiveListener > m_PerspectiveListener
virtual IViewRegistry * GetViewRegistry() const =0
virtual SmartPointer< IWorkbenchPage > ShowPerspective(const QString &perspectiveId, IWorkbenchWindow::Pointer window)=0
bool comparePerspectives(const berry::IPerspectiveDescriptor::Pointer &a, const berry::IPerspectiveDescriptor::Pointer &b)
ObjectType * GetPointer() const