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