--User changes

-Add backward compatibility option for the following variations: cos, cosh, cot, coth, csc, csch, sec, sech, sin, sinh, tan, tanh.
 -Add the ability to re-order variations by dragging them in the Info tab.
This commit is contained in:
Person
2020-03-04 22:30:08 -08:00
parent c50568a98b
commit ea649bbda6
22 changed files with 1034 additions and 310 deletions

View File

@ -93,4 +93,112 @@ void LibraryTreeWidget::dropEvent(QDropEvent* de)
m_Fractorium->m_Controller->MoveLibraryItems(items, row);
}
}
}
/// <summary>
/// Set a pointer to the main window.
/// </summary>
/// <param name="f">Pointer to the main Fractorium object</param>
void InfoTreeWidget::SetMainWindow(Fractorium* f)
{
m_Fractorium = f;
}
/// <summary>
/// Called on each mouse movement while dragging, validate whether the area
/// being dragged over can be dropped on.
/// Can only drop on like (pre/reg/post) variation section of the same xform
/// of the variation being dragged.
/// </summary>
/// <param name="dme">Pointer to the drag move event</param>
void InfoTreeWidget::dragMoveEvent(QDragMoveEvent* dme)
{
QModelIndex index = indexAt(dme->pos());
if (!index.isValid())//Don't process drop because it's outside of the droppable area.
{
dme->ignore();
return;
}
QList<QTreeWidgetItem*> dragItems = selectedItems();
if (dragItems.size())
{
auto drag0 = dragItems[0];
if (auto itemat = itemFromIndex(index))
{
auto dragpre = drag0->text(0).startsWith("pre_", Qt::CaseInsensitive);
auto droppre = itemat->text(0).startsWith("pre_", Qt::CaseInsensitive);
auto dragpost = drag0->text(0).startsWith("post_", Qt::CaseInsensitive);
auto droppost = itemat->text(0).startsWith("post_", Qt::CaseInsensitive);
if (auto par = itemat->parent())
{
if (drag0->parent() == par &&
(par->text(0).startsWith("xform ", Qt::CaseInsensitive) ||
par->text(0).startsWith("final", Qt::CaseInsensitive)))
{
if (auto vitemat = dynamic_cast<VariationTreeWidgetItem*>(itemat))
{
bool dopre = dragpre && droppre;
bool dopost = dragpost && droppost;
bool doreg = !dragpre && !droppre && !dragpost && !droppost;
if (dopre || doreg || doreg)
{
QTreeWidget::dragMoveEvent(dme);
return;
}
}
}
}
}
}
dme->ignore();
}
/// <summary>
/// Process the drop event to allow for moving items around inside of the tree.
/// This will only allow variations to be moved around within the variation section of the tree
/// and nowhere else.
/// </summary>
/// <param name="de">Pointer to the QDropEvent object</param>
void InfoTreeWidget::dropEvent(QDropEvent* de)
{
QModelIndex droppedIndex = indexAt(de->pos());
auto items = selectionModel()->selectedRows();
if (!droppedIndex.isValid())//Don't process drop because it's outside of the droppable area.
{
de->ignore();
return;
}
else if (!items.empty())//Actually do the drop and move the item to a new location.
{
QList<QTreeWidgetItem*> dragItems = selectedItems();
if (dragItems.size())
{
auto drag0 = dragItems[0];
auto itemat = itemFromIndex(droppedIndex);
if (auto par = itemat->parent())
{
if (auto vdropitem = dynamic_cast<VariationTreeWidgetItem*>(itemat))
{
if (auto vdragitem = dynamic_cast<VariationTreeWidgetItem*>(drag0))
{
QTreeWidget::dropEvent(de);//This internally changes the order of the items.
m_Fractorium->ReorderVariations(par);
return;
}
}
}
}
de->ignore();
}
}