mirror of
https://github.com/leozide/leocad
synced 2024-12-26 21:58:44 +01:00
Added find all.
This commit is contained in:
parent
ecb1112d90
commit
6a2c8a715e
8 changed files with 60 additions and 8 deletions
|
@ -227,6 +227,13 @@ const lcCommand gCommands[] =
|
|||
QT_TRANSLATE_NOOP("Status", "Find previous piece"),
|
||||
"Shift+F3"
|
||||
},
|
||||
// LC_EDIT_FIND_ALL
|
||||
{
|
||||
QT_TRANSLATE_NOOP("Action", "Edit.FindAll"),
|
||||
QT_TRANSLATE_NOOP("Menu", "Find All"),
|
||||
QT_TRANSLATE_NOOP("Status", "Find all pieces that match the search criteria"),
|
||||
""
|
||||
},
|
||||
// LC_EDIT_REPLACE
|
||||
{
|
||||
QT_TRANSLATE_NOOP("Action", "Edit.Replace"),
|
||||
|
@ -241,6 +248,13 @@ const lcCommand gCommands[] =
|
|||
QT_TRANSLATE_NOOP("Status", "Replace next piece"),
|
||||
""
|
||||
},
|
||||
// LC_EDIT_REPLACE_ALL
|
||||
{
|
||||
QT_TRANSLATE_NOOP("Action", "Edit.ReplaceAll"),
|
||||
QT_TRANSLATE_NOOP("Menu", "Replace All"),
|
||||
QT_TRANSLATE_NOOP("Status", "Replace pieces that match the search criteria"),
|
||||
""
|
||||
},
|
||||
// LC_EDIT_SELECT_ALL
|
||||
{
|
||||
QT_TRANSLATE_NOOP("Action", "Edit.SelectAll"),
|
||||
|
|
|
@ -36,8 +36,10 @@ enum lcCommandId
|
|||
LC_EDIT_FIND,
|
||||
LC_EDIT_FIND_NEXT,
|
||||
LC_EDIT_FIND_PREVIOUS,
|
||||
LC_EDIT_FIND_ALL,
|
||||
LC_EDIT_REPLACE,
|
||||
LC_EDIT_REPLACE_NEXT,
|
||||
LC_EDIT_REPLACE_ALL,
|
||||
LC_EDIT_SELECT_ALL,
|
||||
LC_EDIT_SELECT_NONE,
|
||||
LC_EDIT_SELECT_INVERT,
|
||||
|
|
|
@ -11,6 +11,9 @@ lcFindReplaceWidget::lcFindReplaceWidget(QWidget* Parent, lcModel* Model, bool R
|
|||
: QWidget(Parent)
|
||||
{
|
||||
setAutoFillBackground(true);
|
||||
QPalette Palette = palette();
|
||||
Palette.setColor(QPalette::Window, QApplication::palette().color(QPalette::Button));
|
||||
setPalette(Palette);
|
||||
|
||||
QGridLayout* Layout = new QGridLayout(this);
|
||||
Layout->setContentsMargins(5, 5, 5, 5);
|
||||
|
@ -28,9 +31,15 @@ lcFindReplaceWidget::lcFindReplaceWidget(QWidget* Parent, lcModel* Model, bool R
|
|||
Layout->addWidget(FindPartComboBox, 0, 4);
|
||||
|
||||
QToolButton* FindNextButton = new QToolButton(this);
|
||||
FindNextButton->setAutoRaise(true);
|
||||
FindNextButton->setDefaultAction(gMainWindow->mActions[LC_EDIT_FIND_NEXT]);
|
||||
Layout->addWidget(FindNextButton, 0, 5);
|
||||
|
||||
QToolButton* FindAllButton = new QToolButton(this);
|
||||
FindAllButton ->setAutoRaise(true);
|
||||
FindAllButton ->setDefaultAction(gMainWindow->mActions[LC_EDIT_FIND_ALL]);
|
||||
Layout->addWidget(FindAllButton, 0, 6);
|
||||
|
||||
connect(FindColorCheckBox, &QCheckBox::toggled, [](bool Checked)
|
||||
{
|
||||
gMainWindow->mSearchOptions.MatchColor = Checked;
|
||||
|
@ -71,9 +80,15 @@ lcFindReplaceWidget::lcFindReplaceWidget(QWidget* Parent, lcModel* Model, bool R
|
|||
Layout->addWidget(ReplacePartComboBox, 1, 4);
|
||||
|
||||
QToolButton* ReplaceNextButton = new QToolButton(this);
|
||||
ReplaceNextButton->setAutoRaise(true);
|
||||
ReplaceNextButton->setDefaultAction(gMainWindow->mActions[LC_EDIT_REPLACE_NEXT]);
|
||||
Layout->addWidget(ReplaceNextButton, 1, 5);
|
||||
|
||||
QToolButton* ReplaceAllButton = new QToolButton(this);
|
||||
ReplaceAllButton->setAutoRaise(true);
|
||||
ReplaceAllButton->setDefaultAction(gMainWindow->mActions[LC_EDIT_REPLACE_ALL]);
|
||||
Layout->addWidget(ReplaceAllButton, 1, 6);
|
||||
|
||||
connect(ReplaceColorCheckBox, &QCheckBox::toggled, [](bool Checked)
|
||||
{
|
||||
gMainWindow->mSearchOptions.ReplaceColor = Checked;
|
||||
|
|
|
@ -287,6 +287,7 @@ void lcMainWindow::CreateActions()
|
|||
mActions[LC_EDIT_FIND]->setIcon(QIcon(":/resources/edit_find.png"));
|
||||
mActions[LC_EDIT_FIND_NEXT]->setIcon(QIcon(":/resources/edit_find_next.png"));
|
||||
mActions[LC_EDIT_FIND_PREVIOUS]->setIcon(QIcon(":/resources/edit_find_previous.png"));
|
||||
mActions[LC_EDIT_FIND_ALL]->setIcon(QIcon(":/resources/edit_find_all.png"));
|
||||
mActions[LC_PIECE_SHOW_EARLIER]->setIcon(QIcon(":/resources/piece_show_earlier.png"));
|
||||
mActions[LC_PIECE_SHOW_LATER]->setIcon(QIcon(":/resources/piece_show_later.png"));
|
||||
mActions[LC_VIEW_SPLIT_HORIZONTAL]->setIcon(QIcon(":/resources/view_split_horizontal.png"));
|
||||
|
@ -2723,12 +2724,17 @@ void lcMainWindow::HandleCommand(lcCommandId CommandId)
|
|||
|
||||
case LC_EDIT_FIND_NEXT:
|
||||
if (ActiveModel)
|
||||
ActiveModel->FindReplacePiece(true);
|
||||
ActiveModel->FindReplacePiece(true, false);
|
||||
break;
|
||||
|
||||
case LC_EDIT_FIND_PREVIOUS:
|
||||
if (ActiveModel)
|
||||
ActiveModel->FindReplacePiece(false);
|
||||
ActiveModel->FindReplacePiece(false, false);
|
||||
break;
|
||||
|
||||
case LC_EDIT_FIND_ALL:
|
||||
if (ActiveModel)
|
||||
ActiveModel->FindReplacePiece(true, true);
|
||||
break;
|
||||
|
||||
case LC_EDIT_REPLACE:
|
||||
|
@ -2736,9 +2742,14 @@ void lcMainWindow::HandleCommand(lcCommandId CommandId)
|
|||
ActiveView->ShowFindReplaceWidget(true);
|
||||
break;
|
||||
|
||||
case LC_EDIT_REPLACE_ALL:
|
||||
if (ActiveModel)
|
||||
ActiveModel->FindReplacePiece(true, true);
|
||||
break;
|
||||
|
||||
case LC_EDIT_REPLACE_NEXT:
|
||||
if (ActiveModel)
|
||||
ActiveModel->FindReplacePiece(true);
|
||||
ActiveModel->FindReplacePiece(true, false);
|
||||
break;
|
||||
|
||||
case LC_EDIT_SELECT_ALL:
|
||||
|
|
|
@ -3779,7 +3779,7 @@ void lcModel::UnhideAllPieces()
|
|||
SaveCheckpoint(tr("Unhide"));
|
||||
}
|
||||
|
||||
void lcModel::FindReplacePiece(bool SearchForward)
|
||||
void lcModel::FindReplacePiece(bool SearchForward, bool FindAll)
|
||||
{
|
||||
if (mPieces.IsEmpty())
|
||||
return;
|
||||
|
@ -3824,6 +3824,7 @@ void lcModel::FindReplacePiece(bool SearchForward)
|
|||
|
||||
int CurrentIdx = StartIdx;
|
||||
lcPiece* Focus = nullptr;
|
||||
lcArray<lcObject*> Selection;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
|
@ -3843,15 +3844,23 @@ void lcModel::FindReplacePiece(bool SearchForward)
|
|||
continue;
|
||||
|
||||
if (PieceMatches(Current))
|
||||
{
|
||||
if (FindAll)
|
||||
Selection.Add(Current);
|
||||
else
|
||||
{
|
||||
Focus = Current;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (CurrentIdx == StartIdx)
|
||||
break;
|
||||
}
|
||||
|
||||
if (FindAll)
|
||||
SetSelectionAndFocus(Selection, nullptr, 0, false);
|
||||
else
|
||||
ClearSelectionAndSetFocus(Focus, LC_PIECE_SECTION_POSITION, false);
|
||||
}
|
||||
|
||||
|
|
|
@ -281,7 +281,7 @@ public:
|
|||
void UnhideSelectedPieces();
|
||||
void UnhideAllPieces();
|
||||
|
||||
void FindReplacePiece(bool SearchForward);
|
||||
void FindReplacePiece(bool SearchForward, bool FindAll);
|
||||
|
||||
void UndoAction();
|
||||
void RedoAction();
|
||||
|
|
|
@ -65,6 +65,7 @@
|
|||
<file>resources/edit_find.png</file>
|
||||
<file>resources/edit_find_next.png</file>
|
||||
<file>resources/edit_find_previous.png</file>
|
||||
<file>resources/edit_find_all.png</file>
|
||||
<file>resources/edit_paste.png</file>
|
||||
<file>resources/edit_redo.png</file>
|
||||
<file>resources/edit_snap_angle.png</file>
|
||||
|
|
BIN
resources/edit_find_all.png
Normal file
BIN
resources/edit_find_all.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 219 B |
Loading…
Reference in a new issue