diff --git a/Plugins/org.mitk.gui.qt.datamanager/files.cmake b/Plugins/org.mitk.gui.qt.datamanager/files.cmake
index ad9241d53a..c12a40fad0 100644
--- a/Plugins/org.mitk.gui.qt.datamanager/files.cmake
+++ b/Plugins/org.mitk.gui.qt.datamanager/files.cmake
@@ -1,43 +1,52 @@
set(SRC_CPP_FILES
berrySingleNodeSelection.cpp
- QmitkDataManagerView.cpp
+ QmitkDataManagerView.cpp
QmitkDataManagerPreferencePage.cpp
QmitkDataManagerHotkeysPrefPage.cpp
)
set(INTERNAL_CPP_FILES
mitkPluginActivator.cpp
+ QmitkLineEdit.cpp
QmitkPropertyListView.cpp
+ QmitkPropertyTreeItem.cpp
+ QmitkPropertyTreeFilterProxyModel.cpp
+ QmitkPropertyTreeModel.cpp
+ QmitkPropertyTreeView.cpp
QmitkNodeTableViewKeyFilter.cpp
QmitkInfoDialog.cpp
)
set(MOC_H_FILES
src/QmitkDataManagerView.h
src/QmitkDataManagerPreferencePage.h
src/QmitkDataManagerHotkeysPrefPage.h
+ src/internal/QmitkLineEdit.h
src/internal/QmitkNodeTableViewKeyFilter.h
src/internal/QmitkPropertyListView.h
+ src/internal/QmitkPropertyTreeFilterProxyModel.h
+ src/internal/QmitkPropertyTreeModel.h
+ src/internal/QmitkPropertyTreeView.h
src/internal/QmitkInfoDialog.h
src/internal/mitkPluginActivator.h
)
set(CPP_FILES )
set(CACHED_RESOURCE_FILES
plugin.xml
resources/DataManager_48.png
resources/propertylist.png
)
set(QRC_FILES
resources/datamanager.qrc
)
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.datamanager/plugin.xml b/Plugins/org.mitk.gui.qt.datamanager/plugin.xml
index 3f6de9ac92..90b564e87d 100644
--- a/Plugins/org.mitk.gui.qt.datamanager/plugin.xml
+++ b/Plugins/org.mitk.gui.qt.datamanager/plugin.xml
@@ -1,40 +1,45 @@
+
-
+
diff --git a/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkLineEdit.cpp b/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkLineEdit.cpp
new file mode 100644
index 0000000000..87b8f47944
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkLineEdit.cpp
@@ -0,0 +1,105 @@
+/*===================================================================
+
+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 "QmitkLineEdit.h"
+#include
+
+QmitkLineEdit::QmitkLineEdit(QWidget *parent)
+ : QLineEdit(parent)
+{
+ initialize();
+}
+
+QmitkLineEdit::QmitkLineEdit(const QString &defaultText, QWidget *parent)
+ : QLineEdit(parent),
+ m_DefaultText(defaultText)
+{
+ initialize();
+}
+
+QmitkLineEdit::~QmitkLineEdit()
+{
+}
+
+void QmitkLineEdit::initialize()
+{
+ m_DefaultPalette.setColor(QPalette::Text, QApplication::palette().color(QPalette::Disabled, QPalette::Text));
+
+ showDefaultText(true);
+
+ connect(this, SIGNAL(focusChanged(bool)), this, SLOT(onFocusChanged(bool)));
+ connect(this, SIGNAL(textChanged(QString)), this, SLOT(onTextChanged(QString)));
+}
+
+QString QmitkLineEdit::defaultText() const
+{
+ return m_DefaultText;
+}
+
+void QmitkLineEdit::setDefaultText(const QString &defaultText)
+{
+ m_DefaultText = defaultText;
+}
+
+void QmitkLineEdit::focusInEvent(QFocusEvent *event)
+{
+ QLineEdit::focusInEvent(event);
+ emit(focusChanged(true));
+}
+
+void QmitkLineEdit::focusOutEvent(QFocusEvent *event)
+{
+ QLineEdit::focusOutEvent(event);
+ emit(focusChanged(false));
+}
+
+void QmitkLineEdit::onFocusChanged(bool hasFocus)
+{
+ if (hasFocus)
+ {
+ if (text() == m_DefaultText && palette() == m_DefaultPalette)
+ showDefaultText(false);
+ }
+ else
+ {
+ if (text().isEmpty())
+ showDefaultText(true);
+ }
+}
+
+void QmitkLineEdit::onTextChanged(const QString &text)
+{
+ if (palette() == m_DefaultPalette)
+ setPalette(m_Palette);
+}
+
+void QmitkLineEdit::showDefaultText(bool show)
+{
+ blockSignals(true);
+
+ if (show)
+ {
+ setPalette(m_DefaultPalette);
+ setText(m_DefaultText);
+ }
+ else
+ {
+ setPalette(m_Palette);
+ clear();
+ }
+
+ blockSignals(false);
+}
diff --git a/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkLineEdit.h b/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkLineEdit.h
new file mode 100644
index 0000000000..2204e354cb
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkLineEdit.h
@@ -0,0 +1,56 @@
+/*===================================================================
+
+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 QMITKLINEEDIT_H
+#define QMITKLINEEDIT_H
+
+#include
+
+class QmitkLineEdit : public QLineEdit
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString defaultText READ defaultText WRITE setDefaultText)
+
+public:
+ explicit QmitkLineEdit(QWidget *parent = NULL);
+ explicit QmitkLineEdit(const QString &defaultText, QWidget *parent = NULL);
+ ~QmitkLineEdit();
+
+ QString defaultText() const;
+ void setDefaultText(const QString &defaultText);
+
+signals:
+ void focusChanged(bool hasFocus);
+
+protected:
+ void focusInEvent(QFocusEvent *event);
+ void focusOutEvent(QFocusEvent *event);
+
+private slots:
+ void onFocusChanged(bool hasFocus);
+ void onTextChanged(const QString &text);
+
+private:
+ void initialize();
+ void showDefaultText(bool show);
+
+ QString m_DefaultText;
+ QPalette m_Palette;
+ QPalette m_DefaultPalette;
+};
+
+#endif
diff --git a/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkPropertyTreeFilterProxyModel.cpp b/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkPropertyTreeFilterProxyModel.cpp
new file mode 100644
index 0000000000..5e06dcf978
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkPropertyTreeFilterProxyModel.cpp
@@ -0,0 +1,56 @@
+/*===================================================================
+
+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 "QmitkPropertyTreeFilterProxyModel.h"
+#include
+
+QmitkPropertyTreeFilterProxyModel::QmitkPropertyTreeFilterProxyModel(QObject *parent)
+: QSortFilterProxyModel(parent)
+{
+}
+
+QmitkPropertyTreeFilterProxyModel::~QmitkPropertyTreeFilterProxyModel()
+{
+}
+
+bool QmitkPropertyTreeFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
+{
+ return filterAcceptsAnyChildRows(sourceModel()->index(sourceRow, 0, sourceParent));
+}
+
+bool QmitkPropertyTreeFilterProxyModel::filterAcceptsAnyChildRows(const QModelIndex &sourceParent) const
+{
+ QString propertyName = sourceModel()->data(sourceParent).toString();
+
+ if (propertyName.contains(filterRegExp()))
+ return true;
+
+ if (sourceModel()->hasChildren(sourceParent))
+ {
+ for (int row = 0; row < sourceModel()->rowCount(sourceParent); ++row)
+ {
+ if (filterAcceptsAnyChildRows(sourceModel()->index(row, 0, sourceParent)))
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool QmitkPropertyTreeFilterProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const
+{
+ return sourceModel()->data(left).toString().compare(sourceModel()->data(right).toString(), Qt::CaseInsensitive) > 0;
+}
diff --git a/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkPropertyTreeFilterProxyModel.h b/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkPropertyTreeFilterProxyModel.h
new file mode 100644
index 0000000000..cbd06738d1
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkPropertyTreeFilterProxyModel.h
@@ -0,0 +1,38 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+All rights reserved.
+
+This software is distributed WITHOUT ANY WARRANTY; without
+even the implied warranty of MERCHANTABILITY or FITNESS FOR
+A PARTICULAR PURPOSE.
+
+See LICENSE.txt or http://www.mitk.org for details.
+
+===================================================================*/
+
+#ifndef QMITKPROPERTYTREEFILTERPROXYMODEL_H
+#define QMITKPROPERTYTREEFILTERPROXYMODEL_H
+
+#include
+
+class QmitkPropertyTreeFilterProxyModel : public QSortFilterProxyModel
+{
+ Q_OBJECT
+
+public:
+ QmitkPropertyTreeFilterProxyModel(QObject *parent = NULL);
+ ~QmitkPropertyTreeFilterProxyModel();
+
+protected:
+ bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
+ bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
+
+private:
+ bool filterAcceptsAnyChildRows(const QModelIndex &sourceParent) const;
+};
+
+#endif
diff --git a/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkPropertyTreeItem.cpp b/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkPropertyTreeItem.cpp
new file mode 100644
index 0000000000..353949dae1
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkPropertyTreeItem.cpp
@@ -0,0 +1,120 @@
+/*===================================================================
+
+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 "QmitkPropertyTreeItem.h"
+#include
+
+QmitkPropertyTreeItem::QmitkPropertyTreeItem(const QList &data)
+: m_Data(data),
+ m_Parent(NULL)
+{
+}
+
+QmitkPropertyTreeItem::~QmitkPropertyTreeItem()
+{
+ qDeleteAll(m_Children);
+}
+
+void QmitkPropertyTreeItem::AppendChild(QmitkPropertyTreeItem *child)
+{
+ if (child == NULL)
+ return;
+
+ // If property name contains no full stop we can append the property directly.
+ if (!child->GetData(0).toString().contains('.'))
+ {
+ m_Children.append(child);
+ child->m_Parent = this;
+ }
+ else
+ {
+ // Property name contains full stop(s). We split the name appropriately.
+ QStringList names = child->GetData(0).toString().split('.');
+
+ // Traverse the subtree and insert items if they are not already present.
+ QmitkPropertyTreeItem *parent_ = this;
+
+ for (int i = 0; i < names.count(); ++i)
+ {
+ // Subtree present/recently created, append actual property as a leaf item
+ if (i == names.count() - 1)
+ {
+ QList data;
+ data << names[i] << child->m_Data[1];
+ parent_->AppendChild(new QmitkPropertyTreeItem(data));
+
+ delete child;
+ child = NULL;
+ }
+ else
+ {
+ QmitkPropertyTreeItem *child_ = NULL;
+
+ for (int j = 0; j < parent_->m_Children.count(); ++j)
+ {
+ if (parent_->m_Children[j]->GetData(0).toString() == names[i])
+ {
+ child_ = parent_->m_Children[j];
+ break;
+ }
+ }
+
+ if (child_ == NULL)
+ {
+ QList data;
+ data << names[i] << QVariant();
+ child_ = new QmitkPropertyTreeItem(data);
+ parent_->AppendChild(child_);
+ }
+
+ parent_ = child_;
+ }
+ }
+ }
+}
+
+QmitkPropertyTreeItem * QmitkPropertyTreeItem::GetChild(int row)
+{
+ return m_Children.value(row);
+}
+
+int QmitkPropertyTreeItem::GetChildCount() const
+{
+ return m_Children.count();
+}
+
+int QmitkPropertyTreeItem::GetColumnCount() const
+{
+ return m_Data.count();
+}
+
+QVariant QmitkPropertyTreeItem::GetData(int column) const
+{
+ return m_Data.value(column);
+}
+
+QmitkPropertyTreeItem * QmitkPropertyTreeItem::GetParent()
+{
+ return m_Parent;
+}
+
+int QmitkPropertyTreeItem::GetRow() const
+{
+ if (m_Parent != NULL)
+ return m_Parent->m_Children.indexOf(const_cast(this));
+
+ return 0;
+}
diff --git a/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkPropertyTreeItem.h b/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkPropertyTreeItem.h
new file mode 100644
index 0000000000..f7547be861
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkPropertyTreeItem.h
@@ -0,0 +1,43 @@
+/*===================================================================
+
+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 QMITKPROPERTYTREEITEM_H
+#define QMITKPROPERTYTREEITEM_H
+
+#include
+#include
+
+class QmitkPropertyTreeItem
+{
+public:
+ explicit QmitkPropertyTreeItem(const QList &data);
+ ~QmitkPropertyTreeItem();
+
+ void AppendChild(QmitkPropertyTreeItem *child);
+ QmitkPropertyTreeItem * GetChild(int row);
+ int GetChildCount() const;
+ int GetColumnCount() const;
+ QVariant GetData(int column) const;
+ QmitkPropertyTreeItem * GetParent();
+ int GetRow() const;
+
+private:
+ QList m_Children;
+ QList m_Data;
+ QmitkPropertyTreeItem *m_Parent;
+};
+
+#endif
diff --git a/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkPropertyTreeModel.cpp b/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkPropertyTreeModel.cpp
new file mode 100644
index 0000000000..d3d4d19a55
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkPropertyTreeModel.cpp
@@ -0,0 +1,312 @@
+/*===================================================================
+
+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 "QmitkPropertyTreeItem.h"
+#include "QmitkPropertyTreeModel.h"
+#include
+#include
+#include
+#include
+#include
+#include
+
+QmitkPropertyTreeModel::QmitkPropertyTreeModel(QObject *parent)
+: QAbstractItemModel(parent),
+ m_Properties(NULL),
+ m_RootItem(NULL)
+{
+ CreateRootItem();
+}
+
+void QmitkPropertyTreeModel::SetProperties(mitk::PropertyList *properties)
+{
+ if (properties == m_Properties)
+ return;
+
+ beginResetModel();
+
+ if (m_RootItem != NULL)
+ {
+ delete m_RootItem;
+ m_RootItem = NULL;
+ m_Properties = NULL;
+ }
+
+ if (properties != NULL && !properties->IsEmpty())
+ {
+ m_Properties = properties;
+ CreateRootItem();
+
+ std::map::const_iterator end = properties->GetMap()->end();
+
+ for (std::map::const_iterator iter = properties->GetMap()->begin(); iter != end; ++iter)
+ {
+ QList data;
+ data << iter->first.c_str() << QVariant::fromValue((reinterpret_cast(iter->second.GetPointer())));
+ m_RootItem->AppendChild(new QmitkPropertyTreeItem(data));
+ }
+ }
+
+ endResetModel();
+}
+
+void QmitkPropertyTreeModel::CreateRootItem()
+{
+ if (m_RootItem == NULL)
+ {
+ QList rootData;
+ rootData << "Property" << "Value";
+ m_RootItem = new QmitkPropertyTreeItem(rootData);
+ }
+}
+
+QmitkPropertyTreeModel::~QmitkPropertyTreeModel()
+{
+ delete m_RootItem;
+}
+
+int QmitkPropertyTreeModel::columnCount(const QModelIndex &parent) const
+{
+ if (parent.isValid())
+ return static_cast(parent.internalPointer())->GetColumnCount();
+ else
+ return m_RootItem->GetColumnCount();
+}
+
+QVariant QmitkPropertyTreeModel::data(const QModelIndex &index, int role) const
+{
+ if (!index.isValid())
+ return QVariant();
+
+ if (index.column() == 0 && role == Qt::DisplayRole)
+ return static_cast(index.internalPointer())->GetData(index.column());
+
+ if (index.column() == 1 && static_cast(index.internalPointer())->GetData(index.column()).isValid())
+ {
+ mitk::BaseProperty *property = reinterpret_cast(static_cast(index.internalPointer())->GetData(index.column()).value());
+
+ if (mitk::ColorProperty *colorProperty = dynamic_cast(property))
+ {
+ if (role == Qt::DisplayRole || role == Qt::EditRole)
+ {
+ mitk::Color mitkColor = colorProperty->GetColor();
+ QColor qtColor(static_cast(mitkColor.GetRed() * 255), static_cast(mitkColor.GetGreen() * 255), static_cast(mitkColor.GetBlue() * 255));
+ return QVariant::fromValue(qtColor);
+ }
+ }
+ else if (mitk::BoolProperty *boolProperty = dynamic_cast(property))
+ {
+ if (role == Qt::CheckStateRole)
+ return boolProperty->GetValue() ? Qt::Checked : Qt::Unchecked;
+ }
+ else if (mitk::StringProperty *stringProperty = dynamic_cast(property))
+ {
+ if (role == Qt::DisplayRole || role == Qt::EditRole)
+ return QString(stringProperty->GetValue());
+ }
+ else if (mitk::IntProperty *intProperty = dynamic_cast(property))
+ {
+ if (role == Qt::DisplayRole || role == Qt::EditRole)
+ return intProperty->GetValue();
+ }
+ else if (mitk::FloatProperty *floatProperty = dynamic_cast(property))
+ {
+ if (role == Qt::DisplayRole || role == Qt::EditRole)
+ return floatProperty->GetValue();
+ }
+ else if (mitk::DoubleProperty *doubleProperty = dynamic_cast(property))
+ {
+ if (role == Qt::DisplayRole || role == Qt::EditRole)
+ return doubleProperty->GetValue();
+ }
+ else if (mitk::EnumerationProperty *enumProperty = dynamic_cast(property))
+ {
+ if (role == Qt::DisplayRole)
+ {
+ return QString::fromStdString(enumProperty->GetValueAsString());
+ }
+ else if (role == Qt::EditRole)
+ {
+ QStringList values;
+
+ for (mitk::EnumerationProperty::EnumConstIterator iter = enumProperty->Begin(); iter != enumProperty->End(); ++iter)
+ values << QString::fromStdString(iter->second);
+
+ return QVariant(values);
+ }
+ }
+ else
+ {
+ if (role == Qt::DisplayRole)
+ return QString::fromStdString(property->GetValueAsString());
+ }
+ }
+
+ return QVariant();
+}
+
+Qt::ItemFlags QmitkPropertyTreeModel::flags(const QModelIndex &index) const
+{
+ Qt::ItemFlags flags = QAbstractItemModel::flags(index);
+
+ if (index.column() == 1)
+ {
+ if (index.data(Qt::EditRole).isValid())
+ flags |= Qt::ItemIsEditable;
+
+ if (index.data(Qt::CheckStateRole).isValid())
+ flags |= Qt::ItemIsUserCheckable;
+ }
+
+ return flags;
+}
+
+QVariant QmitkPropertyTreeModel::headerData(int section, Qt::Orientation orientation, int role) const
+{
+ if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
+ return m_RootItem->GetData(section);
+
+ return QVariant();
+}
+
+QModelIndex QmitkPropertyTreeModel::index(int row, int column, const QModelIndex &parent) const
+{
+ if (!hasIndex(row, column, parent))
+ return QModelIndex();
+
+ QmitkPropertyTreeItem *parentItem = parent.isValid() ? static_cast(parent.internalPointer()) : m_RootItem;
+ QmitkPropertyTreeItem *childItem = parentItem->GetChild(row);
+
+ if (childItem != NULL)
+ return createIndex(row, column, childItem);
+ else
+ return QModelIndex();
+}
+
+QModelIndex QmitkPropertyTreeModel::parent(const QModelIndex &child) const
+{
+ if (!child.isValid())
+ return QModelIndex();
+
+ QmitkPropertyTreeItem *parentItem = static_cast(child.internalPointer())->GetParent();
+
+ if (parentItem == m_RootItem)
+ return QModelIndex();
+
+ return createIndex(parentItem->GetRow(), 0, parentItem);
+}
+
+int QmitkPropertyTreeModel::rowCount(const QModelIndex &parent) const
+{
+ if (parent.column() > 0)
+ return 0;
+
+ QmitkPropertyTreeItem *parentItem = parent.isValid() ? static_cast(parent.internalPointer()) : m_RootItem;
+
+ return parentItem->GetChildCount();
+}
+
+bool QmitkPropertyTreeModel::setData(const QModelIndex &index, const QVariant &value, int role)
+{
+ if (index.isValid() && (role == Qt::EditRole || role == Qt::CheckStateRole))
+ {
+ if (index.column() == 1)
+ {
+ mitk::BaseProperty *property = reinterpret_cast(static_cast(index.internalPointer())->GetData(index.column()).value());
+
+ if (mitk::ColorProperty *colorProperty = dynamic_cast(property))
+ {
+ QColor qtColor = value.value();
+
+ if (!qtColor.isValid())
+ return false;
+
+ mitk::Color mitkColor = colorProperty->GetColor();
+ mitkColor.SetRed(qtColor.red() / 255.0);
+ mitkColor.SetGreen(qtColor.green() / 255.0);
+ mitkColor.SetBlue(qtColor.blue() / 255.0);
+ colorProperty->SetColor(mitkColor);
+
+ m_Properties->InvokeEvent(itk::ModifiedEvent());
+ m_Properties->Modified();
+
+ mitk::RenderingManager::GetInstance()->RequestUpdateAll();
+ }
+ else if (mitk::BoolProperty *boolProperty = dynamic_cast(property))
+ {
+ boolProperty->SetValue(value.toInt() == Qt::Checked ? true : false);
+
+ m_Properties->InvokeEvent(itk::ModifiedEvent());
+ m_Properties->Modified();
+
+ mitk::RenderingManager::GetInstance()->RequestUpdateAll();
+ }
+ else if (mitk::StringProperty *stringProperty = dynamic_cast(property))
+ {
+ stringProperty->SetValue(value.toString().toStdString());
+
+ m_Properties->InvokeEvent(itk::ModifiedEvent());
+ m_Properties->Modified();
+
+ mitk::RenderingManager::GetInstance()->RequestUpdateAll();
+ }
+ else if (mitk::IntProperty *intProperty = dynamic_cast(property))
+ {
+ int intValue = value.toInt();
+
+ if (intValue != intProperty->GetValue())
+ {
+ intProperty->SetValue(intValue);
+ m_Properties->InvokeEvent(itk::ModifiedEvent());
+ m_Properties->Modified();
+
+ mitk::RenderingManager::GetInstance()->RequestUpdateAll();
+ }
+ }
+ else if (mitk::FloatProperty *floatProperty = dynamic_cast(property))
+ {
+ int floatValue = value.toFloat();
+
+ if (floatValue != floatProperty->GetValue())
+ {
+ floatProperty->SetValue(floatValue);
+ m_Properties->InvokeEvent(itk::ModifiedEvent());
+ m_Properties->Modified();
+
+ mitk::RenderingManager::GetInstance()->RequestUpdateAll();
+ }
+ }
+ else if (mitk::EnumerationProperty *enumProperty = dynamic_cast(property))
+ {
+ std::string activatedItem = value.toString().toStdString();
+
+ if (activatedItem != enumProperty->GetValueAsString())
+ {
+ enumProperty->SetValue(activatedItem);
+ m_Properties->InvokeEvent(itk::ModifiedEvent());
+ m_Properties->Modified();
+
+ mitk::RenderingManager::GetInstance()->RequestUpdateAll();
+ }
+ }
+ }
+
+ emit dataChanged(index, index);
+ return true;
+ }
+
+ return false;
+}
diff --git a/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkPropertyTreeModel.h b/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkPropertyTreeModel.h
new file mode 100644
index 0000000000..58cd5717c0
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkPropertyTreeModel.h
@@ -0,0 +1,51 @@
+/*===================================================================
+
+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 QMITKPROPERTYTREEMODEL_H
+#define QMITKPROPERTYTREEMODEL_H
+
+#include
+#include
+
+class QmitkPropertyTreeItem;
+
+class QmitkPropertyTreeModel : public QAbstractItemModel
+{
+ Q_OBJECT
+
+public:
+ QmitkPropertyTreeModel(QObject *parent = NULL);
+ ~QmitkPropertyTreeModel();
+
+ void SetProperties(mitk::PropertyList *properties);
+
+ int columnCount(const QModelIndex &parent) const;
+ QVariant data(const QModelIndex &index, int role) const;
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+ QVariant headerData(int section, Qt::Orientation orientation, int role) const;
+ QModelIndex index(int row, int column, const QModelIndex &parent) const;
+ QModelIndex parent(const QModelIndex &child) const;
+ int rowCount(const QModelIndex &parent) const;
+ bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
+
+private:
+ void CreateRootItem();
+
+ mitk::PropertyList *m_Properties;
+ QmitkPropertyTreeItem *m_RootItem;
+};
+
+#endif
diff --git a/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkPropertyTreeView.cpp b/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkPropertyTreeView.cpp
new file mode 100644
index 0000000000..8162fcf3cc
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkPropertyTreeView.cpp
@@ -0,0 +1,102 @@
+/*===================================================================
+
+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 "QmitkPropertyTreeView.h"
+#include "QmitkPropertyTreeModel.h"
+#include "QmitkLineEdit.h"
+#include "QmitkPropertyTreeFilterProxyModel.h"
+#include
+#include
+#include
+#include
+
+const std::string QmitkPropertyTreeView::VIEW_ID = "org.mitk.views.propertytreeview";
+
+QmitkPropertyTreeView::QmitkPropertyTreeView()
+ : m_Filter(NULL),
+ m_Model(NULL),
+ m_ProxyModel(NULL),
+ m_Delegate(NULL),
+ m_TreeView(NULL)
+{
+}
+
+QmitkPropertyTreeView::~QmitkPropertyTreeView()
+{
+ if (m_Delegate != NULL)
+ delete m_Delegate;
+
+ if (m_ProxyModel != NULL)
+ delete m_ProxyModel;
+
+ if (m_Model != NULL)
+ delete m_Model;
+}
+
+void QmitkPropertyTreeView::CreateQtPartControl(QWidget *parent)
+{
+ m_Filter = new QmitkLineEdit("Filter", parent);
+
+ m_Model = new QmitkPropertyTreeModel;
+
+ m_ProxyModel = new QmitkPropertyTreeFilterProxyModel;
+ m_ProxyModel->setSourceModel(m_Model);
+ m_ProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
+ m_ProxyModel->setDynamicSortFilter(true);
+
+ m_Delegate = new QmitkPropertyDelegate;
+
+ connect(m_Filter, SIGNAL(textChanged(const QString &)), this, SLOT(OnFilterChanged(const QString &)));
+
+ m_TreeView = new QTreeView(parent);
+
+ m_TreeView->setModel(m_ProxyModel);
+ m_TreeView->setItemDelegateForColumn(1, m_Delegate);
+ m_TreeView->setSortingEnabled(true);
+ m_TreeView->setIndentation(16);
+ m_TreeView->setAlternatingRowColors(true);
+ m_TreeView->setSelectionMode(QAbstractItemView::SingleSelection);
+ m_TreeView->setSelectionBehavior(QAbstractItemView::SelectItems);
+
+ QVBoxLayout *layout = new QVBoxLayout(parent);
+
+ layout->addWidget(m_Filter);
+ layout->addWidget(m_TreeView);
+}
+
+void QmitkPropertyTreeView::OnFilterChanged(const QString &filter)
+{
+ m_ProxyModel->setFilterWildcard(filter);
+ m_TreeView->expandAll();
+}
+
+void QmitkPropertyTreeView::OnSelectionChanged(berry::IWorkbenchPart::Pointer, const QList &nodes)
+{
+ if (nodes.empty() || nodes.front().IsNull())
+ return;
+
+ std::ostringstream partName;
+ partName << "Properties (" << nodes.front()->GetName() << ")";
+
+ SetPartName(partName.str().c_str());
+
+ m_Model->SetProperties(nodes.front()->GetPropertyList());
+}
+
+void QmitkPropertyTreeView::SetFocus()
+{
+ m_Filter->setFocus();
+}
diff --git a/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkPropertyTreeView.h b/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkPropertyTreeView.h
new file mode 100644
index 0000000000..f8e71be711
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkPropertyTreeView.h
@@ -0,0 +1,61 @@
+/*===================================================================
+
+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 QMITKPROPERTYTREEVIEW_H
+#define QMITKPROPERTYTREEVIEW_H
+
+#include
+#include
+
+class QmitkLineEdit;
+class QmitkPropertyDelegate;
+class QmitkPropertyTreeModel;
+class QmitkPropertyTreeFilterProxyModel;
+class QTreeView;
+
+class MITK_QT_DATAMANAGER QmitkPropertyTreeView : public QmitkAbstractView
+{
+ Q_OBJECT
+
+public:
+ berryObjectMacro(QmitkPropertyTreeView)
+
+ static const std::string VIEW_ID;
+
+ QmitkPropertyTreeView();
+ ~QmitkPropertyTreeView();
+
+ void CreateQtPartControl(QWidget *parent);
+ void OnSelectionChanged(berry::IWorkbenchPart::Pointer part, const QList &nodes);
+
+protected:
+ void SetFocus();
+
+private slots:
+ void OnFilterChanged(const QString &filter);
+
+private:
+ QmitkPropertyTreeView(const QmitkPropertyTreeView &);
+ QmitkPropertyTreeView & operator=(const QmitkPropertyTreeView &);
+
+ QmitkLineEdit *m_Filter;
+ QmitkPropertyTreeModel *m_Model;
+ QmitkPropertyTreeFilterProxyModel *m_ProxyModel;
+ QmitkPropertyDelegate *m_Delegate;
+ QTreeView *m_TreeView;
+};
+
+#endif
diff --git a/Plugins/org.mitk.gui.qt.datamanager/src/internal/mitkPluginActivator.cpp b/Plugins/org.mitk.gui.qt.datamanager/src/internal/mitkPluginActivator.cpp
index e774ec0ae8..15bf6d8490 100644
--- a/Plugins/org.mitk.gui.qt.datamanager/src/internal/mitkPluginActivator.cpp
+++ b/Plugins/org.mitk.gui.qt.datamanager/src/internal/mitkPluginActivator.cpp
@@ -1,42 +1,44 @@
/*===================================================================
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 "mitkPluginActivator.h"
#include
#include "QmitkPropertyListView.h"
+#include "QmitkPropertyTreeView.h"
#include "../QmitkDataManagerView.h"
#include "../QmitkDataManagerPreferencePage.h"
#include "../QmitkDataManagerHotkeysPrefPage.h"
namespace mitk {
void PluginActivator::start(ctkPluginContext* context)
{
BERRY_REGISTER_EXTENSION_CLASS(QmitkDataManagerView, context)
BERRY_REGISTER_EXTENSION_CLASS(QmitkPropertyListView, context)
+ BERRY_REGISTER_EXTENSION_CLASS(QmitkPropertyTreeView, context)
BERRY_REGISTER_EXTENSION_CLASS(QmitkDataManagerPreferencePage, context)
BERRY_REGISTER_EXTENSION_CLASS(QmitkDataManagerHotkeysPrefPage, context)
}
void PluginActivator::stop(ctkPluginContext* context)
{
Q_UNUSED(context)
}
}
Q_EXPORT_PLUGIN2(org_mitk_gui_qt_datamanager, mitk::PluginActivator)