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> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>400</width> <width>800</width>
<height>150</height> <height>150</height>
</rect> </rect>
</property> </property>
<property name="minimumSize">
<size>
<width>700</width>
<height>150</height>
</size>
</property>
<property name="windowTitle"> <property name="windowTitle">
<string>Dialog</string> <string>Model filter dialog</string>
</property> </property>
<layout class="QVBoxLayout" name="vl_AircraftModelFilterForm"> <layout class="QVBoxLayout" name="vl_AircraftModelFilterForm">
<item> <item>

View File

@@ -7,8 +7,11 @@
*/ */
#include "blackgui/models/modelfilter.h" #include "blackgui/models/modelfilter.h"
#include "blackmisc/logmessage.h"
#include <QtGlobal> #include <QtGlobal>
using namespace BlackMisc;
namespace BlackGui namespace BlackGui
{ {
namespace Models namespace Models
@@ -48,8 +51,17 @@ namespace BlackGui
return v.endsWith(filterNoWildcard, cs); 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 // should never happen
qFatal("Illegal state"); CLogMessage(this).error(u"Illegal search pattern : '%1'") << f;
return false; return false;
} }