File indexing completed on 2024-11-24 04:53:02

0001 /* Copyright (C) 2006 - 2015 Jan Kundrát <jkt@kde.org>
0002    Copyright (C) 2013 - 2015 Pali Rohár <pali.rohar@gmail.com>
0003 
0004    This file is part of the Trojita Qt IMAP e-mail client,
0005    http://trojita.flaska.net/
0006 
0007    This program is free software; you can redistribute it and/or
0008    modify it under the terms of the GNU General Public License as
0009    published by the Free Software Foundation; either version 2 of
0010    the License or (at your option) version 3 or any later version
0011    accepted by the membership of KDE e.V. (or its successor approved
0012    by the membership of KDE e.V.), which shall act as a proxy
0013    defined in Section 14 of version 3 of the license.
0014 
0015    This program is distributed in the hope that it will be useful,
0016    but WITHOUT ANY WARRANTY; without even the implied warranty of
0017    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0018    GNU General Public License for more details.
0019 
0020    You should have received a copy of the GNU General Public License
0021    along with this program.  If not, see <http://www.gnu.org/licenses/>.
0022 */
0023 #ifndef GUI_ONEENVELOPEADDRESS_H
0024 #define GUI_ONEENVELOPEADDRESS_H
0025 
0026 #include <QModelIndex>
0027 #include <QLabel>
0028 #include "Imap/Parser/MailAddress.h"
0029 
0030 namespace Plugins {
0031 class PluginManager;
0032 }
0033 
0034 namespace Gui {
0035 
0036 class MessageView;
0037 
0038 /** @short Widget displaying the message envelope */
0039 class OneEnvelopeAddress : public QLabel
0040 {
0041     Q_OBJECT
0042 public:
0043     /** @short Is this the last item in a list? */
0044     enum class Position {
0045         Middle, /**< We are not the last item in a row */
0046         Last, /**< This is the last item */
0047     };
0048 
0049     OneEnvelopeAddress(QWidget *parent, const Imap::Message::MailAddress &address, MessageView *messageView, const Position lastOneInRow);
0050 
0051     void contextMenuEvent(QContextMenuEvent *e) override;
0052 
0053 private slots:
0054     void onLinkHovered(const QString &target);
0055     void finishOnLinkHovered(const QStringList &matchingDisplayNames);
0056     void processAddress();
0057     void finishProcessAddress(const QStringList &matchingDisplayNames);
0058 
0059 private:
0060     QString contactKnownUrl, contactUnknownUrl;
0061     Imap::Message::MailAddress m_address;
0062     Position m_lastOneInRow;
0063     Plugins::PluginManager *m_pluginManager;
0064     QString m_link;
0065 
0066     OneEnvelopeAddress(const OneEnvelopeAddress &); // don't implement
0067     OneEnvelopeAddress &operator=(const OneEnvelopeAddress &); // don't implement
0068 };
0069 
0070 }
0071 
0072 #endif