File indexing completed on 2023-10-01 08:44:29

0001 /***************************************************************************
0002     The network search widget dock widget 
0003                              -------------------
0004     begin                : Fri Mai 04 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 SMB4KSHARESVIEWDOCKWIDGET_H
0027 #define SMB4KSHARESVIEWDOCKWIDGET_H
0028 
0029 // application specific includes
0030 #include "smb4ksharesview.h"
0031 #include "core/smb4kglobal.h"
0032 
0033 // Qt includes
0034 #include <QDockWidget>
0035 
0036 // KDE includes
0037 #include <KWidgetsAddons/KActionMenu>
0038 #include <KXmlGui/KActionCollection>
0039 
0040 // forward declarations
0041 class Smb4KSharesViewItem;
0042 
0043 using namespace Smb4KGlobal;
0044 
0045 
0046 class Smb4KSharesViewDockWidget : public QDockWidget
0047 {
0048   Q_OBJECT
0049   
0050   public:
0051     /**
0052      * Constructor
0053      */
0054     Smb4KSharesViewDockWidget(const QString &title, QWidget *parent = 0);
0055     
0056     /**
0057      * Destructor
0058      */
0059     ~Smb4KSharesViewDockWidget();
0060     
0061     /**
0062      * Load settings
0063      */
0064     void loadSettings();
0065 
0066     /**
0067      * Save settings
0068      */
0069     void saveSettings();
0070     
0071     /**
0072      * Returns the action collection of this dock widget
0073      * @returns the action collection
0074      */
0075     KActionCollection *actionCollection();
0076     
0077   protected Q_SLOTS:
0078     /**
0079      * This slot is called if the user requests the context menu. It shows
0080      * the menu with the actions defined for the widget.
0081      * @param pos                 The position where user clicked.
0082      */
0083     void slotContextMenuRequested(const QPoint &pos);
0084     
0085     /**
0086      * This slot is invoked when the user activated an item. It is used to mount
0087      * shares.
0088      * @param item                The item that was executed.
0089      */
0090     void slotItemActivated(QListWidgetItem *item);
0091     
0092     /**
0093      * This slot is called when the selection changed. It takes care of the
0094      * actions being enabled or disabled accordingly. All widget specific
0095      * stuff has to be done in the shares view itself.
0096      */
0097     void slotItemSelectionChanged();
0098     
0099     /**
0100      * This slot is used to process an accepted drop event.
0101      * @param item                The item where the drop event occurred.
0102      * @param e                   The drop event that encapsulates the necessary data.
0103      */
0104     void slotDropEvent(Smb4KSharesViewItem *item, QDropEvent *e);
0105     
0106     /**
0107      * This slot is invoked when the view mode was changed in the View Modes
0108      * context menu.
0109      * @param action              The action that was checked
0110      */
0111     void slotViewModeChanged(QAction *action);
0112     
0113     /**
0114      * This slot is connected to the Smb4KMounter::mounted() signal and adds the 
0115      * mounted share @p share to the shares view.
0116      * @param share               The share item
0117      */
0118     void slotShareMounted(const SharePtr &share);
0119     
0120     /**
0121      * This slot is connected to the Smb4KMounter::unmounted() signal and removes
0122      * the share @p share from the shares view.
0123      * @param share               The share item
0124      */
0125     void slotShareUnmounted(const SharePtr &share);
0126     
0127     /**
0128      * This slot is connected to the Smb4KMounter::updated() signal and updates
0129      * the item in the shares view corresponding to @p share.
0130      * 
0131      * This slot does not remove or add any share, it only updates the present 
0132      * items.
0133      * @param share               The Smb4KShare item
0134      */
0135     void slotShareUpdated(const SharePtr &share);
0136     
0137     /**
0138      * This slot is connected to the 'Unmount action'. 
0139      * @param checked             TRUE if the action is checked and FALSE otherwise.
0140      */
0141     void slotUnmountActionTriggered(bool checked);
0142     
0143     /**
0144      * This slot is connected to the 'Unmount All' action. All shares - either of
0145      * the user or that are present on the system (depending on the settings the
0146      * user chose) - will be unmounted.
0147      * @param checked             TRUE if the action is checked and FALSE otherwise.
0148      */
0149     void slotUnmountAllActionTriggered(bool checked);
0150     
0151     /**
0152      * This slot is connected to the 'Add Bookmark' action. It lets you add a share 
0153      * to the bookmarks.
0154      * @param checked             TRUE if the action is checked and FALSE otherwise.
0155      */
0156     void slotBookmarkActionTriggered(bool checked);
0157     
0158     /**
0159      * This slot is connected to the 'Synchronize' action. The selected items will be
0160      * synchronized with a local copy (or vice versa) if you activate it.
0161      *
0162      * @param checked             TRUE if the action is checked and FALSE otherwise.
0163      */
0164     void slotSynchronizeActionTriggered(bool checked);
0165     
0166     /**
0167      * This slot is connected to the 'Open with Konsole' action. The mount point of 
0168      * the selected share items will be opened in Konsole.
0169      * @param checked             TRUE if the action is checked and FALSE otherwise.
0170      */
0171     void slotKonsoleActionTriggered(bool checked);
0172     
0173     /**
0174      * This slot is connected to the 'Open with Filemanager' action. The contents of 
0175      * the selected share items will be opened in the file manager.
0176      * @param checked             TRUE if the action is checked and FALSE otherwise.
0177      */
0178     void slotFileManagerActionTriggered(bool checked);
0179     
0180     /**
0181      * This slot is called if the icon size was changed.
0182      *
0183      * @param group               The icon group
0184      */
0185     void slotIconSizeChanged(int group);
0186     
0187   private:
0188     /**
0189      * Set up the actions
0190      */
0191     void setupActions();
0192     
0193     /**
0194      * The shares shares view
0195      */
0196     Smb4KSharesView *m_sharesView;
0197     
0198     /**
0199      * Action collection
0200      */
0201     KActionCollection *m_actionCollection;
0202     
0203     /**
0204      * Context menu
0205      */
0206     KActionMenu *m_contextMenu;
0207 };
0208 
0209 #endif
0210