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