]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinpart.h
Handle redirections (e.g. from fish://localhost) without breaking the column view...
[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/part.h>
24 #include <kparts/browserextension.h>
25 class DolphinViewActionHandler;
26 class QActionGroup;
27 class KAction;
28 class KFileItemList;
29 class KFileItem;
30 class DolphinPartBrowserExtension;
31 class DolphinSortFilterProxyModel;
32 class DolphinModel;
33 class KDirLister;
34 class DolphinView;
35 class QLineEdit;
36 class KAboutData;
37
38 class DolphinPart : public KParts::ReadOnlyPart
39 {
40 Q_OBJECT
41 // Used by konqueror. Technically it means "we want undo enabled if
42 // there are things in the undo history and the current part is a dolphin part".
43 // Even though it's konqueror doing the undo...
44 Q_PROPERTY( bool supportsUndo READ supportsUndo )
45
46 Q_PROPERTY( QString currentViewMode READ currentViewMode WRITE setCurrentViewMode )
47
48 // Used by konqueror when typing something like /home/dfaure/*.diff in the location bar
49 Q_PROPERTY( QString nameFilter READ nameFilter WRITE setNameFilter )
50
51 public:
52 explicit DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantList& args);
53 ~DolphinPart();
54
55 static KAboutData* createAboutData();
56
57 /**
58 * Standard KParts::ReadOnlyPart openUrl method.
59 * Called by Konqueror to view a directory in DolphinPart.
60 */
61 virtual bool openUrl(const KUrl& url);
62
63 /// see the supportsUndo property
64 bool supportsUndo() const { return true; }
65
66 /**
67 * Used by konqueror for setting the view mode
68 * @param viewModeName internal name for the view mode, like "icons"
69 * Those names come from the Actions line in dolphinpart.desktop,
70 * and have to match the name of the KActions.
71 */
72 void setCurrentViewMode(const QString& viewModeName);
73
74 /**
75 * Used by konqueror for displaying the current view mode.
76 * @see setCurrentViewMode
77 */
78 QString currentViewMode() const;
79
80 /// Returns the view owned by this part; used by DolphinPartBrowserExtension
81 DolphinView* view() { return m_view; }
82
83 /**
84 * Sets a name filter, like *.diff
85 */
86 void setNameFilter(const QString& nameFilter);
87
88 /**
89 * Returns the current name filter. Used by konqueror to show it in the URL.
90 */
91 QString nameFilter() const { return m_nameFilter; }
92
93 protected:
94 /**
95 * We reimplement openUrl so no need to implement openFile.
96 */
97 virtual bool openFile() { return true; }
98
99 Q_SIGNALS:
100 /**
101 * Emitted when the view mode changes. Used by konqueror.
102 */
103 void viewModeChanged();
104
105
106 /**
107 * Emitted whenever the current URL is about to be changed.
108 */
109 void aboutToOpenURL();
110
111 private Q_SLOTS:
112 void slotCompleted(const KUrl& url);
113 void slotCanceled(const KUrl& url);
114 void slotInfoMessage(const QString& msg);
115 void slotErrorMessage(const QString& msg);
116 /**
117 * Shows the information for the item \a item inside the statusbar. If the
118 * item is null, the default statusbar information is shown.
119 */
120 void slotRequestItemInfo(const KFileItem& item);
121 /**
122 * Handles clicking on an item
123 */
124 void slotItemTriggered(const KFileItem& item);
125 /**
126 * Creates a new window showing the content of \a url.
127 */
128 void createNewWindow(const KUrl& url);
129 /**
130 * Opens the context menu on the current mouse position.
131 * @item File item context. If item is 0, the context menu
132 * should be applied to \a url.
133 * @url URL which contains \a item.
134 */
135 void slotOpenContextMenu(const KFileItem& item, const KUrl& url);
136
137 /**
138 * Asks the host to open the URL \a url if the current view has
139 * a different URL.
140 */
141 void slotRequestUrlChange(const KUrl& url);
142
143 /**
144 * Informs the host that we are opening \a url (e.g. after a redirection).
145 */
146 void slotUrlChanged(const KUrl& url);
147
148 /**
149 * Updates the state of the 'Edit' menu actions and emits
150 * the signal selectionChanged().
151 */
152 void slotSelectionChanged(const KFileItemList& selection);
153
154 /**
155 * Updates the text of the paste action dependent from
156 * the number of items which are in the clipboard.
157 */
158 void updatePasteAction();
159
160 /**
161 * Connected to all "Go" menu actions provided by DolphinPart
162 */
163 void slotGoTriggered(QAction* action);
164
165 /**
166 * Connected to the "editMimeType" action
167 */
168 void slotEditMimeType();
169
170 /**
171 * Connected to the "properties" action
172 */
173 void slotProperties();
174
175 private:
176 void createActions();
177 void createGoAction(const char* name, const char* iconName,
178 const QString& text, const QString& url,
179 QActionGroup* actionGroup);
180
181 private:
182 DolphinView* m_view;
183 DolphinViewActionHandler* m_actionHandler;
184 KDirLister* m_dirLister;
185 DolphinModel* m_dolphinModel;
186 DolphinSortFilterProxyModel* m_proxyModel;
187 DolphinPartBrowserExtension* m_extension;
188 QString m_nameFilter;
189 Q_DISABLE_COPY(DolphinPart)
190 };
191
192 class DolphinPartBrowserExtension : public KParts::BrowserExtension
193 {
194 Q_OBJECT
195 public:
196 DolphinPartBrowserExtension( DolphinPart* part )
197 : KParts::BrowserExtension( part ), m_part(part) {}
198
199 public Q_SLOTS:
200 void cut();
201 void copy();
202 void paste();
203 void reparseConfiguration();
204
205 private:
206 DolphinPart* m_part;
207 };
208
209 #endif /* DOLPHINPART_H */