18 #undef TQT_NO_ASCII_CAST 29 #include <tqcheckbox.h> 30 #include <tqtextview.h> 32 #include <tdelocale.h> 33 #include <kstandarddirs.h> 35 #include <kinputdialog.h> 38 #include "kscoringeditor.h" 43 static TQString toXml(
const TQString& str)
46 uint len = tmp.length();
49 if (tmp[(
int)i] ==
'<') {
50 tmp.replace(i, 1,
"<");
53 }
else if (tmp[(
int)i] ==
'"') {
54 tmp.replace(i, 1,
""");
57 }
else if (tmp[(
int)i] ==
'&') {
58 tmp.replace(i, 1,
"&");
61 }
else if (tmp[(
int)i] ==
'>') {
62 tmp.replace(i, 1,
">");
75 NotifyDialog* NotifyDialog::me = 0;
76 NotifyDialog::NotesMap NotifyDialog::dict;
78 NotifyDialog::NotifyDialog(TQWidget* p)
79 : KDialogBase(p,
"notify action dialog",true,
"Notify Message",Close,Close,true)
81 TQFrame *f = makeMainWidget();
82 TQVBoxLayout *topL =
new TQVBoxLayout(f);
83 note =
new TQLabel(f);
84 note->setTextFormat(RichText);
85 topL->addWidget(note);
86 TQCheckBox *check =
new TQCheckBox(i18n(
"Do not show this message again"),f);
87 check->setChecked(
true);
88 topL->addWidget(check);
89 connect(check,TQT_SIGNAL(toggled(
bool)),TQT_SLOT(slotShowAgainToggled(
bool)));
92 void NotifyDialog::slotShowAgainToggled(
bool flag)
94 dict.replace(msg,!flag);
95 kdDebug(5100) <<
"note \"" << note <<
"\" will popup again: " << flag << endl;
98 void NotifyDialog::display(ScorableArticle& a,
const TQString& s)
100 kdDebug(5100) <<
"displaying message" << endl;
101 if (!me) me =
new NotifyDialog();
104 NotesMap::Iterator i = dict.find(s);
105 if (i == dict.end() || i.data()) {
106 TQString msg = i18n(
"Article\n<b>%1</b><br><b>%2</b><br>caused the following" 107 " note to appear:<br>%3").
111 me->note->setText(msg);
112 if ( i == dict.end() ) i = dict.replace(s,
false);
120 ScorableArticle::~ScorableArticle()
124 void ScorableArticle::displayMessage(
const TQString& note)
126 NotifyDialog::display(*
this,note);
130 ScorableGroup::~ScorableGroup()
135 ActionBase::ActionBase()
137 kdDebug(5100) <<
"new Action " <<
this << endl;
140 ActionBase::~ActionBase()
142 kdDebug(5100) <<
"delete Action " <<
this << endl;
146 TQStringList ActionBase::userNames()
149 l << userName(SETSCORE);
150 l << userName(NOTIFY);
151 l << userName(COLOR);
152 l << userName(MARKASREAD);
156 ActionBase* ActionBase::factory(
int type,
const TQString &value)
159 case SETSCORE:
return new ActionSetScore(value);
160 case NOTIFY:
return new ActionNotify(value);
161 case COLOR:
return new ActionColor(value);
162 case MARKASREAD:
return new ActionMarkAsRead();
164 kdWarning(5100) <<
"unknown type " << type <<
" in ActionBase::factory()" << endl;
169 TQString ActionBase::userName(
int type)
172 case SETSCORE:
return i18n(
"Adjust Score");
173 case NOTIFY:
return i18n(
"Display Message");
174 case COLOR:
return i18n(
"Colorize Header");
175 case MARKASREAD:
return i18n(
"Mark As Read");
177 kdWarning(5100) <<
"unknown type " << type <<
" in ActionBase::userName()" << endl;
182 int ActionBase::getTypeForName(
const TQString& name)
184 if (name ==
"SETSCORE")
return SETSCORE;
185 else if (name ==
"NOTIFY")
return NOTIFY;
186 else if (name ==
"COLOR")
return COLOR;
187 else if (name ==
"MARKASREAD")
return MARKASREAD;
189 kdWarning(5100) <<
"unknown type string " << name
190 <<
" in ActionBase::getTypeForName()" << endl;
195 int ActionBase::getTypeForUserName(
const TQString& name)
197 if (name == userName(SETSCORE))
return SETSCORE;
198 else if (name == userName(NOTIFY))
return NOTIFY;
199 else if (name == userName(COLOR))
return COLOR;
200 else if ( name == userName(MARKASREAD) )
return MARKASREAD;
202 kdWarning(5100) <<
"unknown type string " << name
203 <<
" in ActionBase::getTypeForUserName()" << endl;
209 ActionSetScore::ActionSetScore(
short v)
214 ActionSetScore::ActionSetScore(
const TQString& s)
219 ActionSetScore::ActionSetScore(
const ActionSetScore& as)
225 ActionSetScore::~ActionSetScore()
229 TQString ActionSetScore::toString()
const 232 a +=
"<Action type=\"SETSCORE\" value=\"" + TQString::number(val) +
"\" />";
236 void ActionSetScore::apply(ScorableArticle& a)
const 241 ActionSetScore* ActionSetScore::clone()
const 243 return new ActionSetScore(*
this);
247 ActionColor::ActionColor(
const TQColor& c)
252 ActionColor::ActionColor(
const TQString& s)
258 ActionColor::ActionColor(
const ActionColor& a)
263 ActionColor::~ActionColor()
266 TQString ActionColor::toString()
const 269 a +=
"<Action type=\"COLOR\" value=\"" + toXml(color.name()) +
"\" />";
273 void ActionColor::apply(ScorableArticle& a)
const 275 a.changeColor(color);
278 ActionColor* ActionColor::clone()
const 280 return new ActionColor(*
this);
285 ActionNotify::ActionNotify(
const TQString& s)
290 ActionNotify::ActionNotify(
const ActionNotify& an)
296 TQString ActionNotify::toString()
const 298 return "<Action type=\"NOTIFY\" value=\"" + toXml(note) +
"\" />";
301 void ActionNotify::apply(ScorableArticle& a)
const 303 a.displayMessage(note);
306 ActionNotify* ActionNotify::clone()
const 308 return new ActionNotify(*
this);
313 ActionMarkAsRead::ActionMarkAsRead() :
318 ActionMarkAsRead::ActionMarkAsRead(
const ActionMarkAsRead &action ) :
324 TQString ActionMarkAsRead::toString()
const 326 return "<Action type=\"MARKASREAD\"/>";
329 void ActionMarkAsRead::apply( ScorableArticle &article )
const 331 article.markAsRead();
334 ActionMarkAsRead* ActionMarkAsRead::clone()
const 336 return new ActionMarkAsRead(*
this);
340 NotifyCollection::NotifyCollection()
342 notifyList.setAutoDelete(
true);
345 NotifyCollection::~NotifyCollection()
349 void NotifyCollection::addNote(
const ScorableArticle& a,
const TQString& note)
351 article_list *l = notifyList.find(note);
353 notifyList.insert(note,
new article_list);
354 l = notifyList.find(note);
358 i.subject = a.subject();
362 TQString NotifyCollection::collection()
const 364 TQString notifyCollection = i18n(
"<h1>List of collected notes</h1>");
365 notifyCollection +=
"<p><ul>";
367 TQDictIterator<article_list> it(notifyList);
368 for(;it.current();++it) {
369 const TQString& note = it.currentKey();
370 notifyCollection +=
"<li>" + note +
"<ul>";
371 article_list* alist = it.current();
372 article_list::Iterator ait;
373 for(ait = alist->begin(); ait != alist->end(); ++ait) {
374 notifyCollection +=
"<li><b>From: </b>" + (*ait).from +
"<br>";
375 notifyCollection +=
"<b>Subject: </b>" + (*ait).subject;
377 notifyCollection +=
"</ul>";
379 notifyCollection +=
"</ul>";
381 return notifyCollection;
384 void NotifyCollection::displayCollection(TQWidget *p)
const 387 KDialogBase *dlg =
new KDialogBase( p, 0,
false, i18n(
"Collected Notes"),
388 KDialogBase::Close, KDialogBase::Close );
389 TQTextView *text =
new TQTextView(dlg);
390 text->setText(collection());
391 dlg->setMainWidget(text);
392 dlg->setMinimumWidth(300);
393 dlg->setMinimumHeight(300);
398 KScoringExpression::KScoringExpression(
const TQString& h,
const TQString& t,
const TQString& n,
const TQString& ng)
399 : header(h), expr_str(n)
403 expr.setPattern(expr_str);
404 expr.setCaseSensitive(
false);
406 else if ( t ==
"MATCHCS" ) {
408 expr.setPattern( expr_str );
409 expr.setCaseSensitive(
true );
411 else if (t ==
"CONTAINS" ) cond = CONTAINS;
412 else if (t ==
"EQUALS" ) cond = EQUALS;
413 else if (t ==
"GREATER") {
415 expr_int = expr_str.toInt();
417 else if (t ==
"SMALLER") {
419 expr_int = expr_str.toInt();
422 kdDebug(5100) <<
"unknown match type in new expression" << endl;
426 c_header = header.latin1();
428 kdDebug(5100) <<
"new expr: " << c_header <<
" " << t <<
" " 429 << expr_str <<
" " << neg << endl;
433 int KScoringExpression::getConditionForName(
const TQString& s)
435 if (s == getNameForCondition(CONTAINS))
return CONTAINS;
436 else if (s == getNameForCondition(MATCH))
return MATCH;
437 else if (s == getNameForCondition(MATCHCS))
return MATCHCS;
438 else if (s == getNameForCondition(EQUALS))
return EQUALS;
439 else if (s == getNameForCondition(SMALLER))
return SMALLER;
440 else if (s == getNameForCondition(GREATER))
return GREATER;
442 kdWarning(5100) <<
"unknown condition name " << s
443 <<
" in KScoringExpression::getConditionForName()" << endl;
449 TQString KScoringExpression::getNameForCondition(
int cond)
452 case CONTAINS:
return i18n(
"Contains Substring");
453 case MATCH:
return i18n(
"Matches Regular Expression");
454 case MATCHCS:
return i18n(
"Matches Regular Expression (Case Sensitive)");
455 case EQUALS:
return i18n(
"Is Exactly the Same As");
456 case SMALLER:
return i18n(
"Less Than");
457 case GREATER:
return i18n(
"Greater Than");
459 kdWarning(5100) <<
"unknown condition " << cond
460 <<
" in KScoringExpression::getNameForCondition()" << endl;
466 TQStringList KScoringExpression::conditionNames()
469 l << getNameForCondition(CONTAINS);
470 l << getNameForCondition(MATCH);
471 l << getNameForCondition(MATCHCS);
472 l << getNameForCondition(EQUALS);
473 l << getNameForCondition(SMALLER);
474 l << getNameForCondition(GREATER);
479 TQStringList KScoringExpression::headerNames()
483 l.append(
"Message-ID");
486 l.append(
"References");
487 l.append(
"NNTP-Posting-Host");
494 KScoringExpression::~KScoringExpression()
498 bool KScoringExpression::match(ScorableArticle& a)
const 504 if (header ==
"From")
506 else if (header ==
"Subject")
509 head = a.getHeaderByType(c_header);
511 if (!head.isEmpty()) {
514 res = (head.lower() == expr_str.lower());
517 res = (head.lower().find(expr_str.lower()) >= 0);
521 res = (expr.search(head)!=-1);
524 res = (head.toInt() > expr_int);
527 res = (head.toInt() < expr_int);
530 kdDebug(5100) <<
"unknown match" << endl;
536 return (neg)?!res:res;
539 void KScoringExpression::write(TQTextStream& st)
const 544 TQString KScoringExpression::toString()
const 552 e +=
"<Expression neg=\"" + TQString::number(neg?1:0)
553 +
"\" header=\"" + header
554 +
"\" type=\"" + getTypeString()
555 +
"\" expr=\"" + toXml(expr_str)
561 TQString KScoringExpression::getTypeString()
const 563 return KScoringExpression::getTypeString(cond);
566 TQString KScoringExpression::getTypeString(
int cond)
569 case CONTAINS:
return "CONTAINS";
570 case MATCH:
return "MATCH";
571 case MATCHCS:
return "MATCHCS";
572 case EQUALS:
return "EQUALS";
573 case SMALLER:
return "SMALLER";
574 case GREATER:
return "GREATER";
576 kdWarning(5100) <<
"unknown cond " << cond <<
" in KScoringExpression::getTypeString()" << endl;
581 int KScoringExpression::getType()
const 587 KScoringRule::KScoringRule(
const TQString& n )
590 expressions.setAutoDelete(
true);
591 actions.setAutoDelete(
true);
594 KScoringRule::KScoringRule(
const KScoringRule& r)
596 kdDebug(5100) <<
"copying rule " << r.getName() << endl;
598 expressions.setAutoDelete(
true);
599 actions.setAutoDelete(
true);
602 const ScoreExprList& rexpr = r.expressions;
603 TQPtrListIterator<KScoringExpression> it(rexpr);
604 for ( ; it.current(); ++it ) {
605 KScoringExpression *t =
new KScoringExpression(**it);
606 expressions.append(t);
610 const ActionList& ract = r.actions;
611 TQPtrListIterator<ActionBase> ait(ract);
612 for ( ; ait.current(); ++ait ) {
614 actions.append(t->clone());
622 KScoringRule::~KScoringRule()
628 void KScoringRule::cleanExpressions()
634 void KScoringRule::cleanActions()
640 void KScoringRule::addExpression( KScoringExpression* expr)
642 kdDebug(5100) <<
"KScoringRule::addExpression" << endl;
643 expressions.append(expr);
646 void KScoringRule::addAction(
int type,
const TQString& val)
648 ActionBase *action = ActionBase::factory(type,val);
654 kdDebug(5100) <<
"KScoringRule::addAction() " << a->toString() << endl;
658 void KScoringRule::setLinkMode(
const TQString& l)
660 if (l ==
"OR") link = OR;
664 void KScoringRule::setExpire(
const TQString& e)
667 TQStringList l = TQStringList::split(
"-",e);
668 Q_ASSERT( l.count() == 3 );
669 expires.setYMD( (*(l.at(0))).toInt(),
670 (*(l.at(1))).toInt(),
671 (*(l.at(2))).toInt());
673 kdDebug(5100) <<
"Rule " << getName() <<
" expires at " << getExpireDateString() << endl;
676 bool KScoringRule::matchGroup(
const TQString& group)
const 678 for(GroupList::ConstIterator i=groups.begin(); i!=groups.end();++i) {
680 if (e.search(group, 0) != -1 &&
681 (uint)e.matchedLength() == group.length())
687 void KScoringRule::applyAction(ScorableArticle& a)
const 689 TQPtrListIterator<ActionBase> it(actions);
690 for(; it.current(); ++it) {
691 it.current()->apply(a);
695 void KScoringRule::applyRule(ScorableArticle& a)
const 701 bool oper_and = (link == AND);
703 TQPtrListIterator<KScoringExpression> it(expressions);
705 for (; it.current(); ++it) {
706 Q_ASSERT( it.current() );
707 res = it.current()->match(a);
708 if (!res && oper_and)
return;
709 else if (res && !oper_and)
break;
711 if (res) applyAction(a);
714 void KScoringRule::applyRule(ScorableArticle& a ,
const TQString& g)
const 717 for (TQStringList::ConstIterator i = groups.begin(); i != groups.end(); ++i) {
718 if (TQRegExp(*i).search(g) != -1) {
725 void KScoringRule::write(TQTextStream& s)
const 730 TQString KScoringRule::toString()
const 734 r +=
"<Rule name=\"" + toXml(name) +
"\" linkmode=\"" + getLinkModeName();
735 r +=
"\" expires=\"" + getExpireDateString() +
"\">";
737 for(GroupList::ConstIterator i=groups.begin();i!=groups.end();++i) {
738 r +=
"<Group name=\"" + toXml(*i) +
"\" />";
741 TQPtrListIterator<KScoringExpression> eit(expressions);
742 for (; eit.current(); ++eit) {
743 r += eit.current()->toString();
746 TQPtrListIterator<ActionBase> ait(actions);
747 for (; ait.current(); ++ait) {
748 r += ait.current()->toString();
755 TQString KScoringRule::getLinkModeName()
const 758 case AND:
return "AND";
759 case OR:
return "OR";
760 default:
return "AND";
764 TQString KScoringRule::getExpireDateString()
const 766 if (expires.isNull())
return "never";
768 return TQString::number(expires.year()) + TQString(
"-")
769 + TQString::number(expires.month()) + TQString(
"-")
770 + TQString::number(expires.day());
774 bool KScoringRule::isExpired()
const 776 return (expires.isValid() && (expires < TQDate::currentDate()));
782 KScoringManager::KScoringManager(
const TQString& appName)
785 allRules.setAutoDelete(
true);
787 if(appName.isEmpty())
788 mFilename = TDEGlobal::dirs()->saveLocation(
"appdata") +
"/scorefile";
790 mFilename = TDEGlobal::dirs()->saveLocation(
"data") +
"/" + appName +
"/scorefile";
796 KScoringManager::~KScoringManager()
800 void KScoringManager::load()
802 TQDomDocument sdoc(
"Scorefile");
803 TQFile f( mFilename );
804 if ( !f.open( IO_ReadOnly ) )
806 if ( !sdoc.setContent( &f ) ) {
808 kdDebug(5100) <<
"loading the scorefile failed" << endl;
812 kdDebug(5100) <<
"loaded the scorefile, creating internal representation" << endl;
814 createInternalFromXML(sdoc);
816 kdDebug(5100) <<
"ready, got " << allRules.count() <<
" rules" << endl;
819 void KScoringManager::save()
821 kdDebug(5100) <<
"KScoringManager::save() starts" << endl;
822 TQFile f( mFilename );
823 if ( !f.open( IO_WriteOnly ) )
825 TQTextStream stream(&f);
826 stream.setEncoding(TQTextStream::Unicode);
827 kdDebug(5100) <<
"KScoringManager::save() creating xml" << endl;
828 createXMLfromInternal().save(stream,2);
829 kdDebug(5100) <<
"KScoringManager::save() finished" << endl;
832 TQDomDocument KScoringManager::createXMLfromInternal()
836 TQDomDocument sdoc(
"Scorefile");
838 ss +=
"<?xml version = '1.0'?><!DOCTYPE Scorefile >";
840 ss +=
"</Scorefile>\n";
841 kdDebug(5100) <<
"KScoringManager::createXMLfromInternal():" << endl << ss << endl;
846 TQString KScoringManager::toString()
const 849 s +=
"<Scorefile>\n";
850 TQPtrListIterator<KScoringRule> it(allRules);
851 for( ; it.current(); ++it) {
852 s += it.current()->toString();
857 void KScoringManager::expireRules()
859 for ( KScoringRule *cR = allRules.first(); cR; cR=allRules.next()) {
860 if (cR->isExpired()) {
861 kdDebug(5100) <<
"Rule " << cR->getName() <<
" is expired, deleting it" << endl;
867 void KScoringManager::createInternalFromXML(TQDomNode n)
869 static KScoringRule *cR = 0;
872 kdDebug(5100) <<
"inspecting node of type " << n.nodeType()
873 <<
" named " << n.toElement().tagName() << endl;
875 switch (n.nodeType()) {
876 case TQDomNode::DocumentNode: {
880 case TQDomNode::ElementNode: {
882 TQDomElement e = n.toElement();
885 TQString s = e.tagName();
887 cR =
new KScoringRule(e.attribute(
"name"));
888 cR->setLinkMode(e.attribute(
"linkmode"));
889 cR->setExpire(e.attribute(
"expires"));
892 else if (s ==
"Group") {
894 cR->addGroup( e.attribute(
"name") );
896 else if (s ==
"Expression") {
897 cR->addExpression(
new KScoringExpression(e.attribute(
"header"),
900 e.attribute(
"neg")));
902 else if (s ==
"Action") {
904 cR->addAction(ActionBase::getTypeForName(e.attribute(
"type")),
905 e.attribute(
"value"));
912 TQDomNodeList nodelist = n.childNodes();
913 unsigned cnt = nodelist.count();
915 for (
unsigned i=0;i<cnt;++i)
916 createInternalFromXML(nodelist.item(i));
920 KScoringRule* KScoringManager::addRule(
const ScorableArticle& a, TQString group,
short score)
922 KScoringRule *rule =
new KScoringRule(findUniqueName());
923 rule->addGroup( group );
925 new KScoringExpression(
"From",
"CONTAINS",
927 if (score) rule->addAction(
new ActionSetScore(score));
928 rule->setExpireDate(TQDate::currentDate().addDays(30));
930 KScoringEditor *edit = KScoringEditor::createEditor(
this);
933 setCacheValid(
false);
937 KScoringRule* KScoringManager::addRule(KScoringRule* expr)
939 int i = allRules.findRef(expr);
942 addRuleInternal(expr);
950 KScoringRule* KScoringManager::addRule()
952 KScoringRule *rule =
new KScoringRule(findUniqueName());
957 void KScoringManager::addRuleInternal(KScoringRule *e)
960 setCacheValid(
false);
962 kdDebug(5100) <<
"KScoringManager::addRuleInternal " << e->getName() << endl;
965 void KScoringManager::cancelNewRule(KScoringRule *r)
968 int i = allRules.findRef(r);
970 kdDebug(5100) <<
"deleting rule " << r->getName() << endl;
974 kdDebug(5100) <<
"rule " << r->getName() <<
" not deleted" << endl;
978 void KScoringManager::setRuleName(KScoringRule *r,
const TQString& s)
982 TQString oldName = r->getName();
985 TQPtrListIterator<KScoringRule> it(allRules);
986 for (; it.current(); ++it) {
987 if ( it.current() != r && it.current()->getName() == text ) {
988 kdDebug(5100) <<
"rule name " << text <<
" is not unique" << endl;
989 text = KInputDialog::getText(i18n(
"Choose Another Rule Name"),
990 i18n(
"The rule name is already assigned, please choose another name:"),
997 if (text != oldName) {
999 emit changedRuleName(oldName,text);
1003 void KScoringManager::deleteRule(KScoringRule *r)
1005 int i = allRules.findRef(r);
1008 emit changedRules();
1012 void KScoringManager::editRule(KScoringRule *e, TQWidget *w)
1014 KScoringEditor *edit = KScoringEditor::createEditor(
this, w);
1020 void KScoringManager::moveRuleAbove( KScoringRule *above, KScoringRule *below )
1022 int aindex = allRules.findRef( above );
1023 int bindex = allRules.findRef( below );
1024 if ( aindex <= 0 || bindex < 0 )
1026 if ( aindex < bindex )
1028 allRules.take( aindex );
1029 allRules.insert( bindex, above );
1032 void KScoringManager::moveRuleBelow( KScoringRule *below, KScoringRule *above )
1034 int bindex = allRules.findRef( below );
1035 int aindex = allRules.findRef( above );
1036 if ( bindex < 0 || bindex >= (
int)allRules.count() - 1 || aindex < 0 )
1038 if ( bindex < aindex )
1040 allRules.take( bindex );
1041 allRules.insert( aindex + 1, below );
1044 void KScoringManager::editorReady()
1046 kdDebug(5100) <<
"emitting signal finishedEditing" << endl;
1048 emit finishedEditing();
1051 KScoringRule* KScoringManager::copyRule(KScoringRule *r)
1053 KScoringRule *rule =
new KScoringRule(*r);
1054 rule->setName(findUniqueName());
1055 addRuleInternal(rule);
1061 kdWarning(5100) <<
"KScoringManager::applyRules(ScorableGroup* ) isn't implemented" << endl;
1064 void KScoringManager::applyRules(ScorableArticle& article,
const TQString& group)
1067 applyRules(article);
1070 void KScoringManager::applyRules(ScorableArticle& a)
1072 TQPtrListIterator<KScoringRule> it(isCacheValid()? ruleList : allRules);
1073 for( ; it.current(); ++it) {
1074 it.current()->applyRule(a);
1078 void KScoringManager::initCache(
const TQString& g)
1082 TQPtrListIterator<KScoringRule> it(allRules);
1083 for (; it.current(); ++it) {
1084 if ( it.current()->matchGroup(group) ) {
1085 ruleList.append(it.current());
1088 kdDebug(5100) <<
"created cache for group " << group
1089 <<
" with " << ruleList.count() <<
" rules" << endl;
1090 setCacheValid(
true);
1093 void KScoringManager::setGroup(
const TQString& g)
1095 if (group != g) initCache(g);
1098 bool KScoringManager::hasRulesForCurrentGroup()
1100 return ruleList.count() != 0;
1104 TQStringList KScoringManager::getRuleNames()
1107 TQPtrListIterator<KScoringRule> it(allRules);
1108 for( ; it.current(); ++it) {
1109 l << it.current()->getName();
1114 KScoringRule* KScoringManager::findRule(
const TQString& ruleName)
1116 TQPtrListIterator<KScoringRule> it(allRules);
1117 for (; it.current(); ++it) {
1118 if ( it.current()->getName() == ruleName ) {
1125 bool KScoringManager::setCacheValid(
bool v)
1127 bool res = cacheValid;
1132 TQString KScoringManager::findUniqueName()
const 1136 bool duplicated=
false;
1138 while (nr < 99999999) {
1140 ret = i18n(
"rule %1").arg(nr);
1143 TQPtrListIterator<KScoringRule> it(allRules);
1144 for( ; it.current(); ++it) {
1145 if (it.current()->getName() == ret) {
1158 bool KScoringManager::hasFeature(
int p)
1161 case ActionBase::SETSCORE:
return canScores();
1162 case ActionBase::NOTIFY:
return canNotes();
1163 case ActionBase::COLOR:
return canColors();
1164 case ActionBase::MARKASREAD:
return canMarkAsRead();
1165 default:
return false;
1169 TQStringList KScoringManager::getDefaultHeaders()
const 1172 l.append(
"Subject");
1175 l.append(
"Message-ID");
1179 void KScoringManager::pushRuleList()
1181 stack.push(allRules);
1184 void KScoringManager::popRuleList()
1186 stack.pop(allRules);
1189 void KScoringManager::removeTOS()
1194 RuleStack::RuleStack()
1198 RuleStack::~RuleStack()
1203 kdDebug(5100) <<
"RuleStack::push pushing list with " << l.count() <<
" rules" << endl;
1204 KScoringManager::ScoringRuleList *l1 =
new KScoringManager::ScoringRuleList;
1205 for ( KScoringRule *r=l.first(); r != 0; r=l.next() ) {
1206 l1->append(
new KScoringRule(*r));
1209 kdDebug(5100) <<
"now there are " << stack.count() <<
" lists on the stack" << endl;
1216 kdDebug(5100) <<
"RuleStack::pop pops list with " << l.count() <<
" rules" << endl;
1217 kdDebug(5100) <<
"now there are " << stack.count() <<
" lists on the stack" << endl;
1223 KScoringManager::ScoringRuleList *l1 = stack.top();
1229 kdDebug(5100) <<
"drop: now there are " << stack.count() <<
" lists on the stack" << endl;
1234 #include "kscoring.moc" void push(TQPtrList< KScoringRule > &)
puts the list on the stack, doesn't change the list
void top(TQPtrList< KScoringRule > &)
like pop but without dropping the TOS
Base class for other Action classes.
The following classes ScorableArticle, ScorableGroup define the interface for the scoring...
void pop(TQPtrList< KScoringRule > &)
clears the argument list and copy the content of the TOS into it after that the TOS gets dropped ...