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