]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinmainwindow.cpp
There are some extractable strings in subdirs too.
[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-other"), 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::handlePlacesClick(const KUrl& url, Qt::MouseButtons buttons)
767 {
768 if (buttons & Qt::MidButton) {
769 openNewTab(url);
770 m_tabBar->setCurrentIndex(m_viewTab.count() - 1);
771 } else {
772 changeUrl(url);
773 }
774 }
775
776 void DolphinMainWindow::init()
777 {
778 DolphinSettings& settings = DolphinSettings::instance();
779
780 // Check whether Dolphin runs the first time. If yes then
781 // a proper default window size is given at the end of DolphinMainWindow::init().
782 GeneralSettings* generalSettings = settings.generalSettings();
783 const bool firstRun = generalSettings->firstRun();
784 if (firstRun) {
785 generalSettings->setViewPropsTimestamp(QDateTime::currentDateTime());
786 }
787
788 setAcceptDrops(true);
789
790 m_viewTab[m_tabIndex].splitter = new QSplitter(this);
791
792 setupActions();
793
794 const KUrl& homeUrl = generalSettings->homeUrl();
795 setCaption(homeUrl.fileName());
796 m_actionHandler = new DolphinViewActionHandler(actionCollection(), this);
797 connect(m_actionHandler, SIGNAL(actionBeingHandled()), SLOT(clearStatusBar()));
798 ViewProperties props(homeUrl);
799 m_viewTab[m_tabIndex].primaryView = new DolphinViewContainer(this,
800 m_viewTab[m_tabIndex].splitter,
801 homeUrl);
802
803 m_activeViewContainer = m_viewTab[m_tabIndex].primaryView;
804 connectViewSignals(m_activeViewContainer);
805 DolphinView* view = m_activeViewContainer->view();
806 view->reload();
807 m_activeViewContainer->show();
808 m_actionHandler->setCurrentView(view);
809
810 m_tabBar = new KTabBar(this);
811 m_tabBar->setCloseButtonEnabled(true);
812 connect(m_tabBar, SIGNAL(currentChanged(int)),
813 this, SLOT(setActiveTab(int)));
814 connect(m_tabBar, SIGNAL(closeRequest(int)),
815 this, SLOT(closeTab(int)));
816 connect(m_tabBar, SIGNAL(contextMenu(int, const QPoint&)),
817 this, SLOT(openTabContextMenu(int, const QPoint&)));
818 connect(m_tabBar, SIGNAL(newTabRequest()),
819 this, SLOT(openNewTab()));
820 m_tabBar->blockSignals(true); // signals get unblocked after at least 2 tabs are open
821
822 QWidget* centralWidget = new QWidget(this);
823 m_centralWidgetLayout = new QVBoxLayout(centralWidget);
824 m_centralWidgetLayout->setSpacing(0);
825 m_centralWidgetLayout->setMargin(0);
826 m_centralWidgetLayout->addWidget(m_tabBar);
827 m_centralWidgetLayout->addWidget(m_viewTab[m_tabIndex].splitter);
828
829
830 setCentralWidget(centralWidget);
831 setupDockWidgets();
832
833 setupGUI(Keys | Save | Create | ToolBar);
834 createGUI();
835
836 stateChanged("new_file");
837 setAutoSaveSettings();
838
839 QClipboard* clipboard = QApplication::clipboard();
840 connect(clipboard, SIGNAL(dataChanged()),
841 this, SLOT(updatePasteAction()));
842 updatePasteAction();
843 updateGoActions();
844
845 if (generalSettings->splitView()) {
846 toggleSplitView();
847 }
848 updateViewActions();
849
850 if (firstRun) {
851 // assure a proper default size if Dolphin runs the first time
852 resize(750, 500);
853 }
854
855 emit urlChanged(homeUrl);
856 }
857
858 void DolphinMainWindow::setActiveViewContainer(DolphinViewContainer* viewContainer)
859 {
860 Q_ASSERT(viewContainer != 0);
861 Q_ASSERT((viewContainer == m_viewTab[m_tabIndex].primaryView) ||
862 (viewContainer == m_viewTab[m_tabIndex].secondaryView));
863 if (m_activeViewContainer == viewContainer) {
864 return;
865 }
866
867 m_activeViewContainer->setActive(false);
868 m_activeViewContainer = viewContainer;
869
870 // Activating the view container might trigger a recursive setActiveViewContainer() call
871 // inside DolphinMainWindow::toggleActiveView() when having a split view. Temporary
872 // disconnect the activated() signal in this case:
873 disconnect(m_activeViewContainer->view(), SIGNAL(activated()), this, SLOT(toggleActiveView()));
874 m_activeViewContainer->setActive(true);
875 connect(m_activeViewContainer->view(), SIGNAL(activated()), this, SLOT(toggleActiveView()));
876
877 m_actionHandler->setCurrentView(viewContainer->view());
878
879 updateHistory();
880 updateEditActions();
881 updateViewActions();
882 updateGoActions();
883
884 const KUrl& url = m_activeViewContainer->url();
885 setCaption(url.fileName());
886 if (m_viewTab.count() > 1) {
887 m_tabBar->setTabText(m_tabIndex, tabName(url));
888 }
889
890 emit urlChanged(url);
891 }
892
893 void DolphinMainWindow::setupActions()
894 {
895 // setup 'File' menu
896 m_newMenu = new DolphinNewMenu(this);
897 KMenu* menu = m_newMenu->menu();
898 menu->setTitle(i18nc("@title:menu Create new folder, file, link, etc.", "Create New"));
899 menu->setIcon(KIcon("document-new"));
900 connect(menu, SIGNAL(aboutToShow()),
901 this, SLOT(updateNewMenu()));
902
903 KAction* newWindow = actionCollection()->addAction("new_window");
904 newWindow->setIcon(KIcon("window-new"));
905 newWindow->setText(i18nc("@action:inmenu File", "New &Window"));
906 newWindow->setShortcut(Qt::CTRL | Qt::Key_N);
907 connect(newWindow, SIGNAL(triggered()), this, SLOT(openNewMainWindow()));
908
909 KAction* newTab = actionCollection()->addAction("new_tab");
910 newTab->setIcon(KIcon("tab-new"));
911 newTab->setText(i18nc("@action:inmenu File", "New Tab"));
912 newTab->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_N);
913 connect(newTab, SIGNAL(triggered()), this, SLOT(openNewTab()));
914
915 QAction* closeTab = new QAction(KIcon("tab-close"), i18nc("@action:inmenu File", "Close Tab"), this);
916 closeTab->setShortcut(Qt::CTRL | Qt::Key_W);
917 connect(closeTab, SIGNAL(triggered()), this, SLOT(closeTab()));
918 actionCollection()->addAction("close_tab", closeTab);
919
920 KAction* properties = actionCollection()->addAction("properties");
921 properties->setText(i18nc("@action:inmenu File", "Properties"));
922 properties->setShortcut(Qt::ALT | Qt::Key_Return);
923 connect(properties, SIGNAL(triggered()), this, SLOT(properties()));
924
925 KStandardAction::quit(this, SLOT(quit()), actionCollection());
926
927 // setup 'Edit' menu
928 KStandardAction::undo(this,
929 SLOT(undo()),
930 actionCollection());
931
932 // need to remove shift+del from cut action, else the shortcut for deletejob
933 // doesn't work
934 KAction* cut = KStandardAction::cut(this, SLOT(cut()), actionCollection());
935 KShortcut cutShortcut = cut->shortcut();
936 cutShortcut.remove(Qt::SHIFT + Qt::Key_Delete, KShortcut::KeepEmpty);
937 cut->setShortcut(cutShortcut);
938 KStandardAction::copy(this, SLOT(copy()), actionCollection());
939 KStandardAction::paste(this, SLOT(paste()), actionCollection());
940
941 KAction* selectAll = actionCollection()->addAction("select_all");
942 selectAll->setText(i18nc("@action:inmenu Edit", "Select All"));
943 selectAll->setShortcut(Qt::CTRL + Qt::Key_A);
944 connect(selectAll, SIGNAL(triggered()), this, SLOT(selectAll()));
945
946 KAction* invertSelection = actionCollection()->addAction("invert_selection");
947 invertSelection->setText(i18nc("@action:inmenu Edit", "Invert Selection"));
948 invertSelection->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_A);
949 connect(invertSelection, SIGNAL(triggered()), this, SLOT(invertSelection()));
950
951 // setup 'View' menu
952 // (note that most of it is set up in DolphinViewActionHandler)
953
954 KAction* split = actionCollection()->addAction("split_view");
955 split->setShortcut(Qt::Key_F3);
956 updateSplitAction();
957 connect(split, SIGNAL(triggered()), this, SLOT(toggleSplitView()));
958
959 KAction* reload = actionCollection()->addAction("reload");
960 reload->setText(i18nc("@action:inmenu View", "Reload"));
961 reload->setShortcut(Qt::Key_F5);
962 reload->setIcon(KIcon("view-refresh"));
963 connect(reload, SIGNAL(triggered()), this, SLOT(reloadView()));
964
965 KAction* stop = actionCollection()->addAction("stop");
966 stop->setText(i18nc("@action:inmenu View", "Stop"));
967 stop->setIcon(KIcon("process-stop"));
968 connect(stop, SIGNAL(triggered()), this, SLOT(stopLoading()));
969
970 // TODO: the naming "Show full Location" is currently confusing...
971 KToggleAction* showFullLocation = actionCollection()->add<KToggleAction>("editable_location");
972 showFullLocation->setText(i18nc("@action:inmenu Navigation Bar", "Show Full Location"));
973 showFullLocation->setShortcut(Qt::CTRL | Qt::Key_L);
974 connect(showFullLocation, SIGNAL(triggered()), this, SLOT(toggleEditLocation()));
975
976 KAction* editLocation = actionCollection()->addAction("edit_location");
977 editLocation->setText(i18nc("@action:inmenu Navigation Bar", "Edit Location"));
978 editLocation->setShortcut(Qt::Key_F6);
979 connect(editLocation, SIGNAL(triggered()), this, SLOT(editLocation()));
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, Qt::MouseButtons)),
1050 this, SLOT(handlePlacesClick(KUrl, Qt::MouseButtons)));
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, Qt::MouseButtons)),
1098 this, SLOT(handlePlacesClick(KUrl, Qt::MouseButtons)));
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 FileItemCapabilities capabilities(list);
1112 actionCollection()->action("rename")->setEnabled(capabilities.supportsMoving());
1113 const bool enableMoveToTrash = capabilities.isLocal() && capabilities.supportsMoving();
1114 actionCollection()->action("move_to_trash")->setEnabled(enableMoveToTrash);
1115 actionCollection()->action("delete")->setEnabled(capabilities.supportsDeleting());
1116 }
1117 updatePasteAction();
1118 }
1119
1120 void DolphinMainWindow::updateViewActions()
1121 {
1122 m_actionHandler->updateViewActions();
1123
1124 QAction* showFilterBarAction = actionCollection()->action("show_filter_bar");
1125 showFilterBarAction->setChecked(m_activeViewContainer->isFilterBarVisible());
1126
1127 updateSplitAction();
1128
1129 QAction* editableLocactionAction = actionCollection()->action("editable_location");
1130 const KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
1131 editableLocactionAction->setChecked(urlNavigator->isUrlEditable());
1132 }
1133
1134 void DolphinMainWindow::updateGoActions()
1135 {
1136 QAction* goUpAction = actionCollection()->action(KStandardAction::name(KStandardAction::Up));
1137 const KUrl& currentUrl = m_activeViewContainer->url();
1138 goUpAction->setEnabled(currentUrl.upUrl() != currentUrl);
1139 }
1140
1141 void DolphinMainWindow::clearStatusBar()
1142 {
1143 m_activeViewContainer->statusBar()->clear();
1144 }
1145
1146 void DolphinMainWindow::connectViewSignals(DolphinViewContainer* container)
1147 {
1148 connect(container, SIGNAL(showFilterBarChanged(bool)),
1149 this, SLOT(updateFilterBarAction(bool)));
1150
1151 DolphinView* view = container->view();
1152 connect(view, SIGNAL(selectionChanged(KFileItemList)),
1153 this, SLOT(slotSelectionChanged(KFileItemList)));
1154 connect(view, SIGNAL(requestItemInfo(KFileItem)),
1155 this, SLOT(slotRequestItemInfo(KFileItem)));
1156 connect(view, SIGNAL(activated()),
1157 this, SLOT(toggleActiveView()));
1158 connect(view, SIGNAL(doingOperation(KIO::FileUndoManager::CommandType)),
1159 this, SLOT(slotDoingOperation(KIO::FileUndoManager::CommandType)));
1160 connect(view, SIGNAL(tabRequested(const KUrl&)),
1161 this, SLOT(openNewTab(const KUrl&)));
1162
1163 const KUrlNavigator* navigator = container->urlNavigator();
1164 connect(navigator, SIGNAL(urlChanged(const KUrl&)),
1165 this, SLOT(changeUrl(const KUrl&)));
1166 connect(navigator, SIGNAL(historyChanged()),
1167 this, SLOT(updateHistory()));
1168 connect(navigator, SIGNAL(editableStateChanged(bool)),
1169 this, SLOT(slotEditableStateChanged(bool)));
1170 }
1171
1172 void DolphinMainWindow::updateSplitAction()
1173 {
1174 QAction* splitAction = actionCollection()->action("split_view");
1175 if (m_viewTab[m_tabIndex].secondaryView != 0) {
1176 if (m_activeViewContainer == m_viewTab[m_tabIndex].primaryView) {
1177 splitAction->setText(i18nc("@action:intoolbar Close right view", "Close"));
1178 splitAction->setIcon(KIcon("view-right-close"));
1179 } else {
1180 splitAction->setText(i18nc("@action:intoolbar Close left view", "Close"));
1181 splitAction->setIcon(KIcon("view-left-close"));
1182 }
1183 } else {
1184 splitAction->setText(i18nc("@action:intoolbar Split view", "Split"));
1185 splitAction->setIcon(KIcon("view-right-new"));
1186 }
1187 }
1188
1189 QString DolphinMainWindow::tabName(const KUrl& url) const
1190 {
1191 QString name;
1192 if (url.equals(KUrl("file:///"))) {
1193 name = "/";
1194 } else {
1195 name = url.fileName();
1196 if (name.isEmpty()) {
1197 name = url.protocol();
1198 }
1199 }
1200 return name;
1201 }
1202
1203 DolphinMainWindow::UndoUiInterface::UndoUiInterface() :
1204 KIO::FileUndoManager::UiInterface()
1205 {
1206 }
1207
1208 DolphinMainWindow::UndoUiInterface::~UndoUiInterface()
1209 {
1210 }
1211
1212 void DolphinMainWindow::UndoUiInterface::jobError(KIO::Job* job)
1213 {
1214 DolphinMainWindow* mainWin= qobject_cast<DolphinMainWindow *>(parentWidget());
1215 if (mainWin) {
1216 DolphinStatusBar* statusBar = mainWin->activeViewContainer()->statusBar();
1217 statusBar->setMessage(job->errorString(), DolphinStatusBar::Error);
1218 } else {
1219 KIO::FileUndoManager::UiInterface::jobError(job);
1220 }
1221 }
1222
1223 #include "dolphinmainwindow.moc"