mirror of
https://github.com/leozide/leocad
synced 2024-12-27 21:58:37 +01:00
New find/replace widget.
This commit is contained in:
parent
a257aab9c6
commit
b74eb3a81e
14 changed files with 288 additions and 260 deletions
|
@ -209,24 +209,38 @@ const lcCommand gCommands[] =
|
||||||
// LC_EDIT_FIND
|
// LC_EDIT_FIND
|
||||||
{
|
{
|
||||||
QT_TRANSLATE_NOOP("Action", "Edit.Find"),
|
QT_TRANSLATE_NOOP("Action", "Edit.Find"),
|
||||||
QT_TRANSLATE_NOOP("Menu", "&Find..."),
|
QT_TRANSLATE_NOOP("Menu", "&Find"),
|
||||||
QT_TRANSLATE_NOOP("Status", "Find object"),
|
QT_TRANSLATE_NOOP("Status", "Find piece"),
|
||||||
"Ctrl+F"
|
"Ctrl+F"
|
||||||
},
|
},
|
||||||
// LC_EDIT_FIND_NEXT
|
// LC_EDIT_FIND_NEXT
|
||||||
{
|
{
|
||||||
QT_TRANSLATE_NOOP("Action", "Edit.FindNext"),
|
QT_TRANSLATE_NOOP("Action", "Edit.FindNext"),
|
||||||
QT_TRANSLATE_NOOP("Menu", "Find Ne&xt"),
|
QT_TRANSLATE_NOOP("Menu", "Find Ne&xt"),
|
||||||
QT_TRANSLATE_NOOP("Status", "Find next object"),
|
QT_TRANSLATE_NOOP("Status", "Find next piece"),
|
||||||
"F3"
|
"F3"
|
||||||
},
|
},
|
||||||
// LC_EDIT_FIND_PREVIOUS
|
// LC_EDIT_FIND_PREVIOUS
|
||||||
{
|
{
|
||||||
QT_TRANSLATE_NOOP("Action", "Edit.FindPrevious"),
|
QT_TRANSLATE_NOOP("Action", "Edit.FindPrevious"),
|
||||||
QT_TRANSLATE_NOOP("Menu", "Find Pre&vious"),
|
QT_TRANSLATE_NOOP("Menu", "Find Pre&vious"),
|
||||||
QT_TRANSLATE_NOOP("Status", "Find object"),
|
QT_TRANSLATE_NOOP("Status", "Find previous piece"),
|
||||||
"Shift+F3"
|
"Shift+F3"
|
||||||
},
|
},
|
||||||
|
// LC_EDIT_REPLACE
|
||||||
|
{
|
||||||
|
QT_TRANSLATE_NOOP("Action", "Edit.Replace"),
|
||||||
|
QT_TRANSLATE_NOOP("Menu", "&Replace"),
|
||||||
|
QT_TRANSLATE_NOOP("Status", "Replace piece"),
|
||||||
|
""
|
||||||
|
},
|
||||||
|
// LC_EDIT_REPLACE_NEXT
|
||||||
|
{
|
||||||
|
QT_TRANSLATE_NOOP("Action", "Edit.ReplaceNext"),
|
||||||
|
QT_TRANSLATE_NOOP("Menu", "Replace Next"),
|
||||||
|
QT_TRANSLATE_NOOP("Status", "Replace next piece"),
|
||||||
|
""
|
||||||
|
},
|
||||||
// LC_EDIT_SELECT_ALL
|
// LC_EDIT_SELECT_ALL
|
||||||
{
|
{
|
||||||
QT_TRANSLATE_NOOP("Action", "Edit.SelectAll"),
|
QT_TRANSLATE_NOOP("Action", "Edit.SelectAll"),
|
||||||
|
|
|
@ -36,6 +36,8 @@ 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_REPLACE,
|
||||||
|
LC_EDIT_REPLACE_NEXT,
|
||||||
LC_EDIT_SELECT_ALL,
|
LC_EDIT_SELECT_ALL,
|
||||||
LC_EDIT_SELECT_NONE,
|
LC_EDIT_SELECT_NONE,
|
||||||
LC_EDIT_SELECT_INVERT,
|
LC_EDIT_SELECT_INVERT,
|
||||||
|
|
158
common/lc_findreplacewidget.cpp
Normal file
158
common/lc_findreplacewidget.cpp
Normal file
|
@ -0,0 +1,158 @@
|
||||||
|
#include "lc_global.h"
|
||||||
|
#include "lc_findreplacewidget.h"
|
||||||
|
#include "lc_qcolorpicker.h"
|
||||||
|
#include "lc_library.h"
|
||||||
|
#include "lc_mainwindow.h"
|
||||||
|
#include "pieceinf.h"
|
||||||
|
#include "piece.h"
|
||||||
|
#include "lc_model.h"
|
||||||
|
|
||||||
|
lcFindReplaceWidget::lcFindReplaceWidget(QWidget* Parent, lcModel* Model, bool Replace)
|
||||||
|
: QWidget(Parent)
|
||||||
|
{
|
||||||
|
setAutoFillBackground(true);
|
||||||
|
|
||||||
|
QGridLayout* Layout = new QGridLayout(this);
|
||||||
|
Layout->setContentsMargins(5, 5, 5, 5);
|
||||||
|
|
||||||
|
QCheckBox* FindColorCheckBox = new QCheckBox(tr("Find Color"), this);
|
||||||
|
Layout->addWidget(FindColorCheckBox, 0, 1);
|
||||||
|
|
||||||
|
lcQColorPicker* FindColorPicker = new lcQColorPicker(this);
|
||||||
|
Layout->addWidget(FindColorPicker, 0, 2);
|
||||||
|
|
||||||
|
QCheckBox* FindPartCheckBox = new QCheckBox(tr("Find Part"), this);
|
||||||
|
Layout->addWidget(FindPartCheckBox, 0, 3);
|
||||||
|
|
||||||
|
QComboBox* FindPartComboBox = new QComboBox(this);
|
||||||
|
Layout->addWidget(FindPartComboBox, 0, 4);
|
||||||
|
|
||||||
|
QToolButton* FindNextButton = new QToolButton(this);
|
||||||
|
FindNextButton->setDefaultAction(gMainWindow->mActions[LC_EDIT_FIND_NEXT]);
|
||||||
|
Layout->addWidget(FindNextButton, 0, 5);
|
||||||
|
|
||||||
|
connect(FindColorCheckBox, &QCheckBox::toggled, [](bool Checked)
|
||||||
|
{
|
||||||
|
gMainWindow->mSearchOptions.MatchColor = Checked;
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(FindColorPicker, &lcQColorPicker::colorChanged, [](int ColorIndex)
|
||||||
|
{
|
||||||
|
gMainWindow->mSearchOptions.ColorIndex = ColorIndex;
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(FindPartCheckBox, &QCheckBox::toggled, [](bool Checked)
|
||||||
|
{
|
||||||
|
gMainWindow->mSearchOptions.MatchInfo = Checked;
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(FindPartComboBox, qOverload<int>(&QComboBox::currentIndexChanged), [FindPartComboBox](int Index)
|
||||||
|
{
|
||||||
|
gMainWindow->mSearchOptions.Info = (PieceInfo*)FindPartComboBox->itemData(Index).value<void*>();
|
||||||
|
});
|
||||||
|
|
||||||
|
QCheckBox* ReplaceColorCheckBox = nullptr;
|
||||||
|
lcQColorPicker* ReplaceColorPicker = nullptr;
|
||||||
|
QCheckBox* ReplacePartCheckBox = nullptr;
|
||||||
|
QComboBox* ReplacePartComboBox = nullptr;
|
||||||
|
|
||||||
|
if (Replace)
|
||||||
|
{
|
||||||
|
ReplaceColorCheckBox = new QCheckBox(tr("Replace Color"), this);
|
||||||
|
Layout->addWidget(ReplaceColorCheckBox, 1, 1);
|
||||||
|
|
||||||
|
ReplaceColorPicker = new lcQColorPicker(this);
|
||||||
|
Layout->addWidget(ReplaceColorPicker, 1, 2);
|
||||||
|
|
||||||
|
ReplacePartCheckBox = new QCheckBox(tr("Replace Part"), this);
|
||||||
|
Layout->addWidget(ReplacePartCheckBox, 1, 3);
|
||||||
|
|
||||||
|
ReplacePartComboBox = new QComboBox(this);
|
||||||
|
Layout->addWidget(ReplacePartComboBox, 1, 4);
|
||||||
|
|
||||||
|
QToolButton* ReplaceNextButton = new QToolButton(this);
|
||||||
|
ReplaceNextButton->setDefaultAction(gMainWindow->mActions[LC_EDIT_REPLACE_NEXT]);
|
||||||
|
Layout->addWidget(ReplaceNextButton, 1, 5);
|
||||||
|
|
||||||
|
connect(ReplaceColorCheckBox, &QCheckBox::toggled, [](bool Checked)
|
||||||
|
{
|
||||||
|
gMainWindow->mSearchOptions.ReplaceColor = Checked;
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(ReplaceColorPicker, &lcQColorPicker::colorChanged, [](int ColorIndex)
|
||||||
|
{
|
||||||
|
gMainWindow->mSearchOptions.ReplaceColorIndex = ColorIndex;
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(ReplacePartCheckBox, &QCheckBox::toggled, [](bool Checked)
|
||||||
|
{
|
||||||
|
gMainWindow->mSearchOptions.ReplaceInfo = Checked;
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(ReplacePartComboBox, qOverload<int>(&QComboBox::currentIndexChanged), [ReplacePartComboBox](int Index)
|
||||||
|
{
|
||||||
|
gMainWindow->mSearchOptions.ReplacePieceInfo = (PieceInfo*)ReplacePartComboBox->itemData(Index).value<void*>();
|
||||||
|
});
|
||||||
|
|
||||||
|
ReplacePartComboBox->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon);
|
||||||
|
ReplacePartComboBox->setMinimumContentsLength(1);
|
||||||
|
|
||||||
|
lcPiecesLibrary* Library = lcGetPiecesLibrary();
|
||||||
|
std::vector<PieceInfo*> SortedPieces;
|
||||||
|
SortedPieces.reserve(Library->mPieces.size());
|
||||||
|
|
||||||
|
for (const auto& PartIt : Library->mPieces)
|
||||||
|
SortedPieces.push_back(PartIt.second);
|
||||||
|
|
||||||
|
auto PieceCompare = [](PieceInfo* Info1, PieceInfo* Info2)
|
||||||
|
{
|
||||||
|
return strcmp(Info1->m_strDescription, Info2->m_strDescription) < 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::sort(SortedPieces.begin(), SortedPieces.end(), PieceCompare);
|
||||||
|
|
||||||
|
for (PieceInfo* Info : SortedPieces)
|
||||||
|
ReplacePartComboBox->addItem(Info->m_strDescription, QVariant::fromValue((void*)Info));
|
||||||
|
}
|
||||||
|
|
||||||
|
lcPartsList PartsList;
|
||||||
|
Model->GetPartsList(gDefaultColor, false, true, PartsList);
|
||||||
|
|
||||||
|
for (const auto& PartIt : PartsList)
|
||||||
|
FindPartComboBox->addItem(PartIt.first->m_strDescription, QVariant::fromValue((void*)PartIt.first));
|
||||||
|
FindPartComboBox->model()->sort(0);
|
||||||
|
|
||||||
|
lcPiece* Focus = dynamic_cast<lcPiece*>(Model->GetFocusObject());
|
||||||
|
|
||||||
|
lcSearchOptions& SearchOptions = gMainWindow->mSearchOptions;
|
||||||
|
|
||||||
|
if (!Replace)
|
||||||
|
{
|
||||||
|
SearchOptions.ReplaceColor = false;
|
||||||
|
SearchOptions.ReplaceInfo = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Focus)
|
||||||
|
{
|
||||||
|
SearchOptions.SearchValid = true;
|
||||||
|
SearchOptions.Info = Focus->mPieceInfo;
|
||||||
|
SearchOptions.ColorIndex = Focus->GetColorIndex();
|
||||||
|
|
||||||
|
FindColorCheckBox->setChecked(true);
|
||||||
|
FindColorPicker->setCurrentColor(SearchOptions.ColorIndex);
|
||||||
|
FindPartCheckBox->setChecked(true);
|
||||||
|
FindPartComboBox->setCurrentIndex(FindPartComboBox->findData(QVariant::fromValue((void*)SearchOptions.Info)));
|
||||||
|
|
||||||
|
if (Replace)
|
||||||
|
{
|
||||||
|
ReplaceColorCheckBox->setChecked(true);
|
||||||
|
ReplaceColorPicker->setCurrentColor(SearchOptions.ColorIndex);
|
||||||
|
ReplacePartCheckBox->setChecked(true);
|
||||||
|
ReplacePartComboBox->setCurrentIndex(ReplacePartComboBox->findData(QVariant::fromValue((void*)SearchOptions.Info)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
adjustSize();
|
||||||
|
move(1, 1);
|
||||||
|
show();
|
||||||
|
}
|
9
common/lc_findreplacewidget.h
Normal file
9
common/lc_findreplacewidget.h
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
class lcFindReplaceWidget : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
lcFindReplaceWidget(QWidget* Parent, lcModel* Model, bool Replace);
|
||||||
|
};
|
|
@ -8,7 +8,6 @@
|
||||||
#include "lc_qcolorlist.h"
|
#include "lc_qcolorlist.h"
|
||||||
#include "lc_qpropertiestree.h"
|
#include "lc_qpropertiestree.h"
|
||||||
#include "lc_qutils.h"
|
#include "lc_qutils.h"
|
||||||
#include "lc_qfinddialog.h"
|
|
||||||
#include "lc_qupdatedialog.h"
|
#include "lc_qupdatedialog.h"
|
||||||
#include "lc_qaboutdialog.h"
|
#include "lc_qaboutdialog.h"
|
||||||
#include "lc_setsdatabasedialog.h"
|
#include "lc_setsdatabasedialog.h"
|
||||||
|
@ -24,7 +23,6 @@
|
||||||
#include "pieceinf.h"
|
#include "pieceinf.h"
|
||||||
#include "lc_library.h"
|
#include "lc_library.h"
|
||||||
#include "lc_colors.h"
|
#include "lc_colors.h"
|
||||||
|
|
||||||
#include "lc_previewwidget.h"
|
#include "lc_previewwidget.h"
|
||||||
|
|
||||||
#if LC_ENABLE_GAMEPAD
|
#if LC_ENABLE_GAMEPAD
|
||||||
|
@ -493,9 +491,10 @@ void lcMainWindow::CreateMenus()
|
||||||
EditMenu->addAction(mActions[LC_EDIT_PASTE]);
|
EditMenu->addAction(mActions[LC_EDIT_PASTE]);
|
||||||
EditMenu->addSeparator();
|
EditMenu->addSeparator();
|
||||||
EditMenu->addAction(mActions[LC_EDIT_FIND]);
|
EditMenu->addAction(mActions[LC_EDIT_FIND]);
|
||||||
|
|
||||||
EditMenu->addAction(mActions[LC_EDIT_FIND_NEXT]);
|
EditMenu->addAction(mActions[LC_EDIT_FIND_NEXT]);
|
||||||
EditMenu->addAction(mActions[LC_EDIT_FIND_PREVIOUS]);
|
EditMenu->addAction(mActions[LC_EDIT_FIND_PREVIOUS]);
|
||||||
|
EditMenu->addAction(mActions[LC_EDIT_REPLACE]);
|
||||||
|
EditMenu->addAction(mActions[LC_EDIT_REPLACE_NEXT]);
|
||||||
EditMenu->addSeparator();
|
EditMenu->addSeparator();
|
||||||
EditMenu->addAction(mActions[LC_EDIT_SELECT_ALL]);
|
EditMenu->addAction(mActions[LC_EDIT_SELECT_ALL]);
|
||||||
EditMenu->addAction(mActions[LC_EDIT_SELECT_NONE]);
|
EditMenu->addAction(mActions[LC_EDIT_SELECT_NONE]);
|
||||||
|
@ -1268,22 +1267,6 @@ void lcMainWindow::Print(QPrinter* Printer)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcMainWindow::ShowSearchDialog()
|
|
||||||
{
|
|
||||||
lcModel* Model = GetActiveModel();
|
|
||||||
|
|
||||||
if (!mSearchOptions.SearchValid)
|
|
||||||
{
|
|
||||||
lcObject* Focus = Model->GetFocusObject();
|
|
||||||
if (Focus && Focus->IsPiece())
|
|
||||||
mSearchOptions.Info = ((lcPiece*)Focus)->mPieceInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
lcQFindDialog Dialog(this, &mSearchOptions, Model);
|
|
||||||
if (Dialog.exec() == QDialog::Accepted)
|
|
||||||
Model->FindPiece(true, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void lcMainWindow::ShowUpdatesDialog()
|
void lcMainWindow::ShowUpdatesDialog()
|
||||||
{
|
{
|
||||||
lcQUpdateDialog Dialog(this, false);
|
lcQUpdateDialog Dialog(this, false);
|
||||||
|
@ -1634,12 +1617,12 @@ void lcMainWindow::SetCurrentModelTab(lcModel* Model)
|
||||||
TabWidget = new lcModelTabWidget(Model);
|
TabWidget = new lcModelTabWidget(Model);
|
||||||
mModelTabWidget->addTab(TabWidget, Model->GetProperties().mFileName);
|
mModelTabWidget->addTab(TabWidget, Model->GetProperties().mFileName);
|
||||||
|
|
||||||
QGridLayout* CentralLayout = new QGridLayout(TabWidget);
|
QVBoxLayout* CentralLayout = new QVBoxLayout(TabWidget);
|
||||||
CentralLayout->setContentsMargins(0, 0, 0, 0);
|
CentralLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
|
||||||
NewView = CreateView(Model);
|
NewView = CreateView(Model);
|
||||||
ViewWidget = new lcViewWidget(TabWidget, NewView);
|
ViewWidget = new lcViewWidget(TabWidget, NewView);
|
||||||
CentralLayout->addWidget(ViewWidget, 0, 0, 1, 1);
|
CentralLayout->addWidget(ViewWidget);
|
||||||
|
|
||||||
mModelTabWidget->setCurrentWidget(TabWidget);
|
mModelTabWidget->setCurrentWidget(TabWidget);
|
||||||
}
|
}
|
||||||
|
@ -1703,9 +1686,13 @@ void lcMainWindow::RemoveView(lcView* View)
|
||||||
void lcMainWindow::SetActiveView(lcView* ActiveView)
|
void lcMainWindow::SetActiveView(lcView* ActiveView)
|
||||||
{
|
{
|
||||||
lcModelTabWidget* TabWidget = GetTabForView(ActiveView);
|
lcModelTabWidget* TabWidget = GetTabForView(ActiveView);
|
||||||
|
|
||||||
|
if (!TabWidget)
|
||||||
|
return;
|
||||||
|
|
||||||
lcView* CurrentActiveView = TabWidget->GetActiveView();
|
lcView* CurrentActiveView = TabWidget->GetActiveView();
|
||||||
|
|
||||||
if (!TabWidget || CurrentActiveView == ActiveView)
|
if (CurrentActiveView == ActiveView)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (CurrentActiveView)
|
if (CurrentActiveView)
|
||||||
|
@ -2726,17 +2713,28 @@ void lcMainWindow::HandleCommand(lcCommandId CommandId)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LC_EDIT_FIND:
|
case LC_EDIT_FIND:
|
||||||
ShowSearchDialog();
|
if (ActiveView)
|
||||||
|
ActiveView->ShowFindReplaceWidget(false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LC_EDIT_FIND_NEXT:
|
case LC_EDIT_FIND_NEXT:
|
||||||
if (ActiveModel)
|
if (ActiveModel)
|
||||||
ActiveModel->FindPiece(false, true);
|
ActiveModel->FindReplacePiece(true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LC_EDIT_FIND_PREVIOUS:
|
case LC_EDIT_FIND_PREVIOUS:
|
||||||
if (ActiveModel)
|
if (ActiveModel)
|
||||||
ActiveModel->FindPiece(false, false);
|
ActiveModel->FindReplacePiece(false);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LC_EDIT_REPLACE:
|
||||||
|
if (ActiveView)
|
||||||
|
ActiveView->ShowFindReplaceWidget(true);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LC_EDIT_REPLACE_NEXT:
|
||||||
|
if (ActiveModel)
|
||||||
|
ActiveModel->FindReplacePiece(true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LC_EDIT_SELECT_ALL:
|
case LC_EDIT_SELECT_ALL:
|
||||||
|
@ -3448,7 +3446,7 @@ void lcMainWindow::HandleCommand(lcCommandId CommandId)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LC_EDIT_CANCEL:
|
case LC_EDIT_CANCEL:
|
||||||
if (ActiveView)
|
if (ActiveView && !ActiveView->CloseFindReplaceDialog())
|
||||||
ActiveView->CancelTrackingOrClearSelection();
|
ActiveView->CancelTrackingOrClearSelection();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -25,10 +25,13 @@ struct lcSearchOptions
|
||||||
bool SearchValid;
|
bool SearchValid;
|
||||||
bool MatchInfo;
|
bool MatchInfo;
|
||||||
bool MatchColor;
|
bool MatchColor;
|
||||||
bool MatchName;
|
bool ReplaceInfo;
|
||||||
|
bool ReplaceColor;
|
||||||
|
|
||||||
PieceInfo* Info;
|
PieceInfo* Info;
|
||||||
int ColorIndex;
|
int ColorIndex;
|
||||||
char Name[256];
|
PieceInfo* ReplacePieceInfo;
|
||||||
|
int ReplaceColorIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
class lcTabBar : public QTabBar
|
class lcTabBar : public QTabBar
|
||||||
|
@ -375,7 +378,6 @@ protected:
|
||||||
void SetActiveView(lcView* ActiveView);
|
void SetActiveView(lcView* ActiveView);
|
||||||
void ToggleDockWidget(QWidget* DockWidget);
|
void ToggleDockWidget(QWidget* DockWidget);
|
||||||
void SplitView(Qt::Orientation Orientation);
|
void SplitView(Qt::Orientation Orientation);
|
||||||
void ShowSearchDialog();
|
|
||||||
void ShowUpdatesDialog();
|
void ShowUpdatesDialog();
|
||||||
void ShowAboutDialog();
|
void ShowAboutDialog();
|
||||||
void ShowHTMLDialog();
|
void ShowHTMLDialog();
|
||||||
|
|
|
@ -3779,29 +3779,51 @@ void lcModel::UnhideAllPieces()
|
||||||
SaveCheckpoint(tr("Unhide"));
|
SaveCheckpoint(tr("Unhide"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcModel::FindPiece(bool FindFirst, bool SearchForward)
|
void lcModel::FindReplacePiece(bool SearchForward)
|
||||||
{
|
{
|
||||||
if (mPieces.IsEmpty())
|
if (mPieces.IsEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int StartIdx = mPieces.GetSize() - 1;
|
const lcSearchOptions& SearchOptions = gMainWindow->mSearchOptions;
|
||||||
if (!FindFirst)
|
|
||||||
|
if (!SearchOptions.SearchValid)
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto PieceMatches = [](const lcPiece* Piece)
|
||||||
{
|
{
|
||||||
|
const lcSearchOptions& SearchOptions = gMainWindow->mSearchOptions;
|
||||||
|
return (!SearchOptions.MatchInfo || Piece->mPieceInfo == SearchOptions.Info) && (!SearchOptions.MatchColor || Piece->GetColorIndex() == SearchOptions.ColorIndex);
|
||||||
|
};
|
||||||
|
|
||||||
|
int StartIdx = mPieces.GetSize() - 1;
|
||||||
|
|
||||||
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
|
||||||
{
|
{
|
||||||
lcPiece* Piece = mPieces[PieceIdx];
|
lcPiece* Piece = mPieces[PieceIdx];
|
||||||
|
|
||||||
if (Piece->IsFocused() && Piece->IsVisible(mCurrentStep))
|
if (Piece->IsFocused() && Piece->IsVisible(mCurrentStep))
|
||||||
{
|
{
|
||||||
|
if (PieceMatches(Piece))
|
||||||
|
{
|
||||||
|
if (SearchOptions.ReplaceColor)
|
||||||
|
Piece->SetColorIndex(SearchOptions.ReplaceColorIndex);
|
||||||
|
|
||||||
|
if (SearchOptions.ReplaceInfo)
|
||||||
|
Piece->SetPieceInfo(SearchOptions.ReplacePieceInfo, QString(), true);
|
||||||
|
|
||||||
|
SaveCheckpoint(tr("Replacing Part"));
|
||||||
|
gMainWindow->UpdateSelectedObjects(false);
|
||||||
|
UpdateAllViews();
|
||||||
|
gMainWindow->UpdateTimeline(false, true);
|
||||||
|
}
|
||||||
|
|
||||||
StartIdx = PieceIdx;
|
StartIdx = PieceIdx;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
int CurrentIdx = StartIdx;
|
int CurrentIdx = StartIdx;
|
||||||
lcObject* Focus = nullptr;
|
lcPiece* Focus = nullptr;
|
||||||
const lcSearchOptions& SearchOptions = gMainWindow->mSearchOptions;
|
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
|
@ -3815,21 +3837,19 @@ void lcModel::FindPiece(bool FindFirst, bool SearchForward)
|
||||||
else if (CurrentIdx >= mPieces.GetSize())
|
else if (CurrentIdx >= mPieces.GetSize())
|
||||||
CurrentIdx = 0;
|
CurrentIdx = 0;
|
||||||
|
|
||||||
if (CurrentIdx == StartIdx)
|
|
||||||
break;
|
|
||||||
|
|
||||||
lcPiece* Current = mPieces[CurrentIdx];
|
lcPiece* Current = mPieces[CurrentIdx];
|
||||||
|
|
||||||
if (!Current->IsVisible(mCurrentStep))
|
if (!Current->IsVisible(mCurrentStep))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ((!SearchOptions.MatchInfo || Current->mPieceInfo == SearchOptions.Info) &&
|
if (PieceMatches(Current))
|
||||||
(!SearchOptions.MatchColor || Current->GetColorIndex() == SearchOptions.ColorIndex) &&
|
|
||||||
(!SearchOptions.MatchName || (Current->GetName().indexOf(SearchOptions.Name, 0, Qt::CaseInsensitive) != -1)))
|
|
||||||
{
|
{
|
||||||
Focus = Current;
|
Focus = Current;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (CurrentIdx == StartIdx)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
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 FindPiece(bool FindFirst, bool SearchForward);
|
void FindReplacePiece(bool SearchForward);
|
||||||
|
|
||||||
void UndoAction();
|
void UndoAction();
|
||||||
void RedoAction();
|
void RedoAction();
|
||||||
|
|
|
@ -12,7 +12,9 @@
|
||||||
#include "lc_scene.h"
|
#include "lc_scene.h"
|
||||||
#include "lc_context.h"
|
#include "lc_context.h"
|
||||||
#include "lc_viewsphere.h"
|
#include "lc_viewsphere.h"
|
||||||
|
#include "lc_findreplacewidget.h"
|
||||||
|
|
||||||
|
QWidget* lcView::mFindWidget;
|
||||||
lcView* lcView::mLastFocusedView;
|
lcView* lcView::mLastFocusedView;
|
||||||
std::vector<lcView*> lcView::mViews;
|
std::vector<lcView*> lcView::mViews;
|
||||||
|
|
||||||
|
@ -95,7 +97,13 @@ void lcView::SetFocus(bool Focus)
|
||||||
{
|
{
|
||||||
if (Focus)
|
if (Focus)
|
||||||
{
|
{
|
||||||
|
if (mLastFocusedView != this)
|
||||||
|
{
|
||||||
|
delete mFindWidget;
|
||||||
|
mFindWidget = nullptr;
|
||||||
|
|
||||||
mLastFocusedView = this;
|
mLastFocusedView = this;
|
||||||
|
}
|
||||||
|
|
||||||
emit FocusReceived();
|
emit FocusReceived();
|
||||||
}
|
}
|
||||||
|
@ -465,6 +473,25 @@ void lcView::ShowContextMenu() const
|
||||||
delete Popup;
|
delete Popup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool lcView::CloseFindReplaceDialog()
|
||||||
|
{
|
||||||
|
if (mFindWidget && (mWidget->hasFocus() || mFindWidget->focusWidget()))
|
||||||
|
{
|
||||||
|
delete mFindWidget;
|
||||||
|
mFindWidget = nullptr;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void lcView::ShowFindReplaceWidget(bool Replace)
|
||||||
|
{
|
||||||
|
delete mFindWidget;
|
||||||
|
mFindWidget = new lcFindReplaceWidget(mWidget, GetActiveModel(), Replace);
|
||||||
|
}
|
||||||
|
|
||||||
lcVector3 lcView::GetMoveDirection(const lcVector3& Direction) const
|
lcVector3 lcView::GetMoveDirection(const lcVector3& Direction) const
|
||||||
{
|
{
|
||||||
if (lcGetPreferences().mFixedAxes)
|
if (lcGetPreferences().mFixedAxes)
|
||||||
|
|
|
@ -231,6 +231,8 @@ public:
|
||||||
|
|
||||||
void RemoveCamera();
|
void RemoveCamera();
|
||||||
void ShowContextMenu() const;
|
void ShowContextMenu() const;
|
||||||
|
bool CloseFindReplaceDialog();
|
||||||
|
void ShowFindReplaceWidget(bool Replace);
|
||||||
|
|
||||||
lcVector3 GetMoveDirection(const lcVector3& Direction) const;
|
lcVector3 GetMoveDirection(const lcVector3& Direction) const;
|
||||||
lcMatrix44 GetPieceInsertPosition(bool IgnoreSelected, PieceInfo* Info) const;
|
lcMatrix44 GetPieceInsertPosition(bool IgnoreSelected, PieceInfo* Info) const;
|
||||||
|
@ -324,10 +326,10 @@ protected:
|
||||||
lcVertexBuffer mGridBuffer;
|
lcVertexBuffer mGridBuffer;
|
||||||
int mGridSettings[7];
|
int mGridSettings[7];
|
||||||
|
|
||||||
|
static QWidget* mFindWidget;
|
||||||
static lcView* mLastFocusedView;
|
static lcView* mLastFocusedView;
|
||||||
static std::vector<lcView*> mViews;
|
static std::vector<lcView*> mViews;
|
||||||
|
|
||||||
static lcVertexBuffer mRotateMoveVertexBuffer;
|
static lcVertexBuffer mRotateMoveVertexBuffer;
|
||||||
static lcIndexBuffer mRotateMoveIndexBuffer;
|
static lcIndexBuffer mRotateMoveIndexBuffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -173,6 +173,7 @@ SOURCES += \
|
||||||
common/lc_context.cpp \
|
common/lc_context.cpp \
|
||||||
common/lc_edgecolordialog.cpp \
|
common/lc_edgecolordialog.cpp \
|
||||||
common/lc_file.cpp \
|
common/lc_file.cpp \
|
||||||
|
common/lc_findreplacewidget.cpp \
|
||||||
common/lc_glextensions.cpp \
|
common/lc_glextensions.cpp \
|
||||||
common/lc_http.cpp \
|
common/lc_http.cpp \
|
||||||
common/lc_instructions.cpp \
|
common/lc_instructions.cpp \
|
||||||
|
@ -219,7 +220,6 @@ SOURCES += \
|
||||||
qt/lc_qpropertiestree.cpp \
|
qt/lc_qpropertiestree.cpp \
|
||||||
qt/lc_qcolorpicker.cpp \
|
qt/lc_qcolorpicker.cpp \
|
||||||
qt/lc_qcolorlist.cpp \
|
qt/lc_qcolorlist.cpp \
|
||||||
qt/lc_qfinddialog.cpp \
|
|
||||||
qt/lc_qmodellistdialog.cpp \
|
qt/lc_qmodellistdialog.cpp \
|
||||||
qt/lc_renderdialog.cpp \
|
qt/lc_renderdialog.cpp \
|
||||||
qt/lc_setsdatabasedialog.cpp \
|
qt/lc_setsdatabasedialog.cpp \
|
||||||
|
@ -241,6 +241,7 @@ HEADERS += \
|
||||||
common/lc_context.h \
|
common/lc_context.h \
|
||||||
common/lc_edgecolordialog.h \
|
common/lc_edgecolordialog.h \
|
||||||
common/lc_file.h \
|
common/lc_file.h \
|
||||||
|
common/lc_findreplacewidget.h \
|
||||||
common/lc_glextensions.h \
|
common/lc_glextensions.h \
|
||||||
common/lc_global.h \
|
common/lc_global.h \
|
||||||
common/lc_http.h \
|
common/lc_http.h \
|
||||||
|
@ -287,7 +288,6 @@ HEADERS += \
|
||||||
qt/lc_qpropertiestree.h \
|
qt/lc_qpropertiestree.h \
|
||||||
qt/lc_qcolorpicker.h \
|
qt/lc_qcolorpicker.h \
|
||||||
qt/lc_qcolorlist.h \
|
qt/lc_qcolorlist.h \
|
||||||
qt/lc_qfinddialog.h \
|
|
||||||
qt/lc_qmodellistdialog.h \
|
qt/lc_qmodellistdialog.h \
|
||||||
qt/lc_renderdialog.h \
|
qt/lc_renderdialog.h \
|
||||||
qt/lc_setsdatabasedialog.h \
|
qt/lc_setsdatabasedialog.h \
|
||||||
|
@ -304,7 +304,6 @@ FORMS += \
|
||||||
qt/lc_qcategorydialog.ui \
|
qt/lc_qcategorydialog.ui \
|
||||||
qt/lc_qimagedialog.ui \
|
qt/lc_qimagedialog.ui \
|
||||||
qt/lc_qupdatedialog.ui \
|
qt/lc_qupdatedialog.ui \
|
||||||
qt/lc_qfinddialog.ui \
|
|
||||||
qt/lc_qmodellistdialog.ui \
|
qt/lc_qmodellistdialog.ui \
|
||||||
qt/lc_renderdialog.ui \
|
qt/lc_renderdialog.ui \
|
||||||
qt/lc_setsdatabasedialog.ui \
|
qt/lc_setsdatabasedialog.ui \
|
||||||
|
|
|
@ -1,51 +0,0 @@
|
||||||
#include "lc_global.h"
|
|
||||||
#include "lc_qfinddialog.h"
|
|
||||||
#include "ui_lc_qfinddialog.h"
|
|
||||||
#include "lc_mainwindow.h"
|
|
||||||
#include "pieceinf.h"
|
|
||||||
#include "lc_colors.h"
|
|
||||||
#include "lc_model.h"
|
|
||||||
|
|
||||||
lcQFindDialog::lcQFindDialog(QWidget* Parent, lcSearchOptions* SearchOptions, lcModel* Model)
|
|
||||||
: QDialog(Parent), ui(new Ui::lcQFindDialog)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
|
|
||||||
QComboBox *parts = ui->ID;
|
|
||||||
parts->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon);
|
|
||||||
parts->setMinimumContentsLength(1);
|
|
||||||
|
|
||||||
lcPartsList PartsList;
|
|
||||||
Model->GetPartsList(gDefaultColor, false, true, PartsList);
|
|
||||||
|
|
||||||
for (const auto& PartIt : PartsList)
|
|
||||||
parts->addItem(PartIt.first->m_strDescription, QVariant::fromValue((void*)PartIt.first));
|
|
||||||
parts->model()->sort(0);
|
|
||||||
|
|
||||||
mSearchOptions = SearchOptions;
|
|
||||||
|
|
||||||
ui->findColor->setChecked(mSearchOptions->MatchColor);
|
|
||||||
ui->color->setCurrentColor(mSearchOptions->ColorIndex);
|
|
||||||
ui->findID->setChecked(mSearchOptions->MatchInfo);
|
|
||||||
parts->setCurrentIndex(parts->findData(QVariant::fromValue((void*)mSearchOptions->Info)));
|
|
||||||
ui->findName->setChecked(mSearchOptions->MatchName);
|
|
||||||
ui->name->setText(mSearchOptions->Name);
|
|
||||||
}
|
|
||||||
|
|
||||||
lcQFindDialog::~lcQFindDialog()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void lcQFindDialog::accept()
|
|
||||||
{
|
|
||||||
mSearchOptions->MatchColor = ui->findColor->isChecked();
|
|
||||||
mSearchOptions->ColorIndex = ui->color->currentColor();
|
|
||||||
mSearchOptions->MatchInfo= ui->findID->isChecked();
|
|
||||||
mSearchOptions->Info = (PieceInfo*)ui->ID->itemData(ui->ID->currentIndex()).value<void*>();
|
|
||||||
mSearchOptions->MatchName = ui->findName->isChecked();
|
|
||||||
QString name = ui->name->text();
|
|
||||||
strcpy(mSearchOptions->Name, name.toLocal8Bit().data());
|
|
||||||
|
|
||||||
QDialog::accept();
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
struct lcSearchOptions;
|
|
||||||
|
|
||||||
namespace Ui {
|
|
||||||
class lcQFindDialog;
|
|
||||||
}
|
|
||||||
|
|
||||||
class lcQFindDialog : public QDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
lcQFindDialog(QWidget* Parent, lcSearchOptions* SearchOptions, lcModel* Model);
|
|
||||||
~lcQFindDialog();
|
|
||||||
|
|
||||||
lcSearchOptions* mSearchOptions;
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void accept() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::lcQFindDialog *ui;
|
|
||||||
};
|
|
||||||
|
|
|
@ -1,126 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>lcQFindDialog</class>
|
|
||||||
<widget class="QDialog" name="lcQFindDialog">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>325</width>
|
|
||||||
<height>125</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Find</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="QComboBox" name="ID"/>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="1">
|
|
||||||
<widget class="QLineEdit" name="name"/>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0">
|
|
||||||
<widget class="QCheckBox" name="findName">
|
|
||||||
<property name="text">
|
|
||||||
<string>Name</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QCheckBox" name="findID">
|
|
||||||
<property name="text">
|
|
||||||
<string>Part ID</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QCheckBox" name="findColor">
|
|
||||||
<property name="text">
|
|
||||||
<string>Color</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="lcQColorPicker" name="color">
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="standardButtons">
|
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<customwidgets>
|
|
||||||
<customwidget>
|
|
||||||
<class>lcQColorPicker</class>
|
|
||||||
<extends>QToolButton</extends>
|
|
||||||
<header>lc_qcolorpicker.h</header>
|
|
||||||
</customwidget>
|
|
||||||
</customwidgets>
|
|
||||||
<resources/>
|
|
||||||
<connections>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>accepted()</signal>
|
|
||||||
<receiver>lcQFindDialog</receiver>
|
|
||||||
<slot>accept()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>248</x>
|
|
||||||
<y>254</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>157</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>rejected()</signal>
|
|
||||||
<receiver>lcQFindDialog</receiver>
|
|
||||||
<slot>reject()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>316</x>
|
|
||||||
<y>260</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>286</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
|
Loading…
Reference in a new issue