diff --git a/Plugins/PluginList.cmake b/Plugins/PluginList.cmake
index 6abfe68531..9837294fe9 100644
--- a/Plugins/PluginList.cmake
+++ b/Plugins/PluginList.cmake
@@ -1,57 +1,58 @@
# Plug-ins must be ordered according to their dependencies
if (MITK_USE_Qt4)
set(MITK_EXT_PLUGINS
org.mitk.core.services:ON
org.mitk.gui.common:ON
org.mitk.planarfigure:ON
org.mitk.core.ext:OFF
org.mitk.core.jobs:OFF
org.mitk.diffusionimaging:OFF
org.mitk.simulation:OFF
org.mitk.gui.qt.application:ON
org.mitk.gui.qt.coreapplication:OFF
org.mitk.gui.qt.ext:OFF
org.mitk.gui.qt.extapplication:OFF
org.mitk.gui.qt.common:ON
org.mitk.gui.qt.stdmultiwidgeteditor:ON
org.mitk.gui.qt.common.legacy:OFF
org.mitk.gui.qt.cmdlinemodules:OFF
org.mitk.gui.qt.diffusionimagingapp:OFF
org.mitk.gui.qt.datamanager:ON
org.mitk.gui.qt.datamanagerlight:OFF
org.mitk.gui.qt.properties:ON
org.mitk.gui.qt.basicimageprocessing:OFF
org.mitk.gui.qt.dicom:OFF
org.mitk.gui.qt.diffusionimaging:OFF
org.mitk.gui.qt.dtiatlasapp:OFF
org.mitk.gui.qt.igtexamples:OFF
org.mitk.gui.qt.igttracking:OFF
org.mitk.gui.qt.imagecropper:OFF
org.mitk.gui.qt.imagenavigator:ON
+ org.mitk.gui.qt.candystore:ON
org.mitk.gui.qt.materialeditor:OFF
org.mitk.gui.qt.measurementtoolbox:OFF
org.mitk.gui.qt.moviemaker:OFF
org.mitk.gui.qt.pointsetinteraction:OFF
org.mitk.gui.qt.python:OFF
org.mitk.gui.qt.registration:OFF
org.mitk.gui.qt.remeshing:OFF
org.mitk.gui.qt.segmentation:OFF
org.mitk.gui.qt.simulation:OFF
org.mitk.gui.qt.toftutorial:OFF
org.mitk.gui.qt.tofutil:OFF
org.mitk.gui.qt.ugvisualization:OFF
org.mitk.gui.qt.ultrasound:OFF
org.mitk.gui.qt.volumevisualization:OFF
org.mitk.gui.qt.eventrecorder:OFF
org.mitk.gui.qt.xnat:OFF
)
else()
set(MITK_EXT_PLUGINS
# empty so far
)
endif()
diff --git a/Plugins/org.mitk.gui.qt.candystore/CMakeLists.txt b/Plugins/org.mitk.gui.qt.candystore/CMakeLists.txt
new file mode 100644
index 0000000000..e34977274f
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.candystore/CMakeLists.txt
@@ -0,0 +1,8 @@
+project(org_mitk_gui_qt_candystore)
+
+MACRO_CREATE_MITK_CTK_PLUGIN(
+ EXPORT_DIRECTIVE CANDYSTORE_EXPORT
+ EXPORTED_INCLUDE_SUFFIXES src
+ MODULE_DEPENDENCIES MitkQtWidgetsExt
+ PACKAGE_DEPENDS CTK
+)
diff --git a/Plugins/org.mitk.gui.qt.candystore/documentation/UserManual/Manual.dox b/Plugins/org.mitk.gui.qt.candystore/documentation/UserManual/Manual.dox
new file mode 100644
index 0000000000..eb80add408
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.candystore/documentation/UserManual/Manual.dox
@@ -0,0 +1,18 @@
+/**
+\page org_mitk_gui_qt_candystore Candy Store
+
+\imageMacro{icon.png,"Icon of Candy Store",2.00}
+
+Available sections:
+ - \ref org_mitk_gui_qt_candystoreOverview
+
+\section org_mitk_gui_qt_candystoreOverview
+Describe the features of your awesome plugin here
+
+- Increases productivity
+
- Creates beautiful images
+
- Generates PhD thesis
+
- Brings world peace
+
+
+*/
diff --git a/Plugins/org.mitk.gui.qt.candystore/documentation/UserManual/icon.xpm b/Plugins/org.mitk.gui.qt.candystore/documentation/UserManual/icon.xpm
new file mode 100644
index 0000000000..9057c20bc6
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.candystore/documentation/UserManual/icon.xpm
@@ -0,0 +1,21 @@
+/* XPM */
+static const char * icon_xpm[] = {
+"16 16 2 1",
+" c #FF0000",
+". c #000000",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" "};
diff --git a/Plugins/org.mitk.gui.qt.candystore/documentation/doxygen/modules.dox b/Plugins/org.mitk.gui.qt.candystore/documentation/doxygen/modules.dox
new file mode 100644
index 0000000000..75081965a2
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.candystore/documentation/doxygen/modules.dox
@@ -0,0 +1,16 @@
+/**
+ \defgroup org_mitk_gui_qt_candystore org.mitk.gui.qt.candystore
+ \ingroup MITKPlugins
+
+ \brief Describe your plugin here.
+
+*/
+
+/**
+ \defgroup org_mitk_gui_qt_candystore_internal Internal
+ \ingroup org_mitk_gui_qt_candystore
+
+ \brief This subcategory includes the internal classes of the org.mitk.gui.qt.candystore plugin. Other
+ plugins must not rely on these classes. They contain implementation details and their interface
+ may change at any time. We mean it.
+*/
diff --git a/Plugins/org.mitk.gui.qt.candystore/files.cmake b/Plugins/org.mitk.gui.qt.candystore/files.cmake
new file mode 100644
index 0000000000..99d102bb16
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.candystore/files.cmake
@@ -0,0 +1,50 @@
+set(SRC_CPP_FILES
+ QmitkCandyStoreWidget.cpp
+ QmitkNewPerspectiveDialog.cpp
+)
+
+set(INTERNAL_CPP_FILES
+ org_mitk_gui_qt_candystore_Activator.cpp
+ CandyStoreView.cpp
+)
+
+set(UI_FILES
+ src/internal/CandyStoreViewControls.ui
+ src/QmitkCandyStoreWidgetControls.ui
+)
+
+set(MOC_H_FILES
+ src/internal/org_mitk_gui_qt_candystore_Activator.h
+ src/internal/CandyStoreView.h
+
+ src/QmitkCandyStoreWidget.h
+ src/mitkQtPerspectiveItem.h
+ src/mitkQtViewItem.h
+ src/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
+ resources/Candy_icon.png
+ 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.candystore/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.candystore/manifest_headers.cmake
new file mode 100644
index 0000000000..6657eca0c2
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.candystore/manifest_headers.cmake
@@ -0,0 +1,5 @@
+set(Plugin-Name "Candy Store")
+set(Plugin-Version "0.1")
+set(Plugin-Vendor "DKFZ, Medical and Biological Informatics")
+set(Plugin-ContactAddress "")
+set(Require-Plugin org.mitk.gui.qt.common)
diff --git a/Plugins/org.mitk.gui.qt.candystore/plugin.xml b/Plugins/org.mitk.gui.qt.candystore/plugin.xml
new file mode 100644
index 0000000000..8a9bb6095a
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.candystore/plugin.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
diff --git a/Plugins/org.mitk.gui.qt.candystore/resources/Candy_icon.png b/Plugins/org.mitk.gui.qt.candystore/resources/Candy_icon.png
new file mode 100644
index 0000000000..f71e77664c
Binary files /dev/null and b/Plugins/org.mitk.gui.qt.candystore/resources/Candy_icon.png differ
diff --git a/Plugins/org.mitk.gui.qt.candystore/resources/icon.xpm b/Plugins/org.mitk.gui.qt.candystore/resources/icon.xpm
new file mode 100644
index 0000000000..9057c20bc6
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.candystore/resources/icon.xpm
@@ -0,0 +1,21 @@
+/* XPM */
+static const char * icon_xpm[] = {
+"16 16 2 1",
+" c #FF0000",
+". c #000000",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" ",
+" "};
diff --git a/Plugins/org.mitk.gui.qt.ext/src/QmitkCandyStoreWidget.cpp b/Plugins/org.mitk.gui.qt.candystore/src/QmitkCandyStoreWidget.cpp
similarity index 96%
rename from Plugins/org.mitk.gui.qt.ext/src/QmitkCandyStoreWidget.cpp
rename to Plugins/org.mitk.gui.qt.candystore/src/QmitkCandyStoreWidget.cpp
index 61c8384ddd..03df302846 100644
--- a/Plugins/org.mitk.gui.qt.ext/src/QmitkCandyStoreWidget.cpp
+++ b/Plugins/org.mitk.gui.qt.candystore/src/QmitkCandyStoreWidget.cpp
@@ -1,757 +1,770 @@
/*===================================================================
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.
===================================================================*/
//Qmitk headers
#include "QmitkCandyStoreWidget.h"
// Blueberry
#include
#include
#include
#include
#include
#include
// Qt
#include
#include
#include
#include
class KeywordRegistry
{
public:
KeywordRegistry()
{
berry::IExtensionPointService::Pointer extensionPointService = berry::Platform::GetExtensionPointService();
berry::IConfigurationElement::vector keywordExts(extensionPointService->GetConfigurationElementsFor("org.blueberry.ui.keywords"));
std::string keywordId;
std::string keywordLabels;
berry::IConfigurationElement::vector::iterator keywordExtsIt;
for (keywordExtsIt = keywordExts.begin(); keywordExtsIt != keywordExts.end(); ++keywordExtsIt)
{
(*keywordExtsIt)->GetAttribute("id", keywordId);
(*keywordExtsIt)->GetAttribute("label", keywordLabels);
if (m_Keywords.find(keywordId) == m_Keywords.end())
{
m_Keywords[keywordId] = std::vector();
}
m_Keywords[keywordId].push_back(QString::fromStdString(keywordLabels));
}
}
std::vector GetKeywords(const std::string& id)
{
return m_Keywords[id];
}
std::vector GetKeywords(const std::vector& ids)
{
std::vector result;
for (unsigned int i = 0; i < ids.size(); ++i)
{
std::vector< QString > tmpResult;
tmpResult = this->GetKeywords(ids[i]);
result.insert(result.end(), tmpResult.begin(), tmpResult.end());
}
return result;
}
private:
std::map > m_Keywords;
};
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 = false;
QString type = sourceModel()->data(index, Qt::DisplayRole).toString();
QStandardItem * item = dynamic_cast(sourceModel())->itemFromIndex(index);
if (type.contains(filterRegExp()))
{
return true;
}
{
mitk::QtViewItem* viewItem = dynamic_cast(item);
if (viewItem)
{
for (unsigned int i = 0; i < viewItem->m_Tags.size(); ++i)
{
if (viewItem->m_Tags[i].contains(filterRegExp()))
{
return true;
}
}
if (viewItem->m_Description.contains(filterRegExp()))
{
return true;
}
}
}
{
mitk::QtPerspectiveItem* viewItem = dynamic_cast(item);
if (viewItem)
{
for (unsigned int i = 0; i < viewItem->m_Tags.size(); ++i)
{
if (viewItem->m_Tags[i].contains(filterRegExp()))
{
return true;
}
}
if (viewItem->m_Description.contains(filterRegExp()))
{
return true;
}
}
}
return result;
}
bool ClassFilterProxyModel::hasToBeDisplayed(const QModelIndex index) const
{
bool result = false;
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)
{
break;
}
}
}
else
{
result = displayElement(index);
}
return result;
}
class CandyStorePerspectiveListener: public berry::IPerspectiveListener
{
public:
CandyStorePerspectiveListener(QmitkCandyStoreWidget* p) :
parentWidget(p)
{
}
Events::Types GetPerspectiveEventTypes() const
{
return Events::ACTIVATED | Events::SAVED_AS | Events::DEACTIVATED
// remove the following line when command framework is finished
| Events::CLOSED | Events::OPENED | Events::PART_CHANGED;
}
void PerspectiveActivated(berry::IWorkbenchPage::Pointer /*page*/,
berry::IPerspectiveDescriptor::Pointer /*perspective*/)
{
parentWidget->UpdateTreeList();
}
void PerspectiveSavedAs(berry::IWorkbenchPage::Pointer /*page*/,
berry::IPerspectiveDescriptor::Pointer /*oldPerspective*/,
berry::IPerspectiveDescriptor::Pointer /*newPerspective*/)
{
}
void PerspectiveDeactivated(berry::IWorkbenchPage::Pointer /*page*/,
berry::IPerspectiveDescriptor::Pointer /*perspective*/)
{
parentWidget->UpdateTreeList();
}
void PerspectiveOpened(berry::IWorkbenchPage::Pointer /*page*/,
berry::IPerspectiveDescriptor::Pointer /*perspective*/)
{
parentWidget->UpdateTreeList();
}
void PerspectiveClosed(berry::IWorkbenchPage::Pointer /*page*/,
berry::IPerspectiveDescriptor::Pointer /*perspective*/)
{
parentWidget->UpdateTreeList();
}
void PerspectiveChanged(berry::IWorkbenchPage::Pointer,
berry::IPerspectiveDescriptor::Pointer,
berry::IWorkbenchPartReference::Pointer partRef, const std::string& changeId)
{
- parentWidget->UpdateTreeList(NULL, partRef.GetPointer(), changeId);
+ if (changeId=="viewHide" && partRef->GetId()=="org.mitk.views.candystoreview")
+ berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->RemovePerspectiveListener(parentWidget->m_PerspectiveListener);
+ else
+ parentWidget->UpdateTreeList(NULL, partRef.GetPointer(), changeId);
}
private:
QmitkCandyStoreWidget* parentWidget;
};
struct CandyStoreWindowListener : public berry::IWindowListener
{
CandyStoreWindowListener(QmitkCandyStoreWidget* switcher)
- : switcher(switcher),
- m_Done(false)
+ : switcher(switcher)
+ , m_Done(false)
{}
virtual void WindowOpened(berry::IWorkbenchWindow::Pointer window)
{
if (m_Done)
return;
if ( switcher->FillTreeList() )
{
m_Done = true;
switcher->m_PerspectiveListener = CandyStorePerspectiveListener::Pointer(new CandyStorePerspectiveListener(switcher));
window->AddPerspectiveListener(switcher->m_PerspectiveListener);
}
}
virtual void WindowActivated(berry::IWorkbenchWindow::Pointer window)
{
if (m_Done)
return;
if ( switcher->FillTreeList() )
{
m_Done = true;
switcher->m_PerspectiveListener = CandyStorePerspectiveListener::Pointer(new CandyStorePerspectiveListener(switcher));
window->AddPerspectiveListener(switcher->m_PerspectiveListener);
}
}
private:
QmitkCandyStoreWidget* switcher;
bool m_Done;
};
bool compareViews(berry::IViewDescriptor::Pointer a, berry::IViewDescriptor::Pointer b)
{
if (a.IsNull() || b.IsNull())
return false;
return a->GetLabel().compare(b->GetLabel()) < 0;
}
bool comparePerspectives(berry::IPerspectiveDescriptor::Pointer a, berry::IPerspectiveDescriptor::Pointer b)
{
if (a.IsNull() || b.IsNull())
return false;
return a->GetLabel().compare(b->GetLabel()) < 0;
}
bool compareQStandardItems(QStandardItem* a, QStandardItem* b)
{
if (a==NULL || b==NULL)
return false;
return a->text().compare(b->text()) < 0;
}
QmitkCandyStoreWidget::QmitkCandyStoreWidget( QWidget * parent, Qt::WindowFlags )
: QWidget(parent)
{
this->CreateQtPartControl(this);
}
QmitkCandyStoreWidget::~QmitkCandyStoreWidget()
{
}
void QmitkCandyStoreWidget::CreateQtPartControl( QWidget *parent )
{
// create GUI widgets from the Qt Designer's .ui file
- m_WindowListener = CandyStoreWindowListener::Pointer(new CandyStoreWindowListener(this));
- berry::PlatformUI::GetWorkbench()->AddWindowListener(m_WindowListener);
+ if (berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow().IsNotNull())
+ {
+ m_PerspectiveListener = CandyStorePerspectiveListener::Pointer(new CandyStorePerspectiveListener(this));
+ berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->AddPerspectiveListener(m_PerspectiveListener);
+ }
+ else
+ {
+ m_WindowListener = CandyStoreWindowListener::Pointer(new CandyStoreWindowListener(this));
+ berry::PlatformUI::GetWorkbench()->AddWindowListener(m_WindowListener);
+ }
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.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();
}
void QmitkCandyStoreWidget::UpdateTreeList(QStandardItem* root, berry::IWorkbenchPartReference *partRef, const std::string &changeId)
{
berry::IWorkbenchPage::Pointer page = berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage();
if (page.IsNull())
return;
if (root==NULL)
root = m_TreeModel->invisibleRootItem();
for (int i=0; irowCount(); i++)
{
QStandardItem* item = root->child(i);
QFont font;
if (dynamic_cast(item))
{
mitk::QtPerspectiveItem* pItem = dynamic_cast(item);
berry::IPerspectiveDescriptor::Pointer currentPersp = page->GetPerspective();
if (currentPersp.IsNotNull() && currentPersp->GetId()==pItem->m_Perspective->GetId())
font.setBold(true);
pItem->setFont(font);
}
mitk::QtViewItem* vItem = dynamic_cast(item);
if (vItem)
{
std::vector viewParts(page->GetViews());
for (unsigned int i=0; iGetPartName()==vItem->m_View->GetLabel())
{
font.setBold(true);
break;
}
if( partRef!=NULL && partRef->GetId()==vItem->m_View->GetId() && changeId=="viewHide")
font.setBold(false);
vItem->setFont(font);
}
UpdateTreeList(item, partRef, changeId);
}
}
bool QmitkCandyStoreWidget::FillTreeList()
{
// active workbench window available?
if (berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow().IsNull())
return false;
+
// active page available?
berry::IWorkbenchPage::Pointer page = berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage();
if (page.IsNull())
return false;
// everything is fine and we can remove the window listener
- berry::PlatformUI::GetWorkbench()->RemoveWindowListener(m_WindowListener);
+ if (m_WindowListener.IsNotNull())
+ berry::PlatformUI::GetWorkbench()->RemoveWindowListener(m_WindowListener);
// initialize tree model
m_TreeModel->clear();
QStandardItem *treeRootItem = m_TreeModel->invisibleRootItem();
// get all available perspectives
berry::IPerspectiveRegistry* perspRegistry = berry::PlatformUI::GetWorkbench()->GetPerspectiveRegistry();
std::vector perspectiveDescriptors(perspRegistry->GetPerspectives());
std::sort(perspectiveDescriptors.begin(), perspectiveDescriptors.end(), comparePerspectives);
// get all Keywords
KeywordRegistry keywordRegistry;
berry::IPerspectiveDescriptor::Pointer currentPersp = page->GetPerspective();
std::vector perspectiveExcludeList = berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetPerspectiveExcludeList();
std::vector< QStandardItem* > categoryItems;
QStandardItem *perspectiveRootItem = new QStandardItem("Workflows");
perspectiveRootItem->setEditable(false);
treeRootItem->appendRow(perspectiveRootItem);
for (unsigned int i=0; iGetId())
{
skipPerspective = true;
break;
}
if (skipPerspective)
continue;
//QIcon* pIcon = static_cast(p->GetImageDescriptor()->CreateImage());
mitk::QtPerspectiveItem* pItem = new mitk::QtPerspectiveItem(QString::fromStdString(p->GetLabel()));
pItem->m_Perspective = p;
pItem->m_Description = QString::fromStdString(p->GetDescription());
std::vector keylist = p->GetKeywordReferences();
pItem->m_Tags = keywordRegistry.GetKeywords(keylist);
pItem->setEditable(false);
QFont font; font.setBold(true);
if (currentPersp.IsNotNull() && currentPersp->GetId()==p->GetId())
pItem->setFont(font);
std::vector catPath = p->GetCategoryPath();
if (catPath.empty())
{
perspectiveRootItem->appendRow(pItem);
}
else
{
QStandardItem* categoryItem = NULL;
for (unsigned int c=0; ctext().toStdString() == catPath.front())
{
categoryItem = categoryItems.at(c);
break;
}
if (categoryItem==NULL)
{
categoryItem = new QStandardItem(QIcon(),catPath.front().c_str());
categoryItems.push_back(categoryItem);
}
categoryItem->setEditable(false);
categoryItem->appendRow(pItem);
}
}
std::sort(categoryItems.begin(), categoryItems.end(), compareQStandardItems);
for (unsigned int i=0; iappendRow(categoryItems.at(i));
// get all available views
berry::IViewRegistry* viewRegistry = berry::PlatformUI::GetWorkbench()->GetViewRegistry();
std::vector viewDescriptors(viewRegistry->GetViews());
std::vector viewParts(page->GetViews());
std::sort(viewDescriptors.begin(), viewDescriptors.end(), compareViews);
std::vector viewExcludeList = berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetViewExcludeList();
QStandardItem* viewRootItem = new QStandardItem(QIcon(),"Candies");
viewRootItem->setEditable(false);
treeRootItem->appendRow(viewRootItem);
categoryItems.clear();
QStandardItem* noCategoryItem = new QStandardItem(QIcon(),"Miscellaneous");
noCategoryItem->setEditable(false);
for (unsigned int i = 0; i < viewDescriptors.size(); ++i)
{
berry::IViewDescriptor::Pointer v = viewDescriptors[i];
bool skipView = false;
for(unsigned int e=0; eGetId())
{
skipView = true;
break;
}
if (skipView)
continue;
std::vector catPath = v->GetCategoryPath();
QIcon* icon = static_cast(v->GetImageDescriptor()->CreateImage());
mitk::QtViewItem* vItem = new mitk::QtViewItem(*icon, QString::fromStdString(v->GetLabel()));
vItem->m_View = v;
vItem->setToolTip(v->GetDescription().c_str());
vItem->m_Description = QString::fromStdString(v->GetDescription());
std::vector keylist = v->GetKeywordReferences();
vItem->m_Tags = keywordRegistry.GetKeywords(keylist);
vItem->setEditable(false);
for (unsigned int i=0; iGetPartName()==v->GetLabel())
{
QFont font; font.setBold(true);
vItem->setFont(font);
break;
}
if (catPath.empty())
noCategoryItem->appendRow(vItem);
else
{
QStandardItem* categoryItem = NULL;
for (unsigned int c=0; ctext().toStdString() == catPath.front())
{
categoryItem = categoryItems.at(c);
break;
}
if (categoryItem==NULL)
{
categoryItem = new QStandardItem(QIcon(),catPath.front().c_str());
categoryItems.push_back(categoryItem);
}
categoryItem->setEditable(false);
categoryItem->appendRow(vItem);
}
}
std::sort(categoryItems.begin(), categoryItems.end(), compareQStandardItems);
for (unsigned int i=0; iappendRow(categoryItems.at(i));
if (noCategoryItem->hasChildren())
viewRootItem->appendRow(noCategoryItem);
m_Controls.m_PluginTreeView->expandAll();
return true;
}
void QmitkCandyStoreWidget::FilterChanged()
{
QString filterString = m_Controls.lineEdit->text();
if (filterString.size() > 0 )
m_Controls.m_PluginTreeView->expandAll();
else
m_Controls.m_PluginTreeView->collapseAll();
// QRegExp::PatternSyntax syntax = QRegExp::RegExp;
Qt::CaseSensitivity caseSensitivity = Qt::CaseInsensitive;
QString strPattern = "^*" + filterString;
QRegExp regExp(strPattern, caseSensitivity);
m_FilterProxyModel->setFilterRegExp(regExp);
}
void QmitkCandyStoreWidget::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 QmitkCandyStoreWidget::AddPerspective()
{
QmitkNewPerspectiveDialog* dialog = new QmitkNewPerspectiveDialog( m_Parent );
int dialogReturnValue = dialog->exec();
if ( dialogReturnValue == QDialog::Rejected )
return;
berry::IPerspectiveRegistry* perspRegistry = berry::PlatformUI::GetWorkbench()->GetPerspectiveRegistry();
try
{
berry::IPerspectiveDescriptor::Pointer perspDesc;
perspDesc = perspRegistry->CreatePerspective(dialog->GetPerspectiveName().toStdString(), perspRegistry->FindPerspectiveWithId(perspRegistry->GetDefaultPerspective()));
berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->SetPerspective(perspDesc);
}
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 QmitkCandyStoreWidget::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
{
berry::IPerspectiveDescriptor::Pointer perspDesc = perspRegistry->ClonePerspective(dialog->GetPerspectiveName().toStdString(), dialog->GetPerspectiveName().toStdString(), m_RegisteredPerspective);
berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->SetPerspective(perspDesc);
}
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 QmitkCandyStoreWidget::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 QmitkCandyStoreWidget::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);
berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->RemovePerspective(m_RegisteredPerspective);
FillTreeList();
if (! berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->GetPerspective())
{
berry::IPerspectiveDescriptor::Pointer persp = perspRegistry->FindPerspectiveWithId(perspRegistry->GetDefaultPerspective());
berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->SetPerspective(persp);
}
}
}
}
void QmitkCandyStoreWidget::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 QmitkCandyStoreWidget::CloseAllPerspectives()
{
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 QmitkCandyStoreWidget::ExpandAll()
{
m_Controls.m_PluginTreeView->expandAll();
}
void QmitkCandyStoreWidget::CollapseAll()
{
m_Controls.m_PluginTreeView->collapseAll();
}
void QmitkCandyStoreWidget::CustomMenuRequested(QPoint pos)
{
QModelIndex index = m_Controls.m_PluginTreeView->indexAt(pos);
QStandardItem* item = m_TreeModel->itemFromIndex(m_FilterProxyModel->mapToSource(index));
if (m_ContextMenu==NULL)
return;
m_ContextMenu->clear();
m_RegisteredPerspective = NULL;
QAction* expandAction = new QAction("Expand tree", this);
m_ContextMenu->addAction(expandAction);
connect(expandAction, SIGNAL(triggered()), SLOT(ExpandAll()));
QAction* collapseAction = new QAction("Collapse tree", this);
m_ContextMenu->addAction(collapseAction);
connect(collapseAction, SIGNAL(triggered()), SLOT(CollapseAll()));
m_ContextMenu->addSeparator();
if ( item!=NULL && 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()));
}
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(CloseAllPerspectives()));
m_ContextMenu->popup(m_Controls.m_PluginTreeView->viewport()->mapToGlobal(pos));
}
diff --git a/Plugins/org.mitk.gui.qt.ext/src/QmitkCandyStoreWidget.h b/Plugins/org.mitk.gui.qt.candystore/src/QmitkCandyStoreWidget.h
similarity index 93%
rename from Plugins/org.mitk.gui.qt.ext/src/QmitkCandyStoreWidget.h
rename to Plugins/org.mitk.gui.qt.candystore/src/QmitkCandyStoreWidget.h
index 995ea9ca94..509c4cdad6 100644
--- a/Plugins/org.mitk.gui.qt.ext/src/QmitkCandyStoreWidget.h
+++ b/Plugins/org.mitk.gui.qt.candystore/src/QmitkCandyStoreWidget.h
@@ -1,88 +1,89 @@
/*===================================================================
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 _QMITKCandyStoreWidget_H_INCLUDED
#define _QMITKCandyStoreWidget_H_INCLUDED
//QT headers
#include
#include
+
+#include
#include "ui_QmitkCandyStoreWidgetControls.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
class ClassFilterProxyModel;
/** @brief
*/
class QmitkCandyStoreWidget : public QWidget
{
//this is needed for all Qt objects that should have a MOC object (everything that derives from QObject)
Q_OBJECT
public:
QmitkCandyStoreWidget (QWidget* parent = 0, Qt::WindowFlags f = 0);
virtual ~QmitkCandyStoreWidget();
virtual void CreateQtPartControl(QWidget *parent);
bool FillTreeList();
void UpdateTreeList(QStandardItem* item = NULL, berry::IWorkbenchPartReference* partRef=NULL, const std::string& changeId="");
- berry::IPerspectiveListener::Pointer m_PerspectiveListener;
+ berry::IPerspectiveListener::Pointer m_PerspectiveListener;
+ berry::IWindowListener::Pointer m_WindowListener;
public slots:
void CustomMenuRequested(QPoint pos);
void ItemClicked(const QModelIndex &index);
void AddPerspective();
void ClonePerspective();
void ResetPerspective();
void DeletePerspective();
void CloseAllPerspectives();
void ClosePerspective();
void ExpandAll();
void CollapseAll();
void FilterChanged();
protected:
// member variables
Ui::QmitkCandyStoreWidgetControls m_Controls;
QWidget* m_Parent;
QStandardItemModel* m_TreeModel;
ClassFilterProxyModel* m_FilterProxyModel;
QMenu* m_ContextMenu;
berry::IPerspectiveDescriptor::Pointer m_RegisteredPerspective;
- berry::IWindowListener::Pointer m_WindowListener;
-
private:
};
#endif // _QMITKCandyStoreWidget_H_INCLUDED
diff --git a/Plugins/org.mitk.gui.qt.ext/src/QmitkCandyStoreWidgetControls.ui b/Plugins/org.mitk.gui.qt.candystore/src/QmitkCandyStoreWidgetControls.ui
similarity index 100%
rename from Plugins/org.mitk.gui.qt.ext/src/QmitkCandyStoreWidgetControls.ui
rename to Plugins/org.mitk.gui.qt.candystore/src/QmitkCandyStoreWidgetControls.ui
diff --git a/Plugins/org.mitk.gui.qt.ext/src/QmitkNewPerspectiveDialog.cpp b/Plugins/org.mitk.gui.qt.candystore/src/QmitkNewPerspectiveDialog.cpp
similarity index 100%
rename from Plugins/org.mitk.gui.qt.ext/src/QmitkNewPerspectiveDialog.cpp
rename to Plugins/org.mitk.gui.qt.candystore/src/QmitkNewPerspectiveDialog.cpp
diff --git a/Plugins/org.mitk.gui.qt.ext/src/QmitkNewPerspectiveDialog.h b/Plugins/org.mitk.gui.qt.candystore/src/QmitkNewPerspectiveDialog.h
similarity index 100%
rename from Plugins/org.mitk.gui.qt.ext/src/QmitkNewPerspectiveDialog.h
rename to Plugins/org.mitk.gui.qt.candystore/src/QmitkNewPerspectiveDialog.h
diff --git a/Plugins/org.mitk.gui.qt.candystore/src/internal/CandyStoreView.cpp b/Plugins/org.mitk.gui.qt.candystore/src/internal/CandyStoreView.cpp
new file mode 100644
index 0000000000..1ad53d1f97
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.candystore/src/internal/CandyStoreView.cpp
@@ -0,0 +1,57 @@
+/*===================================================================
+
+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
+
+// Qmitk
+#include "CandyStoreView.h"
+
+// Qt
+#include
+
+//mitk image
+#include
+
+const std::string CandyStoreView::VIEW_ID = "org.mitk.views.candystoreview";
+
+void CandyStoreView::SetFocus()
+{
+
+}
+
+void CandyStoreView::CreateQtPartControl( QWidget *parent )
+{
+ // create GUI widgets from the Qt Designer's .ui file
+ m_Controls.setupUi( parent );
+
+
+
+// candyStore = new QDockWidget("Candy Store");
+// candyStore->setWidget(new QmitkCandyStoreWidget());
+// candyStore->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
+// candyStore->setVisible(false);
+// candyStore->setObjectName("Candy Store");
+// mainWindow->addDockWidget(Qt::LeftDockWidgetArea, candyStore);
+}
+
+void CandyStoreView::OnSelectionChanged( berry::IWorkbenchPart::Pointer /*source*/,
+ const QList& nodes )
+{
+
+}
diff --git a/Plugins/org.mitk.gui.qt.candystore/src/internal/CandyStoreView.h b/Plugins/org.mitk.gui.qt.candystore/src/internal/CandyStoreView.h
new file mode 100644
index 0000000000..2b49dc9247
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.candystore/src/internal/CandyStoreView.h
@@ -0,0 +1,64 @@
+/*===================================================================
+
+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 CandyStoreView_h
+#define CandyStoreView_h
+
+#include
+#include
+#include
+
+#include "ui_CandyStoreViewControls.h"
+
+
+/**
+ \brief CandyStoreView
+
+ \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 CandyStoreView : 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
+
+ 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::CandyStoreViewControls m_Controls;
+
+};
+
+#endif // CandyStoreView_h
diff --git a/Plugins/org.mitk.gui.qt.candystore/src/internal/CandyStoreViewControls.ui b/Plugins/org.mitk.gui.qt.candystore/src/internal/CandyStoreViewControls.ui
new file mode 100644
index 0000000000..4d663835b9
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.candystore/src/internal/CandyStoreViewControls.ui
@@ -0,0 +1,54 @@
+
+
+ CandyStoreViewControls
+
+
+
+ 0
+ 0
+ 222
+ 161
+
+
+
+
+ 0
+ 0
+
+
+
+ QmitkTemplate
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+ -
+
+
+
+
+
+
+
+ QmitkCandyStoreWidget
+ QWidget
+
+ 1
+
+
+
+
+
diff --git a/Plugins/org.mitk.gui.qt.ext/src/mitkQtViewItem.h b/Plugins/org.mitk.gui.qt.candystore/src/internal/org_mitk_gui_qt_candystore_Activator.cpp
similarity index 52%
copy from Plugins/org.mitk.gui.qt.ext/src/mitkQtViewItem.h
copy to Plugins/org.mitk.gui.qt.candystore/src/internal/org_mitk_gui_qt_candystore_Activator.cpp
index 04c2beeb80..cd04f1c6e5 100644
--- a/Plugins/org.mitk.gui.qt.ext/src/mitkQtViewItem.h
+++ b/Plugins/org.mitk.gui.qt.candystore/src/internal/org_mitk_gui_qt_candystore_Activator.cpp
@@ -1,49 +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 _ViewItem
-#define _ViewItem
-#include
-#include
-#include
+#include "org_mitk_gui_qt_candystore_Activator.h"
-namespace mitk
-{
+#include
-class QtViewItem : public QStandardItem
-{
-public:
- QtViewItem(QString string) :
- QStandardItem(string)
- {
- }
- QtViewItem(const QIcon& icon, QString string) :
- QStandardItem(icon, string)
- {
- }
+#include "CandyStoreView.h"
- berry::IViewDescriptor::Pointer m_View;
- std::vector m_Tags;
- QString m_Description;
+namespace mitk {
-private:
+void org_mitk_gui_qt_candystore_Activator::start(ctkPluginContext* context)
+{
+ BERRY_REGISTER_EXTENSION_CLASS(CandyStoreView, context)
+}
-};
+void org_mitk_gui_qt_candystore_Activator::stop(ctkPluginContext* context)
+{
+ Q_UNUSED(context)
+}
}
-#endif
+Q_EXPORT_PLUGIN2(org_mitk_gui_qt_candystore, mitk::org_mitk_gui_qt_candystore_Activator)
diff --git a/Plugins/org.mitk.gui.qt.ext/src/mitkQtViewItem.h b/Plugins/org.mitk.gui.qt.candystore/src/internal/org_mitk_gui_qt_candystore_Activator.h
similarity index 53%
copy from Plugins/org.mitk.gui.qt.ext/src/mitkQtViewItem.h
copy to Plugins/org.mitk.gui.qt.candystore/src/internal/org_mitk_gui_qt_candystore_Activator.h
index 04c2beeb80..d97e38fc8f 100644
--- a/Plugins/org.mitk.gui.qt.ext/src/mitkQtViewItem.h
+++ b/Plugins/org.mitk.gui.qt.candystore/src/internal/org_mitk_gui_qt_candystore_Activator.h
@@ -1,49 +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 _ViewItem
-#define _ViewItem
-#include
-#include
-#include
+#ifndef org_mitk_gui_qt_candystore_Activator_h
+#define org_mitk_gui_qt_candystore_Activator_h
-namespace mitk
-{
+#include
+
+namespace mitk {
-class QtViewItem : public QStandardItem
+class org_mitk_gui_qt_candystore_Activator :
+ public QObject, public ctkPluginActivator
{
-public:
- QtViewItem(QString string) :
- QStandardItem(string)
- {
- }
- QtViewItem(const QIcon& icon, QString string) :
- QStandardItem(icon, string)
- {
- }
+ Q_OBJECT
+ Q_INTERFACES(ctkPluginActivator)
- berry::IViewDescriptor::Pointer m_View;
- std::vector m_Tags;
- QString m_Description;
+public:
-private:
+ void start(ctkPluginContext* context);
+ void stop(ctkPluginContext* context);
-};
+}; // org_mitk_gui_qt_candystore_Activator
}
-#endif
+#endif // org_mitk_gui_qt_candystore_Activator_h
diff --git a/Plugins/org.mitk.gui.qt.ext/src/mitkQtPerspectiveItem.h b/Plugins/org.mitk.gui.qt.candystore/src/mitkQtPerspectiveItem.h
similarity index 100%
rename from Plugins/org.mitk.gui.qt.ext/src/mitkQtPerspectiveItem.h
rename to Plugins/org.mitk.gui.qt.candystore/src/mitkQtPerspectiveItem.h
diff --git a/Plugins/org.mitk.gui.qt.ext/src/mitkQtViewItem.h b/Plugins/org.mitk.gui.qt.candystore/src/mitkQtViewItem.h
similarity index 100%
rename from Plugins/org.mitk.gui.qt.ext/src/mitkQtViewItem.h
rename to Plugins/org.mitk.gui.qt.candystore/src/mitkQtViewItem.h
diff --git a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/QmitkDiffusionImagingAppWorkbenchAdvisor.cpp b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/QmitkDiffusionImagingAppWorkbenchAdvisor.cpp
index 7046505d06..2cab188697 100644
--- a/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/QmitkDiffusionImagingAppWorkbenchAdvisor.cpp
+++ b/Plugins/org.mitk.gui.qt.diffusionimagingapp/src/QmitkDiffusionImagingAppWorkbenchAdvisor.cpp
@@ -1,86 +1,85 @@
/*===================================================================
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 "QmitkDiffusionImagingAppWorkbenchAdvisor.h"
#include "internal/QmitkDiffusionApplicationPlugin.h"
#include
#include
#include
#include
#include
#include
const std::string QmitkDiffusionImagingAppWorkbenchAdvisor::WELCOME_PERSPECTIVE_ID = "org.mitk.diffusionimagingapp.perspectives.welcome";
void
QmitkDiffusionImagingAppWorkbenchAdvisor::Initialize(berry::IWorkbenchConfigurer::Pointer configurer)
{
berry::QtWorkbenchAdvisor::Initialize(configurer);
configurer->SetSaveAndRestore(true);
}
berry::WorkbenchWindowAdvisor*
QmitkDiffusionImagingAppWorkbenchAdvisor::CreateWorkbenchWindowAdvisor(
berry::IWorkbenchWindowConfigurer::Pointer configurer)
{
std::vector perspExcludeList;
perspExcludeList.push_back( std::string("org.blueberry.uitest.util.EmptyPerspective") );
perspExcludeList.push_back( std::string("org.blueberry.uitest.util.EmptyPerspective2") );
// perspExcludeList.push_back( std::string("org.mitk.coreapp.defaultperspective") );
//perspExcludeList.push_back( std::string("org.mitk.extapp.defaultperspective") );
perspExcludeList.push_back( std::string("org.mitk.perspectives.publicdiffusionimaging") );
perspExcludeList.push_back( std::string("org.mitk.perspectives.diffusionimaginginternal") );
// Exclude the help perspective from org.blueberry.ui.qt.help from
// the normal perspective list.
// The perspective gets a dedicated menu entry in the help menu
perspExcludeList.push_back("org.blueberry.perspectives.help");
std::vector viewExcludeList;
viewExcludeList.push_back( std::string("org.mitk.views.controlvisualizationpropertiesview") );
viewExcludeList.push_back( std::string("org.mitk.views.imagenavigator") );
// viewExcludeList.push_back( std::string("org.mitk.views.datamanager") );
viewExcludeList.push_back( std::string("org.mitk.views.modules") );
viewExcludeList.push_back( std::string("org.blueberry.ui.internal.introview") );
configurer->SetInitialSize(berry::Point(1000,770));
QmitkExtWorkbenchWindowAdvisor* advisor = new QmitkExtWorkbenchWindowAdvisor(this, configurer);
advisor->ShowViewMenuItem(true);
advisor->ShowNewWindowMenuItem(true);
advisor->ShowClosePerspectiveMenuItem(true);
advisor->SetPerspectiveExcludeList(perspExcludeList);
advisor->SetViewExcludeList(viewExcludeList);
advisor->ShowViewToolbar(false);
advisor->ShowPerspectiveToolbar(false);
advisor->ShowVersionInfo(false);
- advisor->EnableCandyStore(true);
advisor->ShowMitkVersionInfo(false);
advisor->ShowMemoryIndicator(false);
advisor->SetProductName("MITK Diffusion");
advisor->SetWindowIcon(":/org.mitk.gui.qt.diffusionimagingapp/app-icon.png");
return advisor;
}
std::string QmitkDiffusionImagingAppWorkbenchAdvisor::GetInitialWindowPerspectiveId()
{
return WELCOME_PERSPECTIVE_ID;
}
diff --git a/Plugins/org.mitk.gui.qt.ext/files.cmake b/Plugins/org.mitk.gui.qt.ext/files.cmake
index f4191da5d4..ba1181ca41 100644
--- a/Plugins/org.mitk.gui.qt.ext/files.cmake
+++ b/Plugins/org.mitk.gui.qt.ext/files.cmake
@@ -1,67 +1,58 @@
set(SRC_CPP_FILES
QmitkExtActionBarAdvisor.cpp
QmitkExtWorkbenchWindowAdvisor.cpp
QmitkExtFileSaveProjectAction.cpp
QmitkOpenDicomEditorAction.cpp
QmitkOpenXnatEditorAction.cpp
-
- QmitkCandyStoreWidget.cpp
- QmitkNewPerspectiveDialog.cpp
)
set(INTERNAL_CPP_FILES
QmitkAppInstancesPreferencePage.cpp
QmitkExternalProgramsPreferencePage.cpp
QmitkCommonExtPlugin.cpp
QmitkInputDevicesPrefPage.cpp
QmitkModuleView.cpp
)
set(UI_FILES
src/internal/QmitkAppInstancesPreferencePage.ui
src/internal/QmitkExternalProgramsPreferencePage.ui
- src/QmitkCandyStoreWidgetControls.ui
)
set(MOC_H_FILES
src/QmitkExtFileSaveProjectAction.h
src/QmitkExtWorkbenchWindowAdvisor.h
src/internal/QmitkAppInstancesPreferencePage.h
src/internal/QmitkExternalProgramsPreferencePage.h
src/internal/QmitkCommonExtPlugin.h
src/internal/QmitkExtWorkbenchWindowAdvisorHack.h
src/internal/QmitkInputDevicesPrefPage.h
src/internal/QmitkModuleView.h
src/QmitkOpenDicomEditorAction.h
src/QmitkOpenXnatEditorAction.h
-
- src/QmitkCandyStoreWidget.h
- src/mitkQtPerspectiveItem.h
- src/mitkQtViewItem.h
- src/QmitkNewPerspectiveDialog.h
)
set(CACHED_RESOURCE_FILES
# 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
plugin.xml
resources/ModuleView.png
)
set(QRC_FILES
# uncomment the following line if you want to use Qt resources
resources/org_mitk_gui_qt_ext.qrc
)
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.ext/src/QmitkExtWorkbenchWindowAdvisor.cpp b/Plugins/org.mitk.gui.qt.ext/src/QmitkExtWorkbenchWindowAdvisor.cpp
index 1945d37a05..6db9cb8e66 100644
--- a/Plugins/org.mitk.gui.qt.ext/src/QmitkExtWorkbenchWindowAdvisor.cpp
+++ b/Plugins/org.mitk.gui.qt.ext/src/QmitkExtWorkbenchWindowAdvisor.cpp
@@ -1,1264 +1,1322 @@
/*===================================================================
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 "QmitkExtWorkbenchWindowAdvisor.h"
#include "QmitkExtActionBarAdvisor.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
// UGLYYY
#include "internal/QmitkExtWorkbenchWindowAdvisorHack.h"
#include "internal/QmitkCommonExtPlugin.h"
#include "mitkUndoController.h"
#include "mitkVerboseLimitedLinearUndo.h"
#include
#include
#include
#include
QmitkExtWorkbenchWindowAdvisorHack
* QmitkExtWorkbenchWindowAdvisorHack::undohack =
new QmitkExtWorkbenchWindowAdvisorHack();
QString QmitkExtWorkbenchWindowAdvisor::QT_SETTINGS_FILENAME = "QtSettings.ini";
class PartListenerForTitle: public berry::IPartListener
{
public:
PartListenerForTitle(QmitkExtWorkbenchWindowAdvisor* wa) :
windowAdvisor(wa)
{
}
Events::Types GetPartEventTypes() const
{
return Events::ACTIVATED | Events::BROUGHT_TO_TOP | Events::CLOSED
| Events::HIDDEN | Events::VISIBLE;
}
void PartActivated(berry::IWorkbenchPartReference::Pointer ref)
{
if (ref.Cast ())
{
windowAdvisor->UpdateTitle(false);
}
}
void PartBroughtToTop(berry::IWorkbenchPartReference::Pointer ref)
{
if (ref.Cast ())
{
windowAdvisor->UpdateTitle(false);
}
}
void PartClosed(berry::IWorkbenchPartReference::Pointer /*ref*/)
{
windowAdvisor->UpdateTitle(false);
}
void PartHidden(berry::IWorkbenchPartReference::Pointer ref)
{
if (!windowAdvisor->lastActiveEditor.Expired() &&
ref->GetPart(false) == windowAdvisor->lastActiveEditor.Lock())
{
windowAdvisor->UpdateTitle(true);
}
}
void PartVisible(berry::IWorkbenchPartReference::Pointer ref)
{
if (!windowAdvisor->lastActiveEditor.Expired() &&
ref->GetPart(false) == windowAdvisor->lastActiveEditor.Lock())
{
windowAdvisor->UpdateTitle(false);
}
}
private:
QmitkExtWorkbenchWindowAdvisor* windowAdvisor;
};
+class PartListenerForCandyStore: public berry::IPartListener
+{
+public:
+
+ PartListenerForCandyStore(QAction* act) :
+ candyStoreAction(act)
+ {
+ }
+
+ Events::Types GetPartEventTypes() const
+ {
+ return Events::OPENED | Events::CLOSED | Events::HIDDEN |
+ Events::VISIBLE;
+ }
+
+ void PartOpened(berry::IWorkbenchPartReference::Pointer ref)
+ {
+ if (ref->GetId()=="org.mitk.views.candystoreview")
+ {
+ candyStoreAction->setChecked(true);
+ }
+ }
+
+ void PartClosed(berry::IWorkbenchPartReference::Pointer ref)
+ {
+ if (ref->GetId()=="org.mitk.views.candystoreview")
+ {
+ candyStoreAction->setChecked(false);
+ }
+ }
+
+ void PartVisible(berry::IWorkbenchPartReference::Pointer ref)
+ {
+ if (ref->GetId()=="org.mitk.views.candystoreview")
+ {
+ candyStoreAction->setChecked(true);
+ }
+ }
+
+ void PartHidden(berry::IWorkbenchPartReference::Pointer ref)
+ {
+ if (ref->GetId()=="org.mitk.views.candystoreview")
+ {
+ candyStoreAction->setChecked(false);
+ }
+ }
+
+private:
+ QAction* candyStoreAction;
+
+};
+
class PartListenerForImageNavigator: public berry::IPartListener
{
public:
PartListenerForImageNavigator(QAction* act) :
imageNavigatorAction(act)
{
}
Events::Types GetPartEventTypes() const
{
return Events::OPENED | Events::CLOSED | Events::HIDDEN |
Events::VISIBLE;
}
void PartOpened(berry::IWorkbenchPartReference::Pointer ref)
{
if (ref->GetId()=="org.mitk.views.imagenavigator")
{
imageNavigatorAction->setChecked(true);
}
}
void PartClosed(berry::IWorkbenchPartReference::Pointer ref)
{
if (ref->GetId()=="org.mitk.views.imagenavigator")
{
imageNavigatorAction->setChecked(false);
}
}
void PartVisible(berry::IWorkbenchPartReference::Pointer ref)
{
if (ref->GetId()=="org.mitk.views.imagenavigator")
{
imageNavigatorAction->setChecked(true);
}
}
void PartHidden(berry::IWorkbenchPartReference::Pointer ref)
{
if (ref->GetId()=="org.mitk.views.imagenavigator")
{
imageNavigatorAction->setChecked(false);
}
}
private:
QAction* imageNavigatorAction;
};
class PerspectiveListenerForTitle: public berry::IPerspectiveListener
{
public:
PerspectiveListenerForTitle(QmitkExtWorkbenchWindowAdvisor* wa) :
windowAdvisor(wa), perspectivesClosed(false)
{
}
Events::Types GetPerspectiveEventTypes() const
{
return Events::ACTIVATED | Events::SAVED_AS | Events::DEACTIVATED
// remove the following line when command framework is finished
| Events::CLOSED | Events::OPENED;
}
void PerspectiveActivated(berry::IWorkbenchPage::Pointer /*page*/,
berry::IPerspectiveDescriptor::Pointer /*perspective*/)
{
windowAdvisor->UpdateTitle(false);
}
void PerspectiveSavedAs(berry::IWorkbenchPage::Pointer /*page*/,
berry::IPerspectiveDescriptor::Pointer /*oldPerspective*/,
berry::IPerspectiveDescriptor::Pointer /*newPerspective*/)
{
windowAdvisor->UpdateTitle(false);
}
void PerspectiveDeactivated(berry::IWorkbenchPage::Pointer /*page*/,
berry::IPerspectiveDescriptor::Pointer /*perspective*/)
{
windowAdvisor->UpdateTitle(false);
}
void PerspectiveOpened(berry::IWorkbenchPage::Pointer /*page*/,
berry::IPerspectiveDescriptor::Pointer /*perspective*/)
{
if (perspectivesClosed)
{
QListIterator i(windowAdvisor->viewActions);
while (i.hasNext())
{
i.next()->setEnabled(true);
}
//GetViewRegistry()->Find("org.mitk.views.imagenavigator");
if(windowAdvisor->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.dicomeditor"))
{
windowAdvisor->openDicomEditorAction->setEnabled(true);
}
if(windowAdvisor->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.xnat.browser"))
{
windowAdvisor->openXnatEditorAction->setEnabled(true);
}
windowAdvisor->fileSaveProjectAction->setEnabled(true);
windowAdvisor->closeProjectAction->setEnabled(true);
windowAdvisor->undoAction->setEnabled(true);
windowAdvisor->redoAction->setEnabled(true);
windowAdvisor->imageNavigatorAction->setEnabled(true);
+ windowAdvisor->candyStoreAction->setEnabled(true);
windowAdvisor->resetPerspAction->setEnabled(true);
if( windowAdvisor->GetShowClosePerspectiveMenuItem() )
{
windowAdvisor->closePerspAction->setEnabled(true);
}
}
perspectivesClosed = false;
}
void PerspectiveClosed(berry::IWorkbenchPage::Pointer /*page*/,
berry::IPerspectiveDescriptor::Pointer /*perspective*/)
{
berry::IWorkbenchWindow::Pointer wnd = windowAdvisor->GetWindowConfigurer()->GetWindow();
bool allClosed = true;
if (wnd->GetActivePage())
{
std::vector perspectives(wnd->GetActivePage()->GetOpenPerspectives());
allClosed = perspectives.empty();
}
if (allClosed)
{
perspectivesClosed = true;
QListIterator i(windowAdvisor->viewActions);
while (i.hasNext())
{
i.next()->setEnabled(false);
}
if(windowAdvisor->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.dicomeditor"))
{
windowAdvisor->openDicomEditorAction->setEnabled(false);
}
if(windowAdvisor->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.xnat.browser"))
{
windowAdvisor->openXnatEditorAction->setEnabled(false);
}
windowAdvisor->fileSaveProjectAction->setEnabled(false);
windowAdvisor->closeProjectAction->setEnabled(false);
windowAdvisor->undoAction->setEnabled(false);
windowAdvisor->redoAction->setEnabled(false);
windowAdvisor->imageNavigatorAction->setEnabled(false);
+ windowAdvisor->candyStoreAction->setEnabled(false);
windowAdvisor->resetPerspAction->setEnabled(false);
if( windowAdvisor->GetShowClosePerspectiveMenuItem() )
{
windowAdvisor->closePerspAction->setEnabled(false);
}
}
}
private:
QmitkExtWorkbenchWindowAdvisor* windowAdvisor;
bool perspectivesClosed;
};
class PerspectiveListenerForMenu: public berry::IPerspectiveListener
{
public:
PerspectiveListenerForMenu(QmitkExtWorkbenchWindowAdvisor* wa) :
windowAdvisor(wa)
{
}
Events::Types GetPerspectiveEventTypes() const
{
return Events::ACTIVATED | Events::DEACTIVATED;
}
void PerspectiveActivated(berry::IWorkbenchPage::Pointer /*page*/,
berry::IPerspectiveDescriptor::Pointer perspective)
{
QAction* action = windowAdvisor->mapPerspIdToAction[perspective->GetId()];
if (action)
{
action->setChecked(true);
}
}
void PerspectiveDeactivated(berry::IWorkbenchPage::Pointer /*page*/,
berry::IPerspectiveDescriptor::Pointer perspective)
{
QAction* action = windowAdvisor->mapPerspIdToAction[perspective->GetId()];
if (action)
{
action->setChecked(false);
}
}
private:
QmitkExtWorkbenchWindowAdvisor* windowAdvisor;
};
QmitkExtWorkbenchWindowAdvisor::QmitkExtWorkbenchWindowAdvisor(berry::WorkbenchAdvisor* wbAdvisor,
berry::IWorkbenchWindowConfigurer::Pointer configurer) :
berry::WorkbenchWindowAdvisor(configurer),
lastInput(0),
wbAdvisor(wbAdvisor),
showViewToolbar(true),
showPerspectiveToolbar(false),
showVersionInfo(true),
showMitkVersionInfo(true),
showViewMenuItem(true),
showNewWindowMenuItem(false),
showClosePerspectiveMenuItem(true),
- enableCandyStore(true),
+ candyStoreFound(false),
showMemoryIndicator(true),
dropTargetListener(new QmitkDefaultDropTargetListener)
{
productName = QCoreApplication::applicationName().toStdString();
+ viewExcludeList.push_back("org.mitk.views.candystoreview");
}
berry::ActionBarAdvisor::Pointer QmitkExtWorkbenchWindowAdvisor::CreateActionBarAdvisor(
berry::IActionBarConfigurer::Pointer configurer)
{
berry::ActionBarAdvisor::Pointer actionBarAdvisor(
new QmitkExtActionBarAdvisor(configurer));
return actionBarAdvisor;
}
void* QmitkExtWorkbenchWindowAdvisor::CreateEmptyWindowContents(void* parent)
{
QWidget* parentWidget = static_cast(parent);
QLabel* label = new QLabel(parentWidget);
label->setText("No perspectives are open. Open a perspective in the Window->Open Perspective menu.");
label->setContentsMargins(10,10,10,10);
label->setAlignment(Qt::AlignTop);
label->setEnabled(false);
parentWidget->layout()->addWidget(label);
return label;
}
void QmitkExtWorkbenchWindowAdvisor::ShowClosePerspectiveMenuItem(bool show)
{
showClosePerspectiveMenuItem = show;
}
bool QmitkExtWorkbenchWindowAdvisor::GetShowClosePerspectiveMenuItem()
{
return showClosePerspectiveMenuItem;
}
void QmitkExtWorkbenchWindowAdvisor::ShowMemoryIndicator(bool show)
{
showMemoryIndicator = show;
}
bool QmitkExtWorkbenchWindowAdvisor::GetShowMemoryIndicator()
{
return showMemoryIndicator;
}
-void QmitkExtWorkbenchWindowAdvisor::EnableCandyStore(bool enable)
-{
- enableCandyStore = enable;
-}
-
-bool QmitkExtWorkbenchWindowAdvisor::GetEnableCandyStore()
-{
- return enableCandyStore;
-}
-
void QmitkExtWorkbenchWindowAdvisor::ShowNewWindowMenuItem(bool show)
{
showNewWindowMenuItem = show;
}
void QmitkExtWorkbenchWindowAdvisor::ShowViewToolbar(bool show)
{
showViewToolbar = show;
}
void QmitkExtWorkbenchWindowAdvisor::ShowViewMenuItem(bool show)
{
showViewMenuItem = show;
}
void QmitkExtWorkbenchWindowAdvisor::ShowPerspectiveToolbar(bool show)
{
showPerspectiveToolbar = show;
}
void QmitkExtWorkbenchWindowAdvisor::ShowVersionInfo(bool show)
{
showVersionInfo = show;
}
void QmitkExtWorkbenchWindowAdvisor::ShowMitkVersionInfo(bool show)
{
showMitkVersionInfo = show;
}
void QmitkExtWorkbenchWindowAdvisor::SetProductName(const std::string& product)
{
productName = product;
}
void QmitkExtWorkbenchWindowAdvisor::SetWindowIcon(const std::string& wndIcon)
{
windowIcon = wndIcon;
}
-void QmitkExtWorkbenchWindowAdvisor::onCandyStore()
-{
- candyStore->setVisible(candyStoreAction->isChecked());
-}
-
void QmitkExtWorkbenchWindowAdvisor::PostWindowCreate()
{
// very bad hack...
berry::IWorkbenchWindow::Pointer window =
this->GetWindowConfigurer()->GetWindow();
QMainWindow* mainWindow =
static_cast (window->GetShell()->GetControl());
window->SetPerspectiveExcludeList(perspectiveExcludeList);
window->SetViewExcludeList(viewExcludeList);
if (!windowIcon.empty())
{
mainWindow->setWindowIcon(QIcon(QString::fromStdString(windowIcon)));
}
mainWindow->setContextMenuPolicy(Qt::PreventContextMenu);
/*mainWindow->setStyleSheet("color: white;"
"background-color: #808080;"
"selection-color: #659EC7;"
"selection-background-color: #808080;"
" QMenuBar {"
"background-color: #808080; }");*/
// ==== Application menu ============================
QMenuBar* menuBar = mainWindow->menuBar();
menuBar->setContextMenuPolicy(Qt::PreventContextMenu);
QMenu* fileMenu = menuBar->addMenu("&File");
fileMenu->setObjectName("FileMenu");
QAction* fileOpenAction = new QmitkFileOpenAction(QIcon(":/org.mitk.gui.qt.ext/Load_48.png"), window);
fileMenu->addAction(fileOpenAction);
fileSaveProjectAction = new QmitkExtFileSaveProjectAction(window);
fileSaveProjectAction->setIcon(QIcon(":/org.mitk.gui.qt.ext/Save_48.png"));
fileMenu->addAction(fileSaveProjectAction);
closeProjectAction = new QmitkCloseProjectAction(window);
closeProjectAction->setIcon(QIcon(":/org.mitk.gui.qt.ext/Remove_48.png"));
fileMenu->addAction(closeProjectAction);
fileMenu->addSeparator();
QAction* fileExitAction = new QmitkFileExitAction(window);
fileExitAction->setObjectName("QmitkFileExitAction");
fileMenu->addAction(fileExitAction);
if(this->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.dicomeditor"))
{
openDicomEditorAction = new QmitkOpenDicomEditorAction(QIcon(":/org.mitk.gui.qt.ext/dcm-icon.png"),window);
}
if(this->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.xnat.browser"))
{
openXnatEditorAction = new QmitkOpenXnatEditorAction(QIcon(":/org.mitk.gui.qt.ext/xnat-icon.png"),window);
}
berry::IViewRegistry* viewRegistry =
berry::PlatformUI::GetWorkbench()->GetViewRegistry();
const std::vector& viewDescriptors =
viewRegistry->GetViews();
// another bad hack to get an edit/undo menu...
QMenu* editMenu = menuBar->addMenu("&Edit");
undoAction = editMenu->addAction(QIcon(":/org.mitk.gui.qt.ext/Undo_48.png"),
"&Undo",
QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onUndo()),
QKeySequence("CTRL+Z"));
undoAction->setToolTip("Undo the last action (not supported by all modules)");
redoAction = editMenu->addAction(QIcon(":/org.mitk.gui.qt.ext/Redo_48.png")
, "&Redo",
QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onRedo()),
QKeySequence("CTRL+Y"));
redoAction->setToolTip("execute the last action that was undone again (not supported by all modules)");
imageNavigatorAction = new QAction(QIcon(":/org.mitk.gui.qt.ext/Slider.png"), "&Image Navigator", NULL);
bool imageNavigatorViewFound = window->GetWorkbench()->GetViewRegistry()->Find("org.mitk.views.imagenavigator");
if (imageNavigatorViewFound)
{
QObject::connect(imageNavigatorAction, SIGNAL(triggered(bool)), QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onImageNavigator()));
imageNavigatorAction->setCheckable(true);
// add part listener for image navigator
imageNavigatorPartListener = new PartListenerForImageNavigator(imageNavigatorAction);
window->GetPartService()->AddPartListener(imageNavigatorPartListener);
berry::IViewPart::Pointer imageNavigatorView =
window->GetActivePage()->FindView("org.mitk.views.imagenavigator");
imageNavigatorAction->setChecked(false);
if (imageNavigatorView)
{
bool isImageNavigatorVisible = window->GetActivePage()->IsPartVisible(imageNavigatorView);
if (isImageNavigatorVisible)
imageNavigatorAction->setChecked(true);
}
imageNavigatorAction->setToolTip("Toggle image navigator for navigating through image");
}
+ candyStoreAction = new QAction(QIcon(":/org.mitk.gui.qt.ext/Candy_icon.png"), "&Candy Store", NULL);
+ candyStoreFound = window->GetWorkbench()->GetViewRegistry()->Find("org.mitk.views.candystoreview");
+ if (candyStoreFound)
+ {
+ QObject::connect(candyStoreAction, SIGNAL(triggered(bool)), QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onCandyStore()));
+ candyStoreAction->setCheckable(true);
+
+ // add part listener for candy store
+ candyStorePartListener = new PartListenerForCandyStore(candyStoreAction);
+ window->GetPartService()->AddPartListener(candyStorePartListener);
+ berry::IViewPart::Pointer candystoreview =
+ window->GetActivePage()->FindView("org.mitk.views.candystoreview");
+ candyStoreAction->setChecked(false);
+ if (candystoreview)
+ {
+ bool isCandyStoreVisible = window->GetActivePage()->IsPartVisible(candystoreview);
+ if (isCandyStoreVisible)
+ candyStoreAction->setChecked(true);
+ }
+ candyStoreAction->setToolTip("Toggle Candy Store");
+ }
+
// toolbar for showing file open, undo, redo and other main actions
QToolBar* mainActionsToolBar = new QToolBar;
mainActionsToolBar->setObjectName("mainActionsToolBar");
mainActionsToolBar->setContextMenuPolicy(Qt::PreventContextMenu);
#ifdef __APPLE__
mainActionsToolBar->setToolButtonStyle ( Qt::ToolButtonTextUnderIcon );
#else
mainActionsToolBar->setToolButtonStyle ( Qt::ToolButtonTextBesideIcon );
#endif
mainActionsToolBar->addAction(fileOpenAction);
mainActionsToolBar->addAction(fileSaveProjectAction);
mainActionsToolBar->addAction(closeProjectAction);
mainActionsToolBar->addAction(undoAction);
mainActionsToolBar->addAction(redoAction);
if(this->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.dicomeditor"))
{
mainActionsToolBar->addAction(openDicomEditorAction);
}
if(this->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.xnat.browser"))
{
mainActionsToolBar->addAction(openXnatEditorAction);
}
if (imageNavigatorViewFound)
{
mainActionsToolBar->addAction(imageNavigatorAction);
}
-
- if (enableCandyStore)
- {
- candyStoreAction = new QAction(QIcon(":/org.mitk.gui.qt.ext/Candy_icon.png"), "&Candy Store", NULL);
- QObject::connect(candyStoreAction, SIGNAL(triggered(bool)), SLOT(onCandyStore()));
- candyStoreAction->setCheckable(true);
- candyStoreAction->setChecked(false);
- candyStoreAction->setToolTip("Toggle Candy Store");
+ if (candyStoreFound)
mainActionsToolBar->addAction(candyStoreAction);
- }
+
mainWindow->addToolBar(mainActionsToolBar);
#ifdef __APPLE__
mainWindow->setUnifiedTitleAndToolBarOnMac(true);
#endif
// ==== Window Menu ==========================
QMenu* windowMenu = menuBar->addMenu("Window");
if (showNewWindowMenuItem)
{
windowMenu->addAction("&New Window", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onNewWindow()));
windowMenu->addSeparator();
}
QMenu* perspMenu = windowMenu->addMenu("&Open Perspective");
QMenu* viewMenu;
if (showViewMenuItem)
{
viewMenu = windowMenu->addMenu("Show &View");
viewMenu->setObjectName("Show View");
}
windowMenu->addSeparator();
resetPerspAction = windowMenu->addAction("&Reset Perspective",
QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onResetPerspective()));
if(showClosePerspectiveMenuItem)
closePerspAction = windowMenu->addAction("&Close Perspective", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onClosePerspective()));
windowMenu->addSeparator();
windowMenu->addAction("&Preferences...",
QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onEditPreferences()),
QKeySequence("CTRL+P"));
// fill perspective menu
berry::IPerspectiveRegistry* perspRegistry =
window->GetWorkbench()->GetPerspectiveRegistry();
QActionGroup* perspGroup = new QActionGroup(menuBar);
std::vector perspectives(
perspRegistry->GetPerspectives());
bool skip = false;
for (std::vector::iterator perspIt =
perspectives.begin(); perspIt != perspectives.end(); ++perspIt)
{
// 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));
}
perspMenu->addActions(perspGroup->actions());
// sort elements (converting vector to map...)
std::vector::const_iterator iter;
std::map VDMap;
skip = false;
for (iter = viewDescriptors.begin(); iter != viewDescriptors.end(); ++iter)
{
// if viewExcludeList is set, it contains the id-strings of view, which
// should not appear as an menu-entry in the menu
if (viewExcludeList.size() > 0)
{
for (unsigned int i=0; iGetId())
{
skip = true;
break;
}
}
if (skip)
{
skip = false;
continue;
}
}
if ((*iter)->GetId() == "org.blueberry.ui.internal.introview")
continue;
if ((*iter)->GetId() == "org.mitk.views.imagenavigator")
continue;
+ if ((*iter)->GetId() == "org.mitk.views.candystoreview")
+ continue;
std::pair p(
(*iter)->GetLabel(), (*iter));
VDMap.insert(p);
}
- // ==================================================
// ==== Perspective Toolbar ==================================
QToolBar* qPerspectiveToolbar = new QToolBar;
qPerspectiveToolbar->setObjectName("perspectiveToolBar");
if (showPerspectiveToolbar)
{
qPerspectiveToolbar->addActions(perspGroup->actions());
mainWindow->addToolBar(qPerspectiveToolbar);
}
else
delete qPerspectiveToolbar;
// ==== View Toolbar ==================================
QToolBar* qToolbar = new QToolBar;
qToolbar->setObjectName("viewToolBar");
std::map::const_iterator
MapIter;
for (MapIter = VDMap.begin(); MapIter != VDMap.end(); ++MapIter)
{
berry::QtShowViewAction* viewAction = new berry::QtShowViewAction(window,
(*MapIter).second);
viewActions.push_back(viewAction);
if(showViewMenuItem)
viewMenu->addAction(viewAction);
if (showViewToolbar)
{
qToolbar->addAction(viewAction);
}
}
if (showViewToolbar)
{
mainWindow->addToolBar(qToolbar);
}
else
delete qToolbar;
QSettings settings(GetQSettingsFile(), QSettings::IniFormat);
mainWindow->restoreState(settings.value("ToolbarPosition").toByteArray());
-
- // ====================================================
-
// ===== Help menu ====================================
QMenu* helpMenu = menuBar->addMenu("&Help");
helpMenu->addAction("&Welcome",this, SLOT(onIntro()));
helpMenu->addAction("&Open Help Perspective", this, SLOT(onHelpOpenHelpPerspective()));
helpMenu->addAction("&Context Help",this, SLOT(onHelp()), QKeySequence("F1"));
helpMenu->addAction("&About",this, SLOT(onAbout()));
// =====================================================
-
QStatusBar* qStatusBar = new QStatusBar();
//creating a QmitkStatusBar for Output on the QStatusBar and connecting it with the MainStatusBar
QmitkStatusBar *statusBar = new QmitkStatusBar(qStatusBar);
//disabling the SizeGrip in the lower right corner
statusBar->SetSizeGripEnabled(false);
-
-
QmitkProgressBar *progBar = new QmitkProgressBar();
qStatusBar->addPermanentWidget(progBar, 0);
progBar->hide();
// progBar->AddStepsToDo(2);
// progBar->Progress(1);
mainWindow->setStatusBar(qStatusBar);
-// QLabel* label = new QLabel();
-// label->setText(" Candy Store");
- candyStore = new QDockWidget("Candy Store");
- candyStore->setWidget(new QmitkCandyStoreWidget());
- candyStore->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
- candyStore->setVisible(false);
- candyStore->setObjectName("Candy Store");
-// candyStore->setTitleBarWidget(label);
- mainWindow->addDockWidget(Qt::LeftDockWidgetArea, candyStore);
-
if (showMemoryIndicator)
{
QmitkMemoryUsageIndicatorView* memoryIndicator = new QmitkMemoryUsageIndicatorView();
qStatusBar->addPermanentWidget(memoryIndicator, 0);
}
}
void QmitkExtWorkbenchWindowAdvisor::PreWindowOpen()
{
berry::IWorkbenchWindowConfigurer::Pointer configurer = GetWindowConfigurer();
// show the shortcut bar and progress indicator, which are hidden by
// default
//configurer->SetShowPerspectiveBar(true);
//configurer->SetShowFastViewBars(true);
//configurer->SetShowProgressIndicator(true);
// // add the drag and drop support for the editor area
// configurer.addEditorAreaTransfer(EditorInputTransfer.getInstance());
// configurer.addEditorAreaTransfer(ResourceTransfer.getInstance());
// configurer.addEditorAreaTransfer(FileTransfer.getInstance());
// configurer.addEditorAreaTransfer(MarkerTransfer.getInstance());
// configurer.configureEditorAreaDropListener(new EditorAreaDropAdapter(
// configurer.getWindow()));
this->HookTitleUpdateListeners(configurer);
menuPerspectiveListener = new PerspectiveListenerForMenu(this);
configurer->GetWindow()->AddPerspectiveListener(menuPerspectiveListener);
configurer->AddEditorAreaTransfer(QStringList("text/uri-list"));
configurer->ConfigureEditorAreaDropListener(dropTargetListener);
}
void QmitkExtWorkbenchWindowAdvisor::PostWindowOpen()
{
// Force Rendering Window Creation on startup.
berry::IWorkbenchWindowConfigurer::Pointer configurer = GetWindowConfigurer();
ctkPluginContext* context = QmitkCommonExtPlugin::getContext();
ctkServiceReference serviceRef = context->getServiceReference();
if (serviceRef)
{
mitk::IDataStorageService *dsService = context->getService(serviceRef);
if (dsService)
{
mitk::IDataStorageReference::Pointer dsRef = dsService->GetDataStorage();
mitk::DataStorageEditorInput::Pointer dsInput(new mitk::DataStorageEditorInput(dsRef));
mitk::WorkbenchUtil::OpenEditor(configurer->GetWindow()->GetActivePage(),dsInput);
}
}
}
void QmitkExtWorkbenchWindowAdvisor::onIntro()
{
QmitkExtWorkbenchWindowAdvisorHack::undohack->onIntro();
}
void QmitkExtWorkbenchWindowAdvisor::onHelp()
{
QmitkExtWorkbenchWindowAdvisorHack::undohack->onHelp();
}
void QmitkExtWorkbenchWindowAdvisor::onHelpOpenHelpPerspective()
{
QmitkExtWorkbenchWindowAdvisorHack::undohack->onHelpOpenHelpPerspective();
}
void QmitkExtWorkbenchWindowAdvisor::onAbout()
{
QmitkExtWorkbenchWindowAdvisorHack::undohack->onAbout();
}
//--------------------------------------------------------------------------------
// Ugly hack from here on. Feel free to delete when command framework
// and undo buttons are done.
//--------------------------------------------------------------------------------
QmitkExtWorkbenchWindowAdvisorHack::QmitkExtWorkbenchWindowAdvisorHack() : QObject()
{
}
QmitkExtWorkbenchWindowAdvisorHack::~QmitkExtWorkbenchWindowAdvisorHack()
{
}
void QmitkExtWorkbenchWindowAdvisorHack::onUndo()
{
mitk::UndoModel* model = mitk::UndoController::GetCurrentUndoModel();
if (model)
{
if (mitk::VerboseLimitedLinearUndo* verboseundo = dynamic_cast( model ))
{
mitk::VerboseLimitedLinearUndo::StackDescription descriptions =
verboseundo->GetUndoDescriptions();
if (descriptions.size() >= 1)
{
MITK_INFO << "Undo " << descriptions.front().second;
}
}
model->Undo();
}
else
{
MITK_ERROR << "No undo model instantiated";
}
}
void QmitkExtWorkbenchWindowAdvisorHack::onRedo()
{
mitk::UndoModel* model = mitk::UndoController::GetCurrentUndoModel();
if (model)
{
if (mitk::VerboseLimitedLinearUndo* verboseundo = dynamic_cast( model ))
{
mitk::VerboseLimitedLinearUndo::StackDescription descriptions =
verboseundo->GetRedoDescriptions();
if (descriptions.size() >= 1)
{
MITK_INFO << "Redo " << descriptions.front().second;
}
}
model->Redo();
}
else
{
MITK_ERROR << "No undo model instantiated";
}
}
void QmitkExtWorkbenchWindowAdvisorHack::onImageNavigator()
{
// get ImageNavigatorView
berry::IViewPart::Pointer imageNavigatorView =
berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->FindView("org.mitk.views.imagenavigator");
if (imageNavigatorView)
{
bool isImageNavigatorVisible = berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->IsPartVisible(imageNavigatorView);
if (isImageNavigatorVisible)
{
berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->HideView(imageNavigatorView);
return;
}
}
berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->ShowView("org.mitk.views.imagenavigator");
//berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->ResetPerspective();
}
+void QmitkExtWorkbenchWindowAdvisorHack::onCandyStore()
+{
+ // get candystoreView
+ berry::IViewPart::Pointer candystoreView =
+ berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->FindView("org.mitk.views.candystoreview");
+ if (candystoreView)
+ {
+ bool iscandystoreVisible = berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->IsPartVisible(candystoreView);
+ if (iscandystoreVisible)
+ {
+ berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->HideView(candystoreView);
+ return;
+ }
+ }
+ berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->ShowView("org.mitk.views.candystoreview");
+ //berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->ResetPerspective();
+}
+
void QmitkExtWorkbenchWindowAdvisorHack::onEditPreferences()
{
QmitkPreferencesDialog _PreferencesDialog(QApplication::activeWindow());
_PreferencesDialog.exec();
}
void QmitkExtWorkbenchWindowAdvisorHack::onQuit()
{
berry::PlatformUI::GetWorkbench()->Close();
}
void QmitkExtWorkbenchWindowAdvisorHack::onResetPerspective()
{
berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->ResetPerspective();
}
void QmitkExtWorkbenchWindowAdvisorHack::onClosePerspective()
{
berry::IWorkbenchPage::Pointer
page =
berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage();
page->ClosePerspective(page->GetPerspective(), true, true);
}
void QmitkExtWorkbenchWindowAdvisorHack::onNewWindow()
{
berry::PlatformUI::GetWorkbench()->OpenWorkbenchWindow(0);
}
void QmitkExtWorkbenchWindowAdvisorHack::onIntro()
{
bool hasIntro =
berry::PlatformUI::GetWorkbench()->GetIntroManager()->HasIntro();
if (!hasIntro)
{
QRegExp reg("(.*)(\\n)*");
QRegExp reg2("(\\n)*(.*)");
QFile file(":/org.mitk.gui.qt.ext/index.html");
file.open(QIODevice::ReadOnly | QIODevice::Text); //text file only for reading
QString text = QString(file.readAll());
file.close();
QString title = text;
title.replace(reg, "");
title.replace(reg2, "");
std::cout << title.toStdString() << std::endl;
QMessageBox::information(NULL, title,
text, "Close");
}
else
{
berry::PlatformUI::GetWorkbench()->GetIntroManager()->ShowIntro(
berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow(), false);
}
}
void QmitkExtWorkbenchWindowAdvisorHack::onHelp()
{
ctkPluginContext* context = QmitkCommonExtPlugin::getContext();
if (context == 0)
{
MITK_WARN << "Plugin context not set, unable to open context help";
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")
{
if (p->getState() != ctkPlugin::ACTIVE)
{
// try to activate the plug-in explicitly
try
{
p->start(ctkPlugin::START_TRANSIENT);
}
catch (const ctkPluginException& pe)
{
MITK_ERROR << "Activating org.blueberry.ui.qt.help failed: " << pe.what();
return;
}
}
}
}
ctkServiceReference eventAdminRef = context->getServiceReference();
ctkEventAdmin* eventAdmin = 0;
if (eventAdminRef)
{
eventAdmin = context->getService(eventAdminRef);
}
if (eventAdmin == 0)
{
MITK_WARN << "ctkEventAdmin service not found. Unable to open context help";
}
else
{
ctkEvent ev("org/blueberry/ui/help/CONTEXTHELP_REQUESTED");
eventAdmin->postEvent(ev);
}
}
void QmitkExtWorkbenchWindowAdvisorHack::onHelpOpenHelpPerspective()
{
berry::PlatformUI::GetWorkbench()->ShowPerspective("org.blueberry.perspectives.help",
berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow());
}
void QmitkExtWorkbenchWindowAdvisorHack::onAbout()
{
QmitkAboutDialog* aboutDialog = new QmitkAboutDialog(QApplication::activeWindow(),NULL);
aboutDialog->open();
}
void QmitkExtWorkbenchWindowAdvisor::HookTitleUpdateListeners(
berry::IWorkbenchWindowConfigurer::Pointer configurer)
{
// hook up the listeners to update the window title
titlePartListener = new PartListenerForTitle(this);
titlePerspectiveListener = new PerspectiveListenerForTitle(this);
editorPropertyListener = new berry::PropertyChangeIntAdapter<
QmitkExtWorkbenchWindowAdvisor>(this,
&QmitkExtWorkbenchWindowAdvisor::PropertyChange);
// configurer.getWindow().addPageListener(new IPageListener() {
// public void pageActivated(IWorkbenchPage page) {
// updateTitle(false);
// }
//
// public void pageClosed(IWorkbenchPage page) {
// updateTitle(false);
// }
//
// public void pageOpened(IWorkbenchPage page) {
// // do nothing
// }
// });
configurer->GetWindow()->AddPerspectiveListener(titlePerspectiveListener);
configurer->GetWindow()->GetPartService()->AddPartListener(titlePartListener);
}
std::string QmitkExtWorkbenchWindowAdvisor::ComputeTitle()
{
berry::IWorkbenchWindowConfigurer::Pointer configurer =
GetWindowConfigurer();
berry::IWorkbenchPage::Pointer currentPage =
configurer->GetWindow()->GetActivePage();
berry::IEditorPart::Pointer activeEditor;
if (currentPage)
{
activeEditor = lastActiveEditor.Lock();
}
std::string title;
//TODO Product
// IProduct product = Platform.getProduct();
// if (product != null) {
// title = product.getName();
// }
// instead of the product name, we use a custom variable for now
title = productName;
if(showMitkVersionInfo)
{
title += std::string(" ") + MITK_VERSION_STRING;
}
if (showVersionInfo)
{
// add version informatioin
QString versions = QString(" (ITK %1.%2.%3 VTK %4.%5.%6 Qt %7 MITK %8)")
.arg(ITK_VERSION_MAJOR).arg(ITK_VERSION_MINOR).arg(ITK_VERSION_PATCH)
.arg(VTK_MAJOR_VERSION).arg(VTK_MINOR_VERSION).arg(VTK_BUILD_VERSION)
.arg(QT_VERSION_STR)
.arg(MITK_VERSION_STRING);
title += versions.toStdString();
}
if (currentPage)
{
if (activeEditor)
{
lastEditorTitle = activeEditor->GetTitleToolTip();
if (!lastEditorTitle.empty())
title = lastEditorTitle + " - " + title;
}
berry::IPerspectiveDescriptor::Pointer persp =
currentPage->GetPerspective();
std::string label = "";
if (persp)
{
label = persp->GetLabel();
}
berry::IAdaptable* input = currentPage->GetInput();
if (input && input != wbAdvisor->GetDefaultPageInput())
{
label = currentPage->GetLabel();
}
if (!label.empty())
{
title = label + " - " + title;
}
}
title += " (Not for use in diagnosis or treatment of patients)";
return title;
}
void QmitkExtWorkbenchWindowAdvisor::RecomputeTitle()
{
berry::IWorkbenchWindowConfigurer::Pointer configurer =
GetWindowConfigurer();
std::string oldTitle = configurer->GetTitle();
std::string newTitle = ComputeTitle();
if (newTitle != oldTitle)
{
configurer->SetTitle(newTitle);
}
}
void QmitkExtWorkbenchWindowAdvisor::UpdateTitle(bool editorHidden)
{
berry::IWorkbenchWindowConfigurer::Pointer configurer =
GetWindowConfigurer();
berry::IWorkbenchWindow::Pointer window = configurer->GetWindow();
berry::IEditorPart::Pointer activeEditor;
berry::IWorkbenchPage::Pointer currentPage = window->GetActivePage();
berry::IPerspectiveDescriptor::Pointer persp;
berry::IAdaptable* input = 0;
if (currentPage)
{
activeEditor = currentPage->GetActiveEditor();
persp = currentPage->GetPerspective();
input = currentPage->GetInput();
}
if (editorHidden)
{
activeEditor = 0;
}
// Nothing to do if the editor hasn't changed
if (activeEditor == lastActiveEditor.Lock() && currentPage == lastActivePage.Lock()
&& persp == lastPerspective.Lock() && input == lastInput)
{
return;
}
if (!lastActiveEditor.Expired())
{
lastActiveEditor.Lock()->RemovePropertyListener(editorPropertyListener);
}
lastActiveEditor = activeEditor;
lastActivePage = currentPage;
lastPerspective = persp;
lastInput = input;
if (activeEditor)
{
activeEditor->AddPropertyListener(editorPropertyListener);
}
RecomputeTitle();
}
void QmitkExtWorkbenchWindowAdvisor::PropertyChange(berry::Object::Pointer /*source*/, int propId)
{
if (propId == berry::IWorkbenchPartConstants::PROP_TITLE)
{
if (!lastActiveEditor.Expired())
{
std::string newTitle = lastActiveEditor.Lock()->GetPartName();
if (lastEditorTitle != newTitle)
{
RecomputeTitle();
}
}
}
}
void QmitkExtWorkbenchWindowAdvisor::SetPerspectiveExcludeList(std::vector v)
{
this->perspectiveExcludeList = v;
}
std::vector QmitkExtWorkbenchWindowAdvisor::GetPerspectiveExcludeList()
{
return this->perspectiveExcludeList;
}
void QmitkExtWorkbenchWindowAdvisor::SetViewExcludeList(std::vector v)
{
this->viewExcludeList = v;
}
std::vector QmitkExtWorkbenchWindowAdvisor::GetViewExcludeList()
{
return this->viewExcludeList;
}
void QmitkExtWorkbenchWindowAdvisor::PostWindowClose()
{
berry::IWorkbenchWindow::Pointer window = this->GetWindowConfigurer()->GetWindow();
QMainWindow* mainWindow = static_cast (window->GetShell()->GetControl());
QSettings settings(GetQSettingsFile(), QSettings::IniFormat);
settings.setValue("ToolbarPosition", mainWindow->saveState());
}
QString QmitkExtWorkbenchWindowAdvisor::GetQSettingsFile() const
{
QFileInfo settingsInfo = QmitkCommonExtPlugin::getContext()->getDataFile(QT_SETTINGS_FILENAME);
return settingsInfo.canonicalFilePath();
}
diff --git a/Plugins/org.mitk.gui.qt.ext/src/QmitkExtWorkbenchWindowAdvisor.h b/Plugins/org.mitk.gui.qt.ext/src/QmitkExtWorkbenchWindowAdvisor.h
index f79da801a3..a85e8c04dd 100644
--- a/Plugins/org.mitk.gui.qt.ext/src/QmitkExtWorkbenchWindowAdvisor.h
+++ b/Plugins/org.mitk.gui.qt.ext/src/QmitkExtWorkbenchWindowAdvisor.h
@@ -1,185 +1,178 @@
/*===================================================================
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 QMITKEXTWORKBENCHWINDOWADVISOR_H_
#define QMITKEXTWORKBENCHWINDOWADVISOR_H_
#include
#include
#include
#include
#include
#include
#include
#include
-#include
-#include
class QAction;
class QMenu;
class MITK_QT_COMMON_EXT_EXPORT QmitkExtWorkbenchWindowAdvisor : public QObject, public berry::WorkbenchWindowAdvisor
{
Q_OBJECT
public:
QmitkExtWorkbenchWindowAdvisor(berry::WorkbenchAdvisor* wbAdvisor,
berry::IWorkbenchWindowConfigurer::Pointer configurer);
berry::ActionBarAdvisor::Pointer CreateActionBarAdvisor(
berry::IActionBarConfigurer::Pointer configurer);
void* CreateEmptyWindowContents(void* parent);
void PostWindowCreate();
void PreWindowOpen();
void PostWindowOpen();
void PostWindowClose();
void ShowViewToolbar(bool show);
void ShowPerspectiveToolbar(bool show);
void ShowVersionInfo(bool show);
void ShowMitkVersionInfo(bool show);
void ShowViewMenuItem(bool show);
void ShowNewWindowMenuItem(bool show);
void ShowClosePerspectiveMenuItem(bool show);
bool GetShowClosePerspectiveMenuItem();
- void EnableCandyStore(bool enable);
-
- bool GetEnableCandyStore();
-
void ShowMemoryIndicator(bool show);
bool GetShowMemoryIndicator();
//TODO should be removed when product support is here
void SetProductName(const std::string& product);
void SetWindowIcon(const std::string& wndIcon);
void SetPerspectiveExcludeList(std::vector v);
std::vector GetPerspectiveExcludeList();
void SetViewExcludeList(std::vector v);
std::vector GetViewExcludeList();
protected slots:
virtual void onIntro();
virtual void onHelp();
virtual void onHelpOpenHelpPerspective();
virtual void onAbout();
- void onCandyStore();
private:
/**
* Hooks the listeners needed on the window
*
* @param configurer
*/
void HookTitleUpdateListeners(berry::IWorkbenchWindowConfigurer::Pointer configurer);
std::string ComputeTitle();
void RecomputeTitle();
QString GetQSettingsFile() const;
/**
* Updates the window title. Format will be: [pageInput -]
* [currentPerspective -] [editorInput -] [workspaceLocation -] productName
* @param editorHidden TODO
*/
void UpdateTitle(bool editorHidden);
void PropertyChange(berry::Object::Pointer /*source*/, int propId);
static QString QT_SETTINGS_FILENAME;
berry::IPartListener::Pointer titlePartListener;
berry::IPerspectiveListener::Pointer titlePerspectiveListener;
berry::IPerspectiveListener::Pointer menuPerspectiveListener;
berry::IPartListener::Pointer imageNavigatorPartListener;
- berry::IPartListener::Pointer CandyStorePartListener;
+ berry::IPartListener::Pointer candyStorePartListener;
berry::IPropertyChangeListener::Pointer editorPropertyListener;
friend struct berry::PropertyChangeIntAdapter;
friend class PartListenerForTitle;
friend class PerspectiveListenerForTitle;
friend class PerspectiveListenerForMenu;
friend class PartListenerForImageNavigator;
+ friend class PartListenerForCandyStore;
berry::IEditorPart::WeakPtr lastActiveEditor;
berry::IPerspectiveDescriptor::WeakPtr lastPerspective;
berry::IWorkbenchPage::WeakPtr lastActivePage;
std::string lastEditorTitle;
berry::IAdaptable* lastInput;
berry::WorkbenchAdvisor* wbAdvisor;
bool showViewToolbar;
bool showPerspectiveToolbar;
bool showVersionInfo;
bool showMitkVersionInfo;
bool showViewMenuItem;
bool showNewWindowMenuItem;
bool showClosePerspectiveMenuItem;
- bool enableCandyStore;
+ bool candyStoreFound;
bool showMemoryIndicator;
std::string productName;
std::string windowIcon;
// enables DnD on the editor area
berry::IDropTargetListener::Pointer dropTargetListener;
// stringlist for excluding perspectives from the perspective menu entry (e.g. Welcome Perspective)
std::vector perspectiveExcludeList;
// stringlist for excluding views from the menu entry
std::vector viewExcludeList;
// maps perspective ids to QAction objects
std::map mapPerspIdToAction;
// actions which will be enabled/disabled depending on the application state
QList viewActions;
QAction* fileSaveProjectAction;
QAction* closeProjectAction;
QAction* undoAction;
QAction* redoAction;
QAction* imageNavigatorAction;
QAction* candyStoreAction;
QAction* resetPerspAction;
QAction* closePerspAction;
QAction* openDicomEditorAction;
QAction* openXnatEditorAction;
- QDockWidget* candyStore;
};
#endif /*QMITKEXTWORKBENCHWINDOWADVISOR_H_*/
diff --git a/Plugins/org.mitk.gui.qt.ext/src/internal/QmitkExtWorkbenchWindowAdvisorHack.h b/Plugins/org.mitk.gui.qt.ext/src/internal/QmitkExtWorkbenchWindowAdvisorHack.h
index 96f8edb1d1..a994eb806f 100644
--- a/Plugins/org.mitk.gui.qt.ext/src/internal/QmitkExtWorkbenchWindowAdvisorHack.h
+++ b/Plugins/org.mitk.gui.qt.ext/src/internal/QmitkExtWorkbenchWindowAdvisorHack.h
@@ -1,58 +1,59 @@
/*===================================================================
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
class ctkPluginContext;
class QmitkPreferencesDialog;
class QmitkExtWorkbenchWindowAdvisorHack : public QObject
{
Q_OBJECT
public slots:
void onUndo();
void onRedo();
void onImageNavigator();
+ void onCandyStore();
void onEditPreferences();
void onQuit();
void onResetPerspective();
void onClosePerspective();
void onNewWindow();
void onIntro();
/**
* @brief This slot is called if the user klicks the menu item "help->context help" or presses F1.
* The help page is shown in a workbench editor.
*/
void onHelp();
void onHelpOpenHelpPerspective();
/**
* @brief This slot is called if the user clicks in help menu the about button
*/
void onAbout();
public:
QmitkExtWorkbenchWindowAdvisorHack();
~QmitkExtWorkbenchWindowAdvisorHack();
static QmitkExtWorkbenchWindowAdvisorHack* undohack;
};