mirror of
https://github.com/leozide/leocad
synced 2024-12-27 21:58:37 +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"),
|
QT_TRANSLATE_NOOP("Status", "Find previous piece"),
|
||||||
"Shift+F3"
|
"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
|
// LC_EDIT_REPLACE
|
||||||
{
|
{
|
||||||
QT_TRANSLATE_NOOP("Action", "Edit.Replace"),
|
QT_TRANSLATE_NOOP("Action", "Edit.Replace"),
|
||||||
|
@ -241,6 +248,13 @@ const lcCommand gCommands[] =
|
||||||
QT_TRANSLATE_NOOP("Status", "Replace next piece"),
|
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
|
// LC_EDIT_SELECT_ALL
|
||||||
{
|
{
|
||||||
QT_TRANSLATE_NOOP("Action", "Edit.SelectAll"),
|
QT_TRANSLATE_NOOP("Action", "Edit.SelectAll"),
|
||||||
|
|
|
@ -36,8 +36,10 @@ enum lcCommandId
|
||||||
LC_EDIT_FIND,
|
LC_EDIT_FIND,
|
||||||
LC_EDIT_FIND_NEXT,
|
LC_EDIT_FIND_NEXT,
|
||||||
LC_EDIT_FIND_PREVIOUS,
|
LC_EDIT_FIND_PREVIOUS,
|
||||||
|
LC_EDIT_FIND_ALL,
|
||||||
LC_EDIT_REPLACE,
|
LC_EDIT_REPLACE,
|
||||||
LC_EDIT_REPLACE_NEXT,
|
LC_EDIT_REPLACE_NEXT,
|
||||||
|
LC_EDIT_REPLACE_ALL,
|
||||||
LC_EDIT_SELECT_ALL,
|
LC_EDIT_SELECT_ALL,
|
||||||
LC_EDIT_SELECT_NONE,
|
LC_EDIT_SELECT_NONE,
|
||||||
LC_EDIT_SELECT_INVERT,
|
LC_EDIT_SELECT_INVERT,
|
||||||
|
|
|
@ -11,6 +11,9 @@ lcFindReplaceWidget::lcFindReplaceWidget(QWidget* Parent, lcModel* Model, bool R
|
||||||
: QWidget(Parent)
|
: QWidget(Parent)
|
||||||
{
|
{
|
||||||
setAutoFillBackground(true);
|
setAutoFillBackground(true);
|
||||||
|
QPalette Palette = palette();
|
||||||
|
Palette.setColor(QPalette::Window, QApplication::palette().color(QPalette::Button));
|
||||||
|
setPalette(Palette);
|
||||||
|
|
||||||
QGridLayout* Layout = new QGridLayout(this);
|
QGridLayout* Layout = new QGridLayout(this);
|
||||||
Layout->setContentsMargins(5, 5, 5, 5);
|
Layout->setContentsMargins(5, 5, 5, 5);
|
||||||
|
@ -28,9 +31,15 @@ lcFindReplaceWidget::lcFindReplaceWidget(QWidget* Parent, lcModel* Model, bool R
|
||||||
Layout->addWidget(FindPartComboBox, 0, 4);
|
Layout->addWidget(FindPartComboBox, 0, 4);
|
||||||
|
|
||||||
QToolButton* FindNextButton = new QToolButton(this);
|
QToolButton* FindNextButton = new QToolButton(this);
|
||||||
|
FindNextButton->setAutoRaise(true);
|
||||||
FindNextButton->setDefaultAction(gMainWindow->mActions[LC_EDIT_FIND_NEXT]);
|
FindNextButton->setDefaultAction(gMainWindow->mActions[LC_EDIT_FIND_NEXT]);
|
||||||
Layout->addWidget(FindNextButton, 0, 5);
|
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)
|
connect(FindColorCheckBox, &QCheckBox::toggled, [](bool Checked)
|
||||||
{
|
{
|
||||||
gMainWindow->mSearchOptions.MatchColor = Checked;
|
gMainWindow->mSearchOptions.MatchColor = Checked;
|
||||||
|
@ -71,9 +80,15 @@ lcFindReplaceWidget::lcFindReplaceWidget(QWidget* Parent, lcModel* Model, bool R
|
||||||
Layout->addWidget(ReplacePartComboBox, 1, 4);
|
Layout->addWidget(ReplacePartComboBox, 1, 4);
|
||||||
|
|
||||||
QToolButton* ReplaceNextButton = new QToolButton(this);
|
QToolButton* ReplaceNextButton = new QToolButton(this);
|
||||||
|
ReplaceNextButton->setAutoRaise(true);
|
||||||
ReplaceNextButton->setDefaultAction(gMainWindow->mActions[LC_EDIT_REPLACE_NEXT]);
|
ReplaceNextButton->setDefaultAction(gMainWindow->mActions[LC_EDIT_REPLACE_NEXT]);
|
||||||
Layout->addWidget(ReplaceNextButton, 1, 5);
|
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)
|
connect(ReplaceColorCheckBox, &QCheckBox::toggled, [](bool Checked)
|
||||||
{
|
{
|
||||||
gMainWindow->mSearchOptions.ReplaceColor = 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]->setIcon(QIcon(":/resources/edit_find.png"));
|
||||||
mActions[LC_EDIT_FIND_NEXT]->setIcon(QIcon(":/resources/edit_find_next.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_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_EARLIER]->setIcon(QIcon(":/resources/piece_show_earlier.png"));
|
||||||
mActions[LC_PIECE_SHOW_LATER]->setIcon(QIcon(":/resources/piece_show_later.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"));
|
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:
|
case LC_EDIT_FIND_NEXT:
|
||||||
if (ActiveModel)
|
if (ActiveModel)
|
||||||
ActiveModel->FindReplacePiece(true);
|
ActiveModel->FindReplacePiece(true, false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LC_EDIT_FIND_PREVIOUS:
|
case LC_EDIT_FIND_PREVIOUS:
|
||||||
if (ActiveModel)
|
if (ActiveModel)
|
||||||
ActiveModel->FindReplacePiece(false);
|
ActiveModel->FindReplacePiece(false, false);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LC_EDIT_FIND_ALL:
|
||||||
|
if (ActiveModel)
|
||||||
|
ActiveModel->FindReplacePiece(true, true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LC_EDIT_REPLACE:
|
case LC_EDIT_REPLACE:
|
||||||
|
@ -2736,9 +2742,14 @@ void lcMainWindow::HandleCommand(lcCommandId CommandId)
|
||||||
ActiveView->ShowFindReplaceWidget(true);
|
ActiveView->ShowFindReplaceWidget(true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case LC_EDIT_REPLACE_ALL:
|
||||||
|
if (ActiveModel)
|
||||||
|
ActiveModel->FindReplacePiece(true, true);
|
||||||
|
break;
|
||||||
|
|
||||||
case LC_EDIT_REPLACE_NEXT:
|
case LC_EDIT_REPLACE_NEXT:
|
||||||
if (ActiveModel)
|
if (ActiveModel)
|
||||||
ActiveModel->FindReplacePiece(true);
|
ActiveModel->FindReplacePiece(true, false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LC_EDIT_SELECT_ALL:
|
case LC_EDIT_SELECT_ALL:
|
||||||
|
|
|
@ -3779,7 +3779,7 @@ void lcModel::UnhideAllPieces()
|
||||||
SaveCheckpoint(tr("Unhide"));
|
SaveCheckpoint(tr("Unhide"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcModel::FindReplacePiece(bool SearchForward)
|
void lcModel::FindReplacePiece(bool SearchForward, bool FindAll)
|
||||||
{
|
{
|
||||||
if (mPieces.IsEmpty())
|
if (mPieces.IsEmpty())
|
||||||
return;
|
return;
|
||||||
|
@ -3824,6 +3824,7 @@ void lcModel::FindReplacePiece(bool SearchForward)
|
||||||
|
|
||||||
int CurrentIdx = StartIdx;
|
int CurrentIdx = StartIdx;
|
||||||
lcPiece* Focus = nullptr;
|
lcPiece* Focus = nullptr;
|
||||||
|
lcArray<lcObject*> Selection;
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
|
@ -3843,15 +3844,23 @@ void lcModel::FindReplacePiece(bool SearchForward)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (PieceMatches(Current))
|
if (PieceMatches(Current))
|
||||||
|
{
|
||||||
|
if (FindAll)
|
||||||
|
Selection.Add(Current);
|
||||||
|
else
|
||||||
{
|
{
|
||||||
Focus = Current;
|
Focus = Current;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (CurrentIdx == StartIdx)
|
if (CurrentIdx == StartIdx)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (FindAll)
|
||||||
|
SetSelectionAndFocus(Selection, nullptr, 0, false);
|
||||||
|
else
|
||||||
ClearSelectionAndSetFocus(Focus, LC_PIECE_SECTION_POSITION, false);
|
ClearSelectionAndSetFocus(Focus, LC_PIECE_SECTION_POSITION, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -281,7 +281,7 @@ public:
|
||||||
void UnhideSelectedPieces();
|
void UnhideSelectedPieces();
|
||||||
void UnhideAllPieces();
|
void UnhideAllPieces();
|
||||||
|
|
||||||
void FindReplacePiece(bool SearchForward);
|
void FindReplacePiece(bool SearchForward, bool FindAll);
|
||||||
|
|
||||||
void UndoAction();
|
void UndoAction();
|
||||||
void RedoAction();
|
void RedoAction();
|
||||||
|
|
|
@ -65,6 +65,7 @@
|
||||||
<file>resources/edit_find.png</file>
|
<file>resources/edit_find.png</file>
|
||||||
<file>resources/edit_find_next.png</file>
|
<file>resources/edit_find_next.png</file>
|
||||||
<file>resources/edit_find_previous.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_paste.png</file>
|
||||||
<file>resources/edit_redo.png</file>
|
<file>resources/edit_redo.png</file>
|
||||||
<file>resources/edit_snap_angle.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