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>
14 class DolphinNewFileMenu
;
15 class DolphinViewActionHandler
;
19 class DolphinPartBrowserExtension
;
20 class DolphinRemoteEncoding
;
23 class DolphinRemoveAction
;
25 class DolphinPart
: public KParts::ReadOnlyPart
28 // Used by konqueror. Technically it means "we want undo enabled if
29 // there are things in the undo history and the current part is a dolphin part".
30 // Even though it's konqueror doing the undo...
31 Q_PROPERTY( bool supportsUndo READ supportsUndo
)
33 Q_PROPERTY( QString currentViewMode READ currentViewMode WRITE setCurrentViewMode
)
35 // Used by konqueror when typing something like /home/dfaure/*.diff in the location bar
36 Q_PROPERTY( QString nameFilter READ nameFilter WRITE setNameFilter
)
38 // Used by konqueror to implement the --select command-line option
39 Q_PROPERTY( QList
<QUrl
> filesToSelect READ filesToSelect WRITE setFilesToSelect
)
42 explicit DolphinPart(QWidget
* parentWidget
, QObject
* parent
,
43 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 { return true; }
56 * Used by konqueror for setting the view mode
57 * @param viewModeName internal name for the view mode, like "icons"
58 * Those names come from the Actions line in dolphinpart.desktop,
59 * and have to match the name of the KActions.
61 void setCurrentViewMode(const QString
& viewModeName
);
64 * Used by konqueror for displaying the current view mode.
65 * @see setCurrentViewMode
67 QString
currentViewMode() const;
69 /// Returns the view owned by this part; used by DolphinPartBrowserExtension
70 DolphinView
* view() { return m_view
; }
73 * Sets a name filter, like *.diff
75 void setNameFilter(const QString
& nameFilter
);
78 * Returns the current name filter. Used by konqueror to show it in the URL.
80 QString
nameFilter() const { return m_nameFilter
; }
84 * We reimplement openUrl so no need to implement openFile.
86 bool openFile() override
{ return true; }
90 * Emitted when the view mode changes. Used by konqueror.
92 void viewModeChanged();
96 * Emitted whenever the current URL is about to be changed.
98 void aboutToOpenURL();
101 void slotMessage(const QString
& msg
);
102 void slotErrorMessage(const QString
& msg
);
104 * Shows the information for the item \a item inside the statusbar. If the
105 * item is null, the default statusbar information is shown.
107 void slotRequestItemInfo(const KFileItem
& item
);
109 * Handles clicking on an item
111 void slotItemActivated(const KFileItem
& item
);
113 * Handles activation of multiple items
115 void slotItemsActivated(const KFileItemList
& items
);
117 * Creates a new window showing the content of \a url.
119 void createNewWindow(const QUrl
&url
);
121 * Opens the context menu on the current mouse position.
122 * @pos Position in screen coordinates.
123 * @item File item context. If item is null, the context menu
124 * should be applied to \a url.
125 * @url URL which contains \a item.
126 * @customActions Actions that should be added to the context menu,
127 * if the file item is null.
129 void slotOpenContextMenu(const QPoint
& pos
,
130 const KFileItem
& item
,
132 const QList
<QAction
*>& customActions
);
135 * Informs the host that we are opening \a url (e.g. after a redirection
136 * coming from KDirLister).
137 * Testcase 1: fish://localhost
138 * Testcase 2: showing a directory that is being renamed by another window (#180156)
140 void slotDirectoryRedirection(const QUrl
& oldUrl
, const QUrl
& newUrl
);
143 * Updates the state of the 'Edit' menu actions and emits
144 * the signal selectionChanged().
146 void slotSelectionChanged(const KFileItemList
& selection
);
149 * Updates the text of the paste action dependent from
150 * the number of items which are in the clipboard.
152 void updatePasteAction();
155 * Connected to all "Go" menu actions provided by DolphinPart
157 void slotGoTriggered(QAction
* action
);
160 * Connected to the "editMimeType" action
162 void slotEditMimeType();
165 * Connected to the "select_items_matching" action.
166 * Opens a dialog which permits to select all items matching a pattern like "*.jpg".
168 void slotSelectItemsMatchingPattern();
171 * Connected to the "unselect_items_matching" action.
172 * Opens a dialog which permits to unselect all items matching a pattern like "*.jpg".
174 void slotUnselectItemsMatchingPattern();
177 * Open a terminal window, starting with the current directory.
179 void slotOpenTerminal();
182 * Open preferred search tool in the current directory to find files.
187 * Updates the 'Create New...' sub menu, just before it's shown.
189 void updateNewMenu();
192 * Updates the number of items (= number of files + number of
193 * directories) in the statusbar. If files are selected, the number
194 * of selected files and the sum of the filesize is shown.
196 void updateStatusBar();
199 * Notify container of folder loading progress.
201 void updateProgress(int percent
);
203 void createDirectory();
206 * Called by konqueror --select
208 void setFilesToSelect(const QList
<QUrl
> &files
);
209 QList
<QUrl
> filesToSelect() const { return QList
<QUrl
>(); } // silence moc
211 bool eventFilter(QObject
*, QEvent
*) override
;
214 void createActions();
215 void createGoAction(const char* name
, const char* iconName
,
216 const QString
& text
, const QString
& url
,
217 QActionGroup
* actionGroup
);
219 void openSelectionDialog(const QString
& title
, const QString
& text
,
224 DolphinViewActionHandler
* m_actionHandler
;
225 DolphinRemoteEncoding
* m_remoteEncoding
;
226 DolphinPartBrowserExtension
* m_extension
;
227 DolphinNewFileMenu
* m_newFileMenu
;
228 QAction
* m_findFileAction
;
229 QAction
* m_openTerminalAction
;
230 QString m_nameFilter
;
231 DolphinRemoveAction
* m_removeAction
;
232 Q_DISABLE_COPY(DolphinPart
)
235 #endif /* DOLPHINPART_H */