Improve for a search bar.

This commit is contained in:
Roman Telezhynskyi 2021-11-22 15:24:48 +02:00
parent 8b966019e6
commit b8b3acbfd3
23 changed files with 2663 additions and 241 deletions

View File

@ -23,6 +23,7 @@
- Remove tool from all visibility groups it in. - Remove tool from all visibility groups it in.
- Option to disable the automatic search for updates. - Option to disable the automatic search for updates.
- [smart-pattern/valentina#153] To add text search bar in History window. - [smart-pattern/valentina#153] To add text search bar in History window.
- Improve for a search bar.
# Valentina 0.7.49 July 1, 2021 # Valentina 0.7.49 July 1, 2021
- Fix crash. - Fix crash.

View File

@ -108,13 +108,13 @@ TMainWindow::TMainWindow(QWidget *parent)
: VAbstractMainWindow(parent), : VAbstractMainWindow(parent),
ui(new Ui::TMainWindow), ui(new Ui::TMainWindow),
formulaBaseHeight(0), formulaBaseHeight(0),
gradation(new QTimer(this)) gradation(new QTimer(this)),
m_searchHistory(new QMenu(this))
{ {
ui->setupUi(this); ui->setupUi(this);
VAbstractApplication::VApp()->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); VAbstractApplication::VApp()->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
ui->lineEditFind->setClearButtonEnabled(true);
ui->lineEditName->setClearButtonEnabled(true); ui->lineEditName->setClearButtonEnabled(true);
ui->lineEditFullName->setClearButtonEnabled(true); ui->lineEditFullName->setClearButtonEnabled(true);
ui->lineEditCustomerName->setClearButtonEnabled(true); ui->lineEditCustomerName->setClearButtonEnabled(true);
@ -123,7 +123,7 @@ TMainWindow::TMainWindow(QWidget *parent)
ui->lineEditFind->installEventFilter(this); ui->lineEditFind->installEventFilter(this);
ui->plainTextEditFormula->installEventFilter(this); ui->plainTextEditFormula->installEventFilter(this);
search = QSharedPointer<VTableSearch>(new VTableSearch(ui->tableWidget)); m_search = QSharedPointer<VTableSearch>(new VTableSearch(ui->tableWidget));
ui->tabWidget->setVisible(false); ui->tabWidget->setVisible(false);
ui->mainToolBar->setContextMenuPolicy(Qt::PreventContextMenu); ui->mainToolBar->setContextMenuPolicy(Qt::PreventContextMenu);
@ -159,6 +159,7 @@ TMainWindow::TMainWindow(QWidget *parent)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
TMainWindow::~TMainWindow() TMainWindow::~TMainWindow()
{ {
ui->lineEditFind->blockSignals(true); // prevents crash
delete data; delete data;
delete m; delete m;
qDeleteAll(hackedWidgets); qDeleteAll(hackedWidgets);
@ -179,7 +180,7 @@ void TMainWindow::RetranslateTable()
const int row = ui->tableWidget->currentRow(); const int row = ui->tableWidget->currentRow();
RefreshTable(); RefreshTable();
ui->tableWidget->selectRow(row); ui->tableWidget->selectRow(row);
search->RefreshList(ui->lineEditFind->text()); m_search->RefreshList(ui->lineEditFind->text());
} }
} }
@ -600,6 +601,9 @@ void TMainWindow::changeEvent(QEvent *event)
// retranslate designer form (single inheritance approach) // retranslate designer form (single inheritance approach)
ui->retranslateUi(this); ui->retranslateUi(this);
ui->lineEditFind->setPlaceholderText(m_search->SearchPlaceholder());
UpdateSearchControlsTooltips();
UpdateWindowTitle(); UpdateWindowTitle();
InitMeasurementUnits(); InitMeasurementUnits();
@ -1158,9 +1162,9 @@ void TMainWindow::Remove()
MeasurementsWereSaved(false); MeasurementsWereSaved(false);
search->RemoveRow(row); m_search->RemoveRow(row);
RefreshData(); RefreshData();
search->RefreshList(ui->lineEditFind->text()); m_search->RefreshList(ui->lineEditFind->text());
if (ui->tableWidget->rowCount() > 0) if (ui->tableWidget->rowCount() > 0)
{ {
@ -1240,7 +1244,7 @@ void TMainWindow::MoveTop()
m->MoveTop(nameField->data(Qt::UserRole).toString()); m->MoveTop(nameField->data(Qt::UserRole).toString());
MeasurementsWereSaved(false); MeasurementsWereSaved(false);
RefreshData(); RefreshData();
search->RefreshList(ui->lineEditFind->text()); m_search->RefreshList(ui->lineEditFind->text());
ui->tableWidget->selectRow(0); ui->tableWidget->selectRow(0);
ui->tableWidget->repaint(); // Force repain to fix paint artifacts on Mac OS X ui->tableWidget->repaint(); // Force repain to fix paint artifacts on Mac OS X
} }
@ -1259,7 +1263,7 @@ void TMainWindow::MoveUp()
m->MoveUp(nameField->data(Qt::UserRole).toString()); m->MoveUp(nameField->data(Qt::UserRole).toString());
MeasurementsWereSaved(false); MeasurementsWereSaved(false);
RefreshData(); RefreshData();
search->RefreshList(ui->lineEditFind->text()); m_search->RefreshList(ui->lineEditFind->text());
ui->tableWidget->selectRow(row-1); ui->tableWidget->selectRow(row-1);
ui->tableWidget->repaint(); // Force repain to fix paint artifacts on Mac OS X ui->tableWidget->repaint(); // Force repain to fix paint artifacts on Mac OS X
} }
@ -1278,7 +1282,7 @@ void TMainWindow::MoveDown()
m->MoveDown(nameField->data(Qt::UserRole).toString()); m->MoveDown(nameField->data(Qt::UserRole).toString());
MeasurementsWereSaved(false); MeasurementsWereSaved(false);
RefreshData(); RefreshData();
search->RefreshList(ui->lineEditFind->text()); m_search->RefreshList(ui->lineEditFind->text());
ui->tableWidget->selectRow(row+1); ui->tableWidget->selectRow(row+1);
ui->tableWidget->repaint(); // Force repain to fix paint artifacts on Mac OS X ui->tableWidget->repaint(); // Force repain to fix paint artifacts on Mac OS X
} }
@ -1297,7 +1301,7 @@ void TMainWindow::MoveBottom()
m->MoveBottom(nameField->data(Qt::UserRole).toString()); m->MoveBottom(nameField->data(Qt::UserRole).toString());
MeasurementsWereSaved(false); MeasurementsWereSaved(false);
RefreshData(); RefreshData();
search->RefreshList(ui->lineEditFind->text()); m_search->RefreshList(ui->lineEditFind->text());
ui->tableWidget->selectRow(ui->tableWidget->rowCount()-1); ui->tableWidget->selectRow(ui->tableWidget->rowCount()-1);
ui->tableWidget->repaint(); // Force repain to fix paint artifacts on Mac OS X ui->tableWidget->repaint(); // Force repain to fix paint artifacts on Mac OS X
} }
@ -1348,7 +1352,7 @@ void TMainWindow::Fx()
RefreshData(); RefreshData();
search->RefreshList(ui->lineEditFind->text()); m_search->RefreshList(ui->lineEditFind->text());
ui->tableWidget->selectRow(row); ui->tableWidget->selectRow(row);
} }
@ -1373,9 +1377,9 @@ void TMainWindow::AddCustom()
m->AddEmptyAfter(nameField->data(Qt::UserRole).toString(), name); m->AddEmptyAfter(nameField->data(Qt::UserRole).toString(), name);
} }
search->AddRow(currentRow); m_search->AddRow(currentRow);
RefreshData(); RefreshData();
search->RefreshList(ui->lineEditFind->text()); m_search->RefreshList(ui->lineEditFind->text());
ui->tableWidget->selectRow(currentRow); ui->tableWidget->selectRow(currentRow);
@ -1408,7 +1412,7 @@ void TMainWindow::AddKnown()
m->AddEmpty(name); m->AddEmpty(name);
} }
search->AddRow(currentRow); m_search->AddRow(currentRow);
} }
} }
else else
@ -1426,13 +1430,13 @@ void TMainWindow::AddKnown()
{ {
m->AddEmptyAfter(after, name); m->AddEmptyAfter(after, name);
} }
search->AddRow(currentRow); m_search->AddRow(currentRow);
after = name; after = name;
} }
} }
RefreshData(); RefreshData();
search->RefreshList(ui->lineEditFind->text()); m_search->RefreshList(ui->lineEditFind->text());
ui->tableWidget->selectRow(currentRow); ui->tableWidget->selectRow(currentRow);
@ -1510,7 +1514,7 @@ void TMainWindow::ImportFromPattern()
RefreshData(); RefreshData();
search->RefreshList(ui->lineEditFind->text()); m_search->RefreshList(ui->lineEditFind->text());
ui->tableWidget->selectRow(currentRow); ui->tableWidget->selectRow(currentRow);
@ -1567,7 +1571,7 @@ void TMainWindow::GradationChanged()
gradation->stop(); gradation->stop();
const int row = ui->tableWidget->currentRow(); const int row = ui->tableWidget->currentRow();
RefreshData(); RefreshData();
search->RefreshList(ui->lineEditFind->text()); m_search->RefreshList(ui->lineEditFind->text());
ui->tableWidget->selectRow(row); ui->tableWidget->selectRow(row);
} }
@ -1810,7 +1814,7 @@ void TMainWindow::SaveMName(const QString &text)
m->SetMName(nameField->text(), newName); m->SetMName(nameField->text(), newName);
MeasurementsWereSaved(false); MeasurementsWereSaved(false);
RefreshData(); RefreshData();
search->RefreshList(ui->lineEditFind->text()); m_search->RefreshList(ui->lineEditFind->text());
ui->tableWidget->blockSignals(true); ui->tableWidget->blockSignals(true);
ui->tableWidget->selectRow(row); ui->tableWidget->selectRow(row);
@ -1888,7 +1892,7 @@ void TMainWindow::SaveMValue()
const QTextCursor cursor = ui->plainTextEditFormula->textCursor(); const QTextCursor cursor = ui->plainTextEditFormula->textCursor();
RefreshData(); RefreshData();
search->RefreshList(ui->lineEditFind->text()); m_search->RefreshList(ui->lineEditFind->text());
ui->tableWidget->blockSignals(true); ui->tableWidget->blockSignals(true);
ui->tableWidget->selectRow(row); ui->tableWidget->selectRow(row);
@ -1913,7 +1917,7 @@ void TMainWindow::SaveMBaseValue(double value)
MeasurementsWereSaved(false); MeasurementsWereSaved(false);
RefreshData(); RefreshData();
search->RefreshList(ui->lineEditFind->text()); m_search->RefreshList(ui->lineEditFind->text());
ui->tableWidget->blockSignals(true); ui->tableWidget->blockSignals(true);
ui->tableWidget->selectRow(row); ui->tableWidget->selectRow(row);
@ -1938,7 +1942,7 @@ void TMainWindow::SaveMShiftA(double value)
MeasurementsWereSaved(false); MeasurementsWereSaved(false);
RefreshData(); RefreshData();
search->RefreshList(ui->lineEditFind->text()); m_search->RefreshList(ui->lineEditFind->text());
ui->tableWidget->blockSignals(true); ui->tableWidget->blockSignals(true);
ui->tableWidget->selectRow(row); ui->tableWidget->selectRow(row);
@ -1963,7 +1967,7 @@ void TMainWindow::SaveMShiftB(double value)
MeasurementsWereSaved(false); MeasurementsWereSaved(false);
RefreshData(); RefreshData();
search->RefreshList(ui->lineEditFind->text()); m_search->RefreshList(ui->lineEditFind->text());
ui->tableWidget->blockSignals(true); ui->tableWidget->blockSignals(true);
ui->tableWidget->selectRow(row); ui->tableWidget->selectRow(row);
@ -1988,7 +1992,7 @@ void TMainWindow::SaveMShiftC(double value)
MeasurementsWereSaved(false); MeasurementsWereSaved(false);
RefreshData(); RefreshData();
search->RefreshList(ui->lineEditFind->text()); m_search->RefreshList(ui->lineEditFind->text());
ui->tableWidget->blockSignals(true); ui->tableWidget->blockSignals(true);
ui->tableWidget->selectRow(row); ui->tableWidget->selectRow(row);
@ -2014,7 +2018,7 @@ void TMainWindow::SaveMCorrectionValue(double value)
MeasurementsWereSaved(false); MeasurementsWereSaved(false);
RefreshData(); RefreshData();
search->RefreshList(ui->lineEditFind->text()); m_search->RefreshList(ui->lineEditFind->text());
ui->tableWidget->blockSignals(true); ui->tableWidget->blockSignals(true);
ui->tableWidget->selectRow(row); ui->tableWidget->selectRow(row);
@ -2112,7 +2116,7 @@ void TMainWindow::SaveMUnits()
MeasurementsWereSaved(false); MeasurementsWereSaved(false);
RefreshData(); RefreshData();
search->RefreshList(ui->lineEditFind->text()); m_search->RefreshList(ui->lineEditFind->text());
ui->tableWidget->blockSignals(true); ui->tableWidget->blockSignals(true);
ui->tableWidget->selectRow(row); ui->tableWidget->selectRow(row);
@ -2138,7 +2142,7 @@ void TMainWindow::SaveMDimension()
MeasurementsWereSaved(false); MeasurementsWereSaved(false);
RefreshData(); RefreshData();
search->RefreshList(ui->lineEditFind->text()); m_search->RefreshList(ui->lineEditFind->text());
ui->tableWidget->blockSignals(true); ui->tableWidget->blockSignals(true);
ui->tableWidget->selectRow(row); ui->tableWidget->selectRow(row);
@ -2553,18 +2557,7 @@ void TMainWindow::InitWindow()
connect(ui->comboBoxPMSystem, QOverload<int>::of(&QComboBox::currentIndexChanged), this, connect(ui->comboBoxPMSystem, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&TMainWindow::SavePMSystem); &TMainWindow::SavePMSystem);
connect(ui->lineEditFind, &QLineEdit::textChanged, this, [this] (const QString &term){search->Find(term);}); InitSearch();
connect(ui->toolButtonFindPrevious, &QToolButton::clicked, this, [this] (){search->FindPrevious();});
connect(ui->toolButtonFindNext, &QToolButton::clicked, this, [this] (){search->FindNext();});
connect(search.data(), &VTableSearch::HasResult, this, [this] (bool state)
{
ui->toolButtonFindPrevious->setEnabled(state);
});
connect(search.data(), &VTableSearch::HasResult, this, [this] (bool state)
{
ui->toolButtonFindNext->setEnabled(state);
});
ui->plainTextEditNotes->setPlainText(m->Notes()); ui->plainTextEditNotes->setPlainText(m->Notes());
connect(ui->plainTextEditNotes, &QPlainTextEdit::textChanged, this, &TMainWindow::SaveNotes); connect(ui->plainTextEditNotes, &QPlainTextEdit::textChanged, this, &TMainWindow::SaveNotes);
@ -3473,6 +3466,11 @@ void TMainWindow::WriteSettings()
settings->SetWindowState(saveState()); settings->SetWindowState(saveState());
settings->SetToolbarsState(saveState(AppVersion())); settings->SetToolbarsState(saveState(AppVersion()));
settings->SetTapeSearchOptionMatchCase(m_search->IsMatchCase());
settings->SetTapeSearchOptionWholeWord(m_search->IsMatchWord());
settings->SetTapeSearchOptionRegexp(m_search->IsMatchRegexp());
settings->SetTapeSearchOptionUseUnicodeProperties(m_search->IsUseUnicodePreperties());
settings->sync(); settings->sync();
if (settings->status() == QSettings::AccessError) if (settings->status() == QSettings::AccessError)
{ {
@ -3498,7 +3496,7 @@ void TMainWindow::UpdatePatternUnit()
RefreshTable(); RefreshTable();
search->RefreshList(ui->lineEditFind->text()); m_search->RefreshList(ui->lineEditFind->text());
ui->tableWidget->selectRow(row); ui->tableWidget->selectRow(row);
} }
@ -3763,9 +3761,9 @@ void TMainWindow::ShowError(const QString &text)
void TMainWindow::RefreshDataAfterImport() void TMainWindow::RefreshDataAfterImport()
{ {
const int currentRow = ui->tableWidget->currentRow(); const int currentRow = ui->tableWidget->currentRow();
search->AddRow(currentRow); m_search->AddRow(currentRow);
RefreshData(); RefreshData();
search->RefreshList(ui->lineEditFind->text()); m_search->RefreshList(ui->lineEditFind->text());
ui->tableWidget->selectRow(currentRow); ui->tableWidget->selectRow(currentRow);
ui->actionExportToCSV->setEnabled(true); ui->actionExportToCSV->setEnabled(true);
@ -4356,6 +4354,182 @@ void TMainWindow::InitMeasurementDimension()
ui->comboBoxDimension->blockSignals(false); ui->comboBoxDimension->blockSignals(false);
} }
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::InitSearch()
{
VTapeSettings *settings = MApplication::VApp()->TapeSettings();
m_search->SetUseUnicodePreperties(settings->GetTapeSearchOptionUseUnicodeProperties());
m_search->SetMatchWord(settings->GetTapeSearchOptionWholeWord());
m_search->SetMatchRegexp(settings->GetTapeSearchOptionRegexp());
m_search->SetMatchCase(settings->GetTapeSearchOptionMatchCase());
ui->lineEditFind->setPlaceholderText(m_search->SearchPlaceholder());
UpdateSearchControlsTooltips();
connect(ui->lineEditFind, &QLineEdit::textChanged, this, [this] (const QString &term){m_search->Find(term);});
connect(ui->lineEditFind, &QLineEdit::editingFinished, this, [this]()
{
SaveSearchRequest();
InitSearchHistory();
m_search->Find(ui->lineEditFind->text());
});
connect(ui->toolButtonFindPrevious, &QToolButton::clicked, this, [this]()
{
SaveSearchRequest();
InitSearchHistory();
m_search->FindPrevious();
ui->labelResults->setText(QString("%1/%2").arg(m_search->MatchIndex()+1).arg(m_search->MatchCount()));
});
connect(ui->toolButtonFindNext, &QToolButton::clicked, this, [this]()
{
SaveSearchRequest();
InitSearchHistory();
m_search->FindNext();
ui->labelResults->setText(QString("%1/%2").arg(m_search->MatchIndex()+1).arg(m_search->MatchCount()));
});
connect(m_search.data(), &VTableSearch::HasResult, this, [this] (bool state)
{
ui->toolButtonFindPrevious->setEnabled(state);
ui->toolButtonFindNext->setEnabled(state);
if (state)
{
ui->labelResults->setText(QString("%1/%2").arg(m_search->MatchIndex()+1).arg(m_search->MatchCount()));
}
else
{
ui->labelResults->setText(tr("0 results"));
}
QPalette palette;
if (not state && not ui->lineEditFind->text().isEmpty())
{
palette.setColor(QPalette::Text, Qt::red);
ui->lineEditFind->setPalette(palette);
palette.setColor(QPalette::Active, ui->labelResults->foregroundRole(), Qt::red);
palette.setColor(QPalette::Inactive, ui->labelResults->foregroundRole(), Qt::red);
ui->labelResults->setPalette(palette);
}
else
{
ui->lineEditFind->setPalette(palette);
ui->labelResults->setPalette(palette);
}
});
connect(ui->toolButtonCaseSensitive, &QToolButton::toggled, this, [this](bool checked)
{
m_search->SetMatchCase(checked);
m_search->Find(ui->lineEditFind->text());
ui->lineEditFind->setPlaceholderText(m_search->SearchPlaceholder());
});
connect(ui->toolButtonWholeWord, &QToolButton::toggled, this, [this](bool checked)
{
m_search->SetMatchWord(checked);
m_search->Find(ui->lineEditFind->text());
ui->lineEditFind->setPlaceholderText(m_search->SearchPlaceholder());
});
connect(ui->toolButtonRegexp, &QToolButton::toggled, this, [this](bool checked)
{
m_search->SetMatchRegexp(checked);
if (checked)
{
ui->toolButtonWholeWord->blockSignals(true);
ui->toolButtonWholeWord->setChecked(false);
ui->toolButtonWholeWord->blockSignals(false);
ui->toolButtonWholeWord->setEnabled(false);
ui->toolButtonUseUnicodeProperties->setEnabled(true);
}
else
{
ui->toolButtonWholeWord->setEnabled(true);
ui->toolButtonUseUnicodeProperties->blockSignals(true);
ui->toolButtonUseUnicodeProperties->setChecked(false);
ui->toolButtonUseUnicodeProperties->blockSignals(false);
ui->toolButtonUseUnicodeProperties->setEnabled(false);
}
m_search->Find(ui->lineEditFind->text());
ui->lineEditFind->setPlaceholderText(m_search->SearchPlaceholder());
});
connect(ui->toolButtonUseUnicodeProperties, &QToolButton::toggled, this, [this](bool checked)
{
m_search->SetUseUnicodePreperties(checked);
m_search->Find(ui->lineEditFind->text());
});
m_searchHistory->setStyleSheet(QStringLiteral("QMenu { menu-scrollable: 1; }"));
InitSearchHistory();
ui->pushButtonSearch->setMenu(m_searchHistory);
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::InitSearchHistory()
{
QStringList searchHistory = MApplication::VApp()->TapeSettings()->GetTapeSearchHistory();
m_searchHistory->clear();
for (const auto& term : searchHistory)
{
QAction *action = m_searchHistory->addAction(term);
action->setData(term);
connect(action, &QAction::triggered, this, [this]()
{
auto *action = qobject_cast<QAction *>(sender());
if (action != nullptr)
{
QString term = action->data().toString();
ui->lineEditFind->setText(term);
m_search->Find(term);
ui->lineEditFind->setFocus();
}
});
}
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::SaveSearchRequest()
{
QStringList searchHistory = MApplication::VApp()->TapeSettings()->GetTapeSearchHistory();
QString term = ui->lineEditFind->text();
if (term.isEmpty())
{
return;
}
searchHistory.removeAll(term);
searchHistory.prepend(term);
while (searchHistory.size() > VTableSearch::MaxHistoryRecords)
{
searchHistory.removeLast();
}
MApplication::VApp()->TapeSettings()->SetTapeSearchHistory(searchHistory);
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::UpdateSearchControlsTooltips()
{
auto UpdateToolTip = [](QAbstractButton *button)
{
button->setToolTip(button->toolTip().arg(button->shortcut().toString(QKeySequence::NativeText)));
};
UpdateToolTip(ui->toolButtonCaseSensitive);
UpdateToolTip(ui->toolButtonWholeWord);
UpdateToolTip(ui->toolButtonRegexp);
UpdateToolTip(ui->toolButtonUseUnicodeProperties);
UpdateToolTip(ui->pushButtonSearch);
UpdateToolTip(ui->toolButtonFindPrevious);
UpdateToolTip(ui->toolButtonFindNext);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void TMainWindow::RetranslateTableHeaders() void TMainWindow::RetranslateTableHeaders()
{ {

View File

@ -165,7 +165,7 @@ private:
QComboBox *comboBoxUnits{nullptr}; QComboBox *comboBoxUnits{nullptr};
int formulaBaseHeight; int formulaBaseHeight;
QSharedPointer<VLockGuard<char>> lock{nullptr}; QSharedPointer<VLockGuard<char>> lock{nullptr};
QSharedPointer<VTableSearch> search{}; QSharedPointer<VTableSearch> m_search{};
QLabel *labelGradationDimensionA{nullptr}; QLabel *labelGradationDimensionA{nullptr};
QLabel *labelGradationDimensionB{nullptr}; QLabel *labelGradationDimensionB{nullptr};
QLabel *labelGradationDimensionC{nullptr}; QLabel *labelGradationDimensionC{nullptr};
@ -173,6 +173,7 @@ private:
bool isInitialized{false}; bool isInitialized{false};
bool mIsReadOnly{false}; bool mIsReadOnly{false};
QTimer *gradation; QTimer *gradation;
QMenu *m_searchHistory;
QVector<QObject *> hackedWidgets{}; QVector<QObject *> hackedWidgets{};
@ -190,6 +191,11 @@ private:
void InitMeasurementUnits(); void InitMeasurementUnits();
void InitGender(QComboBox *gender); void InitGender(QComboBox *gender);
void InitMeasurementDimension(); void InitMeasurementDimension();
void InitSearch();
void InitSearchHistory();
void SaveSearchRequest();
void UpdateSearchControlsTooltips();
void RetranslateTableHeaders(); void RetranslateTableHeaders();

View File

@ -61,23 +61,196 @@
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<item> <item>
<widget class="QLabel" name="labelFind"> <widget class="QPushButton" name="pushButtonSearch">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Search history &lt;span style=&quot; color:#888a85;&quot;&gt;%1&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text"> <property name="text">
<string>Find:</string> <string notr="true"/>
</property>
<property name="icon">
<iconset theme="system-search">
<normaloff>../valentina/dialogs</normaloff>../valentina/dialogs</iconset>
</property>
<property name="shortcut">
<string>Alt+Down</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLineEdit" name="lineEditFind"> <widget class="QLineEdit" name="lineEditFind">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>true</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Search measurements by term. &lt;/p&gt;&lt;p&gt;Prepend &amp;quot;/r/&amp;quot; to the front of the search string to search measurements by regex.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="placeholderText"> <property name="placeholderText">
<string>Search</string> <string>Search</string>
</property> </property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelResults">
<property name="text">
<string>0 results</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonCaseSensitive">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
</font>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Match Case &lt;span style=&quot; color:#888a85;&quot;&gt;%1&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string notr="true">Cc</string>
</property>
<property name="shortcut">
<string notr="true">Alt+C</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonWholeWord">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Match words &lt;span style=&quot; color:#888a85;&quot;&gt;%1&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string notr="true">W</string>
</property>
<property name="shortcut">
<string notr="true">Alt+W</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonRegexp">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Match with regular expressions &lt;span style=&quot; color:#888a85;&quot;&gt;%1&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string notr="true">.*</string>
</property>
<property name="shortcut">
<string notr="true">Alt+X</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonUseUnicodeProperties">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Use unicode properties &lt;span style=&quot; color:#888a85;&quot;&gt;%1&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;span style=&quot; color:#888a85;&quot;&gt;The meaning of the \w, \d, etc., character classes, as well as the meaning of their counterparts (\W, \D, etc.), is changed from matching ASCII characters only to matching any character with the corresponding Unicode property. For instance, \d is changed to match any character with the Unicode Nd (decimal digit) property; \w to match any character with either the Unicode L (letter) or N (digit) property, plus underscore, and so on. This option corresponds to the /u modifier in Perl regular expressions.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string notr="true">U</string>
</property>
<property name="shortcut">
<string>Alt+U</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget> </widget>
</item> </item>
<item> <item>
@ -86,17 +259,17 @@
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>Find Previous</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Find Previous &lt;span style=&quot; color:#888a85;&quot;&gt;%1&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="text"> <property name="text">
<string notr="true">...</string> <string notr="true">...</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset theme="go-previous"> <iconset theme="go-up">
<normaloff>.</normaloff>.</iconset> <normaloff>../valentina/dialogs</normaloff>../valentina/dialogs</iconset>
</property> </property>
<property name="shortcut"> <property name="shortcut">
<string>Ctrl+Shift+G</string> <string>Shift+F3</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -106,17 +279,17 @@
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>Find Next</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Find Next %1&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="text"> <property name="text">
<string notr="true">...</string> <string notr="true">...</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset theme="go-next"> <iconset theme="go-down">
<normaloff>.</normaloff>.</iconset> <normaloff>../valentina/dialogs</normaloff>../valentina/dialogs</iconset>
</property> </property>
<property name="shortcut"> <property name="shortcut">
<string>Ctrl+G</string> <string>F3</string>
</property> </property>
<property name="autoExclusive"> <property name="autoExclusive">
<bool>false</bool> <bool>false</bool>

View File

@ -37,7 +37,16 @@
namespace namespace
{ {
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDataBaseGeometry, (QLatin1String("database/geometry"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDataBaseGeometry, (QLatin1String("database/geometry")))
} Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchHistoryTape, (QLatin1String("searchHistory/tape")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeUseUnicodeProperties,
(QLatin1String("searchOptions/tapeUseUnicodeProperties")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeWholeWord,
(QLatin1String("searchOptions/tapeWholeWord")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeRegexp, (QLatin1String("searchOptions/tapeRegexp")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsTapeMatchCase,
(QLatin1String("searchOptions/tapeMatchCase")))
} // namespace
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VTapeSettings::VTapeSettings(Format format, Scope scope, const QString &organization, const QString &application, VTapeSettings::VTapeSettings(Format format, Scope scope, const QString &organization, const QString &application,
@ -57,3 +66,63 @@ void VTapeSettings::SetDataBaseGeometry(const QByteArray &value)
{ {
setValue(*settingDataBaseGeometry, value); setValue(*settingDataBaseGeometry, value);
} }
//---------------------------------------------------------------------------------------------------------------------
auto VTapeSettings::GetTapeSearchHistory() const -> QStringList
{
return value(*settingSearchHistoryTape).toStringList();
}
//---------------------------------------------------------------------------------------------------------------------
void VTapeSettings::SetTapeSearchHistory(const QStringList &history)
{
setValue(*settingSearchHistoryTape, history);
}
//---------------------------------------------------------------------------------------------------------------------
auto VTapeSettings::GetTapeSearchOptionUseUnicodeProperties() const -> bool
{
return value(*settingSearchOptionsTapeUseUnicodeProperties, false).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
void VTapeSettings::SetTapeSearchOptionUseUnicodeProperties(bool value)
{
setValue(*settingSearchOptionsTapeUseUnicodeProperties, value);
}
//---------------------------------------------------------------------------------------------------------------------
auto VTapeSettings::GetTapeSearchOptionWholeWord() const -> bool
{
return value(*settingSearchOptionsTapeWholeWord, false).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
void VTapeSettings::SetTapeSearchOptionWholeWord(bool value)
{
setValue(*settingSearchOptionsTapeWholeWord, value);
}
//---------------------------------------------------------------------------------------------------------------------
auto VTapeSettings::GetTapeSearchOptionRegexp() const -> bool
{
return value(*settingSearchOptionsTapeRegexp, false).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
void VTapeSettings::SetTapeSearchOptionRegexp(bool value)
{
setValue(*settingSearchOptionsTapeRegexp, value);
}
//---------------------------------------------------------------------------------------------------------------------
auto VTapeSettings::GetTapeSearchOptionMatchCase() const -> bool
{
return value(*settingSearchOptionsTapeMatchCase, false).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
void VTapeSettings::SetTapeSearchOptionMatchCase(bool value)
{
setValue(*settingSearchOptionsTapeMatchCase, value);
}

View File

@ -49,6 +49,21 @@ public:
QByteArray GetDataBaseGeometry() const; QByteArray GetDataBaseGeometry() const;
void SetDataBaseGeometry(const QByteArray &value); void SetDataBaseGeometry(const QByteArray &value);
auto GetTapeSearchHistory() const -> QStringList;
void SetTapeSearchHistory(const QStringList &history);
auto GetTapeSearchOptionUseUnicodeProperties() const -> bool;
void SetTapeSearchOptionUseUnicodeProperties(bool value);
auto GetTapeSearchOptionWholeWord() const -> bool;
void SetTapeSearchOptionWholeWord(bool value);
auto GetTapeSearchOptionRegexp() const -> bool;
void SetTapeSearchOptionRegexp(bool value);
auto GetTapeSearchOptionMatchCase() const ->bool;
void SetTapeSearchOptionMatchCase(bool value);
private: private:
Q_DISABLE_COPY(VTapeSettings) Q_DISABLE_COPY(VTapeSettings)
}; };

View File

@ -36,6 +36,7 @@
#include "../vpatterndb/calculator.h" #include "../vpatterndb/calculator.h"
#include "../vtools/dialogs/support/dialogeditwrongformula.h" #include "../vtools/dialogs/support/dialogeditwrongformula.h"
#include "../core/vapplication.h" #include "../core/vapplication.h"
#include <QMenu>
#include <qnumeric.h> #include <qnumeric.h>
#define DIALOG_MAX_FORMULA_HEIGHT 64 #define DIALOG_MAX_FORMULA_HEIGHT 64
@ -46,7 +47,8 @@ DialogFinalMeasurements::DialogFinalMeasurements(VPattern *doc, QWidget *parent)
ui(new Ui::DialogFinalMeasurements), ui(new Ui::DialogFinalMeasurements),
m_doc(doc), m_doc(doc),
m_data(doc->GetCompleteData()), m_data(doc->GetCompleteData()),
m_measurements(doc->GetFinalMeasurements()) m_measurements(doc->GetFinalMeasurements()),
m_searchHistory(new QMenu(this))
{ {
ui->setupUi(this); ui->setupUi(this);
@ -55,11 +57,10 @@ DialogFinalMeasurements::DialogFinalMeasurements(VPattern *doc, QWidget *parent)
#endif #endif
ui->lineEditName->setClearButtonEnabled(true); ui->lineEditName->setClearButtonEnabled(true);
ui->lineEditFind->setClearButtonEnabled(true);
ui->lineEditFind->installEventFilter(this); ui->lineEditFind->installEventFilter(this);
m_search = QSharedPointer<VTableSearch>(new VTableSearch(ui->tableWidget)); InitSearch();
formulaBaseHeight = ui->plainTextEditFormula->height(); formulaBaseHeight = ui->plainTextEditFormula->height();
ui->plainTextEditFormula->installEventFilter(this); ui->plainTextEditFormula->installEventFilter(this);
@ -89,19 +90,6 @@ DialogFinalMeasurements::DialogFinalMeasurements(VPattern *doc, QWidget *parent)
connect(ui->plainTextEditDescription, &QPlainTextEdit::textChanged, this, connect(ui->plainTextEditDescription, &QPlainTextEdit::textChanged, this,
&DialogFinalMeasurements::SaveDescription); &DialogFinalMeasurements::SaveDescription);
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogFinalMeasurements::SaveFormula); connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogFinalMeasurements::SaveFormula);
connect(ui->lineEditFind, &QLineEdit::textEdited, this, [this](const QString &term){m_search->Find(term);});
connect(ui->toolButtonFindPrevious, &QToolButton::clicked, this, [this](){m_search->FindPrevious();});
connect(ui->toolButtonFindNext, &QToolButton::clicked, this, [this](){m_search->FindNext();});
connect(m_search.data(), &VTableSearch::HasResult, this, [this] (bool state)
{
ui->toolButtonFindPrevious->setEnabled(state);
});
connect(m_search.data(), &VTableSearch::HasResult, this, [this] (bool state)
{
ui->toolButtonFindNext->setEnabled(state);
});
if (ui->tableWidget->rowCount() > 0) if (ui->tableWidget->rowCount() > 0)
{ {
@ -112,6 +100,7 @@ DialogFinalMeasurements::DialogFinalMeasurements(VPattern *doc, QWidget *parent)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
DialogFinalMeasurements::~DialogFinalMeasurements() DialogFinalMeasurements::~DialogFinalMeasurements()
{ {
ui->lineEditFind->blockSignals(true); // prevents crash
delete ui; delete ui;
} }
@ -122,6 +111,12 @@ void DialogFinalMeasurements::closeEvent(QCloseEvent *event)
ui->lineEditName->blockSignals(true); ui->lineEditName->blockSignals(true);
ui->plainTextEditDescription->blockSignals(true); ui->plainTextEditDescription->blockSignals(true);
VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings();
settings->SetFinalMeasurementsSearchOptionMatchCase(m_search->IsMatchCase());
settings->SetFinalMeasurementsSearchOptionWholeWord(m_search->IsMatchWord());
settings->SetFinalMeasurementsSearchOptionRegexp(m_search->IsMatchRegexp());
settings->SetFinalMeasurementsSearchOptionUseUnicodeProperties(m_search->IsUseUnicodePreperties());
QDialog::closeEvent(event); QDialog::closeEvent(event);
} }
@ -132,6 +127,8 @@ void DialogFinalMeasurements::changeEvent(QEvent *event)
{ {
// retranslate designer form (single inheritance approach) // retranslate designer form (single inheritance approach)
ui->retranslateUi(this); ui->retranslateUi(this);
ui->lineEditFind->setPlaceholderText(m_search->SearchPlaceholder());
UpdateSearchControlsTooltips();
FullUpdateFromFile(); FullUpdateFromFile();
} }
// remember to call base class implementation // remember to call base class implementation
@ -721,3 +718,183 @@ qreal DialogFinalMeasurements::EvalFormula(const QString &formula, bool &ok)
ok = true; ok = true;
return result; return result;
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogFinalMeasurements::InitSearch()
{
m_search = QSharedPointer<VTableSearch>(new VTableSearch(ui->tableWidget));
VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings();
m_search->SetUseUnicodePreperties(settings->GetFinalMeasurementsSearchOptionUseUnicodeProperties());
m_search->SetMatchWord(settings->GetFinalMeasurementsSearchOptionWholeWord());
m_search->SetMatchRegexp(settings->GetFinalMeasurementsSearchOptionRegexp());
m_search->SetMatchCase(settings->GetFinalMeasurementsSearchOptionMatchCase());
ui->lineEditFind->setPlaceholderText(m_search->SearchPlaceholder());
UpdateSearchControlsTooltips();
connect(ui->lineEditFind, &QLineEdit::textEdited, this, [this](const QString &term){m_search->Find(term);});
connect(ui->lineEditFind, &QLineEdit::editingFinished, this, [this]()
{
SaveSearchRequest();
InitSearchHistory();
m_search->Find(ui->lineEditFind->text());
});
connect(ui->toolButtonFindPrevious, &QToolButton::clicked, this, [this]()
{
SaveSearchRequest();
InitSearchHistory();
m_search->FindPrevious();
ui->labelResults->setText(QString("%1/%2").arg(m_search->MatchIndex()+1).arg(m_search->MatchCount()));
});
connect(ui->toolButtonFindNext, &QToolButton::clicked, this, [this]()
{
SaveSearchRequest();
InitSearchHistory();
m_search->FindNext();
ui->labelResults->setText(QString("%1/%2").arg(m_search->MatchIndex()+1).arg(m_search->MatchCount()));
});
connect(m_search.data(), &VTableSearch::HasResult, this, [this] (bool state)
{
ui->toolButtonFindPrevious->setEnabled(state);
ui->toolButtonFindNext->setEnabled(state);
if (state)
{
ui->labelResults->setText(QString("%1/%2").arg(m_search->MatchIndex()+1).arg(m_search->MatchCount()));
}
else
{
ui->labelResults->setText(tr("0 results"));
}
QPalette palette;
if (not state && not ui->lineEditFind->text().isEmpty())
{
palette.setColor(QPalette::Text, Qt::red);
ui->lineEditFind->setPalette(palette);
palette.setColor(QPalette::Active, ui->labelResults->foregroundRole(), Qt::red);
palette.setColor(QPalette::Inactive, ui->labelResults->foregroundRole(), Qt::red);
ui->labelResults->setPalette(palette);
}
else
{
ui->lineEditFind->setPalette(palette);
ui->labelResults->setPalette(palette);
}
});
connect(ui->toolButtonCaseSensitive, &QToolButton::toggled, this, [this](bool checked)
{
m_search->SetMatchCase(checked);
m_search->Find(ui->lineEditFind->text());
ui->lineEditFind->setPlaceholderText(m_search->SearchPlaceholder());
});
connect(ui->toolButtonWholeWord, &QToolButton::toggled, this, [this](bool checked)
{
m_search->SetMatchWord(checked);
m_search->Find(ui->lineEditFind->text());
ui->lineEditFind->setPlaceholderText(m_search->SearchPlaceholder());
});
connect(ui->toolButtonRegexp, &QToolButton::toggled, this, [this](bool checked)
{
m_search->SetMatchRegexp(checked);
if (checked)
{
ui->toolButtonWholeWord->blockSignals(true);
ui->toolButtonWholeWord->setChecked(false);
ui->toolButtonWholeWord->blockSignals(false);
ui->toolButtonWholeWord->setEnabled(false);
ui->toolButtonUseUnicodeProperties->setEnabled(true);
}
else
{
ui->toolButtonWholeWord->setEnabled(true);
ui->toolButtonUseUnicodeProperties->blockSignals(true);
ui->toolButtonUseUnicodeProperties->setChecked(false);
ui->toolButtonUseUnicodeProperties->blockSignals(false);
ui->toolButtonUseUnicodeProperties->setEnabled(false);
}
m_search->Find(ui->lineEditFind->text());
ui->lineEditFind->setPlaceholderText(m_search->SearchPlaceholder());
});
connect(ui->toolButtonUseUnicodeProperties, &QToolButton::toggled, this, [this](bool checked)
{
m_search->SetUseUnicodePreperties(checked);
m_search->Find(ui->lineEditFind->text());
});
m_searchHistory->setStyleSheet(QStringLiteral("QMenu { menu-scrollable: 1; }"));
InitSearchHistory();
ui->pushButtonSearch->setMenu(m_searchHistory);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFinalMeasurements::InitSearchHistory()
{
QStringList searchHistory =
VAbstractValApplication::VApp()->ValentinaSettings()->GetFinalMeasurementsSearchHistory();
m_searchHistory->clear();
for (const auto& term : searchHistory)
{
QAction *action = m_searchHistory->addAction(term);
action->setData(term);
connect(action, &QAction::triggered, this, [this]()
{
auto *action = qobject_cast<QAction *>(sender());
if (action != nullptr)
{
QString term = action->data().toString();
ui->lineEditFind->setText(term);
m_search->Find(term);
ui->lineEditFind->setFocus();
}
});
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFinalMeasurements::SaveSearchRequest()
{
QStringList searchHistory =
VAbstractValApplication::VApp()->ValentinaSettings()->GetFinalMeasurementsSearchHistory();
QString term = ui->lineEditFind->text();
if (term.isEmpty())
{
return;
}
searchHistory.removeAll(term);
searchHistory.prepend(term);
while (searchHistory.size() > VTableSearch::MaxHistoryRecords)
{
searchHistory.removeLast();
}
VAbstractValApplication::VApp()->ValentinaSettings()->SetFinalMeasurementsSearchHistory(searchHistory);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFinalMeasurements::UpdateSearchControlsTooltips()
{
auto UpdateToolTip = [](QAbstractButton *button)
{
button->setToolTip(button->toolTip().arg(button->shortcut().toString(QKeySequence::NativeText)));
};
UpdateToolTip(ui->toolButtonCaseSensitive);
UpdateToolTip(ui->toolButtonWholeWord);
UpdateToolTip(ui->toolButtonRegexp);
UpdateToolTip(ui->toolButtonUseUnicodeProperties);
UpdateToolTip(ui->pushButtonSearch);
UpdateToolTip(ui->toolButtonFindPrevious);
UpdateToolTip(ui->toolButtonFindNext);
}

View File

@ -79,6 +79,8 @@ private:
int formulaBaseHeight{0}; int formulaBaseHeight{0};
bool m_isInitialized{false}; bool m_isInitialized{false};
QMenu *m_searchHistory;
void FillFinalMeasurements(bool freshCall = false); void FillFinalMeasurements(bool freshCall = false);
void ShowUnits(); void ShowUnits();
@ -91,6 +93,11 @@ private:
void UpdateTree(); void UpdateTree();
qreal EvalFormula(const QString &formula, bool &ok); qreal EvalFormula(const QString &formula, bool &ok);
void InitSearch();
void InitSearchHistory();
void SaveSearchRequest();
void UpdateSearchControlsTooltips();
}; };
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -19,46 +19,240 @@
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_4"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="topMargin">
<number>0</number>
</property>
<item> <item>
<widget class="QLabel" name="labelFind"> <widget class="QPushButton" name="pushButtonSearch">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Search history &lt;span style=&quot; color:#888a85;&quot;&gt;%1&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text"> <property name="text">
<string>Find:</string> <string notr="true"/>
</property>
<property name="icon">
<iconset theme="system-search">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="shortcut">
<string>Alt+Down</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLineEdit" name="lineEditFind"> <widget class="QLineEdit" name="lineEditFind">
<property name="toolTip"> <property name="enabled">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Search final measurements by term. &lt;/p&gt;&lt;p&gt;Prepend &amp;quot;/r/&amp;quot; to the front of the search string to search final measurements by regex.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <bool>true</bool>
</property> </property>
<property name="placeholderText"> <property name="placeholderText">
<string>Search</string> <string>Search</string>
</property> </property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelResults">
<property name="text">
<string>0 results</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonCaseSensitive">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
</font>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Match Case &lt;span style=&quot; color:#888a85;&quot;&gt;%1&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string notr="true">Cc</string>
</property>
<property name="shortcut">
<string notr="true">Alt+C</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonWholeWord">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Match words &lt;span style=&quot; color:#888a85;&quot;&gt;%1&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string notr="true">W</string>
</property>
<property name="shortcut">
<string notr="true">Alt+W</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonRegexp">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Match with regular expressions &lt;span style=&quot; color:#888a85;&quot;&gt;%1&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string notr="true">.*</string>
</property>
<property name="shortcut">
<string notr="true">Alt+X</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonUseUnicodeProperties">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Use unicode properties &lt;span style=&quot; color:#888a85;&quot;&gt;%1&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;span style=&quot; color:#888a85;&quot;&gt;The meaning of the \w, \d, etc., character classes, as well as the meaning of their counterparts (\W, \D, etc.), is changed from matching ASCII characters only to matching any character with the corresponding Unicode property. For instance, \d is changed to match any character with the Unicode Nd (decimal digit) property; \w to match any character with either the Unicode L (letter) or N (digit) property, plus underscore, and so on. This option corresponds to the /u modifier in Perl regular expressions.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string notr="true">U</string>
</property>
<property name="shortcut">
<string>Alt+U</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QToolButton" name="toolButtonFindPrevious"> <widget class="QToolButton" name="toolButtonFindPrevious">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Find Previous &lt;span style=&quot; color:#888a85;&quot;&gt;%1&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text"> <property name="text">
<string notr="true">...</string> <string notr="true">...</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset theme="go-previous" resource="../../../libs/vmisc/share/resources/theme.qrc"> <iconset theme="go-up">
<normaloff>:/icons/win.icon.theme/16x16/actions/go-previous.png</normaloff>:/icons/win.icon.theme/16x16/actions/go-previous.png</iconset> <normaloff>.</normaloff>.</iconset>
</property>
<property name="shortcut">
<string>Shift+F3</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QToolButton" name="toolButtonFindNext"> <widget class="QToolButton" name="toolButtonFindNext">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Find Next %1&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text"> <property name="text">
<string notr="true">...</string> <string notr="true">...</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset theme="go-next" resource="../../../libs/vmisc/share/resources/theme.qrc"> <iconset theme="go-down">
<normaloff>:/icons/win.icon.theme/16x16/actions/go-next.png</normaloff>:/icons/win.icon.theme/16x16/actions/go-next.png</iconset> <normaloff>.</normaloff>.</iconset>
</property>
<property name="shortcut">
<string>F3</string>
</property>
<property name="autoExclusive">
<bool>false</bool>
</property> </property>
</widget> </widget>
</item> </item>
@ -100,12 +294,12 @@
<attribute name="horizontalHeaderCascadingSectionResizes"> <attribute name="horizontalHeaderCascadingSectionResizes">
<bool>false</bool> <bool>false</bool>
</attribute> </attribute>
<attribute name="horizontalHeaderDefaultSectionSize">
<number>120</number>
</attribute>
<attribute name="horizontalHeaderMinimumSectionSize"> <attribute name="horizontalHeaderMinimumSectionSize">
<number>70</number> <number>70</number>
</attribute> </attribute>
<attribute name="horizontalHeaderDefaultSectionSize">
<number>120</number>
</attribute>
<attribute name="horizontalHeaderShowSortIndicator" stdset="0"> <attribute name="horizontalHeaderShowSortIndicator" stdset="0">
<bool>false</bool> <bool>false</bool>
</attribute> </attribute>
@ -118,12 +312,12 @@
<attribute name="verticalHeaderCascadingSectionResizes"> <attribute name="verticalHeaderCascadingSectionResizes">
<bool>false</bool> <bool>false</bool>
</attribute> </attribute>
<attribute name="verticalHeaderDefaultSectionSize">
<number>25</number>
</attribute>
<attribute name="verticalHeaderMinimumSectionSize"> <attribute name="verticalHeaderMinimumSectionSize">
<number>8</number> <number>8</number>
</attribute> </attribute>
<attribute name="verticalHeaderDefaultSectionSize">
<number>25</number>
</attribute>
<attribute name="verticalHeaderStretchLastSection"> <attribute name="verticalHeaderStretchLastSection">
<bool>false</bool> <bool>false</bool>
</attribute> </attribute>
@ -450,7 +644,6 @@
</customwidgets> </customwidgets>
<resources> <resources>
<include location="../../../libs/vmisc/share/resources/icon.qrc"/> <include location="../../../libs/vmisc/share/resources/icon.qrc"/>
<include location="../../../libs/vmisc/share/resources/theme.qrc"/>
</resources> </resources>
<connections> <connections>
<connection> <connection>

View File

@ -41,6 +41,7 @@
#include "../xml/vpattern.h" #include "../xml/vpattern.h"
#include "../vmisc/diagnostic.h" #include "../vmisc/diagnostic.h"
#include "../vmisc/vtablesearch.h" #include "../vmisc/vtablesearch.h"
#include "../vmisc/vvalentinasettings.h"
#include <QDebug> #include <QDebug>
#include <QtConcurrent> #include <QtConcurrent>
@ -54,8 +55,10 @@
* @param parent parent widget * @param parent parent widget
*/ */
DialogHistory::DialogHistory(VContainer *data, VPattern *doc, QWidget *parent) DialogHistory::DialogHistory(VContainer *data, VPattern *doc, QWidget *parent)
:DialogTool(data, 0, parent), ui(new Ui::DialogHistory), doc(doc), cursorRow(0), :DialogTool(data, 0, parent),
cursorToolRecordRow(0) ui(new Ui::DialogHistory),
doc(doc),
m_searchHistory(new QMenu(this))
{ {
ui->setupUi(this); ui->setupUi(this);
@ -74,26 +77,13 @@ DialogHistory::DialogHistory(VContainer *data, VPattern *doc, QWidget *parent)
connect(doc, &VPattern::patternChanged, this, &DialogHistory::UpdateHistory); connect(doc, &VPattern::patternChanged, this, &DialogHistory::UpdateHistory);
ShowPoint(); ShowPoint();
m_search = QSharedPointer<VTableSearch>(new VTableSearch(ui->tableWidget)); InitSearch();
connect(ui->lineEditFind, &QLineEdit::textEdited, this, [this](const QString &term){m_search->Find(term);});
connect(ui->toolButtonFindPrevious, &QToolButton::clicked, this, [this](){m_search->FindPrevious();});
connect(ui->toolButtonFindNext, &QToolButton::clicked, this, [this](){m_search->FindNext();});
connect(m_search.data(), &VTableSearch::HasResult, this, [this] (bool state)
{
ui->toolButtonFindPrevious->setEnabled(state);
});
connect(m_search.data(), &VTableSearch::HasResult, this, [this] (bool state)
{
ui->toolButtonFindNext->setEnabled(state);
});
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
DialogHistory::~DialogHistory() DialogHistory::~DialogHistory()
{ {
ui->lineEditFind->blockSignals(true); // prevents crash
delete ui; delete ui;
} }
@ -554,6 +544,13 @@ void DialogHistory::closeEvent(QCloseEvent *event)
QTableWidgetItem *item = ui->tableWidget->item(cursorToolRecordRow, 0); QTableWidgetItem *item = ui->tableWidget->item(cursorToolRecordRow, 0);
quint32 id = qvariant_cast<quint32>(item->data(Qt::UserRole)); quint32 id = qvariant_cast<quint32>(item->data(Qt::UserRole));
emit ShowHistoryTool(id, false); emit ShowHistoryTool(id, false);
VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings();
settings->SetHistorySearchOptionMatchCase(m_search->IsMatchCase());
settings->SetHistorySearchOptionWholeWord(m_search->IsMatchWord());
settings->SetHistorySearchOptionRegexp(m_search->IsMatchRegexp());
settings->SetHistorySearchOptionUseUnicodeProperties(m_search->IsUseUnicodePreperties());
DialogTool::closeEvent(event); DialogTool::closeEvent(event);
} }
@ -589,6 +586,8 @@ void DialogHistory::RetranslateUi()
cursorRow = currentRow; cursorRow = currentRow;
cellClicked(cursorRow, 0); cellClicked(cursorRow, 0);
ui->lineEditFind->setPlaceholderText(m_search->SearchPlaceholder());
UpdateSearchControlsTooltips();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -611,3 +610,181 @@ int DialogHistory::CursorRow() const
} }
return ui->tableWidget->rowCount()-1; return ui->tableWidget->rowCount()-1;
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogHistory::InitSearch()
{
m_search = QSharedPointer<VTableSearch>(new VTableSearch(ui->tableWidget));
VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings();
m_search->SetUseUnicodePreperties(settings->GetHistorySearchOptionUseUnicodeProperties());
m_search->SetMatchWord(settings->GetHistorySearchOptionWholeWord());
m_search->SetMatchRegexp(settings->GetHistorySearchOptionRegexp());
m_search->SetMatchCase(settings->GetHistorySearchOptionMatchCase());
ui->lineEditFind->setPlaceholderText(m_search->SearchPlaceholder());
UpdateSearchControlsTooltips();
connect(ui->lineEditFind, &QLineEdit::textEdited, this, [this](const QString &term){m_search->Find(term);});
connect(ui->lineEditFind, &QLineEdit::editingFinished, this, [this]()
{
SaveSearchRequest();
InitSearchHistory();
m_search->Find(ui->lineEditFind->text());
});
connect(ui->toolButtonFindPrevious, &QToolButton::clicked, this, [this]()
{
SaveSearchRequest();
InitSearchHistory();
m_search->FindPrevious();
ui->labelResults->setText(QString("%1/%2").arg(m_search->MatchIndex()+1).arg(m_search->MatchCount()));
});
connect(ui->toolButtonFindNext, &QToolButton::clicked, this, [this]()
{
SaveSearchRequest();
InitSearchHistory();
m_search->FindNext();
ui->labelResults->setText(QString("%1/%2").arg(m_search->MatchIndex()+1).arg(m_search->MatchCount()));
});
connect(m_search.data(), &VTableSearch::HasResult, this, [this] (bool state)
{
ui->toolButtonFindPrevious->setEnabled(state);
ui->toolButtonFindNext->setEnabled(state);
if (state)
{
ui->labelResults->setText(QString("%1/%2").arg(m_search->MatchIndex()+1).arg(m_search->MatchCount()));
}
else
{
ui->labelResults->setText(tr("0 results"));
}
QPalette palette;
if (not state && not ui->lineEditFind->text().isEmpty())
{
palette.setColor(QPalette::Text, Qt::red);
ui->lineEditFind->setPalette(palette);
palette.setColor(QPalette::Active, ui->labelResults->foregroundRole(), Qt::red);
palette.setColor(QPalette::Inactive, ui->labelResults->foregroundRole(), Qt::red);
ui->labelResults->setPalette(palette);
}
else
{
ui->lineEditFind->setPalette(palette);
ui->labelResults->setPalette(palette);
}
});
connect(ui->toolButtonCaseSensitive, &QToolButton::toggled, this, [this](bool checked)
{
m_search->SetMatchCase(checked);
m_search->Find(ui->lineEditFind->text());
ui->lineEditFind->setPlaceholderText(m_search->SearchPlaceholder());
});
connect(ui->toolButtonWholeWord, &QToolButton::toggled, this, [this](bool checked)
{
m_search->SetMatchWord(checked);
m_search->Find(ui->lineEditFind->text());
ui->lineEditFind->setPlaceholderText(m_search->SearchPlaceholder());
});
connect(ui->toolButtonRegexp, &QToolButton::toggled, this, [this](bool checked)
{
m_search->SetMatchRegexp(checked);
if (checked)
{
ui->toolButtonWholeWord->blockSignals(true);
ui->toolButtonWholeWord->setChecked(false);
ui->toolButtonWholeWord->blockSignals(false);
ui->toolButtonWholeWord->setEnabled(false);
ui->toolButtonUseUnicodeProperties->setEnabled(true);
}
else
{
ui->toolButtonWholeWord->setEnabled(true);
ui->toolButtonUseUnicodeProperties->blockSignals(true);
ui->toolButtonUseUnicodeProperties->setChecked(false);
ui->toolButtonUseUnicodeProperties->blockSignals(false);
ui->toolButtonUseUnicodeProperties->setEnabled(false);
}
m_search->Find(ui->lineEditFind->text());
ui->lineEditFind->setPlaceholderText(m_search->SearchPlaceholder());
});
connect(ui->toolButtonUseUnicodeProperties, &QToolButton::toggled, this, [this](bool checked)
{
m_search->SetUseUnicodePreperties(checked);
m_search->Find(ui->lineEditFind->text());
});
m_searchHistory->setStyleSheet(QStringLiteral("QMenu { menu-scrollable: 1; }"));
InitSearchHistory();
ui->pushButtonSearch->setMenu(m_searchHistory);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogHistory::InitSearchHistory()
{
QStringList searchHistory = VAbstractValApplication::VApp()->ValentinaSettings()->GetHistorySearchHistory();
m_searchHistory->clear();
for (const auto& term : searchHistory)
{
QAction *action = m_searchHistory->addAction(term);
action->setData(term);
connect(action, &QAction::triggered, this, [this]()
{
auto *action = qobject_cast<QAction *>(sender());
if (action != nullptr)
{
QString term = action->data().toString();
ui->lineEditFind->setText(term);
m_search->Find(term);
ui->lineEditFind->setFocus();
}
});
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogHistory::SaveSearchRequest()
{
QStringList searchHistory = VAbstractValApplication::VApp()->ValentinaSettings()->GetHistorySearchHistory();
QString term = ui->lineEditFind->text();
if (term.isEmpty())
{
return;
}
searchHistory.removeAll(term);
searchHistory.prepend(term);
while (searchHistory.size() > VTableSearch::MaxHistoryRecords)
{
searchHistory.removeLast();
}
VAbstractValApplication::VApp()->ValentinaSettings()->SetHistorySearchHistory(searchHistory);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogHistory::UpdateSearchControlsTooltips()
{
auto UpdateToolTip = [](QAbstractButton *button)
{
button->setToolTip(button->toolTip().arg(button->shortcut().toString(QKeySequence::NativeText)));
};
UpdateToolTip(ui->toolButtonCaseSensitive);
UpdateToolTip(ui->toolButtonWholeWord);
UpdateToolTip(ui->toolButtonRegexp);
UpdateToolTip(ui->toolButtonUseUnicodeProperties);
UpdateToolTip(ui->pushButtonSearch);
UpdateToolTip(ui->toolButtonFindPrevious);
UpdateToolTip(ui->toolButtonFindNext);
}

View File

@ -87,12 +87,14 @@ private:
VPattern *doc; VPattern *doc;
/** @brief cursorRow save number of row where is cursor */ /** @brief cursorRow save number of row where is cursor */
qint32 cursorRow; qint32 cursorRow{0};
/** @brief cursorToolRecordRow save number of row selected record */ /** @brief cursorToolRecordRow save number of row selected record */
qint32 cursorToolRecordRow; qint32 cursorToolRecordRow{0};
QSharedPointer<VTableSearch> m_search{}; QSharedPointer<VTableSearch> m_search{};
QMenu *m_searchHistory;
void FillTable(); void FillTable();
HistoryRecord Record(const VToolRecord &tool) const; HistoryRecord Record(const VToolRecord &tool) const;
void InitialTable(); void InitialTable();
@ -101,6 +103,11 @@ private:
quint32 AttrUInt(const QDomElement &domElement, const QString &name) const; quint32 AttrUInt(const QDomElement &domElement, const QString &name) const;
void RetranslateUi(); void RetranslateUi();
int CursorRow() const; int CursorRow() const;
void InitSearch();
void InitSearchHistory();
void SaveSearchRequest();
void UpdateSearchControlsTooltips();
}; };
#endif // DIALOGHISTORY_H #endif // DIALOGHISTORY_H

View File

@ -9,8 +9,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>488</width> <width>701</width>
<height>420</height> <height>694</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -25,11 +25,27 @@
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QLabel" name="labelFind"> <widget class="QPushButton" name="pushButtonSearch">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Search history &lt;span style=&quot; color:#888a85;&quot;&gt;%1&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text"> <property name="text">
<string>Find:</string> <string notr="true"/>
</property>
<property name="icon">
<iconset theme="system-search">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="shortcut">
<string>Alt+Down</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -38,12 +54,169 @@
<property name="enabled"> <property name="enabled">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Search measurements by term. &lt;/p&gt;&lt;p&gt;Prepend &amp;quot;/r/&amp;quot; to the front of the search string to search history records by regex.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="placeholderText"> <property name="placeholderText">
<string>Search</string> <string>Search</string>
</property> </property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelResults">
<property name="text">
<string>0 results</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonCaseSensitive">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
</font>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Match Case &lt;span style=&quot; color:#888a85;&quot;&gt;%1&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string notr="true">Cc</string>
</property>
<property name="shortcut">
<string notr="true">Alt+C</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonWholeWord">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Match words &lt;span style=&quot; color:#888a85;&quot;&gt;%1&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string notr="true">W</string>
</property>
<property name="shortcut">
<string notr="true">Alt+W</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonRegexp">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Match with regular expressions &lt;span style=&quot; color:#888a85;&quot;&gt;%1&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string notr="true">.*</string>
</property>
<property name="shortcut">
<string notr="true">Alt+X</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonUseUnicodeProperties">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Use unicode properties &lt;span style=&quot; color:#888a85;&quot;&gt;%1&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;span style=&quot; color:#888a85;&quot;&gt;The meaning of the \w, \d, etc., character classes, as well as the meaning of their counterparts (\W, \D, etc.), is changed from matching ASCII characters only to matching any character with the corresponding Unicode property. For instance, \d is changed to match any character with the Unicode Nd (decimal digit) property; \w to match any character with either the Unicode L (letter) or N (digit) property, plus underscore, and so on. This option corresponds to the /u modifier in Perl regular expressions.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string notr="true">U</string>
</property>
<property name="shortcut">
<string>Alt+U</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget> </widget>
</item> </item>
<item> <item>
@ -52,17 +225,17 @@
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>Find Previous</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Find Previous &lt;span style=&quot; color:#888a85;&quot;&gt;%1&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="text"> <property name="text">
<string notr="true">...</string> <string notr="true">...</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset theme="go-previous"> <iconset theme="go-up">
<normaloff>../../tape</normaloff>../../tape</iconset> <normaloff>.</normaloff>.</iconset>
</property> </property>
<property name="shortcut"> <property name="shortcut">
<string>Ctrl+Shift+G</string> <string>Shift+F3</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -72,17 +245,17 @@
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>Find Next</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Find Next %1&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="text"> <property name="text">
<string notr="true">...</string> <string notr="true">...</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset theme="go-next"> <iconset theme="go-down">
<normaloff>../../tape</normaloff>../../tape</iconset> <normaloff>.</normaloff>.</iconset>
</property> </property>
<property name="shortcut"> <property name="shortcut">
<string>Ctrl+G</string> <string>F3</string>
</property> </property>
<property name="autoExclusive"> <property name="autoExclusive">
<bool>false</bool> <bool>false</bool>
@ -136,8 +309,14 @@
</layout> </layout>
</widget> </widget>
<tabstops> <tabstops>
<tabstop>lineEditFind</tabstop>
<tabstop>pushButtonSearch</tabstop>
<tabstop>toolButtonCaseSensitive</tabstop>
<tabstop>toolButtonWholeWord</tabstop>
<tabstop>toolButtonRegexp</tabstop>
<tabstop>toolButtonFindPrevious</tabstop>
<tabstop>toolButtonFindNext</tabstop>
<tabstop>tableWidget</tabstop> <tabstop>tableWidget</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops> </tabstops>
<resources> <resources>
<include location="../../../libs/vmisc/share/resources/icon.qrc"/> <include location="../../../libs/vmisc/share/resources/icon.qrc"/>

View File

@ -61,12 +61,8 @@ DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *par
data(data), data(data),
doc(doc), doc(doc),
m_completeData(doc->GetCompleteData()), m_completeData(doc->GetCompleteData()),
formulaBaseHeight(0), m_searchHistory(new QMenu(this)),
formulaBaseHeightPC(0), m_searchHistoryPC(new QMenu(this))
search(),
searchPC(),
hasChanges(false),
renameList()
{ {
ui->setupUi(this); ui->setupUi(this);
@ -75,15 +71,13 @@ DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *par
#endif #endif
ui->lineEditName->setClearButtonEnabled(true); ui->lineEditName->setClearButtonEnabled(true);
ui->lineEditFind->setClearButtonEnabled(true);
ui->lineEditNamePC->setClearButtonEnabled(true); ui->lineEditNamePC->setClearButtonEnabled(true);
ui->lineEditFindPC->setClearButtonEnabled(true);
ui->lineEditFind->installEventFilter(this); ui->lineEditFind->installEventFilter(this);
ui->lineEditFindPC->installEventFilter(this); ui->lineEditFindPC->installEventFilter(this);
search = QSharedPointer<VTableSearch>(new VTableSearch(ui->tableWidgetIncrement)); m_search = QSharedPointer<VTableSearch>(new VTableSearch(ui->tableWidgetIncrement));
searchPC = QSharedPointer<VTableSearch>(new VTableSearch(ui->tableWidgetPC)); m_searchPC = QSharedPointer<VTableSearch>(new VTableSearch(ui->tableWidgetPC));
formulaBaseHeight = ui->plainTextEditFormula->height(); formulaBaseHeight = ui->plainTextEditFormula->height();
ui->plainTextEditFormula->installEventFilter(this); ui->plainTextEditFormula->installEventFilter(this);
@ -137,34 +131,10 @@ DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *par
connect(ui->plainTextEditDescriptionPC, &QPlainTextEdit::textChanged, this, &DialogIncrements::SaveIncrDescription); connect(ui->plainTextEditDescriptionPC, &QPlainTextEdit::textChanged, this, &DialogIncrements::SaveIncrDescription);
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogIncrements::SaveIncrFormula); connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogIncrements::SaveIncrFormula);
connect(ui->plainTextEditFormulaPC, &QPlainTextEdit::textChanged, this, &DialogIncrements::SaveIncrFormula); connect(ui->plainTextEditFormulaPC, &QPlainTextEdit::textChanged, this, &DialogIncrements::SaveIncrFormula);
connect(ui->lineEditFind, &QLineEdit::textEdited, this, [this](const QString &term){search->Find(term);});
connect(ui->lineEditFindPC, &QLineEdit::textEdited, this, [this](const QString &term){searchPC->Find(term);});
connect(ui->toolButtonFindPrevious, &QToolButton::clicked, this, [this](){search->FindPrevious();});
connect(ui->toolButtonFindPreviousPC, &QToolButton::clicked, this, [this](){searchPC->FindPrevious();});
connect(ui->toolButtonFindNext, &QToolButton::clicked, this, [this](){search->FindNext();});
connect(ui->toolButtonFindNextPC, &QToolButton::clicked, this, [this](){searchPC->FindNext();});
connect(ui->pushButtonRefresh, &QPushButton::clicked, this, &DialogIncrements::RefreshPattern); connect(ui->pushButtonRefresh, &QPushButton::clicked, this, &DialogIncrements::RefreshPattern);
connect(ui->pushButtonRefreshPC, &QPushButton::clicked, this, &DialogIncrements::RefreshPattern); connect(ui->pushButtonRefreshPC, &QPushButton::clicked, this, &DialogIncrements::RefreshPattern);
connect(search.data(), &VTableSearch::HasResult, this, [this] (bool state) InitSearch();
{
ui->toolButtonFindPrevious->setEnabled(state);
});
connect(searchPC.data(), &VTableSearch::HasResult, this, [this] (bool state)
{
ui->toolButtonFindPreviousPC->setEnabled(state);
});
connect(search.data(), &VTableSearch::HasResult, this, [this] (bool state)
{
ui->toolButtonFindNext->setEnabled(state);
});
connect(searchPC.data(), &VTableSearch::HasResult, this, [this] (bool state)
{
ui->toolButtonFindNextPC->setEnabled(state);
});
if (ui->tableWidgetIncrement->rowCount() > 0) if (ui->tableWidgetIncrement->rowCount() > 0)
{ {
@ -627,8 +597,8 @@ void DialogIncrements::LocalUpdateTree()
ui->tableWidgetPC->selectRow(row); ui->tableWidgetPC->selectRow(row);
ui->tableWidgetPC->blockSignals(false); ui->tableWidgetPC->blockSignals(false);
search->RefreshList(ui->lineEditFind->text()); m_search->RefreshList(ui->lineEditFind->text());
searchPC->RefreshList(ui->lineEditFindPC->text()); m_searchPC->RefreshList(ui->lineEditFindPC->text());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -813,6 +783,344 @@ void DialogIncrements::AddNewIncrement(IncrementType type)
table->repaint(); // Force repain to fix paint artifacts on Mac OS X table->repaint(); // Force repain to fix paint artifacts on Mac OS X
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogIncrements::InitSearch()
{
VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings();
m_search->SetUseUnicodePreperties(settings->GetIncrementsSearchOptionUseUnicodeProperties());
m_search->SetMatchWord(settings->GetIncrementsSearchOptionWholeWord());
m_search->SetMatchRegexp(settings->GetIncrementsSearchOptionRegexp());
m_search->SetMatchCase(settings->GetIncrementsSearchOptionMatchCase());
m_searchPC->SetUseUnicodePreperties(settings->GetPreviewCalculationsSearchOptionUseUnicodeProperties());
m_searchPC->SetMatchWord(settings->GetPreviewCalculationsSearchOptionWholeWord());
m_searchPC->SetMatchRegexp(settings->GetPreviewCalculationsSearchOptionRegexp());
m_searchPC->SetMatchCase(settings->GetPreviewCalculationsSearchOptionMatchCase());
ui->lineEditFind->setPlaceholderText(m_search->SearchPlaceholder());
ui->lineEditFindPC->setPlaceholderText(m_searchPC->SearchPlaceholder());
UpdateSearchControlsTooltips();
connect(ui->lineEditFind, &QLineEdit::textEdited, this, [this](const QString &term){m_search->Find(term);});
connect(ui->lineEditFind, &QLineEdit::editingFinished, this, [this]()
{
SaveIncrementsSearchRequest();
InitIncrementsSearchHistory();
m_search->Find(ui->lineEditFind->text());
});
connect(ui->lineEditFindPC, &QLineEdit::textEdited, this, [this](const QString &term){m_searchPC->Find(term);});
connect(ui->lineEditFindPC, &QLineEdit::editingFinished, this, [this]()
{
SavePreviewCalculationsSearchRequest();
InitPreviewCalculationsSearchHistory();
m_searchPC->Find(ui->lineEditFindPC->text());
});
connect(ui->toolButtonFindPrevious, &QToolButton::clicked, this, [this]()
{
SaveIncrementsSearchRequest();
InitPreviewCalculationsSearchHistory();
m_search->FindPrevious();
ui->labelResults->setText(QString("%1/%2").arg(m_search->MatchIndex()+1).arg(m_search->MatchCount()));
});
connect(ui->toolButtonFindPreviousPC, &QToolButton::clicked, this, [this]()
{
SavePreviewCalculationsSearchRequest();
InitPreviewCalculationsSearchHistory();
m_searchPC->FindPrevious();
ui->labelResultsPC->setText(QString("%1/%2").arg(m_searchPC->MatchIndex()+1).arg(m_searchPC->MatchCount()));
});
connect(ui->toolButtonFindNext, &QToolButton::clicked, this, [this]()
{
SaveIncrementsSearchRequest();
InitIncrementsSearchHistory();
m_search->FindNext();
ui->labelResults->setText(QString("%1/%2").arg(m_search->MatchIndex()+1).arg(m_search->MatchCount()));
});
connect(ui->toolButtonFindNextPC, &QToolButton::clicked, this, [this]()
{
SavePreviewCalculationsSearchRequest();
InitPreviewCalculationsSearchHistory();
m_searchPC->FindNext();
ui->labelResultsPC->setText(QString("%1/%2").arg(m_searchPC->MatchIndex()+1).arg(m_searchPC->MatchCount()));
});
connect(m_search.data(), &VTableSearch::HasResult, this, [this] (bool state)
{
ui->toolButtonFindPrevious->setEnabled(state);
ui->toolButtonFindNext->setEnabled(state);
if (state)
{
ui->labelResults->setText(QString("%1/%2").arg(m_search->MatchIndex()+1).arg(m_search->MatchCount()));
}
else
{
ui->labelResults->setText(tr("0 results"));
}
QPalette palette;
if (not state && not ui->lineEditFind->text().isEmpty())
{
palette.setColor(QPalette::Text, Qt::red);
ui->lineEditFind->setPalette(palette);
palette.setColor(QPalette::Active, ui->labelResults->foregroundRole(), Qt::red);
palette.setColor(QPalette::Inactive, ui->labelResults->foregroundRole(), Qt::red);
ui->labelResults->setPalette(palette);
}
else
{
ui->lineEditFind->setPalette(palette);
ui->labelResults->setPalette(palette);
}
});
connect(m_searchPC.data(), &VTableSearch::HasResult, this, [this] (bool state)
{
ui->toolButtonFindPreviousPC->setEnabled(state);
ui->toolButtonFindNextPC->setEnabled(state);
if (state)
{
ui->labelResultsPC->setText(QString("%1/%2").arg(m_searchPC->MatchIndex()+1).arg(m_searchPC->MatchCount()));
}
else
{
ui->labelResultsPC->setText(tr("0 results"));
}
QPalette palette;
if (not state && not ui->lineEditFindPC->text().isEmpty())
{
palette.setColor(QPalette::Text, Qt::red);
ui->lineEditFindPC->setPalette(palette);
palette.setColor(QPalette::Active, ui->labelResultsPC->foregroundRole(), Qt::red);
palette.setColor(QPalette::Inactive, ui->labelResultsPC->foregroundRole(), Qt::red);
ui->labelResultsPC->setPalette(palette);
}
else
{
ui->lineEditFindPC->setPalette(palette);
ui->labelResultsPC->setPalette(palette);
}
});
connect(ui->toolButtonCaseSensitive, &QToolButton::toggled, this, [this](bool checked)
{
m_search->SetMatchCase(checked);
m_search->Find(ui->lineEditFind->text());
ui->lineEditFind->setPlaceholderText(m_search->SearchPlaceholder());
});
connect(ui->toolButtonCaseSensitivePC, &QToolButton::toggled, this, [this](bool checked)
{
m_searchPC->SetMatchCase(checked);
m_searchPC->Find(ui->lineEditFindPC->text());
ui->lineEditFindPC->setPlaceholderText(m_searchPC->SearchPlaceholder());
});
connect(ui->toolButtonWholeWord, &QToolButton::toggled, this, [this](bool checked)
{
m_search->SetMatchWord(checked);
m_search->Find(ui->lineEditFind->text());
ui->lineEditFind->setPlaceholderText(m_search->SearchPlaceholder());
});
connect(ui->toolButtonWholeWordPC, &QToolButton::toggled, this, [this](bool checked)
{
m_searchPC->SetMatchWord(checked);
m_searchPC->Find(ui->lineEditFindPC->text());
ui->lineEditFindPC->setPlaceholderText(m_searchPC->SearchPlaceholder());
});
connect(ui->toolButtonRegexp, &QToolButton::toggled, this, [this](bool checked)
{
m_search->SetMatchRegexp(checked);
if (checked)
{
ui->toolButtonWholeWord->blockSignals(true);
ui->toolButtonWholeWord->setChecked(false);
ui->toolButtonWholeWord->blockSignals(false);
ui->toolButtonWholeWord->setEnabled(false);
ui->toolButtonUseUnicodeProperties->setEnabled(true);
}
else
{
ui->toolButtonWholeWord->setEnabled(true);
ui->toolButtonUseUnicodeProperties->blockSignals(true);
ui->toolButtonUseUnicodeProperties->setChecked(false);
ui->toolButtonUseUnicodeProperties->blockSignals(false);
ui->toolButtonUseUnicodeProperties->setEnabled(false);
}
m_search->Find(ui->lineEditFind->text());
ui->lineEditFind->setPlaceholderText(m_search->SearchPlaceholder());
});
connect(ui->toolButtonRegexpPC, &QToolButton::toggled, this, [this](bool checked)
{
m_searchPC->SetMatchRegexp(checked);
if (checked)
{
ui->toolButtonWholeWordPC->blockSignals(true);
ui->toolButtonWholeWordPC->setChecked(false);
ui->toolButtonWholeWordPC->blockSignals(false);
ui->toolButtonWholeWordPC->setEnabled(false);
ui->toolButtonUseUnicodePropertiesPC->setEnabled(true);
}
else
{
ui->toolButtonWholeWordPC->setEnabled(true);
ui->toolButtonUseUnicodePropertiesPC->blockSignals(true);
ui->toolButtonUseUnicodePropertiesPC->setChecked(false);
ui->toolButtonUseUnicodePropertiesPC->blockSignals(false);
ui->toolButtonUseUnicodePropertiesPC->setEnabled(false);
}
m_searchPC->Find(ui->lineEditFindPC->text());
ui->lineEditFindPC->setPlaceholderText(m_searchPC->SearchPlaceholder());
});
connect(ui->toolButtonUseUnicodeProperties, &QToolButton::toggled, this, [this](bool checked)
{
m_search->SetUseUnicodePreperties(checked);
m_search->Find(ui->lineEditFind->text());
});
connect(ui->toolButtonUseUnicodePropertiesPC, &QToolButton::toggled, this, [this](bool checked)
{
m_searchPC->SetUseUnicodePreperties(checked);
m_searchPC->Find(ui->lineEditFindPC->text());
});
m_searchHistory->setStyleSheet(QStringLiteral("QMenu { menu-scrollable: 1; }"));
m_searchHistoryPC->setStyleSheet(QStringLiteral("QMenu { menu-scrollable: 1; }"));
InitIncrementsSearchHistory();
InitPreviewCalculationsSearchHistory();
ui->pushButtonSearch->setMenu(m_searchHistory);
ui->pushButtonSearchPC->setMenu(m_searchHistoryPC);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogIncrements::InitIncrementsSearchHistory()
{
QStringList searchHistory = VAbstractValApplication::VApp()->ValentinaSettings()->GetIncrementsSearchHistory();
m_searchHistory->clear();
for (const auto& term : searchHistory)
{
QAction *action = m_searchHistory->addAction(term);
action->setData(term);
connect(action, &QAction::triggered, this, [this]()
{
auto *action = qobject_cast<QAction *>(sender());
if (action != nullptr)
{
QString term = action->data().toString();
ui->lineEditFind->setText(term);
m_search->Find(term);
ui->lineEditFind->setFocus();
}
});
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogIncrements::InitPreviewCalculationsSearchHistory()
{
QStringList searchHistory =
VAbstractValApplication::VApp()->ValentinaSettings()->GetPreviewCalculationsSearchHistory();
m_searchHistoryPC->clear();
for (const auto& term : searchHistory)
{
QAction *action = m_searchHistoryPC->addAction(term);
action->setData(term);
connect(action, &QAction::triggered, this, [this]()
{
auto *action = qobject_cast<QAction *>(sender());
if (action != nullptr)
{
QString term = action->data().toString();
ui->lineEditFindPC->setText(term);
m_searchPC->Find(term);
ui->lineEditFindPC->setFocus();
}
});
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogIncrements::SaveIncrementsSearchRequest()
{
QStringList searchHistory = VAbstractValApplication::VApp()->ValentinaSettings()->GetIncrementsSearchHistory();
QString term = ui->lineEditFind->text();
if (term.isEmpty())
{
return;
}
searchHistory.removeAll(term);
searchHistory.prepend(term);
while (searchHistory.size() > VTableSearch::MaxHistoryRecords)
{
searchHistory.removeLast();
}
VAbstractValApplication::VApp()->ValentinaSettings()->SetIncrementsSearchHistory(searchHistory);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogIncrements::SavePreviewCalculationsSearchRequest()
{
QStringList searchHistory = VAbstractValApplication::VApp()->ValentinaSettings()->GetPreviewCalculationsSearchHistory();
QString term = ui->lineEditFindPC->text();
if (term.isEmpty())
{
return;
}
searchHistory.removeAll(term);
searchHistory.prepend(term);
while (searchHistory.size() > VTableSearch::MaxHistoryRecords)
{
searchHistory.removeLast();
}
VAbstractValApplication::VApp()->ValentinaSettings()->SetPreviewCalculationsSearchHistory(searchHistory);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogIncrements::UpdateSearchControlsTooltips()
{
auto UpdateToolTip = [](QAbstractButton *button)
{
button->setToolTip(button->toolTip().arg(button->shortcut().toString(QKeySequence::NativeText)));
};
UpdateToolTip(ui->toolButtonCaseSensitive);
UpdateToolTip(ui->toolButtonWholeWord);
UpdateToolTip(ui->toolButtonRegexp);
UpdateToolTip(ui->toolButtonUseUnicodeProperties);
UpdateToolTip(ui->pushButtonSearch);
UpdateToolTip(ui->toolButtonFindPrevious);
UpdateToolTip(ui->toolButtonFindNext);
UpdateToolTip(ui->toolButtonCaseSensitivePC);
UpdateToolTip(ui->toolButtonWholeWordPC);
UpdateToolTip(ui->toolButtonRegexpPC);
UpdateToolTip(ui->toolButtonUseUnicodePropertiesPC);
UpdateToolTip(ui->pushButtonSearchPC);
UpdateToolTip(ui->toolButtonFindPreviousPC);
UpdateToolTip(ui->toolButtonFindNextPC);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief FullUpdateFromFile update information in tables form file * @brief FullUpdateFromFile update information in tables form file
@ -841,8 +1149,8 @@ void DialogIncrements::FullUpdateFromFile()
FillRadiusesArcs(); FillRadiusesArcs();
FillAnglesCurves(); FillAnglesCurves();
search->RefreshList(ui->lineEditFind->text()); m_search->RefreshList(ui->lineEditFind->text());
searchPC->RefreshList(ui->lineEditFindPC->text()); m_searchPC->RefreshList(ui->lineEditFindPC->text());
ui->tableWidgetIncrement->selectRow(incrementRow); ui->tableWidgetIncrement->selectRow(incrementRow);
ui->tableWidgetPC->selectRow(pcRow); ui->tableWidgetPC->selectRow(pcRow);
@ -1412,6 +1720,18 @@ void DialogIncrements::closeEvent(QCloseEvent *event)
disconnect(this->doc, &VPattern::FullUpdateFromFile, this, &DialogIncrements::FullUpdateFromFile); disconnect(this->doc, &VPattern::FullUpdateFromFile, this, &DialogIncrements::FullUpdateFromFile);
VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings();
settings->SetIncrementsSearchOptionMatchCase(m_search->IsMatchCase());
settings->SetIncrementsSearchOptionWholeWord(m_search->IsMatchWord());
settings->SetIncrementsSearchOptionRegexp(m_search->IsMatchRegexp());
settings->SetIncrementsSearchOptionUseUnicodeProperties(m_search->IsUseUnicodePreperties());
settings->SetPreviewCalculationsSearchOptionMatchCase(m_searchPC->IsMatchCase());
settings->SetPreviewCalculationsSearchOptionWholeWord(m_searchPC->IsMatchWord());
settings->SetPreviewCalculationsSearchOptionRegexp(m_searchPC->IsMatchRegexp());
settings->SetPreviewCalculationsSearchOptionUseUnicodeProperties(m_searchPC->IsUseUnicodePreperties());
emit UpdateProperties(); emit UpdateProperties();
emit DialogClosed(QDialog::Accepted); emit DialogClosed(QDialog::Accepted);
event->accept(); event->accept();
@ -1428,6 +1748,10 @@ void DialogIncrements::changeEvent(QEvent *event)
ui->toolButtonAdd->setMenu(InitVarTypeMenu(ui->toolButtonAdd->menu(), true /*increments tab*/)); ui->toolButtonAdd->setMenu(InitVarTypeMenu(ui->toolButtonAdd->menu(), true /*increments tab*/));
ui->toolButtonAddPC->setMenu(InitVarTypeMenu(ui->toolButtonAddPC->menu(), false /*preview calculations tab*/)); ui->toolButtonAddPC->setMenu(InitVarTypeMenu(ui->toolButtonAddPC->menu(), false /*preview calculations tab*/));
ui->lineEditFind->setPlaceholderText(m_search->SearchPlaceholder());
ui->lineEditFindPC->setPlaceholderText(m_searchPC->SearchPlaceholder());
UpdateSearchControlsTooltips();
FullUpdateFromFile(); FullUpdateFromFile();
} }
// remember to call base class implementation // remember to call base class implementation
@ -1508,6 +1832,8 @@ void DialogIncrements::ShowIncrementDetails()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
DialogIncrements::~DialogIncrements() DialogIncrements::~DialogIncrements()
{ {
ui->lineEditFind->blockSignals(true); // prevents crash
ui->lineEditFindPC->blockSignals(true); // prevents crash
delete ui; delete ui;
} }

View File

@ -96,15 +96,18 @@ private:
/** @brief m_completeData need to show all internal variables */ /** @brief m_completeData need to show all internal variables */
VContainer m_completeData; VContainer m_completeData;
int formulaBaseHeight; int formulaBaseHeight{0};
int formulaBaseHeightPC; int formulaBaseHeightPC{0};
QSharedPointer<VTableSearch> search; QSharedPointer<VTableSearch> m_search{};
QSharedPointer<VTableSearch> searchPC; QSharedPointer<VTableSearch> m_searchPC{};
bool hasChanges; bool hasChanges{false};
QVector<QPair<QString, QString>> renameList; QVector<QPair<QString, QString>> renameList{};
QMenu *m_searchHistory;
QMenu *m_searchHistoryPC;
template <typename T> template <typename T>
void FillTable(const QMap<QString, T> &varTable, QTableWidget *table); void FillTable(const QMap<QString, T> &varTable, QTableWidget *table);
@ -148,6 +151,13 @@ private:
QMenu *InitVarTypeMenu(QMenu *menu, bool incrementTab); QMenu *InitVarTypeMenu(QMenu *menu, bool incrementTab);
void AddNewIncrement(IncrementType type); void AddNewIncrement(IncrementType type);
void InitSearch();
void InitIncrementsSearchHistory();
void InitPreviewCalculationsSearchHistory();
void SaveIncrementsSearchRequest();
void SavePreviewCalculationsSearchRequest();
void UpdateSearchControlsTooltips();
}; };
#endif // DIALOGINCREMENTS_H #endif // DIALOGINCREMENTS_H

View File

@ -51,45 +51,239 @@
<layout class="QVBoxLayout" name="verticalLayout_4"> <layout class="QVBoxLayout" name="verticalLayout_4">
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_4"> <layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="topMargin">
<number>0</number>
</property>
<item> <item>
<widget class="QLabel" name="labelFind"> <widget class="QPushButton" name="pushButtonSearch">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Search history &lt;span style=&quot; color:#888a85;&quot;&gt;%1&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text"> <property name="text">
<string>Find:</string> <string notr="true"/>
</property>
<property name="icon">
<iconset theme="system-search">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="shortcut">
<string>Alt+Down</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLineEdit" name="lineEditFind"> <widget class="QLineEdit" name="lineEditFind">
<property name="toolTip"> <property name="enabled">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Search increments by term. &lt;/p&gt;&lt;p&gt;Prepend &amp;quot;/r/&amp;quot; to the front of the search string to search increments by regex.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <bool>true</bool>
</property> </property>
<property name="placeholderText"> <property name="placeholderText">
<string>Search</string> <string>Search</string>
</property> </property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelResults">
<property name="text">
<string>0 results</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonCaseSensitive">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
</font>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Match Case &lt;span style=&quot; color:#888a85;&quot;&gt;%1&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string notr="true">Cc</string>
</property>
<property name="shortcut">
<string notr="true">Alt+C</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonWholeWord">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Match words &lt;span style=&quot; color:#888a85;&quot;&gt;%1&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string notr="true">W</string>
</property>
<property name="shortcut">
<string notr="true">Alt+W</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonRegexp">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Match with regular expressions &lt;span style=&quot; color:#888a85;&quot;&gt;%1&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string notr="true">.*</string>
</property>
<property name="shortcut">
<string notr="true">Alt+X</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonUseUnicodeProperties">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Use unicode properties &lt;span style=&quot; color:#888a85;&quot;&gt;%1&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;span style=&quot; color:#888a85;&quot;&gt;The meaning of the \w, \d, etc., character classes, as well as the meaning of their counterparts (\W, \D, etc.), is changed from matching ASCII characters only to matching any character with the corresponding Unicode property. For instance, \d is changed to match any character with the Unicode Nd (decimal digit) property; \w to match any character with either the Unicode L (letter) or N (digit) property, plus underscore, and so on. This option corresponds to the /u modifier in Perl regular expressions.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string notr="true">U</string>
</property>
<property name="shortcut">
<string>Alt+U</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QToolButton" name="toolButtonFindPrevious"> <widget class="QToolButton" name="toolButtonFindPrevious">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Find Previous &lt;span style=&quot; color:#888a85;&quot;&gt;%1&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text"> <property name="text">
<string notr="true">...</string> <string notr="true">...</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset theme="go-previous" resource="../../../libs/vmisc/share/resources/theme.qrc"> <iconset theme="go-up">
<normaloff>:/icons/win.icon.theme/16x16/actions/go-previous.png</normaloff>:/icons/win.icon.theme/16x16/actions/go-previous.png</iconset> <normaloff>.</normaloff>.</iconset>
</property>
<property name="shortcut">
<string>Shift+F3</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QToolButton" name="toolButtonFindNext"> <widget class="QToolButton" name="toolButtonFindNext">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Find Next %1&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text"> <property name="text">
<string notr="true">...</string> <string notr="true">...</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset theme="go-next" resource="../../../libs/vmisc/share/resources/theme.qrc"> <iconset theme="go-down">
<normaloff>:/icons/win.icon.theme/16x16/actions/go-next.png</normaloff>:/icons/win.icon.theme/16x16/actions/go-next.png</iconset> <normaloff>.</normaloff>.</iconset>
</property>
<property name="shortcut">
<string>F3</string>
</property>
<property name="autoExclusive">
<bool>false</bool>
</property> </property>
</widget> </widget>
</item> </item>
@ -131,12 +325,12 @@
<attribute name="horizontalHeaderCascadingSectionResizes"> <attribute name="horizontalHeaderCascadingSectionResizes">
<bool>false</bool> <bool>false</bool>
</attribute> </attribute>
<attribute name="horizontalHeaderDefaultSectionSize">
<number>120</number>
</attribute>
<attribute name="horizontalHeaderMinimumSectionSize"> <attribute name="horizontalHeaderMinimumSectionSize">
<number>70</number> <number>70</number>
</attribute> </attribute>
<attribute name="horizontalHeaderDefaultSectionSize">
<number>120</number>
</attribute>
<attribute name="horizontalHeaderShowSortIndicator" stdset="0"> <attribute name="horizontalHeaderShowSortIndicator" stdset="0">
<bool>false</bool> <bool>false</bool>
</attribute> </attribute>
@ -149,12 +343,12 @@
<attribute name="verticalHeaderCascadingSectionResizes"> <attribute name="verticalHeaderCascadingSectionResizes">
<bool>false</bool> <bool>false</bool>
</attribute> </attribute>
<attribute name="verticalHeaderDefaultSectionSize">
<number>25</number>
</attribute>
<attribute name="verticalHeaderMinimumSectionSize"> <attribute name="verticalHeaderMinimumSectionSize">
<number>8</number> <number>8</number>
</attribute> </attribute>
<attribute name="verticalHeaderDefaultSectionSize">
<number>25</number>
</attribute>
<attribute name="verticalHeaderStretchLastSection"> <attribute name="verticalHeaderStretchLastSection">
<bool>false</bool> <bool>false</bool>
</attribute> </attribute>
@ -499,45 +693,239 @@
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_8"> <layout class="QHBoxLayout" name="horizontalLayout_8">
<property name="topMargin">
<number>0</number>
</property>
<item> <item>
<widget class="QLabel" name="labelFind_2"> <widget class="QPushButton" name="pushButtonSearchPC">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Search history &lt;span style=&quot; color:#888a85;&quot;&gt;%1&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text"> <property name="text">
<string>Find:</string> <string notr="true"/>
</property>
<property name="icon">
<iconset theme="system-search">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="shortcut">
<string>Alt+Down</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLineEdit" name="lineEditFindPC"> <widget class="QLineEdit" name="lineEditFindPC">
<property name="toolTip"> <property name="enabled">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Search preview calculations by term. &lt;/p&gt;&lt;p&gt;Prepend &amp;quot;/r/&amp;quot; to the front of the search string to search preview calculations by regex.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <bool>true</bool>
</property> </property>
<property name="placeholderText"> <property name="placeholderText">
<string>Search</string> <string>Search</string>
</property> </property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelResultsPC">
<property name="text">
<string>0 results</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonCaseSensitivePC">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
<weight>75</weight>
<italic>false</italic>
<bold>true</bold>
</font>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Match Case &lt;span style=&quot; color:#888a85;&quot;&gt;%1&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string notr="true">Cc</string>
</property>
<property name="shortcut">
<string notr="true">Alt+C</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonWholeWordPC">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Match words &lt;span style=&quot; color:#888a85;&quot;&gt;%1&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string notr="true">W</string>
</property>
<property name="shortcut">
<string notr="true">Alt+W</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonRegexpPC">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Match with regular expressions &lt;span style=&quot; color:#888a85;&quot;&gt;%1&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string notr="true">.*</string>
</property>
<property name="shortcut">
<string notr="true">Alt+X</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonUseUnicodePropertiesPC">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Use unicode properties &lt;span style=&quot; color:#888a85;&quot;&gt;%1&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;span style=&quot; color:#888a85;&quot;&gt;The meaning of the \w, \d, etc., character classes, as well as the meaning of their counterparts (\W, \D, etc.), is changed from matching ASCII characters only to matching any character with the corresponding Unicode property. For instance, \d is changed to match any character with the Unicode Nd (decimal digit) property; \w to match any character with either the Unicode L (letter) or N (digit) property, plus underscore, and so on. This option corresponds to the /u modifier in Perl regular expressions.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string notr="true">U</string>
</property>
<property name="shortcut">
<string>Alt+U</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_6">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QToolButton" name="toolButtonFindPreviousPC"> <widget class="QToolButton" name="toolButtonFindPreviousPC">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Find Previous &lt;span style=&quot; color:#888a85;&quot;&gt;%1&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text"> <property name="text">
<string notr="true">...</string> <string notr="true">...</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset theme="go-previous" resource="../../../libs/vmisc/share/resources/theme.qrc"> <iconset theme="go-up">
<normaloff>:/icons/win.icon.theme/16x16/actions/go-previous.png</normaloff>:/icons/win.icon.theme/16x16/actions/go-previous.png</iconset> <normaloff>.</normaloff>.</iconset>
</property>
<property name="shortcut">
<string>Shift+F3</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QToolButton" name="toolButtonFindNextPC"> <widget class="QToolButton" name="toolButtonFindNextPC">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Find Next %1&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text"> <property name="text">
<string notr="true">...</string> <string notr="true">...</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset theme="go-next" resource="../../../libs/vmisc/share/resources/theme.qrc"> <iconset theme="go-down">
<normaloff>:/icons/win.icon.theme/16x16/actions/go-next.png</normaloff>:/icons/win.icon.theme/16x16/actions/go-next.png</iconset> <normaloff>.</normaloff>.</iconset>
</property>
<property name="shortcut">
<string>F3</string>
</property>
<property name="autoExclusive">
<bool>false</bool>
</property> </property>
</widget> </widget>
</item> </item>
@ -579,12 +967,12 @@
<attribute name="horizontalHeaderCascadingSectionResizes"> <attribute name="horizontalHeaderCascadingSectionResizes">
<bool>false</bool> <bool>false</bool>
</attribute> </attribute>
<attribute name="horizontalHeaderDefaultSectionSize">
<number>120</number>
</attribute>
<attribute name="horizontalHeaderMinimumSectionSize"> <attribute name="horizontalHeaderMinimumSectionSize">
<number>70</number> <number>70</number>
</attribute> </attribute>
<attribute name="horizontalHeaderDefaultSectionSize">
<number>120</number>
</attribute>
<attribute name="horizontalHeaderShowSortIndicator" stdset="0"> <attribute name="horizontalHeaderShowSortIndicator" stdset="0">
<bool>false</bool> <bool>false</bool>
</attribute> </attribute>
@ -597,12 +985,12 @@
<attribute name="verticalHeaderCascadingSectionResizes"> <attribute name="verticalHeaderCascadingSectionResizes">
<bool>false</bool> <bool>false</bool>
</attribute> </attribute>
<attribute name="verticalHeaderDefaultSectionSize">
<number>25</number>
</attribute>
<attribute name="verticalHeaderMinimumSectionSize"> <attribute name="verticalHeaderMinimumSectionSize">
<number>8</number> <number>8</number>
</attribute> </attribute>
<attribute name="verticalHeaderDefaultSectionSize">
<number>25</number>
</attribute>
<attribute name="verticalHeaderStretchLastSection"> <attribute name="verticalHeaderStretchLastSection">
<bool>false</bool> <bool>false</bool>
</attribute> </attribute>
@ -1208,7 +1596,6 @@
<tabstop>tableWidgetSplines</tabstop> <tabstop>tableWidgetSplines</tabstop>
</tabstops> </tabstops>
<resources> <resources>
<include location="../../../libs/vmisc/share/resources/theme.qrc"/>
<include location="../../../libs/vmisc/share/resources/icon.qrc"/> <include location="../../../libs/vmisc/share/resources/icon.qrc"/>
</resources> </resources>
<connections/> <connections/>

Binary file not shown.

After

Width:  |  Height:  |  Size: 719 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -105,5 +105,8 @@
<file alias="16x16/actions/object-rotate-right.png">icons/win.icon.theme/16x16/actions/object-rotate-right.png</file> <file alias="16x16/actions/object-rotate-right.png">icons/win.icon.theme/16x16/actions/object-rotate-right.png</file>
<file alias="24x24/actions/object-rotate-right.png">icons/win.icon.theme/24x24/actions/object-rotate-right.png</file> <file alias="24x24/actions/object-rotate-right.png">icons/win.icon.theme/24x24/actions/object-rotate-right.png</file>
<file alias="32x32/actions/object-rotate-right.png">icons/win.icon.theme/32x32/actions/object-rotate-right.png</file> <file alias="32x32/actions/object-rotate-right.png">icons/win.icon.theme/32x32/actions/object-rotate-right.png</file>
<file alias="16x16/actions/system-search.png">icons/win.icon.theme/16x16/actions/system-search.png</file>
<file alias="24x24/actions/system-search.png">icons/win.icon.theme/24x24/actions/system-search.png</file>
<file alias="32x32/actions/system-search.png">icons/win.icon.theme/32x32/actions/system-search.png</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@ -36,12 +36,12 @@
#include "../vmisc/def.h" #include "../vmisc/def.h"
const int VTableSearch::MaxHistoryRecords = 10;
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VTableSearch::VTableSearch(QTableWidget *table, QObject *parent) VTableSearch::VTableSearch(QTableWidget *table, QObject *parent)
: QObject(parent), : QObject(parent),
table(table), table(table)
searchIndex(-1),
searchList()
{ {
} }
@ -94,44 +94,94 @@ void VTableSearch::ShowNext(int newIndex)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QList<QTableWidgetItem *> VTableSearch::FindTableItems(const QString& term) auto VTableSearch::FindTableItems(QString term) -> QList<QTableWidgetItem *>
{ {
if (term.isEmpty()) if (term.isEmpty())
{ {
return {}; return {};
} }
if (term.startsWith(QChar('/'))) QRegularExpression::PatternOptions options = QRegularExpression::NoPatternOption;
if (not m_matchCase)
{ {
QRegularExpression qre(QStringLiteral("^/(?<searchType>[^/]+)/(?<searchString>.+)$")); options |= QRegularExpression::CaseInsensitiveOption;
QScopedPointer<QRegularExpressionMatch> match(new QRegularExpressionMatch()); }
if (!term.contains(qre, match.data()))
{
return QList<QTableWidgetItem *>();
}
auto searchType = match->capturedRef(QStringLiteral("searchType")); if (m_matchWord)
auto searchString = match->capturedRef(QStringLiteral("searchString")); {
if (searchType == QChar('r')) options |= QRegularExpression::UseUnicodePropertiesOption;
{ term = "\\b" % term % "\\b";
QString reSearchString = ".*" % searchString % ".*"; }
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
return table->findItems(reSearchString, Qt::MatchRegExp);
#else
return table->findItems(reSearchString, Qt::MatchRegularExpression);
#endif
}
if (m_matchRegexp && m_useUnicodePreperties)
{
options |= QRegularExpression::UseUnicodePropertiesOption;
}
QRegularExpression re(term, options);
if(not re.isValid())
{
return {}; return {};
} }
return table->findItems(term, Qt::MatchContains); QList<QTableWidgetItem *> list;
for (int r=0; r<table->rowCount(); ++r)
{
for (int c=0; c<table->columnCount(); ++c)
{
QTableWidgetItem *cell = table->item(r, c);
if (cell != nullptr)
{
QString text = cell->text();
QRegularExpressionMatch match = re.match(text);
if (match.hasMatch())
{
list.append(cell);
}
}
}
}
return list;
}
//---------------------------------------------------------------------------------------------------------------------
auto VTableSearch::FindCurrentMatchIndex() const -> int
{
if (searchList.isEmpty())
{
return 0;
}
QList<QTableWidgetItem*> selectedItems = table->selectedItems();
if (selectedItems.isEmpty())
{
return 0;
}
QTableWidgetItem* selectedItem = selectedItems.first();
for (int i=0; i<searchList.size(); ++i)
{
QTableWidgetItem* item = searchList.at(i);
if (item->row()>= selectedItem->row() && item->column()>= selectedItem->column())
{
return i;
}
}
return 0;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VTableSearch::Find(const QString &term) void VTableSearch::Find(const QString &term)
{ {
SCASSERT(table != nullptr) if(table == nullptr)
{
return;
}
Clear(); Clear();
@ -144,13 +194,16 @@ void VTableSearch::Find(const QString &term)
item->setBackground(Qt::yellow); item->setBackground(Qt::yellow);
} }
searchIndex = 0; searchIndex = FindCurrentMatchIndex();
QTableWidgetItem *item = searchList.at(searchIndex); QTableWidgetItem *item = searchList.at(searchIndex);
item->setBackground(Qt::red); item->setBackground(Qt::red);
table->scrollToItem(item); table->scrollToItem(item);
emit HasResult(true); emit HasResult(true);
return;
} }
emit HasResult(false);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -191,7 +244,7 @@ void VTableSearch::RemoveRow(int row)
if (row <= indexRow) if (row <= indexRow)
{ {
for (auto item : qAsConst(searchList)) for (auto *item : qAsConst(searchList))
{ {
if (item->row() == row) if (item->row() == row)
{ {
@ -213,7 +266,7 @@ void VTableSearch::AddRow(int row)
if (row <= indexRow) if (row <= indexRow)
{ {
for (auto item : qAsConst(searchList)) for (auto *item : qAsConst(searchList))
{ {
if (item->row() == row) if (item->row() == row)
{ {
@ -232,7 +285,7 @@ void VTableSearch::RefreshList(const QString &term)
if (not searchList.isEmpty()) if (not searchList.isEmpty())
{ {
for (auto item : qAsConst(searchList)) for (auto *item : qAsConst(searchList))
{ {
item->setBackground(Qt::yellow); item->setBackground(Qt::yellow);
} }
@ -257,3 +310,100 @@ void VTableSearch::RefreshList(const QString &term)
emit HasResult(false); emit HasResult(false);
} }
} }
//---------------------------------------------------------------------------------------------------------------------
void VTableSearch::SetMatchCase(bool value)
{
m_matchCase = value;
}
//---------------------------------------------------------------------------------------------------------------------
auto VTableSearch::IsMatchCase() const -> bool
{
return m_matchCase;
}
//---------------------------------------------------------------------------------------------------------------------
void VTableSearch::SetMatchWord(bool value)
{
m_matchWord = value;
}
//---------------------------------------------------------------------------------------------------------------------
auto VTableSearch::IsMatchWord() const -> bool
{
return m_matchWord;
}
//---------------------------------------------------------------------------------------------------------------------
void VTableSearch::SetMatchRegexp(bool value)
{
m_matchRegexp = value;
m_matchWord = false;
if (not m_matchRegexp)
{
m_useUnicodePreperties = false;
}
}
//---------------------------------------------------------------------------------------------------------------------
auto VTableSearch::IsMatchRegexp() const -> bool
{
return m_matchRegexp;
}
//---------------------------------------------------------------------------------------------------------------------
void VTableSearch::SetUseUnicodePreperties(bool value)
{
m_useUnicodePreperties = value;
}
//---------------------------------------------------------------------------------------------------------------------
auto VTableSearch::IsUseUnicodePreperties() const -> bool
{
return m_useUnicodePreperties;
}
//---------------------------------------------------------------------------------------------------------------------
auto VTableSearch::MatchIndex() const -> int
{
return searchIndex;
}
//---------------------------------------------------------------------------------------------------------------------
auto VTableSearch::MatchCount() const -> int
{
return searchList.size();
}
//---------------------------------------------------------------------------------------------------------------------
auto VTableSearch::SearchPlaceholder() const -> QString
{
if (m_matchCase && not m_matchWord && not m_matchRegexp)
{
return tr("Match case");
}
if (not m_matchCase && m_matchWord && not m_matchRegexp)
{
return tr("Words");
}
if (not m_matchCase && m_matchRegexp)
{
return tr("Regex");
}
if (m_matchCase && m_matchWord)
{
return tr("Match case and words");
}
if (m_matchCase && m_matchRegexp)
{
return tr("Match case and regex");
}
return tr("Search");
}

View File

@ -48,6 +48,25 @@ public:
void AddRow(int row); void AddRow(int row);
void RefreshList(const QString &term); void RefreshList(const QString &term);
void SetMatchCase(bool value);
auto IsMatchCase() const -> bool;
void SetMatchWord(bool value);
auto IsMatchWord() const -> bool;
void SetMatchRegexp(bool value);
auto IsMatchRegexp() const -> bool;
void SetUseUnicodePreperties(bool value);
auto IsUseUnicodePreperties() const -> bool;
auto MatchIndex() const -> int;
auto MatchCount() const -> int;
auto SearchPlaceholder() const -> QString;
static const int MaxHistoryRecords;
signals: signals:
void HasResult(bool state); void HasResult(bool state);
@ -55,12 +74,18 @@ private:
Q_DISABLE_COPY(VTableSearch) Q_DISABLE_COPY(VTableSearch)
QTableWidget *table; QTableWidget *table;
int searchIndex; int searchIndex{-1};
QList<QTableWidgetItem *> searchList; QList<QTableWidgetItem *> searchList{};
bool m_matchCase{false};
bool m_matchWord{false};
bool m_matchRegexp{false};
bool m_useUnicodePreperties{false};
void Clear(); void Clear();
void ShowNext(int newIndex); void ShowNext(int newIndex);
QList<QTableWidgetItem *> FindTableItems(const QString& term); auto FindTableItems(QString term) -> QList<QTableWidgetItem *>;
auto FindCurrentMatchIndex() const -> int;
}; };
#endif // VTABLESEARCH_H #endif // VTABLESEARCH_H

View File

@ -93,7 +93,50 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockWidgetToolOptionsActive,
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockWidgetPatternMessagesActive, Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockWidgetPatternMessagesActive,
(QLatin1String("dockWidget/patternMessagesActive"))) (QLatin1String("dockWidget/patternMessagesActive")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternMessagesFontSize, (QLatin1String("font/patternMessagesSize"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPatternMessagesFontSize, (QLatin1String("font/patternMessagesSize")))
}
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchHistoryHistory, (QLatin1String("searchHistory/history")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchHistoryIncrements, (QLatin1String("searchHistory/increments")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchHistoryPreviewCalculations,
(QLatin1String("searchHistory/previewCalculations")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchHistoryFinalMeasurements,
(QLatin1String("searchHistory/finalMeasurements")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsHistoryUseUnicodeProperties,
(QLatin1String("searchOptions/historyUseUnicodeProperties")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsHistoryWholeWord,
(QLatin1String("searchOptions/historyWholeWord")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsHistoryRegexp,
(QLatin1String("searchOptions/historyRegexp")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsHistoryMatchCase,
(QLatin1String("searchOptions/historyMatchCase")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsIncrementsUseUnicodeProperties,
(QLatin1String("searchOptions/incrementsUseUnicodeProperties")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsIncrementsWholeWord,
(QLatin1String("searchOptions/incrementsWholeWord")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsIncrementsRegexp,
(QLatin1String("searchOptions/incrementsRegexp")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsIncrementsMatchCase,
(QLatin1String("searchOptions/incrementsMatchCase")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsPreviewCalculationsUseUnicodeProperties,
(QLatin1String("searchOptions/previewCalculationsUseUnicodeProperties")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsPreviewCalculationsWholeWord,
(QLatin1String("searchOptions/previewCalculationsWholeWord")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsPreviewCalculationsRegexp,
(QLatin1String("searchOptions/previewCalculationsRegexp")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsPreviewCalculationsMatchCase,
(QLatin1String("searchOptions/previewCalculationsMatchCase")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsFinalMeasurementsUseUnicodeProperties,
(QLatin1String("searchOptions/finalMeasurementsUseUnicodeProperties")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsFinalMeasurementsWholeWord,
(QLatin1String("searchOptions/finalMeasurementsWholeWord")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsFinalMeasurementsRegexp,
(QLatin1String("searchOptions/finalMeasurementsRegexp")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingSearchOptionsFinalMeasurementsMatchCase,
(QLatin1String("searchOptions/finalMeasurementsMatchCase")))
} // namespace
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VValentinaSettings::VValentinaSettings(Format format, Scope scope, const QString &organization, const QString &application, VValentinaSettings::VValentinaSettings(Format format, Scope scope, const QString &organization, const QString &application,
@ -653,6 +696,246 @@ void VValentinaSettings::SetDetailExportFormat(qint8 format)
setValue(*settingDetailExportFormat, format); setValue(*settingDetailExportFormat, format);
} }
//---------------------------------------------------------------------------------------------------------------------
auto VValentinaSettings::GetHistorySearchHistory() const -> QStringList
{
return value(*settingSearchHistoryHistory).toStringList();
}
//---------------------------------------------------------------------------------------------------------------------
void VValentinaSettings::SetHistorySearchHistory(const QStringList &history)
{
setValue(*settingSearchHistoryHistory, history);
}
//---------------------------------------------------------------------------------------------------------------------
QStringList VValentinaSettings::GetIncrementsSearchHistory() const
{
return value(*settingSearchHistoryIncrements).toStringList();
}
//---------------------------------------------------------------------------------------------------------------------
void VValentinaSettings::SetIncrementsSearchHistory(const QStringList &history)
{
setValue(*settingSearchHistoryIncrements, history);
}
//---------------------------------------------------------------------------------------------------------------------
QStringList VValentinaSettings::GetPreviewCalculationsSearchHistory() const
{
return value(*settingSearchHistoryPreviewCalculations).toStringList();
}
//---------------------------------------------------------------------------------------------------------------------
void VValentinaSettings::SetPreviewCalculationsSearchHistory(const QStringList &history)
{
setValue(*settingSearchHistoryPreviewCalculations, history);
}
//---------------------------------------------------------------------------------------------------------------------
QStringList VValentinaSettings::GetFinalMeasurementsSearchHistory() const
{
return value(*settingSearchHistoryFinalMeasurements).toStringList();
}
//---------------------------------------------------------------------------------------------------------------------
void VValentinaSettings::SetFinalMeasurementsSearchHistory(const QStringList &history)
{
setValue(*settingSearchHistoryFinalMeasurements, history);
}
//---------------------------------------------------------------------------------------------------------------------
auto VValentinaSettings::GetHistorySearchOptionUseUnicodeProperties() const -> bool
{
return value(*settingSearchOptionsHistoryUseUnicodeProperties, false).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
void VValentinaSettings::SetHistorySearchOptionUseUnicodeProperties(bool value)
{
setValue(*settingSearchOptionsHistoryUseUnicodeProperties, value);
}
//---------------------------------------------------------------------------------------------------------------------
auto VValentinaSettings::GetHistorySearchOptionWholeWord() const -> bool
{
return value(*settingSearchOptionsHistoryWholeWord, false).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
void VValentinaSettings::SetHistorySearchOptionWholeWord(bool value)
{
setValue(*settingSearchOptionsHistoryWholeWord, value);
}
//---------------------------------------------------------------------------------------------------------------------
auto VValentinaSettings::GetHistorySearchOptionRegexp() const -> bool
{
return value(*settingSearchOptionsHistoryRegexp, false).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
void VValentinaSettings::SetHistorySearchOptionRegexp(bool value)
{
setValue(*settingSearchOptionsHistoryRegexp, value);
}
//---------------------------------------------------------------------------------------------------------------------
auto VValentinaSettings::GetHistorySearchOptionMatchCase() const -> bool
{
return value(*settingSearchOptionsHistoryMatchCase, false).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
void VValentinaSettings::SetHistorySearchOptionMatchCase(bool value)
{
setValue(*settingSearchOptionsHistoryMatchCase, value);
}
//---------------------------------------------------------------------------------------------------------------------
auto VValentinaSettings::GetIncrementsSearchOptionUseUnicodeProperties() const -> bool
{
return value(*settingSearchOptionsIncrementsUseUnicodeProperties, false).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
void VValentinaSettings::SetIncrementsSearchOptionUseUnicodeProperties(bool value)
{
setValue(*settingSearchOptionsIncrementsUseUnicodeProperties, value);
}
//---------------------------------------------------------------------------------------------------------------------
auto VValentinaSettings::GetIncrementsSearchOptionWholeWord() const -> bool
{
return value(*settingSearchOptionsIncrementsWholeWord, false).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
void VValentinaSettings::SetIncrementsSearchOptionWholeWord(bool value)
{
setValue(*settingSearchOptionsIncrementsWholeWord, value);
}
//---------------------------------------------------------------------------------------------------------------------
auto VValentinaSettings::GetIncrementsSearchOptionRegexp() const -> bool
{
return value(*settingSearchOptionsIncrementsRegexp, false).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
void VValentinaSettings::SetIncrementsSearchOptionRegexp(bool value)
{
setValue(*settingSearchOptionsIncrementsRegexp, value);
}
//---------------------------------------------------------------------------------------------------------------------
auto VValentinaSettings::GetIncrementsSearchOptionMatchCase() const -> bool
{
return value(*settingSearchOptionsIncrementsMatchCase, false).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
void VValentinaSettings::SetIncrementsSearchOptionMatchCase(bool value)
{
setValue(*settingSearchOptionsIncrementsMatchCase, value);
}
//---------------------------------------------------------------------------------------------------------------------
auto VValentinaSettings::GetPreviewCalculationsSearchOptionUseUnicodeProperties() const -> bool
{
return value(*settingSearchOptionsPreviewCalculationsUseUnicodeProperties, false).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
void VValentinaSettings::SetPreviewCalculationsSearchOptionUseUnicodeProperties(bool value)
{
setValue(*settingSearchOptionsPreviewCalculationsUseUnicodeProperties, value);
}
//---------------------------------------------------------------------------------------------------------------------
auto VValentinaSettings::GetPreviewCalculationsSearchOptionWholeWord() const -> bool
{
return value(*settingSearchOptionsPreviewCalculationsWholeWord, false).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
void VValentinaSettings::SetPreviewCalculationsSearchOptionWholeWord(bool value)
{
setValue(*settingSearchOptionsPreviewCalculationsWholeWord, value);
}
//---------------------------------------------------------------------------------------------------------------------
auto VValentinaSettings::GetPreviewCalculationsSearchOptionRegexp() const -> bool
{
return value(*settingSearchOptionsPreviewCalculationsRegexp, false).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
void VValentinaSettings::SetPreviewCalculationsSearchOptionRegexp(bool value)
{
setValue(*settingSearchOptionsPreviewCalculationsRegexp, value);
}
//---------------------------------------------------------------------------------------------------------------------
auto VValentinaSettings::GetPreviewCalculationsSearchOptionMatchCase() const -> bool
{
return value(*settingSearchOptionsPreviewCalculationsMatchCase, false).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
void VValentinaSettings::SetPreviewCalculationsSearchOptionMatchCase(bool value)
{
setValue(*settingSearchOptionsPreviewCalculationsMatchCase, value);
}
//---------------------------------------------------------------------------------------------------------------------
auto VValentinaSettings::GetFinalMeasurementsSearchOptionUseUnicodeProperties() const -> bool
{
return value(*settingSearchOptionsFinalMeasurementsUseUnicodeProperties, false).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
void VValentinaSettings::SetFinalMeasurementsSearchOptionUseUnicodeProperties(bool value)
{
setValue(*settingSearchOptionsFinalMeasurementsUseUnicodeProperties, value);
}
//---------------------------------------------------------------------------------------------------------------------
auto VValentinaSettings::GetFinalMeasurementsSearchOptionWholeWord() const -> bool
{
return value(*settingSearchOptionsFinalMeasurementsWholeWord, false).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
void VValentinaSettings::SetFinalMeasurementsSearchOptionWholeWord(bool value)
{
setValue(*settingSearchOptionsFinalMeasurementsWholeWord, value);
}
//---------------------------------------------------------------------------------------------------------------------
auto VValentinaSettings::GetFinalMeasurementsSearchOptionRegexp() const -> bool
{
return value(*settingSearchOptionsFinalMeasurementsRegexp, false).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
void VValentinaSettings::SetFinalMeasurementsSearchOptionRegexp(bool value)
{
setValue(*settingSearchOptionsFinalMeasurementsRegexp, value);
}
//---------------------------------------------------------------------------------------------------------------------
auto VValentinaSettings::GetFinalMeasurementsSearchOptionMatchCase() const -> bool
{
return value(*settingSearchOptionsFinalMeasurementsMatchCase, false).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
void VValentinaSettings::SetFinalMeasurementsSearchOptionMatchCase(bool value)
{
setValue(*settingSearchOptionsFinalMeasurementsMatchCase, value);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
template<typename T> template<typename T>
T VValentinaSettings::GetCachedValue(T &cache, const QString &setting, T defValue, T valueMin, T valueMax) const T VValentinaSettings::GetCachedValue(T &cache, const QString &setting, T defValue, T valueMin, T valueMax) const

View File

@ -170,6 +170,66 @@ public:
auto GetDetailExportFormat() const -> qint8; auto GetDetailExportFormat() const -> qint8;
void SetDetailExportFormat(qint8 format); void SetDetailExportFormat(qint8 format);
auto GetHistorySearchHistory() const -> QStringList;
void SetHistorySearchHistory(const QStringList &history);
auto GetIncrementsSearchHistory() const -> QStringList;
void SetIncrementsSearchHistory(const QStringList &history);
auto GetPreviewCalculationsSearchHistory() const -> QStringList;
void SetPreviewCalculationsSearchHistory(const QStringList &history);
auto GetFinalMeasurementsSearchHistory() const -> QStringList;
void SetFinalMeasurementsSearchHistory(const QStringList &history);
auto GetHistorySearchOptionUseUnicodeProperties() const -> bool;
void SetHistorySearchOptionUseUnicodeProperties(bool value);
auto GetHistorySearchOptionWholeWord() const -> bool;
void SetHistorySearchOptionWholeWord(bool value);
auto GetHistorySearchOptionRegexp() const -> bool;
void SetHistorySearchOptionRegexp(bool value);
auto GetHistorySearchOptionMatchCase() const ->bool;
void SetHistorySearchOptionMatchCase(bool value);
auto GetIncrementsSearchOptionUseUnicodeProperties() const -> bool;
void SetIncrementsSearchOptionUseUnicodeProperties(bool value);
auto GetIncrementsSearchOptionWholeWord() const -> bool;
void SetIncrementsSearchOptionWholeWord(bool value);
auto GetIncrementsSearchOptionRegexp() const -> bool;
void SetIncrementsSearchOptionRegexp(bool value);
auto GetIncrementsSearchOptionMatchCase() const ->bool;
void SetIncrementsSearchOptionMatchCase(bool value);
auto GetPreviewCalculationsSearchOptionUseUnicodeProperties() const -> bool;
void SetPreviewCalculationsSearchOptionUseUnicodeProperties(bool value);
auto GetPreviewCalculationsSearchOptionWholeWord() const -> bool;
void SetPreviewCalculationsSearchOptionWholeWord(bool value);
auto GetPreviewCalculationsSearchOptionRegexp() const -> bool;
void SetPreviewCalculationsSearchOptionRegexp(bool value);
auto GetPreviewCalculationsSearchOptionMatchCase() const ->bool;
void SetPreviewCalculationsSearchOptionMatchCase(bool value);
auto GetFinalMeasurementsSearchOptionUseUnicodeProperties() const -> bool;
void SetFinalMeasurementsSearchOptionUseUnicodeProperties(bool value);
auto GetFinalMeasurementsSearchOptionWholeWord() const -> bool;
void SetFinalMeasurementsSearchOptionWholeWord(bool value);
auto GetFinalMeasurementsSearchOptionRegexp() const -> bool;
void SetFinalMeasurementsSearchOptionRegexp(bool value);
auto GetFinalMeasurementsSearchOptionMatchCase() const ->bool;
void SetFinalMeasurementsSearchOptionMatchCase(bool value);
private: private:
Q_DISABLE_COPY(VValentinaSettings) Q_DISABLE_COPY(VValentinaSettings)