Commit 3c969614 authored by Emilie Harquel's avatar Emilie Harquel
Browse files

Updated uiMedData::SSelector : allows to configure the icon associated to a series.

--HG--
branch : fw4spl_0.10.0
parent 10112d2a
/* ***** BEGIN LICENSE BLOCK *****
* FW4SPL - Copyright (C) IRCAD, 2009-2012.
* FW4SPL - Copyright (C) IRCAD, 2009-2014.
* Distributed under the terms of the GNU Lesser General Public License (LGPL) as
* published by the Free Software Foundation.
* ****** END LICENSE BLOCK ****** */
......@@ -47,6 +47,7 @@ public :
/// Key in m_signals map of signal m_sigSeriesDoubleClicked
UIMEDDATAQT_API static const ::fwCom::Signals::SignalKeyType s_SERIES_DOUBLE_CLICKED_SIG;
protected:
/// Installs GUI : create container and add selector.
......@@ -60,10 +61,17 @@ protected:
* @verbatim
<service uid="selector" impl="::uiMedData::editor::SSelector" type="::gui::editor::IEditor" autoConnect="yes">
<selectionId>selections</selectionId>
<icons>
<icon series="::fwMedData::ImageSeries" icon="Bundles/media_0-1/icons/ImageSeries.svg" />
<icon series="::fwMedData::ModelSeries" icon="Bundles/media_0-1/icons/ModelSeries.svg" />
</icons>
</service>
@endverbatim
* - \b selectionId : defines the fwId of the ::fwData::Vector where the selection
* will be put or get.
* - \b icons : defines the icon to associate for a series
* - \b series : the series classname
* - \b icon : the icon path
*/
virtual void configuring() throw (::fwTools::Failed);
......@@ -118,6 +126,9 @@ private :
/// Signal emitted when there is a double click on a series
SeriesDoubleClickedSignalType::sptr m_sigSeriesDoubleClicked;
/// Map containing the specified icons for a series (map\<series classname, icon path\>)
::uiMedData::widget::Selector::SeriesIconType m_seriesIcons;
};
} // namespace editor
} // namespace uiMedData
......
/* ***** BEGIN LICENSE BLOCK *****
* FW4SPL - Copyright (C) IRCAD, 2009-2013.
* FW4SPL - Copyright (C) IRCAD, 2009-2014.
* Distributed under the terms of the GNU Lesser General Public License (LGPL) as
* published by the Free Software Foundation.
* ****** END LICENSE BLOCK ****** */
......@@ -41,6 +41,9 @@ public:
typedef QVector< ::fwMedData::Series::sptr > SeriesVectorType;
/// Map associating icons to series (map\<series classname, icon path\>)
typedef SelectorModel::SeriesIconType SeriesIconType;
/// Constructor. Init tree view.
UIMEDDATAQT_API Selector(QWidget *parent = 0);
......@@ -69,6 +72,12 @@ public:
/// Catch the delete key event and remove the selected items.
UIMEDDATAQT_API void keyPressEvent(QKeyEvent * event);
/**
* @brief Sets the specific icons for series in selector.
* @param[in] seriesIcons map\<series classname, icon path\>
*/
UIMEDDATAQT_API void setSeriesIcons(const SeriesIconType &seriesIcons);
Q_SIGNALS:
/**
* @brief Signal emitted when the selection change.
......
......@@ -50,6 +50,9 @@ public:
SERIES ///< Type to represent Series
}ItemType;
/// Map associating icons to series (map\<series classname, icon path\>)
typedef std::map<std::string, std::string> SeriesIconType;
/// Constructor. Inits the model.
UIMEDDATAQT_API SelectorModel(QWidget *parent = 0);
......@@ -72,7 +75,7 @@ public:
UIMEDDATAQT_API void clear();
/// Returns item flags with non editable flag
UIMEDDATAQT_API Qt::ItemFlags flags(const QModelIndex& index) const
Qt::ItemFlags flags(const QModelIndex& index) const
{
return (QStandardItemModel::flags(index) & ~Qt::ItemIsEditable);
}
......@@ -96,6 +99,12 @@ public:
/// Returns the item representing the study.
UIMEDDATAQT_API QStandardItem* findStudyItem(::fwMedData::Study::sptr study);
/**
* @brief Sets the specific icons for series in selector.
* @param[in] seriesIcons map\<series classname, icon path\>
*/
UIMEDDATAQT_API void setSeriesIcons(const SeriesIconType &seriesIcons);
private:
......@@ -128,6 +137,9 @@ private:
* It is used to associate the series to its study in the tree.
*/
StudyUidItemMapType m_items;
/// Map containing the specified icons for a series (map\<series classname, icon path\>)
SeriesIconType m_seriesIcons;
};
......
/* ***** BEGIN LICENSE BLOCK *****
* FW4SPL - Copyright (C) IRCAD, 2009-2012.
* FW4SPL - Copyright (C) IRCAD, 2009-2014.
* Distributed under the terms of the GNU Lesser General Public License (LGPL) as
* published by the Free Software Foundation.
* ****** END LICENSE BLOCK ****** */
......@@ -81,6 +81,7 @@ void SSelector::starting() throw(::fwTools::Failed)
SLM_ASSERT("container not instanced", container);
m_selectorWidget = new ::uiMedData::widget::Selector();
m_selectorWidget->setSeriesIcons(m_seriesIcons);
QVBoxLayout *layout = new QVBoxLayout();
layout->addWidget(m_selectorWidget);
container->setLayout(layout);
......@@ -162,6 +163,25 @@ void SSelector::configuring() throw(::fwTools::Failed)
m_selectionId = selectionCfg.front()->getValue();
SLM_ASSERT("selectionId must not be empty", !m_selectionId.empty());
std::vector < ::fwRuntime::ConfigurationElement::sptr > iconsCfg = m_configuration->find("icons");
if (!iconsCfg.empty())
{
SLM_ASSERT("Only one 'config' tag is allowed for SSelector configuration", iconsCfg.size() == 1);
std::vector < ::fwRuntime::ConfigurationElement::sptr > cfg = iconsCfg.front()->find("icon");
BOOST_FOREACH(::fwRuntime::ConfigurationElement::sptr elt, cfg)
{
std::string series = elt->getAttributeValue("series");
SLM_ASSERT("'series' attribute is missing", !series.empty());
std::string icon = elt->getAttributeValue("icon");
SLM_ASSERT("'icon' attribute is missing", !icon.empty());
m_seriesIcons[series] = icon;
}
}
}
//------------------------------------------------------------------------------
......
/* ***** BEGIN LICENSE BLOCK *****
* FW4SPL - Copyright (C) IRCAD, 2009-2013.
* FW4SPL - Copyright (C) IRCAD, 2009-2014.
* Distributed under the terms of the GNU Lesser General Public License (LGPL) as
* published by the Free Software Foundation.
* ****** END LICENSE BLOCK ****** */
......@@ -194,5 +194,12 @@ SelectorModel::ItemType Selector::getItemType(const QModelIndex &index)
//-----------------------------------------------------------------------------
void Selector::setSeriesIcons(const SeriesIconType &seriesIcons)
{
m_model->setSeriesIcons(seriesIcons);
}
//-----------------------------------------------------------------------------
} // namespace widget
} // namespace uiMedData
/* ***** BEGIN LICENSE BLOCK *****
* FW4SPL - Copyright (C) IRCAD, 2009-2013.
* FW4SPL - Copyright (C) IRCAD, 2009-2014.
* Distributed under the terms of the GNU Lesser General Public License (LGPL) as
* published by the Free Software Foundation.
* ****** END LICENSE BLOCK ****** */
......@@ -254,30 +254,38 @@ void SelectorModel::addSeries(::fwMedData::Series::sptr series)
void SelectorModel::addSeriesIcon(::fwMedData::Series::sptr series, QStandardItem *item)
{
::fwMedData::ImageSeries::sptr imageSeries = ::fwMedData::ImageSeries::dynamicCast(series);
::fwMedData::ModelSeries::sptr modelSeries = ::fwMedData::ModelSeries::dynamicCast(series);
::fwMedData::ActivitySeries::sptr activitySeries = ::fwMedData::ActivitySeries::dynamicCast(series);
if(imageSeries)
{
item->setIcon(QIcon("Bundles/media_0-1/icons/ImageSeries.svg"));
}
else if (modelSeries)
SeriesIconType::iterator iter = m_seriesIcons.find(series->getClassname());
if (iter != m_seriesIcons.end())
{
item->setIcon(QIcon("Bundles/media_0-1/icons/ModelSeries.svg"));
}
else if (activitySeries)
{
::fwActivities::registry::Activities::sptr registry = ::fwActivities::registry::Activities::getDefault();
std::string id = activitySeries->getActivityConfigId();
OSLM_ASSERT("Activity information not found for" << id, registry->hasInfo(id));
::fwActivities::registry::ActivityInfo activityInfo;
activityInfo = registry->getInfo(id);
item->setIcon(QIcon(QString::fromStdString(activityInfo.icon)));
item->setIcon(QIcon(QString::fromStdString(iter->second)));
}
else
{
OSLM_WARN("This type of series is not defined (" << series->getClassname() << ")");
::fwMedData::ImageSeries::sptr imageSeries = ::fwMedData::ImageSeries::dynamicCast(series);
::fwMedData::ModelSeries::sptr modelSeries = ::fwMedData::ModelSeries::dynamicCast(series);
::fwMedData::ActivitySeries::sptr activitySeries = ::fwMedData::ActivitySeries::dynamicCast(series);
if(imageSeries)
{
item->setIcon(QIcon("Bundles/media_0-1/icons/ImageSeries.svg"));
}
else if (modelSeries)
{
item->setIcon(QIcon("Bundles/media_0-1/icons/ModelSeries.svg"));
}
else if (activitySeries)
{
::fwActivities::registry::Activities::sptr registry = ::fwActivities::registry::Activities::getDefault();
std::string id = activitySeries->getActivityConfigId();
OSLM_ASSERT("Activity information not found for" << id, registry->hasInfo(id));
::fwActivities::registry::ActivityInfo activityInfo;
activityInfo = registry->getInfo(id);
item->setIcon(QIcon(QString::fromStdString(activityInfo.icon)));
}
else
{
OSLM_WARN("This type of series is not defined (" << series->getClassname() << ")");
}
}
}
......@@ -405,5 +413,12 @@ QStandardItem* SelectorModel::findStudyItem(::fwMedData::Study::sptr study)
//-----------------------------------------------------------------------------
void SelectorModel::setSeriesIcons(const SeriesIconType &seriesIcons)
{
m_seriesIcons = seriesIcons;
}
//-----------------------------------------------------------------------------
} // namespace widget
} // namespace uiMedData
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment