]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinpart.cpp
Interface cleanup: The DolphinView should not expose QAbstractItemView-specific thing...
[dolphin.git] / src / dolphinpart.cpp
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 #include "dolphinpart.h"
21
22 #include <kfileitemlistproperties.h>
23 #include <konq_operations.h>
24
25 #include <kaboutdata.h>
26 #include <kactioncollection.h>
27 #include <kconfiggroup.h>
28 #include <kdebug.h>
29 #include <kglobalsettings.h>
30 #include <kiconloader.h>
31 #include <klocale.h>
32 #include <kmessagebox.h>
33 #include <kpluginfactory.h>
34 #include <ktoggleaction.h>
35 #include <kio/netaccess.h>
36 #include <ktoolinvocation.h>
37 #include <kauthorized.h>
38 #include <knewfilemenu.h>
39 #include <kmenu.h>
40 #include <kinputdialog.h>
41 #include <kprotocolinfo.h>
42
43 #include "settings/dolphinsettings.h"
44 #include "views/dolphinview.h"
45 #include "views/dolphinviewactionhandler.h"
46 #include "views/dolphinsortfilterproxymodel.h"
47 #include "views/dolphinmodel.h"
48 #include "views/dolphinnewfilemenuobserver.h"
49 #include "views/dolphinremoteencoding.h"
50 #include "views/dolphindirlister.h"
51
52 #include <QActionGroup>
53 #include <QApplication>
54 #include <QClipboard>
55
56 K_PLUGIN_FACTORY(DolphinPartFactory, registerPlugin<DolphinPart>();)
57 K_EXPORT_PLUGIN(DolphinPartFactory("dolphinpart", "dolphin"))
58
59 DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantList& args)
60 : KParts::ReadOnlyPart(parent)
61 {
62 Q_UNUSED(args)
63 setComponentData(DolphinPartFactory::componentData(), false);
64 m_extension = new DolphinPartBrowserExtension(this);
65 new DolphinPartFileInfoExtension(this);
66
67 // make sure that other apps using this part find Dolphin's view-file-columns icons
68 KIconLoader::global()->addAppDir("dolphin");
69
70 m_dirLister = new DolphinDirLister;
71 m_dirLister->setAutoUpdate(true);
72 if (parentWidget) {
73 m_dirLister->setMainWindow(parentWidget->window());
74 }
75 m_dirLister->setDelayedMimeTypes(true);
76
77 connect(m_dirLister, SIGNAL(completed(KUrl)), this, SLOT(slotCompleted(KUrl)));
78 connect(m_dirLister, SIGNAL(canceled(KUrl)), this, SLOT(slotCanceled(KUrl)));
79 connect(m_dirLister, SIGNAL(percent(int)), this, SLOT(updateProgress(int)));
80 connect(m_dirLister, SIGNAL(errorMessage(QString)), this, SLOT(slotErrorMessage(QString)));
81
82 m_dolphinModel = new DolphinModel(this);
83 m_dolphinModel->setDirLister(m_dirLister); // m_dolphinModel takes ownership of m_dirLister
84
85 m_proxyModel = new DolphinSortFilterProxyModel(this);
86 m_proxyModel->setSourceModel(m_dolphinModel);
87
88 m_view = new DolphinView(parentWidget, KUrl(), m_proxyModel);
89 m_view->setTabsForFilesEnabled(true);
90 setWidget(m_view);
91
92 setXMLFile("dolphinpart.rc");
93
94 connect(m_view, SIGNAL(infoMessage(QString)),
95 this, SLOT(slotMessage(QString)));
96 connect(m_view, SIGNAL(operationCompletedMessage(QString)),
97 this, SLOT(slotMessage(QString)));
98 connect(m_view, SIGNAL(errorMessage(QString)),
99 this, SLOT(slotErrorMessage(QString)));
100 connect(m_view, SIGNAL(itemTriggered(KFileItem)),
101 this, SLOT(slotItemTriggered(KFileItem)));
102 connect(m_view, SIGNAL(tabRequested(KUrl)),
103 this, SLOT(createNewWindow(KUrl)));
104 connect(m_view, SIGNAL(requestContextMenu(KFileItem,KUrl,QList<QAction*>)),
105 this, SLOT(slotOpenContextMenu(KFileItem,KUrl,QList<QAction*>)));
106 connect(m_view, SIGNAL(selectionChanged(KFileItemList)),
107 m_extension, SIGNAL(selectionInfo(KFileItemList)));
108 connect(m_view, SIGNAL(selectionChanged(KFileItemList)),
109 this, SLOT(slotSelectionChanged(KFileItemList)));
110 connect(m_view, SIGNAL(requestItemInfo(KFileItem)),
111 this, SLOT(slotRequestItemInfo(KFileItem)));
112 connect(m_view, SIGNAL(modeChanged()),
113 this, SIGNAL(viewModeChanged())); // relay signal
114 connect(m_view, SIGNAL(redirection(KUrl, KUrl)),
115 this, SLOT(slotRedirection(KUrl, KUrl)));
116
117 // Watch for changes that should result in updates to the
118 // status bar text.
119 connect(m_dirLister, SIGNAL(itemsDeleted(const KFileItemList&)),
120 this, SLOT(updateStatusBar()));
121 connect(m_dirLister, SIGNAL(clear()),
122 this, SLOT(updateStatusBar()));
123 connect(m_view, SIGNAL(selectionChanged(const KFileItemList)),
124 this, SLOT(updateStatusBar()));
125
126 m_actionHandler = new DolphinViewActionHandler(actionCollection(), this);
127 m_actionHandler->setCurrentView(m_view);
128 connect(m_actionHandler, SIGNAL(createDirectory()), SLOT(createDirectory()));
129
130 m_remoteEncoding = new DolphinRemoteEncoding(this, m_actionHandler);
131 connect(this, SIGNAL(aboutToOpenURL()),
132 m_remoteEncoding, SLOT(slotAboutToOpenUrl()));
133
134 QClipboard* clipboard = QApplication::clipboard();
135 connect(clipboard, SIGNAL(dataChanged()),
136 this, SLOT(updatePasteAction()));
137
138 createActions();
139 m_actionHandler->updateViewActions();
140 slotSelectionChanged(KFileItemList()); // initially disable selection-dependent actions
141
142 // TODO there was a "always open a new window" (when clicking on a directory) setting in konqueror
143 // (sort of spacial navigation)
144
145 loadPlugins(this, this, componentData());
146
147 }
148
149 DolphinPart::~DolphinPart()
150 {
151 DolphinSettings::instance().save();
152 DolphinNewFileMenuObserver::instance().detach(m_newFileMenu);
153 }
154
155 void DolphinPart::createActions()
156 {
157 // Edit menu
158
159 m_newFileMenu = new KNewFileMenu(actionCollection(), "new_menu", this);
160 m_newFileMenu->setParentWidget(widget());
161 DolphinNewFileMenuObserver::instance().attach(m_newFileMenu);
162 connect(m_newFileMenu->menu(), SIGNAL(aboutToShow()),
163 this, SLOT(updateNewMenu()));
164
165 KAction *editMimeTypeAction = actionCollection()->addAction( "editMimeType" );
166 editMimeTypeAction->setText( i18nc("@action:inmenu Edit", "&Edit File Type..." ) );
167 connect(editMimeTypeAction, SIGNAL(triggered()), SLOT(slotEditMimeType()));
168
169 KAction* selectItemsMatching = actionCollection()->addAction("select_items_matching");
170 selectItemsMatching->setText(i18nc("@action:inmenu Edit", "Select Items Matching..."));
171 selectItemsMatching->setShortcut(Qt::CTRL | Qt::Key_S);
172 connect(selectItemsMatching, SIGNAL(triggered()), this, SLOT(slotSelectItemsMatchingPattern()));
173
174 KAction* unselectItemsMatching = actionCollection()->addAction("unselect_items_matching");
175 unselectItemsMatching->setText(i18nc("@action:inmenu Edit", "Unselect Items Matching..."));
176 connect(unselectItemsMatching, SIGNAL(triggered()), this, SLOT(slotUnselectItemsMatchingPattern()));
177
178 actionCollection()->addAction(KStandardAction::SelectAll, "select_all", m_view, SLOT(selectAll()));
179
180 KAction* unselectAll = actionCollection()->addAction("unselect_all");
181 unselectAll->setText(i18nc("@action:inmenu Edit", "Unselect All"));
182 connect(unselectAll, SIGNAL(triggered()), m_view, SLOT(clearSelection()));
183
184 KAction* invertSelection = actionCollection()->addAction("invert_selection");
185 invertSelection->setText(i18nc("@action:inmenu Edit", "Invert Selection"));
186 invertSelection->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_A);
187 connect(invertSelection, SIGNAL(triggered()), m_view, SLOT(invertSelection()));
188
189 // View menu: all done by DolphinViewActionHandler
190
191 // Go menu
192
193 QActionGroup* goActionGroup = new QActionGroup(this);
194 connect(goActionGroup, SIGNAL(triggered(QAction*)),
195 this, SLOT(slotGoTriggered(QAction*)));
196
197 createGoAction("go_applications", "start-here-kde",
198 i18nc("@action:inmenu Go", "App&lications"), QString("programs:/"),
199 goActionGroup);
200 createGoAction("go_network_folders", "folder-remote",
201 i18nc("@action:inmenu Go", "&Network Folders"), QString("remote:/"),
202 goActionGroup);
203 createGoAction("go_settings", "preferences-system",
204 i18nc("@action:inmenu Go", "Sett&ings"), QString("settings:/"),
205 goActionGroup);
206 createGoAction("go_trash", "user-trash",
207 i18nc("@action:inmenu Go", "Trash"), QString("trash:/"),
208 goActionGroup);
209 createGoAction("go_autostart", "",
210 i18nc("@action:inmenu Go", "Autostart"), KGlobalSettings::autostartPath(),
211 goActionGroup);
212
213 // Tools menu
214 if (KAuthorized::authorizeKAction("shell_access")) {
215 KAction* action = actionCollection()->addAction("open_terminal");
216 action->setIcon(KIcon("utilities-terminal"));
217 action->setText(i18nc("@action:inmenu Tools", "Open &Terminal"));
218 connect(action, SIGNAL(triggered()), SLOT(slotOpenTerminal()));
219 action->setShortcut(Qt::Key_F4);
220 }
221
222 }
223
224 void DolphinPart::createGoAction(const char* name, const char* iconName,
225 const QString& text, const QString& url,
226 QActionGroup* actionGroup)
227 {
228 KAction* action = actionCollection()->addAction(name);
229 action->setIcon(KIcon(iconName));
230 action->setText(text);
231 action->setData(url);
232 action->setActionGroup(actionGroup);
233 }
234
235 void DolphinPart::slotGoTriggered(QAction* action)
236 {
237 const QString url = action->data().toString();
238 emit m_extension->openUrlRequest(KUrl(url));
239 }
240
241 void DolphinPart::slotSelectionChanged(const KFileItemList& selection)
242 {
243 const bool hasSelection = !selection.isEmpty();
244
245 QAction* renameAction = actionCollection()->action("rename");
246 QAction* moveToTrashAction = actionCollection()->action("move_to_trash");
247 QAction* deleteAction = actionCollection()->action("delete");
248 QAction* editMimeTypeAction = actionCollection()->action("editMimeType");
249 QAction* propertiesAction = actionCollection()->action("properties");
250 QAction* deleteWithTrashShortcut = actionCollection()->action("delete_shortcut"); // see DolphinViewActionHandler
251
252 if (!hasSelection) {
253 stateChanged("has_no_selection");
254
255 emit m_extension->enableAction("cut", false);
256 emit m_extension->enableAction("copy", false);
257 deleteWithTrashShortcut->setEnabled(false);
258 editMimeTypeAction->setEnabled(false);
259 } else {
260 stateChanged("has_selection");
261
262 // TODO share this code with DolphinMainWindow::updateEditActions (and the desktop code)
263 // in libkonq
264 KFileItemListProperties capabilities(selection);
265 const bool enableMoveToTrash = capabilities.isLocal() && capabilities.supportsMoving();
266
267 renameAction->setEnabled(capabilities.supportsMoving());
268 moveToTrashAction->setEnabled(enableMoveToTrash);
269 deleteAction->setEnabled(capabilities.supportsDeleting());
270 deleteWithTrashShortcut->setEnabled(capabilities.supportsDeleting() && !enableMoveToTrash);
271 editMimeTypeAction->setEnabled(true);
272 propertiesAction->setEnabled(true);
273 emit m_extension->enableAction("cut", capabilities.supportsMoving());
274 emit m_extension->enableAction("copy", true);
275 }
276 }
277
278 void DolphinPart::updatePasteAction()
279 {
280 QPair<bool, QString> pasteInfo = m_view->pasteInfo();
281 emit m_extension->enableAction( "paste", pasteInfo.first );
282 emit m_extension->setActionText( "paste", pasteInfo.second );
283 }
284
285 KAboutData* DolphinPart::createAboutData()
286 {
287 return new KAboutData("dolphinpart", "dolphin", ki18nc("@title", "Dolphin Part"), "0.1");
288 }
289
290 bool DolphinPart::openUrl(const KUrl& url)
291 {
292 bool reload = arguments().reload();
293 // A bit of a workaround so that changing the namefilter works: force reload.
294 // Otherwise DolphinView wouldn't relist the URL, so nothing would happen.
295 if (m_nameFilter != m_dirLister->nameFilter())
296 reload = true;
297 if (m_view->url() == url && !reload) { // DolphinView won't do anything in that case, so don't emit started
298 return true;
299 }
300 setUrl(url); // remember it at the KParts level
301 KUrl visibleUrl(url);
302 if (!m_nameFilter.isEmpty()) {
303 visibleUrl.addPath(m_nameFilter);
304 }
305 QString prettyUrl = visibleUrl.pathOrUrl();
306 emit setWindowCaption(prettyUrl);
307 emit m_extension->setLocationBarUrl(prettyUrl);
308 emit started(0); // get the wheel to spin
309 m_dirLister->setNameFilter(m_nameFilter);
310 m_view->setUrl(url);
311 updatePasteAction();
312 emit aboutToOpenURL();
313 if (reload)
314 m_view->reload();
315 return true;
316 }
317
318 void DolphinPart::slotCompleted(const KUrl& url)
319 {
320 Q_UNUSED(url)
321 emit completed();
322 }
323
324 void DolphinPart::slotCanceled(const KUrl& url)
325 {
326 slotCompleted(url);
327 }
328
329 void DolphinPart::slotMessage(const QString& msg)
330 {
331 emit setStatusBarText(msg);
332 }
333
334 void DolphinPart::slotErrorMessage(const QString& msg)
335 {
336 kDebug() << msg;
337 emit canceled(msg);
338 //KMessageBox::error(m_view, msg);
339 }
340
341 void DolphinPart::slotRequestItemInfo(const KFileItem& item)
342 {
343 emit m_extension->mouseOverInfo(item);
344 if (item.isNull()) {
345 updateStatusBar();
346 } else {
347 ReadOnlyPart::setStatusBarText(item.getStatusBarInfo());
348 }
349 }
350
351 void DolphinPart::slotItemTriggered(const KFileItem& item)
352 {
353 KParts::OpenUrlArguments args;
354 // Forget about the known mimetype if a target URL is used.
355 // Testcase: network:/ with a item (mimetype "inode/some-foo-service") pointing to a http URL (html)
356 if (item.targetUrl() == item.url()) {
357 args.setMimeType(item.mimetype());
358 }
359
360 // Ideally, konqueror should be changed to not require trustedSource for directory views,
361 // since the idea was not to need BrowserArguments for non-browser stuff...
362 KParts::BrowserArguments browserArgs;
363 browserArgs.trustedSource = true;
364 emit m_extension->openUrlRequest(item.targetUrl(), args, browserArgs);
365 }
366
367 void DolphinPart::createNewWindow(const KUrl& url)
368 {
369 // TODO: Check issue N176832 for the missing QAIV signal; task 177399 - maybe this code
370 // should be moved into DolphinPart::slotItemTriggered()
371 emit m_extension->createNewWindow(url);
372 }
373
374 void DolphinPart::slotOpenContextMenu(const KFileItem& _item,
375 const KUrl&,
376 const QList<QAction*>& customActions)
377 {
378 KParts::BrowserExtension::PopupFlags popupFlags = KParts::BrowserExtension::DefaultPopupItems
379 | KParts::BrowserExtension::ShowProperties
380 | KParts::BrowserExtension::ShowUrlOperations;
381
382 KFileItem item(_item);
383
384 if (item.isNull()) { // viewport context menu
385 popupFlags |= KParts::BrowserExtension::ShowNavigationItems | KParts::BrowserExtension::ShowUp;
386 item = m_dirLister->rootItem();
387 if (item.isNull())
388 item = KFileItem( S_IFDIR, (mode_t)-1, url() );
389 else
390 item.setUrl(url()); // ensure we use the view url, not the canonical path (#213799)
391 }
392
393 // TODO: We should change the signature of the slots (and signals) for being able
394 // to tell for which items we want a popup.
395 KFileItemList items;
396 if (m_view->selectedItems().isEmpty()) {
397 items.append(item);
398 } else {
399 items = m_view->selectedItems();
400 }
401
402 KFileItemListProperties capabilities(items);
403
404 KParts::BrowserExtension::ActionGroupMap actionGroups;
405 QList<QAction *> editActions;
406 editActions += m_view->versionControlActions(m_view->selectedItems());
407 editActions += customActions;
408
409 if (!_item.isNull()) { // only for context menu on one or more items
410 bool supportsDeleting = capabilities.supportsDeleting();
411 bool supportsMoving = capabilities.supportsMoving();
412
413 if (!supportsDeleting) {
414 popupFlags |= KParts::BrowserExtension::NoDeletion;
415 }
416
417 if (supportsMoving) {
418 editActions.append(actionCollection()->action("rename"));
419 }
420
421 bool addTrash = capabilities.isLocal() && supportsMoving;
422 bool addDel = false;
423 if (supportsDeleting) {
424 if ( !item.isLocalFile() )
425 addDel = true;
426 else if (QApplication::keyboardModifiers() & Qt::ShiftModifier) {
427 addTrash = false;
428 addDel = true;
429 }
430 else {
431 KSharedConfig::Ptr globalConfig = KSharedConfig::openConfig("kdeglobals", KConfig::IncludeGlobals);
432 KConfigGroup configGroup(globalConfig, "KDE");
433 addDel = configGroup.readEntry("ShowDeleteCommand", false);
434 }
435 }
436
437 if (addTrash)
438 editActions.append(actionCollection()->action("move_to_trash"));
439 if (addDel)
440 editActions.append(actionCollection()->action("delete"));
441
442 // Normally KonqPopupMenu only shows the "Create new" submenu in the current view
443 // since otherwise the created file would not be visible.
444 // But in treeview mode we should allow it.
445 if (m_view->itemsExpandable())
446 popupFlags |= KParts::BrowserExtension::ShowCreateDirectory;
447
448 }
449
450 actionGroups.insert("editactions", editActions);
451
452 emit m_extension->popupMenu(QCursor::pos(),
453 items,
454 KParts::OpenUrlArguments(),
455 KParts::BrowserArguments(),
456 popupFlags,
457 actionGroups);
458 }
459
460 void DolphinPart::slotRedirection(const KUrl& oldUrl, const KUrl& newUrl)
461 {
462 //kDebug() << oldUrl << newUrl << "currentUrl=" << url();
463 if (oldUrl.equals(url(), KUrl::CompareWithoutTrailingSlash /* #207572 */)) {
464 KParts::ReadOnlyPart::setUrl(newUrl);
465 const QString prettyUrl = newUrl.pathOrUrl();
466 emit m_extension->setLocationBarUrl(prettyUrl);
467 }
468 }
469
470
471 void DolphinPart::slotEditMimeType()
472 {
473 const KFileItemList items = m_view->selectedItems();
474 if (!items.isEmpty()) {
475 KonqOperations::editMimeType(items.first().mimetype(), m_view);
476 }
477 }
478
479 void DolphinPart::slotSelectItemsMatchingPattern()
480 {
481 openSelectionDialog(i18nc("@title:window", "Select"),
482 i18n("Select all items matching this pattern:"),
483 true);
484 }
485
486 void DolphinPart::slotUnselectItemsMatchingPattern()
487 {
488 openSelectionDialog(i18nc("@title:window", "Unselect"),
489 i18n("Unselect all items matching this pattern:"),
490 false);
491 }
492
493 void DolphinPart::openSelectionDialog(const QString& title, const QString& text, bool selectItems)
494 {
495 bool okClicked;
496 QString pattern = KInputDialog::getText(title, text, "*", &okClicked, m_view);
497
498 if (okClicked && !pattern.isEmpty()) {
499 QRegExp patternRegExp(pattern, Qt::CaseSensitive, QRegExp::Wildcard);
500 m_view->setItemSelectionEnabled(patternRegExp, selectItems);
501 }
502 }
503
504 void DolphinPart::setCurrentViewMode(const QString& viewModeName)
505 {
506 QAction* action = actionCollection()->action(viewModeName);
507 Q_ASSERT(action);
508 action->trigger();
509 }
510
511 QString DolphinPart::currentViewMode() const
512 {
513 return m_actionHandler->currentViewModeActionName();
514 }
515
516 void DolphinPart::setNameFilter(const QString& nameFilter)
517 {
518 // This is the "/home/dfaure/*.diff" kind of name filter (KDirLister::setNameFilter)
519 // which is unrelated to DolphinView::setNameFilter which is substring filtering in a proxy.
520 m_nameFilter = nameFilter;
521 // TODO save/restore name filter in saveState/restoreState like KonqDirPart did in kde3?
522 }
523
524 void DolphinPart::slotOpenTerminal()
525 {
526 QString dir(QDir::homePath());
527
528 KUrl u(url());
529
530 // If the given directory is not local, it can still be the URL of an
531 // ioslave using UDS_LOCAL_PATH which to be converted first.
532 u = KIO::NetAccess::mostLocalUrl(u, widget());
533
534 //If the URL is local after the above conversion, set the directory.
535 if (u.isLocalFile()) {
536 dir = u.toLocalFile();
537 }
538
539 KToolInvocation::invokeTerminal(QString(), dir);
540 }
541
542 void DolphinPart::updateNewMenu()
543 {
544 // As requested by KNewFileMenu :
545 m_newFileMenu->checkUpToDate();
546 m_newFileMenu->setViewShowsHiddenFiles(m_view->showHiddenFiles());
547 // And set the files that the menu apply on :
548 m_newFileMenu->setPopupFiles(url());
549 }
550
551 void DolphinPart::updateStatusBar()
552 {
553 emit ReadOnlyPart::setStatusBarText(m_view->statusBarText());
554 }
555
556 void DolphinPart::updateProgress(int percent)
557 {
558 m_extension->loadingProgress(percent);
559 }
560
561 void DolphinPart::createDirectory()
562 {
563 m_newFileMenu->setViewShowsHiddenFiles(m_view->showHiddenFiles());
564 m_newFileMenu->setPopupFiles(url());
565 m_newFileMenu->createDirectory();
566 }
567
568 void DolphinPart::setFilesToSelect(const KUrl::List& files)
569 {
570 m_view->markUrlsAsSelected(files);
571 }
572
573 ////
574
575 void DolphinPartBrowserExtension::restoreState(QDataStream &stream)
576 {
577 KParts::BrowserExtension::restoreState(stream);
578 m_part->view()->restoreState(stream);
579 }
580
581 void DolphinPartBrowserExtension::saveState(QDataStream &stream)
582 {
583 KParts::BrowserExtension::saveState(stream);
584 m_part->view()->saveState(stream);
585 }
586
587 void DolphinPartBrowserExtension::cut()
588 {
589 m_part->view()->cutSelectedItems();
590 }
591
592 void DolphinPartBrowserExtension::copy()
593 {
594 m_part->view()->copySelectedItems();
595 }
596
597 void DolphinPartBrowserExtension::paste()
598 {
599 m_part->view()->paste();
600 }
601
602 void DolphinPartBrowserExtension::pasteTo(const KUrl&)
603 {
604 m_part->view()->pasteIntoFolder();
605 }
606
607 void DolphinPartBrowserExtension::reparseConfiguration()
608 {
609 m_part->view()->refresh();
610 }
611
612 ////
613
614 DolphinPartFileInfoExtension::DolphinPartFileInfoExtension(DolphinPart* part)
615 : KParts::FileInfoExtension(part)
616 {
617 }
618
619 DolphinPart* DolphinPartFileInfoExtension::part() const
620 {
621 return static_cast<DolphinPart*>(parent());
622 }
623
624 bool DolphinPartFileInfoExtension::hasSelection() const
625 {
626 return part()->view()->hasSelection();
627 }
628
629 KParts::FileInfoExtension::QueryModes DolphinPartFileInfoExtension::supportedQueryModes() const
630 {
631 return (KParts::FileInfoExtension::AllItems | KParts::FileInfoExtension::SelectedItems);
632 }
633
634 KFileItemList DolphinPartFileInfoExtension::queryFor(KParts::FileInfoExtension::QueryMode mode) const
635 {
636 KFileItemList list;
637
638 if (mode == KParts::FileInfoExtension::None)
639 return list;
640
641 if (!(supportedQueryModes() & mode))
642 return list;
643
644 switch (mode) {
645 case KParts::FileInfoExtension::SelectedItems:
646 if (hasSelection())
647 return part()->view()->selectedItems();
648 break;
649 case KParts::FileInfoExtension::AllItems:
650 return part()->view()->items();
651 default:
652 break;
653 }
654
655 return list;
656 }
657
658 #include "dolphinpart.moc"