mirror of
https://github.com/leozide/leocad
synced 2025-02-07 08:45:49 +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"),
|
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
|
// LC_TIMELINE_SET_CURRENT
|
||||||
{
|
{
|
||||||
"",
|
"",
|
||||||
|
|
|
@ -277,6 +277,8 @@ enum lcCommandId
|
||||||
LC_TIMELINE_INSERT_AFTER,
|
LC_TIMELINE_INSERT_AFTER,
|
||||||
LC_TIMELINE_DELETE,
|
LC_TIMELINE_DELETE,
|
||||||
LC_TIMELINE_MOVE_SELECTION,
|
LC_TIMELINE_MOVE_SELECTION,
|
||||||
|
LC_TIMELINE_MOVE_SELECTION_BEFORE,
|
||||||
|
LC_TIMELINE_MOVE_SELECTION_AFTER,
|
||||||
LC_TIMELINE_SET_CURRENT,
|
LC_TIMELINE_SET_CURRENT,
|
||||||
LC_NUM_COMMANDS
|
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_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_PIECE_SHOW_LATER]->setEnabled(Flags & LC_SEL_PIECE);
|
||||||
mActions[LC_TIMELINE_MOVE_SELECTION]->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);
|
mActions[LC_PIECE_EDIT_END_SUBMODEL]->setEnabled(GetCurrentTabModel() != ActiveModel);
|
||||||
}
|
}
|
||||||
|
@ -3413,6 +3415,14 @@ void lcMainWindow::HandleCommand(lcCommandId CommandId)
|
||||||
mTimelineWidget->MoveSelection();
|
mTimelineWidget->MoveSelection();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case LC_TIMELINE_MOVE_SELECTION_BEFORE:
|
||||||
|
mTimelineWidget->MoveSelectionBefore();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LC_TIMELINE_MOVE_SELECTION_AFTER:
|
||||||
|
mTimelineWidget->MoveSelectionAfter();
|
||||||
|
break;
|
||||||
|
|
||||||
case LC_TIMELINE_SET_CURRENT:
|
case LC_TIMELINE_SET_CURRENT:
|
||||||
mTimelineWidget->SetCurrentStep();
|
mTimelineWidget->SetCurrentStep();
|
||||||
break;
|
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_BEFORE]);
|
||||||
Menu->addAction(gMainWindow->mActions[LC_TIMELINE_INSERT_AFTER]);
|
Menu->addAction(gMainWindow->mActions[LC_TIMELINE_INSERT_AFTER]);
|
||||||
Menu->addAction(gMainWindow->mActions[LC_TIMELINE_DELETE]);
|
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]);
|
||||||
|
Menu->addAction(gMainWindow->mActions[LC_TIMELINE_MOVE_SELECTION_BEFORE]);
|
||||||
|
Menu->addAction(gMainWindow->mActions[LC_TIMELINE_MOVE_SELECTION_AFTER]);
|
||||||
|
|
||||||
Menu->addSeparator();
|
Menu->addSeparator();
|
||||||
|
|
||||||
|
@ -398,6 +403,90 @@ void lcTimelineWidget::MoveSelection()
|
||||||
Model->SetCurrentStep(Step);
|
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()
|
void lcTimelineWidget::SetCurrentStep()
|
||||||
{
|
{
|
||||||
QTreeWidgetItem* CurrentItem = currentItem();
|
QTreeWidgetItem* CurrentItem = currentItem();
|
||||||
|
@ -463,6 +552,9 @@ void lcTimelineWidget::dropEvent(QDropEvent* Event)
|
||||||
QTreeWidgetItem* DropItem = itemAt(Event->pos());
|
QTreeWidgetItem* DropItem = itemAt(Event->pos());
|
||||||
lcModel* Model = gMainWindow->GetActiveModel();
|
lcModel* Model = gMainWindow->GetActiveModel();
|
||||||
|
|
||||||
|
QList<QTreeWidgetItem*> SelectedItems = selectedItems();
|
||||||
|
clearSelection();
|
||||||
|
|
||||||
if (DropItem)
|
if (DropItem)
|
||||||
{
|
{
|
||||||
QTreeWidgetItem* ParentItem = DropItem->parent();
|
QTreeWidgetItem* ParentItem = DropItem->parent();
|
||||||
|
@ -472,9 +564,6 @@ void lcTimelineWidget::dropEvent(QDropEvent* Event)
|
||||||
Model->SetCurrentStep(Step);
|
Model->SetCurrentStep(Step);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QTreeWidgetItem*> SelectedItems = selectedItems();
|
|
||||||
clearSelection();
|
|
||||||
|
|
||||||
auto SortItems = [this](QTreeWidgetItem* Item1, QTreeWidgetItem* Item2)
|
auto SortItems = [this](QTreeWidgetItem* Item1, QTreeWidgetItem* Item2)
|
||||||
{
|
{
|
||||||
QTreeWidgetItem* StepItem1 = Item1->parent();
|
QTreeWidgetItem* StepItem1 = Item1->parent();
|
||||||
|
|
|
@ -15,6 +15,8 @@ public:
|
||||||
void InsertStepAfter();
|
void InsertStepAfter();
|
||||||
void RemoveStep();
|
void RemoveStep();
|
||||||
void MoveSelection();
|
void MoveSelection();
|
||||||
|
void MoveSelectionBefore();
|
||||||
|
void MoveSelectionAfter();
|
||||||
void SetCurrentStep();
|
void SetCurrentStep();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
Loading…
Add table
Reference in a new issue