]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinpart.cpp
KDirModel takes ownership of the directory lister, so don't delete the directory...
[dolphin.git] / src / dolphinpart.cpp
1 /* This file is part of the KDE project
2 Copyright (c) 2007 David Faure <faure@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18 */
19
20 #include "dolphinpart.h"
21
22 #include <kfileitemlistproperties.h>
23 #include <konq_operations.h>
24
25 #include <kaboutdata.h>
26 #include <kactioncollection.h>
27 #include <kconfiggroup.h>
28 #include <kdebug.h>
29 #include <kglobalsettings.h>
30 #include <kiconloader.h>
31 #include <klocale.h>
32 #include <kmessagebox.h>
33 #include <kpluginfactory.h>
34 #include <ktoggleaction.h>
35 #include <kio/netaccess.h>
36 #include <ktoolinvocation.h>
37 #include <kauthorized.h>
38 #include <knewfilemenu.h>
39 #include <kmenu.h>
40 #include <kinputdialog.h>
41
42 #include "settings/dolphinsettings.h"
43 #include "views/dolphinview.h"
44 #include "views/dolphinviewactionhandler.h"
45 #include "views/dolphinsortfilterproxymodel.h"
46 #include "views/dolphinmodel.h"
47 #include "views/dolphinnewfilemenuobserver.h"
48 #include "views/dolphinremoteencoding.h"
49 #include "views/dolphindirlister.h"
50
51 #include <QActionGroup>
52 #include <QApplication>
53 #include <QClipboard>
54
55 K_PLUGIN_FACTORY(DolphinPartFactory, registerPlugin<DolphinPart>();)
56 K_EXPORT_PLUGIN(DolphinPartFactory("dolphinpart", "dolphin"))
57
58 DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantList& args)
59 : KParts::ReadOnlyPart(parent)
60 {
61 Q_UNUSED(args)
62 setComponentData(DolphinPartFactory::componentData(), false);
63 m_extension = new DolphinPartBrowserExtension(this);
64
65 // make sure that other apps using this part find Dolphin's view-file-columns icons
66 KIconLoader::global()->addAppDir("dolphin");
67
68 m_dirLister = new DolphinDirLister;
69 m_dirLister->setAutoUpdate(true);
70 if (parentWidget) {
71 m_dirLister->setMainWindow(parentWidget->window());
72 }
73 m_dirLister->setDelayedMimeTypes(true);
74
75 connect(m_dirLister, SIGNAL(completed(KUrl)), this, SLOT(slotCompleted(KUrl)));
76 connect(m_dirLister, SIGNAL(canceled(KUrl)), this, SLOT(slotCanceled(KUrl)));
77 connect(m_dirLister, SIGNAL(percent(int)), this, SLOT(updateProgress(int)));
78 connect(m_dirLister, SIGNAL(errorMessage(QString)), this, SLOT(slotErrorMessage(QString)));
79
80 m_dolphinModel = new DolphinModel(this);
81 m_dolphinModel->setDirLister(m_dirLister); // m_dolphinModel takes ownership of m_dirLister
82
83 m_proxyModel = new DolphinSortFilterProxyModel(this);
84 m_proxyModel->setSourceModel(m_dolphinModel);
85
86 m_view = new DolphinView(parentWidget, KUrl(), m_proxyModel);
87 m_view->setTabsForFilesEnabled(true);
88 setWidget(m_view);
89
90 setXMLFile("dolphinpart.rc");
91
92 connect(m_view, SIGNAL(infoMessage(QString)),
93 this, SLOT(slotMessage(QString)));
94 connect(m_view, SIGNAL(operationCompletedMessage(QString)),
95 this, SLOT(slotMessage(QString)));
96 connect(m_view, SIGNAL(errorMessage(QString)),
97 this, SLOT(slotErrorMessage(QString)));
98 connect(m_view, SIGNAL(itemTriggered(KFileItem)),
99 this, SLOT(slotItemTriggered(KFileItem)));
100 connect(m_view, SIGNAL(tabRequested(KUrl)),
101 this, SLOT(createNewWindow(KUrl)));
102 connect(m_view, SIGNAL(requestContextMenu(KFileItem,KUrl,QList<QAction*>)),
103 this, SLOT(slotOpenContextMenu(KFileItem,KUrl,QList<QAction*>)));
104 connect(m_view, SIGNAL(selectionChanged(KFileItemList)),
105 m_extension, SIGNAL(selectionInfo(KFileItemList)));
106 connect(m_view, SIGNAL(selectionChanged(KFileItemList)),
107 this, SLOT(slotSelectionChanged(KFileItemList)));
108 connect(m_view, SIGNAL(requestItemInfo(KFileItem)),
109 this, SLOT(slotRequestItemInfo(KFileItem)));
110 connect(m_view, SIGNAL(modeChanged()),
111 this, SIGNAL(viewModeChanged())); // relay signal
112 connect(m_view, SIGNAL(redirection(KUrl, KUrl)),
113 this, SLOT(slotRedirection(KUrl, KUrl)));
114
115 // Watch for changes that should result in updates to the
116 // status bar text.
117 connect(m_dirLister, SIGNAL(itemsDeleted(const KFileItemList&)),
118 this, SLOT(updateStatusBar()));
119 connect(m_dirLister, SIGNAL(clear()),
120 this, SLOT(updateStatusBar()));
121 connect(m_view, SIGNAL(selectionChanged(const KFileItemList)),
122 this, SLOT(updateStatusBar()));
123
124 m_actionHandler = new DolphinViewActionHandler(actionCollection(), this);
125 m_actionHandler->setCurrentView(m_view);
126 connect(m_actionHandler, SIGNAL(createDirectory()), SLOT(createDirectory()));
127
128 m_remoteEncoding = new DolphinRemoteEncoding(this, m_actionHandler);
129 connect(this, SIGNAL(aboutToOpenURL()),
130 m_remoteEncoding, SLOT(slotAboutToOpenUrl()));
131
132 QClipboard* clipboard = QApplication::clipboard();
133 connect(clipboard, SIGNAL(dataChanged()),
134 this, SLOT(updatePasteAction()));
135
136 createActions();
137 m_actionHandler->updateViewActions();
138 slotSelectionChanged(KFileItemList()); // initially disable selection-dependent actions
139
140 // TODO there was a "always open a new window" (when clicking on a directory) setting in konqueror
141 // (sort of spacial navigation)
142
143 loadPlugins(this, this, componentData());
144
145 }
146
147 DolphinPart::~DolphinPart()
148 {
149 DolphinSettings::instance().save();
150 DolphinNewFileMenuObserver::instance().detach(m_newFileMenu);
151 }
152
153 void DolphinPart::createActions()
154 {
155 // Edit menu
156
157 m_newFileMenu = new KNewFileMenu(actionCollection(), "new_menu", this);
158 m_newFileMenu->setParentWidget(widget());
159 DolphinNewFileMenuObserver::instance().attach(m_newFileMenu);
160 connect(m_newFileMenu->menu(), SIGNAL(aboutToShow()),
161 this, SLOT(updateNewMenu()));
162
163 KAction *editMimeTypeAction = actionCollection()->addAction( "editMimeType" );
164 editMimeTypeAction->setText( i18nc("@action:inmenu Edit", "&Edit File Type..." ) );
165 connect(editMimeTypeAction, SIGNAL(triggered()), SLOT(slotEditMimeType()));
166
167 KAction* selectItemsMatching = actionCollection()->addAction("select_items_matching");
168 selectItemsMatching->setText(i18nc("@action:inmenu Edit", "Select Items Matching..."));
169 selectItemsMatching->setShortcut(Qt::CTRL | Qt::Key_S);
170 connect(selectItemsMatching, SIGNAL(triggered()), this, SLOT(slotSelectItemsMatchingPattern()));
171
172 KAction* unselectItemsMatching = actionCollection()->addAction("unselect_items_matching");
173 unselectItemsMatching->setText(i18nc("@action:inmenu Edit", "Unselect Items Matching..."));
174 connect(unselectItemsMatching, SIGNAL(triggered()), this, SLOT(slotUnselectItemsMatchingPattern()));
175
176 actionCollection()->addAction(KStandardAction::SelectAll, "select_all", m_view, SLOT(selectAll()));
177
178 KAction* unselectAll = actionCollection()->addAction("unselect_all");
179 unselectAll->setText(i18nc("@action:inmenu Edit", "Unselect All"));
180 connect(unselectAll, SIGNAL(triggered()), m_view, SLOT(clearSelection()));
181
182 KAction* invertSelection = actionCollection()->addAction("invert_selection");
183 invertSelection->setText(i18nc("@action:inmenu Edit", "Invert Selection"));
184 invertSelection->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_A);
185 connect(invertSelection, SIGNAL(triggered()), m_view, SLOT(invertSelection()));
186
187 // View menu: all done by DolphinViewActionHandler
188
189 // Go menu
190
191 QActionGroup* goActionGroup = new QActionGroup(this);
192 connect(goActionGroup, SIGNAL(triggered(QAction*)),
193 this, SLOT(slotGoTriggered(QAction*)));
194
195 createGoAction("go_applications", "start-here-kde",
196 i18nc("@action:inmenu Go", "App&lications"), QString("programs:/"),
197 goActionGroup);
198 createGoAction("go_network_folders", "folder-remote",
199 i18nc("@action:inmenu Go", "&Network Folders"), QString("remote:/"),
200 goActionGroup);
201 createGoAction("go_settings", "preferences-system",
202 i18nc("@action:inmenu Go", "Sett&ings"), QString("settings:/"),
203 goActionGroup);
204 createGoAction("go_trash", "user-trash",
205 i18nc("@action:inmenu Go", "Trash"), QString("trash:/"),
206 goActionGroup);
207 createGoAction("go_autostart", "",
208 i18nc("@action:inmenu Go", "Autostart"), KGlobalSettings::autostartPath(),
209 goActionGroup);
210
211 // Tools menu
212 if (KAuthorized::authorizeKAction("shell_access")) {
213 KAction* action = actionCollection()->addAction("open_terminal");
214 action->setIcon(KIcon("utilities-terminal"));
215 action->setText(i18nc("@action:inmenu Tools", "Open &Terminal"));
216 connect(action, SIGNAL(triggered()), SLOT(slotOpenTerminal()));
217 action->setShortcut(Qt::Key_F4);
218 }
219
220 }
221
222 void DolphinPart::createGoAction(const char* name, const char* iconName,
223 const QString& text, const QString& url,
224 QActionGroup* actionGroup)
225 {
226 KAction* action = actionCollection()->addAction(name);
227 action->setIcon(KIcon(iconName));
228 action->setText(text);
229 action->setData(url);
230 action->setActionGroup(actionGroup);
231 }
232
233 void DolphinPart::slotGoTriggered(QAction* action)
234 {
235 const QString url = action->data().toString();
236 emit m_extension->openUrlRequest(KUrl(url));
237 }
238
239 void DolphinPart::slotSelectionChanged(const KFileItemList& selection)
240 {
241 const bool hasSelection = !selection.isEmpty();
242
243 QAction* renameAction = actionCollection()->action("rename");
244 QAction* moveToTrashAction = actionCollection()->action("move_to_trash");
245 QAction* deleteAction = actionCollection()->action("delete");
246 QAction* editMimeTypeAction = actionCollection()->action("editMimeType");
247 QAction* propertiesAction = actionCollection()->action("properties");
248 QAction* deleteWithTrashShortcut = actionCollection()->action("delete_shortcut"); // see DolphinViewActionHandler
249
250 if (!hasSelection) {
251 stateChanged("has_no_selection");
252
253 emit m_extension->enableAction("cut", false);
254 emit m_extension->enableAction("copy", false);
255 deleteWithTrashShortcut->setEnabled(false);
256 editMimeTypeAction->setEnabled(false);
257 } else {
258 stateChanged("has_selection");
259
260 // TODO share this code with DolphinMainWindow::updateEditActions (and the desktop code)
261 // in libkonq
262 KFileItemListProperties capabilities(selection);
263 const bool enableMoveToTrash = capabilities.isLocal() && capabilities.supportsMoving();
264
265 renameAction->setEnabled(capabilities.supportsMoving());
266 moveToTrashAction->setEnabled(enableMoveToTrash);
267 deleteAction->setEnabled(capabilities.supportsDeleting());
268 deleteWithTrashShortcut->setEnabled(capabilities.supportsDeleting() && !enableMoveToTrash);
269 editMimeTypeAction->setEnabled(true);
270 propertiesAction->setEnabled(true);
271 emit m_extension->enableAction("cut", capabilities.supportsMoving());
272 emit m_extension->enableAction("copy", true);
273 }
274 }
275
276 void DolphinPart::updatePasteAction()
277 {
278 QPair<bool, QString> pasteInfo = m_view->pasteInfo();
279 emit m_extension->enableAction( "paste", pasteInfo.first );
280 emit m_extension->setActionText( "paste", pasteInfo.second );
281 }
282
283 KAboutData* DolphinPart::createAboutData()
284 {
285 return new KAboutData("dolphinpart", "dolphin", ki18nc("@title", "Dolphin Part"), "0.1");
286 }
287
288 bool DolphinPart::openUrl(const KUrl& url)
289 {
290 bool reload = arguments().reload();
291 // A bit of a workaround so that changing the namefilter works: force reload.
292 // Otherwise DolphinView wouldn't relist the URL, so nothing would happen.
293 if (m_nameFilter != m_dirLister->nameFilter())
294 reload = true;
295 if (m_view->url() == url && !reload) { // DolphinView won't do anything in that case, so don't emit started
296 return true;
297 }
298 setUrl(url); // remember it at the KParts level
299 KUrl visibleUrl(url);
300 if (!m_nameFilter.isEmpty()) {
301 visibleUrl.addPath(m_nameFilter);
302 }
303 QString prettyUrl = visibleUrl.pathOrUrl();
304 emit setWindowCaption(prettyUrl);
305 emit m_extension->setLocationBarUrl(prettyUrl);
306 emit started(0); // get the wheel to spin
307 m_dirLister->setNameFilter(m_nameFilter);
308 m_view->setUrl(url);
309 updatePasteAction();
310 emit aboutToOpenURL();
311 if (reload)
312 m_view->reload();
313 return true;
314 }
315
316 void DolphinPart::slotCompleted(const KUrl& url)
317 {
318 Q_UNUSED(url)
319 emit completed();
320 }
321
322 void DolphinPart::slotCanceled(const KUrl& url)
323 {
324 slotCompleted(url);
325 }
326
327 void DolphinPart::slotMessage(const QString& msg)
328 {
329 emit setStatusBarText(msg);
330 }
331
332 void DolphinPart::slotErrorMessage(const QString& msg)
333 {
334 kDebug() << msg;
335 emit canceled(msg);
336 //KMessageBox::error(m_view, msg);
337 }
338
339 void DolphinPart::slotRequestItemInfo(const KFileItem& item)
340 {
341 emit m_extension->mouseOverInfo(item);
342 if (item.isNull()) {
343 updateStatusBar();
344 } else {
345 ReadOnlyPart::setStatusBarText(item.getStatusBarInfo());
346 }
347 }
348
349 void DolphinPart::slotItemTriggered(const KFileItem& item)
350 {
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());
356 }
357
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);
363 }
364
365 void DolphinPart::createNewWindow(const KUrl& url)
366 {
367 // TODO: Check issue N176832 for the missing QAIV signal; task 177399 - maybe this code
368 // should be moved into DolphinPart::slotItemTriggered()
369 emit m_extension->createNewWindow(url);
370 }
371
372 void DolphinPart::slotOpenContextMenu(const KFileItem& _item,
373 const KUrl&,
374 const QList<QAction*>& customActions)
375 {
376 KParts::BrowserExtension::PopupFlags popupFlags = KParts::BrowserExtension::DefaultPopupItems
377 | KParts::BrowserExtension::ShowProperties
378 | KParts::BrowserExtension::ShowUrlOperations;
379
380 KFileItem item(_item);
381
382 if (item.isNull()) { // viewport context menu
383 popupFlags |= KParts::BrowserExtension::ShowNavigationItems | KParts::BrowserExtension::ShowUp;
384 item = m_dirLister->rootItem();
385 if (item.isNull())
386 item = KFileItem( S_IFDIR, (mode_t)-1, url() );
387 else
388 item.setUrl(url()); // ensure we use the view url, not the canonical path (#213799)
389 }
390
391 // TODO: We should change the signature of the slots (and signals) for being able
392 // to tell for which items we want a popup.
393 KFileItemList items;
394 if (m_view->selectedItems().isEmpty()) {
395 items.append(item);
396 } else {
397 items = m_view->selectedItems();
398 }
399
400 KFileItemListProperties capabilities(items);
401
402 KParts::BrowserExtension::ActionGroupMap actionGroups;
403 QList<QAction *> editActions;
404 editActions += m_view->versionControlActions(m_view->selectedItems());
405 editActions += customActions;
406
407 if (!_item.isNull()) { // only for context menu on one or more items
408 bool supportsDeleting = capabilities.supportsDeleting();
409 bool supportsMoving = capabilities.supportsMoving();
410
411 if (!supportsDeleting) {
412 popupFlags |= KParts::BrowserExtension::NoDeletion;
413 }
414
415 if (supportsMoving) {
416 editActions.append(actionCollection()->action("rename"));
417 }
418
419 bool addTrash = capabilities.isLocal() && supportsMoving;
420 bool addDel = false;
421 if (supportsDeleting) {
422 if ( !item.isLocalFile() )
423 addDel = true;
424 else if (QApplication::keyboardModifiers() & Qt::ShiftModifier) {
425 addTrash = false;
426 addDel = true;
427 }
428 else {
429 KSharedConfig::Ptr globalConfig = KSharedConfig::openConfig("kdeglobals", KConfig::IncludeGlobals);
430 KConfigGroup configGroup(globalConfig, "KDE");
431 addDel = configGroup.readEntry("ShowDeleteCommand", false);
432 }
433 }
434
435 if (addTrash)
436 editActions.append(actionCollection()->action("move_to_trash"));
437 if (addDel)
438 editActions.append(actionCollection()->action("delete"));
439
440 // Normally KonqPopupMenu only shows the "Create new" submenu in the current view
441 // since otherwise the created file would not be visible.
442 // But in treeview mode we should allow it.
443 if (m_view->itemsExpandable())
444 popupFlags |= KParts::BrowserExtension::ShowCreateDirectory;
445
446 }
447
448 actionGroups.insert("editactions", editActions);
449
450 emit m_extension->popupMenu(QCursor::pos(),
451 items,
452 KParts::OpenUrlArguments(),
453 KParts::BrowserArguments(),
454 popupFlags,
455 actionGroups);
456 }
457
458 void DolphinPart::slotRedirection(const KUrl& oldUrl, const KUrl& newUrl)
459 {
460 //kDebug() << oldUrl << newUrl << "currentUrl=" << url();
461 if (oldUrl.equals(url(), KUrl::CompareWithoutTrailingSlash /* #207572 */)) {
462 KParts::ReadOnlyPart::setUrl(newUrl);
463 const QString prettyUrl = newUrl.pathOrUrl();
464 emit m_extension->setLocationBarUrl(prettyUrl);
465 }
466 }
467
468 ////
469
470 void DolphinPartBrowserExtension::restoreState(QDataStream &stream)
471 {
472 KParts::BrowserExtension::restoreState(stream);
473 m_part->view()->restoreState(stream);
474 }
475
476 void DolphinPartBrowserExtension::saveState(QDataStream &stream)
477 {
478 KParts::BrowserExtension::saveState(stream);
479 m_part->view()->saveState(stream);
480 }
481
482 void DolphinPartBrowserExtension::cut()
483 {
484 m_part->view()->cutSelectedItems();
485 }
486
487 void DolphinPartBrowserExtension::copy()
488 {
489 m_part->view()->copySelectedItems();
490 }
491
492 void DolphinPartBrowserExtension::paste()
493 {
494 m_part->view()->paste();
495 }
496
497 void DolphinPartBrowserExtension::pasteTo(const KUrl&)
498 {
499 m_part->view()->pasteIntoFolder();
500 }
501
502 void DolphinPartBrowserExtension::reparseConfiguration()
503 {
504 m_part->view()->refresh();
505 }
506
507 ////
508
509 void DolphinPart::slotEditMimeType()
510 {
511 const KFileItemList items = m_view->selectedItems();
512 if (!items.isEmpty()) {
513 KonqOperations::editMimeType(items.first().mimetype(), m_view);
514 }
515 }
516
517 void DolphinPart::slotSelectItemsMatchingPattern()
518 {
519 openSelectionDialog(i18nc("@title:window", "Select"),
520 i18n("Select all items matching this pattern:"),
521 QItemSelectionModel::Select);
522 }
523
524 void DolphinPart::slotUnselectItemsMatchingPattern()
525 {
526 openSelectionDialog(i18nc("@title:window", "Unselect"),
527 i18n("Unselect all items matching this pattern:"),
528 QItemSelectionModel::Deselect);
529 }
530
531 void DolphinPart::openSelectionDialog(const QString& title, const QString& text, QItemSelectionModel::SelectionFlags command)
532 {
533 bool okClicked;
534 QString pattern = KInputDialog::getText(title, text, "*", &okClicked, m_view);
535
536 if (okClicked && !pattern.isEmpty()) {
537 QRegExp patternRegExp(pattern, Qt::CaseSensitive, QRegExp::Wildcard);
538 QItemSelection matchingIndexes = childrenMatchingPattern(QModelIndex(), patternRegExp);
539 m_view->selectionModel()->select(matchingIndexes, command);
540 }
541 }
542
543 QItemSelection DolphinPart::childrenMatchingPattern(const QModelIndex& parent, const QRegExp& patternRegExp)
544 {
545 QItemSelection matchingIndexes;
546 int numRows = m_proxyModel->rowCount(parent);
547
548 for (int row = 0; row < numRows; row++) {
549 QModelIndex index = m_proxyModel->index(row, 0, parent);
550 QModelIndex sourceIndex = m_proxyModel->mapToSource(index);
551
552 if (sourceIndex.isValid() && patternRegExp.exactMatch(m_dolphinModel->data(sourceIndex).toString())) {
553 matchingIndexes += QItemSelectionRange(index);
554 }
555
556 if (m_proxyModel->hasChildren(index)) {
557 matchingIndexes += childrenMatchingPattern(index, patternRegExp);
558 }
559 }
560
561 return matchingIndexes;
562 }
563
564 void DolphinPart::setCurrentViewMode(const QString& viewModeName)
565 {
566 QAction* action = actionCollection()->action(viewModeName);
567 Q_ASSERT(action);
568 action->trigger();
569 }
570
571 QString DolphinPart::currentViewMode() const
572 {
573 return m_actionHandler->currentViewModeActionName();
574 }
575
576 void DolphinPart::setNameFilter(const QString& nameFilter)
577 {
578 // This is the "/home/dfaure/*.diff" kind of name filter (KDirLister::setNameFilter)
579 // which is unrelated to DolphinView::setNameFilter which is substring filtering in a proxy.
580 m_nameFilter = nameFilter;
581 // TODO save/restore name filter in saveState/restoreState like KonqDirPart did in kde3?
582 }
583
584 void DolphinPart::slotOpenTerminal()
585 {
586 QString dir(QDir::homePath());
587
588 KUrl u(url());
589
590 // If the given directory is not local, it can still be the URL of an
591 // ioslave using UDS_LOCAL_PATH which to be converted first.
592 u = KIO::NetAccess::mostLocalUrl(u, widget());
593
594 //If the URL is local after the above conversion, set the directory.
595 if (u.isLocalFile()) {
596 dir = u.toLocalFile();
597 }
598
599 KToolInvocation::invokeTerminal(QString(), dir);
600 }
601
602 void DolphinPart::updateNewMenu()
603 {
604 // As requested by KNewFileMenu :
605 m_newFileMenu->checkUpToDate();
606 m_newFileMenu->setViewShowsHiddenFiles(m_view->showHiddenFiles());
607 // And set the files that the menu apply on :
608 m_newFileMenu->setPopupFiles(url());
609 }
610
611 void DolphinPart::updateStatusBar()
612 {
613 emit ReadOnlyPart::setStatusBarText(m_view->statusBarText());
614 }
615
616 void DolphinPart::updateProgress(int percent)
617 {
618 m_extension->loadingProgress(percent);
619 }
620
621 void DolphinPart::createDirectory()
622 {
623 m_newFileMenu->setViewShowsHiddenFiles(m_view->showHiddenFiles());
624 m_newFileMenu->setPopupFiles(url());
625 m_newFileMenu->createDirectory();
626 }
627
628 void DolphinPart::setFilesToSelect(const KUrl::List& files)
629 {
630 m_view->markUrlsAsSelected(files);
631 }
632
633 #include "dolphinpart.moc"