1 /* This file is part of the KDE project
2 SPDX-FileCopyrightText: 2007 David Faure <faure@kde.org>
4 SPDX-License-Identifier: LGPL-2.0-or-later
10 #include <KParts/ReadOnlyPart>
15 class DolphinNewFileMenu
;
16 class DolphinViewActionHandler
;
20 class DolphinPartBrowserExtension
;
21 class DolphinRemoteEncoding
;
24 class DolphinRemoveAction
;
26 class DolphinPart
: public KParts::ReadOnlyPart
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 CONSTANT
)
34 Q_PROPERTY(QString currentViewMode READ currentViewMode WRITE setCurrentViewMode
)
36 // Used by konqueror when typing something like /home/dfaure/*.diff in the location bar
37 Q_PROPERTY(QString nameFilter READ nameFilter WRITE setNameFilter
)
39 // Used by konqueror to implement the --select command-line option
40 Q_PROPERTY(QList
<QUrl
> filesToSelect READ filesToSelect WRITE setFilesToSelect
)
43 explicit DolphinPart(QWidget
*parentWidget
, QObject
*parent
, const KPluginMetaData
&metaData
, const QVariantList
&args
);
44 ~DolphinPart() override
;
47 * Standard KParts::ReadOnlyPart openUrl method.
48 * Called by Konqueror to view a directory in DolphinPart.
50 bool openUrl(const QUrl
&url
) override
;
52 /// see the supportsUndo property
53 bool supportsUndo() const
59 * Used by konqueror for setting the view mode
60 * @param viewModeName internal name for the view mode, like "icons"
61 * Those names come from the Actions line in dolphinpart.desktop,
62 * and have to match the name of the KActions.
64 void setCurrentViewMode(const QString
&viewModeName
);
67 * Used by konqueror for displaying the current view mode.
68 * @see setCurrentViewMode
70 QString
currentViewMode() const;
72 /// Returns the view owned by this part; used by DolphinPartBrowserExtension
79 * Sets a name filter, like *.diff
81 void setNameFilter(const QString
&nameFilter
);
84 * Returns the current name filter. Used by konqueror to show it in the URL.
86 QString
nameFilter() const
93 * We reimplement openUrl so no need to implement openFile.
95 bool openFile() override
102 * Emitted when the view mode changes. Used by konqueror.
104 void viewModeChanged();
107 * Emitted whenever the current URL is about to be changed.
109 void aboutToOpenURL();
112 void slotMessage(const QString
&msg
);
113 void slotErrorMessage(const QString
&msg
);
115 * Shows the information for the item \a item inside the statusbar. If the
116 * item is null, the default statusbar information is shown.
118 void slotRequestItemInfo(const KFileItem
&item
);
120 * Handles clicking on an item
122 void slotItemActivated(const KFileItem
&item
);
124 * Handles activation of multiple items
126 void slotItemsActivated(const KFileItemList
&items
);
128 * Creates a new window showing the content of \a url.
130 void createNewWindow(const QUrl
&url
);
132 * Opens the context menu on the current mouse position.
133 * @pos Position in screen coordinates.
134 * @item File item context. If item is null, the context menu
135 * should be applied to \a url.
136 * @selectedItems The selected items for which the context menu
137 * is opened. This list generally includes \a item.
138 * @url URL which contains \a item.
140 void slotOpenContextMenu(const QPoint
&pos
, const KFileItem
&_item
, const KFileItemList
&selectedItems
, const QUrl
&);
143 * Informs the host that we are opening \a url (e.g. after a redirection
144 * coming from KDirLister).
145 * Testcase 1: fish://localhost
146 * Testcase 2: showing a directory that is being renamed by another window (#180156)
148 void slotDirectoryRedirection(const QUrl
&oldUrl
, const QUrl
&newUrl
);
151 * Updates the state of the 'Edit' menu actions and emits
152 * the signal selectionChanged().
154 void slotSelectionChanged(const KFileItemList
&selection
);
157 * Updates the text of the paste action dependent from
158 * the number of items which are in the clipboard.
160 void updatePasteAction();
163 * Connected to all "Go" menu actions provided by DolphinPart
165 void slotGoTriggered(QAction
*action
);
168 * Connected to the "editMimeType" action
170 void slotEditMimeType();
173 * Connected to the "select_items_matching" action.
174 * Opens a dialog which permits to select all items matching a pattern like "*.jpg".
176 void slotSelectItemsMatchingPattern();
179 * Connected to the "unselect_items_matching" action.
180 * Opens a dialog which permits to unselect all items matching a pattern like "*.jpg".
182 void slotUnselectItemsMatchingPattern();
185 * Open a terminal window, starting with the current directory.
187 void slotOpenTerminal();
190 * Open preferred search tool in the current directory to find files.
195 * Updates the 'Create New...' sub menu, just before it's shown.
197 void updateNewMenu();
200 * Updates the number of items (= number of files + number of
201 * directories) in the statusbar. If files are selected, the number
202 * of selected files and the sum of the filesize is shown.
204 void updateStatusBar();
207 * Notify container of folder loading progress.
209 void updateProgress(int percent
);
211 void createDirectory();
214 * Called by konqueror --select
216 void setFilesToSelect(const QList
<QUrl
> &files
);
217 QList
<QUrl
> filesToSelect() const
219 return QList
<QUrl
>();
222 bool eventFilter(QObject
*, QEvent
*) override
;
225 void createActions();
226 void createGoAction(const char *name
, const char *iconName
, const QString
&text
, const QString
&url
, QActionGroup
*actionGroup
);
228 void openSelectionDialog(const QString
&title
, const QString
&text
, bool selectItems
);
229 QString
urlToLocalFilePath(const QUrl
&url
);
230 QString
localFilePathOrHome() const;
234 DolphinViewActionHandler
*m_actionHandler
;
235 DolphinRemoteEncoding
*m_remoteEncoding
;
236 DolphinPartBrowserExtension
*m_extension
;
237 DolphinNewFileMenu
*m_newFileMenu
;
238 QAction
*m_findFileAction
;
239 QAction
*m_openTerminalAction
;
240 QString m_nameFilter
;
241 DolphinRemoveAction
*m_removeAction
;
242 Q_DISABLE_COPY(DolphinPart
)
245 #endif /* DOLPHINPART_H */