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