Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
PIM
PIM Messagelib
Commits
12f3461b
Commit
12f3461b
authored
Apr 20, 2016
by
Laurent Montel
😁
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove code
parent
f595c2db
Changes
27
Hide whitespace changes
Inline
Side-by-side
Showing
27 changed files
with
0 additions
and
2386 deletions
+0
-2386
messageviewer/src/adblock/adblockruleimpl.h
messageviewer/src/adblock/adblockruleimpl.h
+0
-46
messageviewer/src/adblock/common/adblockaddsubscriptiondialog.cpp
...iewer/src/adblock/common/adblockaddsubscriptiondialog.cpp
+0
-105
messageviewer/src/adblock/common/adblockaddsubscriptiondialog.h
...eviewer/src/adblock/common/adblockaddsubscriptiondialog.h
+0
-46
messageviewer/src/adblock/common/adblockautomaticruleslistwidget.cpp
...er/src/adblock/common/adblockautomaticruleslistwidget.cpp
+0
-109
messageviewer/src/adblock/common/adblockautomaticruleslistwidget.h
...ewer/src/adblock/common/adblockautomaticruleslistwidget.h
+0
-47
messageviewer/src/adblock/common/adblocklistwidget.cpp
messageviewer/src/adblock/common/adblocklistwidget.cpp
+0
-71
messageviewer/src/adblock/common/adblocklistwidget.h
messageviewer/src/adblock/common/adblocklistwidget.h
+0
-46
messageviewer/src/adblock/common/adblocksettingwidget.cpp
messageviewer/src/adblock/common/adblocksettingwidget.cpp
+0
-494
messageviewer/src/adblock/common/adblocksettingwidget.h
messageviewer/src/adblock/common/adblocksettingwidget.h
+0
-94
messageviewer/src/adblock/common/adblockshowlistdialog.cpp
messageviewer/src/adblock/common/adblockshowlistdialog.cpp
+0
-161
messageviewer/src/adblock/common/adblockshowlistdialog.h
messageviewer/src/adblock/common/adblockshowlistdialog.h
+0
-68
messageviewer/src/adblock/common/adblocksyntaxhighlighter.cpp
...ageviewer/src/adblock/common/adblocksyntaxhighlighter.cpp
+0
-54
messageviewer/src/adblock/common/adblocksyntaxhighlighter.h
messageviewer/src/adblock/common/adblocksyntaxhighlighter.h
+0
-37
messageviewer/src/adblock/common/adblockutil.cpp
messageviewer/src/adblock/common/adblockutil.cpp
+0
-71
messageviewer/src/adblock/common/adblockutil.h
messageviewer/src/adblock/common/adblockutil.h
+0
-35
messageviewer/src/adblock/common/autotests/CMakeLists.txt
messageviewer/src/adblock/common/autotests/CMakeLists.txt
+0
-14
messageviewer/src/adblock/common/autotests/adblockaddsubscriptiondialogtest.cpp
...ock/common/autotests/adblockaddsubscriptiondialogtest.cpp
+0
-65
messageviewer/src/adblock/common/autotests/adblockaddsubscriptiondialogtest.h
...block/common/autotests/adblockaddsubscriptiondialogtest.h
+0
-35
messageviewer/src/adblock/common/autotests/adblockautomaticruleslistwidgettest.cpp
.../common/autotests/adblockautomaticruleslistwidgettest.cpp
+0
-58
messageviewer/src/adblock/common/autotests/adblockautomaticruleslistwidgettest.h
...ck/common/autotests/adblockautomaticruleslistwidgettest.h
+0
-35
messageviewer/src/adblock/tests/CMakeLists.txt
messageviewer/src/adblock/tests/CMakeLists.txt
+0
-23
messageviewer/src/adblock/tests/adblockautomaticruleslistwidget_gui.cpp
...src/adblock/tests/adblockautomaticruleslistwidget_gui.cpp
+0
-81
messageviewer/src/adblock/tests/adblockautomaticruleslistwidget_gui.h
...r/src/adblock/tests/adblockautomaticruleslistwidget_gui.h
+0
-31
messageviewer/src/adblock/tests/adblocksettings_gui.cpp
messageviewer/src/adblock/tests/adblocksettings_gui.cpp
+0
-43
messageviewer/src/adblock/tests/adblocksettingsdialog_gui.cpp
...ageviewer/src/adblock/tests/adblocksettingsdialog_gui.cpp
+0
-62
messageviewer/src/adblock/ui/adblockcreatefilterwidget.ui
messageviewer/src/adblock/ui/adblockcreatefilterwidget.ui
+0
-199
messageviewer/src/adblock/ui/settings_adblock.ui
messageviewer/src/adblock/ui/settings_adblock.ui
+0
-256
No files found.
messageviewer/src/adblock/adblockruleimpl.h
deleted
100644 → 0
View file @
f595c2db
/* ============================================================
*
* This file is a part of the rekonq project
*
* Copyright (C) 2010-2011 by Benjamin Poulain <ikipou at gmail dot com>
*
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* ============================================================ */
#ifndef ADBLOCKRULEIMPL_H
#define ADBLOCKRULEIMPL_H
class
QString
;
class
QNetworkRequest
;
namespace
MessageViewer
{
class
AdBlockRuleImpl
{
public:
explicit
AdBlockRuleImpl
(
const
QString
&
)
{}
virtual
~
AdBlockRuleImpl
()
{}
virtual
bool
match
(
const
QNetworkRequest
&
request
,
const
QString
&
encodedUrl
,
const
QString
&
encodedUrlLowerCase
)
const
=
0
;
// This are added just for debugging purposes
virtual
QString
ruleString
()
const
=
0
;
virtual
QString
ruleType
()
const
=
0
;
};
}
#endif // ADBLOCKRULEIMPL_H
messageviewer/src/adblock/common/adblockaddsubscriptiondialog.cpp
deleted
100644 → 0
View file @
f595c2db
/*
Copyright (c) 2013-2016 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "adblockaddsubscriptiondialog.h"
#include "adblockshowlistdialog.h"
#include "adblockutil.h"
#include <KLocalizedString>
#include <QComboBox>
#include <QLabel>
#include <QHBoxLayout>
#include <QDialogButtonBox>
#include <QPushButton>
#include <QVBoxLayout>
#include <QToolButton>
#include <QPointer>
using
namespace
MessageViewer
;
AdBlockAddSubscriptionDialog
::
AdBlockAddSubscriptionDialog
(
const
QStringList
&
excludeList
,
QWidget
*
parent
)
:
QDialog
(
parent
)
{
setWindowTitle
(
i18n
(
"Add subscription"
));
QVBoxLayout
*
mainLayout
=
new
QVBoxLayout
;
setLayout
(
mainLayout
);
QWidget
*
w
=
new
QWidget
;
QHBoxLayout
*
lay
=
new
QHBoxLayout
;
lay
->
setMargin
(
0
);
QLabel
*
lab
=
new
QLabel
(
i18n
(
"Select List:"
));
lab
->
setObjectName
(
QStringLiteral
(
"listsubscriptionlabel"
));
lay
->
addWidget
(
lab
);
mListSubscription
=
new
QComboBox
;
mListSubscription
->
setObjectName
(
QStringLiteral
(
"listsubscriptioncombobox"
));
lay
->
addWidget
(
mListSubscription
);
mShowList
=
new
QToolButton
;
mShowList
->
setToolTip
(
i18n
(
"Show List"
));
mShowList
->
setObjectName
(
QStringLiteral
(
"showlisttoolbutton"
));
mShowList
->
setIcon
(
QIcon
::
fromTheme
(
QStringLiteral
(
"document-preview"
)));
lay
->
addWidget
(
mShowList
);
connect
(
mShowList
,
&
QToolButton
::
clicked
,
this
,
&
AdBlockAddSubscriptionDialog
::
slotShowList
);
QDialogButtonBox
*
buttonBox
=
new
QDialogButtonBox
(
QDialogButtonBox
::
Ok
|
QDialogButtonBox
::
Cancel
);
buttonBox
->
setObjectName
(
QStringLiteral
(
"listsubscriptionbuttonBox"
));
QPushButton
*
okButton
=
buttonBox
->
button
(
QDialogButtonBox
::
Ok
);
okButton
->
setDefault
(
true
);
okButton
->
setShortcut
(
Qt
::
CTRL
|
Qt
::
Key_Return
);
connect
(
buttonBox
,
&
QDialogButtonBox
::
accepted
,
this
,
&
AdBlockAddSubscriptionDialog
::
accept
);
connect
(
buttonBox
,
&
QDialogButtonBox
::
rejected
,
this
,
&
AdBlockAddSubscriptionDialog
::
reject
);
w
->
setLayout
(
lay
);
mainLayout
->
addWidget
(
w
);
mainLayout
->
addWidget
(
buttonBox
);
initializeList
(
excludeList
);
}
AdBlockAddSubscriptionDialog
::~
AdBlockAddSubscriptionDialog
()
{
}
void
AdBlockAddSubscriptionDialog
::
initializeList
(
const
QStringList
&
excludeList
)
{
QMapIterator
<
QString
,
QString
>
i
(
MessageViewer
::
AdBlockUtil
::
listSubscriptions
());
while
(
i
.
hasNext
())
{
i
.
next
();
if
(
!
excludeList
.
contains
(
i
.
key
()))
{
mListSubscription
->
addItem
(
i
.
key
(),
i
.
value
());
}
}
}
void
AdBlockAddSubscriptionDialog
::
selectedList
(
QString
&
name
,
QString
&
url
)
{
name
=
mListSubscription
->
currentText
();
url
=
mListSubscription
->
itemData
(
mListSubscription
->
currentIndex
()).
toString
();
}
void
AdBlockAddSubscriptionDialog
::
slotShowList
()
{
const
QString
url
=
mListSubscription
->
itemData
(
mListSubscription
->
currentIndex
()).
toString
();
if
(
!
url
.
isEmpty
())
{
QPointer
<
AdBlockShowListDialog
>
dlg
=
new
AdBlockShowListDialog
(
false
,
this
);
dlg
->
setListName
(
mListSubscription
->
currentText
());
dlg
->
setAdBlockListPath
(
QString
(),
url
);
dlg
->
exec
();
delete
dlg
;
}
}
messageviewer/src/adblock/common/adblockaddsubscriptiondialog.h
deleted
100644 → 0
View file @
f595c2db
/*
Copyright (c) 2013-2016 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef ADBLOCKADDSUBSCRIPTIONDIALOG_H
#define ADBLOCKADDSUBSCRIPTIONDIALOG_H
#include <QDialog>
class
QComboBox
;
class
QToolButton
;
namespace
MessageViewer
{
class
AdBlockAddSubscriptionDialog
:
public
QDialog
{
Q_OBJECT
public:
explicit
AdBlockAddSubscriptionDialog
(
const
QStringList
&
excludeList
,
QWidget
*
parent
=
Q_NULLPTR
);
~
AdBlockAddSubscriptionDialog
();
void
selectedList
(
QString
&
name
,
QString
&
url
);
private
Q_SLOTS
:
void
slotShowList
();
private:
void
initializeList
(
const
QStringList
&
excludeList
);
QComboBox
*
mListSubscription
;
QToolButton
*
mShowList
;
};
}
#endif // ADBLOCKADDSUBSCRIPTIONDIALOG_H
messageviewer/src/adblock/common/adblockautomaticruleslistwidget.cpp
deleted
100644 → 0
View file @
f595c2db
/*
Copyright (c) 2016 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "adblockautomaticruleslistwidget.h"
using
namespace
MessageViewer
;
AdBlockAutomaticRulesListWidget
::
AdBlockAutomaticRulesListWidget
(
QWidget
*
parent
)
:
QListWidget
(
parent
)
{
connect
(
this
,
&
AdBlockAutomaticRulesListWidget
::
itemChanged
,
this
,
&
AdBlockAutomaticRulesListWidget
::
slotItemChanged
);
}
AdBlockAutomaticRulesListWidget
::~
AdBlockAutomaticRulesListWidget
()
{
}
void
AdBlockAutomaticRulesListWidget
::
slotItemChanged
(
QListWidgetItem
*
item
)
{
updateItem
(
item
);
}
void
AdBlockAutomaticRulesListWidget
::
updateItem
(
QListWidgetItem
*
item
)
{
const
bool
itemIsChecked
=
(
item
->
checkState
()
&
Qt
::
Checked
);
QFont
font
=
item
->
font
();
const
QString
rule
=
item
->
text
();
if
(
itemIsChecked
)
{
font
.
setItalic
(
false
);
item
->
setFont
(
font
);
if
(
rule
.
contains
(
QRegularExpression
(
QStringLiteral
(
"^@@.*"
))))
{
item
->
setTextColor
(
Qt
::
magenta
);
}
else
if
(
rule
.
contains
(
QRegularExpression
(
QStringLiteral
(
"^
\\
[.*"
))))
{
item
->
setTextColor
(
Qt
::
red
);
}
else
if
(
rule
.
contains
(
QRegularExpression
(
QStringLiteral
(
".*##.*"
))))
{
item
->
setTextColor
(
Qt
::
blue
);
}
else
{
if
(
!
defaultTextColor
.
isValid
())
{
const
QPalette
palette
=
viewport
()
->
palette
();
defaultTextColor
=
palette
.
text
().
color
();
}
item
->
setTextColor
(
defaultTextColor
);
}
}
else
{
font
.
setItalic
(
true
);
item
->
setFont
(
font
);
item
->
setTextColor
(
Qt
::
gray
);
}
}
void
AdBlockAutomaticRulesListWidget
::
setDisabledRules
(
const
QStringList
&
disabledRules
)
{
mDisabledRules
=
disabledRules
;
}
void
AdBlockAutomaticRulesListWidget
::
setRules
(
const
QString
&
rules
)
{
clear
();
const
QStringList
lst
=
rules
.
split
(
QLatin1Char
(
'\n'
),
QString
::
SkipEmptyParts
);
Q_FOREACH
(
const
QString
&
rule
,
lst
)
{
createItem
(
rule
);
}
}
void
AdBlockAutomaticRulesListWidget
::
createItem
(
const
QString
&
rule
)
{
QListWidgetItem
*
subItem
=
new
QListWidgetItem
(
this
);
subItem
->
setText
(
rule
);
if
(
rule
.
startsWith
(
QLatin1Char
(
'!'
))
||
rule
.
startsWith
(
QLatin1Char
(
'['
)))
{
//Comment
subItem
->
setFlags
(
Qt
::
ItemIsEnabled
|
Qt
::
ItemIsSelectable
|
Qt
::
ItemIsDragEnabled
);
subItem
->
setTextColor
(
Qt
::
gray
);
}
else
{
subItem
->
setFlags
(
Qt
::
ItemIsEnabled
|
Qt
::
ItemIsUserCheckable
|
Qt
::
ItemIsSelectable
|
Qt
::
ItemIsDragEnabled
);
const
bool
checkState
=
mDisabledRules
.
contains
(
rule
);
subItem
->
setCheckState
(
checkState
?
Qt
::
Unchecked
:
Qt
::
Checked
);
updateItem
(
subItem
);
}
}
QStringList
AdBlockAutomaticRulesListWidget
::
disabledRules
()
const
{
QStringList
currentDisabledRules
;
for
(
int
i
=
0
;
i
<
count
();
++
i
)
{
QListWidgetItem
*
row
=
item
(
i
);
if
(
row
->
flags
()
&
Qt
::
ItemIsUserCheckable
)
{
if
(
row
->
checkState
()
==
Qt
::
Unchecked
)
{
currentDisabledRules
<<
row
->
text
();
}
}
}
return
currentDisabledRules
;
}
messageviewer/src/adblock/common/adblockautomaticruleslistwidget.h
deleted
100644 → 0
View file @
f595c2db
/*
Copyright (c) 2016 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef ADBLOCKAUTOMATICRULESLISTWIDGET_H
#define ADBLOCKAUTOMATICRULESLISTWIDGET_H
#include <QListWidget>
#include "messageviewer_export.h"
namespace
MessageViewer
{
class
MESSAGEVIEWER_EXPORT
AdBlockAutomaticRulesListWidget
:
public
QListWidget
{
Q_OBJECT
public:
explicit
AdBlockAutomaticRulesListWidget
(
QWidget
*
parent
=
Q_NULLPTR
);
~
AdBlockAutomaticRulesListWidget
();
void
setRules
(
const
QString
&
rules
);
void
setDisabledRules
(
const
QStringList
&
disabledRules
);
QStringList
disabledRules
()
const
;
private
Q_SLOTS
:
void
slotItemChanged
(
QListWidgetItem
*
item
);
private:
void
updateItem
(
QListWidgetItem
*
item
);
void
createItem
(
const
QString
&
rule
);
QStringList
mDisabledRules
;
QColor
defaultTextColor
;
};
}
#endif // ADBLOCKAUTOMATICRULESLISTWIDGET_H
messageviewer/src/adblock/common/adblocklistwidget.cpp
deleted
100644 → 0
View file @
f595c2db
/*
Copyright (c) 2013-2016 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "adblocklistwidget.h"
#include <KLocalizedString>
#include <QPainter>
#include <QPaintEvent>
using
namespace
MessageViewer
;
AdBlockListWidget
::
AdBlockListWidget
(
QWidget
*
parent
)
:
QListWidget
(
parent
)
{
}
AdBlockListWidget
::~
AdBlockListWidget
()
{
}
void
AdBlockListWidget
::
changeEvent
(
QEvent
*
event
)
{
if
(
event
->
type
()
==
QEvent
::
PaletteChange
)
{
generalPaletteChanged
();
}
QListWidget
::
changeEvent
(
event
);
}
void
AdBlockListWidget
::
generalPaletteChanged
()
{
const
QPalette
palette
=
viewport
()
->
palette
();
QColor
color
=
palette
.
text
().
color
();
color
.
setAlpha
(
128
);
mTextColor
=
color
;
}
void
AdBlockListWidget
::
paintEvent
(
QPaintEvent
*
event
)
{
if
(
!
model
()
||
model
()
->
rowCount
()
==
0
)
{
QPainter
p
(
viewport
());
QFont
font
=
p
.
font
();
font
.
setItalic
(
true
);
p
.
setFont
(
font
);
if
(
!
mTextColor
.
isValid
())
{
generalPaletteChanged
();
}
p
.
setPen
(
mTextColor
);
p
.
drawText
(
QRect
(
0
,
0
,
width
(),
height
()),
Qt
::
AlignCenter
,
i18n
(
"Not subscription added..."
));
}
else
{
QListWidget
::
paintEvent
(
event
);
}
}
messageviewer/src/adblock/common/adblocklistwidget.h
deleted
100644 → 0
View file @
f595c2db
/*
Copyright (c) 2013-2016 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef ADBLOCKLISTWIDGET_H
#define ADBLOCKLISTWIDGET_H
#include <QListWidget>
class
QPaintEvent
;
class
QEvent
;
namespace
MessageViewer
{
class
AdBlockListWidget
:
public
QListWidget
{
Q_OBJECT
public:
explicit
AdBlockListWidget
(
QWidget
*
parent
=
Q_NULLPTR
);
~
AdBlockListWidget
();
private:
void
generalPaletteChanged
();
protected:
void
paintEvent
(
QPaintEvent
*
event
)
Q_DECL_OVERRIDE
;
void
changeEvent
(
QEvent
*
event
)
Q_DECL_OVERRIDE
;
private:
QColor
mTextColor
;
};
}
#endif // ADBLOCKLISTWIDGET_H
messageviewer/src/adblock/common/adblocksettingwidget.cpp
deleted
100644 → 0
View file @
f595c2db
/* ============================================================
*
* This file is a part of the rekonq project
*
* Copyright (c) 2013-2016 Montel Laurent <montel@kde.org>
* based on code from rekonq
* Copyright (C) 2010-2012 by Andrea Diamantini <adjam7 at gmail dot com>
*
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* ============================================================ */
// Self Includes
#include "config-messageviewer.h"
#include "adblocksettingwidget.h"
#include "ui_settings_adblock.h"
#include "messageviewer_debug.h"
#include "settings/messageviewersettings.h"
#include "adblockaddsubscriptiondialog.h"
#include "adblockshowlistdialog.h"
#include "adblock/common/adblockutil.h"
#include "PimCommon/ConfigureImmutableWidgetUtils"
using
namespace
PimCommon
::
ConfigureImmutableWidgetUtils
;
#include "PimCommon/PimUtil"
// KDE Includes
#include <KSharedConfig>
#include <QIcon>
#include <KMessageBox>
#include <KLocalizedString>
#include <QWhatsThisClickedEvent>
// Qt Includes
#include <QWhatsThis>
#include <QListWidgetItem>
#include <QFile>
#include <QPointer>
#include <QTextStream>
#include <QStandardPaths>
#include <QRegularExpression>
#include <KRun>
using
namespace
MessageViewer
;
AdBlockSettingWidget
::
AdBlockSettingWidget
(
QWidget
*
parent
)
:
QWidget
(
parent
)
,
mChanged
(
false
)
{
mUi
=
new
Ui
::
adblock
;
mUi
->
setupUi
(
this
);
mUi
->
hintLabel
->
setText
(
i18n
(
"<qt>Filter expression (e.g. <tt>http://www.example.com/ad/*</tt>, <a href=
\"
filterhelp
\"
>more information</a>):"
));
connect
(
mUi
->
hintLabel
,
&
QLabel
::
linkActivated
,
this
,
&
AdBlockSettingWidget
::
slotInfoLinkActivated
);
mUi
->
hintLabel
->
setContextMenuPolicy
(
Qt
::
NoContextMenu
);
mUi
->
manualFiltersListWidget
->
setSelectionMode
(
QAbstractItemView
::
MultiSelection
);
mUi
->
searchLine
->
setListWidget
(
mUi
->
manualFiltersListWidget
);
mUi
->
insertButton
->
setIcon
(
QIcon
::
fromTheme
(
QStringLiteral
(
"list-add"
)));
connect
(
mUi
->
insertButton
,
&
QToolButton
::
clicked
,
this
,
&
AdBlockSettingWidget
::
insertRule
);
mUi
->
removeButton
->
setIcon
(
QIcon
::
fromTheme
(
QStringLiteral
(
"list-remove"
)));
connect
(
mUi
->
removeButton
,
&
QPushButton
::
clicked
,
this
,
&
AdBlockSettingWidget
::
removeRule
);
connect
(
mUi
->
removeSubscription
,
&
QPushButton
::
clicked
,
this
,
&
AdBlockSettingWidget
::
slotRemoveSubscription
);
connect
(
mUi
->
manualFiltersListWidget
,
&
QListWidget
::
currentItemChanged
,
this
,
&
AdBlockSettingWidget
::
slotUpdateManualButtons
);
connect
(
mUi
->
manualFiltersListWidget
,
&
QListWidget
::
itemChanged
,
this
,
&
AdBlockSettingWidget
::
hasChanged
);
mUi
->
spinBox
->
setSuffix
(
ki18np
(
" day"
,
" days"
));
mUi
->
removeSubscription
->
setEnabled
(
false
);
mUi
->
showList
->
setEnabled
(
false
);
// Q_EMIT changed signal
connect
(
mUi
->
checkEnableAdblock
,
&
QCheckBox
::
stateChanged
,
this
,
&
AdBlockSettingWidget
::
hasChanged
);
connect
(
mUi
->
checkHideAds
,
&
QCheckBox
::
stateChanged
,
this
,
&
AdBlockSettingWidget
::
hasChanged
);
connect
(
mUi
->
spinBox
,
static_cast
<
void
(
KPluralHandlingSpinBox
::*
)(
int
)
>
(
&
KPluralHandlingSpinBox
::
valueChanged
),
this
,
&
AdBlockSettingWidget
::
hasChanged
);
connect
(
mUi
->
addFilters
,
&
QPushButton
::
clicked
,
this
,
&
AdBlockSettingWidget
::
slotAddFilter
);
connect
(
mUi
->
showList
,
&
QPushButton
::
clicked
,
this
,
&
AdBlockSettingWidget
::
slotShowList
);
connect
(
mUi
->
editFilter
,
&
QPushButton
::
clicked
,
this
,
&
AdBlockSettingWidget
::
slotEditFilter
);
connect
(
mUi
->
automaticFiltersListWidget
,
&
MessageViewer
::
AdBlockListWidget
::
itemChanged
,
this
,
&
AdBlockSettingWidget
::
hasChanged
);
connect
(
mUi
->
automaticFiltersListWidget
,
&
MessageViewer
::
AdBlockListWidget
::
currentItemChanged
,
this
,
&
AdBlockSettingWidget
::
slotUpdateButtons
);
connect
(
mUi
->
automaticFiltersListWidget
,
&
MessageViewer
::
AdBlockListWidget
::
itemDoubleClicked
,
this
,
&
AdBlockSettingWidget
::
slotAutomaticFilterDouble
);
connect
(
mUi
->
importFilters
,
&
QPushButton
::
clicked
,
this
,
&
AdBlockSettingWidget
::
slotImportFilters
);
connect
(
mUi
->
exportFilters
,
&
QPushButton
::
clicked
,
this
,
&
AdBlockSettingWidget
::
slotExportFilters
);
connect
(
mUi
->
addFilterLineEdit
,
&
QLineEdit
::
textChanged
,
this
,
&
AdBlockSettingWidget
::
slotManualFilterLineEditTextChanged
);