15 #include <kstandarddirs.h>
17 #include <kconfiggroup.h>
30 static const char *
defFil[] = {
"all",
"unread",
"new",
"watched",
"threads with unread",
31 "threads with new",
"own articles",
"threads with own articles", 0 };
34 i18nc(
"default filter name",
"all");
35 i18nc(
"default filter name",
"unread");
36 i18nc(
"default filter name",
"new");
37 i18nc(
"default filter name",
"watched");
38 i18nc(
"default filter name",
"threads with unread");
39 i18nc(
"default filter name",
"threads with new");
40 i18nc(
"default filter name",
"own articles");
41 i18nc(
"default filter name",
"threads with own articles");
49 : i_d(id), c_ount(0), l_oaded(false), e_nabled(true), translateName(true), s_earchFilter(false), apon(articles)
56 : i_d(-1), c_ount(0), l_oaded(false), e_nabled(org.e_nabled), translateName(true), s_earchFilter(org.s_earchFilter), apon(org.apon)
78 QString fname( KStandardDirs::locate(
"data",
79 QString(
"knode/filters/%1.fltr" ).arg(
i_d ) ) );
83 KConfig conf( fname, KConfig::SimpleConfig);
85 KConfigGroup group = conf.group(
"GENERAL");
86 n_ame=group.readEntry(
"name");
88 e_nabled=group.readEntry(
"enabled",
true);
89 apon=(
ApOn) group.readEntry(
"applyOn", 0);
99 QString fname(KStandardDirs::locate(
"data", QString(
"knode/filters/%1.fltr" ).arg(
i_d ) ) );
103 KConfig conf( fname, KConfig::SimpleConfig);
105 KConfigGroup group = conf.group(
"STATUS");
108 group = conf.group(
"SCORE");
111 group = conf.group(
"AGE");
114 group = conf.group(
"LINES");
117 group = conf.group(
"SUBJECT");
120 group = conf.group(
"FROM");
123 group = conf.group(
"MESSAGEID");
126 group = conf.group(
"REFERENCES");
131 kDebug(5003) <<
"KNMessageFilter: filter loaded \"" <<
n_ame <<
"\"";
141 QString dir( KStandardDirs::locateLocal(
"data",
"knode/filters/" ) );
146 KConfig conf(dir+QString(
"%1.fltr").arg(
i_d), KConfig::SimpleConfig);
148 KConfigGroup group = conf.group(
"GENERAL");
149 group.writeEntry(
"name", QString(
n_ame));
151 group.writeEntry(
"enabled",
e_nabled);
152 group.writeEntry(
"applyOn", (
int)
apon);
154 group = conf.group(
"STATUS");
157 group = conf.group(
"SCORE");
160 group = conf.group(
"AGE");
163 group = conf.group(
"LINES");
166 group = conf.group(
"SUBJECT");
169 group = conf.group(
"FROM");
172 group = conf.group(
"MESSAGEID");
175 group = conf.group(
"REFERENCES");
178 kDebug(5003) <<
"KNMessageFilter: filter saved \"" <<
n_ame <<
"\"";
199 for(
int idx=0; idx<g->length(); idx++) {
201 art->setFiltered(
false);
202 art->setVisibleFollowUps(
false);
206 for(
int idx=0; idx<g->length(); idx++) {
214 ref->setFilterResult(
true);
215 ref->setFiltered(
true);
216 if ( idRef==ref->idRef() )
break;
223 for(
int idx=0; idx<g->length(); idx++) {
230 while(idRef!=0 && !inThread) {
232 inThread=ref->filterResult();
235 art->setFilterResult(inThread);
238 if(art->filterResult()) {
242 while(ref && !ref->filterResult())
245 art->setDisplayedReference(ref);
247 ref->setVisibleFollowUps(
true);
248 else if(art->idRef()>0) {
249 orphant_threads.append(art);
255 if( orphant_threads.count() > 0 ) {
259 for ( KNRemoteArticle::List::Iterator it = orphant_threads.begin(); it != orphant_threads.end(); ++it ) {
260 if ( (*it)->displayedReference() )
263 s = (*it)->subject()->asUnicodeString();
264 same_subjects.clear();
265 for ( KNRemoteArticle::List::Iterator it2 = orphant_threads.begin(); it2 != orphant_threads.end(); ++it2 ) {
266 if ( (*it2) != (*it) && (*it2)->subject()->asUnicodeString() == s )
267 same_subjects.append( (*it2) );
270 (*it)->setVisibleFollowUps( (*it)->hasVisibleFollowUps() || same_subjects.count() > 0 );
271 for ( KNRemoteArticle::List::Iterator it2 = same_subjects.begin(); it2 != same_subjects.end(); ++it2 ) {
272 (*it2)->setDisplayedReference( (*it) );
278 kDebug(5003) <<
"KNArticleFilter::doFilter() : matched" <<
c_ount
279 <<
"articles , merged" << mergeCnt
280 <<
"threads by subject";
297 for(
int idx=0; idx<f->length(); idx++) {
310 if (!
n_ame.isEmpty()) {
311 if (i18nc(
"default filter name",
n_ame.toLocal8Bit())!=
n_ame.toLocal8Bit().data())
312 return i18nc(
"default filter name",
n_ame.toLocal8Bit());
326 bool retranslated =
false;
327 for (
const char **c=
defFil;(*c)!=0;c++)
328 if (s==i18nc(
"default filter name",*c)) {
329 n_ame = QString::fromLatin1(*c);
349 if(result) result=
lines.
doFilter(a->lines()->numberOfLines());
350 if(result) result=
age.
doFilter(a->date()->ageInDays());
354 if ( !a->from()->isEmpty() )
355 tmp = a->from()->displayNames().first() + QLatin1String(
"##")
356 + QString::fromLatin1( a->from()->addresses().first() );
362 a->setFilterResult(result);
363 a->setFiltered(
true);
374 if(result) result=
lines.
doFilter(a->lines()->numberOfLines());
375 if(result) result=
age.
doFilter(a->date()->ageInDays());
379 if ( !a->from()->isEmpty() )
380 tmp = a->from()->displayNames().first() + QLatin1String(
"##")
381 + QString::fromLatin1( a->from()->addresses().first() );
388 a->setFilterResult(result);
boost::shared_ptr< KNLocalArticle > Ptr
Shared pointer to a KNLocalArticle. To be used instead of raw KNLocalArticle*.
static const char * defFil[]
KNode::StringFilter subject
void load(const KConfigGroup &conf)
void doFilter(KNGroup::Ptr g)
KNode::StringFilter references
void setTranslatedName(const QString &s)
tries to retranslate the name to english
void save(KConfigGroup &conf)
boost::shared_ptr< KNFolder > Ptr
Shared pointer to a KNFolder.
QString translatedName()
tries to translate the name
void load(const KConfigGroup &group)
bool isSearchFilter() const
static void displayInternalFileError(QWidget *w=0)
use this for all internal files
void expand(KNGroup *g)
replace placeholders
void save(KConfigGroup &conf)
KNode::StringFilter messageId
void load(const KConfigGroup &conf)
bool doFilter(const QString &s)
KNArticleFilter(int id=-1)
boost::shared_ptr< KNRemoteArticle > Ptr
Shared pointer to a KNRemoteArticle. To be used instead of raw KNRemoteArticle*.
KNode::StatusFilter status
void save(KConfigGroup &conf)
bool doFilter(KNRemoteArticle::Ptr a)
boost::shared_ptr< KNGroup > Ptr
Shared pointer to a KNGroup.
bool applyFilter(KNRemoteArticle::Ptr a)