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