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>
61 #include <QTextDocument>
63 K_PLUGIN_FACTORY(DolphinPartFactory
, registerPlugin
<DolphinPart
>();)
64 K_EXPORT_PLUGIN(DolphinPartFactory("dolphinpart", "dolphin"))
66 DolphinPart::DolphinPart(QWidget
* parentWidget
, QObject
* parent
, const QVariantList
& args
)
67 : KParts::ReadOnlyPart(parent
)
68 ,m_openTerminalAction(0)
72 setComponentData(DolphinPartFactory::componentData(), false);
73 m_extension
= new DolphinPartBrowserExtension(this);
75 // make sure that other apps using this part find Dolphin's view-file-columns icons
76 KIconLoader::global()->addAppDir("dolphin");
78 m_view
= new DolphinView(KUrl(), parentWidget
);
79 m_view
->setTabsForFilesEnabled(true);
82 connect(m_view
, SIGNAL(directoryLoadingCompleted()), this, SIGNAL(completed()));
83 connect(m_view
, SIGNAL(directoryLoadingProgress(int)), this, SLOT(updateProgress(int)));
84 connect(m_view
, SIGNAL(errorMessage(QString
)), this, SLOT(slotErrorMessage(QString
)));
86 setXMLFile("dolphinpart.rc");
88 connect(m_view
, SIGNAL(infoMessage(QString
)),
89 this, SLOT(slotMessage(QString
)));
90 connect(m_view
, SIGNAL(operationCompletedMessage(QString
)),
91 this, SLOT(slotMessage(QString
)));
92 connect(m_view
, SIGNAL(errorMessage(QString
)),
93 this, SLOT(slotErrorMessage(QString
)));
94 connect(m_view
, SIGNAL(itemActivated(KFileItem
)),
95 this, SLOT(slotItemActivated(KFileItem
)));
96 connect(m_view
, SIGNAL(itemsActivated(KFileItemList
)),
97 this, SLOT(slotItemsActivated(KFileItemList
)));
98 connect(m_view
, SIGNAL(tabRequested(KUrl
)),
99 this, SLOT(createNewWindow(KUrl
)));
100 connect(m_view
, SIGNAL(requestContextMenu(QPoint
,KFileItem
,KUrl
,QList
<QAction
*>)),
101 this, SLOT(slotOpenContextMenu(QPoint
,KFileItem
,KUrl
,QList
<QAction
*>)));
102 connect(m_view
, SIGNAL(selectionChanged(KFileItemList
)),
103 m_extension
, SIGNAL(selectionInfo(KFileItemList
)));
104 connect(m_view
, SIGNAL(selectionChanged(KFileItemList
)),
105 this, SLOT(slotSelectionChanged(KFileItemList
)));
106 connect(m_view
, SIGNAL(requestItemInfo(KFileItem
)),
107 this, SLOT(slotRequestItemInfo(KFileItem
)));
108 connect(m_view
, SIGNAL(modeChanged(DolphinView::Mode
,DolphinView::Mode
)),
109 this, SIGNAL(viewModeChanged())); // relay signal
110 connect(m_view
, SIGNAL(redirection(KUrl
,KUrl
)),
111 this, SLOT(slotDirectoryRedirection(KUrl
,KUrl
)));
113 // Watch for changes that should result in updates to the
115 connect(m_view
, SIGNAL(itemCountChanged()), this, SLOT(updateStatusBar()));
116 connect(m_view
, SIGNAL(selectionChanged(KFileItemList
)), this, SLOT(updateStatusBar()));
118 m_actionHandler
= new DolphinViewActionHandler(actionCollection(), this);
119 m_actionHandler
->setCurrentView(m_view
);
120 connect(m_actionHandler
, SIGNAL(createDirectory()), SLOT(createDirectory()));
122 m_remoteEncoding
= new DolphinRemoteEncoding(this, m_actionHandler
);
123 connect(this, SIGNAL(aboutToOpenURL()),
124 m_remoteEncoding
, SLOT(slotAboutToOpenUrl()));
126 QClipboard
* clipboard
= QApplication::clipboard();
127 connect(clipboard
, SIGNAL(dataChanged()),
128 this, SLOT(updatePasteAction()));
130 // Create file info and listing filter extensions.
131 // NOTE: Listing filter needs to be instantiated after the creation of the view.
132 new DolphinPartFileInfoExtension(this);
134 #if KDE_IS_VERSION(4, 9, 2)
135 new DolphinPartListingFilterExtension(this);
137 KDirLister
* lister
= m_view
->m_model
->m_dirLister
;
139 DolphinPartListingNotificationExtension
* notifyExt
= new DolphinPartListingNotificationExtension(this);
140 connect(lister
, SIGNAL(newItems(KFileItemList
)), notifyExt
, SLOT(slotNewItems(KFileItemList
)));
141 connect(lister
, SIGNAL(itemsDeleted(KFileItemList
)), notifyExt
, SLOT(slotItemsDeleted(KFileItemList
)));
143 kWarning() << "NULL KDirLister object! KParts::ListingNotificationExtension will NOT be supported";
148 m_actionHandler
->updateViewActions();
149 slotSelectionChanged(KFileItemList()); // initially disable selection-dependent actions
151 // Listen to events from the app so we can update the remove key by
152 // checking for a Shift key press.
153 qApp
->installEventFilter(this);
155 // TODO there was a "always open a new window" (when clicking on a directory) setting in konqueror
156 // (sort of spacial navigation)
158 loadPlugins(this, this, componentData());
161 DolphinPart::~DolphinPart()
163 DolphinNewFileMenuObserver::instance().detach(m_newFileMenu
);
166 void DolphinPart::createActions()
170 m_newFileMenu
= new KNewFileMenu(actionCollection(), "new_menu", this);
171 m_newFileMenu
->setParentWidget(widget());
172 DolphinNewFileMenuObserver::instance().attach(m_newFileMenu
);
173 connect(m_newFileMenu
->menu(), SIGNAL(aboutToShow()),
174 this, SLOT(updateNewMenu()));
176 KAction
*editMimeTypeAction
= actionCollection()->addAction( "editMimeType" );
177 editMimeTypeAction
->setText( i18nc("@action:inmenu Edit", "&Edit File Type..." ) );
178 connect(editMimeTypeAction
, SIGNAL(triggered()), SLOT(slotEditMimeType()));
180 KAction
* selectItemsMatching
= actionCollection()->addAction("select_items_matching");
181 selectItemsMatching
->setText(i18nc("@action:inmenu Edit", "Select Items Matching..."));
182 selectItemsMatching
->setShortcut(Qt::CTRL
| Qt::Key_S
);
183 connect(selectItemsMatching
, SIGNAL(triggered()), this, SLOT(slotSelectItemsMatchingPattern()));
185 KAction
* unselectItemsMatching
= actionCollection()->addAction("unselect_items_matching");
186 unselectItemsMatching
->setText(i18nc("@action:inmenu Edit", "Unselect Items Matching..."));
187 connect(unselectItemsMatching
, SIGNAL(triggered()), this, SLOT(slotUnselectItemsMatchingPattern()));
189 actionCollection()->addAction(KStandardAction::SelectAll
, "select_all", m_view
, SLOT(selectAll()));
191 KAction
* unselectAll
= actionCollection()->addAction("unselect_all");
192 unselectAll
->setText(i18nc("@action:inmenu Edit", "Unselect All"));
193 connect(unselectAll
, SIGNAL(triggered()), m_view
, SLOT(clearSelection()));
195 KAction
* invertSelection
= actionCollection()->addAction("invert_selection");
196 invertSelection
->setText(i18nc("@action:inmenu Edit", "Invert Selection"));
197 invertSelection
->setShortcut(Qt::CTRL
| Qt::SHIFT
| Qt::Key_A
);
198 connect(invertSelection
, SIGNAL(triggered()), m_view
, SLOT(invertSelection()));
200 // View menu: all done by DolphinViewActionHandler
204 QActionGroup
* goActionGroup
= new QActionGroup(this);
205 connect(goActionGroup
, SIGNAL(triggered(QAction
*)),
206 this, SLOT(slotGoTriggered(QAction
*)));
208 createGoAction("go_applications", "start-here-kde",
209 i18nc("@action:inmenu Go", "App&lications"), QString("programs:/"),
211 createGoAction("go_network_folders", "folder-remote",
212 i18nc("@action:inmenu Go", "&Network Folders"), QString("remote:/"),
214 createGoAction("go_settings", "preferences-system",
215 i18nc("@action:inmenu Go", "Sett&ings"), QString("settings:/"),
217 createGoAction("go_trash", "user-trash",
218 i18nc("@action:inmenu Go", "Trash"), QString("trash:/"),
220 createGoAction("go_autostart", "",
221 i18nc("@action:inmenu Go", "Autostart"), KGlobalSettings::autostartPath(),
225 m_findFileAction
= actionCollection()->addAction("find_file");
226 m_findFileAction
->setText(i18nc("@action:inmenu Tools", "Find File..."));
227 m_findFileAction
->setShortcut(Qt::CTRL
| Qt::Key_F
);
228 m_findFileAction
->setIcon(KIcon("edit-find"));
229 connect(m_findFileAction
, SIGNAL(triggered()), this, SLOT(slotFindFile()));
231 if (KAuthorized::authorizeKAction("shell_access")) {
232 m_openTerminalAction
= actionCollection()->addAction("open_terminal");
233 m_openTerminalAction
->setIcon(KIcon("utilities-terminal"));
234 m_openTerminalAction
->setText(i18nc("@action:inmenu Tools", "Open &Terminal"));
235 connect(m_openTerminalAction
, SIGNAL(triggered()), SLOT(slotOpenTerminal()));
236 m_openTerminalAction
->setShortcut(Qt::Key_F4
);
240 void DolphinPart::createGoAction(const char* name
, const char* iconName
,
241 const QString
& text
, const QString
& url
,
242 QActionGroup
* actionGroup
)
244 KAction
* action
= actionCollection()->addAction(name
);
245 action
->setIcon(KIcon(iconName
));
246 action
->setText(text
);
247 action
->setData(url
);
248 action
->setActionGroup(actionGroup
);
251 void DolphinPart::slotGoTriggered(QAction
* action
)
253 const QString url
= action
->data().toString();
254 emit m_extension
->openUrlRequest(KUrl(url
));
257 void DolphinPart::slotSelectionChanged(const KFileItemList
& selection
)
259 const bool hasSelection
= !selection
.isEmpty();
261 QAction
* renameAction
= actionCollection()->action("rename");
262 QAction
* moveToTrashAction
= actionCollection()->action("move_to_trash");
263 QAction
* deleteAction
= actionCollection()->action("delete");
264 QAction
* editMimeTypeAction
= actionCollection()->action("editMimeType");
265 QAction
* propertiesAction
= actionCollection()->action("properties");
266 QAction
* deleteWithTrashShortcut
= actionCollection()->action("delete_shortcut"); // see DolphinViewActionHandler
269 stateChanged("has_no_selection");
271 emit m_extension
->enableAction("cut", false);
272 emit m_extension
->enableAction("copy", false);
273 deleteWithTrashShortcut
->setEnabled(false);
274 editMimeTypeAction
->setEnabled(false);
276 stateChanged("has_selection");
278 // TODO share this code with DolphinMainWindow::updateEditActions (and the desktop code)
280 KFileItemListProperties
capabilities(selection
);
281 const bool enableMoveToTrash
= capabilities
.isLocal() && capabilities
.supportsMoving();
283 renameAction
->setEnabled(capabilities
.supportsMoving());
284 moveToTrashAction
->setEnabled(enableMoveToTrash
);
285 deleteAction
->setEnabled(capabilities
.supportsDeleting());
286 deleteWithTrashShortcut
->setEnabled(capabilities
.supportsDeleting() && !enableMoveToTrash
);
287 editMimeTypeAction
->setEnabled(true);
288 propertiesAction
->setEnabled(true);
289 emit m_extension
->enableAction("cut", capabilities
.supportsMoving());
290 emit m_extension
->enableAction("copy", true);
294 void DolphinPart::updatePasteAction()
296 QPair
<bool, QString
> pasteInfo
= m_view
->pasteInfo();
297 emit m_extension
->enableAction( "paste", pasteInfo
.first
);
298 emit m_extension
->setActionText( "paste", pasteInfo
.second
);
301 KAboutData
* DolphinPart::createAboutData()
303 return new KAboutData("dolphinpart", "dolphin", ki18nc("@title", "Dolphin Part"), "0.1");
306 bool DolphinPart::openUrl(const KUrl
& url
)
308 bool reload
= arguments().reload();
309 // A bit of a workaround so that changing the namefilter works: force reload.
310 // Otherwise DolphinView wouldn't relist the URL, so nothing would happen.
311 if (m_nameFilter
!= m_view
->nameFilter())
313 if (m_view
->url() == url
&& !reload
) { // DolphinView won't do anything in that case, so don't emit started
316 setUrl(url
); // remember it at the KParts level
317 KUrl
visibleUrl(url
);
318 if (!m_nameFilter
.isEmpty()) {
319 visibleUrl
.addPath(m_nameFilter
);
321 QString prettyUrl
= visibleUrl
.pathOrUrl();
322 emit
setWindowCaption(prettyUrl
);
323 emit m_extension
->setLocationBarUrl(prettyUrl
);
324 emit
started(0); // get the wheel to spin
325 m_view
->setNameFilter(m_nameFilter
);
328 emit
aboutToOpenURL();
331 // Disable "Find File" and "Open Terminal" actions for non-file URLs,
332 // e.g. ftp, smb, etc. #279283
333 const bool isLocalUrl
= url
.isLocalFile();
334 m_findFileAction
->setEnabled(isLocalUrl
);
335 if (m_openTerminalAction
) {
336 m_openTerminalAction
->setEnabled(isLocalUrl
);
341 void DolphinPart::slotMessage(const QString
& msg
)
343 emit
setStatusBarText(msg
);
346 void DolphinPart::slotErrorMessage(const QString
& msg
)
350 //KMessageBox::error(m_view, msg);
353 void DolphinPart::slotRequestItemInfo(const KFileItem
& item
)
355 emit m_extension
->mouseOverInfo(item
);
359 const QString escapedText
= Qt::convertFromPlainText(item
.getStatusBarInfo());
360 ReadOnlyPart::setStatusBarText(QString("<qt>%1</qt>").arg(escapedText
));
364 void DolphinPart::slotItemActivated(const KFileItem
& item
)
366 KParts::OpenUrlArguments args
;
367 // Forget about the known mimetype if a target URL is used.
368 // Testcase: network:/ with a item (mimetype "inode/some-foo-service") pointing to a http URL (html)
369 if (item
.targetUrl() == item
.url()) {
370 args
.setMimeType(item
.mimetype());
373 // Ideally, konqueror should be changed to not require trustedSource for directory views,
374 // since the idea was not to need BrowserArguments for non-browser stuff...
375 KParts::BrowserArguments browserArgs
;
376 browserArgs
.trustedSource
= true;
377 emit m_extension
->openUrlRequest(item
.targetUrl(), args
, browserArgs
);
380 void DolphinPart::slotItemsActivated(const KFileItemList
& items
)
382 foreach (const KFileItem
& item
, items
) {
383 slotItemActivated(item
);
387 void DolphinPart::createNewWindow(const KUrl
& url
)
389 // TODO: Check issue N176832 for the missing QAIV signal; task 177399 - maybe this code
390 // should be moved into DolphinPart::slotItemActivated()
391 emit m_extension
->createNewWindow(url
);
394 void DolphinPart::slotOpenContextMenu(const QPoint
& pos
,
395 const KFileItem
& _item
,
397 const QList
<QAction
*>& customActions
)
399 KParts::BrowserExtension::PopupFlags popupFlags
= KParts::BrowserExtension::DefaultPopupItems
400 | KParts::BrowserExtension::ShowProperties
401 | KParts::BrowserExtension::ShowUrlOperations
;
403 KFileItem
item(_item
);
405 if (item
.isNull()) { // viewport context menu
406 popupFlags
|= KParts::BrowserExtension::ShowNavigationItems
| KParts::BrowserExtension::ShowUp
;
407 item
= m_view
->rootItem();
409 item
= KFileItem( S_IFDIR
, (mode_t
)-1, url() );
411 item
.setUrl(url()); // ensure we use the view url, not the canonical path (#213799)
414 // TODO: We should change the signature of the slots (and signals) for being able
415 // to tell for which items we want a popup.
417 if (m_view
->selectedItems().isEmpty()) {
420 items
= m_view
->selectedItems();
423 KFileItemListProperties
capabilities(items
);
425 KParts::BrowserExtension::ActionGroupMap actionGroups
;
426 QList
<QAction
*> editActions
;
427 editActions
+= m_view
->versionControlActions(m_view
->selectedItems());
428 editActions
+= customActions
;
430 if (!_item
.isNull()) { // only for context menu on one or more items
431 const bool supportsMoving
= capabilities
.supportsMoving();
433 if (capabilities
.supportsDeleting()) {
434 const bool showDeleteAction
= (KGlobal::config()->group("KDE").readEntry("ShowDeleteCommand", false) ||
435 !item
.isLocalFile());
436 const bool showMoveToTrashAction
= capabilities
.isLocal() && supportsMoving
;
438 if (showDeleteAction
&& showMoveToTrashAction
) {
439 delete m_removeAction
;
441 editActions
.append(actionCollection()->action("move_to_trash"));
442 editActions
.append(actionCollection()->action("delete"));
443 } else if (showDeleteAction
&& !showMoveToTrashAction
) {
444 editActions
.append(actionCollection()->action("delete"));
447 m_removeAction
= new DolphinRemoveAction(this, actionCollection());
448 editActions
.append(m_removeAction
);
449 m_removeAction
->update();
452 popupFlags
|= KParts::BrowserExtension::NoDeletion
;
455 if (supportsMoving
) {
456 editActions
.append(actionCollection()->action("rename"));
459 // Normally KonqPopupMenu only shows the "Create new" submenu in the current view
460 // since otherwise the created file would not be visible.
461 // But in treeview mode we should allow it.
462 if (m_view
->itemsExpandable())
463 popupFlags
|= KParts::BrowserExtension::ShowCreateDirectory
;
467 actionGroups
.insert("editactions", editActions
);
469 emit m_extension
->popupMenu(pos
,
471 KParts::OpenUrlArguments(),
472 KParts::BrowserArguments(),
477 void DolphinPart::slotDirectoryRedirection(const KUrl
& oldUrl
, const KUrl
& newUrl
)
479 //kDebug() << oldUrl << newUrl << "currentUrl=" << url();
480 if (oldUrl
.equals(url(), KUrl::CompareWithoutTrailingSlash
/* #207572 */)) {
481 KParts::ReadOnlyPart::setUrl(newUrl
);
482 const QString prettyUrl
= newUrl
.pathOrUrl();
483 emit m_extension
->setLocationBarUrl(prettyUrl
);
488 void DolphinPart::slotEditMimeType()
490 const KFileItemList items
= m_view
->selectedItems();
491 if (!items
.isEmpty()) {
492 KonqOperations::editMimeType(items
.first().mimetype(), m_view
);
496 void DolphinPart::slotSelectItemsMatchingPattern()
498 openSelectionDialog(i18nc("@title:window", "Select"),
499 i18n("Select all items matching this pattern:"),
503 void DolphinPart::slotUnselectItemsMatchingPattern()
505 openSelectionDialog(i18nc("@title:window", "Unselect"),
506 i18n("Unselect all items matching this pattern:"),
510 void DolphinPart::openSelectionDialog(const QString
& title
, const QString
& text
, bool selectItems
)
513 QString pattern
= KInputDialog::getText(title
, text
, "*", &okClicked
, m_view
);
515 if (okClicked
&& !pattern
.isEmpty()) {
516 QRegExp
patternRegExp(pattern
, Qt::CaseSensitive
, QRegExp::Wildcard
);
517 m_view
->selectItems(patternRegExp
, selectItems
);
521 void DolphinPart::setCurrentViewMode(const QString
& viewModeName
)
523 QAction
* action
= actionCollection()->action(viewModeName
);
528 QString
DolphinPart::currentViewMode() const
530 return m_actionHandler
->currentViewModeActionName();
533 void DolphinPart::setNameFilter(const QString
& nameFilter
)
535 // This is the "/home/dfaure/*.diff" kind of name filter (KDirLister::setNameFilter)
536 // which is unrelated to DolphinView::setNameFilter which is substring filtering in a proxy.
537 m_nameFilter
= nameFilter
;
538 // TODO save/restore name filter in saveState/restoreState like KonqDirPart did in kde3?
541 void DolphinPart::slotOpenTerminal()
543 QString
dir(QDir::homePath());
547 // If the given directory is not local, it can still be the URL of an
548 // ioslave using UDS_LOCAL_PATH which to be converted first.
549 u
= KIO::NetAccess::mostLocalUrl(u
, widget());
551 //If the URL is local after the above conversion, set the directory.
552 if (u
.isLocalFile()) {
553 dir
= u
.toLocalFile();
556 KToolInvocation::invokeTerminal(QString(), dir
);
559 void DolphinPart::slotFindFile()
561 KRun::run("kfind", url(), widget());
564 void DolphinPart::updateNewMenu()
566 // As requested by KNewFileMenu :
567 m_newFileMenu
->checkUpToDate();
568 m_newFileMenu
->setViewShowsHiddenFiles(m_view
->hiddenFilesShown());
569 // And set the files that the menu apply on :
570 m_newFileMenu
->setPopupFiles(url());
573 void DolphinPart::updateStatusBar()
575 const QString escapedText
= Qt::convertFromPlainText(m_view
->statusBarText());
576 emit
ReadOnlyPart::setStatusBarText(QString("<qt>%1</qt>").arg(escapedText
));
579 void DolphinPart::updateProgress(int percent
)
581 m_extension
->loadingProgress(percent
);
584 void DolphinPart::createDirectory()
586 m_newFileMenu
->setViewShowsHiddenFiles(m_view
->hiddenFilesShown());
587 m_newFileMenu
->setPopupFiles(url());
588 m_newFileMenu
->createDirectory();
591 void DolphinPart::setFilesToSelect(const KUrl::List
& files
)
593 if (files
.isEmpty()) {
597 m_view
->markUrlsAsSelected(files
);
598 m_view
->markUrlAsCurrent(files
.at(0));
601 bool DolphinPart::eventFilter(QObject
* obj
, QEvent
* event
)
603 const int type
= event
->type();
605 if ((type
== QEvent::KeyPress
|| type
== QEvent::KeyRelease
) && m_removeAction
) {
606 QMenu
* menu
= qobject_cast
<QMenu
*>(obj
);
607 if (menu
&& menu
->parent() == m_view
) {
608 QKeyEvent
* ev
= static_cast<QKeyEvent
*>(event
);
609 if (ev
->key() == Qt::Key_Shift
) {
610 m_removeAction
->update();
615 return KParts::ReadOnlyPart::eventFilter(obj
, event
);
620 void DolphinPartBrowserExtension::restoreState(QDataStream
&stream
)
622 KParts::BrowserExtension::restoreState(stream
);
623 m_part
->view()->restoreState(stream
);
626 void DolphinPartBrowserExtension::saveState(QDataStream
&stream
)
628 KParts::BrowserExtension::saveState(stream
);
629 m_part
->view()->saveState(stream
);
632 void DolphinPartBrowserExtension::cut()
634 m_part
->view()->cutSelectedItems();
637 void DolphinPartBrowserExtension::copy()
639 m_part
->view()->copySelectedItems();
642 void DolphinPartBrowserExtension::paste()
644 m_part
->view()->paste();
647 void DolphinPartBrowserExtension::pasteTo(const KUrl
&)
649 m_part
->view()->pasteIntoFolder();
652 void DolphinPartBrowserExtension::reparseConfiguration()
654 m_part
->view()->readSettings();
659 DolphinPartFileInfoExtension::DolphinPartFileInfoExtension(DolphinPart
* part
)
660 : KParts::FileInfoExtension(part
)
664 DolphinPart
* DolphinPartFileInfoExtension::part() const
666 return static_cast<DolphinPart
*>(parent());
669 bool DolphinPartFileInfoExtension::hasSelection() const
671 return part()->view()->selectedItemsCount() > 0;
674 KParts::FileInfoExtension::QueryModes
DolphinPartFileInfoExtension::supportedQueryModes() const
676 return (KParts::FileInfoExtension::AllItems
| KParts::FileInfoExtension::SelectedItems
);
679 KFileItemList
DolphinPartFileInfoExtension::queryFor(KParts::FileInfoExtension::QueryMode mode
) const
683 if (mode
== KParts::FileInfoExtension::None
)
686 if (!(supportedQueryModes() & mode
))
690 case KParts::FileInfoExtension::SelectedItems
:
692 return part()->view()->selectedItems();
694 case KParts::FileInfoExtension::AllItems
:
695 return part()->view()->items();
703 #include "dolphinpart.moc"