| 157 | /////////////////////// HOUSEHOLDING CODE ///////////////////////////////// |
| 158 | |
| 159 | QListWidgetItem *QmitkServiceListWidget::AddServiceToList(const us::ServiceReferenceU &serviceRef) |
| 160 | { |
| 161 | QListWidgetItem *newItem = new QListWidgetItem; |
| 162 | |
| 163 | newItem->setText(this->CreateCaptionForService(serviceRef)); |
| 164 | |
| 165 | // Add new item to QListWidget |
| 166 | m_Controls->m_ServiceList->addItem(newItem); |
| 167 | m_Controls->m_ServiceList->sortItems(); |
| 168 | |
| 169 | // Construct link and add to internal List for reference |
| 170 | QmitkServiceListWidget::ServiceListLink link; |
| 171 | link.service = serviceRef; |
| 172 | link.item = newItem; |
| 173 | m_ListContent.push_back(link); |
| 174 | |
| 175 | // Select first entry and emit corresponding signal if the list was |
| 176 | // empty before and this feature is enabled |
| 177 | if (m_AutomaticallySelectFirstEntry && m_Controls->m_ServiceList->selectedItems().isEmpty()) |
| 178 | { |
| 179 | m_Controls->m_ServiceList->setCurrentIndex(m_Controls->m_ServiceList->indexAt(QPoint(0, 0))); |
| 180 | this->OnServiceSelectionChanged(); |
| 181 | } |
| 182 | |
| 183 | return newItem; |
| 184 | } |
| 185 | |
| 186 | bool QmitkServiceListWidget::RemoveServiceFromList(const us::ServiceReferenceU &serviceRef) |
| 187 | { |
no test coverage detected