File indexing completed on 2024-04-21 05:01:46

0001 /*
0002     smb4knetworkbrowser  -  The network browser widget of Smb4K.
0003 
0004     SPDX-FileCopyrightText: 2007-2023 Alexander Reinholdt <alexander.reinholdt@kdemail.net>
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #ifndef SMB4KNETWORKBROWSER_H
0009 #define SMB4KNETWORKBROWSER_H
0010 
0011 // Qt includes
0012 #include <QTreeWidget>
0013 
0014 // forward declarations
0015 class Smb4KNetworkBrowserItem;
0016 class Smb4KToolTip;
0017 
0018 /**
0019  * This is the network neighborhood browser widget.
0020  *
0021  * @author Alexander Reinholdt <alexander.reinholdt@kdemail.net>
0022  */
0023 
0024 class Smb4KNetworkBrowser : public QTreeWidget
0025 {
0026     Q_OBJECT
0027 
0028 public:
0029     /**
0030      * The constructor
0031      *
0032      * @param parent        The parent widget
0033      */
0034     explicit Smb4KNetworkBrowser(QWidget *parent = nullptr);
0035 
0036     /**
0037      * The destructor
0038      */
0039     ~Smb4KNetworkBrowser();
0040 
0041     /**
0042      * Enumeration for the columns in the list view.
0043      */
0044     enum Columns { Network = 0, Type = 1, IP = 2, Comment = 3 };
0045 
0046     /**
0047      * The tooltip
0048      */
0049     Smb4KToolTip *toolTip();
0050 
0051 protected:
0052     /**
0053      * Reimplemented from QWidget.
0054      */
0055     bool event(QEvent *e) override;
0056 
0057     /**
0058      * Reimplemented from QAbstractItemView. This function handles
0059      * mouse press events.
0060      *
0061      * @param e             The mouse event object
0062      */
0063     void mousePressEvent(QMouseEvent *e) override;
0064 
0065     /**
0066      * Reimplemented from QAbstractItemView. This function handles
0067      * mouse move events.
0068      *
0069      * @param e             The mouse event object
0070      */
0071     void mouseMoveEvent(QMouseEvent *e) override;
0072 
0073 protected Q_SLOTS:
0074     /**
0075      * This slot is called when the user activated an item. It is used
0076      * to open the item if it is expandable.
0077      * @param item          The item that has been activated.
0078      * @param column        The column where the item was activated.
0079      */
0080     void slotItemActivated(QTreeWidgetItem *item, int column);
0081 
0082     /**
0083      * Take care that only shares are selected when the user marks multiple
0084      * shares.
0085      */
0086     void slotItemSelectionChanged();
0087 
0088 private:
0089     Smb4KToolTip *m_toolTip;
0090 };
0091 
0092 #endif