diff --git a/Plugins/org.mitk.gui.qt.application/files.cmake b/Plugins/org.mitk.gui.qt.application/files.cmake index 19301027e2..2f3746459b 100644 --- a/Plugins/org.mitk.gui.qt.application/files.cmake +++ b/Plugins/org.mitk.gui.qt.application/files.cmake @@ -1,85 +1,87 @@ set(SRC_CPP_FILES QmitkAbstractDataNodeAction.cpp QmitkCloseProjectAction.cpp QmitkDataNodeColorAction.cpp QmitkDataNodeColorMapAction.cpp QmitkDataNodeComponentAction.cpp QmitkDataNodeContextMenu.cpp QmitkDataNodeGlobalReinitAction.cpp QmitkDataNodeHideAllNodesAction.cpp QmitkDataNodeOpacityAction.cpp QmitkDataNodeReinitAction.cpp QmitkDataNodeRemoveAction.cpp QmitkDataNodeShowDetailsAction.cpp QmitkDataNodeShowSelectedNodesAction.cpp QmitkDataNodeSurfaceRepresentationAction.cpp QmitkDataNodeTextureInterpolationAction.cpp QmitkDataNodeToggleVisibilityAction.cpp QmitkDefaultDropTargetListener.cpp QmitkFileExitAction.cpp QmitkFileOpenAction.cpp QmitkFileSaveAction.cpp QmitkUndoAction.cpp QmitkRedoAction.cpp QmitkPreferencesDialog.cpp QmitkStatusBar.cpp ) set(INTERNAL_CPP_FILES org_mitk_gui_qt_application_Activator.cpp QmitkEditorsPreferencePage.cpp QmitkGeneralPreferencePage.cpp + QmitkInfoDialog.cpp QmitkShowPreferencePageHandler.cpp ) set(MOC_H_FILES src/QmitkAbstractDataNodeAction.h src/QmitkCloseProjectAction.h src/QmitkDataNodeColorAction.h src/QmitkDataNodeColorMapAction.h src/QmitkDataNodeComponentAction.h src/QmitkDataNodeGlobalReinitAction.h src/QmitkDataNodeContextMenu.h src/QmitkDataNodeHideAllNodesAction.h src/QmitkDataNodeOpacityAction.h src/QmitkDataNodeReinitAction.h src/QmitkDataNodeRemoveAction.h src/QmitkDataNodeShowDetailsAction.h src/QmitkDataNodeShowSelectedNodesAction.h src/QmitkDataNodeSurfaceRepresentationAction.h src/QmitkDataNodeTextureInterpolationAction.h src/QmitkDataNodeToggleVisibilityAction.h src/QmitkFileExitAction.h src/QmitkFileOpenAction.h src/QmitkFileSaveAction.h src/QmitkUndoAction.h src/QmitkRedoAction.h src/QmitkPreferencesDialog.h src/internal/org_mitk_gui_qt_application_Activator.h src/internal/QmitkEditorsPreferencePage.h src/internal/QmitkGeneralPreferencePage.h + src/internal/QmitkInfoDialog.h src/internal/QmitkShowPreferencePageHandler.h ) set(UI_FILES src/QmitkPreferencesDialog.ui ) set(CACHED_RESOURCE_FILES plugin.xml ) set(QRC_FILES resources/resources.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.application/src/internal/QmitkInfoDialog.cpp b/Plugins/org.mitk.gui.qt.application/src/internal/QmitkInfoDialog.cpp new file mode 100644 index 0000000000..11a8efc17d --- /dev/null +++ b/Plugins/org.mitk.gui.qt.application/src/internal/QmitkInfoDialog.cpp @@ -0,0 +1,127 @@ +/*=================================================================== + +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 "QmitkInfoDialog.h" + +#include "QmitkDataStorageComboBox.h" + +#include + +#include +#include +#include +#include +#include +#include + +QmitkInfoDialog::QmitkInfoDialog(const QList& nodes, QWidget* parent /*= nullptr*/, Qt::WindowFlags flags /*= nullptr */) + : QDialog(parent, flags) +{ + auto parentLayout = new QGridLayout; + auto dataStorageComboBox = new QmitkDataStorageComboBox(this, true); + m_KeyWord = new QLineEdit; + m_KeyWord->installEventFilter(this); + m_SearchButton = new QPushButton("Search (F3)", this); + m_SearchButton->installEventFilter(this); + m_TextBrowser = new QTextBrowser(this); + QPushButton* cancelButton = new QPushButton("Cancel", this); + + setMinimumSize(512, 512); + setLayout(parentLayout); + setSizeGripEnabled(true); + setModal(true); + + parentLayout->addWidget(dataStorageComboBox, 0, 0, 1, 2); + parentLayout->addWidget(m_KeyWord, 1, 0); + parentLayout->addWidget(m_SearchButton, 1, 1); + parentLayout->addWidget(m_TextBrowser, 2, 0, 1, 2); + parentLayout->addWidget(cancelButton, 3, 0, 1, 2); + + connect(dataStorageComboBox, &QmitkDataStorageComboBox::OnSelectionChanged, this, &QmitkInfoDialog::OnSelectionChanged); + + for(auto& node : nodes) + { + dataStorageComboBox->AddNode(node); + } + + connect(m_KeyWord, &QLineEdit::textChanged, this, &QmitkInfoDialog::KeyWordTextChanged); + connect(m_SearchButton, &QPushButton::clicked, this, &QmitkInfoDialog::OnSearchButtonClicked); + connect(cancelButton, &QPushButton::clicked, this, &QmitkInfoDialog::OnCancelButtonClicked); + + cancelButton->setDefault(true); +} + +void QmitkInfoDialog::OnSelectionChanged(const mitk::DataNode* node) +{ + if (nullptr == node) + { + return; + } + + std::ostringstream s; + itk::Indent i(2); + mitk::BaseData* baseData = node->GetData(); + if (nullptr != baseData) + { + baseData->Print(s, i); + } + + m_TextBrowser->setPlainText(QString::fromStdString(s.str())); +} + +void QmitkInfoDialog::OnSearchButtonClicked(bool /*checked*/ /*= false */) +{ + QString keyWord = m_KeyWord->text(); + QString text = m_TextBrowser->toPlainText(); + + if (keyWord.isEmpty() || text.isEmpty()) + { + return; + } + + m_TextBrowser->find(keyWord); + m_SearchButton->setText("Search Next(F3)"); +} + +void QmitkInfoDialog::OnCancelButtonClicked(bool /*checked*/ /*= false */) +{ + done(0); +} + +bool QmitkInfoDialog::eventFilter(QObject* obj, QEvent* event) +{ + if (event->type() == QEvent::KeyPress) + { + QKeyEvent *keyEvent = static_cast(event); + if (keyEvent->key() == Qt::Key_F3 || keyEvent->key() == Qt::Key_Return) + { + // trigger deletion of selected node(s) + OnSearchButtonClicked(true); + // return true: this means the delete key event is not send to the table + return true; + } + } + // standard event processing + return QObject::eventFilter(obj, event); +} + +void QmitkInfoDialog::KeyWordTextChanged(const QString& /*text*/) +{ + QTextCursor textCursor = m_TextBrowser->textCursor(); + textCursor.setPosition(0); + m_TextBrowser->setTextCursor(textCursor); + m_SearchButton->setText("Search (F3)"); +} diff --git a/Plugins/org.mitk.gui.qt.application/src/internal/QmitkInfoDialog.h b/Plugins/org.mitk.gui.qt.application/src/internal/QmitkInfoDialog.h new file mode 100644 index 0000000000..f5cdd17572 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.application/src/internal/QmitkInfoDialog.h @@ -0,0 +1,54 @@ +/*=================================================================== + +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 QMITKINFODIALOG_H +#define QMITKINFODIALOG_H + +#include + +#include + +class QLineEdit; +class QTextBrowser; + +class QmitkInfoDialog : public QDialog +{ + Q_OBJECT + +public: + + QmitkInfoDialog(const QList& nodes, QWidget* parent = nullptr, Qt::WindowFlags flags = nullptr); + +public Q_SLOTS: + + void OnSelectionChanged(const mitk::DataNode*); + void OnSearchButtonClicked(bool checked = false); + void OnCancelButtonClicked(bool checked = false); + void KeyWordTextChanged(const QString& text); + +protected: + + bool eventFilter(QObject* obj, QEvent* event) override; + +protected: + + QLineEdit* m_KeyWord; + QPushButton* m_SearchButton; + QTextBrowser* m_TextBrowser; + +}; + +#endif // QMITKINFODIALOG_H diff --git a/Plugins/org.mitk.gui.qt.datamanager/files.cmake b/Plugins/org.mitk.gui.qt.datamanager/files.cmake index 8f3295caaa..13fd4bb937 100644 --- a/Plugins/org.mitk.gui.qt.datamanager/files.cmake +++ b/Plugins/org.mitk.gui.qt.datamanager/files.cmake @@ -1,38 +1,36 @@ set(SRC_CPP_FILES berrySingleNodeSelection.cpp QmitkDataManagerView.cpp QmitkDataManagerPreferencePage.cpp ) set(INTERNAL_CPP_FILES mitkPluginActivator.cpp - QmitkInfoDialog.cpp QmitkDataManagerItemDelegate.cpp ) set(MOC_H_FILES src/QmitkDataManagerView.h src/QmitkDataManagerPreferencePage.h - src/internal/QmitkInfoDialog.h src/internal/QmitkDataManagerItemDelegate.h src/internal/mitkPluginActivator.h ) set(CPP_FILES ) set(CACHED_RESOURCE_FILES plugin.xml resources/data-manager.svg ) 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/src/QmitkDataManagerView.cpp b/Plugins/org.mitk.gui.qt.datamanager/src/QmitkDataManagerView.cpp index 265701ddde..b6aa590ef2 100644 --- a/Plugins/org.mitk.gui.qt.datamanager/src/QmitkDataManagerView.cpp +++ b/Plugins/org.mitk.gui.qt.datamanager/src/QmitkDataManagerView.cpp @@ -1,294 +1,293 @@ /*=================================================================== 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 "QmitkDataManagerView.h" // mitk gui qt datamanager -#include "src/internal/QmitkInfoDialog.h" #include "src/internal/QmitkDataManagerItemDelegate.h" // mitk core #include #include #include #include #include #include #include #include #include #include #include #include #include #include // qt widgets module #include #include #include #include #include // beery plugins #include #include #include #include #include #include #include #include #include // mitk core services plugin #include #include // mitk gui common plugin #include #include #include // mitk gui qt application plugin #include // mitk gui qt common plugin #include // qt #include #include #include #include #include #include #include #include #include #include const QString QmitkDataManagerView::VIEW_ID = "org.mitk.views.datamanager"; QmitkDataManagerView::QmitkDataManagerView() : m_GlobalReinitOnNodeDelete(true) , m_GlobalReinitOnNodeVisibilityChanged(false) , m_ItemDelegate(nullptr) { } QmitkDataManagerView::~QmitkDataManagerView() { // nothing here } void QmitkDataManagerView::CreateQtPartControl(QWidget* parent) { m_CurrentRowCount = 0; m_Parent = parent; //# Preferences berry::IPreferencesService* prefService = berry::Platform::GetPreferencesService(); berry::IBerryPreferences::Pointer prefs = (prefService->GetSystemPreferences()->Node(VIEW_ID)).Cast(); assert(prefs); prefs->OnChanged.AddListener(berry::MessageDelegate1(this, &QmitkDataManagerView::OnPreferencesChanged)); //# GUI m_NodeTreeModel = new QmitkDataStorageTreeModel(GetDataStorage(), prefs->GetBool("Place new nodes on top", true)); m_NodeTreeModel->setParent(parent); m_NodeTreeModel->SetAllowHierarchyChange(prefs->GetBool("Allow changing of parent node", false)); m_SurfaceDecimation = prefs->GetBool("Use surface decimation", false); // Prepare filters m_HelperObjectFilterPredicate = mitk::NodePredicateOr::New( mitk::NodePredicateProperty::New("helper object", mitk::BoolProperty::New(true)), mitk::NodePredicateProperty::New("hidden object", mitk::BoolProperty::New(true))); m_NodeWithNoDataFilterPredicate = mitk::NodePredicateData::New(nullptr); m_FilterModel = new QmitkDataStorageFilterProxyModel(); m_FilterModel->setSourceModel(m_NodeTreeModel); m_FilterModel->AddFilterPredicate(m_HelperObjectFilterPredicate); m_FilterModel->AddFilterPredicate(m_NodeWithNoDataFilterPredicate); //# Tree View (experimental) m_NodeTreeView = new QTreeView; m_NodeTreeView->setHeaderHidden(true); m_NodeTreeView->setSelectionMode(QAbstractItemView::ExtendedSelection); m_NodeTreeView->setSelectionBehavior(QAbstractItemView::SelectRows); m_NodeTreeView->setAlternatingRowColors(true); m_NodeTreeView->setDragEnabled(true); m_NodeTreeView->setDropIndicatorShown(true); m_NodeTreeView->setAcceptDrops(true); m_NodeTreeView->setContextMenuPolicy(Qt::CustomContextMenu); m_NodeTreeView->setModel(m_FilterModel); m_NodeTreeView->setTextElideMode(Qt::ElideMiddle); m_ItemDelegate = new QmitkDataManagerItemDelegate(m_NodeTreeView); m_NodeTreeView->setItemDelegate(m_ItemDelegate); connect(m_NodeTreeModel, SIGNAL(rowsInserted(const QModelIndex&, int, int)), this, SLOT(NodeTreeViewRowsInserted(const QModelIndex&, int, int))); connect(m_NodeTreeModel, SIGNAL(rowsRemoved(const QModelIndex&, int, int)), this, SLOT(NodeTreeViewRowsRemoved(const QModelIndex&, int, int))); connect(m_NodeTreeView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), this, SLOT(NodeSelectionChanged(const QItemSelection &, const QItemSelection &))); connect(m_NodeTreeModel, &QmitkDataStorageTreeModel::nodeVisibilityChanged, this, &QmitkDataManagerView::OnNodeVisibilityChanged); // data node context menu and menu actions m_DataNodeContextMenu = new QmitkDataNodeContextMenu(GetSite(), m_NodeTreeView); m_DataNodeContextMenu->SetDataStorage(GetDataStorage()); m_DataNodeContextMenu->SetSurfaceDecimation(m_SurfaceDecimation); connect(m_NodeTreeView, SIGNAL(customContextMenuRequested(const QPoint&)), m_DataNodeContextMenu, SLOT(OnContextMenuRequested(const QPoint&))); berry::IEditorRegistry* editorRegistry = berry::PlatformUI::GetWorkbench()->GetEditorRegistry(); QList editors = editorRegistry->GetEditors("*.mitk"); if (editors.size() > 1) { m_ShowInMapper = new QSignalMapper(this); foreach(berry::IEditorDescriptor::Pointer descriptor, editors) { QAction* action = new QAction(descriptor->GetLabel(), this); m_ShowInActions << action; m_ShowInMapper->connect(action, SIGNAL(triggered()), m_ShowInMapper, SLOT(map())); m_ShowInMapper->setMapping(action, descriptor->GetId()); } connect(m_ShowInMapper, SIGNAL(mapped(QString)), this, SLOT(ShowIn(QString))); } QGridLayout* dndFrameWidgetLayout = new QGridLayout; dndFrameWidgetLayout->addWidget(m_NodeTreeView, 0, 0); dndFrameWidgetLayout->setContentsMargins(0, 0, 0, 0); m_DnDFrameWidget = new QmitkDnDFrameWidget(m_Parent); m_DnDFrameWidget->setLayout(dndFrameWidgetLayout); QVBoxLayout* layout = new QVBoxLayout(parent); layout->addWidget(m_DnDFrameWidget); layout->setContentsMargins(0, 0, 0, 0); m_Parent->setLayout(layout); } void QmitkDataManagerView::SetFocus() { } void QmitkDataManagerView::NodeChanged(const mitk::DataNode* /*node*/) { // m_FilterModel->invalidate(); // fix as proposed by R. Khlebnikov in the mitk-users mail from 02.09.2014 QMetaObject::invokeMethod(m_FilterModel, "invalidate", Qt::QueuedConnection); } void QmitkDataManagerView::OnPreferencesChanged(const berry::IBerryPreferences* prefs) { if (m_NodeTreeModel->GetPlaceNewNodesOnTopFlag() != prefs->GetBool("Place new nodes on top", true)) { m_NodeTreeModel->SetPlaceNewNodesOnTop(!m_NodeTreeModel->GetPlaceNewNodesOnTopFlag()); } bool hideHelperObjects = !prefs->GetBool("Show helper objects", false); if (m_FilterModel->HasFilterPredicate(m_HelperObjectFilterPredicate) != hideHelperObjects) { if (hideHelperObjects) { m_FilterModel->AddFilterPredicate(m_HelperObjectFilterPredicate); } else { m_FilterModel->RemoveFilterPredicate(m_HelperObjectFilterPredicate); } } bool hideNodesWithNoData = !prefs->GetBool("Show nodes containing no data", false); if (m_FilterModel->HasFilterPredicate(m_NodeWithNoDataFilterPredicate) != hideNodesWithNoData) { if (hideNodesWithNoData) { m_FilterModel->AddFilterPredicate(m_NodeWithNoDataFilterPredicate); } else { m_FilterModel->RemoveFilterPredicate(m_NodeWithNoDataFilterPredicate); } } m_GlobalReinitOnNodeDelete = prefs->GetBool("Call global reinit if node is deleted", true); m_GlobalReinitOnNodeVisibilityChanged = prefs->GetBool("Call global reinit if node visibility is changed", false); m_NodeTreeView->expandAll(); m_SurfaceDecimation = prefs->GetBool("Use surface decimation", false); m_DataNodeContextMenu->SetSurfaceDecimation(m_SurfaceDecimation); m_NodeTreeModel->SetAllowHierarchyChange(prefs->GetBool("Allow changing of parent node", false)); GlobalReinitAction::Run(GetSite(), GetDataStorage()); } ////////////////////////////////////////////////////////////////////////// // Node tree modification ////////////////////////////////////////////////////////////////////////// void QmitkDataManagerView::NodeTreeViewRowsInserted(const QModelIndex& parent, int /*start*/, int /*end*/) { QModelIndex viewIndex = m_FilterModel->mapFromSource(parent); m_NodeTreeView->setExpanded(viewIndex, true); // a new row was inserted if (m_CurrentRowCount == 0 && m_NodeTreeModel->rowCount() == 1) { mitk::WorkbenchUtil::OpenRenderWindowPart(GetSite()->GetPage()); m_CurrentRowCount = m_NodeTreeModel->rowCount(); } } void QmitkDataManagerView::NodeTreeViewRowsRemoved(const QModelIndex& /*parent*/, int /*start*/, int /*end*/) { m_CurrentRowCount = m_NodeTreeModel->rowCount(); } void QmitkDataManagerView::NodeSelectionChanged(const QItemSelection& /*selected*/, const QItemSelection& /*deselected*/) { auto selectedNodes = GetCurrentSelection(); auto nodeSet = m_NodeTreeModel->GetNodeSet(); for (auto node : nodeSet) { if (node.IsNotNull()) { node->SetSelected(selectedNodes.contains(node)); } } } void QmitkDataManagerView::OnNodeVisibilityChanged() { if (m_GlobalReinitOnNodeVisibilityChanged) { GlobalReinitAction::Run(GetSite(), GetDataStorage()); } else { mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } } void QmitkDataManagerView::ShowIn(const QString& editorId) { berry::IWorkbenchPage::Pointer page = GetSite()->GetPage(); berry::IEditorInput::Pointer input(new mitk::DataStorageEditorInput(GetDataStorageReference())); page->OpenEditor(input, editorId, false, berry::IWorkbenchPage::MATCH_ID); } QItemSelectionModel* QmitkDataManagerView::GetDataNodeSelectionModel() const { return m_NodeTreeView->selectionModel(); } diff --git a/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkInfoDialog.cpp b/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkInfoDialog.cpp deleted file mode 100644 index 29240dbbce..0000000000 --- a/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkInfoDialog.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/*=================================================================== - -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 "QmitkInfoDialog.h" - -#include "QmitkDataStorageComboBox.h" - -#include - -#include -#include -#include -#include -#include -#include - -QmitkInfoDialog::QmitkInfoDialog( const QList &_Nodes, QWidget * parent /*= 0*/, Qt::WindowFlags f /*= 0 */ ) -: QDialog(parent, f) -{ - // DIM - auto parentLayout = new QGridLayout; - auto _QmitkDataStorageComboBox = new QmitkDataStorageComboBox(this, true); - m_KeyWord = new QLineEdit; - m_KeyWord->installEventFilter(this); - m_SearchButton = new QPushButton("Search (F3)", this); - m_SearchButton->installEventFilter(this); - m_TextBrowser = new QTextBrowser(this); - QPushButton* _CancelButton = new QPushButton("Cancel", this); - - // SET - this->setMinimumSize(512, 512); - this->setLayout(parentLayout); - this->setSizeGripEnabled(true); - this->setModal(true); - - parentLayout->addWidget(_QmitkDataStorageComboBox, 0, 0, 1, 2); - parentLayout->addWidget(m_KeyWord, 1, 0); - parentLayout->addWidget(m_SearchButton, 1, 1); - parentLayout->addWidget(m_TextBrowser, 2, 0, 1, 2); - parentLayout->addWidget(_CancelButton, 3, 0, 1, 2); - - QObject::connect( _QmitkDataStorageComboBox, SIGNAL( OnSelectionChanged( const mitk::DataNode* ) ) - , this, SLOT( OnSelectionChanged( const mitk::DataNode* ) ) ); - - foreach(mitk::DataNode::Pointer node, _Nodes) - { - _QmitkDataStorageComboBox->AddNode(node); - } - - QObject::connect( m_KeyWord, SIGNAL( textChanged ( const QString & ) ) - , this, SLOT( KeyWordTextChanged(const QString &) ) ); - - QObject::connect( m_SearchButton, SIGNAL( clicked ( bool ) ) - , this, SLOT( OnSearchButtonClicked( bool ) ) ); - - QObject::connect( _CancelButton, SIGNAL( clicked ( bool ) ) - , this, SLOT( OnCancelButtonClicked( bool ) ) ); - - _CancelButton->setDefault(true); - -} - -void QmitkInfoDialog::OnSelectionChanged( const mitk::DataNode* node ) -{ - std::ostringstream s; - itk::Indent i(2); - mitk::BaseData* _BaseData = node->GetData(); - if(_BaseData) - _BaseData->Print(s, i); - m_TextBrowser->setPlainText(QString::fromStdString(s.str())); -} - -void QmitkInfoDialog::OnSearchButtonClicked( bool /*checked*/ /*= false */ ) -{ - QString keyWord = m_KeyWord->text(); - QString text = m_TextBrowser->toPlainText(); - - if(keyWord.isEmpty() || text.isEmpty()) - return; - - m_TextBrowser->find(keyWord); - m_SearchButton->setText("Search Next(F3)"); -} - -void QmitkInfoDialog::OnCancelButtonClicked( bool /*checked*/ /*= false */ ) -{ - this->done(0); -} - -bool QmitkInfoDialog::eventFilter( QObject *obj, QEvent *event ) -{ - if (event->type() == QEvent::KeyPress) - { - QKeyEvent *keyEvent = static_cast(event); - if(keyEvent->key() == Qt::Key_F3 || keyEvent->key() == Qt::Key_Return) - { - // trigger deletion of selected node(s) - this->OnSearchButtonClicked(true); - // return true: this means the delete key event is not send to the table - return true; - } - } - // standard event processing - return QObject::eventFilter(obj, event); -} - -void QmitkInfoDialog::KeyWordTextChanged(const QString & /*text*/) -{ - QTextCursor textCursor = m_TextBrowser->textCursor(); - textCursor.setPosition(0); - m_TextBrowser->setTextCursor(textCursor); - m_SearchButton->setText("Search (F3)"); -} diff --git a/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkInfoDialog.h b/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkInfoDialog.h deleted file mode 100644 index 30a03edb08..0000000000 --- a/Plugins/org.mitk.gui.qt.datamanager/src/internal/QmitkInfoDialog.h +++ /dev/null @@ -1,50 +0,0 @@ -/*=================================================================== - -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 QMITKINFODIALOG_H_ -#define QMITKINFODIALOG_H_ - -#include - -#include - -class QTextBrowser; -class QLineEdit; - -/// -/// A small class which "eats" all Del-Key-pressed events on the node table. -/// When the Del Key is pressed selected nodes should be removed. -/// -class QmitkInfoDialog : public QDialog -{ - Q_OBJECT - - public: - QmitkInfoDialog(const QList& _Nodes, QWidget * parent = nullptr, Qt::WindowFlags f = nullptr ); - public slots: - void OnSelectionChanged(const mitk::DataNode*); - void OnSearchButtonClicked ( bool checked = false ); - void OnCancelButtonClicked ( bool checked = false ); - void KeyWordTextChanged(const QString & text); - protected: - bool eventFilter(QObject *obj, QEvent *event) override; - protected: - QLineEdit* m_KeyWord; - QPushButton* m_SearchButton; - QTextBrowser* m_TextBrowser; -}; - -#endif // QMITKINFODIALOG_H_