2 KNode, the KDE newsreader
3 Copyright (c) 1999-2005 the KNode authors.
4 See file AUTHORS for details
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10 You should have received a copy of the GNU General Public License
11 along with this program; if not, write to the Free Software Foundation,
12 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, US
15 #include "knstatusfilter.h"
18 #include <QGridLayout>
33 using namespace KNode
;
35 KNode::StatusFilter::StatusFilter()
42 KNode::StatusFilter::~StatusFilter()
48 void KNode::StatusFilter::load( const KConfigGroup
&group
)
50 data
.setBit(EN_R
, group
.readEntry("EN_R", false));
51 data
.setBit(DAT_R
, group
.readEntry("DAT_R", false));
53 data
.setBit(EN_N
, group
.readEntry("EN_N", false));
54 data
.setBit(DAT_N
, group
.readEntry("DAT_N", false));
56 data
.setBit(EN_US
, group
.readEntry("EN_US", false));
57 data
.setBit(DAT_US
, group
.readEntry("DAT_US", false));
59 data
.setBit(EN_NS
, group
.readEntry("EN_NS", false));
60 data
.setBit(DAT_NS
, group
.readEntry("DAT_NS", false));
66 void KNode::StatusFilter::save( KConfigGroup
&group
)
68 group
.writeEntry("EN_R", data
.at(EN_R
));
69 group
.writeEntry("DAT_R", data
.at(DAT_R
));
71 group
.writeEntry("EN_N", data
.at(EN_N
));
72 group
.writeEntry("DAT_N", data
.at(DAT_N
));
74 group
.writeEntry("EN_US", data
.at(EN_US
));
75 group
.writeEntry("DAT_US", data
.at(DAT_US
));
77 group
.writeEntry("EN_NS", data
.at(EN_NS
));
78 group
.writeEntry("DAT_NS", data
.at(DAT_NS
));
83 bool KNode::StatusFilter::doFilter( KNRemoteArticle::Ptr a
)
87 if(data
.at(EN_R
) && ret
)
88 ret
=(a
->isRead() == data
.at(DAT_R
));
90 if(data
.at(EN_N
) && ret
)
91 ret
=(a
->isNew() == data
.at(DAT_N
));
93 if(data
.at(EN_US
) && ret
)
94 ret
=(a
->hasUnreadFollowUps() == data
.at(DAT_US
));
96 if(data
.at(EN_NS
) && ret
)
97 ret
=(a
->hasNewFollowUps() == data
.at(DAT_NS
));
104 //==============================================================================
106 KNode::StatusFilterWidget::StatusFilterWidget( QWidget
*parent
) :
109 enR
=new QCheckBox(i18n("Is read:"), this);
110 enN
=new QCheckBox(i18n("Is new:"), this);
111 enUS
=new QCheckBox(i18n("Has unread followups:"), this);
112 enNS
=new QCheckBox(i18n("Has new followups:"), this);
114 rCom
=new TFCombo(this);
115 nCom
=new TFCombo(this);
116 usCom
=new TFCombo(this);
117 nsCom
=new TFCombo(this);
119 QGridLayout
*topL
= new QGridLayout( this );
120 topL
->setSpacing( KDialog::spacingHint() );
121 topL
->addWidget(enR
,0,0); topL
->addWidget(rCom
,0,1);
122 topL
->addWidget(enN
,1,0); topL
->addWidget(nCom
,1,1);
123 topL
->addWidget(enUS
,2,0); topL
->addWidget(usCom
,2,1);
124 topL
->addWidget(enNS
,3,0); topL
->addWidget(nsCom
,3,1);
125 topL
->setColumnStretch(2,1);
126 topL
->setRowStretch(4,1);
128 connect( enR
, SIGNAL(toggled(bool)), SLOT(slotEnabled()) );
129 connect( enN
, SIGNAL(toggled(bool)), SLOT(slotEnabled()) );
130 connect( enUS
, SIGNAL(toggled(bool)), SLOT(slotEnabled()) );
131 connect( enNS
, SIGNAL(toggled(bool)), SLOT(slotEnabled()) );
136 KNode::StatusFilterWidget::~StatusFilterWidget()
142 StatusFilter
KNode::StatusFilterWidget::filter()
146 f
.data
.setBit(EN_R
, enR
->isChecked());
147 f
.data
.setBit(DAT_R
, rCom
->value());
149 f
.data
.setBit(EN_N
, enN
->isChecked());
150 f
.data
.setBit(DAT_N
, nCom
->value());
152 f
.data
.setBit(EN_US
, enUS
->isChecked());
153 f
.data
.setBit(DAT_US
, usCom
->value());
155 f
.data
.setBit(EN_NS
, enNS
->isChecked());
156 f
.data
.setBit(DAT_NS
, nsCom
->value());
163 void KNode::StatusFilterWidget::setFilter( StatusFilter
&f
)
165 enR
->setChecked(f
.data
.at(EN_R
));
166 rCom
->setValue(f
.data
.at(DAT_R
));
168 enN
->setChecked(f
.data
.at(EN_N
));
169 nCom
->setValue(f
.data
.at(DAT_N
));
171 enUS
->setChecked(f
.data
.at(EN_US
));
172 usCom
->setValue(f
.data
.at(DAT_US
));
174 enNS
->setChecked(f
.data
.at(EN_NS
));
175 nsCom
->setValue(f
.data
.at(DAT_NS
));
181 void KNode::StatusFilterWidget::clear()
183 enR
->setChecked(false);
184 enN
->setChecked(false);
185 enUS
->setChecked(false);
186 enNS
->setChecked(false);
187 rCom
->setValue(true);
188 nCom
->setValue(true);
189 nsCom
->setValue(true);
190 usCom
->setValue(true);
197 void KNode::StatusFilterWidget::slotEnabled()
199 rCom
->setEnabled( enR
->isChecked() );
200 nCom
->setEnabled( enN
->isChecked() );
201 usCom
->setEnabled( enUS
->isChecked() );
202 nsCom
->setEnabled( enNS
->isChecked() );
206 //==============================================================================
209 KNode::StatusFilterWidget::TFCombo::TFCombo( QWidget
*parent
) : QComboBox( parent
)
211 addItem(i18n("True"));
212 addItem(i18n("False"));
217 KNode::StatusFilterWidget::TFCombo::~TFCombo()
223 //--------------------------------
225 #include "knstatusfilter.moc"