7 #include "guiQt/editor/SListView.hpp" 9 #include <fwCom/Signal.hxx> 10 #include <fwCom/Slots.hxx> 12 #include <fwCore/base.hpp> 14 #include <fwGuiQt/container/QtContainer.hpp> 16 #include <fwServices/macros.hpp> 19 #include <QHBoxLayout> 28 const ::fwCom::Signals::SignalKeyType SListView::s_ITEM_ADDED_SIG =
"itemAdded";
29 const ::fwCom::Signals::SignalKeyType SListView::s_ITEM_REMOVED_SIG =
"itemRemoved";
30 const ::fwCom::Signals::SignalKeyType SListView::s_ITEM_DOUBLE_CLICKED_SIG =
"itemDoubleClicked";
39 newSignal< ItemAddedSignalType>(s_ITEM_ADDED_SIG);
40 newSignal< ItemRemovedSignalType>(s_ITEM_REMOVED_SIG);
41 newSignal< ItemDoubleClickedSignalType>(s_ITEM_DOUBLE_CLICKED_SIG);
58 if(watched == m_listWidget && event->type() == QEvent::KeyRelease)
60 QKeyEvent* eventKey =
static_cast<QKeyEvent*
>(event);
61 if(eventKey->key() == Qt::Key_Delete)
63 const QList<QListWidgetItem*>& listItem = m_listWidget->selectedItems();
64 if(listItem.size() > 0)
66 this->
removeItem(m_listWidget->row(listItem.first()));
85 ::fwGuiQt::container::QtContainer::sptr qtContainer =
86 ::fwGuiQt::container::QtContainer::dynamicCast(this->getContainer());
88 QPointer<QHBoxLayout> layout =
new QHBoxLayout();
89 layout->setObjectName(
"SListViewLayout");
90 m_listWidget =
new(QListWidget);
91 m_listWidget->setObjectName(
"SListViewWidget");
92 m_listWidget->installEventFilter(
this);
93 layout->addWidget( m_listWidget );
95 connect(m_listWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)),
this,
96 SLOT(onItemDoubleClicked(QListWidgetItem*)));
98 qtContainer->setLayout(layout);
126 QListWidgetItem* newItem =
new QListWidgetItem(QString::fromStdString(value));
127 m_listWidget->insertItem(index, newItem);
130 this->signal<ItemAddedSignalType>(s_ITEM_ADDED_SIG)->asyncEmit(index);
137 delete m_listWidget->takeItem(index);
140 this->signal<ItemRemovedSignalType>(s_ITEM_REMOVED_SIG)->asyncEmit(index);
145 void SListView::onItemDoubleClicked(QListWidgetItem* item)
147 const int index = m_listWidget->row(item);
148 this->signal<ItemDoubleClickedSignalType>(s_ITEM_DOUBLE_CLICKED_SIG)->asyncEmit(index);
virtual void stopping() override
Destroys the layout.
void insertItem(int index, std::string value)
SLOT : Called to insert an item at index.
#define SLM_TRACE_FUNC()
Trace contextual function signature.
Defines the service interface managing the editor service for object.
FWGUI_API void destroy()
Stops sub-views and toobar services. Destroys view, sub-views and toolbar containers.
virtual void starting() override
Installs the layout.
This editor allows to draw a list. The currently selected item can be deleted by pressing on "del" ke...
GUIQT_API SListView() noexcept
Constructor. Do nothing.
virtual void swapping() override
Does nothing.
FWGUI_API void create()
Creates view, sub-views and toolbar containers. Manages sub-views and toobar services.
void removeItem(int index)
SLOT : Called to remove the item at the index position.
virtual void updating() override
Does nothing.
static GUIQT_APIconst::fwCom::Slots::SlotKeyType s_INSERT_ITEM_SLOT
SLOT : Called to insert an item at index.
bool eventFilter(QObject *watched, QEvent *event) override
used to catch the del key released event
virtual void configuring() override
Configure the service.
virtual GUIQT_API ~SListView() noexcept
Destructor. Do nothing.
The namespace guiQt contains the basic services to build the application IHM with Qt...
static GUIQT_APIconst::fwCom::Slots::SlotKeyType s_REMOVE_ITEM_SLOT
SLOT : Called to insert an item at index.
FWGUI_API void initialize()
Initialize managers.