Crossfire Server, Trunk  R20513
CREFilter.cpp
Go to the documentation of this file.
1 #include "CREFilter.h"
2 #include <QDebug>
3 
5 {
6 }
7 
8 bool CREFilter::showItem(QObject* item)
9 {
10  if (myFilter.isEmpty())
11  return true;
12 
13  QScriptValue engineValue = myEngine.newQObject(item);
14  myEngine.globalObject().setProperty("item", engineValue);
15 
16  myEngine.pushContext();
17  bool show = myEngine.evaluate(myFilter).toBoolean();
18  myEngine.popContext();
19  if (myEngine.hasUncaughtException())
20  {
21  //qDebug() << myEngine.uncaughtException().toString();
22  return false;
23  }
24 
25  return show;
26 }
27 
28 const QString& CREFilter::filter() const
29 {
30  return myFilter;
31 }
32 
33 void CREFilter::setFilter(const QString& filter)
34 {
35  myFilter = filter;
36 }
void setFilter(const QString &filter)
Definition: CREFilter.cpp:33
QString myFilter
Definition: CREFilter.h:19
bool showItem(QObject *item)
Definition: CREFilter.cpp:8
CREScriptEngine myEngine
Definition: CREFilter.h:20
const QString & filter() const
Definition: CREFilter.cpp:28