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.
20 #include "dolphinpart.h"
21 #include "dolphinremoveaction.h"
23 #include <KFileItemListProperties>
24 #include <konq_operations.h>
27 #include <KActionCollection>
28 #include <KConfigGroup>
30 #include <KGlobalSettings>
31 #include <KIconLoader>
33 #include <KMessageBox>
34 #include <KPluginFactory>
36 #include <KToggleAction>
37 #include <KIO/NetAccess>
38 #include <KToolInvocation>
39 #include <kauthorized.h>
40 #include <KNewFileMenu>
42 #include <KInputDialog>
43 #include <KProtocolInfo>
44 #include <kdeversion.h>
46 #if KDE_IS_VERSION(4, 9, 2)
47 #include "dolphinpart_ext.h"
50 #include "views/dolphinview.h"
51 #include "views/dolphinviewactionhandler.h"
52 #include "views/dolphinnewfilemenuobserver.h"
53 #include "views/dolphinremoteencoding.h"
54 #include "kitemviews/kfileitemmodel.h"
55 #include "kitemviews/private/kfileitemmodeldirlister.h"
57 #include <QActionGroup>
58 #include <QApplication>
62 K_PLUGIN_FACTORY(DolphinPartFactory
, registerPlugin
<DolphinPart
>();)
63 K_EXPORT_PLUGIN(DolphinPartFactory("dolphinpart", "dolphin"))
65 DolphinPart::DolphinPart(QWidget
* parentWidget
, QObject
* parent
, const QVariantList
& args
)
66 : KParts::ReadOnlyPart(parent
)
67 ,m_openTerminalAction(0)
71 setComponentData(DolphinPartFactory::componentData(), false);
72 m_extension
= new DolphinPartBrowserExtension(this);
74 // make sure that other apps using this part find Dolphin's view-file-columns icons
75 KIconLoader::global()->addAppDir("dolphin");
77 m_view
= new DolphinView(KUrl(), parentWidget
);
78 m_view
->setTabsForFilesEnabled(true);
81 connect(m_view
, SIGNAL(directoryLoadingCompleted()), this, SIGNAL(completed()));
82 connect(m_view
, SIGNAL(directoryLoadingProgress(int)), this, SLOT(updateProgress(int)));
83 connect(m_view
, SIGNAL(errorMessage(QString
)), this, SLOT(slotErrorMessage(QString
)));
85 setXMLFile("dolphinpart.rc");
87 connect(m_view
, SIGNAL(infoMessage(QString
)),
88 this, SLOT(slotMessage(QString
)));
89 connect(m_view
, SIGNAL(operationCompletedMessage(QString
)),
90 this, SLOT(slotMessage(QString
)));
91 connect(m_view
, SIGNAL(errorMessage(QString
)),
92 this, SLOT(slotErrorMessage(QString
)));
93 connect(m_view
, SIGNAL(itemActivated(KFileItem
)),
94 this, SLOT(slotItemActivated(KFileItem
)));
95 connect(m_view
, SIGNAL(itemsActivated(KFileItemList
)),
96 this, SLOT(slotItemsActivated(KFileItemList
)));
97 connect(m_view
, SIGNAL(tabRequested(KUrl
)),
98 this, SLOT(createNewWindow(KUrl
)));
99 connect(m_view
, SIGNAL(requestContextMenu(QPoint
,KFileItem
,KUrl
,QList
<QAction
*>)),
100 this, SLOT(slotOpenContextMenu(QPoint
,KFileItem
,KUrl
,QList
<QAction
*>)));
101 connect(m_view
, SIGNAL(selectionChanged(KFileItemList
)),
102 m_extension
, SIGNAL(selectionInfo(KFileItemList
)));
103 connect(m_view
, SIGNAL(selectionChanged(KFileItemList
)),
104 this, SLOT(slotSelectionChanged(KFileItemList
)));
105 connect(m_view
, SIGNAL(requestItemInfo(KFileItem
)),
106 this, SLOT(slotRequestItemInfo(KFileItem
)));
107 connect(m_view
, SIGNAL(modeChanged(DolphinView::Mode
,DolphinView::Mode
)),
108 this, SIGNAL(viewModeChanged())); // relay signal
109 connect(m_view
, SIGNAL(redirection(KUrl
,KUrl
)),
110 this, SLOT(slotDirectoryRedirection(KUrl
,KUrl
)));
112 // Watch for changes that should result in updates to the
114 connect(m_view
, SIGNAL(itemCountChanged()), this, SLOT(updateStatusBar()));
115 connect(m_view
, SIGNAL(selectionChanged(KFileItemList
)), this, SLOT(updateStatusBar()));
117 m_actionHandler
= new DolphinViewActionHandler(actionCollection(), this);
118 m_actionHandler
->setCurrentView(m_view
);
119 connect(m_actionHandler
, SIGNAL(createDirectory()), SLOT(createDirectory()));
121 m_remoteEncoding
= new DolphinRemoteEncoding(this, m_actionHandler
);
122 connect(this, SIGNAL(aboutToOpenURL()),
123 m_remoteEncoding
, SLOT(slotAboutToOpenUrl()));
125 QClipboard
* clipboard
= QApplication::clipboard();
126 connect(clipboard
, SIGNAL(dataChanged()),
127 this, SLOT(updatePasteAction()));
129 // Create file info and listing filter extensions.
130 // NOTE: Listing filter needs to be instantiated after the creation of the view.
131 new DolphinPartFileInfoExtension(this);
133 #if KDE_IS_VERSION(4, 9, 2)
134 new DolphinPartListingFilterExtension(this);
136 KDirLister
* lister
= m_view
->m_model
->m_dirLister
;
138 DolphinPartListingNotificationExtension
* notifyExt
= new DolphinPartListingNotificationExtension(this);
139 connect(lister
, SIGNAL(newItems(KFileItemList
)), notifyExt
, SLOT(slotNewItems(KFileItemList
)));
140 connect(lister
, SIGNAL(itemsDeleted(KFileItemList
)), notifyExt
, SLOT(slotItemsDeleted(KFileItemList
)));
142 kWarning() << "NULL KDirLister object! KParts::ListingNotificationExtension will NOT be supported";
147 m_actionHandler
->updateViewActions();
148 slotSelectionChanged(KFileItemList()); // initially disable selection-dependent actions
150 // Listen to events from the app so we can update the remove key by
151 // checking for a Shift key press.
152 qApp
->installEventFilter(this);
154 // TODO there was a "always open a new window" (when clicking on a directory) setting in konqueror
155 // (sort of spacial navigation)
157 loadPlugins(this, this, componentData());
160 DolphinPart::~DolphinPart()
162 DolphinNewFileMenuObserver::instance().detach(m_newFileMenu
);
165 void DolphinPart::createActions()
169 m_newFileMenu
= new KNewFileMenu(actionCollection(), "new_menu", this);
170 m_newFileMenu
->setParentWidget(widget());
171 DolphinNewFileMenuObserver::instance().attach(m_newFileMenu
);
172 connect(m_newFileMenu
->menu(), SIGNAL(aboutToShow()),
173 this, SLOT(updateNewMenu()));
175 KAction
*editMimeTypeAction
= actionCollection()->addAction( "editMimeType" );
176 editMimeTypeAction
->setText( i18nc("@action:inmenu Edit", "&Edit File Type..." ) );
177 connect(editMimeTypeAction
, SIGNAL(triggered()), SLOT(slotEditMimeType()));
179 KAction
* selectItemsMatching
= actionCollection()->addAction("select_items_matching");
180 selectItemsMatching
->setText(i18nc("@action:inmenu Edit", "Select Items Matching..."));
181 selectItemsMatching
->setShortcut(Qt::CTRL
| Qt::Key_S
);
182 connect(selectItemsMatching
, SIGNAL(triggered()), this, SLOT(slotSelectItemsMatchingPattern()));
184 KAction
* unselectItemsMatching
= actionCollection()->addAction("unselect_items_matching");
185 unselectItemsMatching
->setText(i18nc("@action:inmenu Edit", "Unselect Items Matching..."));
186 connect(unselectItemsMatching
, SIGNAL(triggered()), this, SLOT(slotUnselectItemsMatchingPattern()));
188 actionCollection()->addAction(KStandardAction::SelectAll
, "select_all", m_view
, SLOT(selectAll()));
190 KAction
* unselectAll
= actionCollection()->addAction("unselect_all");
191 unselectAll
->setText(i18nc("@action:inmenu Edit", "Unselect All"));
192 connect(unselectAll
, SIGNAL(triggered()), m_view
, SLOT(clearSelection()));
194 KAction
* invertSelection
= actionCollection()->addAction("invert_selection");
195 invertSelection
->setText(i18nc("@action:inmenu Edit", "Invert Selection"));
196 invertSelection
->setShortcut(Qt::CTRL
| Qt::SHIFT
| Qt::Key_A
);
197 connect(invertSelection
, SIGNAL(triggered()), m_view
, SLOT(invertSelection()));
199 // View menu: all done by DolphinViewActionHandler
203 QActionGroup
* goActionGroup
= new QActionGroup(this);
204 connect(goActionGroup
, SIGNAL(triggered(QAction
*)),
205 this, SLOT(slotGoTriggered(QAction
*)));
207 createGoAction("go_applications", "start-here-kde",
208 i18nc("@action:inmenu Go", "App&lications"), QString("programs:/"),
210 createGoAction("go_network_folders", "folder-remote",
211 i18nc("@action:inmenu Go", "&Network Folders"), QString("remote:/"),
213 createGoAction("go_settings", "preferences-system",
214 i18nc("@action:inmenu Go", "Sett&ings"), QString("settings:/"),
216 createGoAction("go_trash", "user-trash",
217 i18nc("@action:inmenu Go", "Trash"), QString("trash:/"),
219 createGoAction("go_autostart", "",
220 i18nc("@action:inmenu Go", "Autostart"), KGlobalSettings::autostartPath(),
224 m_findFileAction
= actionCollection()->addAction("find_file");
225 m_findFileAction
->setText(i18nc("@action:inmenu Tools", "Find File..."));
226 m_findFileAction
->setShortcut(Qt::CTRL
| Qt::Key_F
);
227 m_findFileAction
->setIcon(KIcon("edit-find"));
228 connect(m_findFileAction
, SIGNAL(triggered()), this, SLOT(slotFindFile()));
230 if (KAuthorized::authorizeKAction("shell_access")) {
231 m_openTerminalAction
= actionCollection()->addAction("open_terminal");
232 m_openTerminalAction
->setIcon(KIcon("utilities-terminal"));
233 m_openTerminalAction
->setText(i18nc("@action:inmenu Tools", "Open &Terminal"));
234 connect(m_openTerminalAction
, SIGNAL(triggered()), SLOT(slotOpenTerminal()));
235 m_openTerminalAction
->setShortcut(Qt::Key_F4
);
239 void DolphinPart::createGoAction(const char* name
, const char* iconName
,
240 const QString
& text
, const QString
& url
,
241 QActionGroup
* actionGroup
)
243 KAction
* action
= actionCollection()->addAction(name
);
244 action
->setIcon(KIcon(iconName
));
245 action
->setText(text
);
246 action
->setData(url
);
247 action
->setActionGroup(actionGroup
);
250 void DolphinPart::slotGoTriggered(QAction
* action
)
252 const QString url
= action
->data().toString();
253 emit m_extension
->openUrlRequest(KUrl(url
));
256 void DolphinPart::slotSelectionChanged(const KFileItemList
& selection
)
258 const bool hasSelection
= !selection
.isEmpty();
260 QAction
* renameAction
= actionCollection()->action("rename");
261 QAction
* moveToTrashAction
= actionCollection()->action("move_to_trash");
262 QAction
* deleteAction
= actionCollection()->action("delete");
263 QAction
* editMimeTypeAction
= actionCollection()->action("editMimeType");
264 QAction
* propertiesAction
= actionCollection()->action("properties");
265 QAction
* deleteWithTrashShortcut
= actionCollection()->action("delete_shortcut"); // see DolphinViewActionHandler
268 stateChanged("has_no_selection");
270 emit m_extension
->enableAction("cut", false);
271 emit m_extension
->enableAction("copy", false);
272 deleteWithTrashShortcut
->setEnabled(false);
273 editMimeTypeAction
->setEnabled(false);
275 stateChanged("has_selection");
277 // TODO share this code with DolphinMainWindow::updateEditActions (and the desktop code)
279 KFileItemListProperties
capabilities(selection
);
280 const bool enableMoveToTrash
= capabilities
.isLocal() && capabilities
.supportsMoving();
282 renameAction
->setEnabled(capabilities
.supportsMoving());
283 moveToTrashAction
->setEnabled(enableMoveToTrash
);
284 deleteAction
->setEnabled(capabilities
.supportsDeleting());
285 deleteWithTrashShortcut
->setEnabled(capabilities
.supportsDeleting() && !enableMoveToTrash
);
286 editMimeTypeAction
->setEnabled(true);
287 propertiesAction
->setEnabled(true);
288 emit m_extension
->enableAction("cut", capabilities
.supportsMoving());
289 emit m_extension
->enableAction("copy", true);
293 void DolphinPart::updatePasteAction()
295 QPair
<bool, QString
> pasteInfo
= m_view
->pasteInfo();
296 emit m_extension
->enableAction( "paste", pasteInfo
.first
);
297 emit m_extension
->setActionText( "paste", pasteInfo
.second
);
300 KAboutData
* DolphinPart::createAboutData()
302 return new KAboutData("dolphinpart", "dolphin", ki18nc("@title", "Dolphin Part"), "0.1");
305 bool DolphinPart::openUrl(const KUrl
& url
)
307 bool reload
= arguments().reload();
308 // A bit of a workaround so that changing the namefilter works: force reload.
309 // Otherwise DolphinView wouldn't relist the URL, so nothing would happen.
310 if (m_nameFilter
!= m_view
->nameFilter())
312 if (m_view
->url() == url
&& !reload
) { // DolphinView won't do anything in that case, so don't emit started
315 setUrl(url
); // remember it at the KParts level
316 KUrl
visibleUrl(url
);
317 if (!m_nameFilter
.isEmpty()) {
318 visibleUrl
.addPath(m_nameFilter
);
320 QString prettyUrl
= visibleUrl
.pathOrUrl();
321 emit
setWindowCaption(prettyUrl
);
322 emit m_extension
->setLocationBarUrl(prettyUrl
);
323 emit
started(0); // get the wheel to spin
324 m_view
->setNameFilter(m_nameFilter
);
327 emit
aboutToOpenURL();
330 // Disable "Find File" and "Open Terminal" actions for non-file URLs,
331 // e.g. ftp, smb, etc. #279283
332 const bool isLocalUrl
= url
.isLocalFile();
333 m_findFileAction
->setEnabled(isLocalUrl
);
334 if (m_openTerminalAction
) {
335 m_openTerminalAction
->setEnabled(isLocalUrl
);
340 void DolphinPart::slotMessage(const QString
& msg
)
342 emit
setStatusBarText(msg
);
345 void DolphinPart::slotErrorMessage(const QString
& msg
)
349 //KMessageBox::error(m_view, msg);
352 void DolphinPart::slotRequestItemInfo(const KFileItem
& item
)
354 emit m_extension
->mouseOverInfo(item
);
358 ReadOnlyPart::setStatusBarText(item
.getStatusBarInfo());
362 void DolphinPart::slotItemActivated(const KFileItem
& item
)
364 KParts::OpenUrlArguments args
;
365 // Forget about the known mimetype if a target URL is used.
366 // Testcase: network:/ with a item (mimetype "inode/some-foo-service") pointing to a http URL (html)
367 if (item
.targetUrl() == item
.url()) {
368 args
.setMimeType(item
.mimetype());
371 // Ideally, konqueror should be changed to not require trustedSource for directory views,
372 // since the idea was not to need BrowserArguments for non-browser stuff...
373 KParts::BrowserArguments browserArgs
;
374 browserArgs
.trustedSource
= true;
375 emit m_extension
->openUrlRequest(item
.targetUrl(), args
, browserArgs
);
378 void DolphinPart::slotItemsActivated(const KFileItemList
& items
)
380 foreach (const KFileItem
& item
, items
) {
381 slotItemActivated(item
);
385 void DolphinPart::createNewWindow(const KUrl
& url
)
387 // TODO: Check issue N176832 for the missing QAIV signal; task 177399 - maybe this code
388 // should be moved into DolphinPart::slotItemActivated()
389 emit m_extension
->createNewWindow(url
);
392 void DolphinPart::slotOpenContextMenu(const QPoint
& pos
,
393 const KFileItem
& _item
,
395 const QList
<QAction
*>& customActions
)
397 KParts::BrowserExtension::PopupFlags popupFlags
= KParts::BrowserExtension::DefaultPopupItems
398 | KParts::BrowserExtension::ShowProperties
399 | KParts::BrowserExtension::ShowUrlOperations
;
401 KFileItem
item(_item
);
403 if (item
.isNull()) { // viewport context menu
404 popupFlags
|= KParts::BrowserExtension::ShowNavigationItems
| KParts::BrowserExtension::ShowUp
;
405 item
= m_view
->rootItem();
407 item
= KFileItem( S_IFDIR
, (mode_t
)-1, url() );
409 item
.setUrl(url()); // ensure we use the view url, not the canonical path (#213799)
412 // TODO: We should change the signature of the slots (and signals) for being able
413 // to tell for which items we want a popup.
415 if (m_view
->selectedItems().isEmpty()) {
418 items
= m_view
->selectedItems();
421 KFileItemListProperties
capabilities(items
);
423 KParts::BrowserExtension::ActionGroupMap actionGroups
;
424 QList
<QAction
*> editActions
;
425 editActions
+= m_view
->versionControlActions(m_view
->selectedItems());
426 editActions
+= customActions
;
428 if (!_item
.isNull()) { // only for context menu on one or more items
429 bool supportsDeleting
= capabilities
.supportsDeleting();
430 bool supportsMoving
= capabilities
.supportsMoving();
432 if (!supportsDeleting
) {
433 popupFlags
|= KParts::BrowserExtension::NoDeletion
;
436 if (supportsMoving
) {
437 editActions
.append(actionCollection()->action("rename"));
440 bool addTrash
= capabilities
.isLocal() && supportsMoving
;
442 if (supportsDeleting
) {
443 if ( !item
.isLocalFile() )
445 else if (QApplication::keyboardModifiers() & Qt::ShiftModifier
) {
450 KSharedConfig::Ptr globalConfig
= KSharedConfig::openConfig("kdeglobals", KConfig::IncludeGlobals
);
451 KConfigGroup
configGroup(globalConfig
, "KDE");
452 addDel
= configGroup
.readEntry("ShowDeleteCommand", false);
456 if (!addTrash
|| !addDel
) {
457 if (!m_removeAction
) {
458 m_removeAction
= new DolphinRemoveAction(this, actionCollection());
460 editActions
.append(m_removeAction
);
461 m_removeAction
->update();
463 delete m_removeAction
;
465 editActions
.append(actionCollection()->action("move_to_trash"));
466 editActions
.append(actionCollection()->action("delete"));
469 // Normally KonqPopupMenu only shows the "Create new" submenu in the current view
470 // since otherwise the created file would not be visible.
471 // But in treeview mode we should allow it.
472 if (m_view
->itemsExpandable())
473 popupFlags
|= KParts::BrowserExtension::ShowCreateDirectory
;
477 actionGroups
.insert("editactions", editActions
);
479 emit m_extension
->popupMenu(pos
,
481 KParts::OpenUrlArguments(),
482 KParts::BrowserArguments(),
487 void DolphinPart::slotDirectoryRedirection(const KUrl
& oldUrl
, const KUrl
& newUrl
)
489 //kDebug() << oldUrl << newUrl << "currentUrl=" << url();
490 if (oldUrl
.equals(url(), KUrl::CompareWithoutTrailingSlash
/* #207572 */)) {
491 KParts::ReadOnlyPart::setUrl(newUrl
);
492 const QString prettyUrl
= newUrl
.pathOrUrl();
493 emit m_extension
->setLocationBarUrl(prettyUrl
);
498 void DolphinPart::slotEditMimeType()
500 const KFileItemList items
= m_view
->selectedItems();
501 if (!items
.isEmpty()) {
502 KonqOperations::editMimeType(items
.first().mimetype(), m_view
);
506 void DolphinPart::slotSelectItemsMatchingPattern()
508 openSelectionDialog(i18nc("@title:window", "Select"),
509 i18n("Select all items matching this pattern:"),
513 void DolphinPart::slotUnselectItemsMatchingPattern()
515 openSelectionDialog(i18nc("@title:window", "Unselect"),
516 i18n("Unselect all items matching this pattern:"),
520 void DolphinPart::openSelectionDialog(const QString
& title
, const QString
& text
, bool selectItems
)
523 QString pattern
= KInputDialog::getText(title
, text
, "*", &okClicked
, m_view
);
525 if (okClicked
&& !pattern
.isEmpty()) {
526 QRegExp
patternRegExp(pattern
, Qt::CaseSensitive
, QRegExp::Wildcard
);
527 m_view
->selectItems(patternRegExp
, selectItems
);
531 void DolphinPart::setCurrentViewMode(const QString
& viewModeName
)
533 QAction
* action
= actionCollection()->action(viewModeName
);
538 QString
DolphinPart::currentViewMode() const
540 return m_actionHandler
->currentViewModeActionName();
543 void DolphinPart::setNameFilter(const QString
& nameFilter
)
545 // This is the "/home/dfaure/*.diff" kind of name filter (KDirLister::setNameFilter)
546 // which is unrelated to DolphinView::setNameFilter which is substring filtering in a proxy.
547 m_nameFilter
= nameFilter
;
548 // TODO save/restore name filter in saveState/restoreState like KonqDirPart did in kde3?
551 void DolphinPart::slotOpenTerminal()
553 QString
dir(QDir::homePath());
557 // If the given directory is not local, it can still be the URL of an
558 // ioslave using UDS_LOCAL_PATH which to be converted first.
559 u
= KIO::NetAccess::mostLocalUrl(u
, widget());
561 //If the URL is local after the above conversion, set the directory.
562 if (u
.isLocalFile()) {
563 dir
= u
.toLocalFile();
566 KToolInvocation::invokeTerminal(QString(), dir
);
569 void DolphinPart::slotFindFile()
571 KRun::run("kfind", url(), widget());
574 void DolphinPart::updateNewMenu()
576 // As requested by KNewFileMenu :
577 m_newFileMenu
->checkUpToDate();
578 m_newFileMenu
->setViewShowsHiddenFiles(m_view
->hiddenFilesShown());
579 // And set the files that the menu apply on :
580 m_newFileMenu
->setPopupFiles(url());
583 void DolphinPart::updateStatusBar()
585 emit
ReadOnlyPart::setStatusBarText(m_view
->statusBarText());
588 void DolphinPart::updateProgress(int percent
)
590 m_extension
->loadingProgress(percent
);
593 void DolphinPart::createDirectory()
595 m_newFileMenu
->setViewShowsHiddenFiles(m_view
->hiddenFilesShown());
596 m_newFileMenu
->setPopupFiles(url());
597 m_newFileMenu
->createDirectory();
600 void DolphinPart::setFilesToSelect(const KUrl::List
& files
)
602 if (files
.isEmpty()) {
606 m_view
->markUrlsAsSelected(files
);
607 m_view
->markUrlAsCurrent(files
.at(0));
610 bool DolphinPart::eventFilter(QObject
* obj
, QEvent
* event
)
612 const int type
= event
->type();
614 if ((type
== QEvent::KeyPress
|| type
== QEvent::KeyRelease
) && m_removeAction
) {
615 QMenu
* menu
= qobject_cast
<QMenu
*>(obj
);
616 if (menu
&& menu
->parent() == m_view
) {
617 QKeyEvent
* ev
= static_cast<QKeyEvent
*>(event
);
618 if (ev
->key() == Qt::Key_Shift
) {
619 m_removeAction
->update();
624 return KParts::ReadOnlyPart::eventFilter(obj
, event
);
629 void DolphinPartBrowserExtension::restoreState(QDataStream
&stream
)
631 KParts::BrowserExtension::restoreState(stream
);
632 m_part
->view()->restoreState(stream
);
635 void DolphinPartBrowserExtension::saveState(QDataStream
&stream
)
637 KParts::BrowserExtension::saveState(stream
);
638 m_part
->view()->saveState(stream
);
641 void DolphinPartBrowserExtension::cut()
643 m_part
->view()->cutSelectedItems();
646 void DolphinPartBrowserExtension::copy()
648 m_part
->view()->copySelectedItems();
651 void DolphinPartBrowserExtension::paste()
653 m_part
->view()->paste();
656 void DolphinPartBrowserExtension::pasteTo(const KUrl
&)
658 m_part
->view()->pasteIntoFolder();
661 void DolphinPartBrowserExtension::reparseConfiguration()
663 m_part
->view()->readSettings();
668 DolphinPartFileInfoExtension::DolphinPartFileInfoExtension(DolphinPart
* part
)
669 : KParts::FileInfoExtension(part
)
673 DolphinPart
* DolphinPartFileInfoExtension::part() const
675 return static_cast<DolphinPart
*>(parent());
678 bool DolphinPartFileInfoExtension::hasSelection() const
680 return part()->view()->selectedItemsCount() > 0;
683 KParts::FileInfoExtension::QueryModes
DolphinPartFileInfoExtension::supportedQueryModes() const
685 return (KParts::FileInfoExtension::AllItems
| KParts::FileInfoExtension::SelectedItems
);
688 KFileItemList
DolphinPartFileInfoExtension::queryFor(KParts::FileInfoExtension::QueryMode mode
) const
692 if (mode
== KParts::FileInfoExtension::None
)
695 if (!(supportedQueryModes() & mode
))
699 case KParts::FileInfoExtension::SelectedItems
:
701 return part()->view()->selectedItems();
703 case KParts::FileInfoExtension::AllItems
:
704 return part()->view()->items();
712 #include "dolphinpart.moc"