1 /* This file is part of the KDE project
2 Copyright (c) 2007 David Faure <faure@kde.org>
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.
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.
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.
23 #include <kparts/part.h>
24 #include <kparts/browserextension.h>
26 class DolphinViewActionHandler
;
31 class DolphinPartBrowserExtension
;
32 class DolphinSortFilterProxyModel
;
39 class DolphinPart
: public KParts::ReadOnlyPart
42 // Used by konqueror. Technically it means "we want undo enabled if
43 // there are things in the undo history and the current part is a dolphin part".
44 // Even though it's konqueror doing the undo...
45 Q_PROPERTY( bool supportsUndo READ supportsUndo
)
47 Q_PROPERTY( QString currentViewMode READ currentViewMode WRITE setCurrentViewMode
)
49 // Used by konqueror when typing something like /home/dfaure/*.diff in the location bar
50 Q_PROPERTY( QString nameFilter READ nameFilter WRITE setNameFilter
)
53 explicit DolphinPart(QWidget
* parentWidget
, QObject
* parent
, const QVariantList
& args
);
56 static KAboutData
* createAboutData();
59 * Standard KParts::ReadOnlyPart openUrl method.
60 * Called by Konqueror to view a directory in DolphinPart.
62 virtual bool openUrl(const KUrl
& url
);
64 /// see the supportsUndo property
65 bool supportsUndo() const { return true; }
68 * Used by konqueror for setting the view mode
69 * @param viewModeName internal name for the view mode, like "icons"
70 * Those names come from the Actions line in dolphinpart.desktop,
71 * and have to match the name of the KActions.
73 void setCurrentViewMode(const QString
& viewModeName
);
76 * Used by konqueror for displaying the current view mode.
77 * @see setCurrentViewMode
79 QString
currentViewMode() const;
81 /// Returns the view owned by this part; used by DolphinPartBrowserExtension
82 DolphinView
* view() { return m_view
; }
85 * Sets a name filter, like *.diff
87 void setNameFilter(const QString
& nameFilter
);
90 * Returns the current name filter. Used by konqueror to show it in the URL.
92 QString
nameFilter() const { return m_nameFilter
; }
96 * We reimplement openUrl so no need to implement openFile.
98 virtual bool openFile() { return true; }
102 * Emitted when the view mode changes. Used by konqueror.
104 void viewModeChanged();
108 * Emitted whenever the current URL is about to be changed.
110 void aboutToOpenURL();
113 void slotCompleted(const KUrl
& url
);
114 void slotCanceled(const KUrl
& url
);
115 void slotInfoMessage(const QString
& msg
);
116 void slotErrorMessage(const QString
& msg
);
118 * Shows the information for the item \a item inside the statusbar. If the
119 * item is null, the default statusbar information is shown.
121 void slotRequestItemInfo(const KFileItem
& item
);
123 * Handles clicking on an item
125 void slotItemTriggered(const KFileItem
& item
);
127 * Creates a new window showing the content of \a url.
129 void createNewWindow(const KUrl
& url
);
131 * Opens the context menu on the current mouse position.
132 * @item File item context. If item is 0, the context menu
133 * should be applied to \a url.
134 * @url URL which contains \a item.
136 void slotOpenContextMenu(const KFileItem
& item
, const KUrl
& url
);
139 * Asks the host to open the URL \a url if the current view has
142 void slotRequestUrlChange(const KUrl
& url
);
145 * Informs the host that we are opening \a url (e.g. after a redirection
146 * coming from KDirLister).
147 * Testcase 1: fish://localhost
148 * Testcase 2: showing a directory that is being renamed by another window (#180156)
150 void slotRedirection(const KUrl
& oldUrl
, const KUrl
& newUrl
);
153 * Updates the state of the 'Edit' menu actions and emits
154 * the signal selectionChanged().
156 void slotSelectionChanged(const KFileItemList
& selection
);
159 * Updates the text of the paste action dependent from
160 * the number of items which are in the clipboard.
162 void updatePasteAction();
165 * Connected to all "Go" menu actions provided by DolphinPart
167 void slotGoTriggered(QAction
* action
);
170 * Connected to the "editMimeType" action
172 void slotEditMimeType();
175 * Open a terminal window, starting with the current directory.
177 void slotOpenTerminal();
180 * Updates the 'Create New...' sub menu, just before it's shown.
182 void updateNewMenu();
185 * Updates the number of items (= number of files + number of
186 * directories) in the statusbar. If files are selected, the number
187 * of selected files and the sum of the filesize is shown.
189 void updateStatusBar();
192 * Notify container of folder loading progress.
194 void updateProgress(int percent
);
197 void createActions();
198 void createGoAction(const char* name
, const char* iconName
,
199 const QString
& text
, const QString
& url
,
200 QActionGroup
* actionGroup
);
204 DolphinViewActionHandler
* m_actionHandler
;
205 KDirLister
* m_dirLister
;
206 DolphinModel
* m_dolphinModel
;
207 DolphinSortFilterProxyModel
* m_proxyModel
;
208 DolphinPartBrowserExtension
* m_extension
;
210 QString m_nameFilter
;
211 Q_DISABLE_COPY(DolphinPart
)
214 class DolphinPartBrowserExtension
: public KParts::BrowserExtension
218 DolphinPartBrowserExtension( DolphinPart
* part
)
219 : KParts::BrowserExtension( part
), m_part(part
) {}
225 void reparseConfiguration();
231 #endif /* DOLPHINPART_H */