[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdepim] messageviewer: Split in own file.
From:       Montel Laurent <montel () kde ! org>
Date:       2014-10-31 22:09:19
Message-ID: E1XkKNj-000390-C0 () scm ! kde ! org
[Download RAW message or body]

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 \
[from: messageviewer/viewer/mailsourceviewer.cpp - 074% similarity] R  +4    -25   \
messageviewer/widgets/mailsourceviewtextbrowserwidget.h [from: \
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/autotests/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( unencryptedmessagetest )
 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.cpp \
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 <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 "mailsourceviewtextbrowserwidgettest.h"
+#include <qtest.h>
+
+MailSourceViewTextBrowserWidgetTest::MailSourceViewTextBrowserWidgetTest(QObject \
*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 <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 MAILSOURCEVIEWTEXTBROWSERWIDGETTEST_H
+#define MAILSOURCEVIEWTEXTBROWSERWIDGETTEST_H
+
+#include <QObject>
+
+class MailSourceViewTextBrowserWidgetTest : public QObject
+{
+    Q_OBJECT
+public:
+    explicit MailSourceViewTextBrowserWidgetTest(QObject *parent = 0);
+    ~MailSourceViewTextBrowserWidgetTest();
+};
+
+#endif // MAILSOURCEVIEWTEXTBROWSERWIDGETTEST_H
+
diff --git a/messageviewer/viewer/viewer_p.cpp b/messageviewer/viewer/viewer_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/widgets/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 <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 "utils/util.h"
+#include "findbar/findbarsourceview.h"
+#include <kpimtextedit/htmlhighlighter.h>
+#include "pimcommon/widgets/slidecontainer.h"
+#include "pimcommon/util/pimutil.h"
+#include <kiconloader.h>
+#include <KLocalizedString>
+#include <KStandardAction>
+#include <kwindowsystem.h>
+#include <QTabWidget>
+#include <KMessageBox>
+#include <QAction>
+#include <QIcon>
+#include <KIconTheme>
+#include <KLocalizedString>
+
+#include <QtCore/QRegExp>
+#include <QApplication>
+#include <QIcon>
+#include <QShortcut>
+#include <QVBoxLayout>
+#include <QContextMenuEvent>
+#include <QDebug>
+#include <QMenu>
+#include <QFontDatabase>
+#include <KConfigGroup>
+#include <QDialogButtonBox>
+#include <QPushButton>
+
+namespace MessageViewer
+{
+
+MailSourceViewer::MailSourceViewer(QWidget *parent)
+    : QDialog(parent)
+{
+    setAttribute(Qt::WA_DeleteOnClose);
+    QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close);
+    QWidget *mainWidget = new QWidget(this);
+    QVBoxLayout *mainLayout = new QVBoxLayout;
+    setLayout(mainLayout);
+    mainLayout->addWidget(mainWidget);
+    connect(buttonBox, &QDialogButtonBox::accepted, this, \
&MailSourceViewer::accept); +    connect(buttonBox, &QDialogButtonBox::rejected, \
this, &MailSourceViewer::reject); +
+    QVBoxLayout *layout = new QVBoxLayout(mainWidget);
+    layout->setMargin(0);
+    connect(buttonBox->button(QDialogButtonBox::Close), &QPushButton::clicked, this, \
&MailSourceViewer::close); +
+    mRawBrowser = new MailSourceViewTextBrowserWidget();
+
+#ifndef NDEBUG
+    mTabWidget = new QTabWidget;
+    layout->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();
+    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
+    layout->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(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/widgets/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 <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 <QSyntaxHighlighter>
+#include <QPlainTextEdit>
+#include <QDialog>
+#include <KConfigGroup>
+class QTabWidget;
+namespace PimCommon
+{
+class SlideContainer;
+}
+namespace MessageViewer
+{
+class FindBarSourceView;
+class MailSourceViewTextBrowserWidget;
+class MailSourceViewer : public QDialog
+{
+    Q_OBJECT
+public:
+    explicit MailSourceViewer(QWidget *parent = 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/widgets/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 <kpimtextedit/htmlhighlighter.h>
@@ -60,9 +60,7 @@
 #include <QDialogButtonBox>
 #include <QPushButton>
 
-namespace MessageViewer
-{
-
+using namespace MessageViewer;
 MailSourceViewTextBrowserWidget::MailSourceViewTextBrowserWidget(QWidget *parent)
     : QWidget(parent)
 {
@@ -238,84 +236,3 @@ const QString HTMLPrettyFormatter::reformat(const QString &src)
     // Finally reassemble and return :)
     return tmpSource.join(QLatin1String("\n"));
 }
-
-MailSourceViewer::MailSourceViewer(QWidget *parent)
-    : QDialog(parent)
-{
-    setAttribute(Qt::WA_DeleteOnClose);
-    QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close);
-    QWidget *mainWidget = new QWidget(this);
-    QVBoxLayout *mainLayout = new QVBoxLayout;
-    setLayout(mainLayout);
-    mainLayout->addWidget(mainWidget);
-    connect(buttonBox, &QDialogButtonBox::accepted, this, \
                &MailSourceViewer::accept);
-    connect(buttonBox, &QDialogButtonBox::rejected, this, \
                &MailSourceViewer::reject);
-
-    QVBoxLayout *layout = new QVBoxLayout(mainWidget);
-    layout->setMargin(0);
-    connect(buttonBox->button(QDialogButtonBox::Close), &QPushButton::clicked, this, \
                &MailSourceViewer::close);
-
-    mRawBrowser = new MailSourceViewTextBrowserWidget();
-
-#ifndef NDEBUG
-    mTabWidget = new QTabWidget;
-    layout->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();
-    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
-    layout->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(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/widgets/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 <QSyntaxHighlighter>
 #include <QPlainTextEdit>
 #include <QDialog>
 #include <KConfigGroup>
-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 = 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
+


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic