Improve search in Tape app. Provide search not only in selected measurement
description, but in all descriptions. ref #732. --HG-- branch : develop
This commit is contained in:
parent
34ffa5ab51
commit
28044ff4c6
|
@ -315,20 +315,7 @@ void DialogMDataBase::ShowDescription(QTreeWidgetItem *item, int column)
|
|||
return;
|
||||
}
|
||||
|
||||
const QString name = item->data(0, Qt::UserRole).toString();
|
||||
const VTranslateVars *trv = qApp->TrVars();
|
||||
const QString number = trv->MNumber(name);
|
||||
|
||||
const QString text = QString("<p align=\"center\" style=\"font-variant: normal; font-style: normal; font-weight: "
|
||||
"normal\"> %1 <br clear=\"left\"><b>%2</b>. <i>%3</i></p>"
|
||||
"<p align=\"left\" style=\"font-variant: normal; font-style: normal; font-weight: "
|
||||
"normal\">%4</p>")
|
||||
.arg(ImgTag(number))
|
||||
.arg(number)
|
||||
.arg(trv->GuiText(name))
|
||||
.arg(trv->Description(name));
|
||||
|
||||
ui->textEdit->setHtml(text);
|
||||
ui->textEdit->setHtml(ItemFullDescription(item));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -456,10 +443,12 @@ void DialogMDataBase::FilterGroup(QTreeWidgetItem *group, const QString &search)
|
|||
for (int i=0; i < group->childCount(); ++i)
|
||||
{
|
||||
QTreeWidgetItem *childItem = group->child(i);
|
||||
const bool hidden = (not childItem->isSelected()
|
||||
&& not childItem->text(0).contains(search, Qt::CaseInsensitive))
|
||||
|| (childItem->isSelected() && not ui->textEdit->toPlainText().contains(search, Qt::CaseInsensitive)
|
||||
&& not childItem->text(0).contains(search, Qt::CaseInsensitive));
|
||||
const QString description = QTextDocumentFragment::fromHtml(ItemFullDescription(childItem, false))
|
||||
.toPlainText();
|
||||
|
||||
const bool hidden = not childItem->text(0).contains(search, Qt::CaseInsensitive)
|
||||
&& not description.contains(search, Qt::CaseInsensitive);
|
||||
|
||||
childItem->setHidden(hidden);
|
||||
if (not hidden)
|
||||
{
|
||||
|
@ -527,6 +516,40 @@ void DialogMDataBase::WriteSettings()
|
|||
qApp->TapeSettings()->SetDataBaseGeometry(saveGeometry());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString DialogMDataBase::ItemFullDescription(QTreeWidgetItem *item, bool showImage) const
|
||||
{
|
||||
if (item == nullptr || item->childCount() != 0)
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
|
||||
const QString name = item->data(0, Qt::UserRole).toString();
|
||||
if (name.isEmpty())
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
|
||||
const QString number = qApp->TrVars()->MNumber(name);
|
||||
|
||||
QString imgTag;
|
||||
if (showImage)
|
||||
{
|
||||
imgTag = ImgTag(number);
|
||||
}
|
||||
|
||||
const QString text = QString("<p align=\"center\" style=\"font-variant: normal; font-style: normal; font-weight: "
|
||||
"normal\"> %1 <br clear=\"left\"><b>%2</b>. <i>%3</i></p>"
|
||||
"<p align=\"left\" style=\"font-variant: normal; font-style: normal; font-weight: "
|
||||
"normal\">%4</p>")
|
||||
.arg(imgTag)
|
||||
.arg(number)
|
||||
.arg(qApp->TrVars()->GuiText(name))
|
||||
.arg(qApp->TrVars()->Description(name));
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogMDataBase::RetranslateGroup(QTreeWidgetItem *group, const QString &groupText, const QStringList &list)
|
||||
{
|
||||
|
|
|
@ -100,6 +100,8 @@ private:
|
|||
void ReadSettings();
|
||||
void WriteSettings();
|
||||
|
||||
QString ItemFullDescription(QTreeWidgetItem *item, bool showImage = true) const;
|
||||
|
||||
void RetranslateGroup(QTreeWidgetItem *group, const QString &groupText, const QStringList &list);
|
||||
void RetranslateMeasurement(QTreeWidgetItem *group, int index, const QString &name);
|
||||
|
||||
|
|
|
@ -404,12 +404,6 @@ void MApplication::InitOptions()
|
|||
QResource::registerResource(diagramsPath());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
const VTranslateVars *MApplication::TrVars()
|
||||
{
|
||||
return trVars;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void MApplication::InitTrVars()
|
||||
{
|
||||
|
|
|
@ -97,5 +97,11 @@ private:
|
|||
|
||||
void Clean();
|
||||
};
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
inline const VTranslateVars *MApplication::TrVars()
|
||||
{
|
||||
return trVars;
|
||||
}
|
||||
|
||||
#endif // MAPPLICATION_H
|
||||
|
|
Loading…
Reference in New Issue
Block a user