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