Gui: fix Qt warning: QMetaObject::connectSlotsByName: No matching signal for on_findGroup_changed(QString)

do not auto-collapse when search string is empty
set red-ish background if no matching group was found
This commit is contained in:
wmayer
2020-03-15 18:06:58 +01:00
parent 020ba6c1ce
commit 2f46c3fcf0
3 changed files with 23 additions and 6 deletions

View File

@@ -46,6 +46,13 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="quickSearch">
<property name="text" >
<string>Quick search</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="findGroupLE">
<property name="toolTip">

View File

@@ -118,9 +118,6 @@ DlgParameterImp::DlgParameterImp( QWidget* parent, Qt::WindowFlags fl )
this, SLOT(onGroupSelected(QTreeWidgetItem*)));
onGroupSelected(paramGroup->currentItem());
connect(ui->findGroupLE, SIGNAL(textChanged(QString)),
this, SLOT(on_findGroup_changed(QString)));
// setup for function on_findGroup_changed:
// store the current font properties because
// we don't know what style sheet the user uses for FC
@@ -150,7 +147,7 @@ void DlgParameterImp::on_buttonFind_clicked()
finder->show();
}
void DlgParameterImp::on_findGroup_changed(const QString &SearchStr)
void DlgParameterImp::on_findGroupLE_textChanged(const QString &SearchStr)
{
// search for group tree items and highlight found results
@@ -163,7 +160,8 @@ void DlgParameterImp::on_findGroup_changed(const QString &SearchStr)
item->setForeground(0, defaultColor);
ExpandItem = item;
// a group can be nested down to several levels
while (true) {
// do not collapse if the search string is empty
while (!SearchStr.isEmpty()) {
if (!ExpandItem->parent())
break;
else {
@@ -185,6 +183,9 @@ void DlgParameterImp::on_findGroup_changed(const QString &SearchStr)
// search the tree widget
foundList = paramGroup->findItems(SearchStr, Qt::MatchContains | Qt::MatchRecursive);
if (foundList.size() > 0) {
// reset background style sheet
if (!ui->findGroupLE->styleSheet().isEmpty())
ui->findGroupLE->setStyleSheet(QString());
for (QTreeWidgetItem* item : foundList) {
item->setFont(0, boldFont);
item->setForeground(0, Qt::red);
@@ -205,6 +206,15 @@ void DlgParameterImp::on_findGroup_changed(const QString &SearchStr)
}
}
}
else {
// Set red background to indicate no matching
QString styleSheet = QString::fromLatin1(
" QLineEdit {\n"
" background-color: rgb(255,170,255);\n"
" }\n"
);
ui->findGroupLE->setStyleSheet(styleSheet);
}
}
/**

View File

@@ -57,7 +57,7 @@ public:
protected Q_SLOTS:
void onChangeParameterSet(int);
void on_buttonFind_clicked();
void on_findGroup_changed(const QString &SearchStr);
void on_findGroupLE_textChanged(const QString &SearchStr);
void on_buttonSaveToDisk_clicked();
void onGroupSelected(QTreeWidgetItem *);