25 #include "akregatorconfig.h"
27 #include "propertiesdialog.h"
29 #include <kcombobox.h>
30 #include <klineedit.h>
32 #include <tdelocale.h>
33 #include <knuminput.h>
35 #include <tqcheckbox.h>
36 #include <tqbuttongroup.h>
37 #include <tqradiobutton.h>
41 FeedPropertiesWidget::FeedPropertiesWidget(TQWidget *parent,
const char *name)
42 : FeedPropertiesWidgetBase(parent, name)
46 FeedPropertiesWidget::~FeedPropertiesWidget()
50 void FeedPropertiesWidget::slotUpdateComboBoxActivated(
int index )
53 updateSpinBox->setEnabled(
false);
55 updateSpinBox->setEnabled(
true);
59 void FeedPropertiesWidget::slotUpdateCheckBoxToggled(
bool enabled )
61 if (enabled && updateComboBox->currentItem() != 3 )
62 updateSpinBox->setEnabled(
true);
64 updateSpinBox->setEnabled(
false);
68 FeedPropertiesDialog::FeedPropertiesDialog(TQWidget *parent,
const char *name)
69 : KDialogBase(KDialogBase::Swallow, TQt::WStyle_DialogBorder, parent, name, true, i18n(
"Feed Properties"), KDialogBase::Ok|KDialogBase::Cancel)
71 widget=
new FeedPropertiesWidget(
this);
72 setMainWidget(widget);
73 widget->feedNameEdit->setFocus();
75 connect(widget->feedNameEdit, TQ_SIGNAL(textChanged(
const TQString&)),
this, TQ_SLOT(slotSetCaption(
const TQString&)));
78 FeedPropertiesDialog::~FeedPropertiesDialog()
81 void FeedPropertiesDialog::slotOk()
83 m_feed->setNotificationMode(
false);
84 m_feed->setTitle( feedName() );
85 m_feed->setXmlUrl( url() );
86 m_feed->setCustomFetchIntervalEnabled(autoFetch());
88 m_feed->setFetchInterval(fetchInterval());
89 m_feed->setArchiveMode(archiveMode());
90 m_feed->setMaxArticleAge(maxArticleAge());
91 m_feed->setMaxArticleNumber(maxArticleNumber());
92 m_feed->setMarkImmediatelyAsRead(markImmediatelyAsRead());
93 m_feed->setUseNotification(useNotification());
94 m_feed->setLoadLinkedWebsite(loadLinkedWebsite());
95 m_feed->setNotificationMode(
true,
true);
97 KDialogBase::slotOk();
100 void FeedPropertiesDialog::slotSetCaption(
const TQString& c)
103 setCaption(i18n(
"Feed Properties"));
105 setCaption(i18n(
"Properties of %1").arg(c));
109 void FeedPropertiesDialog::setFeed(Feed* feed)
115 setFeedName( feed->title() );
116 setUrl( feed->xmlUrl() );
117 setAutoFetch(feed->useCustomFetchInterval());
118 if (feed->useCustomFetchInterval())
119 setFetchInterval(feed->fetchInterval());
121 setFetchInterval(Settings::autoFetchInterval());
122 setArchiveMode(feed->archiveMode());
123 setMaxArticleAge(feed->maxArticleAge());
124 setMaxArticleNumber(feed->maxArticleNumber());
125 setMarkImmediatelyAsRead(feed->markImmediatelyAsRead());
126 setUseNotification(feed->useNotification());
127 setLoadLinkedWebsite(feed->loadLinkedWebsite());
128 slotSetCaption(feedName());
132 const TQString FeedPropertiesDialog::feedName()
const
134 return widget->feedNameEdit->text();
137 const TQString FeedPropertiesDialog::url()
const
139 return widget->urlEdit->text();
142 bool FeedPropertiesDialog::autoFetch()
const
144 return widget->upChkbox->isChecked();
147 int FeedPropertiesDialog::fetchInterval()
const
149 switch (widget->updateComboBox->currentItem() )
152 return widget->updateSpinBox->value();
154 return widget->updateSpinBox->value()*60;
156 return widget->updateSpinBox->value()*60*24;
162 Feed::ArchiveMode FeedPropertiesDialog::archiveMode()
const
165 if ( widget->rb_globalDefault->isChecked() )
166 return Feed::globalDefault;
168 if ( widget->rb_keepAllArticles->isChecked() )
169 return Feed::keepAllArticles;
171 if ( widget->rb_limitArticleAge->isChecked() )
172 return Feed::limitArticleAge;
174 if ( widget->rb_limitArticleNumber->isChecked() )
175 return Feed::limitArticleNumber;
177 if ( widget->rb_disableArchiving->isChecked() )
178 return Feed::disableArchiving;
182 return Feed::globalDefault;
186 int FeedPropertiesDialog::maxArticleAge()
const
188 return widget->sb_maxArticleAge->value();
191 int FeedPropertiesDialog::maxArticleNumber()
const
193 return widget->sb_maxArticleNumber->value();
196 void FeedPropertiesDialog::setArchiveMode(Feed::ArchiveMode mode)
200 case Feed::globalDefault:
201 widget->rb_globalDefault->setChecked(
true);
203 case Feed::keepAllArticles:
204 widget->rb_keepAllArticles->setChecked(
true);
206 case Feed::disableArchiving:
207 widget->rb_disableArchiving->setChecked(
true);
209 case Feed::limitArticleAge:
210 widget->rb_limitArticleAge->setChecked(
true);
212 case Feed::limitArticleNumber:
213 widget->rb_limitArticleNumber->setChecked(
true);
216 void FeedPropertiesDialog::setFeedName(
const TQString& title)
218 widget->feedNameEdit->setText(title);
221 void FeedPropertiesDialog::setUrl(
const TQString& url)
223 widget->urlEdit->setText(url);
226 void FeedPropertiesDialog::setAutoFetch(
bool customFetchEnabled)
228 widget->upChkbox->setChecked(customFetchEnabled);
229 widget->updateComboBox->setEnabled(customFetchEnabled);
231 if (widget->updateSpinBox->value() > -1)
232 widget->updateSpinBox->setEnabled(customFetchEnabled);
234 widget->updateSpinBox->setEnabled(
false);
237 void FeedPropertiesDialog::setFetchInterval(
int interval)
241 widget->updateSpinBox->setValue(0);
242 widget->updateSpinBox->setDisabled(
true);
243 widget->updateComboBox->setCurrentItem(3);
249 widget->updateSpinBox->setValue(0);
250 widget->updateSpinBox->setEnabled(widget->upChkbox->isChecked());
251 widget->updateComboBox->setCurrentItem(0);
255 if (interval % (60*24) == 0)
257 widget->updateSpinBox->setValue(interval / (60*24) );
258 widget->updateSpinBox->setEnabled(widget->upChkbox->isChecked());
259 widget->updateComboBox->setCurrentItem(2);
263 if (interval % 60 == 0)
265 widget->updateSpinBox->setValue(interval / 60 );
266 widget->updateSpinBox->setEnabled(widget->upChkbox->isChecked());
267 widget->updateComboBox->setCurrentItem(1);
271 widget->updateSpinBox->setValue(interval);
272 widget->updateSpinBox->setEnabled(widget->upChkbox->isChecked());
273 widget->updateComboBox->setCurrentItem(0);
276 void FeedPropertiesDialog::setMaxArticleAge(
int age)
278 widget->sb_maxArticleAge->setValue(age);
281 void FeedPropertiesDialog::setMaxArticleNumber(
int number)
283 widget->sb_maxArticleNumber->setValue(number);
286 void FeedPropertiesDialog::setMarkImmediatelyAsRead(
bool enabled)
288 widget->checkBox_markRead->setChecked(enabled);
291 bool FeedPropertiesDialog::markImmediatelyAsRead()
const
293 return widget->checkBox_markRead->isChecked();
296 void FeedPropertiesDialog::setUseNotification(
bool enabled)
298 widget->checkBox_useNotification->setChecked(enabled);
301 bool FeedPropertiesDialog::useNotification()
const
303 return widget->checkBox_useNotification->isChecked();
306 bool FeedPropertiesDialog::loadLinkedWebsite()
const
308 return widget->checkBox_loadWebsite->isChecked();
311 void FeedPropertiesDialog::setLoadLinkedWebsite(
bool enabled)
313 widget->checkBox_loadWebsite->setChecked(enabled);
316 void FeedPropertiesDialog::selectFeedName()
318 widget->feedNameEdit->selectAll();
323 #include "propertiesdialog.moc"