File indexing completed on 2024-04-21 08:51:46

0001 /*
0002     This is the shares view of Smb4K.
0003 
0004     SPDX-FileCopyrightText: 2006-2022 Alexander Reinholdt <alexander.reinholdt@kdemail.net>
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #ifndef SMB4KSHARESVIEW_H
0009 #define SMB4KSHARESVIEW_H
0010 
0011 // Qt includes
0012 #include <QListWidget>
0013 #include <QMimeData>
0014 #include <QTimer>
0015 
0016 // forward declarations
0017 class Smb4KSharesViewItem;
0018 class Smb4KToolTip;
0019 
0020 /**
0021  * This widget class provides the shares view of Smb4K.
0022  *
0023  * @author Alexander Reinholdt <alexander.reinholdt@kdemail.net>
0024  */
0025 
0026 class Smb4KSharesView : public QListWidget
0027 {
0028     Q_OBJECT
0029 
0030 public:
0031     /**
0032      * The constructor.
0033      *
0034      * @param parent        The parent widget
0035      */
0036     explicit Smb4KSharesView(QWidget *parent = nullptr);
0037 
0038     /**
0039      * The destructor.
0040      */
0041     ~Smb4KSharesView();
0042 
0043     /**
0044      * Set the view mode.
0045      *
0046      * @param mode          The view mode
0047      * @param iconSize      The size of the icons
0048      */
0049     void setViewMode(ViewMode mode, int iconSize);
0050 
0051     /**
0052      * The tooltip
0053      */
0054     Smb4KToolTip *toolTip();
0055 
0056 Q_SIGNALS:
0057     /**
0058      * This signal is emitted when something has been dropped onto
0059      * @p item and the drop event was accepted.
0060      *
0061      * @param item          The item on which something has been dropped.
0062      *
0063      * @param e             The drop event.
0064      */
0065     void acceptedDropEvent(Smb4KSharesViewItem *item, QDropEvent *e);
0066 
0067 protected:
0068     /**
0069      * Reimplemented from QListWidget.
0070      */
0071     bool event(QEvent *e) override;
0072 
0073     /**
0074      * Reimplemented from QAbstractItemView. This function handles
0075      * mouse press events.
0076      *
0077      * @param e             The mouse event object
0078      */
0079     void mousePressEvent(QMouseEvent *e) override;
0080 
0081     /**
0082      * Reimplemented from QAbstractItemView. This function handles
0083      * mouse move events.
0084      *
0085      * @param e             The mouse event object
0086      */
0087     void mouseMoveEvent(QMouseEvent *e) override;
0088 
0089     /**
0090      * Reimplemented to allow dragging and dropping.
0091      *
0092      * @param e             The drag event
0093      */
0094     virtual void dragEnterEvent(QDragEnterEvent *e) override;
0095 
0096     /**
0097      * Reimplemented to allow dragging and dropping.
0098      *
0099      * @param e             The drag move event
0100      */
0101     void dragMoveEvent(QDragMoveEvent *e) override;
0102 
0103     /**
0104      * Reimplemented to allow dragging and dropping.
0105      *
0106      * @param e             The drop event
0107      */
0108     void dropEvent(QDropEvent *e) override;
0109 
0110     /**
0111      * Reimplemented to allow only the copy drop action.
0112      */
0113     Qt::DropActions supportedDropActions() const override;
0114 
0115 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
0116     /**
0117      * Reimplemented to allow dragging.
0118      */
0119     QMimeData *mimeData(const QList<QListWidgetItem *> &list) const override;
0120 #else
0121     /**
0122      * Reimplemented to allow dragging.
0123      */
0124     QMimeData *mimeData(const QList<QListWidgetItem *> list) const override;
0125 #endif
0126 
0127     /**
0128      * Reimplemented to allow dragging.
0129      */
0130     void startDrag(Qt::DropActions supported) override;
0131 
0132 private:
0133     /**
0134      * The tool top widget
0135      */
0136     Smb4KToolTip *m_toolTip;
0137 };
0138 
0139 #endif