MCPcopy Create free account
hub / github.com/ModOrganizer2/modorganizer / dropMimeData

Method dropMimeData

src/modlistbypriorityproxy.cpp:290–391  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

288}
289
290bool ModListByPriorityProxy::dropMimeData(const QMimeData* data, Qt::DropAction action,
291 int row, int column,
292 const QModelIndex& parent)
293{
294 // we need to fix the source model row if we are dropping at a
295 // given priority (not a local file)
296 const ModListDropInfo dropInfo(data, m_core);
297 int sourceRow = -1;
298
299 if (dropInfo.isLocalFileDrop()) {
300 if (parent.isValid()) {
301 sourceRow = static_cast<TreeItem*>(parent.internalPointer())->index;
302 }
303 } else {
304
305 if (row >= 0) {
306 if (!parent.isValid()) {
307 if (row < m_Root.children.size()) {
308
309 if (m_sortOrder == Qt::AscendingOrder) {
310 sourceRow = m_Root.children[row]->index;
311
312 // fix bug when dropping a mod just below an expanded separator
313 //
314 // by default, Qt consider it's a drop at the end of that separator
315 // but we want to make it a drop at the beginning
316 if (row > 0 && m_sortOrder == Qt::AscendingOrder &&
317 m_Root.children[row - 1]->mod->isSeparator() &&
318 !m_Root.children[row - 1]->children.empty() && m_dropExpanded &&
319 m_dropPosition == ModListView::DropPosition::BelowItem) {
320 sourceRow = m_Root.children[row - 1]->children[0]->index;
321 }
322 } else {
323 sourceRow = m_Root.children[row - 1]->index;
324
325 // fix drop below a collapsed separator or at the end of an expanded
326 // separator, above the next item
327 if (row > 0 && m_sortOrder == Qt::DescendingOrder &&
328 m_Root.children[row - 1]->mod->isSeparator() &&
329 !m_Root.children[row - 1]->children.empty() &&
330 (!m_dropExpanded ||
331 m_dropPosition == ModListView::DropPosition::AboveItem)) {
332 sourceRow = m_Root.children[row - 1]->children.back()->index;
333 }
334 }
335 } else {
336 sourceRow = ModInfo::getNumMods();
337 }
338 }
339
340 // the parent is valid, we are dropping in a separator
341 else {
342 auto* item = static_cast<TreeItem*>(parent.internalPointer());
343
344 // we usually need to decrement the row in descending priority, but if
345 // it's the first row, we need to go back to the separator itself
346 if (m_sortOrder == Qt::DescendingOrder && row == 0 &&
347 m_dropPosition == ModListView::DropPosition::AboveItem) {

Callers

nothing calls this directly

Calls 7

QModelIndexClass · 0.85
isLocalFileDropMethod · 0.80
backMethod · 0.80
isValidMethod · 0.45
sizeMethod · 0.45
isSeparatorMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected