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"
22 #include <KFileItemListProperties>
23 #include <konq_operations.h>
26 #include <KActionCollection>
27 #include <KConfigGroup>
29 #include <KGlobalSettings>
30 #include <KIconLoader>
32 #include <KMessageBox>
33 #include <KPluginFactory>
35 #include <KToggleAction>
36 #include <KIO/NetAccess>
37 #include <KToolInvocation>
38 #include <kauthorized.h>
39 #include <KNewFileMenu>
41 #include <KInputDialog>
42 #include <KProtocolInfo>
44 #include "views/dolphinview.h"
45 #include "views/dolphinviewactionhandler.h"
46 #include "views/dolphinnewfilemenuobserver.h"
47 #include "views/dolphinremoteencoding.h"
48 #include "kitemviews/kfileitemmodel.h"
49 #include "kitemviews/private/kfileitemmodeldirlister.h"
51 #include <QActionGroup>
52 #include <QApplication>
56 K_PLUGIN_FACTORY(DolphinPartFactory
, registerPlugin
<DolphinPart
>();)
57 K_EXPORT_PLUGIN(DolphinPartFactory("dolphinpart", "dolphin"))
59 DolphinPart::DolphinPart(QWidget
* parentWidget
, QObject
* parent
, const QVariantList
& args
)
60 : KParts::ReadOnlyPart(parent
)
61 ,m_openTerminalAction(0)
64 setComponentData(DolphinPartFactory::componentData(), false);
65 m_extension
= new DolphinPartBrowserExtension(this);
67 // make sure that other apps using this part find Dolphin's view-file-columns icons
68 KIconLoader::global()->addAppDir("dolphin");
70 m_view
= new DolphinView(KUrl(), parentWidget
);
71 m_view
->setTabsForFilesEnabled(true);
74 connect(m_view
, SIGNAL(directoryLoadingCompleted()), this, SIGNAL(completed()));
75 connect(m_view
, SIGNAL(directoryLoadingProgress(int)), this, SLOT(updateProgress(int)));
76 connect(m_view
, SIGNAL(errorMessage(QString
)), this, SLOT(slotErrorMessage(QString
)));
78 setXMLFile("dolphinpart.rc");
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(itemActivated(KFileItem
)),
87 this, SLOT(slotItemActivated(KFileItem
)));
88 connect(m_view
, SIGNAL(tabRequested(KUrl
)),
89 this, SLOT(createNewWindow(KUrl
)));
90 connect(m_view
, SIGNAL(requestContextMenu(QPoint
,KFileItem
,KUrl
,QList
<QAction
*>)),
91 this, SLOT(slotOpenContextMenu(QPoint
,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(DolphinView::Mode
,DolphinView::Mode
)),
99 this, SIGNAL(viewModeChanged())); // relay signal
100 connect(m_view
, SIGNAL(redirection(KUrl
,KUrl
)),
101 this, SLOT(slotDirectoryRedirection(KUrl
,KUrl
)));
103 // Watch for changes that should result in updates to the
105 connect(m_view
, SIGNAL(itemCountChanged()), this, SLOT(updateStatusBar()));
106 connect(m_view
, SIGNAL(selectionChanged(KFileItemList
)), this, SLOT(updateStatusBar()));
108 m_actionHandler
= new DolphinViewActionHandler(actionCollection(), this);
109 m_actionHandler
->setCurrentView(m_view
);
110 connect(m_actionHandler
, SIGNAL(createDirectory()), SLOT(createDirectory()));
112 m_remoteEncoding
= new DolphinRemoteEncoding(this, m_actionHandler
);
113 connect(this, SIGNAL(aboutToOpenURL()),
114 m_remoteEncoding
, SLOT(slotAboutToOpenUrl()));
116 QClipboard
* clipboard
= QApplication::clipboard();
117 connect(clipboard
, SIGNAL(dataChanged()),
118 this, SLOT(updatePasteAction()));
120 // Create file info and listing filter extensions.
121 // NOTE: Listing filter needs to be instantiated after the creation of the view.
122 new DolphinPartFileInfoExtension(this);
124 #if KDE_IS_VERSION(4, 9, 2)
125 new DolphinPartListingFilterExtension(this);
127 KDirLister
* lister
= m_view
->m_model
->m_dirLister
;
129 DolphinPartListingNotificationExtension
* notifyExt
= new DolphinPartListingNotificationExtension(this);
130 connect(lister
, SIGNAL(newItems(KFileItemList
)), notifyExt
, SLOT(slotNewItems(KFileItemList
)));
131 connect(lister
, SIGNAL(itemsDeleted(KFileItemList
)), notifyExt
, SLOT(slotItemsDeleted(KFileItemList
)));
133 kWarning() << "NULL KDirLister object! KParts::ListingNotificationExtension will NOT be supported";
138 m_actionHandler
->updateViewActions();
139 slotSelectionChanged(KFileItemList()); // initially disable selection-dependent actions
141 // TODO there was a "always open a new window" (when clicking on a directory) setting in konqueror
142 // (sort of spacial navigation)
144 loadPlugins(this, this, componentData());
147 DolphinPart::~DolphinPart()
149 DolphinNewFileMenuObserver::instance().detach(m_newFileMenu
);
152 void DolphinPart::createActions()
156 m_newFileMenu
= new KNewFileMenu(actionCollection(), "new_menu", this);
157 m_newFileMenu
->setParentWidget(widget());
158 DolphinNewFileMenuObserver::instance().attach(m_newFileMenu
);
159 connect(m_newFileMenu
->menu(), SIGNAL(aboutToShow()),
160 this, SLOT(updateNewMenu()));
162 KAction
*editMimeTypeAction
= actionCollection()->addAction( "editMimeType" );
163 editMimeTypeAction
->setText( i18nc("@action:inmenu Edit", "&Edit File Type..." ) );
164 connect(editMimeTypeAction
, SIGNAL(triggered()), SLOT(slotEditMimeType()));
166 KAction
* selectItemsMatching
= actionCollection()->addAction("select_items_matching");
167 selectItemsMatching
->setText(i18nc("@action:inmenu Edit", "Select Items Matching..."));
168 selectItemsMatching
->setShortcut(Qt::CTRL
| Qt::Key_S
);
169 connect(selectItemsMatching
, SIGNAL(triggered()), this, SLOT(slotSelectItemsMatchingPattern()));
171 KAction
* unselectItemsMatching
= actionCollection()->addAction("unselect_items_matching");
172 unselectItemsMatching
->setText(i18nc("@action:inmenu Edit", "Unselect Items Matching..."));
173 connect(unselectItemsMatching
, SIGNAL(triggered()), this, SLOT(slotUnselectItemsMatchingPattern()));
175 actionCollection()->addAction(KStandardAction::SelectAll
, "select_all", m_view
, SLOT(selectAll()));
177 KAction
* unselectAll
= actionCollection()->addAction("unselect_all");
178 unselectAll
->setText(i18nc("@action:inmenu Edit", "Unselect All"));
179 connect(unselectAll
, SIGNAL(triggered()), m_view
, SLOT(clearSelection()));
181 KAction
* invertSelection
= actionCollection()->addAction("invert_selection");
182 invertSelection
->setText(i18nc("@action:inmenu Edit", "Invert Selection"));
183 invertSelection
->setShortcut(Qt::CTRL
| Qt::SHIFT
| Qt::Key_A
);
184 connect(invertSelection
, SIGNAL(triggered()), m_view
, SLOT(invertSelection()));
186 // View menu: all done by DolphinViewActionHandler
190 QActionGroup
* goActionGroup
= new QActionGroup(this);
191 connect(goActionGroup
, SIGNAL(triggered(QAction
*)),
192 this, SLOT(slotGoTriggered(QAction
*)));
194 createGoAction("go_applications", "start-here-kde",
195 i18nc("@action:inmenu Go", "App&lications"), QString("programs:/"),
197 createGoAction("go_network_folders", "folder-remote",
198 i18nc("@action:inmenu Go", "&Network Folders"), QString("remote:/"),
200 createGoAction("go_settings", "preferences-system",
201 i18nc("@action:inmenu Go", "Sett&ings"), QString("settings:/"),
203 createGoAction("go_trash", "user-trash",
204 i18nc("@action:inmenu Go", "Trash"), QString("trash:/"),
206 createGoAction("go_autostart", "",
207 i18nc("@action:inmenu Go", "Autostart"), KGlobalSettings::autostartPath(),
211 m_findFileAction
= actionCollection()->addAction("find_file");
212 m_findFileAction
->setText(i18nc("@action:inmenu Tools", "Find File..."));
213 m_findFileAction
->setShortcut(Qt::CTRL
| Qt::Key_F
);
214 m_findFileAction
->setIcon(KIcon("edit-find"));
215 connect(m_findFileAction
, SIGNAL(triggered()), this, SLOT(slotFindFile()));
217 if (KAuthorized::authorizeKAction("shell_access")) {
218 m_openTerminalAction
= actionCollection()->addAction("open_terminal");
219 m_openTerminalAction
->setIcon(KIcon("utilities-terminal"));
220 m_openTerminalAction
->setText(i18nc("@action:inmenu Tools", "Open &Terminal"));
221 connect(m_openTerminalAction
, SIGNAL(triggered()), SLOT(slotOpenTerminal()));
222 m_openTerminalAction
->setShortcut(Qt::Key_F4
);
226 void DolphinPart::createGoAction(const char* name
, const char* iconName
,
227 const QString
& text
, const QString
& url
,
228 QActionGroup
* actionGroup
)
230 KAction
* action
= actionCollection()->addAction(name
);
231 action
->setIcon(KIcon(iconName
));
232 action
->setText(text
);
233 action
->setData(url
);
234 action
->setActionGroup(actionGroup
);
237 void DolphinPart::slotGoTriggered(QAction
* action
)
239 const QString url
= action
->data().toString();
240 emit m_extension
->openUrlRequest(KUrl(url
));
243 void DolphinPart::slotSelectionChanged(const KFileItemList
& selection
)
245 const bool hasSelection
= !selection
.isEmpty();
247 QAction
* renameAction
= actionCollection()->action("rename");
248 QAction
* moveToTrashAction
= actionCollection()->action("move_to_trash");
249 QAction
* deleteAction
= actionCollection()->action("delete");
250 QAction
* editMimeTypeAction
= actionCollection()->action("editMimeType");
251 QAction
* propertiesAction
= actionCollection()->action("properties");
252 QAction
* deleteWithTrashShortcut
= actionCollection()->action("delete_shortcut"); // see DolphinViewActionHandler
255 stateChanged("has_no_selection");
257 emit m_extension
->enableAction("cut", false);
258 emit m_extension
->enableAction("copy", false);
259 deleteWithTrashShortcut
->setEnabled(false);
260 editMimeTypeAction
->setEnabled(false);
262 stateChanged("has_selection");
264 // TODO share this code with DolphinMainWindow::updateEditActions (and the desktop code)
266 KFileItemListProperties
capabilities(selection
);
267 const bool enableMoveToTrash
= capabilities
.isLocal() && capabilities
.supportsMoving();
269 renameAction
->setEnabled(capabilities
.supportsMoving());
270 moveToTrashAction
->setEnabled(enableMoveToTrash
);
271 deleteAction
->setEnabled(capabilities
.supportsDeleting());
272 deleteWithTrashShortcut
->setEnabled(capabilities
.supportsDeleting() && !enableMoveToTrash
);
273 editMimeTypeAction
->setEnabled(true);
274 propertiesAction
->setEnabled(true);
275 emit m_extension
->enableAction("cut", capabilities
.supportsMoving());
276 emit m_extension
->enableAction("copy", true);
280 void DolphinPart::updatePasteAction()
282 QPair
<bool, QString
> pasteInfo
= m_view
->pasteInfo();
283 emit m_extension
->enableAction( "paste", pasteInfo
.first
);
284 emit m_extension
->setActionText( "paste", pasteInfo
.second
);
287 KAboutData
* DolphinPart::createAboutData()
289 return new KAboutData("dolphinpart", "dolphin", ki18nc("@title", "Dolphin Part"), "0.1");
292 bool DolphinPart::openUrl(const KUrl
& url
)
294 bool reload
= arguments().reload();
295 // A bit of a workaround so that changing the namefilter works: force reload.
296 // Otherwise DolphinView wouldn't relist the URL, so nothing would happen.
297 if (m_nameFilter
!= m_view
->nameFilter())
299 if (m_view
->url() == url
&& !reload
) { // DolphinView won't do anything in that case, so don't emit started
302 setUrl(url
); // remember it at the KParts level
303 KUrl
visibleUrl(url
);
304 if (!m_nameFilter
.isEmpty()) {
305 visibleUrl
.addPath(m_nameFilter
);
307 QString prettyUrl
= visibleUrl
.pathOrUrl();
308 emit
setWindowCaption(prettyUrl
);
309 emit m_extension
->setLocationBarUrl(prettyUrl
);
310 emit
started(0); // get the wheel to spin
311 m_view
->setNameFilter(m_nameFilter
);
314 emit
aboutToOpenURL();
317 // Disable "Find File" and "Open Terminal" actions for non-file URLs,
318 // e.g. ftp, smb, etc. #279283
319 const bool isLocalUrl
= url
.isLocalFile();
320 m_findFileAction
->setEnabled(isLocalUrl
);
321 if (m_openTerminalAction
) {
322 m_openTerminalAction
->setEnabled(isLocalUrl
);
327 void DolphinPart::slotMessage(const QString
& msg
)
329 emit
setStatusBarText(msg
);
332 void DolphinPart::slotErrorMessage(const QString
& msg
)
336 //KMessageBox::error(m_view, msg);
339 void DolphinPart::slotRequestItemInfo(const KFileItem
& item
)
341 emit m_extension
->mouseOverInfo(item
);
345 ReadOnlyPart::setStatusBarText(item
.getStatusBarInfo());
349 void DolphinPart::slotItemActivated(const KFileItem
& item
)
351 KParts::OpenUrlArguments args
;
352 // Forget about the known mimetype if a target URL is used.
353 // Testcase: network:/ with a item (mimetype "inode/some-foo-service") pointing to a http URL (html)
354 if (item
.targetUrl() == item
.url()) {
355 args
.setMimeType(item
.mimetype());
358 // Ideally, konqueror should be changed to not require trustedSource for directory views,
359 // since the idea was not to need BrowserArguments for non-browser stuff...
360 KParts::BrowserArguments browserArgs
;
361 browserArgs
.trustedSource
= true;
362 emit m_extension
->openUrlRequest(item
.targetUrl(), args
, browserArgs
);
365 void DolphinPart::createNewWindow(const KUrl
& url
)
367 // TODO: Check issue N176832 for the missing QAIV signal; task 177399 - maybe this code
368 // should be moved into DolphinPart::slotItemActivated()
369 emit m_extension
->createNewWindow(url
);
372 void DolphinPart::slotOpenContextMenu(const QPoint
& pos
,
373 const KFileItem
& _item
,
375 const QList
<QAction
*>& customActions
)
377 KParts::BrowserExtension::PopupFlags popupFlags
= KParts::BrowserExtension::DefaultPopupItems
378 | KParts::BrowserExtension::ShowProperties
379 | KParts::BrowserExtension::ShowUrlOperations
;
381 KFileItem
item(_item
);
383 if (item
.isNull()) { // viewport context menu
384 popupFlags
|= KParts::BrowserExtension::ShowNavigationItems
| KParts::BrowserExtension::ShowUp
;
385 item
= m_view
->rootItem();
387 item
= KFileItem( S_IFDIR
, (mode_t
)-1, url() );
389 item
.setUrl(url()); // ensure we use the view url, not the canonical path (#213799)
392 // TODO: We should change the signature of the slots (and signals) for being able
393 // to tell for which items we want a popup.
395 if (m_view
->selectedItems().isEmpty()) {
398 items
= m_view
->selectedItems();
401 KFileItemListProperties
capabilities(items
);
403 KParts::BrowserExtension::ActionGroupMap actionGroups
;
404 QList
<QAction
*> editActions
;
405 editActions
+= m_view
->versionControlActions(m_view
->selectedItems());
406 editActions
+= customActions
;
408 if (!_item
.isNull()) { // only for context menu on one or more items
409 bool supportsDeleting
= capabilities
.supportsDeleting();
410 bool supportsMoving
= capabilities
.supportsMoving();
412 if (!supportsDeleting
) {
413 popupFlags
|= KParts::BrowserExtension::NoDeletion
;
416 if (supportsMoving
) {
417 editActions
.append(actionCollection()->action("rename"));
420 bool addTrash
= capabilities
.isLocal() && supportsMoving
;
422 if (supportsDeleting
) {
423 if ( !item
.isLocalFile() )
425 else if (QApplication::keyboardModifiers() & Qt::ShiftModifier
) {
430 KSharedConfig::Ptr globalConfig
= KSharedConfig::openConfig("kdeglobals", KConfig::IncludeGlobals
);
431 KConfigGroup
configGroup(globalConfig
, "KDE");
432 addDel
= configGroup
.readEntry("ShowDeleteCommand", false);
437 editActions
.append(actionCollection()->action("move_to_trash"));
439 editActions
.append(actionCollection()->action("delete"));
441 // Normally KonqPopupMenu only shows the "Create new" submenu in the current view
442 // since otherwise the created file would not be visible.
443 // But in treeview mode we should allow it.
444 if (m_view
->itemsExpandable())
445 popupFlags
|= KParts::BrowserExtension::ShowCreateDirectory
;
449 actionGroups
.insert("editactions", editActions
);
451 emit m_extension
->popupMenu(pos
,
453 KParts::OpenUrlArguments(),
454 KParts::BrowserArguments(),
459 void DolphinPart::slotDirectoryRedirection(const KUrl
& oldUrl
, const KUrl
& newUrl
)
461 //kDebug() << oldUrl << newUrl << "currentUrl=" << url();
462 if (oldUrl
.equals(url(), KUrl::CompareWithoutTrailingSlash
/* #207572 */)) {
463 KParts::ReadOnlyPart::setUrl(newUrl
);
464 const QString prettyUrl
= newUrl
.pathOrUrl();
465 emit m_extension
->setLocationBarUrl(prettyUrl
);
470 void DolphinPart::slotEditMimeType()
472 const KFileItemList items
= m_view
->selectedItems();
473 if (!items
.isEmpty()) {
474 KonqOperations::editMimeType(items
.first().mimetype(), m_view
);
478 void DolphinPart::slotSelectItemsMatchingPattern()
480 openSelectionDialog(i18nc("@title:window", "Select"),
481 i18n("Select all items matching this pattern:"),
485 void DolphinPart::slotUnselectItemsMatchingPattern()
487 openSelectionDialog(i18nc("@title:window", "Unselect"),
488 i18n("Unselect all items matching this pattern:"),
492 void DolphinPart::openSelectionDialog(const QString
& title
, const QString
& text
, bool selectItems
)
495 QString pattern
= KInputDialog::getText(title
, text
, "*", &okClicked
, m_view
);
497 if (okClicked
&& !pattern
.isEmpty()) {
498 QRegExp
patternRegExp(pattern
, Qt::CaseSensitive
, QRegExp::Wildcard
);
499 m_view
->selectItems(patternRegExp
, selectItems
);
503 void DolphinPart::setCurrentViewMode(const QString
& viewModeName
)
505 QAction
* action
= actionCollection()->action(viewModeName
);
510 QString
DolphinPart::currentViewMode() const
512 return m_actionHandler
->currentViewModeActionName();
515 void DolphinPart::setNameFilter(const QString
& nameFilter
)
517 // This is the "/home/dfaure/*.diff" kind of name filter (KDirLister::setNameFilter)
518 // which is unrelated to DolphinView::setNameFilter which is substring filtering in a proxy.
519 m_nameFilter
= nameFilter
;
520 // TODO save/restore name filter in saveState/restoreState like KonqDirPart did in kde3?
523 void DolphinPart::slotOpenTerminal()
525 QString
dir(QDir::homePath());
529 // If the given directory is not local, it can still be the URL of an
530 // ioslave using UDS_LOCAL_PATH which to be converted first.
531 u
= KIO::NetAccess::mostLocalUrl(u
, widget());
533 //If the URL is local after the above conversion, set the directory.
534 if (u
.isLocalFile()) {
535 dir
= u
.toLocalFile();
538 KToolInvocation::invokeTerminal(QString(), dir
);
541 void DolphinPart::slotFindFile()
543 KRun::run("kfind", url(), widget());
546 void DolphinPart::updateNewMenu()
548 // As requested by KNewFileMenu :
549 m_newFileMenu
->checkUpToDate();
550 m_newFileMenu
->setViewShowsHiddenFiles(m_view
->hiddenFilesShown());
551 // And set the files that the menu apply on :
552 m_newFileMenu
->setPopupFiles(url());
555 void DolphinPart::updateStatusBar()
557 emit
ReadOnlyPart::setStatusBarText(m_view
->statusBarText());
560 void DolphinPart::updateProgress(int percent
)
562 m_extension
->loadingProgress(percent
);
565 void DolphinPart::createDirectory()
567 m_newFileMenu
->setViewShowsHiddenFiles(m_view
->hiddenFilesShown());
568 m_newFileMenu
->setPopupFiles(url());
569 m_newFileMenu
->createDirectory();
572 void DolphinPart::setFilesToSelect(const KUrl::List
& files
)
574 if (files
.isEmpty()) {
578 m_view
->markUrlsAsSelected(files
);
579 m_view
->markUrlAsCurrent(files
.at(0));
584 void DolphinPartBrowserExtension::restoreState(QDataStream
&stream
)
586 KParts::BrowserExtension::restoreState(stream
);
587 m_part
->view()->restoreState(stream
);
590 void DolphinPartBrowserExtension::saveState(QDataStream
&stream
)
592 KParts::BrowserExtension::saveState(stream
);
593 m_part
->view()->saveState(stream
);
596 void DolphinPartBrowserExtension::cut()
598 m_part
->view()->cutSelectedItems();
601 void DolphinPartBrowserExtension::copy()
603 m_part
->view()->copySelectedItems();
606 void DolphinPartBrowserExtension::paste()
608 m_part
->view()->paste();
611 void DolphinPartBrowserExtension::pasteTo(const KUrl
&)
613 m_part
->view()->pasteIntoFolder();
616 void DolphinPartBrowserExtension::reparseConfiguration()
618 m_part
->view()->readSettings();
623 DolphinPartFileInfoExtension::DolphinPartFileInfoExtension(DolphinPart
* part
)
624 : KParts::FileInfoExtension(part
)
628 DolphinPart
* DolphinPartFileInfoExtension::part() const
630 return static_cast<DolphinPart
*>(parent());
633 bool DolphinPartFileInfoExtension::hasSelection() const
635 return part()->view()->selectedItemsCount() > 0;
638 KParts::FileInfoExtension::QueryModes
DolphinPartFileInfoExtension::supportedQueryModes() const
640 return (KParts::FileInfoExtension::AllItems
| KParts::FileInfoExtension::SelectedItems
);
643 KFileItemList
DolphinPartFileInfoExtension::queryFor(KParts::FileInfoExtension::QueryMode mode
) const
647 if (mode
== KParts::FileInfoExtension::None
)
650 if (!(supportedQueryModes() & mode
))
654 case KParts::FileInfoExtension::SelectedItems
:
656 return part()->view()->selectedItems();
658 case KParts::FileInfoExtension::AllItems
:
659 return part()->view()->items();
667 #if KDE_IS_VERSION(4, 9, 2)
669 DolphinPartListingFilterExtension::DolphinPartListingFilterExtension (DolphinPart
* part
)
670 : KParts::ListingFilterExtension(part
)
675 KParts::ListingFilterExtension::FilterModes
DolphinPartListingFilterExtension::supportedFilterModes() const
677 return (KParts::ListingFilterExtension::MimeType
|
678 KParts::ListingFilterExtension::SubString
|
679 KParts::ListingFilterExtension::WildCard
);
682 bool DolphinPartListingFilterExtension::supportsMultipleFilters (KParts::ListingFilterExtension::FilterMode mode
) const
684 if (mode
== KParts::ListingFilterExtension::MimeType
)
690 QVariant
DolphinPartListingFilterExtension::filter (KParts::ListingFilterExtension::FilterMode mode
) const
695 case KParts::ListingFilterExtension::MimeType
:
696 result
= m_part
->view()->mimeTypeFilters();
698 case KParts::ListingFilterExtension::SubString
:
699 case KParts::ListingFilterExtension::WildCard
:
700 result
= m_part
->view()->nameFilter();
709 void DolphinPartListingFilterExtension::setFilter (KParts::ListingFilterExtension::FilterMode mode
, const QVariant
& filter
)
712 case KParts::ListingFilterExtension::MimeType
:
713 m_part
->view()->setMimeTypeFilters(filter
.toStringList());
715 case KParts::ListingFilterExtension::SubString
:
716 case KParts::ListingFilterExtension::WildCard
:
717 m_part
->view()->setNameFilter(filter
.toString());
726 DolphinPartListingNotificationExtension::DolphinPartListingNotificationExtension(DolphinPart
* part
)
727 :KParts::ListingNotificationExtension(part
)
731 KParts::ListingNotificationExtension::NotificationEventTypes
DolphinPartListingNotificationExtension::supportedNotificationEventTypes() const
733 return (KParts::ListingNotificationExtension::ItemsAdded
|
734 KParts::ListingNotificationExtension::ItemsDeleted
);
737 void DolphinPartListingNotificationExtension::slotNewItems(const KFileItemList
& items
)
739 emit
listingEvent(KParts::ListingNotificationExtension::ItemsAdded
, items
);
742 void DolphinPartListingNotificationExtension::slotItemsDeleted(const KFileItemList
& items
)
744 emit
listingEvent(KParts::ListingNotificationExtension::ItemsDeleted
, items
);
749 #include "dolphinpart.moc"