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
f1bd8fc4
Commit
f1bd8fc4
authored
Mar 13, 2016
by
Laurent Montel
😁
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
git://anongit.kde.org/messagelib
parents
f359d455
26440e1d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
18 deletions
+49
-18
messageviewer/src/adblock/common/adblockautomaticruleslistwidget.cpp
...er/src/adblock/common/adblockautomaticruleslistwidget.cpp
+19
-10
messageviewer/src/adblock/common/adblockautomaticruleslistwidget.h
...ewer/src/adblock/common/adblockautomaticruleslistwidget.h
+2
-2
messageviewer/src/adblock/common/autotests/CMakeLists.txt
messageviewer/src/adblock/common/autotests/CMakeLists.txt
+1
-1
messageviewer/src/adblock/tests/adblockautomaticruleslistwidget_gui.cpp
...src/adblock/tests/adblockautomaticruleslistwidget_gui.cpp
+26
-4
messageviewer/src/adblock/tests/adblockautomaticruleslistwidget_gui.h
...r/src/adblock/tests/adblockautomaticruleslistwidget_gui.h
+1
-1
No files found.
messageviewer/src/adblock/common/adblockautomaticruleslistwidget.cpp
View file @
f1bd8fc4
...
...
@@ -39,8 +39,24 @@ void AdBlockAutomaticRulesListWidget::updateItem(QListWidgetItem *item)
{
const
bool
itemIsChecked
=
(
item
->
checkState
()
&
Qt
::
Checked
);
QFont
font
=
item
->
font
();
font
.
setItalic
(
!
itemIsChecked
);
item
->
setFont
(
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
{
item
->
setTextColor
(
Qt
::
black
);
}
}
else
{
font
.
setItalic
(
true
);
item
->
setFont
(
font
);
item
->
setTextColor
(
Qt
::
gray
);
}
}
void
AdBlockAutomaticRulesListWidget
::
setDisabledRules
(
const
QStringList
&
disabledRules
)
...
...
@@ -64,19 +80,12 @@ void AdBlockAutomaticRulesListWidget::createItem(const QString &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
);
if
(
rule
.
contains
(
QRegularExpression
(
QStringLiteral
(
"^@@.*"
))))
{
subItem
->
setTextColor
(
Qt
::
magenta
);
}
else
if
(
rule
.
contains
(
QRegularExpression
(
QStringLiteral
(
"^
\\
[.*"
))))
{
subItem
->
setTextColor
(
Qt
::
red
);
}
else
if
(
rule
.
contains
(
QRegularExpression
(
QStringLiteral
(
".*##.*"
))))
{
subItem
->
setTextColor
(
Qt
::
blue
);
}
}
}
...
...
messageviewer/src/adblock/common/adblockautomaticruleslistwidget.h
View file @
f1bd8fc4
...
...
@@ -19,10 +19,10 @@
#define ADBLOCKAUTOMATICRULESLISTWIDGET_H
#include <QListWidget>
#include "messageviewer_export.h"
namespace
MessageViewer
{
class
AdBlockAutomaticRulesListWidget
:
public
QListWidget
class
MESSAGEVIEWER_EXPORT
AdBlockAutomaticRulesListWidget
:
public
QListWidget
{
Q_OBJECT
public:
...
...
messageviewer/src/adblock/common/autotests/CMakeLists.txt
View file @
f1bd8fc4
...
...
@@ -11,4 +11,4 @@ set( adblockautomaticruleslistwidgettest_SRCS adblockautomaticruleslistwidgettes
add_executable
(
adblockautomaticruleslistwidgettest
${
adblockautomaticruleslistwidgettest_SRCS
}
)
add_test
(
adblockautomaticruleslistwidgettest adblockautomaticruleslistwidgettest
)
ecm_mark_as_test
(
adblockautomaticruleslistwidgettest
)
target_link_libraries
(
adblockautomaticruleslistwidgettest Qt5::Test Qt5::Widgets
)
target_link_libraries
(
adblockautomaticruleslistwidgettest Qt5::Test Qt5::Widgets
KF5::MessageViewer
)
messageviewer/src/adblock/tests/adblockautomaticruleslistwidget_gui.cpp
View file @
f1bd8fc4
...
...
@@ -16,6 +16,7 @@
*/
#include "adblockautomaticruleslistwidget_gui.h"
#include "../common/adblockautomaticruleslistwidget.h"
#include <KAboutData>
...
...
@@ -24,12 +25,20 @@
#include <QHBoxLayout>
#include <QApplication>
#include <QStandardPaths>
#include <QFileDialog>
AdBlockAutomaticRulesListWidgetTest
::
AdBlockAutomaticRulesListWidgetTest
(
QWidget
*
parent
)
AdBlockAutomaticRulesListWidgetTest
::
AdBlockAutomaticRulesListWidgetTest
(
const
QString
&
fileName
,
QWidget
*
parent
)
:
QWidget
(
parent
)
{
QVBoxLayout
*
lay
=
new
QVBoxLayout
;
QVBoxLayout
*
lay
=
new
QVBoxLayout
(
this
);
QFile
localFile
(
fileName
);
QString
adblockList
;
if
(
localFile
.
open
(
QIODevice
::
ReadOnly
|
QIODevice
::
Text
))
{
adblockList
=
QString
::
fromLatin1
(
localFile
.
readAll
());
}
MessageViewer
::
AdBlockAutomaticRulesListWidget
*
list
=
new
MessageViewer
::
AdBlockAutomaticRulesListWidget
(
this
);
list
->
setRules
(
adblockList
);
lay
->
addWidget
(
list
);
}
AdBlockAutomaticRulesListWidgetTest
::~
AdBlockAutomaticRulesListWidgetTest
()
...
...
@@ -46,12 +55,25 @@ int main(int argc, char **argv)
KAboutData
::
setApplicationData
(
aboutData
);
parser
.
addVersionOption
();
parser
.
addHelpOption
();
parser
.
addOption
(
QCommandLineOption
(
QStringList
()
<<
QStringLiteral
(
"+[url]"
),
i18n
(
"URL of adblock file list"
)));
aboutData
.
setupCommandLine
(
&
parser
);
parser
.
process
(
app
);
aboutData
.
processCommandLine
(
&
parser
);
AdBlockAutomaticRulesListWidgetTest
*
w
=
new
AdBlockAutomaticRulesListWidgetTest
();
QString
fileName
;
if
(
parser
.
positionalArguments
().
count
())
{
fileName
=
parser
.
positionalArguments
().
at
(
0
);
}
else
{
fileName
=
QFileDialog
::
getOpenFileName
(
0
,
QString
(),
QString
(),
i18n
(
"Adblock File (*)"
));
}
if
(
fileName
.
isEmpty
())
{
return
0
;
}
AdBlockAutomaticRulesListWidgetTest
*
w
=
new
AdBlockAutomaticRulesListWidgetTest
(
fileName
);
w
->
resize
(
800
,
600
);
w
->
show
();
...
...
messageviewer/src/adblock/tests/adblockautomaticruleslistwidget_gui.h
View file @
f1bd8fc4
...
...
@@ -24,7 +24,7 @@ class AdBlockAutomaticRulesListWidgetTest : public QWidget
{
Q_OBJECT
public:
explicit
AdBlockAutomaticRulesListWidgetTest
(
QWidget
*
parent
=
Q_NULLPTR
);
explicit
AdBlockAutomaticRulesListWidgetTest
(
const
QString
&
fileName
,
QWidget
*
parent
=
Q_NULLPTR
);
~
AdBlockAutomaticRulesListWidgetTest
();
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment