[kde-doc-english] [trojita] src/Gui: GUI: render pretty message headers for the attached messages

Jan Kundrát jkt at flaska.net
Fri May 3 14:08:13 UTC 2013


Git commit 59fd7e712726a540ebd1934359caf6533ec2fd45 by Jan Kundrát.
Committed on 03/05/2013 at 15:59.
Pushed by jkt into branch 'master'.

GUI: render pretty message headers for the attached messages

M  +0    -2    src/Gui/Gui.pro
M  +4    -5    src/Gui/PartWidget.cpp
D  +0    -86   src/Gui/Rfc822HeaderView.cpp
D  +0    -50   src/Gui/Rfc822HeaderView.h

http://commits.kde.org/trojita/59fd7e712726a540ebd1934359caf6533ec2fd45

diff --git a/src/Gui/Gui.pro b/src/Gui/Gui.pro
index 2cb70b9..34468f0 100644
--- a/src/Gui/Gui.pro
+++ b/src/Gui/Gui.pro
@@ -25,7 +25,6 @@ SOURCES += \
     PartWidgetFactory.cpp \
     PartWidget.cpp \
     SimplePartWidget.cpp \
-    Rfc822HeaderView.cpp \
     AttachmentView.cpp \
     LoadablePartWidget.cpp \
     Window.cpp \
@@ -67,7 +66,6 @@ HEADERS += \
     AbstractPartWidget.h \
     EmbeddedWebView.h \
     Window.h \
-    Rfc822HeaderView.h \
     LoadablePartWidget.h \
     PartWidget.h \
     SettingsDialog.h \
diff --git a/src/Gui/PartWidget.cpp b/src/Gui/PartWidget.cpp
index 487d9fa..f1d88ed 100644
--- a/src/Gui/PartWidget.cpp
+++ b/src/Gui/PartWidget.cpp
@@ -26,8 +26,8 @@
 #include <QVBoxLayout>
 #include <QTabBar>
 
+#include "EnvelopeView.h"
 #include "PartWidgetFactory.h"
-#include "Rfc822HeaderView.h"
 #include "Imap/Model/ItemRoles.h"
 #include "Imap/Model/MailboxTree.h"
 
@@ -174,10 +174,9 @@ Message822Widget::Message822Widget(QWidget *parent,
     setFlat(true);
     QVBoxLayout *layout = new QVBoxLayout(this);
     layout->setSpacing(0);
-    QModelIndex headerIndex = partIndex.child(0, Imap::Mailbox::TreeItem::OFFSET_HEADER);
-    Q_ASSERT(headerIndex.isValid());
-    QLabel *header = new Rfc822HeaderView(0, headerIndex);
-    layout->addWidget(header);
+    EnvelopeView *envelope = new EnvelopeView(0);
+    envelope->setMessage(partIndex);
+    layout->addWidget(envelope);
     for (int i = 0; i < partIndex.model()->rowCount(partIndex); ++i) {
         using namespace Imap::Mailbox;
         QModelIndex anotherPart = partIndex.child(i, 0);
diff --git a/src/Gui/Rfc822HeaderView.cpp b/src/Gui/Rfc822HeaderView.cpp
deleted file mode 100644
index 6362eaa..0000000
--- a/src/Gui/Rfc822HeaderView.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-/* Copyright (C) 2006 - 2013 Jan Kundrát <jkt at flaska.net>
-
-   This file is part of the Trojita Qt IMAP e-mail client,
-   http://trojita.flaska.net/
-
-   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/>.
-*/
-#include "Rfc822HeaderView.h"
-
-#include <QModelIndex>
-
-#include "Imap/Model/ItemRoles.h"
-#include "Imap/Model/MailboxTree.h"
-#include "Imap/Model/Model.h"
-
-namespace Gui
-{
-
-Rfc822HeaderView::Rfc822HeaderView(QWidget *parent, QModelIndex index_):
-    QLabel(parent)
-{
-    Q_ASSERT(index_.isValid());
-
-    // We have to obtain the underlying index
-    const Imap::Mailbox::Model *constModel;
-    Imap::Mailbox::TreeItemPart *part = dynamic_cast<Imap::Mailbox::TreeItemPart *>(Imap::Mailbox::Model::realTreeItem(index_, &constModel, &index_));
-    Q_ASSERT(part);
-    index = index_;
-
-    Imap::Mailbox::Model *model = const_cast<Imap::Mailbox::Model *>(constModel); // the const_cast is required because QModelIndex::model() returns const
-    part->fetch(model);
-    if (part->fetched()) {
-        setCorrectText();
-    } else if (part->isUnavailable(model)) {
-        setText(tr("Offline"));
-    } else {
-        setText(tr("Loading..."));
-        connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(handleDataChanged(QModelIndex,QModelIndex)));
-    }
-    setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse);
-}
-
-void Rfc822HeaderView::handleDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
-{
-    if (!topLeft.isValid()) {
-        // For example when reloading a top-level mailbox -> do nothing...
-        return;
-    }
-    if (!index.isValid()) {
-        // Our message is gone, so there's no point in checking further
-        disconnect(sender(), SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(handleDataChanged(QModelIndex,QModelIndex)));
-        if (text() == tr("Loading...") || text() == tr("Offline")) {
-            setCorrectText();
-        }
-        return;
-    }
-
-    Q_UNUSED(bottomRight);
-    // FIXME: verify that th dataChanged() is emitted separately for each message
-    Q_ASSERT(topLeft.model() == index.model());
-    if (topLeft == index)
-        setCorrectText();
-}
-
-void Rfc822HeaderView::setCorrectText()
-{
-    setText(index.isValid() ? index.data(Imap::Mailbox::RolePartData).toString() : tr("<i>Message deleted</i>"));
-}
-
-}
-
-
diff --git a/src/Gui/Rfc822HeaderView.h b/src/Gui/Rfc822HeaderView.h
deleted file mode 100644
index 74c8896..0000000
--- a/src/Gui/Rfc822HeaderView.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/* Copyright (C) 2006 - 2013 Jan Kundrát <jkt at flaska.net>
-
-   This file is part of the Trojita Qt IMAP e-mail client,
-   http://trojita.flaska.net/
-
-   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 GUI_RFC822HEADERVIEW_H
-#define GUI_RFC822HEADERVIEW_H
-
-#include <QLabel>
-#include <QPersistentModelIndex>
-
-class QModelIndex;
-
-namespace Gui
-{
-
-class Rfc822HeaderView : public QLabel
-{
-    Q_OBJECT
-public:
-    Rfc822HeaderView(QWidget *parent, QModelIndex index);
-private slots:
-    void handleDataChanged(const QModelIndex &, const QModelIndex &);
-    void setCorrectText();
-private:
-    QPersistentModelIndex index;
-
-    Rfc822HeaderView(const Rfc822HeaderView &); // don't implement
-    Rfc822HeaderView &operator=(const Rfc822HeaderView &); // don't implement
-};
-
-}
-
-#endif // GUI_RFC822HEADERVIEW_H


More information about the kde-doc-english mailing list