Page MenuHomePhabricator

No OneTemporary

diff --git a/Plugins/org.mitk.gui.qt.ext/resources/icons/awesome/scalable/tag.svg b/Plugins/org.mitk.gui.qt.ext/resources/icons/awesome/scalable/tag.svg
new file mode 100644
index 0000000000..af15475e17
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.ext/resources/icons/awesome/scalable/tag.svg
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 16.0.4, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+ width="216px" height="146px" viewBox="0 0 216 146" enable-background="new 0 0 216 146" xml:space="preserve">
+<path d="M166.703,76.869l-58.254-58.172c-2.064-2.065-4.834-3.816-8.31-5.255c-3.477-1.439-6.654-2.159-9.533-2.159H56.713
+ c-2.825,0-5.269,1.033-7.333,3.096c-2.064,2.064-3.096,4.508-3.096,7.333v33.893c0,2.879,0.719,6.055,2.159,9.532
+ s3.191,6.219,5.255,8.229l58.253,58.335c2.01,2.01,4.453,3.015,7.333,3.015c2.823,0,5.296-1.005,7.414-3.015l40.004-40.085
+ c2.01-2.011,3.014-4.453,3.014-7.332C169.716,81.46,168.712,78.988,166.703,76.869z M79.729,44.728
+ c-2.038,2.037-4.495,3.056-7.374,3.056c-2.878,0-5.336-1.019-7.373-3.056s-3.055-4.494-3.055-7.373s1.018-5.337,3.055-7.373
+ c2.037-2.037,4.495-3.056,7.373-3.056c2.879,0,5.337,1.019,7.374,3.056c2.036,2.036,3.055,4.494,3.055,7.373
+ S81.766,42.691,79.729,44.728z"/>
+</svg>
diff --git a/Plugins/org.mitk.gui.qt.ext/resources/icons/awesome/scalable/tags.svg b/Plugins/org.mitk.gui.qt.ext/resources/icons/awesome/scalable/tags.svg
new file mode 100644
index 0000000000..48242a0040
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.ext/resources/icons/awesome/scalable/tags.svg
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 16.0.4, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+ width="216px" height="146px" viewBox="0 0 216 146" enable-background="new 0 0 216 146" xml:space="preserve">
+<g>
+ <path d="M154.073,84.284c0-2.824-1.005-5.296-3.015-7.415L92.805,18.697c-2.064-2.065-4.834-3.816-8.31-5.255
+ c-3.476-1.439-6.654-2.159-9.533-2.159H41.069c-2.824,0-5.269,1.033-7.332,3.096c-2.065,2.064-3.097,4.508-3.097,7.333v33.893
+ c0,2.879,0.719,6.055,2.159,9.532s3.192,6.219,5.255,8.229l58.254,58.335c2.01,2.01,4.454,3.015,7.332,3.015
+ c2.825,0,5.297-1.005,7.415-3.015l40.004-40.085C153.068,89.605,154.073,87.163,154.073,84.284z M64.086,44.728
+ c-2.037,2.037-4.495,3.056-7.374,3.056c-2.878,0-5.336-1.019-7.373-3.056s-3.055-4.494-3.055-7.373s1.018-5.337,3.055-7.373
+ c2.037-2.037,4.495-3.056,7.373-3.056c2.879,0,5.337,1.019,7.374,3.056c2.036,2.036,3.055,4.494,3.055,7.373
+ S66.122,42.691,64.086,44.728z"/>
+ <path d="M182.343,76.87L124.09,18.698c-2.064-2.065-4.834-3.816-8.311-5.255c-3.475-1.439-6.653-2.159-9.532-2.159h-18.25
+ c2.879,0,6.056,0.72,9.532,2.159c3.477,1.44,6.247,3.191,8.311,5.255l58.253,58.172c2.011,2.118,3.017,4.59,3.017,7.414
+ c0,2.879-1.006,5.321-3.017,7.332l-38.292,38.293c1.631,1.684,3.069,2.905,4.318,3.666s2.852,1.141,4.807,1.141
+ c2.825,0,5.297-1.005,7.414-3.015l40.003-40.085c2.011-2.011,3.017-4.453,3.017-7.332C185.359,81.46,184.354,78.988,182.343,76.87z
+ "/>
+</g>
+</svg>
diff --git a/Plugins/org.mitk.gui.qt.ext/resources/org_mitk_icons.qrc b/Plugins/org.mitk.gui.qt.ext/resources/org_mitk_icons.qrc
index 08f6548161..4d67ab9b0f 100644
--- a/Plugins/org.mitk.gui.qt.ext/resources/org_mitk_icons.qrc
+++ b/Plugins/org.mitk.gui.qt.ext/resources/org_mitk_icons.qrc
@@ -1,67 +1,68 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource prefix="/org_mitk_icons">
<file>icons/awesome/index.theme</file>
<file>icons/awesome/scalable/actions/document-open.svg</file>
<file>icons/awesome/scalable/actions/document-print.svg</file>
<file>icons/awesome/scalable/actions/document-save.svg</file>
<file>icons/awesome/scalable/actions/edit-delete.svg</file>
<file>icons/awesome/scalable/actions/edit-redo.svg</file>
<file>icons/awesome/scalable/actions/edit-undo.svg</file>
<file>icons/awesome/scalable/actions/go-down.svg</file>
<file>icons/awesome/scalable/actions/go-home.svg</file>
<file>icons/awesome/scalable/actions/go-next.svg</file>
<file>icons/awesome/scalable/actions/go-previous.svg</file>
<file>icons/awesome/scalable/actions/go-up.svg</file>
<file>icons/awesome/scalable/actions/system-log-out.svg</file>
<file>icons/awesome/scalable/actions/view-list-details.svg</file>
<file>icons/awesome/scalable/actions/view-list-icons.svg</file>
<file>icons/awesome/scalable/actions/view-refresh.svg</file>
<file>icons/awesome/scalable/places/folder.svg</file>
<file>icons/awesome/scalable/status/dialog-error.svg</file>
<file>icons/awesome/scalable/status/dialog-information.svg</file>
<file>icons/awesome/scalable/status/dialog-question.svg</file>
<file>icons/awesome/scalable/status/dialog-warning.svg</file>
+ <file>icons/awesome/scalable/tag.svg</file>
+ <file>icons/awesome/scalable/tags.svg</file>
<file>icons/tango/index.theme</file>
<file>icons/tango/scalable/actions/document-open.svg</file>
<file>icons/tango/scalable/actions/document-print.svg</file>
<file>icons/tango/scalable/actions/document-save.svg</file>
<file>icons/tango/scalable/actions/edit-delete.svg</file>
<file>icons/tango/scalable/actions/edit-redo.svg</file>
<file>icons/tango/scalable/actions/edit-undo.svg</file>
<file>icons/tango/scalable/actions/go-bottom.svg</file>
<file>icons/tango/scalable/actions/go-down.svg</file>
<file>icons/tango/scalable/actions/go-first.svg</file>
<file>icons/tango/scalable/actions/go-home.svg</file>
<file>icons/tango/scalable/actions/go-last.svg</file>
<file>icons/tango/scalable/actions/go-next.svg</file>
<file>icons/tango/scalable/actions/go-previous.svg</file>
<file>icons/tango/scalable/actions/go-top.svg</file>
<file>icons/tango/scalable/actions/go-up.svg</file>
<file>icons/tango/scalable/actions/system-log-out.svg</file>
<file>icons/tango/scalable/actions/view-list-details.svg</file>
<file>icons/tango/scalable/actions/view-list-icons.svg</file>
<file>icons/tango/scalable/actions/view-refresh.svg</file>
<file>icons/tango/scalable/actions/list-add.svg</file>
<file>icons/tango/scalable/actions/list-remove.svg</file>
<file>icons/tango/scalable/actions/media-playback-pause.svg</file>
<file>icons/tango/scalable/actions/media-playback-start.svg</file>
<file>icons/tango/scalable/actions/media-playback-stop.svg</file>
<file>icons/tango/scalable/actions/media-record.svg</file>
<file>icons/tango/scalable/actions/media-seek-backward.svg</file>
<file>icons/tango/scalable/actions/media-seek-forward.svg</file>
<file>icons/tango/scalable/actions/media-skip-backward.svg</file>
<file>icons/tango/scalable/actions/media-skip-forward.svg</file>
- <file>icons/tango/scalable/actions/system-log-out.svg</file>
<file>icons/tango/scalable/categories/applications-multimedia.svg</file>
<file>icons/tango/scalable/devices/camera-photo.svg</file>
<file>icons/tango/scalable/devices/camera-video.svg</file>
<file>icons/tango/scalable/mimetypes/image-x-generic.svg</file>
<file>icons/tango/scalable/mimetypes/video-x-generic.svg</file>
<file>icons/tango/scalable/places/folder.svg</file>
<file>icons/tango/scalable/places/folder-remote.svg</file>
<file>icons/tango/scalable/status/dialog-error.svg</file>
<file>icons/tango/scalable/status/dialog-information.svg</file>
<file>icons/tango/scalable/status/dialog-question.svg</file>
<file>icons/tango/scalable/status/dialog-warning.svg</file>
</qresource>
</RCC>
diff --git a/Plugins/org.mitk.gui.qt.properties/src/internal/QmitkPropertiesPreferencePage.cpp b/Plugins/org.mitk.gui.qt.properties/src/internal/QmitkPropertiesPreferencePage.cpp
index d4ee664023..dcdb9982a5 100644
--- a/Plugins/org.mitk.gui.qt.properties/src/internal/QmitkPropertiesPreferencePage.cpp
+++ b/Plugins/org.mitk.gui.qt.properties/src/internal/QmitkPropertiesPreferencePage.cpp
@@ -1,86 +1,87 @@
/*===================================================================
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 "QmitkPropertiesPreferencePage.h"
#include <berryIPreferencesService.h>
#include <berryPlatform.h>
const QString QmitkPropertiesPreferencePage::FILTER_PROPERTIES = "filter properties";
const QString QmitkPropertiesPreferencePage::SHOW_ALIASES = "show aliases";
const QString QmitkPropertiesPreferencePage::SHOW_DESCRIPTIONS = "show descriptions";
const QString QmitkPropertiesPreferencePage::SHOW_ALIASES_IN_DESCRIPTION = "show aliases in description";
const QString QmitkPropertiesPreferencePage::SHOW_PERSISTENCE_IN_DESCRIPTION = "show persistence in description";
const QString QmitkPropertiesPreferencePage::DEVELOPER_MODE = "enable developer mode";
QmitkPropertiesPreferencePage::QmitkPropertiesPreferencePage()
: m_Control(nullptr),
m_Preferences(berry::Platform::GetPreferencesService()->GetSystemPreferences()->Node("/org.mitk.views.properties"))
{
}
QmitkPropertiesPreferencePage::~QmitkPropertiesPreferencePage()
{
}
void QmitkPropertiesPreferencePage::CreateQtControl(QWidget* parent)
{
m_Control = new QWidget(parent);
m_Controls.setupUi(m_Control);
connect(m_Controls.showDescriptionsCheckBox, SIGNAL(stateChanged(int)), this, SLOT(OnShowDescriptionsStateChanged(int)));
this->Update();
}
QWidget* QmitkPropertiesPreferencePage::GetQtControl() const
{
return m_Control;
}
void QmitkPropertiesPreferencePage::Init(berry::IWorkbench::Pointer)
{
}
void QmitkPropertiesPreferencePage::OnShowDescriptionsStateChanged(int state)
{
m_Controls.showAliasesInDescriptionCheckBox->setEnabled(state != Qt::Unchecked);
+ m_Controls.showPersistenceInDescriptionCheckBox->setEnabled(state != Qt::Unchecked);
}
bool QmitkPropertiesPreferencePage::PerformOk()
{
m_Preferences->PutBool(FILTER_PROPERTIES, m_Controls.filterPropertiesCheckBox->isChecked());
m_Preferences->PutBool(SHOW_ALIASES, m_Controls.showAliasesCheckBox->isChecked());
m_Preferences->PutBool(SHOW_DESCRIPTIONS, m_Controls.showDescriptionsCheckBox->isChecked());
m_Preferences->PutBool(SHOW_ALIASES_IN_DESCRIPTION, m_Controls.showAliasesInDescriptionCheckBox->isChecked());
m_Preferences->PutBool(SHOW_PERSISTENCE_IN_DESCRIPTION, m_Controls.showPersistenceInDescriptionCheckBox->isChecked());
m_Preferences->PutBool(DEVELOPER_MODE, m_Controls.enableDeveloperModeCheckBox->isChecked());
return true;
}
void QmitkPropertiesPreferencePage::PerformCancel()
{
}
void QmitkPropertiesPreferencePage::Update()
{
m_Controls.filterPropertiesCheckBox->setChecked(m_Preferences->GetBool(FILTER_PROPERTIES, true));
m_Controls.showAliasesCheckBox->setChecked(m_Preferences->GetBool(SHOW_ALIASES, true));
m_Controls.showDescriptionsCheckBox->setChecked(m_Preferences->GetBool(SHOW_DESCRIPTIONS, true));
m_Controls.showAliasesInDescriptionCheckBox->setChecked(m_Preferences->GetBool(SHOW_ALIASES_IN_DESCRIPTION, true));
m_Controls.showPersistenceInDescriptionCheckBox->setChecked(m_Preferences->GetBool(SHOW_PERSISTENCE_IN_DESCRIPTION, true));
m_Controls.enableDeveloperModeCheckBox->setChecked(m_Preferences->GetBool(DEVELOPER_MODE, false));
}
diff --git a/Plugins/org.mitk.gui.qt.properties/src/internal/QmitkPropertyTreeView.cpp b/Plugins/org.mitk.gui.qt.properties/src/internal/QmitkPropertyTreeView.cpp
index 38a9ec1348..5398aa49cf 100644
--- a/Plugins/org.mitk.gui.qt.properties/src/internal/QmitkPropertyTreeView.cpp
+++ b/Plugins/org.mitk.gui.qt.properties/src/internal/QmitkPropertyTreeView.cpp
@@ -1,446 +1,460 @@
/*===================================================================
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 "mitkGetPropertyService.h"
#include "QmitkAddNewPropertyDialog.h"
#include "QmitkPropertiesPreferencePage.h"
#include "QmitkPropertyItemDelegate.h"
#include "QmitkPropertyItemModel.h"
#include "QmitkPropertyItemSortFilterProxyModel.h"
#include "QmitkPropertyTreeView.h"
#include <berryIBerryPreferences.h>
#include <mitkIPropertyAliases.h>
#include <mitkIPropertyDescriptions.h>
#include <mitkIPropertyPersistence.h>
#include <QmitkRenderWindow.h>
#include <QPainter>
#include <memory>
const std::string QmitkPropertyTreeView::VIEW_ID = "org.mitk.views.properties";
QmitkPropertyTreeView::QmitkPropertyTreeView()
: m_Parent(nullptr),
m_PropertyNameChangedTag(0),
m_PropertyAliases(nullptr),
m_PropertyDescriptions(nullptr),
m_PropertyPersistence(nullptr),
m_ShowAliasesInDescription(true),
m_ShowPersistenceInDescription(true),
m_DeveloperMode(false),
m_ProxyModel(nullptr),
m_Model(nullptr),
m_Delegate(nullptr),
m_Renderer(nullptr)
{
}
QmitkPropertyTreeView::~QmitkPropertyTreeView()
{
}
void QmitkPropertyTreeView::CreateQtPartControl(QWidget* parent)
{
m_Parent = parent;
m_Controls.setupUi(parent);
m_Controls.propertyListComboBox->addItem("Data node: common");
mitk::IRenderWindowPart* renderWindowPart = this->GetRenderWindowPart();
if (renderWindowPart != NULL)
{
QHash<QString, QmitkRenderWindow*> renderWindows = renderWindowPart->GetQmitkRenderWindows();
Q_FOREACH(QString renderWindow, renderWindows.keys())
{
m_Controls.propertyListComboBox->addItem(QString("Data node: ") + renderWindow);
}
}
m_Controls.propertyListComboBox->addItem("Base data");
m_Controls.newButton->setEnabled(false);
m_Controls.description->hide();
m_Controls.propertyListLabel->hide();
m_Controls.propertyListComboBox->hide();
m_Controls.newButton->hide();
m_ProxyModel = new QmitkPropertyItemSortFilterProxyModel(m_Controls.treeView);
m_Model = new QmitkPropertyItemModel(m_ProxyModel);
m_ProxyModel->setSourceModel(m_Model);
m_ProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
m_ProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
m_ProxyModel->setDynamicSortFilter(true);
m_Delegate = new QmitkPropertyItemDelegate(m_Controls.treeView);
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
m_Controls.filterLineEdit->setClearButtonEnabled(true);
#endif
m_Controls.treeView->setItemDelegateForColumn(1, m_Delegate);
m_Controls.treeView->setModel(m_ProxyModel);
m_Controls.treeView->setColumnWidth(0, 160);
m_Controls.treeView->sortByColumn(0, Qt::AscendingOrder);
m_Controls.treeView->setSelectionBehavior(QAbstractItemView::SelectRows);
m_Controls.treeView->setSelectionMode(QAbstractItemView::SingleSelection);
m_Controls.treeView->setEditTriggers(QAbstractItemView::SelectedClicked | QAbstractItemView::DoubleClicked);
connect(m_Controls.filterLineEdit, SIGNAL(textChanged(const QString&)), this, SLOT(OnFilterTextChanged(const QString&)));
connect(m_Controls.propertyListComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(OnPropertyListChanged(int)));
connect(m_Controls.newButton, SIGNAL(clicked()), this, SLOT(OnAddNewProperty()));
connect(m_Controls.treeView->selectionModel(), SIGNAL(currentRowChanged(const QModelIndex&, const QModelIndex&)), this, SLOT(OnCurrentRowChanged(const QModelIndex&, const QModelIndex&)));
connect(m_Model, SIGNAL(modelReset()), this, SLOT(OnModelReset()));
}
QString QmitkPropertyTreeView::GetPropertyNameOrAlias(const QModelIndex& index)
{
QString propertyName;
if (index.isValid())
{
QModelIndex current = index;
while (current.isValid())
{
QString name = m_ProxyModel->data(m_ProxyModel->index(current.row(), 0, current.parent())).toString();
propertyName.prepend(propertyName.isEmpty()
? name
: name.append('.'));
current = current.parent();
}
}
return propertyName;
}
void QmitkPropertyTreeView::OnCurrentRowChanged(const QModelIndex& current, const QModelIndex&)
{
if (m_PropertyDescriptions != nullptr && current.isValid())
{
QString name = this->GetPropertyNameOrAlias(current);
if (!name.isEmpty())
{
QString alias;
bool isTrueName = true;
if (m_PropertyAliases != nullptr)
{
std::string trueName = m_PropertyAliases->GetPropertyName(name.toStdString());
if (trueName.empty() && !m_SelectionClassName.empty())
trueName = m_PropertyAliases->GetPropertyName(name.toStdString(), m_SelectionClassName);
if (!trueName.empty())
{
alias = name;
name = QString::fromStdString(trueName);
isTrueName = false;
}
}
QString description = QString::fromStdString(m_PropertyDescriptions->GetDescription(name.toStdString()));
std::vector<std::string> aliases;
if (!isTrueName && m_PropertyAliases != nullptr)
{
aliases = m_PropertyAliases->GetAliases(name.toStdString(), m_SelectionClassName);
if (aliases.empty() && !m_SelectionClassName.empty())
aliases = m_PropertyAliases->GetAliases(name.toStdString());
}
bool isPersistent = false;
- QString persistenceKey;
+ // QString persistenceKey;
if (m_PropertyPersistence != nullptr)
{
isPersistent = m_PropertyPersistence->HasInfo(name.toStdString());
- if (isPersistent)
+ /*if (isPersistent)
{
persistenceKey = QString::fromStdString(m_PropertyPersistence->GetInfo(name.toStdString())->GetKey());
if (persistenceKey.isEmpty())
persistenceKey = name;
- }
+ }*/
}
if (!description.isEmpty() || !aliases.empty() || isPersistent)
{
QString customizedDescription;
if (m_ShowAliasesInDescription && !aliases.empty())
{
customizedDescription = "<h3 style=\"margin-bottom:0\">" + name + "</h3>";
std::size_t numAliases = aliases.size();
std::size_t lastAlias = numAliases - 1;
for (std::size_t i = 0; i < numAliases; ++i)
{
customizedDescription += i != lastAlias
? "<h5 style=\"margin-top:0;margin-bottom:0\">"
: "<h5 style=\"margin-top:0;margin-bottom:10px\">";
customizedDescription += QString::fromStdString(aliases[i]) + "</h5>";
}
}
else
{
customizedDescription = "<h3 style=\"margin-bottom:10px\">" + name + "</h3>";
}
- if (isPersistent)
- customizedDescription += "<h5 style=\"margin-top:0;margin-bottom:10px\">Persistence key: " + persistenceKey + "</h5>";
-
if (!description.isEmpty())
- customizedDescription += description;
+ customizedDescription += "<p>" + description + "</p>";
+
+ if (!aliases.empty() || isPersistent)
+ {
+ customizedDescription += "<div align=\"right\">";
+
+ if (!aliases.empty())
+ {
+ customizedDescription += aliases.size() > 1
+ ? "<img height=\"32\" src=\":/org_mitk_icons/icons/awesome/scalable/tags.svg\"/>"
+ : "<img height=\"32\" src=\":/org_mitk_icons/icons/awesome/scalable/tag.svg\"/>";
+ }
+
+ if (isPersistent)
+ customizedDescription += "<img height=\"32\" src=\":/org_mitk_icons/icons/awesome/scalable/actions/document-save.svg\"/>";
+
+ customizedDescription += "</div>";
+ }
m_Controls.description->setText(customizedDescription);
m_Controls.description->show();
return;
}
}
}
m_Controls.description->hide();
}
void QmitkPropertyTreeView::OnFilterTextChanged(const QString& filter)
{
m_ProxyModel->setFilterWildcard(filter);
if (filter.isEmpty())
m_Controls.treeView->collapseAll();
else
m_Controls.treeView->expandAll();
}
void QmitkPropertyTreeView::OnModelReset()
{
m_Controls.description->hide();
}
void QmitkPropertyTreeView::OnPreferencesChanged(const berry::IBerryPreferences* preferences)
{
bool showAliases = preferences->GetBool(QmitkPropertiesPreferencePage::SHOW_ALIASES, true);
bool showDescriptions = preferences->GetBool(QmitkPropertiesPreferencePage::SHOW_DESCRIPTIONS, true);
bool showAliasesInDescription = preferences->GetBool(QmitkPropertiesPreferencePage::SHOW_ALIASES_IN_DESCRIPTION, true);
bool showPersistenceInDescription = preferences->GetBool(QmitkPropertiesPreferencePage::SHOW_PERSISTENCE_IN_DESCRIPTION, true);
bool developerMode = preferences->GetBool(QmitkPropertiesPreferencePage::DEVELOPER_MODE, false);
bool updateAliases = showAliases != (m_PropertyAliases != NULL);
bool updateDescriptions = showDescriptions != (m_PropertyDescriptions != NULL);
bool updateAliasesInDescription = showAliasesInDescription != m_ShowAliasesInDescription;
bool updatePersistenceInDescription = showPersistenceInDescription != m_ShowPersistenceInDescription;
bool updateDeveloperMode = developerMode != m_DeveloperMode;
if (updateAliases)
m_PropertyAliases = showAliases
? mitk::GetPropertyService<mitk::IPropertyAliases>()
: nullptr;
if (updateDescriptions)
m_PropertyDescriptions = showDescriptions
? mitk::GetPropertyService<mitk::IPropertyDescriptions>()
: nullptr;
if (showPersistenceInDescription)
m_PropertyPersistence = mitk::GetPropertyService<mitk::IPropertyPersistence>();
if (updateAliasesInDescription)
m_ShowAliasesInDescription = showAliasesInDescription;
if (updatePersistenceInDescription)
m_ShowPersistenceInDescription = showPersistenceInDescription;
if (updateDescriptions || updateAliasesInDescription || updatePersistenceInDescription)
{
QModelIndexList selection = m_Controls.treeView->selectionModel()->selectedRows();
if (!selection.isEmpty())
this->OnCurrentRowChanged(selection[0], selection[0]);
}
if (updateDeveloperMode)
{
m_DeveloperMode = developerMode;
if (!developerMode)
m_Controls.propertyListComboBox->setCurrentIndex(0);
m_Controls.propertyListLabel->setVisible(developerMode);
m_Controls.propertyListComboBox->setVisible(developerMode);
m_Controls.newButton->setVisible(developerMode);
}
m_Model->OnPreferencesChanged(preferences);
}
void QmitkPropertyTreeView::OnPropertyNameChanged(const itk::EventObject&)
{
mitk::PropertyList* propertyList = m_Model->GetPropertyList();
if (propertyList != NULL)
{
mitk::BaseProperty* nameProperty = propertyList->GetProperty("name");
if (nameProperty != NULL)
{
QString partName = "Properties (";
partName.append(QString::fromStdString(nameProperty->GetValueAsString())).append(')');
this->SetPartName(partName);
}
}
}
void QmitkPropertyTreeView::OnSelectionChanged(berry::IWorkbenchPart::Pointer, const QList<mitk::DataNode::Pointer>& nodes)
{
mitk::PropertyList* propertyList = m_Model->GetPropertyList();
if (propertyList != NULL)
{
mitk::BaseProperty* nameProperty = propertyList->GetProperty("name");
if (nameProperty != NULL)
nameProperty->RemoveObserver(m_PropertyNameChangedTag);
m_PropertyNameChangedTag = 0;
}
if (nodes.empty() || nodes.front().IsNull())
{
m_SelectedNode = NULL;
this->SetPartName("Properties");
m_Model->SetPropertyList(NULL);
m_Delegate->SetPropertyList(NULL);
m_Controls.newButton->setEnabled(false);
}
else
{
m_SelectedNode = nodes.front();
QString selectionClassName = m_SelectedNode->GetData() != NULL
? m_SelectedNode->GetData()->GetNameOfClass()
: "";
m_SelectionClassName = selectionClassName.toStdString();
mitk::PropertyList::Pointer propertyList;
if (m_Renderer == NULL && m_Controls.propertyListComboBox->currentText() == "Base data")
{
propertyList = m_SelectedNode->GetData() != NULL
? m_SelectedNode->GetData()->GetPropertyList()
: NULL;
}
else
{
propertyList = m_SelectedNode->GetPropertyList(m_Renderer);
}
m_Model->SetPropertyList(propertyList, selectionClassName);
m_Delegate->SetPropertyList(propertyList);
OnPropertyNameChanged(itk::ModifiedEvent());
mitk::BaseProperty* nameProperty = m_SelectedNode->GetProperty("name");
if (nameProperty != NULL)
{
itk::ReceptorMemberCommand<QmitkPropertyTreeView>::Pointer command = itk::ReceptorMemberCommand<QmitkPropertyTreeView>::New();
command->SetCallbackFunction(this, &QmitkPropertyTreeView::OnPropertyNameChanged);
m_PropertyNameChangedTag = nameProperty->AddObserver(itk::ModifiedEvent(), command);
}
m_Controls.newButton->setEnabled(true);
}
if (!m_ProxyModel->filterRegExp().isEmpty())
m_Controls.treeView->expandAll();
}
void QmitkPropertyTreeView::SetFocus()
{
m_Controls.filterLineEdit->setFocus();
}
void QmitkPropertyTreeView::RenderWindowPartActivated(mitk::IRenderWindowPart* /*renderWindowPart*/)
{
if (m_Controls.propertyListComboBox->count() == 2)
{
QHash<QString, QmitkRenderWindow*> renderWindows = this->GetRenderWindowPart()->GetQmitkRenderWindows();
Q_FOREACH(QString renderWindow, renderWindows.keys())
{
m_Controls.propertyListComboBox->insertItem(m_Controls.propertyListComboBox->count() - 1, QString("Data node: ") + renderWindow);
}
}
}
void QmitkPropertyTreeView::RenderWindowPartDeactivated(mitk::IRenderWindowPart*)
{
if (m_Controls.propertyListComboBox->count() > 2)
{
m_Controls.propertyListComboBox->clear();
m_Controls.propertyListComboBox->addItem("Data node: common");
m_Controls.propertyListComboBox->addItem("Base data");
}
}
void QmitkPropertyTreeView::OnPropertyListChanged(int index)
{
if (index == -1)
return;
QString renderer = m_Controls.propertyListComboBox->itemText(index);
if (renderer.startsWith("Data node: "))
renderer = QString::fromStdString(renderer.toStdString().substr(11));
m_Renderer = renderer != "common" && renderer != "Base data"
? this->GetRenderWindowPart()->GetQmitkRenderWindow(renderer)->GetRenderer()
: NULL;
QList<mitk::DataNode::Pointer> nodes;
if (m_SelectedNode.IsNotNull())
nodes << m_SelectedNode;
berry::IWorkbenchPart::Pointer workbenchPart;
this->OnSelectionChanged(workbenchPart, nodes);
}
void QmitkPropertyTreeView::OnAddNewProperty()
{
std::unique_ptr<QmitkAddNewPropertyDialog> dialog(m_Controls.propertyListComboBox->currentText() != "Base data"
? new QmitkAddNewPropertyDialog(m_SelectedNode, m_Renderer, m_Parent)
: new QmitkAddNewPropertyDialog(m_SelectedNode->GetData()));
if (dialog->exec() == QDialog::Accepted)
this->m_Model->Update();
}

File Metadata

Mime Type
image/svg+xml
Expires
Tue, Oct 1, 8:18 AM (1 d, 21 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2293212
Default Alt Text
(27 KB)

Event Timeline