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