]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinpart.h
Output of licensedigger + manual cleanup afterwards.
[dolphin.git] / src / dolphinpart.h
1 /* This file is part of the KDE project
2 SPDX-FileCopyrightText: 2007 David Faure <faure@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
7 #ifndef DOLPHINPART_H
8 #define DOLPHINPART_H
9
10 #include <KParts/ReadOnlyPart>
11
12 #include <QUrl>
13
14 class DolphinNewFileMenu;
15 class DolphinViewActionHandler;
16 class QActionGroup;
17 class KFileItemList;
18 class KFileItem;
19 class DolphinPartBrowserExtension;
20 class DolphinRemoteEncoding;
21 class KDirLister;
22 class DolphinView;
23 class KAboutData;
24 class DolphinRemoveAction;
25
26 class DolphinPart : public KParts::ReadOnlyPart
27 {
28 Q_OBJECT
29 // Used by konqueror. Technically it means "we want undo enabled if
30 // there are things in the undo history and the current part is a dolphin part".
31 // Even though it's konqueror doing the undo...
32 Q_PROPERTY( bool supportsUndo READ supportsUndo )
33
34 Q_PROPERTY( QString currentViewMode READ currentViewMode WRITE setCurrentViewMode )
35
36 // Used by konqueror when typing something like /home/dfaure/*.diff in the location bar
37 Q_PROPERTY( QString nameFilter READ nameFilter WRITE setNameFilter )
38
39 // Used by konqueror to implement the --select command-line option
40 Q_PROPERTY( QList<QUrl> filesToSelect READ filesToSelect WRITE setFilesToSelect )
41
42 public:
43 explicit DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantList& args);
44 ~DolphinPart() override;
45
46 static KAboutData* createAboutData();
47
48 /**
49 * Standard KParts::ReadOnlyPart openUrl method.
50 * Called by Konqueror to view a directory in DolphinPart.
51 */
52 bool openUrl(const QUrl& url) override;
53
54 /// see the supportsUndo property
55 bool supportsUndo() const { return true; }
56
57 /**
58 * Used by konqueror for setting the view mode
59 * @param viewModeName internal name for the view mode, like "icons"
60 * Those names come from the Actions line in dolphinpart.desktop,
61 * and have to match the name of the KActions.
62 */
63 void setCurrentViewMode(const QString& viewModeName);
64
65 /**
66 * Used by konqueror for displaying the current view mode.
67 * @see setCurrentViewMode
68 */
69 QString currentViewMode() const;
70
71 /// Returns the view owned by this part; used by DolphinPartBrowserExtension
72 DolphinView* view() { return m_view; }
73
74 /**
75 * Sets a name filter, like *.diff
76 */
77 void setNameFilter(const QString& nameFilter);
78
79 /**
80 * Returns the current name filter. Used by konqueror to show it in the URL.
81 */
82 QString nameFilter() const { return m_nameFilter; }
83
84 protected:
85 /**
86 * We reimplement openUrl so no need to implement openFile.
87 */
88 bool openFile() override { return true; }
89
90 Q_SIGNALS:
91 /**
92 * Emitted when the view mode changes. Used by konqueror.
93 */
94 void viewModeChanged();
95
96
97 /**
98 * Emitted whenever the current URL is about to be changed.
99 */
100 void aboutToOpenURL();
101
102 private Q_SLOTS:
103 void slotMessage(const QString& msg);
104 void slotErrorMessage(const QString& msg);
105 /**
106 * Shows the information for the item \a item inside the statusbar. If the
107 * item is null, the default statusbar information is shown.
108 */
109 void slotRequestItemInfo(const KFileItem& item);
110 /**
111 * Handles clicking on an item
112 */
113 void slotItemActivated(const KFileItem& item);
114 /**
115 * Handles activation of multiple items
116 */
117 void slotItemsActivated(const KFileItemList& items);
118 /**
119 * Creates a new window showing the content of \a url.
120 */
121 void createNewWindow(const QUrl &url);
122 /**
123 * Opens the context menu on the current mouse position.
124 * @pos Position in screen coordinates.
125 * @item File item context. If item is null, the context menu
126 * should be applied to \a url.
127 * @url URL which contains \a item.
128 * @customActions Actions that should be added to the context menu,
129 * if the file item is null.
130 */
131 void slotOpenContextMenu(const QPoint& pos,
132 const KFileItem& item,
133 const QUrl& url,
134 const QList<QAction*>& customActions);
135
136 /**
137 * Informs the host that we are opening \a url (e.g. after a redirection
138 * coming from KDirLister).
139 * Testcase 1: fish://localhost
140 * Testcase 2: showing a directory that is being renamed by another window (#180156)
141 */
142 void slotDirectoryRedirection(const QUrl& oldUrl, const QUrl& newUrl);
143
144 /**
145 * Updates the state of the 'Edit' menu actions and emits
146 * the signal selectionChanged().
147 */
148 void slotSelectionChanged(const KFileItemList& selection);
149
150 /**
151 * Updates the text of the paste action dependent from
152 * the number of items which are in the clipboard.
153 */
154 void updatePasteAction();
155
156 /**
157 * Connected to all "Go" menu actions provided by DolphinPart
158 */
159 void slotGoTriggered(QAction* action);
160
161 /**
162 * Connected to the "editMimeType" action
163 */
164 void slotEditMimeType();
165
166 /**
167 * Connected to the "select_items_matching" action.
168 * Opens a dialog which permits to select all items matching a pattern like "*.jpg".
169 */
170 void slotSelectItemsMatchingPattern();
171
172 /**
173 * Connected to the "unselect_items_matching" action.
174 * Opens a dialog which permits to unselect all items matching a pattern like "*.jpg".
175 */
176 void slotUnselectItemsMatchingPattern();
177
178 /**
179 * Open a terminal window, starting with the current directory.
180 */
181 void slotOpenTerminal();
182
183 /**
184 * Open preferred search tool in the current directory to find files.
185 */
186 void slotFindFile();
187
188 /**
189 * Updates the 'Create New...' sub menu, just before it's shown.
190 */
191 void updateNewMenu();
192
193 /**
194 * Updates the number of items (= number of files + number of
195 * directories) in the statusbar. If files are selected, the number
196 * of selected files and the sum of the filesize is shown.
197 */
198 void updateStatusBar();
199
200 /**
201 * Notify container of folder loading progress.
202 */
203 void updateProgress(int percent);
204
205 void createDirectory();
206
207 /**
208 * Called by konqueror --select
209 */
210 void setFilesToSelect(const QList<QUrl> &files);
211 QList<QUrl> filesToSelect() const { return QList<QUrl>(); } // silence moc
212
213 bool eventFilter(QObject*, QEvent*) override;
214
215 private:
216 void createActions();
217 void createGoAction(const char* name, const char* iconName,
218 const QString& text, const QString& url,
219 QActionGroup* actionGroup);
220
221 void openSelectionDialog(const QString& title, const QString& text,
222 bool selectItems);
223
224 private:
225 DolphinView* m_view;
226 DolphinViewActionHandler* m_actionHandler;
227 DolphinRemoteEncoding* m_remoteEncoding;
228 DolphinPartBrowserExtension* m_extension;
229 DolphinNewFileMenu* m_newFileMenu;
230 QAction* m_findFileAction;
231 QAction* m_openTerminalAction;
232 QString m_nameFilter;
233 DolphinRemoveAction* m_removeAction;
234 Q_DISABLE_COPY(DolphinPart)
235 };
236
237 #endif /* DOLPHINPART_H */