]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinpart.h
assure that the Dolphin KPart inside Konqueror gets updated when the settings are...
[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 public:
49 explicit DolphinPart(QWidget* parentWidget, QObject* parent, const QStringList& args);
50 ~DolphinPart();
51
52 static KAboutData* createAboutData();
53
54 /**
55 * Standard KParts::ReadOnlyPart openUrl method.
56 * Called by Konqueror to view a directory in DolphinPart.
57 */
58 virtual bool openUrl(const KUrl& url);
59
60 /// see the supportsUndo property
61 bool supportsUndo() const { return true; }
62
63 /**
64 * Used by konqueror for setting the view mode
65 * @param viewModeName internal name for the view mode, like "icons"
66 * Those names come from the Actions line in dolphinpart.desktop,
67 * and have to match the name of the KActions.
68 */
69 void setCurrentViewMode(const QString& viewModeName);
70
71 /**
72 * Used by konqueror for displaying the current view mode.
73 * @see setCurrentViewMode
74 */
75 QString currentViewMode() const;
76
77 /// Returns the view owned by this part; used by DolphinPartBrowserExtension
78 DolphinView* view() { return m_view; }
79
80 protected:
81 /**
82 * We reimplement openUrl so no need to implement openFile.
83 */
84 virtual bool openFile() { return true; }
85
86 Q_SIGNALS:
87 /**
88 * Emitted when the view mode changes. Used by konqueror.
89 */
90 void viewModeChanged();
91
92 private Q_SLOTS:
93 void slotCompleted(const KUrl& url);
94 void slotCanceled(const KUrl& url);
95 void slotInfoMessage(const QString& msg);
96 void slotErrorMessage(const QString& msg);
97 /**
98 * Shows the information for the item \a item inside the statusbar. If the
99 * item is null, the default statusbar information is shown.
100 */
101 void slotRequestItemInfo(const KFileItem& item);
102 /**
103 * Handles clicking on an item
104 */
105 void slotItemTriggered(const KFileItem& item);
106 /**
107 * Opens the context menu on the current mouse position.
108 * @item File item context. If item is 0, the context menu
109 * should be applied to \a url.
110 * @url URL which contains \a item.
111 */
112 void slotOpenContextMenu(const KFileItem& item, const KUrl& url);
113
114 /**
115 * Asks the host to open the URL \a url if the current view has
116 * a different URL.
117 */
118 void slotUrlChanged(const KUrl& url);
119
120 /**
121 * Updates the state of the 'Edit' menu actions and emits
122 * the signal selectionChanged().
123 */
124 void slotSelectionChanged(const KFileItemList& selection);
125
126 /**
127 * Updates the text of the paste action dependent from
128 * the number of items which are in the clipboard.
129 */
130 void updatePasteAction();
131
132 /**
133 * Connected to all "Go" menu actions provided by DolphinPart
134 */
135 void slotGoTriggered(QAction* action);
136
137 /**
138 * Connected to the "editMimeType" action
139 */
140 void slotEditMimeType();
141
142 /**
143 * Connected to the "properties" action
144 */
145 void slotProperties();
146
147 private:
148 void createActions();
149 void createGoAction(const char* name, const char* iconName,
150 const QString& text, const QString& url,
151 QActionGroup* actionGroup);
152
153 private:
154 DolphinView* m_view;
155 DolphinViewActionHandler* m_actionHandler;
156 KDirLister* m_dirLister;
157 DolphinModel* m_dolphinModel;
158 DolphinSortFilterProxyModel* m_proxyModel;
159 DolphinPartBrowserExtension* m_extension;
160 Q_DISABLE_COPY(DolphinPart)
161 };
162
163 class DolphinPartBrowserExtension : public KParts::BrowserExtension
164 {
165 Q_OBJECT
166 public:
167 DolphinPartBrowserExtension( DolphinPart* part )
168 : KParts::BrowserExtension( part ), m_part(part) {}
169
170 public Q_SLOTS:
171 void cut();
172 void copy();
173 void paste();
174 void reparseConfiguration();
175
176 private:
177 DolphinPart* m_part;
178 };
179
180 #endif /* DOLPHINPART_H */