Commit a8e61e0f authored by Volker Krause's avatar Volker Krause
Browse files

Factor out gadget match implementation for use by other sub-classes

parent efd0220d
......@@ -62,6 +62,11 @@ bool ExtractorDocumentProcessor::matches(const ExtractorFilter &filter, const Ex
// Q_GADGET content
const auto mo = QMetaType(node.content().userType()).metaObject();
return matchesGadget(filter, mo, node.content().constData());
}
bool ExtractorDocumentProcessor::matchesGadget(const ExtractorFilter &filter, const QMetaObject *mo, const void *obj)
{
if (!mo) {
return false;
}
......@@ -70,7 +75,7 @@ bool ExtractorDocumentProcessor::matches(const ExtractorFilter &filter, const Ex
return false;
}
const auto prop = mo->property(propIdx);
const auto value = prop.readOnGadget(node.content().constData());
const auto value = prop.readOnGadget(obj);
return filter.matches(value.toString());
}
......
......@@ -81,6 +81,13 @@ protected:
{
delete static_cast<T*>(node.content<Internal::OwnedPtr<T>>());
}
static bool matchesGadget(const ExtractorFilter &filter, const QMetaObject *mo, const void *obj);
template <typename T>
static inline bool matchesGadget(const ExtractorFilter &filter, const T *obj)
{
return matchesGadget(filter, &T::staticMetaObject, obj);
}
};
}
......
......@@ -83,13 +83,7 @@ bool IcalEventProcessor::matches(const ExtractorFilter &filter, const ExtractorD
{
#ifdef HAVE_KCAL
const auto event = node.content<KCalCore::Event::Ptr>();
const auto propIdx = KCalendarCore::Event::staticMetaObject.indexOfProperty(filter.fieldName().toUtf8().constData());
if (propIdx < 0) {
return false;
}
const auto prop = KCalendarCore::Event::staticMetaObject.property(propIdx);
const auto value = prop.readOnGadget(event.data());
return filter.matches(value.toString());
return matchesGadget(filter, event.data());
#else
return false;
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment