File indexing completed on 2024-04-14 05:43:25

0001 /*
0002     SPDX-FileCopyrightText: 2002 Jean-Baptiste Mardelle <bj@altern.org>
0003     SPDX-FileCopyrightText: 2009-2022 Rolf Eike Beer <kde@opensource.sf-tec.de>
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef KGPGTEXTEDIT_H
0008 #define KGPGTEXTEDIT_H
0009 
0010 #include <QString>
0011 
0012 #include <KTextEdit>
0013 #include <QUrl>
0014 
0015 class QDragEnterEvent;
0016 class QDropEvent;
0017 
0018 class KGpgItemModel;
0019 class KeysManager;
0020 
0021 class KgpgTextEdit : public KTextEdit
0022 {
0023     Q_OBJECT
0024 
0025 public:
0026     explicit KgpgTextEdit(QWidget *parent, KGpgItemModel *model, KeysManager *manager);
0027     ~KgpgTextEdit() override = default;
0028 
0029     void signVerifyText(const QString &message);
0030     void openDroppedFile(const QUrl &url, const bool probe);
0031 
0032 Q_SIGNALS:
0033     void newText();
0034     void resetEncoding(bool);
0035     void verifyFinished();
0036 
0037 public Q_SLOTS:
0038     void slotDroppedFile(const QUrl &url);
0039     void slotEncode();
0040     void slotDecode();
0041     void slotSign(const QString &message);
0042     void slotVerify(const QString &message);
0043     void slotSignVerify();
0044     void slotHighlightText(const QString &, const int matchingindex, const int matchedlength);
0045     void slotVerifyDone(int result);
0046 
0047 protected:
0048     void dragEnterEvent(QDragEnterEvent *e) override;
0049     void dropEvent(QDropEvent *e) override;
0050 
0051 private:
0052     void verifyKeyNeeded(const QString &id);
0053 
0054 private Q_SLOTS:
0055     void slotEncodeUpdate(int result);
0056     void slotSignUpdate(int result);
0057 
0058     void slotDecryptDone(int result);
0059 
0060 private:
0061     QString m_tempfile;
0062 
0063     int m_posstart;
0064     int m_posend;
0065 
0066     KGpgItemModel *m_model;
0067     KeysManager *m_keysmanager;
0068 };
0069 
0070 #endif // KGPGVIEW_H