From c896cc340d7e6e0878b3249c5792e6d88a12cf42 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 30 Apr 2010 11:23:37 +0200 Subject: A coding style round --- src/settings/adblockwidget.cpp | 92 +++++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 46 deletions(-) (limited to 'src/settings/adblockwidget.cpp') diff --git a/src/settings/adblockwidget.cpp b/src/settings/adblockwidget.cpp index 2f431c1e..0d65c2de 100644 --- a/src/settings/adblockwidget.cpp +++ b/src/settings/adblockwidget.cpp @@ -43,64 +43,64 @@ AdBlockWidget::AdBlockWidget(QWidget *parent) - : QWidget(parent) - , _changed(false) + : QWidget(parent) + , _changed(false) { setupUi(this); - - hintLabel->setText( i18n("Filter expression (e.g. http://www.example.com/ad/*, more information):") ); - connect( hintLabel, SIGNAL(linkActivated(const QString &)), this, SLOT(slotInfoLinkActivated(const QString &)) ); - + + hintLabel->setText(i18n("Filter expression (e.g. http://www.example.com/ad/*, more information):")); + connect(hintLabel, SIGNAL(linkActivated(const QString &)), this, SLOT(slotInfoLinkActivated(const QString &))); + listWidget->setSortingEnabled(true); listWidget->setSelectionMode(QAbstractItemView::SingleSelection); - + searchLine->setListWidget(listWidget); - - insertButton->setIcon( KIcon("list-add") ); - connect( insertButton, SIGNAL( clicked() ), this, SLOT( insertRule() ) ); - - removeButton->setIcon( KIcon("list-remove") ); - connect( removeButton, SIGNAL( clicked() ), this, SLOT( removeRule() ) ); - + + insertButton->setIcon(KIcon("list-add")); + connect(insertButton, SIGNAL(clicked()), this, SLOT(insertRule())); + + removeButton->setIcon(KIcon("list-remove")); + connect(removeButton, SIGNAL(clicked()), this, SLOT(removeRule())); + load(); - + // emit changed signal - connect( insertButton, SIGNAL( clicked() ), this, SLOT( hasChanged() ) ); - connect( removeButton, SIGNAL( clicked() ), this, SLOT( hasChanged() ) ); - connect( checkEnableAdblock, SIGNAL( stateChanged(int) ), this, SLOT( hasChanged() ) ); - connect( checkHideAds, SIGNAL( stateChanged(int) ), this, SLOT( hasChanged() ) ); - connect( spinBox, SIGNAL( valueChanged(int) ), this, SLOT( hasChanged() ) ); + connect(insertButton, SIGNAL(clicked()), this, SLOT(hasChanged())); + connect(removeButton, SIGNAL(clicked()), this, SLOT(hasChanged())); + connect(checkEnableAdblock, SIGNAL(stateChanged(int)), this, SLOT(hasChanged())); + connect(checkHideAds, SIGNAL(stateChanged(int)), this, SLOT(hasChanged())); + connect(spinBox, SIGNAL(valueChanged(int)), this, SLOT(hasChanged())); } void AdBlockWidget::slotInfoLinkActivated(const QString &url) { Q_UNUSED(url) - + QString hintHelpString = i18n("

Enter an expression to filter. Filters can be defined as either:" "

  • a shell-style wildcard, e.g. http://www.example.com/ads*, the wildcards *?[] may be used
  • " "
  • a full regular expression by surrounding the string with '/', e.g. /\\/(ad|banner)\\./
" "

Any filter string can be preceded by '@@' to whitelist (allow) any matching URL, " "which takes priority over any blacklist (blocking) filter."); - QWhatsThis::showText( QCursor::pos(), hintHelpString ); + QWhatsThis::showText(QCursor::pos(), hintHelpString); } void AdBlockWidget::insertRule() { QString rule = addFilterLineEdit->text(); - if(rule.isEmpty()) + if (rule.isEmpty()) return; - - listWidget->addItem( rule ); + + listWidget->addItem(rule); addFilterLineEdit->clear(); } void AdBlockWidget::removeRule() { - listWidget->takeItem( listWidget->currentRow() ); + listWidget->takeItem(listWidget->currentRow()); } @@ -108,13 +108,13 @@ void AdBlockWidget::load() { bool isAdBlockEnabled = ReKonfig::adBlockEnabled(); checkEnableAdblock->setChecked(isAdBlockEnabled); - + bool areImageFiltered = ReKonfig::hideAdsEnabled(); checkHideAds->setChecked(areImageFiltered); - + int days = ReKonfig::updateInterval(); - spinBox->setValue( days ); - + spinBox->setValue(days); + QStringList subscriptions = ReKonfig::subscriptionTitles(); // load automatic rules @@ -124,14 +124,14 @@ void AdBlockWidget::load() subItem->setText(0, sub); loadRules(subItem); } - + // load local rules KSharedConfig::Ptr config = KGlobal::config(); - KConfigGroup localGroup( config, "rules" ); - QStringList rules = localGroup.readEntry( "local-rules" , QStringList() ); + KConfigGroup localGroup(config, "rules"); + QStringList rules = localGroup.readEntry("local-rules" , QStringList()); foreach(const QString &rule, rules) { - listWidget->addItem( rule ); + listWidget->addItem(rule); } } @@ -139,12 +139,12 @@ void AdBlockWidget::load() void AdBlockWidget::loadRules(QTreeWidgetItem *item) { KSharedConfig::Ptr config = KGlobal::config(); - KConfigGroup localGroup( config, "rules" ); - + KConfigGroup localGroup(config, "rules"); + QString str = item->text(0) + "-rules"; kDebug() << str; - QStringList rules = localGroup.readEntry( str , QStringList() ); - + QStringList rules = localGroup.readEntry(str , QStringList()); + foreach(const QString &rule, rules) { QTreeWidgetItem *subItem = new QTreeWidgetItem(item); @@ -159,21 +159,21 @@ void AdBlockWidget::save() // local rules KSharedConfig::Ptr config = KGlobal::config(); - KConfigGroup localGroup( config , "rules" ); - + KConfigGroup localGroup(config , "rules"); + QStringList localRules; - + n = listWidget->count(); - for(int i = 0; i < n; ++i) + for (int i = 0; i < n; ++i) { QListWidgetItem *item = listWidget->item(i); localRules << item->text(); } - localGroup.writeEntry( "local-rules" , localRules ); + localGroup.writeEntry("local-rules" , localRules); - ReKonfig::setAdBlockEnabled( checkEnableAdblock->isChecked() ); - ReKonfig::setHideAdsEnabled( checkHideAds->isChecked() ); - ReKonfig::setUpdateInterval( spinBox->value() ); + ReKonfig::setAdBlockEnabled(checkEnableAdblock->isChecked()); + ReKonfig::setHideAdsEnabled(checkHideAds->isChecked()); + ReKonfig::setUpdateInterval(spinBox->value()); _changed = false; emit changed(false); -- cgit v1.2.1