• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

knode

  • sources
  • kde-4.12
  • kdepim
  • knode
kscoring.cpp
Go to the documentation of this file.
1 /*
2  kscoring.cpp
3 
4  Copyright (c) 2001 Mathias Waack <mathias@atoll-net.de>
5  Copyright (C) 2005 by Volker Krause <vkrause@kde.org>
6 
7  Author: Mathias Waack <mathias@atoll-net.de>
8 
9  This program is free software; you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation; either version 2 of the License, or
12  (at your option) any later version.
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software Foundation,
15  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, US
16 */
17 #ifdef KDE_USE_FINAL
18 #undef QT_NO_ASCII_CAST
19 #endif
20 
21 #undef QT_NO_COMPAT
22 
23 #include "kscoring.h"
24 #include "kscoringeditor.h"
25 
26 #include <KDebug>
27 #include <KLocale>
28 #include <KInputDialog>
29 #include <KStandardDirs>
30 #include <KTextEdit>
31 
32 #include <QCheckBox>
33 #include <QDomElement>
34 #include <QDomDocument>
35 #include <QDomNode>
36 #include <QDomNodeList>
37 #include <QFile>
38 #include <QLayout>
39 #include <QLabel>
40 #include <QTextStream>
41 #include <QVBoxLayout>
42 #include <Q3PtrList>
43 
44 #include <iostream>
45 
46 using namespace KPIM;
47 
48 //----------------------------------------------------------------------------
49 // a small function to encode attribute values, code stolen from QDom
50 static QString toXml( const QString &str )
51 {
52  QString tmp(str);
53  uint len = tmp.length();
54  uint i = 0;
55  while ( i < len ) {
56  if ( tmp[(int)i] == '<' ) {
57  tmp.replace( i, 1, "&lt;" );
58  len += 3;
59  i += 4;
60  } else if ( tmp[(int)i] == '"' ) {
61  tmp.replace( i, 1, "&quot;" );
62  len += 5;
63  i += 6;
64  } else if ( tmp[(int)i] == '&' ) {
65  tmp.replace( i, 1, "&amp;" );
66  len += 4;
67  i += 5;
68  } else if ( tmp[(int)i] == '>' ) {
69  tmp.replace( i, 1, "&gt;" );
70  len += 3;
71  i += 4;
72  } else {
73  ++i;
74  }
75  }
76 
77  return tmp;
78 }
79 
80 // small dialog to display the messages from NotifyAction
81 NotifyDialog *NotifyDialog::me = 0;
82 NotifyDialog::NotesMap NotifyDialog::dict;
83 
84 NotifyDialog::NotifyDialog( QWidget *parent )
85  : KDialog( parent )
86 {
87  setCaption( i18n( "Notify Message" ) );
88  setButtons( Close );
89  setDefaultButton( Close );
90  setModal( true );
91 
92  QFrame *f = new QFrame( this );
93  setMainWidget ( f );
94  QVBoxLayout *topL = new QVBoxLayout( f );
95  note = new QLabel( f );
96  note->setTextFormat( Qt::RichText );
97  topL->addWidget( note );
98  QCheckBox *check = new QCheckBox( i18n( "Do not show this message again" ), f );
99  check->setChecked( true );
100  topL->addWidget( check );
101  connect( check, SIGNAL(toggled(bool)), SLOT(slotShowAgainToggled(bool)) );
102 }
103 
104 void NotifyDialog::slotShowAgainToggled( bool flag )
105 {
106  dict.remove( msg );
107  dict.insert( msg, !flag );
108  kDebug(5100) <<"note \"" << note <<"\" will popup again:" << flag;
109 }
110 
111 void NotifyDialog::display( ScorableArticle &a, const QString &s )
112 {
113  kDebug(5100) <<"displaying message";
114  if ( !me ) {
115  me = new NotifyDialog();
116  }
117  me->msg = s;
118 
119  NotesMap::Iterator i = dict.find( s );
120  if ( i == dict.end() || i.value() ) {
121  QString msg =
122  i18n( "Article\n<b>%1</b><br /><b>%2</b><br />caused the following note to appear:<br />%3",
123  a.from(),
124  a.subject(),
125  s );
126  me->note->setText(msg);
127  if ( i == dict.end() ) {
128  dict.remove( s );
129  i = dict.insert( s, false );
130  }
131  me->adjustSize();
132  me->exec();
133  }
134 }
135 
136 //----------------------------------------------------------------------------
137 ScorableArticle::~ScorableArticle()
138 {
139 }
140 
141 void ScorableArticle::displayMessage( const QString &note )
142 {
143  NotifyDialog::display( *this, note );
144 }
145 
146 //----------------------------------------------------------------------------
147 ScorableGroup::~ScorableGroup()
148 {
149 }
150 
151 // the base class for all actions
152 ActionBase::ActionBase()
153 {
154  kDebug(5100) <<"new Action" << this;
155 }
156 
157 ActionBase::~ActionBase()
158 {
159  kDebug(5100) <<"delete Action" << this;
160 }
161 
162 QStringList ActionBase::userNames()
163 {
164  QStringList l;
165  l << userName( SETSCORE );
166  l << userName( NOTIFY );
167  l << userName( COLOR );
168  l << userName( MARKASREAD );
169  return l;
170 }
171 
172 ActionBase *ActionBase::factory( int type, const QString &value )
173 {
174  switch( type ) {
175  case SETSCORE:
176  return new ActionSetScore( value );
177  case NOTIFY:
178  return new ActionNotify( value );
179  case COLOR:
180  return new ActionColor( value );
181  case MARKASREAD:
182  return new ActionMarkAsRead();
183  default:
184  kWarning(5100) <<"unknown type" << type <<" in ActionBase::factory()";
185  return 0;
186  }
187 }
188 
189 QString ActionBase::userName( int type )
190 {
191  switch( type ) {
192  case SETSCORE:
193  return i18n( "Adjust Score" );
194  case NOTIFY:
195  return i18n( "Display Message" );
196  case COLOR:
197  return i18n( "Colorize Header" );
198  case MARKASREAD:
199  return i18n( "Mark as Read" );
200  default:
201  kWarning(5100) <<"unknown type" << type <<" in ActionBase::userName()";
202  return 0;
203  }
204 }
205 
206 int ActionBase::getTypeForName( const QString &name )
207 {
208  if ( name == "SETSCORE" ) {
209  return SETSCORE;
210  } else if ( name == "NOTIFY" ) {
211  return NOTIFY;
212  } else if ( name == "COLOR" ) {
213  return COLOR;
214  } else if ( name == "MARKASREAD" ) {
215  return MARKASREAD;
216  } else {
217  kWarning(5100) <<"unknown type string" << name
218  << "in ActionBase::getTypeForName()";
219  return -1;
220  }
221 }
222 
223 int ActionBase::getTypeForUserName( const QString &name )
224 {
225  if ( name == userName( SETSCORE ) ) {
226  return SETSCORE;
227  } else if ( name == userName( NOTIFY ) ) {
228  return NOTIFY;
229  } else if ( name == userName( COLOR ) ) {
230  return COLOR;
231  } else if ( name == userName( MARKASREAD ) ) {
232  return MARKASREAD;
233  } else {
234  kWarning(5100) <<"unknown type string" << name
235  << "in ActionBase::getTypeForUserName()";
236  return -1;
237  }
238 }
239 
240 // the set score action
241 ActionSetScore::ActionSetScore( short v )
242  : val( v )
243 {
244 }
245 
246 ActionSetScore::ActionSetScore( const QString &s )
247 {
248  val = s.toShort();
249 }
250 
251 ActionSetScore::ActionSetScore( const ActionSetScore &as )
252  : ActionBase(),
253  val( as.val )
254 {
255 }
256 
257 ActionSetScore::~ActionSetScore()
258 {
259 }
260 
261 QString ActionSetScore::toString() const
262 {
263  QString a;
264  a += "<Action type=\"SETSCORE\" value=\"" + QString::number(val) + "\" />";
265  return a;
266 }
267 
268 void ActionSetScore::apply( ScorableArticle &a ) const
269 {
270  a.addScore( val );
271 }
272 
273 ActionSetScore *ActionSetScore::clone() const
274 {
275  return new ActionSetScore( *this );
276 }
277 
278 // the color action
279 ActionColor::ActionColor( const QColor &c )
280  : ActionBase(), color( c )
281 {
282 }
283 
284 ActionColor::ActionColor( const QString &s )
285  : ActionBase()
286 {
287  setValue(s);
288 }
289 
290 ActionColor::ActionColor( const ActionColor &a )
291  : ActionBase(), color( a.color )
292 {
293 }
294 
295 ActionColor::~ActionColor()
296 {}
297 
298 QString ActionColor::toString() const
299 {
300  QString a;
301  a += "<Action type=\"COLOR\" value=\"" + toXml(color.name()) + "\" />";
302  return a;
303 }
304 
305 void ActionColor::apply( ScorableArticle &a ) const
306 {
307  a.changeColor( color );
308 }
309 
310 ActionColor *ActionColor::clone() const
311 {
312  return new ActionColor( *this );
313 }
314 
315 // the notify action
316 ActionNotify::ActionNotify( const QString &s )
317 {
318  note = s;
319 }
320 
321 ActionNotify::ActionNotify( const ActionNotify &an )
322  : ActionBase()
323 {
324  note = an.note;
325 }
326 
327 QString ActionNotify::toString() const
328 {
329  return "<Action type=\"NOTIFY\" value=\"" + toXml(note) + "\" />";
330 }
331 
332 void ActionNotify::apply( ScorableArticle &a ) const
333 {
334  a.displayMessage( note );
335 }
336 
337 ActionNotify *ActionNotify::clone() const
338 {
339  return new ActionNotify( *this );
340 }
341 
342 // mark as read action
343 ActionMarkAsRead::ActionMarkAsRead() :
344  ActionBase()
345 {
346 }
347 
348 ActionMarkAsRead::ActionMarkAsRead( const ActionMarkAsRead &action ) :
349  ActionBase()
350 {
351  Q_UNUSED( action );
352 }
353 
354 QString ActionMarkAsRead::toString() const
355 {
356  return "<Action type=\"MARKASREAD\"/>";
357 }
358 
359 void ActionMarkAsRead::apply( ScorableArticle &article ) const
360 {
361  article.markAsRead();
362 }
363 
364 ActionMarkAsRead *ActionMarkAsRead::clone() const
365 {
366  return new ActionMarkAsRead( *this );
367 }
368 
369 //----------------------------------------------------------------------------
370 NotifyCollection::NotifyCollection()
371 {
372  notifyList.setAutoDelete( true );
373 }
374 
375 NotifyCollection::~NotifyCollection()
376 {
377 }
378 
379 void NotifyCollection::addNote( const ScorableArticle &a, const QString &note )
380 {
381  article_list *l = notifyList.find( note );
382  if ( !l ) {
383  notifyList.insert( note, new article_list );
384  l = notifyList.find( note );
385  }
386  article_info i;
387  i.from = a.from();
388  i.subject = a.subject();
389  l->append(i);
390 }
391 
392 QString NotifyCollection::collection() const
393 {
394  QString notifyCollection = i18n( "<h1>List of collected notes</h1>" );
395  notifyCollection += "<p><ul>";
396  // first look thru the notes and create one string
397  Q3DictIterator<article_list> it(notifyList);
398  for ( ; it.current(); ++it ) {
399  const QString &note = it.currentKey();
400  notifyCollection += "<li>" + note + "<ul>";
401  article_list *alist = it.current();
402  article_list::Iterator ait;
403  for ( ait = alist->begin(); ait != alist->end(); ++ait ) {
404  notifyCollection += "<li><b>From: </b>" + (*ait).from + "<br>";
405  notifyCollection += "<b>Subject: </b>" + (*ait).subject;
406  }
407  notifyCollection += "</ul>";
408  }
409  notifyCollection += "</ul>";
410 
411  return notifyCollection;
412 }
413 
414 void NotifyCollection::displayCollection( QWidget *p ) const
415 {
416  //KMessageBox::information(p,collection(),i18n("Collected Notes"));
417  KDialog *dlg = new KDialog( p );
418  dlg->setCaption( i18n( "Collected Notes" ) );
419  dlg->setButtons( KDialog::Close );
420  dlg->setDefaultButton( KDialog::Close );
421  dlg->setModal( false );
422  KTextEdit *text = new KTextEdit( dlg );
423  text->setReadOnly( true );
424  text->setText( collection() );
425  dlg->setMainWidget( text );
426  dlg->setMinimumWidth( 300 );
427  dlg->setMinimumHeight( 300 );
428  dlg->show();
429 }
430 
431 //----------------------------------------------------------------------------
432 KScoringExpression::KScoringExpression( const QString &h, const QString &t,
433  const QString &n, const QString &ng )
434  : header( h ), expr_str( n )
435 {
436  if ( t == "MATCH" ) {
437  cond = MATCH;
438  expr.setPattern( expr_str );
439  expr.setCaseSensitivity( Qt::CaseInsensitive );
440  } else if ( t == "MATCHCS" ) {
441  cond = MATCHCS;
442  expr.setPattern( expr_str );
443  expr.setCaseSensitivity( Qt::CaseSensitive );
444  } else if ( t == "CONTAINS" ) {
445  cond = CONTAINS;
446  } else if ( t == "EQUALS" ) {
447  cond = EQUALS;
448  } else if ( t == "GREATER" ) {
449  cond = GREATER;
450  expr_int = expr_str.toInt();
451  } else if ( t == "SMALLER" ) {
452  cond = SMALLER;
453  expr_int = expr_str.toInt();
454  } else {
455  kDebug(5100) <<"unknown match type in new expression";
456  }
457 
458  neg = ng.toInt();
459 
460  kDebug(5100) <<"new expr:" << header << t
461  << expr_str << neg;
462 }
463 
464 // static
465 int KScoringExpression::getConditionForName( const QString &s )
466 {
467  if ( s == getNameForCondition( CONTAINS ) ) {
468  return CONTAINS;
469  } else if ( s == getNameForCondition( MATCH ) ) {
470  return MATCH;
471  } else if ( s == getNameForCondition( MATCHCS ) ) {
472  return MATCHCS;
473  } else if ( s == getNameForCondition( EQUALS ) ) {
474  return EQUALS;
475  } else if ( s == getNameForCondition( SMALLER ) ) {
476  return SMALLER;
477  } else if ( s == getNameForCondition( GREATER ) ) {
478  return GREATER;
479  } else {
480  kWarning(5100) <<"unknown condition name" << s
481  << "in KScoringExpression::getConditionForName()";
482  return -1;
483  }
484 }
485 
486 // static
487 QString KScoringExpression::getNameForCondition( int cond )
488 {
489  switch ( cond ) {
490  case CONTAINS:
491  return i18n( "Contains Substring" );
492  case MATCH:
493  return i18n( "Matches Regular Expression" );
494  case MATCHCS:
495  return i18n( "Matches Regular Expression (Case Sensitive)" );
496  case EQUALS:
497  return i18n( "Is Exactly the Same As" );
498  case SMALLER:
499  return i18n( "Less Than" );
500  case GREATER:
501  return i18n( "Greater Than" );
502  default:
503  kWarning(5100) <<"unknown condition" << cond
504  << "in KScoringExpression::getNameForCondition()";
505  return "";
506  }
507 }
508 
509 // static
510 QStringList KScoringExpression::conditionNames()
511 {
512  QStringList l;
513  l << getNameForCondition( CONTAINS );
514  l << getNameForCondition( MATCH );
515  l << getNameForCondition( MATCHCS );
516  l << getNameForCondition( EQUALS );
517  l << getNameForCondition( SMALLER );
518  l << getNameForCondition( GREATER );
519  return l;
520 }
521 
522 // static
523 QStringList KScoringExpression::headerNames()
524 {
525  QStringList l;
526  l.append( "From" );
527  l.append( "Message-ID" );
528  l.append( "Subject" );
529  l.append( "Date" );
530  l.append( "References" );
531  l.append( "NNTP-Posting-Host" );
532  l.append( "Bytes" );
533  l.append( "Lines" );
534  l.append( "Xref" );
535  return l;
536 }
537 
538 KScoringExpression::~KScoringExpression()
539 {
540 }
541 
542 bool KScoringExpression::match( ScorableArticle &a ) const
543 {
544  bool res = true;
545  QString head;
546 
547  if ( header == "From" ) {
548  head = a.from();
549  } else if ( header == "Subject" ) {
550  head = a.subject();
551  } else {
552  head = a.getHeaderByType( header );
553  }
554 
555  if ( !head.isEmpty() ) {
556  switch( cond ) {
557  case EQUALS:
558  res = ( head.toLower() == expr_str.toLower() );
559  break;
560  case CONTAINS:
561  res = ( head.toLower().indexOf( expr_str.toLower() ) >= 0 );
562  break;
563  case MATCH:
564  case MATCHCS:
565  res = ( expr.indexIn( head ) != -1 );
566  break;
567  case GREATER:
568  res = ( head.toInt() > expr_int );
569  break;
570  case SMALLER:
571  res = ( head.toInt() < expr_int );
572  break;
573  default:
574  kDebug(5100) <<"unknown match";
575  res = false;
576  }
577  } else {
578  res = false;
579  }
580 
581  return neg ? !res : res;
582 }
583 
584 void KScoringExpression::write( QTextStream &st ) const
585 {
586  st << toString();
587 }
588 
589 QString KScoringExpression::toString() const
590 {
591  QString e;
592  e += "<Expression neg=\"" + QString::number( neg ? 1 : 0 ) +
593  "\" header=\"" + header +
594  "\" type=\"" + getTypeString() +
595  "\" expr=\"" + toXml(expr_str) +
596  "\" />";
597 
598  return e;
599 }
600 
601 QString KScoringExpression::getTypeString() const
602 {
603  return KScoringExpression::getTypeString(cond);
604 }
605 
606 QString KScoringExpression::getTypeString( int cond )
607 {
608  switch( cond ) {
609  case CONTAINS:
610  return "CONTAINS";
611  case MATCH:
612  return "MATCH";
613  case MATCHCS:
614  return "MATCHCS";
615  case EQUALS:
616  return "EQUALS";
617  case SMALLER:
618  return "SMALLER";
619  case GREATER:
620  return "GREATER";
621  default:
622  kWarning(5100) <<"unknown cond" << cond
623  <<" in KScoringExpression::getTypeString()";
624  return "";
625  }
626 }
627 
628 int KScoringExpression::getType() const
629 {
630  return cond;
631 }
632 
633 //----------------------------------------------------------------------------
634 KScoringRule::KScoringRule( const QString &n )
635  : name( n ), link( AND )
636 {
637  expressions.setAutoDelete( true );
638  actions.setAutoDelete( true );
639 }
640 
641 KScoringRule::KScoringRule( const KScoringRule &r )
642 {
643  kDebug(5100) <<"copying rule" << r.getName();
644  name = r.getName();
645  expressions.setAutoDelete( true );
646  actions.setAutoDelete( true );
647  // copy expressions
648  expressions.clear();
649  const ScoreExprList &rexpr = r.expressions;
650  Q3PtrListIterator<KScoringExpression> it( rexpr );
651  for ( ; it.current(); ++it ) {
652  KScoringExpression *t = new KScoringExpression( **it );
653  expressions.append( t );
654  }
655  // copy actions
656  actions.clear();
657  const ActionList &ract = r.actions;
658  Q3PtrListIterator<ActionBase> ait( ract );
659  for ( ; ait.current(); ++ait ) {
660  ActionBase *t = *ait;
661  actions.append( t->clone() );
662  }
663  // copy groups, servers, linkmode and expires
664  groups = r.groups;
665  expires = r.expires;
666  link = r.link;
667 }
668 
669 KScoringRule::~KScoringRule()
670 {
671  cleanExpressions();
672  cleanActions();
673 }
674 
675 void KScoringRule::cleanExpressions()
676 {
677  // the expressions is setAutoDelete(true)
678  expressions.clear();
679 }
680 
681 void KScoringRule::cleanActions()
682 {
683  // the actions is setAutoDelete(true)
684  actions.clear();
685 }
686 
687 void KScoringRule::addExpression( KScoringExpression *expr )
688 {
689  kDebug(5100) <<"KScoringRule::addExpression";
690  expressions.append(expr);
691 }
692 
693 void KScoringRule::addAction( int type, const QString &val )
694 {
695  ActionBase *action = ActionBase::factory( type, val );
696  addAction( action );
697 }
698 
699 void KScoringRule::addAction( ActionBase *a )
700 {
701  kDebug(5100) <<"KScoringRule::addAction()" << a->toString();
702  actions.append(a);
703 }
704 
705 void KScoringRule::setLinkMode( const QString &l )
706 {
707  if ( l == "OR" ) {
708  link = OR;
709  } else {
710  link = AND;
711  }
712 }
713 
714 void KScoringRule::setExpire( const QString &e )
715 {
716  if ( e != "never" ) {
717  QStringList l = e.split( '-', QString::SkipEmptyParts );
718  Q_ASSERT( l.count() == 3 );
719  expires.setYMD( l.at(0).toInt(), l.at(1).toInt(), l.at(2).toInt() );
720  }
721  kDebug(5100) <<"Rule" << getName() <<" expires at" << getExpireDateString();
722 }
723 
724 bool KScoringRule::matchGroup( const QString &group ) const
725 {
726  for ( GroupList::ConstIterator i = groups.begin(); i != groups.end(); ++i ) {
727  QRegExp e( *i );
728  if ( e.indexIn( group, 0 ) != -1 && e.matchedLength() == group.length() ) {
729  return true;
730  }
731  }
732  return false;
733 }
734 
735 void KScoringRule::applyAction( ScorableArticle &a ) const
736 {
737  Q3PtrListIterator<ActionBase> it( actions );
738  for ( ; it.current(); ++it ) {
739  it.current()->apply( a );
740  }
741 }
742 
743 void KScoringRule::applyRule( ScorableArticle &a ) const
744 {
745  bool oper_and = ( link == AND );
746  bool res = true;
747  Q3PtrListIterator<KScoringExpression> it( expressions );
748 
749  for ( ; it.current(); ++it ) {
750  Q_ASSERT( it.current() );
751  res = it.current()->match( a );
752  if ( !res && oper_and ) {
753  return;
754  } else if ( res && !oper_and ) {
755  break;
756  }
757  }
758  if ( res ) {
759  applyAction( a );
760  }
761 }
762 
763 void KScoringRule::applyRule( ScorableArticle &a, const QString &g ) const
764 {
765  // check if one of the groups match
766  for ( QStringList::ConstIterator i = groups.begin(); i != groups.end(); ++i ) {
767  if ( QRegExp( *i ).indexIn( g ) != -1 ) {
768  applyRule( a );
769  return;
770  }
771  }
772 }
773 
774 void KScoringRule::write( QTextStream &s ) const
775 {
776  s << toString();
777 }
778 
779 QString KScoringRule::toString() const
780 {
781  QString r;
782  r += "<Rule name=\"" + toXml(name) + "\" linkmode=\"" + getLinkModeName();
783  r += "\" expires=\"" + getExpireDateString() + "\">";
784 
785  for ( GroupList::ConstIterator i = groups.begin(); i != groups.end(); ++i ) {
786  r += "<Group name=\"" + toXml(*i) + "\" />";
787  }
788 
789  Q3PtrListIterator<KScoringExpression> eit(expressions);
790  for ( ; eit.current(); ++eit ) {
791  r += eit.current()->toString();
792  }
793 
794  Q3PtrListIterator<ActionBase> ait(actions);
795  for ( ; ait.current(); ++ait ) {
796  r += ait.current()->toString();
797  }
798  r += "</Rule>";
799  return r;
800 }
801 
802 QString KScoringRule::getLinkModeName() const
803 {
804  switch( link ) {
805  case AND:
806  return "AND";
807  case OR:
808  return "OR";
809  default:
810  return "AND";
811  }
812 }
813 
814 QString KScoringRule::getExpireDateString() const
815 {
816  if ( expires.isNull() ) {
817  return "never";
818  } else {
819  return
820  QString::number( expires.year() ) + QString( '-' ) +
821  QString::number( expires.month() ) + QString( '-' ) +
822  QString::number( expires.day() );
823  }
824 }
825 
826 bool KScoringRule::isExpired() const
827 {
828  return
829  expires.isValid() &&
830  ( expires < QDate::currentDate() );
831 }
832 
833 //----------------------------------------------------------------------------
834 KScoringManager::KScoringManager( const QString &appName )
835  : cacheValid( false )
836 {
837  allRules.setAutoDelete( true );
838  // determine filename of the scorefile
839  if ( appName.isEmpty() ) {
840  mFilename = KGlobal::dirs()->saveLocation( "appdata" ) + "/scorefile";
841  } else {
842  mFilename = KGlobal::dirs()->saveLocation( "data" ) + '/' + appName + "/scorefile";
843  }
844  // open the score file
845  load();
846 }
847 
848 KScoringManager::~KScoringManager()
849 {
850 }
851 
852 void KScoringManager::load()
853 {
854  QDomDocument sdoc( "Scorefile" );
855  QFile f( mFilename );
856  if ( !f.open( QIODevice::ReadOnly ) ) {
857  return;
858  }
859  if ( !sdoc.setContent( &f ) ) {
860  f.close();
861  kDebug(5100) <<"loading the scorefile failed";
862  return;
863  }
864  f.close();
865  kDebug(5100) <<"loaded the scorefile, creating internal representation";
866  allRules.clear();
867  createInternalFromXML( sdoc );
868  expireRules();
869  kDebug(5100) <<"ready, got" << allRules.count() <<" rules";
870 }
871 
872 void KScoringManager::save()
873 {
874  kDebug(5100) <<"KScoringManager::save() starts";
875  QFile f( mFilename );
876  if ( !f.open( QIODevice::WriteOnly ) ) {
877  return;
878  }
879  QTextStream stream( &f );
880  stream.setCodec( "UTF-8" );
881  kDebug(5100) <<"KScoringManager::save() creating xml";
882  createXMLfromInternal().save( stream, 2 );
883  kDebug(5100) <<"KScoringManager::save() finished";
884 }
885 
886 QDomDocument KScoringManager::createXMLfromInternal()
887 {
888  // I was'nt able to create a QDomDocument in memory:(
889  // so I write the content into a string, which is really stupid
890  QDomDocument sdoc( "Scorefile" );
891  QString ss; // scorestring
892  ss += "<?xml version = '1.0'?><!DOCTYPE Scorefile >";
893  ss += toString();
894  ss += "</Scorefile>\n";
895  kDebug(5100) <<"KScoringManager::createXMLfromInternal():" << endl << ss;
896  sdoc.setContent(ss);
897  return sdoc;
898 }
899 
900 QString KScoringManager::toString() const
901 {
902  QString s;
903  s += "<Scorefile>\n";
904  Q3PtrListIterator<KScoringRule> it( allRules );
905  for ( ; it.current(); ++it ) {
906  s += it.current()->toString();
907  }
908  return s;
909 }
910 
911 void KScoringManager::expireRules()
912 {
913  for ( KScoringRule *cR = allRules.first(); cR; cR=allRules.next() ) {
914  if ( cR->isExpired() ) {
915  kDebug(5100) <<"Rule" << cR->getName() <<" is expired, deleting it";
916  allRules.remove();
917  }
918  }
919 }
920 
921 void KScoringManager::createInternalFromXML( QDomNode n )
922 {
923  static KScoringRule *cR = 0; // the currentRule
924  // the XML file was parsed and now we simply traverse the resulting tree
925  if ( !n.isNull() ) {
926  kDebug(5100) <<"inspecting node of type" << n.nodeType()
927  << "named" << n.toElement().tagName();
928 
929  switch ( n.nodeType() ) {
930  case QDomNode::DocumentNode:
931  {
932  // the document itself
933  break;
934  }
935  case QDomNode::ElementNode:
936  {
937  // Server, Newsgroup, Rule, Expression, Action
938  QDomElement e = n.toElement();
939  QString s = e.tagName();
940  if ( s == "Rule" ) {
941  cR = new KScoringRule( e.attribute( "name" ) );
942  cR->setLinkMode( e.attribute( "linkmode" ) );
943  cR->setExpire( e.attribute( "expires" ) );
944  addRuleInternal( cR );
945  } else if ( s == "Group" ) {
946  Q_CHECK_PTR( cR );
947  cR->addGroup( e.attribute( "name" ) );
948  } else if ( s == "Expression" ) {
949  cR->addExpression( new KScoringExpression( e.attribute( "header" ),
950  e.attribute( "type" ),
951  e.attribute( "expr" ),
952  e.attribute( "neg" ) ) );
953  } else if ( s == "Action" ) {
954  Q_CHECK_PTR( cR );
955  cR->addAction( ActionBase::getTypeForName( e.attribute( "type" ) ),
956  e.attribute( "value" ) );
957  }
958  break;
959  }
960  default:
961  ;
962  }
963  QDomNodeList nodelist = n.childNodes();
964  int cnt = nodelist.count();
965  for ( int i=0; i<cnt; ++i ) {
966  createInternalFromXML( nodelist.item( i ) );
967  }
968  }
969 }
970 
971 KScoringRule *KScoringManager::addRule( const ScorableArticle &a,
972  const QString &group, short score )
973 {
974  KScoringRule *rule = new KScoringRule( findUniqueName() );
975  rule->addGroup( group );
976  rule->addExpression( new KScoringExpression( "From","CONTAINS", a.from(), "0" ) );
977  if ( score ) {
978  rule->addAction( new ActionSetScore( score ) );
979  }
980  rule->setExpireDate( QDate::currentDate().addDays( 30 ) );
981  KScoringEditor *edit = KScoringEditor::createEditor( this );
982  // Note: the call to createEditor() call this->pushRuleList(). So addRule(KScoringRule)
983  // must be place after it, otherwise the cancel button of the editor is not effective (bug #101092).
984  addRule( rule );
985  edit->setRule( rule );
986  edit->show();
987  setCacheValid( false );
988  return rule;
989 }
990 
991 KScoringRule *KScoringManager::addRule( KScoringRule *expr )
992 {
993  int i = allRules.findRef( expr );
994  if ( i == -1 ) {
995  // only add a rule we don't know
996  addRuleInternal( expr );
997  } else {
998  emit changedRules();
999  }
1000  return expr;
1001 }
1002 
1003 KScoringRule *KScoringManager::addRule()
1004 {
1005  KScoringRule *rule = new KScoringRule( findUniqueName() );
1006  addRule( rule );
1007  return rule;
1008 }
1009 
1010 void KScoringManager::addRuleInternal( KScoringRule *e )
1011 {
1012  allRules.append( e ) ;
1013  setCacheValid( false );
1014  emit changedRules();
1015  kDebug(5100) <<"KScoringManager::addRuleInternal" << e->getName();
1016 }
1017 
1018 void KScoringManager::cancelNewRule( KScoringRule *r )
1019 {
1020  // if e was'nt previously added to the list of rules, we delete it
1021  int i = allRules.findRef( r );
1022  if ( i == -1 ) {
1023  kDebug(5100) <<"deleting rule" << r->getName();
1024  deleteRule( r );
1025  } else {
1026  kDebug(5100) <<"rule" << r->getName() <<" not deleted";
1027  }
1028 }
1029 
1030 void KScoringManager::setRuleName( KScoringRule *r, const QString &s )
1031 {
1032  bool cont = true;
1033  QString text = s;
1034  QString oldName = r->getName();
1035  while ( cont ) {
1036  cont = false;
1037  Q3PtrListIterator<KScoringRule> it( allRules );
1038  for ( ; it.current(); ++it ) {
1039  if ( it.current() != r && it.current()->getName() == text ) {
1040  kDebug(5100) <<"rule name" << text <<" is not unique";
1041  text = KInputDialog::getText(
1042  i18n( "Choose Another Rule Name" ),
1043  i18n( "The rule name is already assigned, please choose another name:" ),
1044  text );
1045  cont = true;
1046  break;
1047  }
1048  }
1049  }
1050  if ( text != oldName ) {
1051  r->setName( text );
1052  emit changedRuleName( oldName, text );
1053  }
1054 }
1055 
1056 void KScoringManager::deleteRule( KScoringRule *r )
1057 {
1058  int i = allRules.findRef( r );
1059  if ( i != -1 ) {
1060  allRules.remove();
1061  emit changedRules();
1062  }
1063 }
1064 
1065 void KScoringManager::editRule( KScoringRule *e, QWidget *w )
1066 {
1067  KScoringEditor *edit = KScoringEditor::createEditor( this, w );
1068  edit->setRule( e );
1069  edit->show();
1070  delete edit;
1071 }
1072 
1073 void KScoringManager::moveRuleAbove( KScoringRule *above, KScoringRule *below )
1074 {
1075  int aindex = allRules.findRef( above );
1076  int bindex = allRules.findRef( below );
1077  if ( aindex <= 0 || bindex < 0 ) {
1078  return;
1079  }
1080  if ( aindex < bindex ) {
1081  --bindex;
1082  }
1083  allRules.take( aindex );
1084  allRules.insert( bindex, above );
1085 }
1086 
1087 void KScoringManager::moveRuleBelow( KScoringRule *below, KScoringRule *above )
1088 {
1089  int bindex = allRules.findRef( below );
1090  int aindex = allRules.findRef( above );
1091  if ( bindex < 0 || bindex >= (int)allRules.count() - 1 || aindex < 0 ) {
1092  return;
1093  }
1094  if ( bindex < aindex ) {
1095  --aindex;
1096  }
1097  allRules.take( bindex );
1098  allRules.insert( aindex + 1, below );
1099 }
1100 
1101 void KScoringManager::editorReady()
1102 {
1103  kDebug(5100) <<"emitting signal finishedEditing";
1104  save();
1105  emit finishedEditing();
1106 }
1107 
1108 KScoringRule *KScoringManager::copyRule( KScoringRule *r )
1109 {
1110  KScoringRule *rule = new KScoringRule( *r );
1111  rule->setName( findUniqueName() );
1112  addRuleInternal( rule );
1113  return rule;
1114 }
1115 
1116 void KScoringManager::applyRules( ScorableGroup * )
1117 {
1118  kWarning(5100) <<"KScoringManager::applyRules(ScorableGroup* ) isn't implemented";
1119 }
1120 
1121 void KScoringManager::applyRules( ScorableArticle &article, const QString &group )
1122 {
1123  setGroup( group );
1124  applyRules( article );
1125 }
1126 
1127 void KScoringManager::applyRules( ScorableArticle &a )
1128 {
1129  Q3PtrListIterator<KScoringRule> it( isCacheValid() ? ruleList : allRules );
1130  for ( ; it.current(); ++it ) {
1131  it.current()->applyRule( a );
1132  }
1133 }
1134 
1135 void KScoringManager::initCache( const QString &g )
1136 {
1137  group = g;
1138  ruleList.clear();
1139  Q3PtrListIterator<KScoringRule> it(allRules);
1140  for ( ; it.current(); ++it ) {
1141  if ( it.current()->matchGroup( group ) ) {
1142  ruleList.append( it.current() );
1143  }
1144  }
1145  kDebug(5100) <<"created cache for group" << group
1146  << "with" << ruleList.count() << "rules";
1147  setCacheValid( true );
1148 }
1149 
1150 void KScoringManager::setGroup( const QString &g )
1151 {
1152  if ( group != g ) {
1153  initCache( g );
1154  }
1155 }
1156 
1157 bool KScoringManager::hasRulesForCurrentGroup()
1158 {
1159  return ruleList.count() != 0;
1160 }
1161 
1162 QStringList KScoringManager::getRuleNames()
1163 {
1164  QStringList l;
1165  Q3PtrListIterator<KScoringRule> it( allRules );
1166  for ( ; it.current(); ++it ) {
1167  l << it.current()->getName();
1168  }
1169  return l;
1170 }
1171 
1172 KScoringRule *KScoringManager::findRule( const QString &ruleName )
1173 {
1174  Q3PtrListIterator<KScoringRule> it( allRules );
1175  for ( ; it.current(); ++it ) {
1176  if ( it.current()->getName() == ruleName ) {
1177  return it;
1178  }
1179  }
1180  return 0;
1181 }
1182 
1183 bool KScoringManager::setCacheValid( bool v )
1184 {
1185  bool res = cacheValid;
1186  cacheValid = v;
1187  return res;
1188 }
1189 
1190 QString KScoringManager::findUniqueName() const
1191 {
1192  int nr = 0;
1193  QString ret;
1194  bool duplicated = false;
1195 
1196  while ( nr < 99999999 ) {
1197  nr++;
1198  ret = i18n( "rule %1", nr );
1199 
1200  duplicated = false;
1201  Q3PtrListIterator<KScoringRule> it( allRules );
1202  for ( ; it.current(); ++it ) {
1203  if ( it.current()->getName() == ret ) {
1204  duplicated = true;
1205  break;
1206  }
1207  }
1208 
1209  if ( !duplicated ) {
1210  return ret;
1211  }
1212  }
1213 
1214  return ret;
1215 }
1216 
1217 bool KScoringManager::hasFeature( int p )
1218 {
1219  switch ( p ) {
1220  case ActionBase::SETSCORE:
1221  return canScores();
1222  case ActionBase::NOTIFY:
1223  return canNotes();
1224  case ActionBase::COLOR:
1225  return canColors();
1226  case ActionBase::MARKASREAD:
1227  return canMarkAsRead();
1228  default:
1229  return false;
1230  }
1231 }
1232 
1233 QStringList KScoringManager::getDefaultHeaders() const
1234 {
1235  QStringList l;
1236  l.append( "Subject" );
1237  l.append( "From" );
1238  l.append( "Date" );
1239  l.append( "Message-ID" );
1240  return l;
1241 }
1242 
1243 void KScoringManager::pushRuleList()
1244 {
1245  stack.push( allRules );
1246 }
1247 
1248 void KScoringManager::popRuleList()
1249 {
1250  stack.pop( allRules );
1251 }
1252 
1253 void KScoringManager::removeTOS()
1254 {
1255  stack.drop();
1256 }
1257 
1258 RuleStack::RuleStack()
1259 {
1260 }
1261 
1262 RuleStack::~RuleStack()
1263 {}
1264 
1265 void RuleStack::push( Q3PtrList<KScoringRule> &l )
1266 {
1267  kDebug(5100) <<"RuleStack::push pushing list with" << l.count() <<" rules";
1268  KScoringManager::ScoringRuleList *l1 = new KScoringManager::ScoringRuleList;
1269  for ( KScoringRule *r=l.first(); r != 0; r=l.next() ) {
1270  l1->append( new KScoringRule( *r ) );
1271  }
1272  stack.push( l1 );
1273  kDebug(5100) <<"now there are" << stack.count() <<" lists on the stack";
1274 }
1275 
1276 void RuleStack::pop( Q3PtrList<KScoringRule> &l )
1277 {
1278  top( l );
1279  drop();
1280  kDebug(5100) <<"RuleStack::pop pops list with" << l.count() <<" rules";
1281  kDebug(5100) <<"now there are" << stack.count() <<" lists on the stack";
1282 }
1283 
1284 void RuleStack::top( Q3PtrList<KScoringRule> &l )
1285 {
1286  l.clear();
1287  KScoringManager::ScoringRuleList *l1 = stack.top();
1288  l = *l1;
1289 }
1290 
1291 void RuleStack::drop()
1292 {
1293  kDebug(5100) <<"drop: now there are" << stack.count() <<" lists on the stack";
1294  stack.remove();
1295 }
1296 
1297 #include "kscoring.moc"
KPIM::ScorableArticle::from
virtual QString from() const =0
KPIM::ActionSetScore::ActionSetScore
ActionSetScore(short)
Definition: kscoring.cpp:241
KPIM::KScoringExpression::MATCHCS
Definition: kscoring.h:195
KPIM::ActionBase::getTypeForName
static int getTypeForName(const QString &name)
Definition: kscoring.cpp:206
KPIM::KScoringManager::KScoringManager
KScoringManager(const QString &appName=QString())
Definition: kscoring.cpp:834
KPIM::ActionColor::apply
virtual void apply(ScorableArticle &) const
Definition: kscoring.cpp:305
KPIM::KScoringRule::toString
QString toString() const
Definition: kscoring.cpp:779
KPIM::RuleStack::drop
void drop()
drops the TOS
Definition: kscoring.cpp:1291
KPIM::KScoringRule::KScoringRule
KScoringRule(const QString &name)
Definition: kscoring.cpp:634
KPIM::KScoringRule::setExpireDate
void setExpireDate(const QDate &d)
Definition: kscoring.h:250
KPIM::KScoringRule::setExpire
void setExpire(const QString &exp)
Definition: kscoring.cpp:714
KPIM::RuleStack::top
void top(Q3PtrList< KScoringRule > &)
like pop but without dropping the TOS
Definition: kscoring.cpp:1284
KPIM::RuleStack::~RuleStack
~RuleStack()
Definition: kscoring.cpp:1262
KPIM::KScoringEditor::setRule
void setRule(KScoringRule *)
Definition: kscoringeditor.cpp:1005
KPIM::ActionColor
Definition: kscoring.h:101
KPIM::NotifyCollection::~NotifyCollection
~NotifyCollection()
Definition: kscoring.cpp:375
KPIM::KScoringManager::toString
QString toString() const
Definition: kscoring.cpp:900
KPIM::ActionColor::~ActionColor
virtual ~ActionColor()
Definition: kscoring.cpp:295
KPIM::KScoringManager::hasFeature
virtual bool hasFeature(int)
Definition: kscoring.cpp:1217
KPIM::KScoringManager::canScores
virtual bool canScores() const
Definition: kscoring.h:381
KPIM::ActionColor::setValue
virtual void setValue(const QString &s)
Definition: kscoring.h:110
KPIM::ActionSetScore::clone
virtual ActionSetScore * clone() const
Definition: kscoring.cpp:273
KPIM::ScorableArticle::displayMessage
virtual void displayMessage(const QString &)
Definition: kscoring.cpp:141
text
virtual QByteArray text(quint32 serialNumber) const =0
KPIM::KScoringManager::~KScoringManager
virtual ~KScoringManager()
Definition: kscoring.cpp:848
KPIM::KScoringEditor
Definition: kscoringeditor.h:261
KPIM::KScoringManager::popRuleList
void popRuleList()
Definition: kscoring.cpp:1248
KPIM::KScoringRule::setLinkMode
void setLinkMode(const QString &link)
Definition: kscoring.cpp:705
KPIM::KScoringManager::moveRuleBelow
void moveRuleBelow(KScoringRule *below, KScoringRule *above)
Definition: kscoring.cpp:1087
KPIM::KScoringManager::editRule
void editRule(KScoringRule *e, QWidget *w=0)
Definition: kscoring.cpp:1065
QWidget
KPIM::KScoringExpression::getTypeString
QString getTypeString() const
Definition: kscoring.cpp:601
KPIM::KScoringManager::finishedEditing
void finishedEditing()
KPIM::ActionSetScore::toString
virtual QString toString() const
Definition: kscoring.cpp:261
KPIM::NotifyCollection::addNote
void addNote(const ScorableArticle &, const QString &)
Definition: kscoring.cpp:379
KPIM::KScoringRule::matchGroup
bool matchGroup(const QString &group) const
Definition: kscoring.cpp:724
KPIM::ActionMarkAsRead::apply
virtual void apply(ScorableArticle &article) const
Definition: kscoring.cpp:359
KPIM::KScoringRule
Definition: kscoring.h:227
KPIM::ActionNotify::ActionNotify
ActionNotify(const QString &)
Definition: kscoring.cpp:316
KPIM::ActionSetScore::~ActionSetScore
virtual ~ActionSetScore()
Definition: kscoring.cpp:257
KPIM::KScoringManager::ScoringRuleList
Q3PtrList< KScoringRule > ScoringRuleList
Definition: kscoring.h:320
KPIM::KScoringManager::setCacheValid
bool setCacheValid(bool v)
Definition: kscoring.cpp:1183
KDialog
KPIM::KScoringManager::canColors
virtual bool canColors() const
Definition: kscoring.h:383
KPIM::RuleStack::pop
void pop(Q3PtrList< KScoringRule > &)
clears the argument list and copy the content of the TOS into it after that the TOS gets dropped ...
Definition: kscoring.cpp:1276
KPIM::KScoringManager::deleteRule
void deleteRule(KScoringRule *)
Definition: kscoring.cpp:1056
KPIM::ScorableArticle::subject
virtual QString subject() const =0
KPIM::ScorableArticle
Definition: kscoring.h:59
KPIM::ActionSetScore::apply
virtual void apply(ScorableArticle &) const
Definition: kscoring.cpp:268
KPIM::ActionBase::SETSCORE
Definition: kscoring.h:94
KPIM::KScoringRule::OR
Definition: kscoring.h:240
KPIM::KScoringRule::applyAction
void applyAction(ScorableArticle &a) const
Definition: kscoring.cpp:735
KPIM::ScorableArticle::markAsRead
virtual void markAsRead()
Definition: kscoring.h:67
KPIM::ActionSetScore
Definition: kscoring.h:120
KPIM::ActionBase
Base class for other Action classes.
Definition: kscoring.h:77
KPIM::KScoringManager::addRule
KScoringRule * addRule()
Definition: kscoring.cpp:1003
KPIM::KScoringManager::pushRuleList
void pushRuleList()
Definition: kscoring.cpp:1243
KPIM::ActionBase::ActionBase
ActionBase()
Definition: kscoring.cpp:152
KPIM::ActionBase::COLOR
Definition: kscoring.h:96
KPIM::NotifyDialog
Definition: kscoring.h:419
KPIM::ActionBase::clone
virtual ActionBase * clone() const =0
KPIM::KScoringManager::findUniqueName
QString findUniqueName() const
Definition: kscoring.cpp:1190
KPIM::ScorableArticle::addScore
virtual void addScore(short)
Definition: kscoring.h:64
KPIM::KScoringManager::setGroup
void setGroup(const QString &g)
Definition: kscoring.cpp:1150
KPIM::KScoringRule::ScoreExprList
Q3PtrList< KScoringExpression > ScoreExprList
Definition: kscoring.h:235
KPIM::KScoringExpression::SMALLER
Definition: kscoring.h:193
KPIM::KScoringManager::removeTOS
void removeTOS()
Definition: kscoring.cpp:1253
KPIM::KScoringRule::cleanExpressions
void cleanExpressions()
Definition: kscoring.cpp:675
KPIM::NotifyDialog::display
static void display(ScorableArticle &, const QString &)
Definition: kscoring.cpp:111
KPIM::KScoringExpression
Definition: kscoring.h:185
KPIM::ActionColor::ActionColor
ActionColor(const QColor &)
Definition: kscoring.cpp:279
KPIM::KScoringManager::isCacheValid
bool isCacheValid()
Definition: kscoring.h:374
KPIM::KScoringManager::findRule
KScoringRule * findRule(const QString &)
Definition: kscoring.cpp:1172
KPIM::NotifyCollection::NotifyCollection
NotifyCollection()
Definition: kscoring.cpp:370
KPIM::KScoringExpression::getType
int getType() const
Definition: kscoring.cpp:628
KPIM::ActionNotify
Definition: kscoring.h:139
kscoringeditor.h
KPIM::ActionNotify::clone
virtual ActionNotify * clone() const
Definition: kscoring.cpp:337
KPIM::ScorableArticle::changeColor
virtual void changeColor(const QColor &)
Definition: kscoring.h:66
KPIM::KScoringManager::changedRules
void changedRules()
KPIM::KScoringExpression::match
bool match(ScorableArticle &a) const
Definition: kscoring.cpp:542
KPIM::ActionBase::userName
QString userName()
Definition: kscoring.h:92
KPIM::KScoringRule::cleanActions
void cleanActions()
Definition: kscoring.cpp:681
KPIM::KScoringManager::moveRuleAbove
void moveRuleAbove(KScoringRule *above, KScoringRule *below)
Definition: kscoring.cpp:1073
KPIM::KScoringRule::addExpression
void addExpression(KScoringExpression *)
Definition: kscoring.cpp:687
KPIM::ActionNotify::apply
virtual void apply(ScorableArticle &) const
Definition: kscoring.cpp:332
KPIM::ActionBase::getTypeForUserName
static int getTypeForUserName(const QString &name)
Definition: kscoring.cpp:223
KPIM::NotifyCollection::collection
QString collection() const
Definition: kscoring.cpp:392
KPIM::KScoringRule::addAction
void addAction(int, const QString &)
Definition: kscoring.cpp:693
KPIM::KScoringManager::save
void save()
Definition: kscoring.cpp:872
KPIM::ActionMarkAsRead
Definition: kscoring.h:155
KPIM::KScoringRule::~KScoringRule
~KScoringRule()
Definition: kscoring.cpp:669
KPIM::KScoringExpression::CONTAINS
Definition: kscoring.h:190
KPIM::KScoringExpression::~KScoringExpression
~KScoringExpression()
Definition: kscoring.cpp:538
KPIM::KScoringRule::getLinkModeName
QString getLinkModeName() const
Definition: kscoring.cpp:802
toXml
static QString toXml(const QString &str)
Definition: kscoring.cpp:50
KPIM::NotifyCollection::displayCollection
void displayCollection(QWidget *p=0) const
Definition: kscoring.cpp:414
KPIM::KScoringExpression::EQUALS
Definition: kscoring.h:192
KPIM::KScoringManager::editorReady
void editorReady()
called from an editor whenever it finishes editing the rule base, causes the finishedEditing signal t...
Definition: kscoring.cpp:1101
KPIM::ScorableGroup::~ScorableGroup
virtual ~ScorableGroup()
Definition: kscoring.cpp:147
KPIM::ActionMarkAsRead::toString
virtual QString toString() const
Definition: kscoring.cpp:354
KPIM::KScoringManager::applyRules
void applyRules(ScorableArticle &article, const QString &group)
Definition: kscoring.cpp:1121
KPIM::KScoringExpression::conditionNames
static QStringList conditionNames()
Definition: kscoring.cpp:510
KPIM::KScoringRule::AND
Definition: kscoring.h:239
KPIM::KScoringManager::canNotes
virtual bool canNotes() const
Definition: kscoring.h:382
KPIM::KScoringManager::setRuleName
void setRuleName(KScoringRule *, const QString &)
Definition: kscoring.cpp:1030
KPIM::KScoringManager::initCache
void initCache(const QString &group)
Definition: kscoring.cpp:1135
KPIM::ActionMarkAsRead::ActionMarkAsRead
ActionMarkAsRead()
Definition: kscoring.cpp:343
KPIM::KScoringManager::load
void load()
Definition: kscoring.cpp:852
KPIM::KScoringEditor::createEditor
static KScoringEditor * createEditor(KScoringManager *m, QWidget *parent=0)
Definition: kscoringeditor.cpp:996
KPIM::ScorableGroup
The following classes ScorableArticle, ScorableGroup define the interface for the scoring...
Definition: kscoring.h:53
KPIM::KScoringExpression::MATCH
Definition: kscoring.h:191
KPIM::KScoringManager::changedRuleName
void changedRuleName(const QString &oldName, const QString &newName)
kscoring.h
KPIM::ActionColor::clone
virtual ActionColor * clone() const
Definition: kscoring.cpp:310
KPIM::KScoringManager::getRuleNames
QStringList getRuleNames()
Definition: kscoring.cpp:1162
KPIM::ActionColor::toString
virtual QString toString() const
Definition: kscoring.cpp:298
KPIM::KScoringManager::canMarkAsRead
virtual bool canMarkAsRead() const
Definition: kscoring.h:384
KPIM::ActionBase::toString
virtual QString toString() const =0
KPIM::ActionBase::~ActionBase
virtual ~ActionBase()
Definition: kscoring.cpp:157
KPIM::ActionBase::MARKASREAD
Definition: kscoring.h:97
KPIM::ScorableArticle::~ScorableArticle
virtual ~ScorableArticle()
Definition: kscoring.cpp:137
KPIM::KScoringExpression::getNameForCondition
static QString getNameForCondition(int)
Definition: kscoring.cpp:487
QLabel
KPIM::KScoringManager::cancelNewRule
void cancelNewRule(KScoringRule *)
Definition: kscoring.cpp:1018
KPIM::KScoringExpression::getConditionForName
static int getConditionForName(const QString &)
Definition: kscoring.cpp:465
KPIM::ActionBase::userNames
static QStringList userNames()
Definition: kscoring.cpp:162
KPIM::KScoringRule::write
void write(QTextStream &) const
Definition: kscoring.cpp:774
KPIM::KScoringExpression::GREATER
Definition: kscoring.h:194
KPIM::KScoringRule::addGroup
void addGroup(const QString &group)
Definition: kscoring.h:266
KPIM::KScoringRule::isExpired
bool isExpired() const
Definition: kscoring.cpp:826
KPIM::ActionMarkAsRead::clone
virtual ActionMarkAsRead * clone() const
Definition: kscoring.cpp:364
KPIM::KScoringManager::hasRulesForCurrentGroup
bool hasRulesForCurrentGroup()
Definition: kscoring.cpp:1157
KPIM::KScoringRule::setName
void setName(const QString &n)
assert that the name is unique
Definition: kscoring.h:278
KPIM::KScoringManager::copyRule
KScoringRule * copyRule(KScoringRule *)
Definition: kscoring.cpp:1108
KPIM::ScorableArticle::getHeaderByType
virtual QString getHeaderByType(const QString &) const =0
KPIM::KScoringRule::getExpireDateString
QString getExpireDateString() const
Definition: kscoring.cpp:814
KPIM::KScoringManager::getDefaultHeaders
virtual QStringList getDefaultHeaders() const
returns a list of common (or available) headers defaults to returning { Subject, From, Message-ID, Date }
Definition: kscoring.cpp:1233
KPIM::ActionNotify::toString
virtual QString toString() const
Definition: kscoring.cpp:327
KPIM::ActionBase::factory
static ActionBase * factory(int type, const QString &value)
Definition: kscoring.cpp:172
QFrame
KPIM::RuleStack::RuleStack
RuleStack()
Definition: kscoring.cpp:1258
KPIM::KScoringExpression::write
void write(QTextStream &) const
Definition: kscoring.cpp:584
KPIM::KScoringExpression::headerNames
static QStringList headerNames()
Definition: kscoring.cpp:523
KPIM::KScoringRule::getName
QString getName() const
Definition: kscoring.h:243
KPIM::KScoringRule::applyRule
void applyRule(ScorableArticle &a) const
Definition: kscoring.cpp:743
KPIM::RuleStack::push
void push(Q3PtrList< KScoringRule > &)
puts the list on the stack, doesn't change the list
Definition: kscoring.cpp:1265
KTextEdit
QList
KPIM::KScoringExpression::KScoringExpression
KScoringExpression(const QString &, const QString &, const QString &, const QString &)
Definition: kscoring.cpp:432
KPIM::ActionBase::NOTIFY
Definition: kscoring.h:95
KPIM::KScoringExpression::toString
QString toString() const
Definition: kscoring.cpp:589
KPIM::KScoringRule::ActionList
Q3PtrList< ActionBase > ActionList
Definition: kscoring.h:236
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:58:36 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

knode

Skip menu "knode"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal