File indexing completed on 2024-07-14 15:13:56

0001 /***************************************************************************
0002     The network neighborhood browser dock widget 
0003                              -------------------
0004     begin                : Sat Apr 28 2018
0005     copyright            : (C) 2018-2019 by Alexander Reinholdt
0006     email                : alexander.reinholdt@kdemail.net
0007  ***************************************************************************/
0008 
0009 /***************************************************************************
0010  *   This program is free software; you can redistribute it and/or modify  *
0011  *   it under the terms of the GNU General Public License as published by  *
0012  *   the Free Software Foundation; either version 2 of the License, or     *
0013  *   (at your option) any later version.                                   *
0014  *                                                                         *
0015  *   This program is distributed in the hope that it will be useful, but   *
0016  *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
0017  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
0018  *   General Public License for more details.                              *
0019  *                                                                         *
0020  *   You should have received a copy of the GNU General Public License     *
0021  *   along with this program; if not, write to the                         *
0022  *   Free Software Foundation, Inc., 51 Franklin Street, Suite 500, Boston,*
0023  *   MA 02110-1335, USA                                                    *
0024  ***************************************************************************/
0025 
0026 #ifndef SMB4KNETWORKBROWSERDOCKWIDGET_H
0027 #define SMB4KNETWORKBROWSERDOCKWIDGET_H
0028 
0029 // application specific includes
0030 #include "smb4knetworkbrowser.h"
0031 #include "smb4knetworksearchtoolbar.h"
0032 #include "core/smb4kglobal.h"
0033 
0034 // Qt includes
0035 #include <QDockWidget>
0036 
0037 // KDE includes
0038 #include <KWidgetsAddons/KActionMenu>
0039 #include <KXmlGui/KActionCollection>
0040 
0041 using namespace Smb4KGlobal;
0042 
0043 
0044 class Smb4KNetworkBrowserDockWidget : public QDockWidget
0045 {
0046   Q_OBJECT
0047   
0048   public:
0049     /**
0050     * Constructor
0051     */
0052     Smb4KNetworkBrowserDockWidget(const QString &title, QWidget *parent = 0);
0053     
0054     /**
0055     * Destructor
0056     */
0057     ~Smb4KNetworkBrowserDockWidget();
0058     
0059     /**
0060      * Load settings
0061      */
0062     void loadSettings();
0063 
0064     /**
0065      * Save settings
0066      */
0067     void saveSettings();
0068     
0069     /**
0070      * Returns the action collection of this dock widget
0071      * @returns the action collection
0072      */
0073     KActionCollection *actionCollection();
0074     
0075   protected Q_SLOTS:
0076     /**
0077      * This slot is called if the user requests the context menu. It shows
0078      * the menu with the actions defined for the widget.
0079      * @param pos                 The position where user clicked.
0080      */
0081     void slotContextMenuRequested(const QPoint &pos);
0082     
0083     /**
0084      * This slot is invoked when the user activated an item in the network
0085      * neighborhood browser.
0086      * @param item                The item that was executed.
0087      * @param column              The column where the item was executed.
0088      */
0089     void slotItemActivated(QTreeWidgetItem *item, int column);
0090     
0091     /**
0092      * Is called when the selection changed. This slot takes care of the
0093      * actions being enabled or disabled accordingly. All widget specific
0094      * stuff has to be done in the browser widget itself.
0095      * @param item                The selection list view item.
0096      */
0097     void slotItemSelectionChanged();
0098     
0099     /**
0100      * This slot is connected to the Smb4KClient::aboutToStart() signal.
0101      * 
0102      * @param item                The Smb4KBasicNetworkItem object
0103      * @param process             The process
0104      */
0105     void slotClientAboutToStart(const NetworkItemPtr &item, int process);
0106 
0107     /**
0108      * This slot is connected to the Smb4KClient::finished() signal.
0109      * 
0110      * @param item                The Smb4KBasicNetworkItem object
0111      * @param process             The process
0112      */
0113     void slotClientFinished(const NetworkItemPtr &item, int process);    
0114     
0115     /**
0116      * This slot is called when workgroups/domains were discovered
0117      */
0118     void slotWorkgroups();
0119     
0120     /**
0121      * This slot is called when the list of servers of workgroup/domain 
0122      * @p workgroup was discovered. 
0123      * @param workgroup           The workgroup/domain that was queried
0124      */
0125     void slotWorkgroupMembers(const WorkgroupPtr &workgroup);
0126     
0127     /**
0128      * This slot is called when the list of shared resources of host @p host was
0129      * queried.
0130      * @param host                The host that was queried
0131      */
0132     void slotShares(const HostPtr &host);
0133     
0134     /**
0135      * Rescan the network or abort a network scan.
0136      * @param checked             Is TRUE if the action is checked (not used here).
0137      */
0138     void slotRescanAbortActionTriggered(bool checked);
0139     
0140     /**
0141      * Bookmark a remote share. This slot is connected to the 'Add Bookmark'
0142      * action.
0143      * @param checked             Is TRUE if the action is checked (not used here).
0144      */
0145     void slotAddBookmark(bool checked);
0146     
0147     /**
0148      * Manually mount a share. This slot is connected to the 'Mount Manually'
0149      * action and opens a mount dialog.
0150      * @param checked             Is TRUE if the action is checked (not used here).
0151      */
0152     void slotMountManually(bool checked);
0153     
0154     /**
0155      * Provide authentication for the current network object. This slot is
0156      * connected to the 'Authentication' action.
0157      *
0158      * @param checked             Is TRUE if the action is checked (not used here).
0159      */
0160     void slotAuthentication(bool checked);
0161     
0162     /**
0163      * Provide custom options for a server or share. This slot is connected
0164      * to the 'Custom Options' action.
0165      * @param checked             Is TRUE if the action is checked (not used here).
0166      */
0167     void slotCustomOptions(bool checked);
0168     
0169     /**
0170      * Preview a share. This slot is connected to the 'Preview' action.
0171      * @param checked             Is TRUE if the action is checked (not used here).
0172      */
0173     void slotPreview(bool checked);
0174     
0175     /**
0176      * Print a document on a remote printer. This slot is connected to the
0177      * 'Print File' action.
0178      * @param checked             Is TRUE if the action is checked (not used here).
0179      */
0180     void slotPrint(bool checked);
0181     
0182     /**
0183      * Mount or unmount a share. This slot is connected to the 'Mount'/'Unmount' dual action.
0184      * @param checked             Is TRUE if the action is checked (not used here).
0185      */
0186     void slotMountActionTriggered(bool checked);
0187     
0188     /**
0189      * Change the state of the 'Mount'/'Unmount' dual action.
0190      * @param active              TRUE if the action is in the active state.
0191      */
0192     void slotMountActionChanged(bool active);
0193     
0194     /**
0195      * This slot is called whenever a share has been mounted. It marks the
0196      * respective share in the tree widget as mounted.
0197      * @param share               The Smb4KShare object
0198      */
0199     void slotShareMounted(const SharePtr &share);
0200 
0201     /**
0202      * This slot is called whenever a share has been unmounted. It marks the
0203      * respective share in the tree widget as not mounted.
0204      * @param share               The Smb4KShare object
0205      */
0206     void slotShareUnmounted(const SharePtr &share);
0207     
0208     /**
0209      * This slot is connected to the Smb4KMounter::aboutToStart() signal.
0210      * @param process             The process
0211      */
0212     void slotMounterAboutToStart(int process);
0213 
0214     /**
0215      * This slot is connected to the Smb4KMounter::finished() signal.
0216      * @param process             The process
0217      */
0218     void slotMounterFinished(int process);
0219     
0220     /**
0221      * This slot is called if the icon size was changed.
0222      * @param group               The icon group
0223      */
0224     void slotIconSizeChanged(int group);
0225     
0226     /**
0227      * This slot is called when the search toolbar is to be shown
0228      */
0229     void slotShowSearchToolBar();
0230     
0231     /**
0232      * This slot is called when the search toolbar is to be closed
0233      */
0234     void slotHideSearchToolBar();
0235     
0236     /**
0237      * This slot is called when a search should be performed
0238      * 
0239      * @param item                The search item
0240      */
0241     void slotPerformSearch(const QString &item);
0242     
0243     /**
0244      * This slot is called when a search should be stopped
0245      */
0246     void slotStopSearch();
0247     
0248     /**
0249      * This slot is called when a search was performed and the search 
0250      * results were returned
0251      * 
0252      * @param shares              The list of search results
0253      */
0254     void slotSearchResults(const QList<SharePtr> &shares);
0255     
0256     /**
0257      * This slot is called when the user pressed the up or down action
0258      * in the search toolbar
0259      *
0260      * @param url                 The URL of the search result the user wants 
0261      *                            to jump to
0262      */
0263     void slotJumpToResult(const QString &url);
0264     
0265     /**
0266      * This slot is called when the search results are to be cleared
0267      */
0268     void slotClearSearchResults();
0269     
0270   private:
0271     /**
0272      * Set up the actions
0273      */
0274     void setupActions();
0275     
0276     /**
0277      * The network browser
0278      */
0279     Smb4KNetworkBrowser *m_networkBrowser;
0280     
0281     /**
0282      * Action collection
0283      */
0284     KActionCollection *m_actionCollection;
0285     
0286     /**
0287      * Context menu
0288      */
0289     KActionMenu *m_contextMenu;
0290     
0291     /**
0292      * Network search bar
0293      */
0294     Smb4KNetworkSearchToolBar *m_searchToolBar;
0295     
0296     /**
0297      * Boolean to prevent the expansion of the items while global 
0298      * network search is underway
0299      */
0300     bool m_searchRunning;
0301 };
0302 
0303 #endif