mirror of
https://github.com/leozide/leocad
synced 2025-02-11 20:48:31 +01:00
Show current step as bold in the timeline.
This commit is contained in:
parent
1f839be310
commit
524e154caa
2 changed files with 60 additions and 2 deletions
|
@ -8,6 +8,7 @@
|
||||||
lcTimelineWidget::lcTimelineWidget(QWidget* Parent)
|
lcTimelineWidget::lcTimelineWidget(QWidget* Parent)
|
||||||
: QTreeWidget(Parent)
|
: QTreeWidget(Parent)
|
||||||
{
|
{
|
||||||
|
mCurrentStepItem = nullptr;
|
||||||
mIgnoreUpdates = false;
|
mIgnoreUpdates = false;
|
||||||
|
|
||||||
setSelectionMode(QAbstractItemView::ExtendedSelection);
|
setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||||
|
@ -103,6 +104,9 @@ void lcTimelineWidget::Update(bool Clear, bool UpdateItems)
|
||||||
delete PieceItem;
|
delete PieceItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mCurrentStepItem == StepItem)
|
||||||
|
mCurrentStepItem = nullptr;
|
||||||
|
|
||||||
delete StepItem;
|
delete StepItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,9 +235,38 @@ void lcTimelineWidget::Update(bool Clear, bool UpdateItems)
|
||||||
PieceItemIndex = 0;
|
PieceItemIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UpdateCurrentStepItem();
|
||||||
|
|
||||||
blockSignals(Blocked);
|
blockSignals(Blocked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void lcTimelineWidget::UpdateCurrentStepItem()
|
||||||
|
{
|
||||||
|
lcModel* Model = gMainWindow->GetActiveModel();
|
||||||
|
lcStep CurrentStep = Model->GetCurrentStep();
|
||||||
|
QTreeWidgetItem* CurrentStepItem = topLevelItem(CurrentStep - 1);
|
||||||
|
|
||||||
|
if (CurrentStepItem != mCurrentStepItem)
|
||||||
|
{
|
||||||
|
if (mCurrentStepItem)
|
||||||
|
{
|
||||||
|
QFont Font = mCurrentStepItem->font(0);
|
||||||
|
Font.setBold(false);
|
||||||
|
mCurrentStepItem->setFont(0, Font);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CurrentStepItem)
|
||||||
|
{
|
||||||
|
QFont Font = CurrentStepItem->font(0);
|
||||||
|
Font.setBold(true);
|
||||||
|
CurrentStepItem->setFont(0, Font);
|
||||||
|
}
|
||||||
|
|
||||||
|
mCurrentStepItem = CurrentStepItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void lcTimelineWidget::UpdateSelection()
|
void lcTimelineWidget::UpdateSelection()
|
||||||
{
|
{
|
||||||
if (mIgnoreUpdates)
|
if (mIgnoreUpdates)
|
||||||
|
@ -315,6 +348,7 @@ void lcTimelineWidget::MoveSelection()
|
||||||
|
|
||||||
if (Step == -1)
|
if (Step == -1)
|
||||||
return;
|
return;
|
||||||
|
Step++;
|
||||||
|
|
||||||
QList<QTreeWidgetItem*> SelectedItems = selectedItems();
|
QList<QTreeWidgetItem*> SelectedItems = selectedItems();
|
||||||
|
|
||||||
|
@ -330,6 +364,11 @@ void lcTimelineWidget::MoveSelection()
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateModel();
|
UpdateModel();
|
||||||
|
|
||||||
|
lcModel* Model = gMainWindow->GetActiveModel();
|
||||||
|
|
||||||
|
if (Step > static_cast<int>(Model->GetCurrentStep()))
|
||||||
|
Model->SetCurrentStep(Step);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcTimelineWidget::SetCurrentStep()
|
void lcTimelineWidget::SetCurrentStep()
|
||||||
|
@ -352,9 +391,9 @@ void lcTimelineWidget::SetCurrentStep()
|
||||||
|
|
||||||
void lcTimelineWidget::CurrentItemChanged(QTreeWidgetItem* Current, QTreeWidgetItem* Previous)
|
void lcTimelineWidget::CurrentItemChanged(QTreeWidgetItem* Current, QTreeWidgetItem* Previous)
|
||||||
{
|
{
|
||||||
Q_UNUSED(Current);
|
|
||||||
Q_UNUSED(Previous);
|
Q_UNUSED(Previous);
|
||||||
|
|
||||||
|
if (Current && !Current->parent())
|
||||||
SetCurrentStep();
|
SetCurrentStep();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -383,7 +422,10 @@ void lcTimelineWidget::ItemSelectionChanged()
|
||||||
mIgnoreUpdates = true;
|
mIgnoreUpdates = true;
|
||||||
lcModel* Model = gMainWindow->GetActiveModel();
|
lcModel* Model = gMainWindow->GetActiveModel();
|
||||||
if (LastStep > Model->GetCurrentStep())
|
if (LastStep > Model->GetCurrentStep())
|
||||||
|
{
|
||||||
Model->SetCurrentStep(LastStep);
|
Model->SetCurrentStep(LastStep);
|
||||||
|
UpdateCurrentStepItem();
|
||||||
|
}
|
||||||
Model->SetSelectionAndFocus(Selection, CurrentPiece, LC_PIECE_SECTION_POSITION, false);
|
Model->SetSelectionAndFocus(Selection, CurrentPiece, LC_PIECE_SECTION_POSITION, false);
|
||||||
mIgnoreUpdates = false;
|
mIgnoreUpdates = false;
|
||||||
blockSignals(Blocked);
|
blockSignals(Blocked);
|
||||||
|
@ -391,8 +433,22 @@ void lcTimelineWidget::ItemSelectionChanged()
|
||||||
|
|
||||||
void lcTimelineWidget::dropEvent(QDropEvent* Event)
|
void lcTimelineWidget::dropEvent(QDropEvent* Event)
|
||||||
{
|
{
|
||||||
|
QTreeWidgetItem* DropItem = itemAt(Event->pos());
|
||||||
|
lcModel* Model = gMainWindow->GetActiveModel();
|
||||||
|
|
||||||
|
if (DropItem)
|
||||||
|
{
|
||||||
|
QTreeWidgetItem* ParentItem = DropItem->parent();
|
||||||
|
lcStep Step = indexOfTopLevelItem(ParentItem ? ParentItem : DropItem) + 1;
|
||||||
|
|
||||||
|
if (Step > Model->GetCurrentStep())
|
||||||
|
Model->SetCurrentStep(Step);
|
||||||
|
}
|
||||||
|
|
||||||
QTreeWidget::dropEvent(Event);
|
QTreeWidget::dropEvent(Event);
|
||||||
|
|
||||||
UpdateModel();
|
UpdateModel();
|
||||||
|
Update(false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcTimelineWidget::mousePressEvent(QMouseEvent* Event)
|
void lcTimelineWidget::mousePressEvent(QMouseEvent* Event)
|
||||||
|
|
|
@ -25,9 +25,11 @@ protected:
|
||||||
virtual void dropEvent(QDropEvent* Event);
|
virtual void dropEvent(QDropEvent* Event);
|
||||||
virtual void mousePressEvent(QMouseEvent* Event);
|
virtual void mousePressEvent(QMouseEvent* Event);
|
||||||
void UpdateModel();
|
void UpdateModel();
|
||||||
|
void UpdateCurrentStepItem();
|
||||||
|
|
||||||
QMap<int, QIcon> mIcons;
|
QMap<int, QIcon> mIcons;
|
||||||
QMap<lcPiece*, QTreeWidgetItem*> mItems;
|
QMap<lcPiece*, QTreeWidgetItem*> mItems;
|
||||||
|
QTreeWidgetItem* mCurrentStepItem;
|
||||||
bool mIgnoreUpdates;
|
bool mIgnoreUpdates;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue