35 #include <QListWidgetItem> 53 mTrackingService(trackingService)
55 connect(
this, SIGNAL(itemSelectionChanged()),
this, SLOT(selectionChangedSlot()));
57 this->setSelectionBehavior(QAbstractItemView::SelectItems);
58 this->setSelectionMode(QAbstractItemView::SingleSelection);
69 foreach(QString tool, toolsAbsoluteFilePath)
79 QString name = config->getTool(absoluteFilePath).mName;
84 QListWidgetItem* item =
new QListWidgetItem(name);
85 item->setData(Qt::ToolTipRole, absoluteFilePath);
86 item->setData(Qt::UserRole, absoluteFilePath);
91 void ToolListWidget::selectionChangedSlot()
93 QListWidgetItem* selectedItem = this->currentItem();
94 this->toolSelectedSlot(selectedItem);
97 void ToolListWidget::toolSelectedSlot(QListWidgetItem* item)
102 QString absoluteFilePath = item->data(Qt::UserRole).toString();
111 this->setDragDropMode(QAbstractItemView::DragOnly);
112 this->setDragEnabled(
true);
121 QFontMetrics metric(this->font());
122 int height = metric.lineSpacing() * 15;
123 return QSize(300,height);
128 if (event->button() == Qt::LeftButton)
129 startPos = event->pos();
130 QListWidget::mousePressEvent(event);
135 if (event->buttons() & Qt::LeftButton)
137 int distance = (
event->pos() - startPos).manhattanLength();
145 QListWidgetItem *item = currentItem();
148 QMimeData *mimeData =
new QMimeData;
149 mimeData->setText(item->data(Qt::ToolTipRole).toString());
150 QDrag *drag =
new QDrag(
this);
151 drag->setMimeData(mimeData);
153 drag->start(Qt::MoveAction);
160 QStringList filteredTools = config->getToolsGivenFilter(applicationsFilter,
161 trackingsystemsFilter);
171 this->setContextMenuPolicy(Qt::CustomContextMenu);
173 this->viewport()->setAcceptDrops(
true);
174 this->setDropIndicatorShown(
true);
175 this->setDefaultDropAction(Qt::CopyAction);
176 this->setDragDropMode(QAbstractItemView::DropOnly);
178 connect(
this, SIGNAL(customContextMenuRequested(
const QPoint &)),
this, SLOT(contextMenuSlot(
const QPoint &)));
188 if (all.contains(event->mimeData()->text()))
196 event->setDropAction(Qt::MoveAction);
199 if (all.contains(event->mimeData()->text()))
208 this->
addTool(event->mimeData()->text());
210 event->setDropAction(Qt::MoveAction);
220 for (
int i = 0; i < this->count(); ++i)
222 QListWidgetItem* item = this->item(i);
223 retval << item->data(Qt::ToolTipRole).toString();
231 this->
populate(toolsAbsoluteFilePath);
238 for (
int i = 0; i < this->count(); ++i)
240 QListWidgetItem* item = this->item(i);
241 QString absoluteFilePath = item->data(Qt::ToolTipRole).toString();
243 QString toolTrackingSystem = config->getTool(absoluteFilePath).mTrackingSystem;
245 QBrush brush = item->foreground();
246 if (!trackingsystemFilter.contains(toolTrackingSystem, Qt::CaseInsensitive) || !config->verifyTool(absoluteFilePath))
247 brush.setColor(Qt::red);
249 brush.setColor(Qt::black);
251 item->setForeground(brush);
255 void ConfigToolListWidget::deleteSlot()
262 this->deleteItemSlot(mItemToDelete);
265 void ConfigToolListWidget::deleteItemSlot(QListWidgetItem* item)
272 void ConfigToolListWidget::contextMenuSlot(
const QPoint& point)
274 QWidget* sender =
dynamic_cast<QWidget*
>(this->sender());
275 QPoint pointGlobal = sender->mapToGlobal(point);
276 QMenu contextMenu(sender);
278 QAction* action =
new QAction(
"Remove", &contextMenu);
280 QListWidgetItem* item = this->itemAt(point);
286 mItemToDelete = item;
288 connect(action, SIGNAL(triggered()),
this, SLOT(deleteSlot()));
289 contextMenu.addAction(action);
291 contextMenu.exec(pointGlobal);
boost::shared_ptr< class TrackingService > TrackingServicePtr
boost::shared_ptr< class TrackerConfiguration > TrackerConfigurationPtr
void reportDebug(QString msg)
Namespace for all CustusX production code.