mirror of
https://bitbucket.org/mfeemster/fractorium.git
synced 2025-07-12 03:04:51 -04:00
--Bug Fixes
-Fix strange spurious crash in library tab when switching between SP and DP. -Compensate for severe Qt bug where dragging and dropping disjoint items in the Library tree would resort the dropped items in special situations. -Move Info.plist to Data folder. -Ensure RTTI is included in build. -Add darker versions of .png icons.
This commit is contained in:
@ -27,14 +27,70 @@ void LibraryTreeWidget::dropEvent(QDropEvent* de)
|
||||
}
|
||||
else if (!items.empty())//Actually do the drop and move the item to a new location.
|
||||
{
|
||||
int row = droppedIndex.row();
|
||||
// get the list of the items that are about to be dragged
|
||||
int i, row = droppedIndex.row();
|
||||
DropIndicatorPosition dp = dropIndicatorPosition();
|
||||
QList<QTreeWidgetItem*> dragItems = selectedItems();
|
||||
|
||||
if (dp == QAbstractItemView::BelowItem)
|
||||
row++;
|
||||
|
||||
auto itemat = this->itemFromIndex(droppedIndex);
|
||||
QTreeWidget::dropEvent(de);//This internally changes the order of the items.
|
||||
|
||||
//Qt has a long standing major bug that rearranges the order of disjoint selections when
|
||||
//The drop location is in between the disjoint regions.
|
||||
//This is an attempt to correct for that bug by removing the dropped items, then re-inserting them
|
||||
//in the order they were selected.
|
||||
//This bug remains present as of Qt 5.8: https://bugreports.qt.io/browse/QTBUG-45320
|
||||
if (auto top = topLevelItem(0))
|
||||
{
|
||||
if (itemat)
|
||||
{
|
||||
auto offsetitem = this->indexFromItem(itemat);
|
||||
|
||||
if (dp == QAbstractItemView::BelowItem)
|
||||
{
|
||||
auto itemrow = offsetitem.row() + 1;
|
||||
|
||||
for (i = 0; i < dragItems.size(); i++)
|
||||
{
|
||||
if (itemrow < top->childCount())
|
||||
top->takeChild(itemrow);
|
||||
}
|
||||
|
||||
for (i = 0; i < dragItems.size(); i++)
|
||||
{
|
||||
auto offset = i + itemrow;
|
||||
|
||||
if (offset <= top->childCount())
|
||||
top->insertChild(offset, dragItems[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
auto itemrow = offsetitem.row();//Will be at least 1 if dropped above it.
|
||||
auto offset = itemrow;
|
||||
|
||||
for (i = 0; i < dragItems.size(); i++)
|
||||
{
|
||||
offset--;
|
||||
|
||||
if (offset < top->childCount())
|
||||
top->takeChild(offset);
|
||||
}
|
||||
|
||||
for (i = 0; i < dragItems.size(); i++)
|
||||
{
|
||||
if (offset <= top->childCount())
|
||||
top->insertChild(offset, dragItems[i]);
|
||||
|
||||
offset++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QTimer::singleShot(500, [ = ]() { m_Fractorium->m_Controller->MoveLibraryItems(items, row); });//Need to fire this after this event has internally reshuffled the items.
|
||||
}
|
||||
|
||||
QTreeWidget::dropEvent(de);
|
||||
}
|
Reference in New Issue
Block a user