From b74eb3a81e6d38cb33d8885969a5ff2e1851ca81 Mon Sep 17 00:00:00 2001 From: Leonardo Zide Date: Sat, 30 Jan 2021 15:37:17 -0800 Subject: [PATCH] New find/replace widget. --- common/lc_commands.cpp | 22 ++++- common/lc_commands.h | 2 + common/lc_findreplacewidget.cpp | 158 ++++++++++++++++++++++++++++++++ common/lc_findreplacewidget.h | 9 ++ common/lc_mainwindow.cpp | 50 +++++----- common/lc_mainwindow.h | 8 +- common/lc_model.cpp | 56 +++++++---- common/lc_model.h | 2 +- common/lc_view.cpp | 29 +++++- common/lc_view.h | 4 +- leocad.pro | 5 +- qt/lc_qfinddialog.cpp | 51 ----------- qt/lc_qfinddialog.h | 26 ------ qt/lc_qfinddialog.ui | 126 ------------------------- 14 files changed, 288 insertions(+), 260 deletions(-) create mode 100644 common/lc_findreplacewidget.cpp create mode 100644 common/lc_findreplacewidget.h delete mode 100644 qt/lc_qfinddialog.cpp delete mode 100644 qt/lc_qfinddialog.h delete mode 100644 qt/lc_qfinddialog.ui diff --git a/common/lc_commands.cpp b/common/lc_commands.cpp index 612ac6d9..88d4fc75 100644 --- a/common/lc_commands.cpp +++ b/common/lc_commands.cpp @@ -209,24 +209,38 @@ const lcCommand gCommands[] = // LC_EDIT_FIND { QT_TRANSLATE_NOOP("Action", "Edit.Find"), - QT_TRANSLATE_NOOP("Menu", "&Find..."), - QT_TRANSLATE_NOOP("Status", "Find object"), + QT_TRANSLATE_NOOP("Menu", "&Find"), + QT_TRANSLATE_NOOP("Status", "Find piece"), "Ctrl+F" }, // LC_EDIT_FIND_NEXT { QT_TRANSLATE_NOOP("Action", "Edit.FindNext"), QT_TRANSLATE_NOOP("Menu", "Find Ne&xt"), - QT_TRANSLATE_NOOP("Status", "Find next object"), + QT_TRANSLATE_NOOP("Status", "Find next piece"), "F3" }, // LC_EDIT_FIND_PREVIOUS { QT_TRANSLATE_NOOP("Action", "Edit.FindPrevious"), QT_TRANSLATE_NOOP("Menu", "Find Pre&vious"), - QT_TRANSLATE_NOOP("Status", "Find object"), + QT_TRANSLATE_NOOP("Status", "Find previous piece"), "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 { QT_TRANSLATE_NOOP("Action", "Edit.SelectAll"), diff --git a/common/lc_commands.h b/common/lc_commands.h index 2933df78..3601f31c 100644 --- a/common/lc_commands.h +++ b/common/lc_commands.h @@ -36,6 +36,8 @@ enum lcCommandId LC_EDIT_FIND, LC_EDIT_FIND_NEXT, LC_EDIT_FIND_PREVIOUS, + LC_EDIT_REPLACE, + LC_EDIT_REPLACE_NEXT, LC_EDIT_SELECT_ALL, LC_EDIT_SELECT_NONE, LC_EDIT_SELECT_INVERT, diff --git a/common/lc_findreplacewidget.cpp b/common/lc_findreplacewidget.cpp new file mode 100644 index 00000000..9a228efd --- /dev/null +++ b/common/lc_findreplacewidget.cpp @@ -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(&QComboBox::currentIndexChanged), [FindPartComboBox](int Index) + { + gMainWindow->mSearchOptions.Info = (PieceInfo*)FindPartComboBox->itemData(Index).value(); + }); + + 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(&QComboBox::currentIndexChanged), [ReplacePartComboBox](int Index) + { + gMainWindow->mSearchOptions.ReplacePieceInfo = (PieceInfo*)ReplacePartComboBox->itemData(Index).value(); + }); + + ReplacePartComboBox->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon); + ReplacePartComboBox->setMinimumContentsLength(1); + + lcPiecesLibrary* Library = lcGetPiecesLibrary(); + std::vector 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(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(); +} diff --git a/common/lc_findreplacewidget.h b/common/lc_findreplacewidget.h new file mode 100644 index 00000000..013a2341 --- /dev/null +++ b/common/lc_findreplacewidget.h @@ -0,0 +1,9 @@ +#pragma once + +class lcFindReplaceWidget : public QWidget +{ + Q_OBJECT + +public: + lcFindReplaceWidget(QWidget* Parent, lcModel* Model, bool Replace); +}; diff --git a/common/lc_mainwindow.cpp b/common/lc_mainwindow.cpp index b04cc006..9b59cb44 100644 --- a/common/lc_mainwindow.cpp +++ b/common/lc_mainwindow.cpp @@ -8,7 +8,6 @@ #include "lc_qcolorlist.h" #include "lc_qpropertiestree.h" #include "lc_qutils.h" -#include "lc_qfinddialog.h" #include "lc_qupdatedialog.h" #include "lc_qaboutdialog.h" #include "lc_setsdatabasedialog.h" @@ -24,7 +23,6 @@ #include "pieceinf.h" #include "lc_library.h" #include "lc_colors.h" - #include "lc_previewwidget.h" #if LC_ENABLE_GAMEPAD @@ -493,9 +491,10 @@ void lcMainWindow::CreateMenus() EditMenu->addAction(mActions[LC_EDIT_PASTE]); EditMenu->addSeparator(); EditMenu->addAction(mActions[LC_EDIT_FIND]); - EditMenu->addAction(mActions[LC_EDIT_FIND_NEXT]); EditMenu->addAction(mActions[LC_EDIT_FIND_PREVIOUS]); + EditMenu->addAction(mActions[LC_EDIT_REPLACE]); + EditMenu->addAction(mActions[LC_EDIT_REPLACE_NEXT]); EditMenu->addSeparator(); EditMenu->addAction(mActions[LC_EDIT_SELECT_ALL]); EditMenu->addAction(mActions[LC_EDIT_SELECT_NONE]); @@ -1268,22 +1267,6 @@ void lcMainWindow::Print(QPrinter* Printer) #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() { lcQUpdateDialog Dialog(this, false); @@ -1634,12 +1617,12 @@ void lcMainWindow::SetCurrentModelTab(lcModel* Model) TabWidget = new lcModelTabWidget(Model); mModelTabWidget->addTab(TabWidget, Model->GetProperties().mFileName); - QGridLayout* CentralLayout = new QGridLayout(TabWidget); + QVBoxLayout* CentralLayout = new QVBoxLayout(TabWidget); CentralLayout->setContentsMargins(0, 0, 0, 0); NewView = CreateView(Model); ViewWidget = new lcViewWidget(TabWidget, NewView); - CentralLayout->addWidget(ViewWidget, 0, 0, 1, 1); + CentralLayout->addWidget(ViewWidget); mModelTabWidget->setCurrentWidget(TabWidget); } @@ -1703,9 +1686,13 @@ void lcMainWindow::RemoveView(lcView* View) void lcMainWindow::SetActiveView(lcView* ActiveView) { lcModelTabWidget* TabWidget = GetTabForView(ActiveView); + + if (!TabWidget) + return; + lcView* CurrentActiveView = TabWidget->GetActiveView(); - if (!TabWidget || CurrentActiveView == ActiveView) + if (CurrentActiveView == ActiveView) return; if (CurrentActiveView) @@ -2726,17 +2713,28 @@ void lcMainWindow::HandleCommand(lcCommandId CommandId) break; case LC_EDIT_FIND: - ShowSearchDialog(); + if (ActiveView) + ActiveView->ShowFindReplaceWidget(false); break; case LC_EDIT_FIND_NEXT: if (ActiveModel) - ActiveModel->FindPiece(false, true); + ActiveModel->FindReplacePiece(true); break; case LC_EDIT_FIND_PREVIOUS: 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; case LC_EDIT_SELECT_ALL: @@ -3448,7 +3446,7 @@ void lcMainWindow::HandleCommand(lcCommandId CommandId) break; case LC_EDIT_CANCEL: - if (ActiveView) + if (ActiveView && !ActiveView->CloseFindReplaceDialog()) ActiveView->CancelTrackingOrClearSelection(); break; diff --git a/common/lc_mainwindow.h b/common/lc_mainwindow.h index 490f2897..b59fe0be 100644 --- a/common/lc_mainwindow.h +++ b/common/lc_mainwindow.h @@ -25,10 +25,13 @@ struct lcSearchOptions bool SearchValid; bool MatchInfo; bool MatchColor; - bool MatchName; + bool ReplaceInfo; + bool ReplaceColor; + PieceInfo* Info; int ColorIndex; - char Name[256]; + PieceInfo* ReplacePieceInfo; + int ReplaceColorIndex; }; class lcTabBar : public QTabBar @@ -375,7 +378,6 @@ protected: void SetActiveView(lcView* ActiveView); void ToggleDockWidget(QWidget* DockWidget); void SplitView(Qt::Orientation Orientation); - void ShowSearchDialog(); void ShowUpdatesDialog(); void ShowAboutDialog(); void ShowHTMLDialog(); diff --git a/common/lc_model.cpp b/common/lc_model.cpp index 50e860a1..22ba72cc 100644 --- a/common/lc_model.cpp +++ b/common/lc_model.cpp @@ -3779,29 +3779,51 @@ void lcModel::UnhideAllPieces() SaveCheckpoint(tr("Unhide")); } -void lcModel::FindPiece(bool FindFirst, bool SearchForward) +void lcModel::FindReplacePiece(bool SearchForward) { if (mPieces.IsEmpty()) return; - int StartIdx = mPieces.GetSize() - 1; - if (!FindFirst) - { - for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++) - { - lcPiece* Piece = mPieces[PieceIdx]; + const lcSearchOptions& SearchOptions = gMainWindow->mSearchOptions; - if (Piece->IsFocused() && Piece->IsVisible(mCurrentStep)) + 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++) + { + lcPiece* Piece = mPieces[PieceIdx]; + + if (Piece->IsFocused() && Piece->IsVisible(mCurrentStep)) + { + if (PieceMatches(Piece)) { - StartIdx = PieceIdx; - break; + 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; + break; } } int CurrentIdx = StartIdx; - lcObject* Focus = nullptr; - const lcSearchOptions& SearchOptions = gMainWindow->mSearchOptions; + lcPiece* Focus = nullptr; for (;;) { @@ -3815,21 +3837,19 @@ void lcModel::FindPiece(bool FindFirst, bool SearchForward) else if (CurrentIdx >= mPieces.GetSize()) CurrentIdx = 0; - if (CurrentIdx == StartIdx) - break; - lcPiece* Current = mPieces[CurrentIdx]; if (!Current->IsVisible(mCurrentStep)) continue; - if ((!SearchOptions.MatchInfo || Current->mPieceInfo == SearchOptions.Info) && - (!SearchOptions.MatchColor || Current->GetColorIndex() == SearchOptions.ColorIndex) && - (!SearchOptions.MatchName || (Current->GetName().indexOf(SearchOptions.Name, 0, Qt::CaseInsensitive) != -1))) + if (PieceMatches(Current)) { Focus = Current; break; } + + if (CurrentIdx == StartIdx) + break; } ClearSelectionAndSetFocus(Focus, LC_PIECE_SECTION_POSITION, false); diff --git a/common/lc_model.h b/common/lc_model.h index d65549cc..416ca902 100644 --- a/common/lc_model.h +++ b/common/lc_model.h @@ -281,7 +281,7 @@ public: void UnhideSelectedPieces(); void UnhideAllPieces(); - void FindPiece(bool FindFirst, bool SearchForward); + void FindReplacePiece(bool SearchForward); void UndoAction(); void RedoAction(); diff --git a/common/lc_view.cpp b/common/lc_view.cpp index f09416af..02bb2649 100644 --- a/common/lc_view.cpp +++ b/common/lc_view.cpp @@ -12,7 +12,9 @@ #include "lc_scene.h" #include "lc_context.h" #include "lc_viewsphere.h" +#include "lc_findreplacewidget.h" +QWidget* lcView::mFindWidget; lcView* lcView::mLastFocusedView; std::vector lcView::mViews; @@ -95,7 +97,13 @@ void lcView::SetFocus(bool Focus) { if (Focus) { - mLastFocusedView = this; + if (mLastFocusedView != this) + { + delete mFindWidget; + mFindWidget = nullptr; + + mLastFocusedView = this; + } emit FocusReceived(); } @@ -465,6 +473,25 @@ void lcView::ShowContextMenu() const 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 { if (lcGetPreferences().mFixedAxes) diff --git a/common/lc_view.h b/common/lc_view.h index 6f98207d..667f256f 100644 --- a/common/lc_view.h +++ b/common/lc_view.h @@ -231,6 +231,8 @@ public: void RemoveCamera(); void ShowContextMenu() const; + bool CloseFindReplaceDialog(); + void ShowFindReplaceWidget(bool Replace); lcVector3 GetMoveDirection(const lcVector3& Direction) const; lcMatrix44 GetPieceInsertPosition(bool IgnoreSelected, PieceInfo* Info) const; @@ -324,10 +326,10 @@ protected: lcVertexBuffer mGridBuffer; int mGridSettings[7]; + static QWidget* mFindWidget; static lcView* mLastFocusedView; static std::vector mViews; static lcVertexBuffer mRotateMoveVertexBuffer; static lcIndexBuffer mRotateMoveIndexBuffer; }; - diff --git a/leocad.pro b/leocad.pro index 3aefb8c0..2620237e 100644 --- a/leocad.pro +++ b/leocad.pro @@ -173,6 +173,7 @@ SOURCES += \ common/lc_context.cpp \ common/lc_edgecolordialog.cpp \ common/lc_file.cpp \ + common/lc_findreplacewidget.cpp \ common/lc_glextensions.cpp \ common/lc_http.cpp \ common/lc_instructions.cpp \ @@ -219,7 +220,6 @@ SOURCES += \ qt/lc_qpropertiestree.cpp \ qt/lc_qcolorpicker.cpp \ qt/lc_qcolorlist.cpp \ - qt/lc_qfinddialog.cpp \ qt/lc_qmodellistdialog.cpp \ qt/lc_renderdialog.cpp \ qt/lc_setsdatabasedialog.cpp \ @@ -241,6 +241,7 @@ HEADERS += \ common/lc_context.h \ common/lc_edgecolordialog.h \ common/lc_file.h \ + common/lc_findreplacewidget.h \ common/lc_glextensions.h \ common/lc_global.h \ common/lc_http.h \ @@ -287,7 +288,6 @@ HEADERS += \ qt/lc_qpropertiestree.h \ qt/lc_qcolorpicker.h \ qt/lc_qcolorlist.h \ - qt/lc_qfinddialog.h \ qt/lc_qmodellistdialog.h \ qt/lc_renderdialog.h \ qt/lc_setsdatabasedialog.h \ @@ -304,7 +304,6 @@ FORMS += \ qt/lc_qcategorydialog.ui \ qt/lc_qimagedialog.ui \ qt/lc_qupdatedialog.ui \ - qt/lc_qfinddialog.ui \ qt/lc_qmodellistdialog.ui \ qt/lc_renderdialog.ui \ qt/lc_setsdatabasedialog.ui \ diff --git a/qt/lc_qfinddialog.cpp b/qt/lc_qfinddialog.cpp deleted file mode 100644 index 21f54cdb..00000000 --- a/qt/lc_qfinddialog.cpp +++ /dev/null @@ -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(); - mSearchOptions->MatchName = ui->findName->isChecked(); - QString name = ui->name->text(); - strcpy(mSearchOptions->Name, name.toLocal8Bit().data()); - - QDialog::accept(); -} diff --git a/qt/lc_qfinddialog.h b/qt/lc_qfinddialog.h deleted file mode 100644 index 1d9317a7..00000000 --- a/qt/lc_qfinddialog.h +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once - -#include -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; -}; - diff --git a/qt/lc_qfinddialog.ui b/qt/lc_qfinddialog.ui deleted file mode 100644 index c6c5c3ea..00000000 --- a/qt/lc_qfinddialog.ui +++ /dev/null @@ -1,126 +0,0 @@ - - - lcQFindDialog - - - - 0 - 0 - 325 - 125 - - - - Find - - - - - - - - - - - - - - Name - - - - - - - Part ID - - - - - - - Color - - - - - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - lcQColorPicker - QToolButton -
lc_qcolorpicker.h
-
-
- - - - buttonBox - accepted() - lcQFindDialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - lcQFindDialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - -