File indexing completed on 2024-10-27 04:50:58
0001 /* 0002 * This file is part of KMail. 0003 * SPDX-FileCopyrightText: 2012-2024 Laurent Montel <montel@kde.org> 0004 * SPDX-FileCopyrightText: 2009 Constantin Berzan <exit3219@gmail.com> 0005 * 0006 * Parts based on KMail code by: 0007 * SPDX-FileCopyrightText: 2003 Ingo Kloecker <kloecker@kde.org> 0008 * SPDX-FileCopyrightText: 2007 Thomas McGuire <Thomas.McGuire@gmx.net> 0009 * 0010 * SPDX-License-Identifier: GPL-2.0-or-later 0011 */ 0012 0013 #pragma once 0014 0015 #include <KConfigGroup> 0016 #include <QTreeView> 0017 0018 class QContextMenuEvent; 0019 class QToolButton; 0020 class QLabel; 0021 namespace MessageComposer 0022 { 0023 class AttachmentModel; 0024 } 0025 0026 namespace KMail 0027 { 0028 class AttachmentView : public QTreeView 0029 { 0030 Q_OBJECT 0031 0032 public: 0033 /// can't change model afterwards. 0034 explicit AttachmentView(MessageComposer::AttachmentModel *model, QWidget *parent = nullptr); 0035 ~AttachmentView() override; 0036 0037 QWidget *widget() const; 0038 void hideIfEmpty(); 0039 0040 protected: 0041 /** reimpl to avoid default drag cursor */ 0042 void startDrag(Qt::DropActions supportedActions) override; 0043 void contextMenuEvent(QContextMenuEvent *event) override; 0044 void keyPressEvent(QKeyEvent *event) override; 0045 /** reimpl to avoid drags from ourselves */ 0046 void dragEnterEvent(QDragEnterEvent *event) override; 0047 0048 private: 0049 void slotShowHideAttchementList(bool); 0050 void saveHeaderState(); 0051 void restoreHeaderState(); 0052 /// model sets these 0053 void setEncryptEnabled(bool enabled); 0054 void setSignEnabled(bool enabled); 0055 void selectNewAttachment(); 0056 0057 void updateAttachmentLabel(); 0058 0059 Q_SIGNALS: 0060 void contextMenuRequested(); 0061 void modified(bool); 0062 0063 private: 0064 MessageComposer::AttachmentModel *const mModel; 0065 QToolButton *const mToolButton; 0066 QLabel *const mInfoAttachment; 0067 QWidget *const mWidget; 0068 KConfigGroup grp; 0069 }; 0070 } // namespace KMail