Model filter size and wildcard

This commit is contained in:
Klaus Basan
2019-05-21 15:11:36 +02:00
parent e4dc189004
commit 8749a7176d
2 changed files with 21 additions and 3 deletions

View File

@@ -6,12 +6,18 @@
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<width>800</width>
<height>150</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>700</width>
<height>150</height>
</size>
</property>
<property name="windowTitle">
<string>Dialog</string>
<string>Model filter dialog</string>
</property>
<layout class="QVBoxLayout" name="vl_AircraftModelFilterForm">
<item>

View File

@@ -7,8 +7,11 @@
*/
#include "blackgui/models/modelfilter.h"
#include "blackmisc/logmessage.h"
#include <QtGlobal>
using namespace BlackMisc;
namespace BlackGui
{
namespace Models
@@ -48,8 +51,17 @@ namespace BlackGui
return v.endsWith(filterNoWildcard, cs);
}
// wildcard in middle
if (f.contains('*'))
{
const QStringList parts = v.split('*');
if (parts.size() < 2) { return false; }
const bool s = v.startsWith(parts.front(), cs) && v.endsWith(parts.back());
return s;
}
// should never happen
qFatal("Illegal state");
CLogMessage(this).error(u"Illegal search pattern : '%1'") << f;
return false;
}