mirror of
https://github.com/leozide/leocad
synced 2025-01-18 22:26:44 +01:00
Added new timeline option to move selection to a new step.
This commit is contained in:
parent
337e5723b8
commit
a18f55913b
5 changed files with 120 additions and 3 deletions
|
@ -1816,6 +1816,20 @@ const lcCommand gCommands[] =
|
|||
QT_TRANSLATE_NOOP("Status", "Move the selected parts into this step"),
|
||||
""
|
||||
},
|
||||
// LC_TIMELINE_MOVE_SELECTION_BEFORE
|
||||
{
|
||||
"",
|
||||
QT_TRANSLATE_NOOP("Menu", "Move Selection Before"),
|
||||
QT_TRANSLATE_NOOP("Status", "Move the selected parts into a new step before this"),
|
||||
""
|
||||
},
|
||||
// LC_TIMELINE_MOVE_SELECTION_AFTER
|
||||
{
|
||||
"",
|
||||
QT_TRANSLATE_NOOP("Menu", "Move Selection After"),
|
||||
QT_TRANSLATE_NOOP("Status", "Move the selected parts into a new step after this"),
|
||||
""
|
||||
},
|
||||
// LC_TIMELINE_SET_CURRENT
|
||||
{
|
||||
"",
|
||||
|
|
|
@ -277,6 +277,8 @@ enum lcCommandId
|
|||
LC_TIMELINE_INSERT_AFTER,
|
||||
LC_TIMELINE_DELETE,
|
||||
LC_TIMELINE_MOVE_SELECTION,
|
||||
LC_TIMELINE_MOVE_SELECTION_BEFORE,
|
||||
LC_TIMELINE_MOVE_SELECTION_AFTER,
|
||||
LC_TIMELINE_SET_CURRENT,
|
||||
LC_NUM_COMMANDS
|
||||
};
|
||||
|
|
|
@ -1971,6 +1971,8 @@ void lcMainWindow::UpdateSelectedObjects(bool SelectionChanged)
|
|||
mActions[LC_PIECE_SHOW_EARLIER]->setEnabled(Flags & LC_SEL_PIECE); // FIXME: disable if current step is 1
|
||||
mActions[LC_PIECE_SHOW_LATER]->setEnabled(Flags & LC_SEL_PIECE);
|
||||
mActions[LC_TIMELINE_MOVE_SELECTION]->setEnabled(Flags & LC_SEL_PIECE);
|
||||
mActions[LC_TIMELINE_MOVE_SELECTION_BEFORE]->setEnabled(Flags & LC_SEL_PIECE);
|
||||
mActions[LC_TIMELINE_MOVE_SELECTION_AFTER]->setEnabled(Flags & LC_SEL_PIECE);
|
||||
|
||||
mActions[LC_PIECE_EDIT_END_SUBMODEL]->setEnabled(GetCurrentTabModel() != ActiveModel);
|
||||
}
|
||||
|
@ -3413,6 +3415,14 @@ void lcMainWindow::HandleCommand(lcCommandId CommandId)
|
|||
mTimelineWidget->MoveSelection();
|
||||
break;
|
||||
|
||||
case LC_TIMELINE_MOVE_SELECTION_BEFORE:
|
||||
mTimelineWidget->MoveSelectionBefore();
|
||||
break;
|
||||
|
||||
case LC_TIMELINE_MOVE_SELECTION_AFTER:
|
||||
mTimelineWidget->MoveSelectionAfter();
|
||||
break;
|
||||
|
||||
case LC_TIMELINE_SET_CURRENT:
|
||||
mTimelineWidget->SetCurrentStep();
|
||||
break;
|
||||
|
|
|
@ -54,7 +54,12 @@ void lcTimelineWidget::CustomMenuRequested(QPoint Pos)
|
|||
Menu->addAction(gMainWindow->mActions[LC_TIMELINE_INSERT_BEFORE]);
|
||||
Menu->addAction(gMainWindow->mActions[LC_TIMELINE_INSERT_AFTER]);
|
||||
Menu->addAction(gMainWindow->mActions[LC_TIMELINE_DELETE]);
|
||||
|
||||
Menu->addSeparator();
|
||||
|
||||
Menu->addAction(gMainWindow->mActions[LC_TIMELINE_MOVE_SELECTION]);
|
||||
Menu->addAction(gMainWindow->mActions[LC_TIMELINE_MOVE_SELECTION_BEFORE]);
|
||||
Menu->addAction(gMainWindow->mActions[LC_TIMELINE_MOVE_SELECTION_AFTER]);
|
||||
|
||||
Menu->addSeparator();
|
||||
|
||||
|
@ -398,6 +403,90 @@ void lcTimelineWidget::MoveSelection()
|
|||
Model->SetCurrentStep(Step);
|
||||
}
|
||||
|
||||
void lcTimelineWidget::MoveSelectionBefore()
|
||||
{
|
||||
QTreeWidgetItem* CurrentItem = currentItem();
|
||||
|
||||
if (!CurrentItem)
|
||||
return;
|
||||
|
||||
if (CurrentItem->parent())
|
||||
CurrentItem = CurrentItem->parent();
|
||||
|
||||
int Step = indexOfTopLevelItem(CurrentItem);
|
||||
|
||||
if (Step == -1)
|
||||
return;
|
||||
|
||||
Step++;
|
||||
|
||||
QList<QTreeWidgetItem*> SelectedItems = selectedItems();
|
||||
|
||||
gMainWindow->GetActiveModel()->InsertStep(Step);
|
||||
|
||||
CurrentItem = topLevelItem(Step - 1);
|
||||
|
||||
for (QTreeWidgetItem* PieceItem : SelectedItems)
|
||||
{
|
||||
QTreeWidgetItem* Parent = PieceItem->parent();
|
||||
|
||||
if (!Parent)
|
||||
continue;
|
||||
|
||||
int ChildIndex = Parent->indexOfChild(PieceItem);
|
||||
CurrentItem->addChild(Parent->takeChild(ChildIndex));
|
||||
}
|
||||
|
||||
UpdateModel();
|
||||
|
||||
lcModel* Model = gMainWindow->GetActiveModel();
|
||||
|
||||
if (Step > static_cast<int>(Model->GetCurrentStep()))
|
||||
Model->SetCurrentStep(Step);
|
||||
}
|
||||
|
||||
void lcTimelineWidget::MoveSelectionAfter()
|
||||
{
|
||||
QTreeWidgetItem* CurrentItem = currentItem();
|
||||
|
||||
if (!CurrentItem)
|
||||
return;
|
||||
|
||||
if (CurrentItem->parent())
|
||||
CurrentItem = CurrentItem->parent();
|
||||
|
||||
int Step = indexOfTopLevelItem(CurrentItem);
|
||||
|
||||
if (Step == -1)
|
||||
return;
|
||||
|
||||
Step += 2;
|
||||
|
||||
QList<QTreeWidgetItem*> SelectedItems = selectedItems();
|
||||
|
||||
gMainWindow->GetActiveModel()->InsertStep(Step);
|
||||
|
||||
CurrentItem = topLevelItem(Step - 1);
|
||||
|
||||
for (QTreeWidgetItem* PieceItem : SelectedItems)
|
||||
{
|
||||
QTreeWidgetItem* Parent = PieceItem->parent();
|
||||
|
||||
if (!Parent)
|
||||
continue;
|
||||
|
||||
int ChildIndex = Parent->indexOfChild(PieceItem);
|
||||
CurrentItem->addChild(Parent->takeChild(ChildIndex));
|
||||
}
|
||||
|
||||
UpdateModel();
|
||||
|
||||
lcModel* Model = gMainWindow->GetActiveModel();
|
||||
|
||||
if (Step > static_cast<int>(Model->GetCurrentStep()))
|
||||
Model->SetCurrentStep(Step);
|
||||
}
|
||||
|
||||
void lcTimelineWidget::SetCurrentStep()
|
||||
{
|
||||
QTreeWidgetItem* CurrentItem = currentItem();
|
||||
|
@ -463,6 +552,9 @@ void lcTimelineWidget::dropEvent(QDropEvent* Event)
|
|||
QTreeWidgetItem* DropItem = itemAt(Event->pos());
|
||||
lcModel* Model = gMainWindow->GetActiveModel();
|
||||
|
||||
QList<QTreeWidgetItem*> SelectedItems = selectedItems();
|
||||
clearSelection();
|
||||
|
||||
if (DropItem)
|
||||
{
|
||||
QTreeWidgetItem* ParentItem = DropItem->parent();
|
||||
|
@ -472,9 +564,6 @@ void lcTimelineWidget::dropEvent(QDropEvent* Event)
|
|||
Model->SetCurrentStep(Step);
|
||||
}
|
||||
|
||||
QList<QTreeWidgetItem*> SelectedItems = selectedItems();
|
||||
clearSelection();
|
||||
|
||||
auto SortItems = [this](QTreeWidgetItem* Item1, QTreeWidgetItem* Item2)
|
||||
{
|
||||
QTreeWidgetItem* StepItem1 = Item1->parent();
|
||||
|
|
|
@ -15,6 +15,8 @@ public:
|
|||
void InsertStepAfter();
|
||||
void RemoveStep();
|
||||
void MoveSelection();
|
||||
void MoveSelectionBefore();
|
||||
void MoveSelectionAfter();
|
||||
void SetCurrentStep();
|
||||
|
||||
public slots:
|
||||
|
|
Loading…
Reference in a new issue