fw4spl
Selector.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2017.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #ifndef __UIMEDDATAQT_WIDGET_SELECTOR_HPP__
8 #define __UIMEDDATAQT_WIDGET_SELECTOR_HPP__
9 
10 #include "uiMedDataQt/config.hpp"
11 #include "uiMedDataQt/widget/SelectorModel.hpp"
12 
13 #include <fwMedData/Series.hpp>
14 #include <fwMedData/Study.hpp>
15 
16 #include <QModelIndex>
17 #include <QPointer>
18 #include <QStandardItem>
19 #include <QStandardItemModel>
20 #include <QString>
21 #include <QTreeView>
22 #include <QVector>
23 
24 #include <map>
25 
26 namespace uiMedDataQt
27 {
28 namespace widget
29 {
30 
34 class UIMEDDATAQT_CLASS_API Selector : public QTreeView
35 {
36 Q_OBJECT
37 
38 public:
39 
40  typedef QVector< ::fwMedData::Series::sptr > SeriesVectorType;
41 
44 
46  UIMEDDATAQT_API Selector(QWidget* parent = 0);
47 
49  UIMEDDATAQT_API ~Selector();
50 
52  UIMEDDATAQT_API void clear();
53 
59  UIMEDDATAQT_API void addSeries(::fwMedData::Series::sptr series);
60 
65  UIMEDDATAQT_API void removeSeries(::fwMedData::Series::sptr series);
66 
68  UIMEDDATAQT_API SelectorModel::ItemType getItemType(const QModelIndex& index);
69 
71  UIMEDDATAQT_API void keyPressEvent(QKeyEvent* event);
72 
77  UIMEDDATAQT_API void setSeriesIcons(const SeriesIconType& seriesIcons);
78 
80  UIMEDDATAQT_API void setAllowedRemove(bool allowed);
81 
83  UIMEDDATAQT_API void setInsertMode(bool insert);
84 
85 Q_SIGNALS:
93  void selectSeries(QVector< ::fwMedData::Series::sptr > selection, QVector< ::fwMedData::Series::sptr > deselection);
94 
99  void removeSeries(QVector< ::fwMedData::Series::sptr > selection);
100 
101 protected Q_SLOTS:
110  void selectionChanged( const QItemSelection& selected, const QItemSelection& deselected );
111 
112 protected:
113 
118  SeriesVectorType getSeries( const QItemSelection& selection );
119 
124  SeriesVectorType getSeries(const QModelIndexList& indexList);
125 
127  QModelIndexList getStudyIndexes(const QModelIndexList& indexList);
128 
130  SeriesVectorType getSeriesFromStudyIndex(const QModelIndex& index);
131 
133  void deleteSelection();
134 
135 private:
136 
138  QPointer<SelectorModel> m_model;
139 
141  bool m_allowedRemove;
142 
143 };
144 
145 } // namespace widget
146 } // namespace uiMedDataQt
147 
148 #endif // __UIMEDDATAQT_WIDGET_SELECTOR_HPP__
The namespace uiMedDataQt contains editors for medical data.
This selector represents the Series in a hierarchical view (Study/Patient->Series).
Definition: Selector.hpp:34
SelectorModel::SeriesIconType SeriesIconType
Map associating icons to series (map<series classname, icon path>)
Definition: Selector.hpp:43
ItemType
Defines item type (STUDY or SERIES), it is used in items data (ITEM_TYPE role).
std::map< std::string, std::string > SeriesIconType
Map associating icons to series (map<series classname, icon path>)