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);
123 new DolphinPartListingFilterExtension(this);
125 KDirLister
* lister
= m_view
->m_model
->m_dirLister
;
127 DolphinPartListingNotificationExtension
* notifyExt
= new DolphinPartListingNotificationExtension(this);
128 connect(lister
, SIGNAL(newItems(KFileItemList
)), notifyExt
, SLOT(slotNewItems(KFileItemList
)));
129 connect(lister
, SIGNAL(itemsDeleted(KFileItemList
)), notifyExt
, SLOT(slotItemsDeleted(KFileItemList
)));
131 kWarning() << "NULL KDirLister object! KParts::ListingNotificationExtension will NOT be supported";
135 m_actionHandler
->updateViewActions();
136 slotSelectionChanged(KFileItemList()); // initially disable selection-dependent actions
138 // TODO there was a "always open a new window" (when clicking on a directory) setting in konqueror
139 // (sort of spacial navigation)
141 loadPlugins(this, this, componentData());
144 DolphinPart::~DolphinPart()
146 DolphinNewFileMenuObserver::instance().detach(m_newFileMenu
);
149 void DolphinPart::createActions()
153 m_newFileMenu
= new KNewFileMenu(actionCollection(), "new_menu", this);
154 m_newFileMenu
->setParentWidget(widget());
155 DolphinNewFileMenuObserver::instance().attach(m_newFileMenu
);
156 connect(m_newFileMenu
->menu(), SIGNAL(aboutToShow()),
157 this, SLOT(updateNewMenu()));
159 KAction
*editMimeTypeAction
= actionCollection()->addAction( "editMimeType" );
160 editMimeTypeAction
->setText( i18nc("@action:inmenu Edit", "&Edit File Type..." ) );
161 connect(editMimeTypeAction
, SIGNAL(triggered()), SLOT(slotEditMimeType()));
163 KAction
* selectItemsMatching
= actionCollection()->addAction("select_items_matching");
164 selectItemsMatching
->setText(i18nc("@action:inmenu Edit", "Select Items Matching..."));
165 selectItemsMatching
->setShortcut(Qt::CTRL
| Qt::Key_S
);
166 connect(selectItemsMatching
, SIGNAL(triggered()), this, SLOT(slotSelectItemsMatchingPattern()));
168 KAction
* unselectItemsMatching
= actionCollection()->addAction("unselect_items_matching");
169 unselectItemsMatching
->setText(i18nc("@action:inmenu Edit", "Unselect Items Matching..."));
170 connect(unselectItemsMatching
, SIGNAL(triggered()), this, SLOT(slotUnselectItemsMatchingPattern()));
172 actionCollection()->addAction(KStandardAction::SelectAll
, "select_all", m_view
, SLOT(selectAll()));
174 KAction
* unselectAll
= actionCollection()->addAction("unselect_all");
175 unselectAll
->setText(i18nc("@action:inmenu Edit", "Unselect All"));
176 connect(unselectAll
, SIGNAL(triggered()), m_view
, SLOT(clearSelection()));
178 KAction
* invertSelection
= actionCollection()->addAction("invert_selection");
179 invertSelection
->setText(i18nc("@action:inmenu Edit", "Invert Selection"));
180 invertSelection
->setShortcut(Qt::CTRL
| Qt::SHIFT
| Qt::Key_A
);
181 connect(invertSelection
, SIGNAL(triggered()), m_view
, SLOT(invertSelection()));
183 // View menu: all done by DolphinViewActionHandler
187 QActionGroup
* goActionGroup
= new QActionGroup(this);
188 connect(goActionGroup
, SIGNAL(triggered(QAction
*)),
189 this, SLOT(slotGoTriggered(QAction
*)));
191 createGoAction("go_applications", "start-here-kde",
192 i18nc("@action:inmenu Go", "App&lications"), QString("programs:/"),
194 createGoAction("go_network_folders", "folder-remote",
195 i18nc("@action:inmenu Go", "&Network Folders"), QString("remote:/"),
197 createGoAction("go_settings", "preferences-system",
198 i18nc("@action:inmenu Go", "Sett&ings"), QString("settings:/"),
200 createGoAction("go_trash", "user-trash",
201 i18nc("@action:inmenu Go", "Trash"), QString("trash:/"),
203 createGoAction("go_autostart", "",
204 i18nc("@action:inmenu Go", "Autostart"), KGlobalSettings::autostartPath(),
208 m_findFileAction
= actionCollection()->addAction("find_file");
209 m_findFileAction
->setText(i18nc("@action:inmenu Tools", "Find File..."));
210 m_findFileAction
->setShortcut(Qt::CTRL
| Qt::Key_F
);
211 m_findFileAction
->setIcon(KIcon("edit-find"));
212 connect(m_findFileAction
, SIGNAL(triggered()), this, SLOT(slotFindFile()));
214 if (KAuthorized::authorizeKAction("shell_access")) {
215 m_openTerminalAction
= actionCollection()->addAction("open_terminal");
216 m_openTerminalAction
->setIcon(KIcon("utilities-terminal"));
217 m_openTerminalAction
->setText(i18nc("@action:inmenu Tools", "Open &Terminal"));
218 connect(m_openTerminalAction
, SIGNAL(triggered()), SLOT(slotOpenTerminal()));
219 m_openTerminalAction
->setShortcut(Qt::Key_F4
);
223 void DolphinPart::createGoAction(const char* name
, const char* iconName
,
224 const QString
& text
, const QString
& url
,
225 QActionGroup
* actionGroup
)
227 KAction
* action
= actionCollection()->addAction(name
);
228 action
->setIcon(KIcon(iconName
));
229 action
->setText(text
);
230 action
->setData(url
);
231 action
->setActionGroup(actionGroup
);
234 void DolphinPart::slotGoTriggered(QAction
* action
)
236 const QString url
= action
->data().toString();
237 emit m_extension
->openUrlRequest(KUrl(url
));
240 void DolphinPart::slotSelectionChanged(const KFileItemList
& selection
)
242 const bool hasSelection
= !selection
.isEmpty();
244 QAction
* renameAction
= actionCollection()->action("rename");
245 QAction
* moveToTrashAction
= actionCollection()->action("move_to_trash");
246 QAction
* deleteAction
= actionCollection()->action("delete");
247 QAction
* editMimeTypeAction
= actionCollection()->action("editMimeType");
248 QAction
* propertiesAction
= actionCollection()->action("properties");
249 QAction
* deleteWithTrashShortcut
= actionCollection()->action("delete_shortcut"); // see DolphinViewActionHandler
252 stateChanged("has_no_selection");
254 emit m_extension
->enableAction("cut", false);
255 emit m_extension
->enableAction("copy", false);
256 deleteWithTrashShortcut
->setEnabled(false);
257 editMimeTypeAction
->setEnabled(false);
259 stateChanged("has_selection");
261 // TODO share this code with DolphinMainWindow::updateEditActions (and the desktop code)
263 KFileItemListProperties
capabilities(selection
);
264 const bool enableMoveToTrash
= capabilities
.isLocal() && capabilities
.supportsMoving();
266 renameAction
->setEnabled(capabilities
.supportsMoving());
267 moveToTrashAction
->setEnabled(enableMoveToTrash
);
268 deleteAction
->setEnabled(capabilities
.supportsDeleting());
269 deleteWithTrashShortcut
->setEnabled(capabilities
.supportsDeleting() && !enableMoveToTrash
);
270 editMimeTypeAction
->setEnabled(true);
271 propertiesAction
->setEnabled(true);
272 emit m_extension
->enableAction("cut", capabilities
.supportsMoving());
273 emit m_extension
->enableAction("copy", true);
277 void DolphinPart::updatePasteAction()
279 QPair
<bool, QString
> pasteInfo
= m_view
->pasteInfo();
280 emit m_extension
->enableAction( "paste", pasteInfo
.first
);
281 emit m_extension
->setActionText( "paste", pasteInfo
.second
);
284 KAboutData
* DolphinPart::createAboutData()
286 return new KAboutData("dolphinpart", "dolphin", ki18nc("@title", "Dolphin Part"), "0.1");
289 bool DolphinPart::openUrl(const KUrl
& url
)
291 bool reload
= arguments().reload();
292 // A bit of a workaround so that changing the namefilter works: force reload.
293 // Otherwise DolphinView wouldn't relist the URL, so nothing would happen.
294 if (m_nameFilter
!= m_view
->nameFilter())
296 if (m_view
->url() == url
&& !reload
) { // DolphinView won't do anything in that case, so don't emit started
299 setUrl(url
); // remember it at the KParts level
300 KUrl
visibleUrl(url
);
301 if (!m_nameFilter
.isEmpty()) {
302 visibleUrl
.addPath(m_nameFilter
);
304 QString prettyUrl
= visibleUrl
.pathOrUrl();
305 emit
setWindowCaption(prettyUrl
);
306 emit m_extension
->setLocationBarUrl(prettyUrl
);
307 emit
started(0); // get the wheel to spin
308 m_view
->setNameFilter(m_nameFilter
);
311 emit
aboutToOpenURL();
314 // Disable "Find File" and "Open Terminal" actions for non-file URLs,
315 // e.g. ftp, smb, etc. #279283
316 const bool isLocalUrl
= url
.isLocalFile();
317 m_findFileAction
->setEnabled(isLocalUrl
);
318 if (m_openTerminalAction
) {
319 m_openTerminalAction
->setEnabled(isLocalUrl
);
324 void DolphinPart::slotMessage(const QString
& msg
)
326 emit
setStatusBarText(msg
);
329 void DolphinPart::slotErrorMessage(const QString
& msg
)
333 //KMessageBox::error(m_view, msg);
336 void DolphinPart::slotRequestItemInfo(const KFileItem
& item
)
338 emit m_extension
->mouseOverInfo(item
);
342 ReadOnlyPart::setStatusBarText(item
.getStatusBarInfo());
346 void DolphinPart::slotItemActivated(const KFileItem
& item
)
348 KParts::OpenUrlArguments args
;
349 // Forget about the known mimetype if a target URL is used.
350 // Testcase: network:/ with a item (mimetype "inode/some-foo-service") pointing to a http URL (html)
351 if (item
.targetUrl() == item
.url()) {
352 args
.setMimeType(item
.mimetype());
355 // Ideally, konqueror should be changed to not require trustedSource for directory views,
356 // since the idea was not to need BrowserArguments for non-browser stuff...
357 KParts::BrowserArguments browserArgs
;
358 browserArgs
.trustedSource
= true;
359 emit m_extension
->openUrlRequest(item
.targetUrl(), args
, browserArgs
);
362 void DolphinPart::createNewWindow(const KUrl
& url
)
364 // TODO: Check issue N176832 for the missing QAIV signal; task 177399 - maybe this code
365 // should be moved into DolphinPart::slotItemActivated()
366 emit m_extension
->createNewWindow(url
);
369 void DolphinPart::slotOpenContextMenu(const QPoint
& pos
,
370 const KFileItem
& _item
,
372 const QList
<QAction
*>& customActions
)
374 KParts::BrowserExtension::PopupFlags popupFlags
= KParts::BrowserExtension::DefaultPopupItems
375 | KParts::BrowserExtension::ShowProperties
376 | KParts::BrowserExtension::ShowUrlOperations
;
378 KFileItem
item(_item
);
380 if (item
.isNull()) { // viewport context menu
381 popupFlags
|= KParts::BrowserExtension::ShowNavigationItems
| KParts::BrowserExtension::ShowUp
;
382 item
= m_view
->rootItem();
384 item
= KFileItem( S_IFDIR
, (mode_t
)-1, url() );
386 item
.setUrl(url()); // ensure we use the view url, not the canonical path (#213799)
389 // TODO: We should change the signature of the slots (and signals) for being able
390 // to tell for which items we want a popup.
392 if (m_view
->selectedItems().isEmpty()) {
395 items
= m_view
->selectedItems();
398 KFileItemListProperties
capabilities(items
);
400 KParts::BrowserExtension::ActionGroupMap actionGroups
;
401 QList
<QAction
*> editActions
;
402 editActions
+= m_view
->versionControlActions(m_view
->selectedItems());
403 editActions
+= customActions
;
405 if (!_item
.isNull()) { // only for context menu on one or more items
406 bool supportsDeleting
= capabilities
.supportsDeleting();
407 bool supportsMoving
= capabilities
.supportsMoving();
409 if (!supportsDeleting
) {
410 popupFlags
|= KParts::BrowserExtension::NoDeletion
;
413 if (supportsMoving
) {
414 editActions
.append(actionCollection()->action("rename"));
417 bool addTrash
= capabilities
.isLocal() && supportsMoving
;
419 if (supportsDeleting
) {
420 if ( !item
.isLocalFile() )
422 else if (QApplication::keyboardModifiers() & Qt::ShiftModifier
) {
427 KSharedConfig::Ptr globalConfig
= KSharedConfig::openConfig("kdeglobals", KConfig::IncludeGlobals
);
428 KConfigGroup
configGroup(globalConfig
, "KDE");
429 addDel
= configGroup
.readEntry("ShowDeleteCommand", false);
434 editActions
.append(actionCollection()->action("move_to_trash"));
436 editActions
.append(actionCollection()->action("delete"));
438 // Normally KonqPopupMenu only shows the "Create new" submenu in the current view
439 // since otherwise the created file would not be visible.
440 // But in treeview mode we should allow it.
441 if (m_view
->itemsExpandable())
442 popupFlags
|= KParts::BrowserExtension::ShowCreateDirectory
;
446 actionGroups
.insert("editactions", editActions
);
448 emit m_extension
->popupMenu(pos
,
450 KParts::OpenUrlArguments(),
451 KParts::BrowserArguments(),
456 void DolphinPart::slotDirectoryRedirection(const KUrl
& oldUrl
, const KUrl
& newUrl
)
458 //kDebug() << oldUrl << newUrl << "currentUrl=" << url();
459 if (oldUrl
.equals(url(), KUrl::CompareWithoutTrailingSlash
/* #207572 */)) {
460 KParts::ReadOnlyPart::setUrl(newUrl
);
461 const QString prettyUrl
= newUrl
.pathOrUrl();
462 emit m_extension
->setLocationBarUrl(prettyUrl
);
467 void DolphinPart::slotEditMimeType()
469 const KFileItemList items
= m_view
->selectedItems();
470 if (!items
.isEmpty()) {
471 KonqOperations::editMimeType(items
.first().mimetype(), m_view
);
475 void DolphinPart::slotSelectItemsMatchingPattern()
477 openSelectionDialog(i18nc("@title:window", "Select"),
478 i18n("Select all items matching this pattern:"),
482 void DolphinPart::slotUnselectItemsMatchingPattern()
484 openSelectionDialog(i18nc("@title:window", "Unselect"),
485 i18n("Unselect all items matching this pattern:"),
489 void DolphinPart::openSelectionDialog(const QString
& title
, const QString
& text
, bool selectItems
)
492 QString pattern
= KInputDialog::getText(title
, text
, "*", &okClicked
, m_view
);
494 if (okClicked
&& !pattern
.isEmpty()) {
495 QRegExp
patternRegExp(pattern
, Qt::CaseSensitive
, QRegExp::Wildcard
);
496 m_view
->selectItems(patternRegExp
, selectItems
);
500 void DolphinPart::setCurrentViewMode(const QString
& viewModeName
)
502 QAction
* action
= actionCollection()->action(viewModeName
);
507 QString
DolphinPart::currentViewMode() const
509 return m_actionHandler
->currentViewModeActionName();
512 void DolphinPart::setNameFilter(const QString
& nameFilter
)
514 // This is the "/home/dfaure/*.diff" kind of name filter (KDirLister::setNameFilter)
515 // which is unrelated to DolphinView::setNameFilter which is substring filtering in a proxy.
516 m_nameFilter
= nameFilter
;
517 // TODO save/restore name filter in saveState/restoreState like KonqDirPart did in kde3?
520 void DolphinPart::slotOpenTerminal()
522 QString
dir(QDir::homePath());
526 // If the given directory is not local, it can still be the URL of an
527 // ioslave using UDS_LOCAL_PATH which to be converted first.
528 u
= KIO::NetAccess::mostLocalUrl(u
, widget());
530 //If the URL is local after the above conversion, set the directory.
531 if (u
.isLocalFile()) {
532 dir
= u
.toLocalFile();
535 KToolInvocation::invokeTerminal(QString(), dir
);
538 void DolphinPart::slotFindFile()
540 KRun::run("kfind", url(), widget());
543 void DolphinPart::updateNewMenu()
545 // As requested by KNewFileMenu :
546 m_newFileMenu
->checkUpToDate();
547 m_newFileMenu
->setViewShowsHiddenFiles(m_view
->hiddenFilesShown());
548 // And set the files that the menu apply on :
549 m_newFileMenu
->setPopupFiles(url());
552 void DolphinPart::updateStatusBar()
554 emit
ReadOnlyPart::setStatusBarText(m_view
->statusBarText());
557 void DolphinPart::updateProgress(int percent
)
559 m_extension
->loadingProgress(percent
);
562 void DolphinPart::createDirectory()
564 m_newFileMenu
->setViewShowsHiddenFiles(m_view
->hiddenFilesShown());
565 m_newFileMenu
->setPopupFiles(url());
566 m_newFileMenu
->createDirectory();
569 void DolphinPart::setFilesToSelect(const KUrl::List
& files
)
571 if (files
.isEmpty()) {
575 m_view
->markUrlsAsSelected(files
);
576 m_view
->markUrlAsCurrent(files
.at(0));
581 void DolphinPartBrowserExtension::restoreState(QDataStream
&stream
)
583 KParts::BrowserExtension::restoreState(stream
);
584 m_part
->view()->restoreState(stream
);
587 void DolphinPartBrowserExtension::saveState(QDataStream
&stream
)
589 KParts::BrowserExtension::saveState(stream
);
590 m_part
->view()->saveState(stream
);
593 void DolphinPartBrowserExtension::cut()
595 m_part
->view()->cutSelectedItems();
598 void DolphinPartBrowserExtension::copy()
600 m_part
->view()->copySelectedItems();
603 void DolphinPartBrowserExtension::paste()
605 m_part
->view()->paste();
608 void DolphinPartBrowserExtension::pasteTo(const KUrl
&)
610 m_part
->view()->pasteIntoFolder();
613 void DolphinPartBrowserExtension::reparseConfiguration()
615 m_part
->view()->readSettings();
620 DolphinPartFileInfoExtension::DolphinPartFileInfoExtension(DolphinPart
* part
)
621 : KParts::FileInfoExtension(part
)
625 DolphinPart
* DolphinPartFileInfoExtension::part() const
627 return static_cast<DolphinPart
*>(parent());
630 bool DolphinPartFileInfoExtension::hasSelection() const
632 return part()->view()->selectedItemsCount() > 0;
635 KParts::FileInfoExtension::QueryModes
DolphinPartFileInfoExtension::supportedQueryModes() const
637 return (KParts::FileInfoExtension::AllItems
| KParts::FileInfoExtension::SelectedItems
);
640 KFileItemList
DolphinPartFileInfoExtension::queryFor(KParts::FileInfoExtension::QueryMode mode
) const
644 if (mode
== KParts::FileInfoExtension::None
)
647 if (!(supportedQueryModes() & mode
))
651 case KParts::FileInfoExtension::SelectedItems
:
653 return part()->view()->selectedItems();
655 case KParts::FileInfoExtension::AllItems
:
656 return part()->view()->items();
664 DolphinPartListingFilterExtension::DolphinPartListingFilterExtension (DolphinPart
* part
)
665 : KParts::ListingFilterExtension(part
)
670 KParts::ListingFilterExtension::FilterModes
DolphinPartListingFilterExtension::supportedFilterModes() const
672 return (KParts::ListingFilterExtension::MimeType
|
673 KParts::ListingFilterExtension::SubString
|
674 KParts::ListingFilterExtension::WildCard
);
677 bool DolphinPartListingFilterExtension::supportsMultipleFilters (KParts::ListingFilterExtension::FilterMode mode
) const
679 if (mode
== KParts::ListingFilterExtension::MimeType
)
685 QVariant
DolphinPartListingFilterExtension::filter (KParts::ListingFilterExtension::FilterMode mode
) const
690 case KParts::ListingFilterExtension::MimeType
:
691 result
= m_part
->view()->mimeTypeFilters();
693 case KParts::ListingFilterExtension::SubString
:
694 case KParts::ListingFilterExtension::WildCard
:
695 result
= m_part
->view()->nameFilter();
704 void DolphinPartListingFilterExtension::setFilter (KParts::ListingFilterExtension::FilterMode mode
, const QVariant
& filter
)
707 case KParts::ListingFilterExtension::MimeType
:
708 m_part
->view()->setMimeTypeFilters(filter
.toStringList());
710 case KParts::ListingFilterExtension::SubString
:
711 case KParts::ListingFilterExtension::WildCard
:
712 m_part
->view()->setNameFilter(filter
.toString());
721 DolphinPartListingNotificationExtension::DolphinPartListingNotificationExtension(DolphinPart
* part
)
722 :KParts::ListingNotificationExtension(part
)
726 KParts::ListingNotificationExtension::NotificationEventTypes
DolphinPartListingNotificationExtension::supportedNotificationEventTypes() const
728 return (KParts::ListingNotificationExtension::ItemsAdded
|
729 KParts::ListingNotificationExtension::ItemsDeleted
);
732 void DolphinPartListingNotificationExtension::slotNewItems(const KFileItemList
& items
)
734 emit
listingEvent(KParts::ListingNotificationExtension::ItemsAdded
, items
);
737 void DolphinPartListingNotificationExtension::slotItemsDeleted(const KFileItemList
& items
)
739 emit
listingEvent(KParts::ListingNotificationExtension::ItemsDeleted
, items
);
742 #include "dolphinpart.moc"