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
;
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
)
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 QVariantList
& args
);
44 ~DolphinPart() override
;
46 static KAboutData
* createAboutData();
49 * Standard KParts::ReadOnlyPart openUrl method.
50 * Called by Konqueror to view a directory in DolphinPart.
52 bool openUrl(const QUrl
& url
) override
;
54 /// see the supportsUndo property
55 bool supportsUndo() const { return true; }
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.
63 void setCurrentViewMode(const QString
& viewModeName
);
66 * Used by konqueror for displaying the current view mode.
67 * @see setCurrentViewMode
69 QString
currentViewMode() const;
71 /// Returns the view owned by this part; used by DolphinPartBrowserExtension
72 DolphinView
* view() { return m_view
; }
75 * Sets a name filter, like *.diff
77 void setNameFilter(const QString
& nameFilter
);
80 * Returns the current name filter. Used by konqueror to show it in the URL.
82 QString
nameFilter() const { return m_nameFilter
; }
86 * We reimplement openUrl so no need to implement openFile.
88 bool openFile() override
{ return true; }
92 * Emitted when the view mode changes. Used by konqueror.
94 void viewModeChanged();
98 * Emitted whenever the current URL is about to be changed.
100 void aboutToOpenURL();
103 void slotMessage(const QString
& msg
);
104 void slotErrorMessage(const QString
& msg
);
106 * Shows the information for the item \a item inside the statusbar. If the
107 * item is null, the default statusbar information is shown.
109 void slotRequestItemInfo(const KFileItem
& item
);
111 * Handles clicking on an item
113 void slotItemActivated(const KFileItem
& item
);
115 * Handles activation of multiple items
117 void slotItemsActivated(const KFileItemList
& items
);
119 * Creates a new window showing the content of \a url.
121 void createNewWindow(const QUrl
&url
);
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.
131 void slotOpenContextMenu(const QPoint
& pos
,
132 const KFileItem
& item
,
134 const QList
<QAction
*>& customActions
);
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)
142 void slotDirectoryRedirection(const QUrl
& oldUrl
, const QUrl
& newUrl
);
145 * Updates the state of the 'Edit' menu actions and emits
146 * the signal selectionChanged().
148 void slotSelectionChanged(const KFileItemList
& selection
);
151 * Updates the text of the paste action dependent from
152 * the number of items which are in the clipboard.
154 void updatePasteAction();
157 * Connected to all "Go" menu actions provided by DolphinPart
159 void slotGoTriggered(QAction
* action
);
162 * Connected to the "editMimeType" action
164 void slotEditMimeType();
167 * Connected to the "select_items_matching" action.
168 * Opens a dialog which permits to select all items matching a pattern like "*.jpg".
170 void slotSelectItemsMatchingPattern();
173 * Connected to the "unselect_items_matching" action.
174 * Opens a dialog which permits to unselect all items matching a pattern like "*.jpg".
176 void slotUnselectItemsMatchingPattern();
179 * Open a terminal window, starting with the current directory.
181 void slotOpenTerminal();
184 * Open preferred search tool in the current directory to find files.
189 * Updates the 'Create New...' sub menu, just before it's shown.
191 void updateNewMenu();
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.
198 void updateStatusBar();
201 * Notify container of folder loading progress.
203 void updateProgress(int percent
);
205 void createDirectory();
208 * Called by konqueror --select
210 void setFilesToSelect(const QList
<QUrl
> &files
);
211 QList
<QUrl
> filesToSelect() const { return QList
<QUrl
>(); } // silence moc
213 bool eventFilter(QObject
*, QEvent
*) override
;
216 void createActions();
217 void createGoAction(const char* name
, const char* iconName
,
218 const QString
& text
, const QString
& url
,
219 QActionGroup
* actionGroup
);
221 void openSelectionDialog(const QString
& title
, const QString
& text
,
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
)
237 #endif /* DOLPHINPART_H */