File indexing completed on 2024-04-21 08:51:46

0001 /*
0002     The network search widget 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 SMB4KSHARESVIEWDOCKWIDGET_H
0009 #define SMB4KSHARESVIEWDOCKWIDGET_H
0010 
0011 // application specific includes
0012 #include "core/smb4kglobal.h"
0013 
0014 // Qt includes
0015 #include <QDockWidget>
0016 #include <QListWidgetItem>
0017 #include <QPointer>
0018 
0019 // KDE includes
0020 #include <KActionCollection>
0021 #include <KActionMenu>
0022 
0023 // forward declarations
0024 class Smb4KSharesViewItem;
0025 class Smb4KSharesView;
0026 class Smb4KPasswordDialog;
0027 
0028 using namespace Smb4KGlobal;
0029 
0030 class Smb4KSharesViewDockWidget : public QDockWidget
0031 {
0032     Q_OBJECT
0033 
0034 public:
0035     /**
0036      * Constructor
0037      */
0038     Smb4KSharesViewDockWidget(const QString &title, QWidget *parent = nullptr);
0039 
0040     /**
0041      * Destructor
0042      */
0043     ~Smb4KSharesViewDockWidget();
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. It is used to mount
0071      * shares.
0072      * @param item                The item that was executed.
0073      */
0074     void slotItemActivated(QListWidgetItem *item);
0075 
0076     /**
0077      * This slot is called when the selection changed. It takes care of the
0078      * actions being enabled or disabled accordingly. All widget specific
0079      * stuff has to be done in the shares view itself.
0080      */
0081     void slotItemSelectionChanged();
0082 
0083     /**
0084      * This slot is used to process an accepted drop event.
0085      * @param item                The item where the drop event occurred.
0086      * @param e                   The drop event that encapsulates the necessary data.
0087      */
0088     void slotDropEvent(Smb4KSharesViewItem *item, QDropEvent *e);
0089 
0090     /**
0091      * This slot is invoked when the view mode was changed in the View Modes
0092      * context menu.
0093      * @param action              The action that was checked
0094      */
0095     void slotViewModeChanged(QAction *action);
0096 
0097     /**
0098      * This slot is connected to the Smb4KMounter::mounted() signal and adds the
0099      * mounted share @p share to the shares view.
0100      * @param share               The share item
0101      */
0102     void slotShareMounted(const SharePtr &share);
0103 
0104     /**
0105      * This slot is connected to the Smb4KMounter::unmounted() signal and removes
0106      * the share @p share from the shares view.
0107      * @param share               The share item
0108      */
0109     void slotShareUnmounted(const SharePtr &share);
0110 
0111     /**
0112      * This slot is connected to the Smb4KMounter::updated() signal and updates
0113      * the item in the shares view corresponding to @p share.
0114      *
0115      * This slot does not remove or add any share, it only updates the present
0116      * items.
0117      * @param share               The Smb4KShare item
0118      */
0119     void slotShareUpdated(const SharePtr &share);
0120 
0121     /**
0122      * This slot is connected to the 'Unmount action'.
0123      * @param checked             TRUE if the action is checked and FALSE otherwise.
0124      */
0125     void slotUnmountActionTriggered(bool checked);
0126 
0127     /**
0128      * This slot is connected to the 'Unmount All' action. All shares - either of
0129      * the user or that are present on the system (depending on the settings the
0130      * user chose) - will be unmounted.
0131      * @param checked             TRUE if the action is checked and FALSE otherwise.
0132      */
0133     void slotUnmountAllActionTriggered(bool checked);
0134 
0135     /**
0136      * This slot is connected to the 'Add Bookmark' action. It lets you add a share
0137      * to the bookmarks.
0138      * @param checked             TRUE if the action is checked and FALSE otherwise.
0139      */
0140     void slotBookmarkActionTriggered(bool checked);
0141 
0142     /**
0143      * Provide custom options for a server or share. This slot is connected
0144      * to the 'Add Custom Settings' action.
0145      *
0146      * @param checked             Is TRUE if the action is checked (not used here).
0147      */
0148     void slotAddCustomSettingsTriggered(bool checked);
0149 
0150     /**
0151      * This slot is connected to the 'Synchronize' action. The selected items will be
0152      * synchronized with a local copy (or vice versa) if you activate it.
0153      *
0154      * @param checked             TRUE if the action is checked and FALSE otherwise.
0155      */
0156     void slotSynchronizeActionTriggered(bool checked);
0157 
0158     /**
0159      * This slot is connected to the 'Open with Konsole' action. The mount point of
0160      * the selected share items will be opened in Konsole.
0161      * @param checked             TRUE if the action is checked and FALSE otherwise.
0162      */
0163     void slotKonsoleActionTriggered(bool checked);
0164 
0165     /**
0166      * This slot is connected to the 'Open with Filemanager' action. The contents of
0167      * the selected share items will be opened in the file manager.
0168      * @param checked             TRUE if the action is checked and FALSE otherwise.
0169      */
0170     void slotFileManagerActionTriggered(bool checked);
0171 
0172 private:
0173     void setupActions();
0174     Smb4KSharesView *m_sharesView;
0175     KActionCollection *m_actionCollection;
0176     KActionMenu *m_contextMenu;
0177 };
0178 
0179 #endif