]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinpart.h
Make sort/descending available 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 QActionGroup;
26 class KAction;
27 class KFileItemList;
28 class KFileItem;
29 class DolphinPartBrowserExtension;
30 class DolphinSortFilterProxyModel;
31 class DolphinModel;
32 class KDirLister;
33 class DolphinView;
34 class QLineEdit;
35 class KAboutData;
36
37 class DolphinPart : public KParts::ReadOnlyPart
38 {
39 Q_OBJECT
40 // Used by konqueror. Technically it means "we want undo enabled if
41 // there are things in the undo history and the current part is a dolphin part".
42 // Even though it's konqueror doing the undo...
43 Q_PROPERTY( bool supportsUndo READ supportsUndo )
44
45 public:
46 explicit DolphinPart(QWidget* parentWidget, QObject* parent, const QStringList& args);
47 ~DolphinPart();
48
49 static KAboutData* createAboutData();
50
51 virtual bool openUrl(const KUrl& url);
52
53 /// see the supportsUndo property
54 bool supportsUndo() const { return true; }
55
56 DolphinView* view() { return m_view; }
57
58 protected:
59 /**
60 * We reimplement openUrl so no need to implement openFile.
61 */
62 virtual bool openFile() { return true; }
63
64 private Q_SLOTS:
65 void slotCompleted(const KUrl& url);
66 void slotCanceled(const KUrl& url);
67 void slotInfoMessage(const QString& msg);
68 void slotErrorMessage(const QString& msg);
69 /**
70 * Shows the information for the item \a item inside the statusbar. If the
71 * item is null, the default statusbar information is shown.
72 */
73 void slotRequestItemInfo(const KFileItem& item);
74 /**
75 * Handles clicking on an item
76 */
77 void slotItemTriggered(const KFileItem& item);
78 /**
79 * Opens the context menu on the current mouse position.
80 * @item File item context. If item is 0, the context menu
81 * should be applied to \a url.
82 * @url URL which contains \a item.
83 */
84 void slotOpenContextMenu(const KFileItem& item, const KUrl& url);
85 /**
86 * Emitted when the user requested a change of view mode
87 */
88 void slotViewModeActionTriggered(QAction*);
89
90 /**
91 * Asks the host to open the URL \a url if the current view has
92 * a different URL.
93 */
94 void slotUrlChanged(const KUrl& url);
95
96 /**
97 * Updates the state of the 'Edit' menu actions and emits
98 * the signal selectionChanged().
99 */
100 void slotSelectionChanged(const KFileItemList& selection);
101
102 /**
103 * Same as in DolphinMainWindow: updates the view menu actions
104 */
105 void updateViewActions();
106
107 /**
108 * Updates the text of the paste action dependent from
109 * the number of items which are in the clipboard.
110 */
111 void updatePasteAction();
112
113 /**
114 * Connected to the "move_to_trash" action; adds "shift means del" handling.
115 */
116 void slotTrashActivated(Qt::MouseButtons, Qt::KeyboardModifiers);
117
118 /**
119 * Connected to all "Go" menu actions provided by DolphinPart
120 */
121 void slotGoTriggered(QAction* action);
122
123 /**
124 * Connected to the "editMimeType" action
125 */
126 void slotEditMimeType();
127
128 /**
129 * Connected to the "properties" action
130 */
131 void slotProperties();
132
133 /**
134 * Opens the dialog for creating a directory. Is connected
135 * with the key shortcut for "new directory" (F10).
136 */
137 void createDir();
138
139 /** Updates the state of the 'Sort Ascending/Descending' action. */
140 void slotSortOrderChanged(Qt::SortOrder);
141
142 private:
143 void createActions();
144 void createGoAction(const char* name, const char* iconName,
145 const QString& text, const QString& url,
146 QActionGroup* actionGroup);
147
148 private:
149 DolphinView* m_view;
150 KDirLister* m_dirLister;
151 DolphinModel* m_dolphinModel;
152 DolphinSortFilterProxyModel* m_proxyModel;
153 DolphinPartBrowserExtension* m_extension;
154 Q_DISABLE_COPY(DolphinPart)
155 };
156
157 class DolphinPartBrowserExtension : public KParts::BrowserExtension
158 {
159 Q_OBJECT
160 public:
161 DolphinPartBrowserExtension( DolphinPart* part )
162 : KParts::BrowserExtension( part ), m_part(part) {}
163
164 public Q_SLOTS:
165 void cut();
166 void copy();
167 void paste();
168
169 private:
170 DolphinPart* m_part;
171 };
172
173 #endif /* DOLPHINPART_H */