##// END OF EJS Templates
Improves reliability
trabillard -
r880:7c654133459a
parent child
Show More
@@ -174,7 +174,7 void DataSourceController::finalize()
174 174
175 175 void DataSourceController::requestVariable(const QVariantHash &productData)
176 176 {
177 DataSourceItem *sourceItem = impl->findDataSourceItem(productData);
177 auto sourceItem = impl->findDataSourceItem(productData);
178 178
179 179 if (sourceItem) {
180 180 auto sourceName = sourceItem->rootItem().name();
@@ -130,9 +130,8 DataSourceItem *DataSourceItem::findItem(const QVariantHash &data, bool recursiv
130 130 return child.get();
131 131 }
132 132
133 if (recursive) {
134 auto foundItem = child->findItem(data, true);
135 if (foundItem) {
133 if (recursive) {
134 if (auto foundItem = child->findItem(data, true)) {
136 135 return foundItem;
137 136 }
138 137 }
@@ -312,7 +312,7 bool VariableModel::canDropMimeData(const QMimeData *data, Qt::DropAction action
312 312 bool VariableModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column,
313 313 const QModelIndex &parent)
314 314 {
315 bool dropDone = false;
315 auto dropDone = false;
316 316
317 317 if (data->hasFormat(MIME_TYPE_PRODUCT_LIST)) {
318 318 QDataStream stream(data->data(MIME_TYPE_PRODUCT_LIST));
@@ -149,6 +149,9 struct DragDropHelper::DragDropHelperPrivate {
149 149
150 150 VisualizationDragWidget *m_HighlightedDragWidget = nullptr;
151 151
152 QMetaObject::Connection m_DragWidgetDestroyedConnection;
153 QMetaObject::Connection m_HighlightedWidgetDestroyedConnection;
154
152 155 explicit DragDropHelperPrivate()
153 156 : m_PlaceHolder{std::make_unique<QWidget>()},
154 157 m_DragDropScroller{std::make_unique<DragDropScroller>()}
@@ -194,6 +197,18 void DragDropHelper::resetDragAndDrop()
194 197
195 198 void DragDropHelper::setCurrentDragWidget(VisualizationDragWidget *dragWidget)
196 199 {
200 if (impl->m_CurrentDragWidget) {
201
202 QObject::disconnect(impl->m_DragWidgetDestroyedConnection);
203 }
204
205 if (dragWidget) {
206 // ensures the impl->m_CurrentDragWidget is reset when the widget is destroyed
207 impl->m_DragWidgetDestroyedConnection
208 = QObject::connect(dragWidget, &VisualizationDragWidget::destroyed,
209 [this]() { impl->m_CurrentDragWidget = nullptr; });
210 }
211
197 212 impl->m_CurrentDragWidget = dragWidget;
198 213 }
199 214
@@ -251,12 +266,19 void DragDropHelper::setHightlightedDragWidget(VisualizationDragWidget *dragWidg
251 266 {
252 267 if (impl->m_HighlightedDragWidget) {
253 268 impl->m_HighlightedDragWidget->highlightForMerge(false);
269 QObject::disconnect(impl->m_HighlightedWidgetDestroyedConnection);
254 270 }
255 271
256 272 if (dragWidget) {
257 impl->m_HighlightedDragWidget = dragWidget;
258 impl->m_HighlightedDragWidget->highlightForMerge(true);
273 dragWidget->highlightForMerge(true);
274
275 // ensures the impl->m_HighlightedDragWidget is reset when the widget is destroyed
276 impl->m_DragWidgetDestroyedConnection
277 = QObject::connect(dragWidget, &VisualizationDragWidget::destroyed,
278 [this]() { impl->m_HighlightedDragWidget = nullptr; });
259 279 }
280
281 impl->m_HighlightedDragWidget = dragWidget;
260 282 }
261 283
262 284 bool DragDropHelper::checkMimeDataForVisualization(const QMimeData *mimeData,
@@ -75,10 +75,7 struct VisualizationDragDropContainer::VisualizationDragDropContainerPrivate {
75 75
76 76 bool cursorIsInContainer(QWidget *container) const
77 77 {
78 auto adustNum = 18; // to be safe, in case of scrollbar on the side
79 auto containerRect = QRect(QPoint(), container->contentsRect().size())
80 .adjusted(adustNum, adustNum, -adustNum, -adustNum);
81 return containerRect.contains(container->mapFromGlobal(QCursor::pos()));
78 return container->isAncestorOf(sqpApp->widgetAt(QCursor::pos()));
82 79 }
83 80
84 81 int countDragWidget(const QWidget *parent) const
@@ -171,6 +168,10 void VisualizationDragDropContainer::startDrag(VisualizationDragWidget *dragWidg
171 168 helper.insertPlaceHolder(impl->m_Layout, dragWidgetIndex);
172 169 dragWidget->setVisible(false);
173 170 }
171 else {
172 // The drag starts directly outside the drop zone
173 // do not add the placeHolder
174 }
174 175
175 176 // Note: The exec() is blocking on windows but not on linux and macOS
176 177 drag->exec(Qt::MoveAction | Qt::CopyAction);
General Comments 3
Under Review
author

Pull request updated. Auto status change to "Under Review"

Changed commits:
  * 1 added
  * 0 removed

Changed files:
  * A core/tests/meson.build
You need to be logged in to leave comments. Login now