Git commit 73a99b8c1ebcf9cbe7cfff245ec7d916bce13060 by Montel Laurent. Committed on 31/10/2014 at 22:08. Pushed by mlaurent into branch 'master'. Split in own file. M +2 -1 messageviewer/CMakeLists.txt M +1 -0 messageviewer/autotests/CMakeLists.txt A +32 -0 messageviewer/autotests/mailsourceviewtextbrowserwidgettest.= cpp [License: GPL (v2)] A +32 -0 messageviewer/autotests/mailsourceviewtextbrowserwidgettest.= h [License: GPL (v2)] M +1 -1 messageviewer/viewer/viewer_p.cpp A +146 -0 messageviewer/widgets/mailsourceviewer.cpp [License: GPL= (v2) (+Qt exception)] A +68 -0 messageviewer/widgets/mailsourceviewer.h [License: GPL (= v2) (+Qt exception)] R +2 -85 messageviewer/widgets/mailsourceviewtextbrowserwidget.cpp [f= rom: messageviewer/viewer/mailsourceviewer.cpp - 074% similarity] R +4 -25 messageviewer/widgets/mailsourceviewtextbrowserwidget.h [fro= m: messageviewer/viewer/mailsourceviewer.h - 088% similarity] http://commits.kde.org/kdepim/73a99b8c1ebcf9cbe7cfff245ec7d916bce13060 diff --git a/messageviewer/CMakeLists.txt b/messageviewer/CMakeLists.txt index 86a43d5..cc5b571 100644 --- a/messageviewer/CMakeLists.txt +++ b/messageviewer/CMakeLists.txt @@ -76,7 +76,6 @@ set(libmessageviewer_viewer_SRCS viewer/csshelperbase.cpp viewer/editorwatcher.cpp viewer/kleojobexecutor.cpp - viewer/mailsourceviewer.cpp viewer/htmlquotecolorer.cpp viewer/mimetreemodel.cpp viewer/nodehelper.cpp @@ -106,6 +105,8 @@ set(libmessageviewer_widgets_SRCS widgets/eventedit.cpp widgets/openattachmentfolderwidget.cpp widgets/eventdatetimewidget.cpp + widgets/mailsourceviewer.cpp + widgets/mailsourceviewtextbrowserwidget.cpp ) = set(libmessageviewer_header_SRCS diff --git a/messageviewer/autotests/CMakeLists.txt b/messageviewer/autotes= ts/CMakeLists.txt index a053c9b..385951b 100644 --- a/messageviewer/autotests/CMakeLists.txt +++ b/messageviewer/autotests/CMakeLists.txt @@ -42,6 +42,7 @@ kde4_handle_crypto_rpath_for_executable( unencryptedmessa= getest ) add_messageviewer_unittest( todoedittest.cpp ) add_messageviewer_unittest( eventedittest.cpp ) add_messageviewer_unittest( eventdatetimewidgettest.cpp ) +add_messageviewer_unittest( mailsourceviewtextbrowserwidgettest.cpp ) ########### viewertest_gui ############### = = diff --git a/messageviewer/autotests/mailsourceviewtextbrowserwidgettest.cp= p b/messageviewer/autotests/mailsourceviewtextbrowserwidgettest.cpp new file mode 100644 index 0000000..21b2ca3 --- /dev/null +++ b/messageviewer/autotests/mailsourceviewtextbrowserwidgettest.cpp @@ -0,0 +1,32 @@ +/* + Copyright (c) 2014 Montel Laurent + + 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 "mailsourceviewtextbrowserwidgettest.h" +#include + +MailSourceViewTextBrowserWidgetTest::MailSourceViewTextBrowserWidgetTest(Q= Object *parent) + : QObject(parent) +{ + +} + +MailSourceViewTextBrowserWidgetTest::~MailSourceViewTextBrowserWidgetTest() +{ + +} + +QTEST_MAIN(MailSourceViewTextBrowserWidgetTest) diff --git a/messageviewer/autotests/mailsourceviewtextbrowserwidgettest.h = b/messageviewer/autotests/mailsourceviewtextbrowserwidgettest.h new file mode 100644 index 0000000..99bda24 --- /dev/null +++ b/messageviewer/autotests/mailsourceviewtextbrowserwidgettest.h @@ -0,0 +1,32 @@ +/* + Copyright (c) 2014 Montel Laurent + + 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 MAILSOURCEVIEWTEXTBROWSERWIDGETTEST_H +#define MAILSOURCEVIEWTEXTBROWSERWIDGETTEST_H + +#include + +class MailSourceViewTextBrowserWidgetTest : public QObject +{ + Q_OBJECT +public: + explicit MailSourceViewTextBrowserWidgetTest(QObject *parent =3D 0); + ~MailSourceViewTextBrowserWidgetTest(); +}; + +#endif // MAILSOURCEVIEWTEXTBROWSERWIDGETTEST_H + diff --git a/messageviewer/viewer/viewer_p.cpp b/messageviewer/viewer/viewe= r_p.cpp index 15607db..1f9b566 100644 --- a/messageviewer/viewer/viewer_p.cpp +++ b/messageviewer/viewer/viewer_p.cpp @@ -131,7 +131,7 @@ #include "header/headerstrategy.h" #include "widgets/htmlstatusbar.h" #include "htmlwriter/webkitparthtmlwriter.h" -#include "viewer/mailsourceviewer.h" +#include "widgets/mailsourceviewer.h" #include "viewer/mimetreemodel.h" #include "viewer/nodehelper.h" #include "viewer/objecttreeparser.h" diff --git a/messageviewer/widgets/mailsourceviewer.cpp b/messageviewer/wid= gets/mailsourceviewer.cpp new file mode 100644 index 0000000..ec2eded --- /dev/null +++ b/messageviewer/widgets/mailsourceviewer.cpp @@ -0,0 +1,146 @@ +/* -*- mode: C++; c-file-style: "gnu" -*- + * + * This file is part of KMail, the KDE mail client. + * + * Copyright (c) 2002-2003 Carsten Pfeiffer + * Copyright (c) 2003 Zack Rusin + * + * 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-1= 301 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 "utils/util.h" +#include "findbar/findbarsourceview.h" +#include +#include "pimcommon/widgets/slidecontainer.h" +#include "pimcommon/util/pimutil.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace MessageViewer +{ + +MailSourceViewer::MailSourceViewer(QWidget *parent) + : QDialog(parent) +{ + setAttribute(Qt::WA_DeleteOnClose); + QDialogButtonBox *buttonBox =3D new QDialogButtonBox(QDialogButtonBox:= :Close); + QWidget *mainWidget =3D new QWidget(this); + QVBoxLayout *mainLayout =3D new QVBoxLayout; + setLayout(mainLayout); + mainLayout->addWidget(mainWidget); + connect(buttonBox, &QDialogButtonBox::accepted, this, &MailSourceViewe= r::accept); + connect(buttonBox, &QDialogButtonBox::rejected, this, &MailSourceViewe= r::reject); + + QVBoxLayout *layout =3D new QVBoxLayout(mainWidget); + layout->setMargin(0); + connect(buttonBox->button(QDialogButtonBox::Close), &QPushButton::clic= ked, this, &MailSourceViewer::close); + + mRawBrowser =3D new MailSourceViewTextBrowserWidget(); + +#ifndef NDEBUG + mTabWidget =3D new QTabWidget; + layout->addWidget(mTabWidget); + + mTabWidget->addTab(mRawBrowser, i18nc("Unchanged mail message", "Raw S= ource")); + mTabWidget->setTabToolTip(0, i18n("Raw, unmodified mail as it is store= d on the filesystem or on the server")); + + mHtmlBrowser =3D new MailSourceViewTextBrowserWidget(); + mTabWidget->addTab(mHtmlBrowser, i18nc("Mail message as shown, in HTML= format", "HTML Source")); + mTabWidget->setTabToolTip(1, i18n("HTML code for displaying the messag= e to the user")); + new KPIMTextEdit::HtmlHighlighter(mHtmlBrowser->textBrowser()->documen= t()); + + mTabWidget->setCurrentIndex(0); +#else + layout->addWidget(mRawBrowser); +#endif + + // combining the shortcuts in one qkeysequence() did not work... + QShortcut *shortcut =3D new QShortcut(this); + shortcut->setKey(Qt::Key_Escape); + connect(shortcut, &QShortcut::activated, this, &MailSourceViewer::clos= e); + shortcut =3D new QShortcut(this); + shortcut->setKey(Qt::Key_W + Qt::CTRL); + connect(shortcut, &QShortcut::activated, this, &MailSourceViewer::clos= e); + + 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(HTMLPrettyFormatter::reformat(source)); +#else + Q_UNUSED(source); +#endif +} + +void MailSourceViewer::setFixedFont() +{ + mRawBrowser->setFixedFont(); +#ifndef NDEBUG + mHtmlBrowser->setFixedFont(); +#endif +} + +} diff --git a/messageviewer/widgets/mailsourceviewer.h b/messageviewer/widge= ts/mailsourceviewer.h new file mode 100644 index 0000000..32e618b --- /dev/null +++ b/messageviewer/widgets/mailsourceviewer.h @@ -0,0 +1,68 @@ +/* -*- mode: C++; c-file-style: "gnu" -*- + * + * This file is part of KMail, the KDE mail client. + * + * Copyright (c) 2002-2003 Carsten Pfeiffer + * Copyright (c) 2003 Zack Rusin + * + * 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-1= 301 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 +#include +#include +#include +class QTabWidget; +namespace PimCommon +{ +class SlideContainer; +} +namespace MessageViewer +{ +class FindBarSourceView; +class MailSourceViewTextBrowserWidget; +class MailSourceViewer : public QDialog +{ + Q_OBJECT +public: + explicit MailSourceViewer(QWidget *parent =3D 0); + ~MailSourceViewer(); + + void setRawSource(const QString &source); + void setDisplayedSource(const QString &source); + void setFixedFont(); +private: + MailSourceViewTextBrowserWidget *mRawBrowser; + FindBarSourceView *mFindBar; +#ifndef NDEBUG + QTabWidget *mTabWidget; + MailSourceViewTextBrowserWidget *mHtmlBrowser; +#endif +}; + +} +#endif // MAILSOURCEVIEWER_H diff --git a/messageviewer/viewer/mailsourceviewer.cpp b/messageviewer/widg= ets/mailsourceviewtextbrowserwidget.cpp similarity index 74% rename from messageviewer/viewer/mailsourceviewer.cpp rename to messageviewer/widgets/mailsourceviewtextbrowserwidget.cpp index ed7f02a..71419ad 100644 --- a/messageviewer/viewer/mailsourceviewer.cpp +++ b/messageviewer/widgets/mailsourceviewtextbrowserwidget.cpp @@ -30,7 +30,7 @@ * your version. */ = -#include "mailsourceviewer.h" +#include "mailsourceviewtextbrowserwidget.h" #include "utils/util.h" #include "findbar/findbarsourceview.h" #include @@ -60,9 +60,7 @@ #include #include = -namespace MessageViewer -{ - +using namespace MessageViewer; MailSourceViewTextBrowserWidget::MailSourceViewTextBrowserWidget(QWidget *= parent) : QWidget(parent) { @@ -238,84 +236,3 @@ const QString HTMLPrettyFormatter::reformat(const QStr= ing &src) // Finally reassemble and return :) return tmpSource.join(QLatin1String("\n")); } - -MailSourceViewer::MailSourceViewer(QWidget *parent) - : QDialog(parent) -{ - setAttribute(Qt::WA_DeleteOnClose); - QDialogButtonBox *buttonBox =3D new QDialogButtonBox(QDialogButtonBox:= :Close); - QWidget *mainWidget =3D new QWidget(this); - QVBoxLayout *mainLayout =3D new QVBoxLayout; - setLayout(mainLayout); - mainLayout->addWidget(mainWidget); - connect(buttonBox, &QDialogButtonBox::accepted, this, &MailSourceViewe= r::accept); - connect(buttonBox, &QDialogButtonBox::rejected, this, &MailSourceViewe= r::reject); - - QVBoxLayout *layout =3D new QVBoxLayout(mainWidget); - layout->setMargin(0); - connect(buttonBox->button(QDialogButtonBox::Close), &QPushButton::clic= ked, this, &MailSourceViewer::close); - - mRawBrowser =3D new MailSourceViewTextBrowserWidget(); - -#ifndef NDEBUG - mTabWidget =3D new QTabWidget; - layout->addWidget(mTabWidget); - - mTabWidget->addTab(mRawBrowser, i18nc("Unchanged mail message", "Raw S= ource")); - mTabWidget->setTabToolTip(0, i18n("Raw, unmodified mail as it is store= d on the filesystem or on the server")); - - mHtmlBrowser =3D new MailSourceViewTextBrowserWidget(); - mTabWidget->addTab(mHtmlBrowser, i18nc("Mail message as shown, in HTML= format", "HTML Source")); - mTabWidget->setTabToolTip(1, i18n("HTML code for displaying the messag= e to the user")); - new KPIMTextEdit::HtmlHighlighter(mHtmlBrowser->textBrowser()->documen= t()); - - mTabWidget->setCurrentIndex(0); -#else - layout->addWidget(mRawBrowser); -#endif - - // combining the shortcuts in one qkeysequence() did not work... - QShortcut *shortcut =3D new QShortcut(this); - shortcut->setKey(Qt::Key_Escape); - connect(shortcut, &QShortcut::activated, this, &MailSourceViewer::clos= e); - shortcut =3D new QShortcut(this); - shortcut->setKey(Qt::Key_W + Qt::CTRL); - connect(shortcut, &QShortcut::activated, this, &MailSourceViewer::clos= e); - - 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(HTMLPrettyFormatter::reformat(source)); -#else - Q_UNUSED(source); -#endif -} - -void MailSourceViewer::setFixedFont() -{ - mRawBrowser->setFixedFont(); -#ifndef NDEBUG - mHtmlBrowser->setFixedFont(); -#endif -} - -} diff --git a/messageviewer/viewer/mailsourceviewer.h b/messageviewer/widget= s/mailsourceviewtextbrowserwidget.h similarity index 88% rename from messageviewer/viewer/mailsourceviewer.h rename to messageviewer/widgets/mailsourceviewtextbrowserwidget.h index c62f9ee..9349131 100644 --- a/messageviewer/viewer/mailsourceviewer.h +++ b/messageviewer/widgets/mailsourceviewtextbrowserwidget.h @@ -29,16 +29,14 @@ * you do not wish to do so, delete this exception statement from * your version. */ -#ifndef MAILSOURCEVIEWER_H -#define MAILSOURCEVIEWER_H +#ifndef MAILSOURCEVIEWTEXTBROWSERWIDGET_H +#define MAILSOURCEVIEWTEXTBROWSERWIDGET_H = #include #include #include #include -class QTabWidget; = -class KTabWidget; namespace PimCommon { class SlideContainer; @@ -123,25 +121,6 @@ const QRegExp htmlTagRegExp(QLatin1String("<" = const QString reformat(const QString &src); } - -class MailSourceViewer : public QDialog -{ - Q_OBJECT -public: - explicit MailSourceViewer(QWidget *parent =3D 0); - ~MailSourceViewer(); - - void setRawSource(const QString &source); - void setDisplayedSource(const QString &source); - void setFixedFont(); -private: - MailSourceViewTextBrowserWidget *mRawBrowser; - FindBarSourceView *mFindBar; -#ifndef NDEBUG - QTabWidget *mTabWidget; - MailSourceViewTextBrowserWidget *mHtmlBrowser; -#endif -}; - } -#endif // MAILSOURCEVIEWER_H +#endif // MAILSOURCEVIEWTEXTBROWSERWIDGET_H +