File indexing completed on 2024-10-13 04:31:35

0001 /*
0002     The network neighborhood browser dock widget
0003 
0004     SPDX-FileCopyrightText: 2018-2023 Alexander Reinholdt <alexander.reinholdt@kdemail.net>
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #ifndef SMB4KNETWORKBROWSERDOCKWIDGET_H
0009 #define SMB4KNETWORKBROWSERDOCKWIDGET_H
0010 
0011 // application specific includes
0012 #include "core/smb4kglobal.h"
0013 
0014 // Qt includes
0015 #include <QDockWidget>
0016 #include <QPointer>
0017 #include <QTreeWidgetItem>
0018 
0019 // KDE includes
0020 #include <KActionCollection>
0021 #include <KActionMenu>
0022 
0023 using namespace Smb4KGlobal;
0024 
0025 // Forward declarations
0026 class Smb4KNetworkBrowser;
0027 class Smb4KNetworkSearchToolBar;
0028 class Smb4KPasswordDialog;
0029 
0030 class Smb4KNetworkBrowserDockWidget : public QDockWidget
0031 {
0032     Q_OBJECT
0033 
0034 public:
0035     /**
0036      * Constructor
0037      */
0038     Smb4KNetworkBrowserDockWidget(const QString &title, QWidget *parent = nullptr);
0039 
0040     /**
0041      * Destructor
0042      */
0043     ~Smb4KNetworkBrowserDockWidget();
0044 
0045     /**
0046      * Load settings
0047      */
0048     void loadSettings();
0049 
0050     /**
0051      * Save settings
0052      */
0053     void saveSettings();
0054 
0055     /**
0056      * Returns the action collection of this dock widget
0057      * @returns the action collection
0058      */
0059     KActionCollection *actionCollection();
0060 
0061 protected Q_SLOTS:
0062     /**
0063      * This slot is called if the user requests the context menu. It shows
0064      * the menu with the actions defined for the widget.
0065      * @param pos                 The position where user clicked.
0066      */
0067     void slotContextMenuRequested(const QPoint &pos);
0068 
0069     /**
0070      * This slot is invoked when the user activated an item in the network
0071      * neighborhood browser.
0072      * @param item                The item that was executed.
0073      * @param column              The column where the item was executed.
0074      */
0075     void slotItemActivated(QTreeWidgetItem *item, int column);
0076 
0077     /**
0078      * Is called when the selection changed. This slot takes care of the
0079      * actions being enabled or disabled accordingly. All widget specific
0080      * stuff has to be done in the browser widget itself.
0081      * @param item                The selection list view item.
0082      */
0083     void slotItemSelectionChanged();
0084 
0085     /**
0086      * This slot is connected to the Smb4KClient::aboutToStart() signal.
0087      *
0088      * @param item                The Smb4KBasicNetworkItem object
0089      * @param process             The process
0090      */
0091     void slotClientAboutToStart(const NetworkItemPtr &item, int process);
0092 
0093     /**
0094      * This slot is connected to the Smb4KClient::finished() signal.
0095      *
0096      * @param item                The Smb4KBasicNetworkItem object
0097      * @param process             The process
0098      */
0099     void slotClientFinished(const NetworkItemPtr &item, int process);
0100 
0101     /**
0102      * This slot is called when workgroups/domains were discovered
0103      */
0104     void slotWorkgroups();
0105 
0106     /**
0107      * This slot is called when the list of servers of workgroup/domain
0108      * @p workgroup was discovered.
0109      * @param workgroup           The workgroup/domain that was queried
0110      */
0111     void slotWorkgroupMembers(const WorkgroupPtr &workgroup);
0112 
0113     /**
0114      * This slot is called when the list of shared resources of host @p host was
0115      * queried.
0116      * @param host                The host that was queried
0117      */
0118     void slotShares(const HostPtr &host);
0119 
0120     /**
0121      * Rescan the network or abort a network scan.
0122      * @param checked             Is TRUE if the action is checked (not used here).
0123      */
0124     void slotRescanAbortActionTriggered(bool checked);
0125 
0126     /**
0127      * Bookmark a remote share. This slot is connected to the 'Add Bookmark'
0128      * action.
0129      * @param checked             Is TRUE if the action is checked (not used here).
0130      */
0131     void slotAddBookmark(bool checked);
0132 
0133     /**
0134      * Manually mount a share. This slot is connected to the 'Mount Manually'
0135      * action and opens a mount dialog.
0136      * @param checked             Is TRUE if the action is checked (not used here).
0137      */
0138     void slotMountManually(bool checked);
0139 
0140     /**
0141      * Provide authentication for the current network object. This slot is
0142      * connected to the 'Authentication' action.
0143      *
0144      * @param checked             Is TRUE if the action is checked (not used here).
0145      */
0146     void slotAuthentication(bool checked);
0147 
0148     /**
0149      * Provide custom options for a server or share. This slot is connected
0150      * to the 'Add Custom Settings' action.
0151      *
0152      * @param checked             Is TRUE if the action is checked (not used here).
0153      */
0154     void slotAddCustomSettings(bool checked);
0155 
0156     /**
0157      * Preview a share. This slot is connected to the 'Preview' action.
0158      * @param checked             Is TRUE if the action is checked (not used here).
0159      */
0160     void slotPreview(bool checked);
0161 
0162     /**
0163      * Print a document on a remote printer. This slot is connected to the
0164      * 'Print File' action.
0165      * @param checked             Is TRUE if the action is checked (not used here).
0166      */
0167     void slotPrint(bool checked);
0168 
0169     /**
0170      * Mount or unmount a share. This slot is connected to the 'Mount'/'Unmount' dual action.
0171      * @param checked             Is TRUE if the action is checked (not used here).
0172      */
0173     void slotMountActionTriggered(bool checked);
0174 
0175     /**
0176      * Change the state of the 'Mount'/'Unmount' dual action.
0177      * @param active              TRUE if the action is in the active state.
0178      */
0179     void slotMountActionChanged(bool active);
0180 
0181     /**
0182      * This slot is called whenever a share has been mounted. It marks the
0183      * respective share in the tree widget as mounted.
0184      * @param share               The Smb4KShare object
0185      */
0186     void slotShareMounted(const SharePtr &share);
0187 
0188     /**
0189      * This slot is called whenever a share has been unmounted. It marks the
0190      * respective share in the tree widget as not mounted.
0191      * @param share               The Smb4KShare object
0192      */
0193     void slotShareUnmounted(const SharePtr &share);
0194 
0195     /**
0196      * This slot is connected to the Smb4KMounter::aboutToStart() signal.
0197      * @param process             The process
0198      */
0199     void slotMounterAboutToStart(int process);
0200 
0201     /**
0202      * This slot is connected to the Smb4KMounter::finished() signal.
0203      * @param process             The process
0204      */
0205     void slotMounterFinished(int process);
0206 
0207     /**
0208      * This slot is called when the search toolbar is to be shown
0209      */
0210     void slotShowSearchToolBar();
0211 
0212     /**
0213      * This slot is called when the search toolbar is to be closed
0214      */
0215     void slotHideSearchToolBar();
0216 
0217     /**
0218      * This slot is called when a search should be performed
0219      *
0220      * @param item                The search item
0221      */
0222     void slotPerformSearch(const QString &item);
0223 
0224     /**
0225      * This slot is called when a search should be stopped
0226      */
0227     void slotStopSearch();
0228 
0229     /**
0230      * This slot is called when a search was performed and the search
0231      * results were returned
0232      *
0233      * @param shares              The list of search results
0234      */
0235     void slotSearchResults(const QList<SharePtr> &shares);
0236 
0237     /**
0238      * This slot is called when the user pressed the up or down action
0239      * in the search toolbar
0240      *
0241      * @param url                 The URL of the search result the user wants
0242      *                            to jump to
0243      */
0244     void slotJumpToResult(const QString &url);
0245 
0246     /**
0247      * This slot is called when the search results are to be cleared
0248      */
0249     void slotClearSearchResults();
0250 
0251 private:
0252     void setupActions();
0253     Smb4KNetworkBrowser *m_networkBrowser;
0254     KActionCollection *m_actionCollection;
0255     KActionMenu *m_contextMenu;
0256     Smb4KNetworkSearchToolBar *m_searchToolBar;
0257     bool m_searchRunning;
0258 };
0259 
0260 #endif