File indexing completed on 2024-04-28 05:47:43
0001 /* 0002 SPDX-FileCopyrightText: 2008 Harald Hvaal <haraldhv (at@at) stud.ntnu.no> 0003 SPDX-FileCopyrightText: 2016 Vladyslav Batyrenko <mvlabat@gmail.com> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #ifndef ARCHIVEVIEW_H 0009 #define ARCHIVEVIEW_H 0010 0011 #include <QStyledItemDelegate> 0012 #include <QTreeView> 0013 0014 class QLineEdit; 0015 0016 class ArchiveView : public QTreeView 0017 { 0018 Q_OBJECT 0019 0020 public: 0021 explicit ArchiveView(QWidget *parent = nullptr); 0022 void dragEnterEvent(class QDragEnterEvent *event) override; 0023 void dropEvent(class QDropEvent *event) override; 0024 void dragMoveEvent(class QDragMoveEvent *event) override; 0025 void startDrag(Qt::DropActions supportedActions) override; 0026 0027 /** 0028 * Expand the first level in the view if there is only one root folder. 0029 * Typical use case: an archive with source code. 0030 */ 0031 void expandIfSingleFolder(); 0032 0033 /** 0034 * Set whether the view should accept drop events. 0035 */ 0036 void setDropsEnabled(bool enabled); 0037 0038 public Q_SLOTS: 0039 void renameSelectedEntry(); 0040 0041 protected: 0042 bool eventFilter(QObject *object, QEvent *event) override; 0043 void mouseReleaseEvent(QMouseEvent *event) override; 0044 void keyPressEvent(QKeyEvent *event) override; 0045 0046 Q_SIGNALS: 0047 void entryChanged(const QString &name); 0048 0049 private: 0050 void openEntryEditor(const QModelIndex &index); 0051 void closeEntryEditor(); 0052 QModelIndex m_editorIndex; 0053 QLineEdit *m_entryEditor = nullptr; 0054 }; 0055 0056 class NoHighlightSelectionDelegate : public QStyledItemDelegate 0057 { 0058 Q_OBJECT 0059 0060 public: 0061 explicit NoHighlightSelectionDelegate(QObject *parent) 0062 : QStyledItemDelegate(parent) 0063 { 0064 } 0065 void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; 0066 }; 0067 0068 #endif /* ARCHIVEVIEW_H */