Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
PIM Messagelib
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PIM
PIM Messagelib
Commits
c3737265
Commit
c3737265
authored
Aug 10, 2016
by
Laurent Montel
😁
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove old code (unused)
parent
780e95bd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
0 additions
and
267 deletions
+0
-267
messageviewer/src/CMakeLists.txt
messageviewer/src/CMakeLists.txt
+0
-1
messageviewer/src/widgets/mailsourceviewer.cpp
messageviewer/src/widgets/mailsourceviewer.cpp
+0
-204
messageviewer/src/widgets/mailsourceviewer.h
messageviewer/src/widgets/mailsourceviewer.h
+0
-62
No files found.
messageviewer/src/CMakeLists.txt
View file @
c3737265
...
...
@@ -79,7 +79,6 @@ set(libmessageviewer_widgets_SRCS
widgets/vcardviewer.cpp
widgets/invitationsettings.cpp
widgets/openattachmentfolderwidget.cpp
widgets/mailsourceviewer.cpp
widgets/mailsourceviewtextbrowserwidget.cpp
)
...
...
messageviewer/src/widgets/mailsourceviewer.cpp
deleted
100644 → 0
View file @
780e95bd
/*
*
* This file is part of KMail, the KDE mail client.
*
* Copyright (c) 2002-2003 Carsten Pfeiffer <pfeiffer@kde.org>
* Copyright (c) 2003 Zack Rusin <zack@kde.org>
*
* KMail 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.
*
* KMail 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
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of this program with any edition of
* the Qt library by Trolltech AS, Norway (or with modified versions
* of Qt that use the same license as Qt), and distribute linked
* combinations including the two. You must obey the GNU General
* Public License in all respects for all of the code used other than
* Qt. If you modify this file, you may extend this exception to
* your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from
* your version.
*/
#include "mailsourceviewer.h"
#include "mailsourceviewtextbrowserwidget.h"
#include "messageviewer/messageviewerutil.h"
#include "findbar/findbarsourceview.h"
#include <kpimtextedit/htmlhighlighter.h>
#include "kpimtextedit/slidecontainer.h"
#include "PimCommon/PimUtil"
#include <kiconloader.h>
#include <KLocalizedString>
#include <kwindowsystem.h>
#include <QTabWidget>
#include <KIconTheme>
#include <QRegExp>
#include <QApplication>
#include <QShortcut>
#include <QVBoxLayout>
#include <QDialogButtonBox>
#include <QPushButton>
namespace
MessageViewer
{
MailSourceViewer
::
MailSourceViewer
(
QWidget
*
parent
)
:
QDialog
(
parent
),
mFindBar
(
Q_NULLPTR
)
{
setAttribute
(
Qt
::
WA_DeleteOnClose
);
QVBoxLayout
*
mainLayout
=
new
QVBoxLayout
(
this
);
QDialogButtonBox
*
buttonBox
=
new
QDialogButtonBox
(
QDialogButtonBox
::
Close
,
this
);
connect
(
buttonBox
,
&
QDialogButtonBox
::
rejected
,
this
,
&
MailSourceViewer
::
reject
);
connect
(
buttonBox
->
button
(
QDialogButtonBox
::
Close
),
&
QPushButton
::
clicked
,
this
,
&
MailSourceViewer
::
close
);
mRawBrowser
=
new
MailSourceViewTextBrowserWidget
(
this
);
#ifndef NDEBUG
mTabWidget
=
new
QTabWidget
(
this
);
mainLayout
->
addWidget
(
mTabWidget
);
mTabWidget
->
addTab
(
mRawBrowser
,
i18nc
(
"Unchanged mail message"
,
"Raw Source"
));
mTabWidget
->
setTabToolTip
(
0
,
i18n
(
"Raw, unmodified mail as it is stored on the filesystem or on the server"
));
mHtmlBrowser
=
new
MailSourceViewTextBrowserWidget
(
this
);
mTabWidget
->
addTab
(
mHtmlBrowser
,
i18nc
(
"Mail message as shown, in HTML format"
,
"HTML Source"
));
mTabWidget
->
setTabToolTip
(
1
,
i18n
(
"HTML code for displaying the message to the user"
));
new
KPIMTextEdit
::
HtmlHighlighter
(
mHtmlBrowser
->
textBrowser
()
->
document
());
mTabWidget
->
setCurrentIndex
(
0
);
#else
mainLayout
->
addWidget
(
mRawBrowser
);
#endif
// combining the shortcuts in one qkeysequence() did not work...
QShortcut
*
shortcut
=
new
QShortcut
(
this
);
shortcut
->
setKey
(
Qt
::
Key_Escape
);
connect
(
shortcut
,
&
QShortcut
::
activated
,
this
,
&
MailSourceViewer
::
close
);
shortcut
=
new
QShortcut
(
this
);
shortcut
->
setKey
(
Qt
::
Key_W
+
Qt
::
CTRL
);
connect
(
shortcut
,
&
QShortcut
::
activated
,
this
,
&
MailSourceViewer
::
close
);
KWindowSystem
::
setIcons
(
winId
(),
qApp
->
windowIcon
().
pixmap
(
IconSize
(
KIconLoader
::
Desktop
),
IconSize
(
KIconLoader
::
Desktop
)),
qApp
->
windowIcon
().
pixmap
(
IconSize
(
KIconLoader
::
Small
),
IconSize
(
KIconLoader
::
Small
)));
new
MailSourceHighlighter
(
mRawBrowser
->
textBrowser
()
->
document
());
mRawBrowser
->
textBrowser
()
->
setFocus
();
mainLayout
->
addWidget
(
buttonBox
);
}
MailSourceViewer
::~
MailSourceViewer
()
{
}
void
MailSourceViewer
::
setRawSource
(
const
QString
&
source
)
{
mRawBrowser
->
setText
(
source
);
}
void
MailSourceViewer
::
setDisplayedSource
(
const
QString
&
source
)
{
#ifndef NDEBUG
mHtmlBrowser
->
setPlainText
(
reformat
(
source
));
#else
Q_UNUSED
(
source
);
#endif
}
void
MailSourceViewer
::
setFixedFont
()
{
mRawBrowser
->
setFixedFont
();
#ifndef NDEBUG
mHtmlBrowser
->
setFixedFont
();
#endif
}
QString
MailSourceViewer
::
reformat
(
const
QString
&
src
)
{
const
QRegExp
cleanLeadingWhitespace
(
QStringLiteral
(
"(?:
\\
n)+
\\
w*"
));
QStringList
tmpSource
;
QString
source
(
src
);
int
pos
=
0
;
QString
indent
;
// Best to be really verbose about this one...
const
static
QRegExp
htmlTagRegExp
(
QStringLiteral
(
"<"
"(/)?"
//Captures the / if this is an end tag.
"(
\\
w+)"
//Captures TagName
"(?:"
//Groups tag contents
"(?:
\\
s+"
//Groups attributes
"(?:
\\
w+)"
//Attribute name
"(?:"
//groups =value portion.
"
\\
s*=
\\
s*"
// =
"(?:"
//Groups attribute "value" portion.
"
\\\"
(?:[^
\\\"
]*)
\\\"
"
// attVal='double quoted'
"|'(?:[^']*)'"
// attVal='single quoted'
"|(?:[^'"">
\\
s]+)"
// attVal=urlnospaces
")"
")?"
//end optional att value portion.
")+
\\
s*"
//One or more attribute pairs
"|
\\
s*"
//Some white space.
")"
"(/)?>"
//Captures the "/" if this is a complete tag.
));
//First make sure that each tag is surrounded by newlines
while
((
pos
=
htmlTagRegExp
.
indexIn
(
source
,
pos
))
!=
-
1
)
{
source
.
insert
(
pos
,
QLatin1Char
(
'\n'
));
pos
+=
htmlTagRegExp
.
matchedLength
()
+
1
;
source
.
insert
(
pos
,
QLatin1Char
(
'\n'
));
++
pos
;
}
// Then split the source on newlines skiping empty parts.
// Now a line is either a tag or pure data.
tmpSource
=
source
.
split
(
QLatin1Char
(
'\n'
),
QString
::
SkipEmptyParts
);
// Then clean any leading whitespace
for
(
int
i
=
0
;
i
!=
tmpSource
.
length
();
++
i
)
{
tmpSource
[
i
]
=
tmpSource
[
i
].
remove
(
cleanLeadingWhitespace
);
}
// Then indent as appropriate
for
(
int
i
=
0
;
i
!=
tmpSource
.
length
();
++
i
)
{
if
(
htmlTagRegExp
.
indexIn
(
tmpSource
.
at
(
i
))
!=
-
1
)
{
// A tag
if
(
htmlTagRegExp
.
cap
(
3
)
==
QLatin1String
(
"/"
)
||
htmlTagRegExp
.
cap
(
2
)
==
QLatin1String
(
"img"
)
||
htmlTagRegExp
.
cap
(
2
)
==
QLatin1String
(
"br"
))
{
//Self closing tag or no closure needed
continue
;
}
if
(
htmlTagRegExp
.
cap
(
1
)
==
QLatin1String
(
"/"
))
{
// End tag
indent
.
chop
(
2
);
tmpSource
[
i
].
prepend
(
indent
);
continue
;
}
// start tag
tmpSource
[
i
].
prepend
(
indent
);
indent
.
append
(
QStringLiteral
(
" "
));
continue
;
}
// Data
tmpSource
[
i
].
prepend
(
indent
);
}
// Finally reassemble and return :)
return
tmpSource
.
join
(
QStringLiteral
(
"
\n
"
));
}
}
messageviewer/src/widgets/mailsourceviewer.h
deleted
100644 → 0
View file @
780e95bd
/*
*
* This file is part of KMail, the KDE mail client.
*
* Copyright (c) 2002-2003 Carsten Pfeiffer <pfeiffer@kde.org>
* Copyright (c) 2003 Zack Rusin <zack@kde.org>
*
* KMail 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.
*
* KMail 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
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of this program with any edition of
* the Qt library by Trolltech AS, Norway (or with modified versions
* of Qt that use the same license as Qt), and distribute linked
* combinations including the two. You must obey the GNU General
* Public License in all respects for all of the code used other than
* Qt. If you modify this file, you may extend this exception to
* your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from
* your version.
*/
#ifndef MAILSOURCEVIEWER_H
#define MAILSOURCEVIEWER_H
#include <QDialog>
class
QTabWidget
;
namespace
MessageViewer
{
class
FindBarSourceView
;
class
MailSourceViewTextBrowserWidget
;
class
MailSourceViewer
:
public
QDialog
{
Q_OBJECT
public:
explicit
MailSourceViewer
(
QWidget
*
parent
=
Q_NULLPTR
);
~
MailSourceViewer
();
void
setRawSource
(
const
QString
&
source
);
void
setDisplayedSource
(
const
QString
&
source
);
void
setFixedFont
();
private:
QString
reformat
(
const
QString
&
src
);
MailSourceViewTextBrowserWidget
*
mRawBrowser
;
FindBarSourceView
*
mFindBar
;
#ifndef NDEBUG
QTabWidget
*
mTabWidget
;
MailSourceViewTextBrowserWidget
*
mHtmlBrowser
;
#endif
};
}
#endif // MAILSOURCEVIEWER_H
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