]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinmainwindow.cpp
Per default QTreeView starts either a selection or a drag operation when dragging...
[dolphin.git] / src / dolphinmainwindow.cpp
1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at> *
3 * Copyright (C) 2006 by Stefan Monov <logixoul@gmail.com> *
4 * Copyright (C) 2006 by Cvetoslav Ludmiloff <ludmiloff@gmail.com> *
5 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the *
18 * Free Software Foundation, Inc., *
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
20 ***************************************************************************/
21
22 #include "dolphinmainwindow.h"
23 #include "dolphinviewactionhandler.h"
24 #include "dolphindropcontroller.h"
25
26 #include <config-nepomuk.h>
27
28 #include "dolphinapplication.h"
29 #include "dolphinfileplacesview.h"
30 #include "dolphinnewmenu.h"
31 #include "dolphinsettings.h"
32 #include "dolphinsettingsdialog.h"
33 #include "dolphinstatusbar.h"
34 #include "dolphinviewcontainer.h"
35 #include "fileitemcapabilities.h"
36 #include "infosidebarpage.h"
37 #include "metadatawidget.h"
38 #include "mainwindowadaptor.h"
39 #include "treeviewsidebarpage.h"
40 #include "viewproperties.h"
41
42 #ifndef Q_OS_WIN
43 #include "terminalsidebarpage.h"
44 #endif
45
46 #include "dolphin_generalsettings.h"
47 #include "dolphin_iconsmodesettings.h"
48
49 #include <kaction.h>
50 #include <kactioncollection.h>
51 #include <kconfig.h>
52 #include <kdesktopfile.h>
53 #include <kdeversion.h>
54 #include <kfiledialog.h>
55 #include <kfileplacesmodel.h>
56 #include <kglobal.h>
57 #include <kicon.h>
58 #include <kiconloader.h>
59 #include <kio/netaccess.h>
60 #include <kinputdialog.h>
61 #include <klocale.h>
62 #include <kmenu.h>
63 #include <kmenubar.h>
64 #include <kmessagebox.h>
65 #include <kurlnavigator.h>
66 #include <konqmimedata.h>
67 #include <kpropertiesdialog.h>
68 #include <kprotocolinfo.h>
69 #include <ktoggleaction.h>
70 #include <krun.h>
71 #include <kshell.h>
72 #include <kstandarddirs.h>
73 #include <kstatusbar.h>
74 #include <kstandardaction.h>
75 #include <ktabbar.h>
76 #include <kurl.h>
77 #include <kurlcombobox.h>
78
79 #include <QKeyEvent>
80 #include <QClipboard>
81 #include <QLineEdit>
82 #include <QSplitter>
83 #include <QDockWidget>
84
85 DolphinMainWindow::DolphinMainWindow(int id) :
86 KXmlGuiWindow(0),
87 m_newMenu(0),
88 m_showMenuBar(0),
89 m_tabBar(0),
90 m_activeViewContainer(0),
91 m_centralWidgetLayout(0),
92 m_id(id),
93 m_tabIndex(0),
94 m_viewTab(),
95 m_actionHandler(0)
96 {
97 setObjectName("Dolphin#");
98
99 m_viewTab.append(ViewTab());
100
101 new MainWindowAdaptor(this);
102 QDBusConnection::sessionBus().registerObject(QString("/dolphin/MainWindow%1").arg(m_id), this);
103
104 KIO::FileUndoManager* undoManager = KIO::FileUndoManager::self();
105 undoManager->setUiInterface(new UndoUiInterface());
106
107 connect(undoManager, SIGNAL(undoAvailable(bool)),
108 this, SLOT(slotUndoAvailable(bool)));
109 connect(undoManager, SIGNAL(undoTextChanged(const QString&)),
110 this, SLOT(slotUndoTextChanged(const QString&)));
111 connect(DolphinSettings::instance().placesModel(), SIGNAL(errorMessage(const QString&)),
112 this, SLOT(slotHandlePlacesError(const QString&)));
113 }
114
115 DolphinMainWindow::~DolphinMainWindow()
116 {
117 DolphinApplication::app()->removeMainWindow(this);
118 }
119
120 void DolphinMainWindow::toggleViews()
121 {
122 if (m_viewTab[m_tabIndex].primaryView == 0) {
123 return;
124 }
125
126 // move secondary view from the last position of the splitter
127 // to the first position
128 m_viewTab[m_tabIndex].splitter->insertWidget(0, m_viewTab[m_tabIndex].secondaryView);
129
130 DolphinViewContainer* container = m_viewTab[m_tabIndex].primaryView;
131 m_viewTab[m_tabIndex].primaryView = m_viewTab[m_tabIndex].secondaryView;
132 m_viewTab[m_tabIndex].secondaryView = container;
133 }
134
135 void DolphinMainWindow::slotDoingOperation(KIO::FileUndoManager::CommandType commandType)
136 {
137 clearStatusBar();
138 m_undoCommandTypes.append(commandType);
139 }
140
141 void DolphinMainWindow::refreshViews()
142 {
143 Q_ASSERT(m_viewTab[m_tabIndex].primaryView != 0);
144
145 // remember the current active view, as because of
146 // the refreshing the active view might change to
147 // the secondary view
148 DolphinViewContainer* activeViewContainer = m_activeViewContainer;
149
150 m_viewTab[m_tabIndex].primaryView->view()->refresh();
151 if (m_viewTab[m_tabIndex].secondaryView != 0) {
152 m_viewTab[m_tabIndex].secondaryView->view()->refresh();
153 }
154
155 setActiveViewContainer(activeViewContainer);
156 }
157
158 void DolphinMainWindow::dropUrls(const KUrl::List& urls,
159 const KUrl& destination)
160 {
161 DolphinDropController dropController(this);
162 connect(&dropController, SIGNAL(doingOperation(KIO::FileUndoManager::CommandType)),
163 this, SLOT(slotDoingOperation(KIO::FileUndoManager::CommandType)));
164 dropController.dropUrls(urls, destination);
165 }
166
167 void DolphinMainWindow::pasteIntoFolder()
168 {
169 m_activeViewContainer->view()->pasteIntoFolder();
170 }
171
172 void DolphinMainWindow::changeUrl(const KUrl& url)
173 {
174 DolphinViewContainer* view = activeViewContainer();
175 if (view != 0) {
176 view->setUrl(url);
177 updateEditActions();
178 updateViewActions();
179 updateGoActions();
180 setCaption(url.fileName());
181 if (m_viewTab.count() > 1) {
182 m_tabBar->setTabText(m_tabIndex, tabName(url));
183 }
184 emit urlChanged(url);
185 }
186 }
187
188 void DolphinMainWindow::changeSelection(const KFileItemList& selection)
189 {
190 activeViewContainer()->view()->changeSelection(selection);
191 }
192
193 void DolphinMainWindow::slotEditableStateChanged(bool editable)
194 {
195 KToggleAction* editableLocationAction =
196 static_cast<KToggleAction*>(actionCollection()->action("editable_location"));
197 editableLocationAction->setChecked(editable);
198 }
199
200 void DolphinMainWindow::slotSelectionChanged(const KFileItemList& selection)
201 {
202 updateEditActions();
203
204 Q_ASSERT(m_viewTab[m_tabIndex].primaryView != 0);
205 int selectedUrlsCount = m_viewTab[m_tabIndex].primaryView->view()->selectedUrls().count();
206 if (m_viewTab[m_tabIndex].secondaryView != 0) {
207 selectedUrlsCount += m_viewTab[m_tabIndex].secondaryView->view()->selectedUrls().count();
208 }
209
210 QAction* compareFilesAction = actionCollection()->action("compare_files");
211 if (selectedUrlsCount == 2) {
212 const bool kompareInstalled = !KGlobal::dirs()->findExe("kompare").isEmpty();
213 compareFilesAction->setEnabled(selectedUrlsCount == 2 && kompareInstalled);
214 } else {
215 compareFilesAction->setEnabled(false);
216 }
217
218 m_activeViewContainer->updateStatusBar();
219
220 emit selectionChanged(selection);
221 }
222
223 void DolphinMainWindow::slotRequestItemInfo(const KFileItem& item)
224 {
225 emit requestItemInfo(item);
226 }
227
228 void DolphinMainWindow::updateHistory()
229 {
230 const KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
231 const int index = urlNavigator->historyIndex();
232
233 QAction* backAction = actionCollection()->action("go_back");
234 if (backAction != 0) {
235 backAction->setEnabled(index < urlNavigator->historySize() - 1);
236 }
237
238 QAction* forwardAction = actionCollection()->action("go_forward");
239 if (forwardAction != 0) {
240 forwardAction->setEnabled(index > 0);
241 }
242 }
243
244 void DolphinMainWindow::updateFilterBarAction(bool show)
245 {
246 QAction* showFilterBarAction = actionCollection()->action("show_filter_bar");
247 showFilterBarAction->setChecked(show);
248 }
249
250 void DolphinMainWindow::openNewMainWindow()
251 {
252 DolphinApplication::app()->createMainWindow()->show();
253 }
254
255 void DolphinMainWindow::openNewTab()
256 {
257 openNewTab(m_activeViewContainer->url());
258 m_tabBar->setCurrentIndex(m_viewTab.count() - 1);
259 }
260
261 void DolphinMainWindow::openNewTab(const KUrl& url)
262 {
263 if (m_viewTab.count() == 1) {
264 // Only one view is open currently and hence no tab is shown at
265 // all. Before creating a tab for 'url', provide a tab for the current URL.
266 m_tabBar->addTab(KIcon("folder"), tabName(m_activeViewContainer->url()));
267 m_tabBar->blockSignals(false);
268 }
269
270 m_tabBar->addTab(KIcon("folder"), tabName(url));
271
272 ViewTab viewTab;
273 viewTab.splitter = new QSplitter(this);
274 viewTab.primaryView = new DolphinViewContainer(this, viewTab.splitter, url);
275 connectViewSignals(viewTab.primaryView);
276 viewTab.primaryView->view()->reload();
277
278 m_viewTab.append(viewTab);
279 }
280
281 void DolphinMainWindow::toggleActiveView()
282 {
283 if (m_viewTab[m_tabIndex].secondaryView == 0) {
284 // only one view is available
285 return;
286 }
287
288 Q_ASSERT(m_activeViewContainer != 0);
289 Q_ASSERT(m_viewTab[m_tabIndex].primaryView != 0);
290
291 DolphinViewContainer* left = m_viewTab[m_tabIndex].primaryView;
292 DolphinViewContainer* right = m_viewTab[m_tabIndex].secondaryView;
293 setActiveViewContainer(m_activeViewContainer == right ? left : right);
294 }
295
296 void DolphinMainWindow::closeEvent(QCloseEvent* event)
297 {
298 DolphinSettings& settings = DolphinSettings::instance();
299 GeneralSettings* generalSettings = settings.generalSettings();
300 generalSettings->setFirstRun(false);
301
302 settings.save();
303
304 KXmlGuiWindow::closeEvent(event);
305 }
306
307 void DolphinMainWindow::saveProperties(KConfigGroup& group)
308 {
309 // TODO: remember tabs
310 DolphinViewContainer* cont = m_viewTab[m_tabIndex].primaryView;
311 group.writeEntry("Primary Url", cont->url().url());
312 group.writeEntry("Primary Editable Url", cont->isUrlEditable());
313
314 cont = m_viewTab[m_tabIndex].secondaryView;
315 if (cont != 0) {
316 group.writeEntry("Secondary Url", cont->url().url());
317 group.writeEntry("Secondary Editable Url", cont->isUrlEditable());
318 }
319 }
320
321 void DolphinMainWindow::readProperties(const KConfigGroup& group)
322 {
323 // TODO: read tabs
324 DolphinViewContainer* cont = m_viewTab[m_tabIndex].primaryView;
325
326 cont->setUrl(group.readEntry("Primary Url"));
327 bool editable = group.readEntry("Primary Editable Url", false);
328 cont->urlNavigator()->setUrlEditable(editable);
329
330 cont = m_viewTab[m_tabIndex].secondaryView;
331 const QString secondaryUrl = group.readEntry("Secondary Url");
332 if (!secondaryUrl.isEmpty()) {
333 if (cont == 0) {
334 // a secondary view should be shown, but no one is available
335 // currently -> create a new view
336 toggleSplitView();
337 cont = m_viewTab[m_tabIndex].secondaryView;
338 Q_ASSERT(cont != 0);
339 }
340
341 cont->setUrl(secondaryUrl);
342 bool editable = group.readEntry("Secondary Editable Url", false);
343 cont->urlNavigator()->setUrlEditable(editable);
344 } else if (cont != 0) {
345 // no secondary view should be shown, but the default setting shows
346 // one already -> close the view
347 toggleSplitView();
348 }
349 }
350
351 void DolphinMainWindow::updateNewMenu()
352 {
353 m_newMenu->slotCheckUpToDate();
354 m_newMenu->setPopupFiles(activeViewContainer()->url());
355 }
356
357 void DolphinMainWindow::properties()
358 {
359 const KFileItemList list = m_activeViewContainer->view()->selectedItems();
360
361 KPropertiesDialog *dialog = new KPropertiesDialog(list, this);
362 dialog->setAttribute(Qt::WA_DeleteOnClose);
363 dialog->show();
364 dialog->raise();
365 dialog->activateWindow();
366 }
367
368 void DolphinMainWindow::quit()
369 {
370 close();
371 }
372
373 void DolphinMainWindow::slotHandlePlacesError(const QString &message)
374 {
375 if (!message.isEmpty()) {
376 DolphinStatusBar* statusBar = m_activeViewContainer->statusBar();
377 statusBar->setMessage(message, DolphinStatusBar::Error);
378 }
379 }
380
381 void DolphinMainWindow::slotUndoAvailable(bool available)
382 {
383 QAction* undoAction = actionCollection()->action(KStandardAction::name(KStandardAction::Undo));
384 if (undoAction != 0) {
385 undoAction->setEnabled(available);
386 }
387
388 if (available && (m_undoCommandTypes.count() > 0)) {
389 const KIO::FileUndoManager::CommandType command = m_undoCommandTypes.takeFirst();
390 DolphinStatusBar* statusBar = m_activeViewContainer->statusBar();
391 switch (command) {
392 case KIO::FileUndoManager::Copy:
393 statusBar->setMessage(i18nc("@info:status", "Copy operation completed."),
394 DolphinStatusBar::OperationCompleted);
395 break;
396 case KIO::FileUndoManager::Move:
397 statusBar->setMessage(i18nc("@info:status", "Move operation completed."),
398 DolphinStatusBar::OperationCompleted);
399 break;
400 case KIO::FileUndoManager::Link:
401 statusBar->setMessage(i18nc("@info:status", "Link operation completed."),
402 DolphinStatusBar::OperationCompleted);
403 break;
404 case KIO::FileUndoManager::Trash:
405 statusBar->setMessage(i18nc("@info:status", "Move to trash operation completed."),
406 DolphinStatusBar::OperationCompleted);
407 break;
408 case KIO::FileUndoManager::Rename:
409 statusBar->setMessage(i18nc("@info:status", "Renaming operation completed."),
410 DolphinStatusBar::OperationCompleted);
411 break;
412
413 case KIO::FileUndoManager::Mkdir:
414 statusBar->setMessage(i18nc("@info:status", "Created folder."),
415 DolphinStatusBar::OperationCompleted);
416 break;
417
418 default:
419 break;
420 }
421
422 }
423 }
424
425 void DolphinMainWindow::slotUndoTextChanged(const QString& text)
426 {
427 QAction* undoAction = actionCollection()->action(KStandardAction::name(KStandardAction::Undo));
428 if (undoAction != 0) {
429 undoAction->setText(text);
430 }
431 }
432
433 void DolphinMainWindow::undo()
434 {
435 clearStatusBar();
436 KIO::FileUndoManager::self()->uiInterface()->setParentWidget(this);
437 KIO::FileUndoManager::self()->undo();
438 }
439
440 void DolphinMainWindow::cut()
441 {
442 m_activeViewContainer->view()->cutSelectedItems();
443 }
444
445 void DolphinMainWindow::copy()
446 {
447 m_activeViewContainer->view()->copySelectedItems();
448 }
449
450 void DolphinMainWindow::paste()
451 {
452 m_activeViewContainer->view()->paste();
453 }
454
455 void DolphinMainWindow::updatePasteAction()
456 {
457 QAction* pasteAction = actionCollection()->action(KStandardAction::name(KStandardAction::Paste));
458 QPair<bool, QString> pasteInfo = m_activeViewContainer->view()->pasteInfo();
459 pasteAction->setEnabled(pasteInfo.first);
460 pasteAction->setText(pasteInfo.second);
461 }
462
463 void DolphinMainWindow::selectAll()
464 {
465 clearStatusBar();
466
467 // if the URL navigator is editable and focused, select the whole
468 // URL instead of all items of the view
469
470 KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
471 QLineEdit* lineEdit = urlNavigator->editor()->lineEdit();
472 const bool selectUrl = urlNavigator->isUrlEditable() &&
473 lineEdit->hasFocus();
474 if (selectUrl) {
475 lineEdit->selectAll();
476 } else {
477 m_activeViewContainer->view()->selectAll();
478 }
479 }
480
481 void DolphinMainWindow::invertSelection()
482 {
483 clearStatusBar();
484 m_activeViewContainer->view()->invertSelection();
485 }
486
487 void DolphinMainWindow::toggleSplitView()
488 {
489 if (m_viewTab[m_tabIndex].secondaryView == 0) {
490 // create a secondary view
491 QSplitter* splitter = m_viewTab[m_tabIndex].splitter;
492 const int newWidth = (m_viewTab[m_tabIndex].primaryView->width() - splitter->handleWidth()) / 2;
493
494 const DolphinView* view = m_viewTab[m_tabIndex].primaryView->view();
495 m_viewTab[m_tabIndex].secondaryView = new DolphinViewContainer(this, 0, view->rootUrl());
496 connectViewSignals(m_viewTab[m_tabIndex].secondaryView);
497 splitter->addWidget(m_viewTab[m_tabIndex].secondaryView);
498 splitter->setSizes(QList<int>() << newWidth << newWidth);
499 m_viewTab[m_tabIndex].secondaryView->view()->reload();
500 m_viewTab[m_tabIndex].secondaryView->setActive(false);
501 m_viewTab[m_tabIndex].secondaryView->show();
502
503 setActiveViewContainer(m_viewTab[m_tabIndex].secondaryView);
504 } else if (m_activeViewContainer == m_viewTab[m_tabIndex].primaryView) {
505 // remove secondary view
506 m_viewTab[m_tabIndex].secondaryView->close();
507 m_viewTab[m_tabIndex].secondaryView->deleteLater();
508 m_viewTab[m_tabIndex].secondaryView = 0;
509
510 setActiveViewContainer(m_viewTab[m_tabIndex].primaryView);
511 } else {
512 // The secondary view is active, hence from a users point of view
513 // the content of the secondary view should be moved to the primary view.
514 // From an implementation point of view it is more efficient to close
515 // the primary view and exchange the internal pointers afterwards.
516
517 m_viewTab[m_tabIndex].primaryView->close();
518 m_viewTab[m_tabIndex].primaryView->deleteLater();
519 m_viewTab[m_tabIndex].primaryView = m_viewTab[m_tabIndex].secondaryView;
520 m_viewTab[m_tabIndex].secondaryView = 0;
521
522 setActiveViewContainer(m_viewTab[m_tabIndex].primaryView);
523 }
524
525 updateViewActions();
526 }
527
528 void DolphinMainWindow::reloadView()
529 {
530 clearStatusBar();
531 m_activeViewContainer->view()->reload();
532 }
533
534 void DolphinMainWindow::stopLoading()
535 {
536 }
537
538 void DolphinMainWindow::toggleFilterBarVisibility(bool show)
539 {
540 m_activeViewContainer->showFilterBar(show);
541 }
542
543 void DolphinMainWindow::toggleEditLocation()
544 {
545 clearStatusBar();
546
547 QAction* action = actionCollection()->action("editable_location");
548 KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
549 urlNavigator->setUrlEditable(action->isChecked());
550 }
551
552 void DolphinMainWindow::editLocation()
553 {
554 KUrlNavigator* navigator = m_activeViewContainer->urlNavigator();
555 navigator->setUrlEditable(true);
556 navigator->setFocus();
557
558 // select the whole text of the combo box editor
559 QLineEdit* lineEdit = navigator->editor()->lineEdit();
560 const QString text = lineEdit->text();
561 lineEdit->setSelection(0, text.length());
562 }
563
564 void DolphinMainWindow::goBack()
565 {
566 clearStatusBar();
567 m_activeViewContainer->urlNavigator()->goBack();
568 }
569
570 void DolphinMainWindow::goForward()
571 {
572 clearStatusBar();
573 m_activeViewContainer->urlNavigator()->goForward();
574 }
575
576 void DolphinMainWindow::goUp()
577 {
578 clearStatusBar();
579 m_activeViewContainer->urlNavigator()->goUp();
580 }
581
582 void DolphinMainWindow::goHome()
583 {
584 clearStatusBar();
585 m_activeViewContainer->urlNavigator()->goHome();
586 }
587
588 void DolphinMainWindow::findFile()
589 {
590 KRun::run("kfind", m_activeViewContainer->url(), this);
591 }
592
593 void DolphinMainWindow::compareFiles()
594 {
595 // The method is only invoked if exactly 2 files have
596 // been selected. The selected files may be:
597 // - both in the primary view
598 // - both in the secondary view
599 // - one in the primary view and the other in the secondary
600 // view
601 Q_ASSERT(m_viewTab[m_tabIndex].primaryView != 0);
602
603 KUrl urlA;
604 KUrl urlB;
605 KUrl::List urls = m_viewTab[m_tabIndex].primaryView->view()->selectedUrls();
606
607 switch (urls.count()) {
608 case 0: {
609 Q_ASSERT(m_viewTab[m_tabIndex].secondaryView != 0);
610 urls = m_viewTab[m_tabIndex].secondaryView->view()->selectedUrls();
611 Q_ASSERT(urls.count() == 2);
612 urlA = urls[0];
613 urlB = urls[1];
614 break;
615 }
616
617 case 1: {
618 urlA = urls[0];
619 Q_ASSERT(m_viewTab[m_tabIndex].secondaryView != 0);
620 urls = m_viewTab[m_tabIndex].secondaryView->view()->selectedUrls();
621 Q_ASSERT(urls.count() == 1);
622 urlB = urls[0];
623 break;
624 }
625
626 case 2: {
627 urlA = urls[0];
628 urlB = urls[1];
629 break;
630 }
631
632 default: {
633 // may not happen: compareFiles may only get invoked if 2
634 // files are selected
635 Q_ASSERT(false);
636 }
637 }
638
639 QString command("kompare -c \"");
640 command.append(urlA.pathOrUrl());
641 command.append("\" \"");
642 command.append(urlB.pathOrUrl());
643 command.append('\"');
644 KRun::runCommand(command, "Kompare", "kompare", this);
645 }
646
647 void DolphinMainWindow::toggleShowMenuBar()
648 {
649 const bool visible = menuBar()->isVisible();
650 menuBar()->setVisible(!visible);
651 }
652
653 void DolphinMainWindow::editSettings()
654 {
655 DolphinSettingsDialog dialog(this);
656 dialog.exec();
657 }
658
659 void DolphinMainWindow::setActiveTab(int index)
660 {
661 Q_ASSERT(index >= 0);
662 Q_ASSERT(index < m_viewTab.count());
663 if (index == m_tabIndex) {
664 return;
665 }
666
667 // hide current tab content
668 m_viewTab[m_tabIndex].isPrimaryViewActive = m_viewTab[m_tabIndex].primaryView->isActive();
669 QSplitter* splitter = m_viewTab[m_tabIndex].splitter;
670 splitter->hide();
671 m_centralWidgetLayout->removeWidget(splitter);
672
673 // show active tab content
674 m_tabIndex = index;
675
676 ViewTab& viewTab = m_viewTab[index];
677 m_centralWidgetLayout->addWidget(viewTab.splitter);
678 viewTab.primaryView->show();
679 if (viewTab.secondaryView != 0) {
680 viewTab.secondaryView->show();
681 }
682 viewTab.splitter->show();
683
684 setActiveViewContainer(viewTab.isPrimaryViewActive ? viewTab.primaryView :
685 viewTab.secondaryView);
686 }
687
688 void DolphinMainWindow::closeTab()
689 {
690 closeTab(m_tabBar->currentIndex());
691 }
692
693 void DolphinMainWindow::closeTab(int index)
694 {
695 Q_ASSERT(index >= 0);
696 Q_ASSERT(index < m_viewTab.count());
697 if (m_viewTab.count() == 1) {
698 // the last tab may never get closed
699 return;
700 }
701
702 if (index == m_tabIndex) {
703 // The tab that should be closed is the active tab. Activate the
704 // previous tab before closing the tab.
705 setActiveTab((index > 0) ? index - 1 : 1);
706 }
707
708 // delete tab
709 m_viewTab[index].primaryView->deleteLater();
710 if (m_viewTab[index].secondaryView != 0) {
711 m_viewTab[index].secondaryView->deleteLater();
712 }
713 m_viewTab[index].splitter->deleteLater();
714 m_viewTab.erase(m_viewTab.begin() + index);
715
716 m_tabBar->blockSignals(true);
717 m_tabBar->removeTab(index);
718
719 if (m_tabIndex > index) {
720 m_tabIndex--;
721 Q_ASSERT(m_tabIndex >= 0);
722 }
723
724 // if only one tab is left, also remove the tab entry so that
725 // closing the last tab is not possible
726 if (m_viewTab.count() == 1) {
727 m_tabBar->removeTab(0);
728 } else {
729 m_tabBar->blockSignals(false);
730 }
731 }
732
733 void DolphinMainWindow::openTabContextMenu(int index, const QPoint& pos)
734 {
735 KMenu menu(this);
736
737 QAction* newTabAction = menu.addAction(KIcon("tab-new"), i18nc("@action:inmenu", "New Tab"));
738 newTabAction->setShortcut(actionCollection()->action("new_tab")->shortcut());
739
740 QAction* closeOtherTabsAction = menu.addAction(KIcon("tab-close"), i18nc("@action:inmenu", "Close Other Tabs"));
741
742 QAction* closeTabAction = menu.addAction(KIcon("tab-close"), i18nc("@action:inmenu", "Close Tab"));
743 closeTabAction->setShortcut(actionCollection()->action("close_tab")->shortcut());
744
745 QAction* selectedAction = menu.exec(pos);
746 if (selectedAction == newTabAction) {
747 const ViewTab& tab = m_viewTab[index];
748 Q_ASSERT(tab.primaryView != 0);
749 const KUrl url = (tab.secondaryView != 0) && tab.secondaryView->isActive() ?
750 tab.secondaryView->url() : tab.primaryView->url();
751 openNewTab(url);
752 m_tabBar->setCurrentIndex(m_viewTab.count() - 1);
753 } else if (selectedAction == closeOtherTabsAction) {
754 const int count = m_tabBar->count();
755 for (int i = 0; i < index; ++i) {
756 closeTab(0);
757 }
758 for (int i = index + 1; i < count; ++i) {
759 closeTab(1);
760 }
761 } else if (selectedAction == closeTabAction) {
762 closeTab(index);
763 }
764 }
765
766 void DolphinMainWindow::init()
767 {
768 DolphinSettings& settings = DolphinSettings::instance();
769
770 // Check whether Dolphin runs the first time. If yes then
771 // a proper default window size is given at the end of DolphinMainWindow::init().
772 GeneralSettings* generalSettings = settings.generalSettings();
773 const bool firstRun = generalSettings->firstRun();
774 if (firstRun) {
775 generalSettings->setViewPropsTimestamp(QDateTime::currentDateTime());
776 }
777
778 setAcceptDrops(true);
779
780 m_viewTab[m_tabIndex].splitter = new QSplitter(this);
781
782 setupActions();
783
784 const KUrl& homeUrl = generalSettings->homeUrl();
785 setCaption(homeUrl.fileName());
786 m_actionHandler = new DolphinViewActionHandler(actionCollection(), this);
787 connect(m_actionHandler, SIGNAL(actionBeingHandled()), SLOT(clearStatusBar()));
788 ViewProperties props(homeUrl);
789 m_viewTab[m_tabIndex].primaryView = new DolphinViewContainer(this,
790 m_viewTab[m_tabIndex].splitter,
791 homeUrl);
792
793 m_activeViewContainer = m_viewTab[m_tabIndex].primaryView;
794 connectViewSignals(m_activeViewContainer);
795 DolphinView* view = m_activeViewContainer->view();
796 view->reload();
797 m_activeViewContainer->show();
798 m_actionHandler->setCurrentView(view);
799
800 m_tabBar = new KTabBar(this);
801 m_tabBar->setCloseButtonEnabled(true);
802 connect(m_tabBar, SIGNAL(currentChanged(int)),
803 this, SLOT(setActiveTab(int)));
804 connect(m_tabBar, SIGNAL(closeRequest(int)),
805 this, SLOT(closeTab(int)));
806 connect(m_tabBar, SIGNAL(contextMenu(int, const QPoint&)),
807 this, SLOT(openTabContextMenu(int, const QPoint&)));
808 connect(m_tabBar, SIGNAL(newTabRequest()),
809 this, SLOT(openNewTab()));
810 m_tabBar->blockSignals(true); // signals get unblocked after at least 2 tabs are open
811
812 QWidget* centralWidget = new QWidget(this);
813 m_centralWidgetLayout = new QVBoxLayout(centralWidget);
814 m_centralWidgetLayout->setSpacing(0);
815 m_centralWidgetLayout->setMargin(0);
816 m_centralWidgetLayout->addWidget(m_tabBar);
817 m_centralWidgetLayout->addWidget(m_viewTab[m_tabIndex].splitter);
818
819
820 setCentralWidget(centralWidget);
821 setupDockWidgets();
822
823 setupGUI(Keys | Save | Create | ToolBar);
824 createGUI();
825
826 stateChanged("new_file");
827 setAutoSaveSettings();
828
829 QClipboard* clipboard = QApplication::clipboard();
830 connect(clipboard, SIGNAL(dataChanged()),
831 this, SLOT(updatePasteAction()));
832 updatePasteAction();
833 updateGoActions();
834
835 if (generalSettings->splitView()) {
836 toggleSplitView();
837 }
838 updateViewActions();
839
840 if (firstRun) {
841 // assure a proper default size if Dolphin runs the first time
842 resize(750, 500);
843 }
844
845 emit urlChanged(homeUrl);
846 }
847
848 void DolphinMainWindow::setActiveViewContainer(DolphinViewContainer* viewContainer)
849 {
850 Q_ASSERT(viewContainer != 0);
851 Q_ASSERT((viewContainer == m_viewTab[m_tabIndex].primaryView) ||
852 (viewContainer == m_viewTab[m_tabIndex].secondaryView));
853 if (m_activeViewContainer == viewContainer) {
854 return;
855 }
856
857 m_activeViewContainer->setActive(false);
858 m_activeViewContainer = viewContainer;
859
860 // Activating the view container might trigger a recursive setActiveViewContainer() call
861 // inside DolphinMainWindow::toggleActiveView() when having a split view. Temporary
862 // disconnect the activated() signal in this case:
863 disconnect(m_activeViewContainer->view(), SIGNAL(activated()), this, SLOT(toggleActiveView()));
864 m_activeViewContainer->setActive(true);
865 connect(m_activeViewContainer->view(), SIGNAL(activated()), this, SLOT(toggleActiveView()));
866
867 m_actionHandler->setCurrentView(viewContainer->view());
868
869 updateHistory();
870 updateEditActions();
871 updateViewActions();
872 updateGoActions();
873
874 const KUrl& url = m_activeViewContainer->url();
875 setCaption(url.fileName());
876 if (m_viewTab.count() > 1) {
877 m_tabBar->setTabText(m_tabIndex, tabName(url));
878 }
879
880 emit urlChanged(url);
881 }
882
883 void DolphinMainWindow::setupActions()
884 {
885 // setup 'File' menu
886 m_newMenu = new DolphinNewMenu(this);
887 KMenu* menu = m_newMenu->menu();
888 menu->setTitle(i18nc("@title:menu Create new folder, file, link, etc.", "Create New"));
889 menu->setIcon(KIcon("document-new"));
890 connect(menu, SIGNAL(aboutToShow()),
891 this, SLOT(updateNewMenu()));
892
893 KAction* newWindow = actionCollection()->addAction("new_window");
894 newWindow->setIcon(KIcon("window-new"));
895 newWindow->setText(i18nc("@action:inmenu File", "New &Window"));
896 newWindow->setShortcut(Qt::CTRL | Qt::Key_N);
897 connect(newWindow, SIGNAL(triggered()), this, SLOT(openNewMainWindow()));
898
899 KAction* newTab = actionCollection()->addAction("new_tab");
900 newTab->setIcon(KIcon("tab-new"));
901 newTab->setText(i18nc("@action:inmenu File", "New Tab"));
902 newTab->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_N);
903 connect(newTab, SIGNAL(triggered()), this, SLOT(openNewTab()));
904
905 QAction* closeTab = new QAction(KIcon("tab-close"), i18nc("@action:inmenu File", "Close Tab"), this);
906 closeTab->setShortcut(Qt::CTRL | Qt::Key_W);
907 connect(closeTab, SIGNAL(triggered()), this, SLOT(closeTab()));
908 actionCollection()->addAction("close_tab", closeTab);
909
910 KAction* properties = actionCollection()->addAction("properties");
911 properties->setText(i18nc("@action:inmenu File", "Properties"));
912 properties->setShortcut(Qt::ALT | Qt::Key_Return);
913 connect(properties, SIGNAL(triggered()), this, SLOT(properties()));
914
915 KStandardAction::quit(this, SLOT(quit()), actionCollection());
916
917 // setup 'Edit' menu
918 KStandardAction::undo(this,
919 SLOT(undo()),
920 actionCollection());
921
922 // need to remove shift+del from cut action, else the shortcut for deletejob
923 // doesn't work
924 KAction* cut = KStandardAction::cut(this, SLOT(cut()), actionCollection());
925 KShortcut cutShortcut = cut->shortcut();
926 cutShortcut.remove(Qt::SHIFT + Qt::Key_Delete, KShortcut::KeepEmpty);
927 cut->setShortcut(cutShortcut);
928 KStandardAction::copy(this, SLOT(copy()), actionCollection());
929 KStandardAction::paste(this, SLOT(paste()), actionCollection());
930
931 KAction* selectAll = actionCollection()->addAction("select_all");
932 selectAll->setText(i18nc("@action:inmenu Edit", "Select All"));
933 selectAll->setShortcut(Qt::CTRL + Qt::Key_A);
934 connect(selectAll, SIGNAL(triggered()), this, SLOT(selectAll()));
935
936 KAction* invertSelection = actionCollection()->addAction("invert_selection");
937 invertSelection->setText(i18nc("@action:inmenu Edit", "Invert Selection"));
938 invertSelection->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_A);
939 connect(invertSelection, SIGNAL(triggered()), this, SLOT(invertSelection()));
940
941 // setup 'View' menu
942 // (note that most of it is set up in DolphinViewActionHandler)
943
944 KAction* split = actionCollection()->addAction("split_view");
945 split->setShortcut(Qt::Key_F3);
946 updateSplitAction();
947 connect(split, SIGNAL(triggered()), this, SLOT(toggleSplitView()));
948
949 KAction* reload = actionCollection()->addAction("reload");
950 reload->setText(i18nc("@action:inmenu View", "Reload"));
951 reload->setShortcut(Qt::Key_F5);
952 reload->setIcon(KIcon("view-refresh"));
953 connect(reload, SIGNAL(triggered()), this, SLOT(reloadView()));
954
955 KAction* stop = actionCollection()->addAction("stop");
956 stop->setText(i18nc("@action:inmenu View", "Stop"));
957 stop->setIcon(KIcon("process-stop"));
958 connect(stop, SIGNAL(triggered()), this, SLOT(stopLoading()));
959
960 // TODO: the naming "Show full Location" is currently confusing...
961 KToggleAction* showFullLocation = actionCollection()->add<KToggleAction>("editable_location");
962 showFullLocation->setText(i18nc("@action:inmenu Navigation Bar", "Show Full Location"));
963 showFullLocation->setShortcut(Qt::CTRL | Qt::Key_L);
964 connect(showFullLocation, SIGNAL(triggered()), this, SLOT(toggleEditLocation()));
965
966 KAction* editLocation = actionCollection()->addAction("edit_location");
967 editLocation->setText(i18nc("@action:inmenu Navigation Bar", "Edit Location"));
968 editLocation->setShortcut(Qt::Key_F6);
969 connect(editLocation, SIGNAL(triggered()), this, SLOT(editLocation()));
970
971 // setup 'Go' menu
972 KAction* backAction = KStandardAction::back(this, SLOT(goBack()), actionCollection());
973 KShortcut backShortcut = backAction->shortcut();
974 backShortcut.setAlternate(Qt::Key_Backspace);
975 backAction->setShortcut(backShortcut);
976
977 KStandardAction::forward(this, SLOT(goForward()), actionCollection());
978 KStandardAction::up(this, SLOT(goUp()), actionCollection());
979 KStandardAction::home(this, SLOT(goHome()), actionCollection());
980
981 // setup 'Tools' menu
982 QAction* findFile = actionCollection()->addAction("find_file");
983 findFile->setText(i18nc("@action:inmenu Tools", "Find File..."));
984 findFile->setShortcut(Qt::CTRL | Qt::Key_F);
985 findFile->setIcon(KIcon("edit-find"));
986 connect(findFile, SIGNAL(triggered()), this, SLOT(findFile()));
987
988 KToggleAction* showFilterBar = actionCollection()->add<KToggleAction>("show_filter_bar");
989 showFilterBar->setText(i18nc("@action:inmenu Tools", "Show Filter Bar"));
990 showFilterBar->setShortcut(Qt::CTRL | Qt::Key_I);
991 connect(showFilterBar, SIGNAL(triggered(bool)), this, SLOT(toggleFilterBarVisibility(bool)));
992
993 KAction* compareFiles = actionCollection()->addAction("compare_files");
994 compareFiles->setText(i18nc("@action:inmenu Tools", "Compare Files"));
995 compareFiles->setIcon(KIcon("kompare"));
996 compareFiles->setEnabled(false);
997 connect(compareFiles, SIGNAL(triggered()), this, SLOT(compareFiles()));
998
999 // setup 'Settings' menu
1000 m_showMenuBar = KStandardAction::showMenubar(this, SLOT(toggleShowMenuBar()), actionCollection());
1001 KStandardAction::preferences(this, SLOT(editSettings()), actionCollection());
1002 }
1003
1004 void DolphinMainWindow::setupDockWidgets()
1005 {
1006 // setup "Information"
1007 QDockWidget* infoDock = new QDockWidget(i18nc("@title:window", "Information"));
1008 infoDock->setObjectName("infoDock");
1009 infoDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
1010 SidebarPage* infoWidget = new InfoSidebarPage(infoDock);
1011 infoDock->setWidget(infoWidget);
1012
1013 infoDock->toggleViewAction()->setText(i18nc("@title:window", "Information"));
1014 infoDock->toggleViewAction()->setShortcut(Qt::Key_F11);
1015 actionCollection()->addAction("show_info_panel", infoDock->toggleViewAction());
1016
1017 addDockWidget(Qt::RightDockWidgetArea, infoDock);
1018 connect(this, SIGNAL(urlChanged(KUrl)),
1019 infoWidget, SLOT(setUrl(KUrl)));
1020 connect(this, SIGNAL(selectionChanged(KFileItemList)),
1021 infoWidget, SLOT(setSelection(KFileItemList)));
1022 connect(this, SIGNAL(requestItemInfo(KFileItem)),
1023 infoWidget, SLOT(requestDelayedItemInfo(KFileItem)));
1024
1025 // setup "Tree View"
1026 QDockWidget* treeViewDock = new QDockWidget(i18nc("@title:window", "Folders"));
1027 treeViewDock->setObjectName("treeViewDock");
1028 treeViewDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
1029 TreeViewSidebarPage* treeWidget = new TreeViewSidebarPage(treeViewDock);
1030 treeViewDock->setWidget(treeWidget);
1031
1032 treeViewDock->toggleViewAction()->setText(i18nc("@title:window", "Folders"));
1033 treeViewDock->toggleViewAction()->setShortcut(Qt::Key_F7);
1034 actionCollection()->addAction("show_folders_panel", treeViewDock->toggleViewAction());
1035
1036 addDockWidget(Qt::LeftDockWidgetArea, treeViewDock);
1037 connect(this, SIGNAL(urlChanged(KUrl)),
1038 treeWidget, SLOT(setUrl(KUrl)));
1039 connect(treeWidget, SIGNAL(changeUrl(KUrl)),
1040 this, SLOT(changeUrl(KUrl)));
1041 connect(treeWidget, SIGNAL(changeSelection(KFileItemList)),
1042 this, SLOT(changeSelection(KFileItemList)));
1043 connect(treeWidget, SIGNAL(urlsDropped(KUrl::List, KUrl)),
1044 this, SLOT(dropUrls(KUrl::List, KUrl)));
1045
1046 // setup "Terminal"
1047 #ifndef Q_OS_WIN
1048 QDockWidget* terminalDock = new QDockWidget(i18nc("@title:window Shell terminal", "Terminal"));
1049 terminalDock->setObjectName("terminalDock");
1050 terminalDock->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
1051 SidebarPage* terminalWidget = new TerminalSidebarPage(terminalDock);
1052 terminalDock->setWidget(terminalWidget);
1053
1054 connect(terminalWidget, SIGNAL(hideTerminalSidebarPage()), terminalDock, SLOT(hide()));
1055
1056 terminalDock->toggleViewAction()->setText(i18nc("@title:window Shell terminal", "Terminal"));
1057 terminalDock->toggleViewAction()->setShortcut(Qt::Key_F4);
1058 actionCollection()->addAction("show_terminal_panel", terminalDock->toggleViewAction());
1059
1060 addDockWidget(Qt::BottomDockWidgetArea, terminalDock);
1061 connect(this, SIGNAL(urlChanged(KUrl)),
1062 terminalWidget, SLOT(setUrl(KUrl)));
1063 #endif
1064
1065 const bool firstRun = DolphinSettings::instance().generalSettings()->firstRun();
1066 if (firstRun) {
1067 treeViewDock->hide();
1068 #ifndef Q_OS_WIN
1069 terminalDock->hide();
1070 #endif
1071 }
1072
1073 QDockWidget* placesDock = new QDockWidget(i18nc("@title:window", "Places"));
1074 placesDock->setObjectName("placesDock");
1075 placesDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
1076
1077 DolphinFilePlacesView* placesView = new DolphinFilePlacesView(placesDock);
1078 placesDock->setWidget(placesView);
1079 placesView->setModel(DolphinSettings::instance().placesModel());
1080 placesView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
1081
1082 placesDock->toggleViewAction()->setText(i18nc("@title:window", "Places"));
1083 placesDock->toggleViewAction()->setShortcut(Qt::Key_F9);
1084 actionCollection()->addAction("show_places_panel", placesDock->toggleViewAction());
1085
1086 addDockWidget(Qt::LeftDockWidgetArea, placesDock);
1087 connect(placesView, SIGNAL(urlChanged(KUrl)),
1088 this, SLOT(changeUrl(KUrl)));
1089 connect(this, SIGNAL(urlChanged(KUrl)),
1090 placesView, SLOT(setUrl(KUrl)));
1091 }
1092
1093 void DolphinMainWindow::updateEditActions()
1094 {
1095 const KFileItemList list = m_activeViewContainer->view()->selectedItems();
1096 if (list.isEmpty()) {
1097 stateChanged("has_no_selection");
1098 } else {
1099 stateChanged("has_selection");
1100
1101 FileItemCapabilities capabilities(list);
1102 actionCollection()->action("rename")->setEnabled(capabilities.supportsMoving());
1103 const bool enableMoveToTrash = capabilities.isLocal() && capabilities.supportsMoving();
1104 actionCollection()->action("move_to_trash")->setEnabled(enableMoveToTrash);
1105 actionCollection()->action("delete")->setEnabled(capabilities.supportsDeleting());
1106 }
1107 updatePasteAction();
1108 }
1109
1110 void DolphinMainWindow::updateViewActions()
1111 {
1112 m_actionHandler->updateViewActions();
1113
1114 QAction* showFilterBarAction = actionCollection()->action("show_filter_bar");
1115 showFilterBarAction->setChecked(m_activeViewContainer->isFilterBarVisible());
1116
1117 updateSplitAction();
1118
1119 QAction* editableLocactionAction = actionCollection()->action("editable_location");
1120 const KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
1121 editableLocactionAction->setChecked(urlNavigator->isUrlEditable());
1122 }
1123
1124 void DolphinMainWindow::updateGoActions()
1125 {
1126 QAction* goUpAction = actionCollection()->action(KStandardAction::name(KStandardAction::Up));
1127 const KUrl& currentUrl = m_activeViewContainer->url();
1128 goUpAction->setEnabled(currentUrl.upUrl() != currentUrl);
1129 }
1130
1131 void DolphinMainWindow::clearStatusBar()
1132 {
1133 m_activeViewContainer->statusBar()->clear();
1134 }
1135
1136 void DolphinMainWindow::connectViewSignals(DolphinViewContainer* container)
1137 {
1138 connect(container, SIGNAL(showFilterBarChanged(bool)),
1139 this, SLOT(updateFilterBarAction(bool)));
1140
1141 DolphinView* view = container->view();
1142 connect(view, SIGNAL(selectionChanged(KFileItemList)),
1143 this, SLOT(slotSelectionChanged(KFileItemList)));
1144 connect(view, SIGNAL(requestItemInfo(KFileItem)),
1145 this, SLOT(slotRequestItemInfo(KFileItem)));
1146 connect(view, SIGNAL(activated()),
1147 this, SLOT(toggleActiveView()));
1148 connect(view, SIGNAL(doingOperation(KIO::FileUndoManager::CommandType)),
1149 this, SLOT(slotDoingOperation(KIO::FileUndoManager::CommandType)));
1150 connect(view, SIGNAL(tabRequested(const KUrl&)),
1151 this, SLOT(openNewTab(const KUrl&)));
1152
1153 const KUrlNavigator* navigator = container->urlNavigator();
1154 connect(navigator, SIGNAL(urlChanged(const KUrl&)),
1155 this, SLOT(changeUrl(const KUrl&)));
1156 connect(navigator, SIGNAL(historyChanged()),
1157 this, SLOT(updateHistory()));
1158 connect(navigator, SIGNAL(editableStateChanged(bool)),
1159 this, SLOT(slotEditableStateChanged(bool)));
1160 }
1161
1162 void DolphinMainWindow::updateSplitAction()
1163 {
1164 QAction* splitAction = actionCollection()->action("split_view");
1165 if (m_viewTab[m_tabIndex].secondaryView != 0) {
1166 if (m_activeViewContainer == m_viewTab[m_tabIndex].primaryView) {
1167 splitAction->setText(i18nc("@action:intoolbar Close right view", "Close"));
1168 splitAction->setIcon(KIcon("view-right-close"));
1169 } else {
1170 splitAction->setText(i18nc("@action:intoolbar Close left view", "Close"));
1171 splitAction->setIcon(KIcon("view-left-close"));
1172 }
1173 } else {
1174 splitAction->setText(i18nc("@action:intoolbar Split view", "Split"));
1175 splitAction->setIcon(KIcon("view-right-new"));
1176 }
1177 }
1178
1179 QString DolphinMainWindow::tabName(const KUrl& url) const
1180 {
1181 return url.equals(KUrl("file:///")) ? "/" : url.fileName();
1182 }
1183
1184 DolphinMainWindow::UndoUiInterface::UndoUiInterface() :
1185 KIO::FileUndoManager::UiInterface()
1186 {
1187 }
1188
1189 DolphinMainWindow::UndoUiInterface::~UndoUiInterface()
1190 {
1191 }
1192
1193 void DolphinMainWindow::UndoUiInterface::jobError(KIO::Job* job)
1194 {
1195 DolphinMainWindow* mainWin= qobject_cast<DolphinMainWindow *>(parentWidget());
1196 if (mainWin) {
1197 DolphinStatusBar* statusBar = mainWin->activeViewContainer()->statusBar();
1198 statusBar->setMessage(job->errorString(), DolphinStatusBar::Error);
1199 } else {
1200 KIO::FileUndoManager::UiInterface::jobError(job);
1201 }
1202 }
1203
1204 #include "dolphinmainwindow.moc"