14 #include <QListWidgetItem> 32 mTrackingService(trackingService)
34 connect(
this, SIGNAL(itemSelectionChanged()),
this, SLOT(selectionChangedSlot()));
36 this->setSelectionBehavior(QAbstractItemView::SelectItems);
37 this->setSelectionMode(QAbstractItemView::SingleSelection);
48 foreach(QString tool, toolsAbsoluteFilePath)
58 QString name = config->getTool(absoluteFilePath).mName;
63 QListWidgetItem* item =
new QListWidgetItem(name);
64 item->setData(Qt::ToolTipRole, absoluteFilePath);
65 item->setData(Qt::UserRole, absoluteFilePath);
70 void ToolListWidget::selectionChangedSlot()
72 QListWidgetItem* selectedItem = this->currentItem();
73 this->toolSelectedSlot(selectedItem);
76 void ToolListWidget::toolSelectedSlot(QListWidgetItem* item)
81 QString absoluteFilePath = item->data(Qt::UserRole).toString();
90 this->setDragDropMode(QAbstractItemView::DragOnly);
91 this->setDragEnabled(
true);
100 QFontMetrics metric(this->font());
101 int height = metric.lineSpacing() * 15;
102 return QSize(300,height);
107 if (event->button() == Qt::LeftButton)
108 startPos = event->pos();
109 QListWidget::mousePressEvent(event);
114 if (event->buttons() & Qt::LeftButton)
116 int distance = (
event->pos() - startPos).manhattanLength();
124 QListWidgetItem *item = currentItem();
127 QMimeData *mimeData =
new QMimeData;
128 mimeData->setText(item->data(Qt::ToolTipRole).toString());
129 QDrag *drag =
new QDrag(
this);
130 drag->setMimeData(mimeData);
132 drag->start(Qt::MoveAction);
139 QStringList filteredTools = config->getToolsGivenFilter(applicationsFilter,
140 trackingsystemsFilter);
150 this->setContextMenuPolicy(Qt::CustomContextMenu);
152 this->viewport()->setAcceptDrops(
true);
153 this->setDropIndicatorShown(
true);
154 this->setDefaultDropAction(Qt::CopyAction);
155 this->setDragDropMode(QAbstractItemView::DropOnly);
157 connect(
this, SIGNAL(customContextMenuRequested(
const QPoint &)),
this, SLOT(contextMenuSlot(
const QPoint &)));
167 if (all.contains(event->mimeData()->text()))
175 event->setDropAction(Qt::MoveAction);
178 if (all.contains(event->mimeData()->text()))
187 this->
addTool(event->mimeData()->text());
189 event->setDropAction(Qt::MoveAction);
199 for (
int i = 0; i < this->count(); ++i)
201 QListWidgetItem* item = this->item(i);
202 retval << item->data(Qt::ToolTipRole).toString();
210 this->
populate(toolsAbsoluteFilePath);
217 for (
int i = 0; i < this->count(); ++i)
219 QListWidgetItem* item = this->item(i);
220 QString absoluteFilePath = item->data(Qt::ToolTipRole).toString();
222 QString toolTrackingSystemName = config->getTool(absoluteFilePath).mTrackingSystemName;
224 QBrush brush = item->foreground();
225 if (!trackingsystemFilter.contains(toolTrackingSystemName, Qt::CaseInsensitive) || !config->verifyTool(absoluteFilePath))
226 brush.setColor(Qt::red);
228 brush.setColor(Qt::black);
230 item->setForeground(brush);
234 void ConfigToolListWidget::deleteSlot()
241 this->deleteItemSlot(mItemToDelete);
244 void ConfigToolListWidget::deleteItemSlot(QListWidgetItem* item)
251 void ConfigToolListWidget::contextMenuSlot(
const QPoint& point)
253 QWidget* sender =
dynamic_cast<QWidget*
>(this->sender());
254 QPoint pointGlobal = sender->mapToGlobal(point);
255 QMenu contextMenu(sender);
257 QAction* action =
new QAction(
"Remove", &contextMenu);
259 QListWidgetItem* item = this->itemAt(point);
265 mItemToDelete = item;
267 connect(action, SIGNAL(triggered()),
this, SLOT(deleteSlot()));
268 contextMenu.addAction(action);
270 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.