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