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