]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinpart.h
Implement cut/copy/paste in dolphinpart.
[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 KFileItemList;
26 class KFileItem;
27 class DolphinPartBrowserExtension;
28 class DolphinSortFilterProxyModel;
29 class DolphinModel;
30 class KDirLister;
31 class DolphinView;
32 class QLineEdit;
33 class KAboutData;
34
35 class DolphinPart : public KParts::ReadOnlyPart
36 {
37 Q_OBJECT
38 // Used by konqueror. Technically it means "we want undo enabled if
39 // there are things in the undo history and the current part is a dolphin part".
40 // Even though it's konqueror doing the undo...
41 Q_PROPERTY( bool supportsUndo READ supportsUndo )
42
43 public:
44 explicit DolphinPart(QWidget* parentWidget, QObject* parent, const QStringList& args);
45 ~DolphinPart();
46
47 static KAboutData* createAboutData();
48
49 virtual bool openUrl(const KUrl& url);
50
51 /// see the supportsUndo property
52 bool supportsUndo() const { return true; }
53
54 DolphinView* view() { return m_view; }
55
56 protected:
57 /**
58 * We reimplement openUrl so no need to implement openFile.
59 */
60 virtual bool openFile() { return true; }
61
62 private Q_SLOTS:
63 void slotCompleted(const KUrl& url);
64 void slotCanceled(const KUrl& url);
65 void slotInfoMessage(const QString& msg);
66 void slotErrorMessage(const QString& msg);
67 /**
68 * Shows the information for the item \a item inside the statusbar. If the
69 * item is null, the default statusbar information is shown.
70 */
71 void slotRequestItemInfo(const KFileItem& item);
72 /**
73 * Handles clicking on an item
74 */
75 void slotItemTriggered(const KFileItem& item);
76 /**
77 * Opens the context menu on the current mouse position.
78 * @item File item context. If item is 0, the context menu
79 * should be applied to \a url.
80 * @url URL which contains \a item.
81 */
82 void slotOpenContextMenu(const KFileItem& item, const KUrl& url);
83 /**
84 * Emitted when the user requested a change of view mode
85 */
86 void slotViewModeActionTriggered(QAction*);
87
88 /**
89 * Asks the host to open the URL \a url if the current view has
90 * a different URL.
91 */
92 void slotUrlChanged(const KUrl& url);
93
94 /**
95 * Updates the state of the 'Edit' menu actions and emits
96 * the signal selectionChanged().
97 */
98 void slotSelectionChanged(const KFileItemList& selection);
99
100 /**
101 * Same as in DolphinMainWindow: updates the view menu actions
102 */
103 void updateViewActions();
104
105 /**
106 * Updates the text of the paste action dependent from
107 * the number of items which are in the clipboard.
108 */
109 void updatePasteAction();
110
111 private:
112 void createActions();
113
114 private:
115 DolphinView* m_view;
116 KDirLister* m_dirLister;
117 DolphinModel* m_dolphinModel;
118 DolphinSortFilterProxyModel* m_proxyModel;
119 DolphinPartBrowserExtension* m_extension;
120 Q_DISABLE_COPY(DolphinPart)
121 };
122
123 class DolphinPartBrowserExtension : public KParts::BrowserExtension
124 {
125 Q_OBJECT
126 public:
127 DolphinPartBrowserExtension( DolphinPart* part )
128 : KParts::BrowserExtension( part ), m_part(part) {}
129
130 public Q_SLOTS:
131 void cut();
132 void copy();
133 void paste();
134
135 private:
136 DolphinPart* m_part;
137 };
138
139 #endif /* DOLPHINPART_H */