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
)
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
,
44 const KPluginMetaData
& metaData
, const QVariantList
& args
);
45 ~DolphinPart() override
;
48 * Standard KParts::ReadOnlyPart openUrl method.
49 * Called by Konqueror to view a directory in DolphinPart.
51 bool openUrl(const QUrl
& url
) override
;
53 /// see the supportsUndo property
54 bool supportsUndo() const { return true; }
57 * Used by konqueror for setting the view mode
58 * @param viewModeName internal name for the view mode, like "icons"
59 * Those names come from the Actions line in dolphinpart.desktop,
60 * and have to match the name of the KActions.
62 void setCurrentViewMode(const QString
& viewModeName
);
65 * Used by konqueror for displaying the current view mode.
66 * @see setCurrentViewMode
68 QString
currentViewMode() const;
70 /// Returns the view owned by this part; used by DolphinPartBrowserExtension
71 DolphinView
* view() { return m_view
; }
74 * Sets a name filter, like *.diff
76 void setNameFilter(const QString
& nameFilter
);
79 * Returns the current name filter. Used by konqueror to show it in the URL.
81 QString
nameFilter() const { return m_nameFilter
; }
85 * We reimplement openUrl so no need to implement openFile.
87 bool openFile() override
{ return true; }
91 * Emitted when the view mode changes. Used by konqueror.
93 void viewModeChanged();
97 * Emitted whenever the current URL is about to be changed.
99 void aboutToOpenURL();
102 void slotMessage(const QString
& msg
);
103 void slotErrorMessage(const QString
& msg
);
105 * Shows the information for the item \a item inside the statusbar. If the
106 * item is null, the default statusbar information is shown.
108 void slotRequestItemInfo(const KFileItem
& item
);
110 * Handles clicking on an item
112 void slotItemActivated(const KFileItem
& item
);
114 * Handles activation of multiple items
116 void slotItemsActivated(const KFileItemList
& items
);
118 * Creates a new window showing the content of \a url.
120 void createNewWindow(const QUrl
&url
);
122 * Opens the context menu on the current mouse position.
123 * @pos Position in screen coordinates.
124 * @item File item context. If item is null, the context menu
125 * should be applied to \a url.
126 * @selectedItems The selected items for which the context menu
127 * is opened. This list generally includes \a item.
128 * @url URL which contains \a item.
130 void slotOpenContextMenu(const QPoint
&pos
, const KFileItem
&_item
, const KFileItemList
&selectedItems
, const QUrl
&);
133 * Informs the host that we are opening \a url (e.g. after a redirection
134 * coming from KDirLister).
135 * Testcase 1: fish://localhost
136 * Testcase 2: showing a directory that is being renamed by another window (#180156)
138 void slotDirectoryRedirection(const QUrl
& oldUrl
, const QUrl
& newUrl
);
141 * Updates the state of the 'Edit' menu actions and emits
142 * the signal selectionChanged().
144 void slotSelectionChanged(const KFileItemList
& selection
);
147 * Updates the text of the paste action dependent from
148 * the number of items which are in the clipboard.
150 void updatePasteAction();
153 * Connected to all "Go" menu actions provided by DolphinPart
155 void slotGoTriggered(QAction
* action
);
158 * Connected to the "editMimeType" action
160 void slotEditMimeType();
163 * Connected to the "select_items_matching" action.
164 * Opens a dialog which permits to select all items matching a pattern like "*.jpg".
166 void slotSelectItemsMatchingPattern();
169 * Connected to the "unselect_items_matching" action.
170 * Opens a dialog which permits to unselect all items matching a pattern like "*.jpg".
172 void slotUnselectItemsMatchingPattern();
175 * Open a terminal window, starting with the current directory.
177 void slotOpenTerminal();
180 * Open preferred search tool in the current directory to find files.
185 * Updates the 'Create New...' sub menu, just before it's shown.
187 void updateNewMenu();
190 * Updates the number of items (= number of files + number of
191 * directories) in the statusbar. If files are selected, the number
192 * of selected files and the sum of the filesize is shown.
194 void updateStatusBar();
197 * Notify container of folder loading progress.
199 void updateProgress(int percent
);
201 void createDirectory();
204 * Called by konqueror --select
206 void setFilesToSelect(const QList
<QUrl
> &files
);
207 QList
<QUrl
> filesToSelect() const { return QList
<QUrl
>(); } // silence moc
209 bool eventFilter(QObject
*, QEvent
*) override
;
212 void createActions();
213 void createGoAction(const char* name
, const char* iconName
,
214 const QString
& text
, const QString
& url
,
215 QActionGroup
* actionGroup
);
217 void openSelectionDialog(const QString
& title
, const QString
& text
,
219 QString
urlToLocalFilePath(const QUrl
&url
);
220 QString
localFilePathOrHome() const;
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 */