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