14 #include <QListWidgetItem> 31 mTrackingService(trackingService)
33 connect(
this, SIGNAL(itemSelectionChanged()),
this, SLOT(selectionChangedSlot()));
35 this->setSelectionBehavior(QAbstractItemView::SelectItems);
36 this->setSelectionMode(QAbstractItemView::SingleSelection);
47 foreach(QString tool, toolsAbsoluteFilePath)
57 QString name = config->getTool(absoluteFilePath).mName;
62 QListWidgetItem* item =
new QListWidgetItem(name);
63 item->setData(Qt::ToolTipRole, absoluteFilePath);
64 item->setData(Qt::UserRole, absoluteFilePath);
69 void ToolListWidget::selectionChangedSlot()
71 QListWidgetItem* selectedItem = this->currentItem();
72 this->toolSelectedSlot(selectedItem);
75 void ToolListWidget::toolSelectedSlot(QListWidgetItem* item)
80 QString absoluteFilePath = item->data(Qt::UserRole).toString();
89 this->setDragDropMode(QAbstractItemView::DragOnly);
90 this->setDragEnabled(
true);
99 QFontMetrics metric(this->font());
100 int height = metric.lineSpacing() * 15;
101 return QSize(300,height);
106 if (event->button() == Qt::LeftButton)
107 startPos = event->pos();
108 QListWidget::mousePressEvent(event);
113 if (event->buttons() & Qt::LeftButton)
115 int distance = (
event->pos() - startPos).manhattanLength();
123 QListWidgetItem *item = currentItem();
126 QMimeData *mimeData =
new QMimeData;
127 mimeData->setText(item->data(Qt::ToolTipRole).toString());
128 QDrag *drag =
new QDrag(
this);
129 drag->setMimeData(mimeData);
131 drag->start(Qt::MoveAction);
138 QStringList filteredTools = config->getToolsGivenFilter(applicationsFilter,
139 trackingsystemsFilter);
149 this->setContextMenuPolicy(Qt::CustomContextMenu);
151 this->viewport()->setAcceptDrops(
true);
152 this->setDropIndicatorShown(
true);
153 this->setDefaultDropAction(Qt::CopyAction);
154 this->setDragDropMode(QAbstractItemView::DropOnly);
156 connect(
this, SIGNAL(customContextMenuRequested(
const QPoint &)),
this, SLOT(contextMenuSlot(
const QPoint &)));
166 if (all.contains(event->mimeData()->text()))
174 event->setDropAction(Qt::MoveAction);
177 if (all.contains(event->mimeData()->text()))
186 this->
addTool(event->mimeData()->text());
188 event->setDropAction(Qt::MoveAction);
198 for (
int i = 0; i < this->count(); ++i)
200 QListWidgetItem* item = this->item(i);
201 retval << item->data(Qt::ToolTipRole).toString();
209 this->
populate(toolsAbsoluteFilePath);
216 for (
int i = 0; i < this->count(); ++i)
218 QListWidgetItem* item = this->item(i);
219 QString absoluteFilePath = item->data(Qt::ToolTipRole).toString();
221 QString toolTrackingSystemName = config->getTool(absoluteFilePath).mTrackingSystemName;
223 QBrush brush = item->foreground();
224 if (!trackingsystemFilter.contains(toolTrackingSystemName, Qt::CaseInsensitive) || !config->verifyTool(absoluteFilePath))
225 brush.setColor(Qt::red);
227 brush.setColor(Qt::black);
229 item->setForeground(brush);
233 void ConfigToolListWidget::deleteSlot()
240 this->deleteItemSlot(mItemToDelete);
243 void ConfigToolListWidget::deleteItemSlot(QListWidgetItem* item)
250 void ConfigToolListWidget::contextMenuSlot(
const QPoint& point)
252 QWidget* sender =
dynamic_cast<QWidget*
>(this->sender());
253 QPoint pointGlobal = sender->mapToGlobal(point);
254 QMenu contextMenu(sender);
256 QAction* action =
new QAction(
"Remove", &contextMenu);
258 QListWidgetItem* item = this->itemAt(point);
264 mItemToDelete = item;
266 connect(action, SIGNAL(triggered()),
this, SLOT(deleteSlot()));
267 contextMenu.addAction(action);
269 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.