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