diff --git a/Plugins/org.blueberry.ui.qt/plugin.xml b/Plugins/org.blueberry.ui.qt/plugin.xml
index f4402e5325..561a9ec8a7 100644
--- a/Plugins/org.blueberry.ui.qt/plugin.xml
+++ b/Plugins/org.blueberry.ui.qt/plugin.xml
@@ -1,466 +1,465 @@
-
-
+
+
-
diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkPreferencesDialog.cpp b/Plugins/org.mitk.gui.qt.application/src/QmitkPreferencesDialog.cpp
index 8e0d43c5cc..ae697ffde8 100644
--- a/Plugins/org.mitk.gui.qt.application/src/QmitkPreferencesDialog.cpp
+++ b/Plugins/org.mitk.gui.qt.application/src/QmitkPreferencesDialog.cpp
@@ -1,454 +1,488 @@
/*===================================================================
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 "QmitkPreferencesDialog.h"
#include "berryPlatform.h"
#include "berryPlatformUI.h"
#include "berryIWorkbench.h"
#include "berryIConfigurationElement.h"
#include "berryIExtensionRegistry.h"
#include "berryIExtension.h"
#include
#include
#include "internal/org_mitk_gui_qt_application_Activator.h"
#include
#include
#include
#include
#include
#include
using namespace std;
+static std::vector splitString(const std::string &s, char delim=' ')
+{
+ std::vector < std::string > elems;
+ std::stringstream ss(s);
+ std::string item;
+ while (std::getline(ss, item, delim))
+ {
+ elems.push_back(item);
+ }
+ return elems;
+}
+
class QmitkPreferencesDialogPrivate : public Ui::QmitkPreferencesDialog
{
public:
///
/// Just a stub class for holding information on prefpages (metadata)
///
struct PrefPage
{
PrefPage(QString _id, QString _name, QString _category
- , QString _className, QString _keywords, berry::IConfigurationElement::Pointer _confElem)
+ , QString _className, QString _keywords, berry::IConfigurationElement::Pointer _confElem)
: id(_id), name(_name), category(_category), className(_className), keywords(_keywords),
prefPage(nullptr), confElem(_confElem), treeWidgetItem(nullptr)
{}
bool operator==(const PrefPage& other)
{ return id == other.id; }
bool operator<(const PrefPage& other)
{ return name < other.name; }
QString id;
QString name;
QString category;
QString className;
QString keywords;
berry::IQtPreferencePage* prefPage;
berry::IConfigurationElement::Pointer confElem;
QTreeWidgetItem* treeWidgetItem;
};
QmitkPreferencesDialogPrivate()
: m_CurrentPage(0)
{
berry::IExtensionRegistry* xpService = berry::Platform::GetExtensionRegistry();
// m_PrefPages
QList prefPages(xpService->GetConfigurationElementsFor("org.blueberry.ui.preferencePages"));
QList keywordExts(xpService->GetConfigurationElementsFor("org.blueberry.ui.keywords"));
QList::iterator prefPagesIt;
QList::iterator keywordRefsIt;
for (prefPagesIt = prefPages.begin(); prefPagesIt != prefPages.end(); ++prefPagesIt)
{
QString id = (*prefPagesIt)->GetAttribute("id");
QString name = (*prefPagesIt)->GetAttribute("name");
QString className = (*prefPagesIt)->GetAttribute("class");
if(!id.isEmpty() && !name.isEmpty() && !className.isEmpty())
{
QString keywordLabels;
QString category = (*prefPagesIt)->GetAttribute("category");
//# collect keywords
QList keywordRefs = (*prefPagesIt)->GetChildren("keywordreference"); // get all keyword references
for (keywordRefsIt = keywordRefs.begin()
- ; keywordRefsIt != keywordRefs.end(); ++keywordRefsIt) // iterate over all refs
+ ; keywordRefsIt != keywordRefs.end(); ++keywordRefsIt) // iterate over all refs
{
QString keywordRefId = (*keywordRefsIt)->GetAttribute("id"); // get referenced id
for (QList::iterator keywordExtsIt = keywordExts.begin();
keywordExtsIt != keywordExts.end(); ++keywordExtsIt) // iterate over all keywords
{
QString keywordId = (*keywordExtsIt)->GetAttribute("id"); // get keyword id
if(keywordId == keywordRefId) // if referenced id is equals the current keyword id
{
//# collect all keywords from label attribute with a tokenizer
QString currLabel = (*keywordExtsIt)->GetAttribute("label");
currLabel = currLabel.toLower();
if (!currLabel.isEmpty()) keywordLabels += QString(" ") + currLabel;
//break; // break here; possibly search for other referenced keywords
}
}
}
// add information as PrefPage
m_PrefPages.push_back(PrefPage(id, name, category, className, keywordLabels, berry::IConfigurationElement::Pointer(*prefPagesIt)));
}
}
}
///
/// Saves all treewidgetitems in a map, the key is the id of the preferencepage.
///
QList m_PrefPages;
int m_CurrentPage;
};
QmitkPreferencesDialog::QmitkPreferencesDialog(QWidget * parent, Qt::WindowFlags f)
: QDialog(parent, f), d(new QmitkPreferencesDialogPrivate)
{
d->setupUi(this);
QObject::connect(d->m_Keyword, SIGNAL(editingFinished()), this, SLOT(OnKeywordEditingFinished()));
QObject::connect(d->m_Keyword, SIGNAL(textChanged(QString)), this, SLOT(OnKeywordTextChanged(QString)));
QObject::connect(d->m_PreferencesTree, SIGNAL(itemSelectionChanged()), this, SLOT(OnPreferencesTreeItemSelectionChanged()));
QPushButton* importButton = d->buttonBox->addButton("Import...", QDialogButtonBox::ActionRole);
QObject::connect(importButton, SIGNAL(clicked()), this, SLOT(OnImportButtonClicked()));
QPushButton* exportButton = d->buttonBox->addButton("Export...", QDialogButtonBox::ActionRole);
QObject::connect(exportButton, SIGNAL(clicked()), this, SLOT(OnExportButtonClicked()));
QObject::connect(this, SIGNAL(accepted()), this, SLOT(OnDialogAccepted()));
QObject::connect(this, SIGNAL(rejected()), this, SLOT(OnDialogRejected()));
this->UpdateTree();
}
QmitkPreferencesDialog::~QmitkPreferencesDialog()
{
}
void QmitkPreferencesDialog::SetSelectedPage(const QString& id)
{
for(QList::iterator it = d->m_PrefPages.begin(); it != d->m_PrefPages.end(); ++it)
{
if(it->id == id)
{
d->m_PreferencesTree->setCurrentItem(it->treeWidgetItem);
break;
}
}
}
void QmitkPreferencesDialog::OnImportButtonClicked()
{
int answer = QMessageBox::question(this, "Importing Preferences"
- , "All existing preferences will be overwritten!\nAre you sure that you want to import other preferences?", QMessageBox::Yes | QMessageBox::No );
+ , "All existing preferences will be overwritten!\nAre you sure that you want to import other preferences?", QMessageBox::Yes | QMessageBox::No );
if(answer == QMessageBox::No)
return;
try
{
berry::IBerryPreferencesService* berryPrefService =
dynamic_cast(berry::Platform::GetPreferencesService());
if(berryPrefService != nullptr)
{
static QString importDir = "";
QString fileName = QFileDialog::getOpenFileName(this, tr("Choose file to import preferences"),
importDir, tr("XML files (*.xml)"));
if(!fileName.isEmpty())
{
importDir = QFileInfo(fileName).absoluteDir().path();
berryPrefService->ImportPreferences(fileName, "");
berry::IQtPreferencePage* prefPage = d->m_PrefPages[d->m_CurrentPage].prefPage;
if(prefPage)
prefPage->Update();
MITK_INFO("QmitkPreferencesDialog") << "Preferences successfully imported from " << fileName;
}
}
}
catch (Poco::Exception& pe)
{
QMessageBox::critical(this, "Error Importing", pe.message().c_str());
MITK_ERROR("QmitkPreferencesDialog") << pe.what();
}
catch (std::exception& e)
{
QMessageBox::critical(this, "Error Importing", e.what());
MITK_ERROR("QmitkPreferencesDialog") << e.what();
}
}
void QmitkPreferencesDialog::OnExportButtonClicked()
{
try
{
berry::IBerryPreferencesService* berryPrefService =
dynamic_cast(berry::Platform::GetPreferencesService());
if(berryPrefService != nullptr)
{
SavePreferences();
static QString exportDir = "";
QString fileName = QFileDialog::getSaveFileName(this, tr("Choose file to export preferences"),
exportDir, tr("XML files (*.xml)"));
if(!fileName.isEmpty())
{
if(QFileInfo(fileName).suffix() != ".xml")
{
fileName += ".xml";
}
exportDir = QFileInfo(fileName).absoluteDir().path();
berryPrefService->ExportPreferences(fileName, "");
MITK_INFO("QmitkPreferencesDialog") << "Preferences successfully exported to " << fileName;
}
}
}
catch (Poco::Exception& pe)
{
QMessageBox::critical(this, "Error Exporting", pe.message().c_str());
MITK_ERROR("QmitkPreferencesDialog") << pe.what();
}
catch (std::exception& e)
{
QMessageBox::critical(this, "Error Exporting", e.what());
MITK_ERROR("QmitkPreferencesDialog") << e.what();
}
}
void QmitkPreferencesDialog::SavePreferences()
{
berry::IQtPreferencePage* prefPage = nullptr;
for(QList::iterator it = d->m_PrefPages.begin(); it != d->m_PrefPages.end(); ++it)
{
prefPage = it->prefPage;
if(prefPage) {
prefPage->PerformOk();
}
}
/**
* Every preference page has its own preferences, which should stay the same after a system restart.
* Therefore this method flushes all the preferences, every time a change in the preferences is
* performed and confirmed.
*
*/
berry::Platform::GetPreferencesService()->GetSystemPreferences()->Flush();
}
void QmitkPreferencesDialog::OnDialogAccepted()
{
this->SavePreferences();
}
void QmitkPreferencesDialog::OnDialogRejected()
{
berry::IQtPreferencePage* prefPage = d->m_PrefPages[d->m_CurrentPage].prefPage;
if(prefPage)
prefPage->PerformCancel();
}
void QmitkPreferencesDialog::OnKeywordTextChanged(const QString & /*s*/)
{
// search for text
this->UpdateTree();
}
void QmitkPreferencesDialog::OnKeywordEditingFinished()
{
}
//bool QmitkPreferencesDialog::eventFilter( QObject *obj, QEvent *event )
//{
// if(obj == d->m_Keyword)
// {
// if(event->type() == QEvent::FocusIn && d->m_Keyword->text() == "search ...")
// {
// d->m_Keyword->setText("");
// d->m_Keyword->setStyleSheet("color: black;");
// }
// else if(event->type() == QEvent::FocusOut && d->m_Keyword->text() == "")
// {
// d->m_Keyword->setText("search ...");
// d->m_Keyword->setStyleSheet("color: gray;");
// }
// }
// return true;
//}
void QmitkPreferencesDialog::OnPreferencesTreeItemSelectionChanged()
{
if(d->m_PreferencesTree == nullptr)
return;
// TODO: create page and show it
QList selectedItems = d->m_PreferencesTree->selectedItems();
if(selectedItems.size()>0)
{
d->m_CurrentPage = 0;
berry::IWorkbench* workbench = berry::PlatformUI::GetWorkbench();
for(QList::iterator it = d->m_PrefPages.begin(); it != d->m_PrefPages.end(); ++it, ++d->m_CurrentPage)
{
if(it->treeWidgetItem == selectedItems.at(0))
{
d->m_Headline->setText(it->name);
if(it->prefPage == nullptr)
{
berry::IPreferencePage* page = it->confElem->CreateExecutableExtension("class");
it->prefPage = dynamic_cast(page);
it->prefPage->Init(berry::IWorkbench::Pointer(workbench));
it->prefPage->CreateQtControl(d->m_PreferencesPanel);
d->m_PreferencesPanel->addWidget(it->prefPage->GetQtControl());
}
d->m_PreferencesPanel->setCurrentWidget(it->prefPage->GetQtControl());
break;
}
}
}
}
void QmitkPreferencesDialog::UpdateTree()
{
if(d->m_PreferencesTree == nullptr)
return;
d->m_PreferencesTree->sortByColumn(0, Qt::AscendingOrder);
//m_PreferencesTree->clear();
QString keyword = d->m_Keyword->text().toLower();
map items;
std::list< QList::iterator > deferredItems;
for (QList::iterator it = d->m_PrefPages.begin();
- it != d->m_PrefPages.end(); ++it)
+ it != d->m_PrefPages.end(); ++it)
{
if (it->treeWidgetItem == nullptr)
{
if (it->category.isEmpty())
{
it->treeWidgetItem = new QTreeWidgetItem(d->m_PreferencesTree);
it->treeWidgetItem->setText(0, it->name);
items[it->id] = it->treeWidgetItem;
}
else
{
// the parent might not be created yet
deferredItems.push_back(it);
}
}
}
// deal with deferred items. We do not know how many levels
// of parents need to be created
auto currentItem = deferredItems.begin();
while (currentItem != deferredItems.end())
{
auto currentItemContent = *currentItem;
if (items[currentItemContent->category] != nullptr)
{
currentItemContent->treeWidgetItem = new QTreeWidgetItem(items[currentItemContent->category]);
currentItemContent->treeWidgetItem->setText(0, currentItemContent->name);
items[currentItemContent->id] = currentItemContent->treeWidgetItem;
deferredItems.erase(currentItem);
currentItem = deferredItems.begin();
}
else
{
++currentItem;
}
}
if (!deferredItems.empty())
{
MITK_ERROR << "Unknown preference category. They are added top-level.";
for (const auto ¤tItemContent : deferredItems)
{
currentItemContent->treeWidgetItem = new QTreeWidgetItem(d->m_PreferencesTree);
currentItemContent->treeWidgetItem->setText(0, currentItemContent->name);
items[currentItemContent->id] = currentItemContent->treeWidgetItem;
}
}
+ //First, set all pages to hidden to avoid prolems
+ //when iterating over the child page first which contains a specific keyword
+ //and sets the parent to visible
+ //but after this the parent is searched for the keyword. However, the keyword might not be available
+ //so the parent and all of its children will be set to hidden.
+ if(!keyword.isEmpty())
+ {
+ for (QList::iterator it = d->m_PrefPages.begin();
+ it != d->m_PrefPages.end(); ++it)
+ {
+ it->treeWidgetItem->setHidden(true);
+ }
+ }
// we have to iterate over the list a second time, as only
// now all parents and items are guaranteed to be created
for (QList::iterator it = d->m_PrefPages.begin();
- it != d->m_PrefPages.end(); ++it)
+ it != d->m_PrefPages.end(); ++it)
{
-
// hide treeWidgetItem if keyword not matches
if(!keyword.isEmpty())
{
- if (it->keywords.indexOf(keyword) == -1)
+ //Split text of search box into multiple single strings
+ vector keywordsAvailable = splitString(keyword.toUtf8().constData());
+ bool foundAll = true;
+
+ //perform an AND-search
+ for(unsigned int i = 0; i < keywordsAvailable.size(); i++)
{
- it->treeWidgetItem->setHidden(true);
+ if (it->keywords.indexOf(QString::fromStdString(keywordsAvailable[i])) == -1)
+ {
+ foundAll = false;
+ break;
+ }
}
- else
+
+ if(foundAll)
{
//#make the whole branch visible
QTreeWidgetItem* treeWidgetParent = it->treeWidgetItem->parent();
while(treeWidgetParent!=nullptr)
{
treeWidgetParent->setHidden(false);
treeWidgetParent->setExpanded(true);
treeWidgetParent = treeWidgetParent->parent();
}
it->treeWidgetItem->setHidden(false);
QFont f = it->treeWidgetItem->font(0);
f.setBold(true);
it->treeWidgetItem->setFont(0, f);
}
}
else
{
QFont f = it->treeWidgetItem->font(0);
f.setBold(false);
it->treeWidgetItem->setFont(0, f);
it->treeWidgetItem->setHidden(false);
}
}
if(d->m_PrefPages.size()>0)
{
if(d->m_PrefPages.front().treeWidgetItem != nullptr)
d->m_PrefPages.front().treeWidgetItem->setSelected(true);
}
}
diff --git a/Plugins/org.mitk.gui.qt.datamanager/plugin.xml b/Plugins/org.mitk.gui.qt.datamanager/plugin.xml
index 6c3dc5c4fe..6606ee9289 100644
--- a/Plugins/org.mitk.gui.qt.datamanager/plugin.xml
+++ b/Plugins/org.mitk.gui.qt.datamanager/plugin.xml
@@ -1,32 +1,32 @@
-
-
+
+
diff --git a/Plugins/org.mitk.gui.qt.ext/plugin.xml b/Plugins/org.mitk.gui.qt.ext/plugin.xml
index dec112b1e5..ecba76ad09 100644
--- a/Plugins/org.mitk.gui.qt.ext/plugin.xml
+++ b/Plugins/org.mitk.gui.qt.ext/plugin.xml
@@ -1,40 +1,42 @@
+
+
-
-
+
+
diff --git a/Plugins/org.mitk.gui.qt.extapplication/plugin.xml b/Plugins/org.mitk.gui.qt.extapplication/plugin.xml
index 0fcb88d3b1..5bcecd82f2 100644
--- a/Plugins/org.mitk.gui.qt.extapplication/plugin.xml
+++ b/Plugins/org.mitk.gui.qt.extapplication/plugin.xml
@@ -1,60 +1,60 @@
-
+
diff --git a/Plugins/org.mitk.gui.qt.multilabelsegmentation/plugin.xml b/Plugins/org.mitk.gui.qt.multilabelsegmentation/plugin.xml
index 312edde71f..95a89089cf 100644
--- a/Plugins/org.mitk.gui.qt.multilabelsegmentation/plugin.xml
+++ b/Plugins/org.mitk.gui.qt.multilabelsegmentation/plugin.xml
@@ -1,42 +1,42 @@
-
+
diff --git a/Plugins/org.mitk.gui.qt.properties/plugin.xml b/Plugins/org.mitk.gui.qt.properties/plugin.xml
index 3054a28697..ae3c2c6c70 100644
--- a/Plugins/org.mitk.gui.qt.properties/plugin.xml
+++ b/Plugins/org.mitk.gui.qt.properties/plugin.xml
@@ -1,18 +1,21 @@
View, Set, and Change properties of DataNodes
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/Plugins/org.mitk.gui.qt.stdmultiwidgeteditor/plugin.xml b/Plugins/org.mitk.gui.qt.stdmultiwidgeteditor/plugin.xml
index 269338f91e..21c86c2a5e 100644
--- a/Plugins/org.mitk.gui.qt.stdmultiwidgeteditor/plugin.xml
+++ b/Plugins/org.mitk.gui.qt.stdmultiwidgeteditor/plugin.xml
@@ -1,29 +1,28 @@
-
-
-
-
-
-
+
+
+
+
+
diff --git a/Plugins/org.mitk.gui.qt.xnat/plugin.xml b/Plugins/org.mitk.gui.qt.xnat/plugin.xml
index 3cff2ce1ff..e096195700 100644
--- a/Plugins/org.mitk.gui.qt.xnat/plugin.xml
+++ b/Plugins/org.mitk.gui.qt.xnat/plugin.xml
@@ -1,53 +1,53 @@
Search, browse and view the data in a XNAT-Installation
Search, browse and view the data in a XNAT-Installation
-
+