mirror of
https://github.com/leozide/leocad
synced 2025-02-07 08:45:49 +01:00
Added SetCurrentStep and MoveSelection to Timeline context menu.
This commit is contained in:
parent
e3bb498741
commit
0dabe0d435
6 changed files with 135 additions and 8 deletions
|
@ -868,15 +868,15 @@ lcCommand gCommands[LC_NUM_COMMANDS] =
|
||||||
// LC_VIEW_TIME_INSERT
|
// LC_VIEW_TIME_INSERT
|
||||||
{
|
{
|
||||||
QT_TRANSLATE_NOOP("Action", "View.Time.Insert"),
|
QT_TRANSLATE_NOOP("Action", "View.Time.Insert"),
|
||||||
QT_TRANSLATE_NOOP("Menu", "Insert"),
|
QT_TRANSLATE_NOOP("Menu", "Insert Step"),
|
||||||
QT_TRANSLATE_NOOP("Status", "Insert new step"),
|
QT_TRANSLATE_NOOP("Status", "Insert new step"),
|
||||||
QT_TRANSLATE_NOOP("Shortcut", "")
|
QT_TRANSLATE_NOOP("Shortcut", "")
|
||||||
},
|
},
|
||||||
// LC_VIEW_TIME_DELETE
|
// LC_VIEW_TIME_DELETE
|
||||||
{
|
{
|
||||||
QT_TRANSLATE_NOOP("Action", "View.Time.Delete"),
|
QT_TRANSLATE_NOOP("Action", "View.Time.Delete"),
|
||||||
QT_TRANSLATE_NOOP("Menu", "Delete"),
|
QT_TRANSLATE_NOOP("Menu", "Remove Step"),
|
||||||
QT_TRANSLATE_NOOP("Status", "Delete current step"),
|
QT_TRANSLATE_NOOP("Status", "Remove current step"),
|
||||||
QT_TRANSLATE_NOOP("Shortcut", "")
|
QT_TRANSLATE_NOOP("Shortcut", "")
|
||||||
},
|
},
|
||||||
// LC_VIEW_TIME_ADD_KEYS
|
// LC_VIEW_TIME_ADD_KEYS
|
||||||
|
@ -1389,6 +1389,34 @@ lcCommand gCommands[LC_NUM_COMMANDS] =
|
||||||
QT_TRANSLATE_NOOP("Menu", "&About..."),
|
QT_TRANSLATE_NOOP("Menu", "&About..."),
|
||||||
QT_TRANSLATE_NOOP("Status", "Display program version number and system information"),
|
QT_TRANSLATE_NOOP("Status", "Display program version number and system information"),
|
||||||
QT_TRANSLATE_NOOP("Shortcut", "")
|
QT_TRANSLATE_NOOP("Shortcut", "")
|
||||||
|
},
|
||||||
|
// LC_TIMELINE_INSERT
|
||||||
|
{
|
||||||
|
"",
|
||||||
|
QT_TRANSLATE_NOOP("Menu", "Insert Step"),
|
||||||
|
QT_TRANSLATE_NOOP("Status", "Insert new step"),
|
||||||
|
""
|
||||||
|
},
|
||||||
|
// LC_TIMELINE_DELETE
|
||||||
|
{
|
||||||
|
"",
|
||||||
|
QT_TRANSLATE_NOOP("Menu", "Remove Step"),
|
||||||
|
QT_TRANSLATE_NOOP("Status", "Remove current step"),
|
||||||
|
""
|
||||||
|
},
|
||||||
|
// LC_TIMELINE_MOVE_SELECTION
|
||||||
|
{
|
||||||
|
"",
|
||||||
|
QT_TRANSLATE_NOOP("Menu", "Move Selection Here"),
|
||||||
|
QT_TRANSLATE_NOOP("Status", "Move the selected parts into this step"),
|
||||||
|
""
|
||||||
|
},
|
||||||
|
// LC_TIMELINE_SET_CURRENT
|
||||||
|
{
|
||||||
|
"",
|
||||||
|
QT_TRANSLATE_NOOP("Menu", "Set Current Step"),
|
||||||
|
QT_TRANSLATE_NOOP("Status", "View the model at this point in the timeline"),
|
||||||
|
""
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -211,6 +211,10 @@ enum lcCommandId
|
||||||
LC_HELP_EMAIL,
|
LC_HELP_EMAIL,
|
||||||
LC_HELP_UPDATES,
|
LC_HELP_UPDATES,
|
||||||
LC_HELP_ABOUT,
|
LC_HELP_ABOUT,
|
||||||
|
LC_TIMELINE_INSERT,
|
||||||
|
LC_TIMELINE_DELETE,
|
||||||
|
LC_TIMELINE_MOVE_SELECTION,
|
||||||
|
LC_TIMELINE_SET_CURRENT,
|
||||||
LC_NUM_COMMANDS
|
LC_NUM_COMMANDS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1489,6 +1489,7 @@ void lcMainWindow::UpdateSelectedObjects(bool SelectionChanged)
|
||||||
mActions[LC_PIECE_GROUP_EDIT]->setEnabled((Flags & LC_SEL_NO_PIECES) == 0);
|
mActions[LC_PIECE_GROUP_EDIT]->setEnabled((Flags & LC_SEL_NO_PIECES) == 0);
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
mPropertiesWidget->Update(Selection, Focus);
|
mPropertiesWidget->Update(Selection, Focus);
|
||||||
|
@ -2543,6 +2544,22 @@ void lcMainWindow::HandleCommand(lcCommandId CommandId)
|
||||||
ActiveView->CancelTrackingOrClearSelection();
|
ActiveView->CancelTrackingOrClearSelection();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case LC_TIMELINE_INSERT:
|
||||||
|
mTimelineWidget->InsertStep();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LC_TIMELINE_DELETE:
|
||||||
|
mTimelineWidget->RemoveStep();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LC_TIMELINE_MOVE_SELECTION:
|
||||||
|
mTimelineWidget->MoveSelection();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LC_TIMELINE_SET_CURRENT:
|
||||||
|
mTimelineWidget->SetCurrentStep();
|
||||||
|
break;
|
||||||
|
|
||||||
case LC_NUM_COMMANDS:
|
case LC_NUM_COMMANDS:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,10 +45,11 @@ void lcTimelineWidget::CustomMenuRequested(QPoint Pos)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QAction* InsertStepAction = Menu->addAction(gMainWindow->mActions[LC_VIEW_TIME_INSERT]->text(), this, SLOT(InsertStep()));
|
Menu->addAction(gMainWindow->mActions[LC_TIMELINE_SET_CURRENT]);
|
||||||
InsertStepAction->setStatusTip(gMainWindow->mActions[LC_VIEW_TIME_INSERT]->statusTip());
|
Menu->addAction(gMainWindow->mActions[LC_TIMELINE_INSERT]);
|
||||||
QAction* RemoveStepAction = Menu->addAction(gMainWindow->mActions[LC_VIEW_TIME_DELETE]->text(), this, SLOT(RemoveStep()));
|
Menu->addAction(gMainWindow->mActions[LC_TIMELINE_DELETE]);
|
||||||
RemoveStepAction->setStatusTip(gMainWindow->mActions[LC_VIEW_TIME_DELETE]->statusTip());
|
Menu->addAction(gMainWindow->mActions[LC_TIMELINE_MOVE_SELECTION]);
|
||||||
|
|
||||||
Menu->addSeparator();
|
Menu->addSeparator();
|
||||||
|
|
||||||
Menu->addAction(gMainWindow->mActions[LC_PIECE_HIDE_SELECTED]);
|
Menu->addAction(gMainWindow->mActions[LC_PIECE_HIDE_SELECTED]);
|
||||||
|
@ -292,6 +293,55 @@ void lcTimelineWidget::RemoveStep()
|
||||||
lcGetActiveModel()->RemoveStep(Step + 1);
|
lcGetActiveModel()->RemoveStep(Step + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void lcTimelineWidget::MoveSelection()
|
||||||
|
{
|
||||||
|
QTreeWidgetItem* CurrentItem = currentItem();
|
||||||
|
|
||||||
|
if (!CurrentItem)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (CurrentItem->parent())
|
||||||
|
CurrentItem = CurrentItem->parent();
|
||||||
|
|
||||||
|
int Step = indexOfTopLevelItem(CurrentItem);
|
||||||
|
|
||||||
|
if (Step == -1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
QList<QTreeWidgetItem*> SelectedItems = selectedItems();
|
||||||
|
|
||||||
|
foreach(QTreeWidgetItem* PieceItem, SelectedItems)
|
||||||
|
{
|
||||||
|
QTreeWidgetItem* Parent = PieceItem->parent();
|
||||||
|
|
||||||
|
if (!Parent)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
int ChildIndex = Parent->indexOfChild(PieceItem);
|
||||||
|
CurrentItem->addChild(Parent->takeChild(ChildIndex));
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
void lcTimelineWidget::SetCurrentStep()
|
||||||
|
{
|
||||||
|
QTreeWidgetItem* CurrentItem = currentItem();
|
||||||
|
|
||||||
|
if (!CurrentItem)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (CurrentItem->parent())
|
||||||
|
CurrentItem = CurrentItem->parent();
|
||||||
|
|
||||||
|
int Step = indexOfTopLevelItem(CurrentItem);
|
||||||
|
|
||||||
|
if (Step == -1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
lcGetActiveModel()->SetCurrentStep(Step + 1);
|
||||||
|
}
|
||||||
|
|
||||||
void lcTimelineWidget::ItemSelectionChanged()
|
void lcTimelineWidget::ItemSelectionChanged()
|
||||||
{
|
{
|
||||||
lcArray<lcObject*> Selection;
|
lcArray<lcObject*> Selection;
|
||||||
|
@ -322,7 +372,27 @@ void lcTimelineWidget::ItemSelectionChanged()
|
||||||
void lcTimelineWidget::dropEvent(QDropEvent* Event)
|
void lcTimelineWidget::dropEvent(QDropEvent* Event)
|
||||||
{
|
{
|
||||||
QTreeWidget::dropEvent(Event);
|
QTreeWidget::dropEvent(Event);
|
||||||
|
UpdateModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
void lcTimelineWidget::mousePressEvent(QMouseEvent* Event)
|
||||||
|
{
|
||||||
|
if (Event->button() == Qt::RightButton)
|
||||||
|
{
|
||||||
|
QItemSelection Selection = selectionModel()->selection();
|
||||||
|
|
||||||
|
bool Blocked = blockSignals(true);
|
||||||
|
QTreeWidget::mousePressEvent(Event);
|
||||||
|
blockSignals(Blocked);
|
||||||
|
|
||||||
|
selectionModel()->select(Selection, QItemSelectionModel::ClearAndSelect);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
QTreeWidget::mousePressEvent(Event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void lcTimelineWidget::UpdateModel()
|
||||||
|
{
|
||||||
QList<QPair<lcPiece*, lcStep>> PieceSteps;
|
QList<QPair<lcPiece*, lcStep>> PieceSteps;
|
||||||
|
|
||||||
for (int TopLevelItemIdx = 0; TopLevelItemIdx < topLevelItemCount(); TopLevelItemIdx++)
|
for (int TopLevelItemIdx = 0; TopLevelItemIdx < topLevelItemCount(); TopLevelItemIdx++)
|
||||||
|
|
|
@ -12,14 +12,19 @@ public:
|
||||||
void Update(bool Clear, bool UpdateItems);
|
void Update(bool Clear, bool UpdateItems);
|
||||||
void UpdateSelection();
|
void UpdateSelection();
|
||||||
|
|
||||||
public slots:
|
|
||||||
void InsertStep();
|
void InsertStep();
|
||||||
void RemoveStep();
|
void RemoveStep();
|
||||||
|
void MoveSelection();
|
||||||
|
void SetCurrentStep();
|
||||||
|
|
||||||
|
public slots:
|
||||||
void ItemSelectionChanged();
|
void ItemSelectionChanged();
|
||||||
void CustomMenuRequested(QPoint Pos);
|
void CustomMenuRequested(QPoint Pos);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void dropEvent(QDropEvent* Event);
|
virtual void dropEvent(QDropEvent* Event);
|
||||||
|
virtual void mousePressEvent(QMouseEvent* Event);
|
||||||
|
void UpdateModel();
|
||||||
|
|
||||||
QMap<int, QIcon> mIcons;
|
QMap<int, QIcon> mIcons;
|
||||||
QMap<lcPiece*, QTreeWidgetItem*> mItems;
|
QMap<lcPiece*, QTreeWidgetItem*> mItems;
|
||||||
|
|
|
@ -431,6 +431,9 @@ void lcQPreferencesDialog::updateCommandList()
|
||||||
|
|
||||||
for (int actionIdx = 0; actionIdx < LC_NUM_COMMANDS; actionIdx++)
|
for (int actionIdx = 0; actionIdx < LC_NUM_COMMANDS; actionIdx++)
|
||||||
{
|
{
|
||||||
|
if (!gCommands[actionIdx].ID[0])
|
||||||
|
continue;
|
||||||
|
|
||||||
const QString identifier = tr(gCommands[actionIdx].ID);
|
const QString identifier = tr(gCommands[actionIdx].ID);
|
||||||
|
|
||||||
int pos = identifier.indexOf(QLatin1Char('.'));
|
int pos = identifier.indexOf(QLatin1Char('.'));
|
||||||
|
|
Loading…
Add table
Reference in a new issue