]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinmainwindow.cpp
Additionally to sorting by name, size and date it is now possible to sort by permissi...
[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
24 #include <assert.h>
25
26 #include "dolphinapplication.h"
27 #include "dolphinnewmenu.h"
28 #include "dolphinsettings.h"
29 #include "dolphinsettingsdialog.h"
30 #include "dolphinstatusbar.h"
31 #include "dolphinapplication.h"
32 #include "urlnavigator.h"
33 #include "dolphinsettings.h"
34 #include "bookmarkssidebarpage.h"
35 #include "infosidebarpage.h"
36 #include "generalsettings.h"
37 #include "viewpropertiesdialog.h"
38 #include "viewproperties.h"
39
40 #include <kaction.h>
41 #include <kactioncollection.h>
42 #include <kbookmarkmanager.h>
43 #include <kconfig.h>
44 #include <kdesktopfile.h>
45 #include <kdeversion.h>
46 #include <kfiledialog.h>
47 #include <kglobal.h>
48 #include <kicon.h>
49 #include <kiconloader.h>
50 #include <kio/netaccess.h>
51 #include <kio/deletejob.h>
52 #include <kio/renamedialog.h>
53 #include <kinputdialog.h>
54 #include <klocale.h>
55 #include <kmenu.h>
56 #include <kmessagebox.h>
57 #include <konqmimedata.h>
58 #include <kpropertiesdialog.h>
59 #include <kprotocolinfo.h>
60 #include <ktoggleaction.h>
61 #include <krun.h>
62 #include <kshell.h>
63 #include <kstandarddirs.h>
64 #include <kstatusbar.h>
65 #include <kstandardaction.h>
66 #include <kurl.h>
67
68 #include <QCloseEvent>
69 #include <QClipboard>
70 #include <QSplitter>
71 #include <QDockWidget>
72
73 DolphinMainWindow::DolphinMainWindow() :
74 KMainWindow(0),
75 m_newMenu(0),
76 m_splitter(0),
77 m_activeView(0)
78 {
79 setObjectName("Dolphin");
80 m_view[PrimaryIdx] = 0;
81 m_view[SecondaryIdx] = 0;
82
83 KonqUndoManager::incRef();
84
85 KonqUndoManager* undoManager = KonqUndoManager::self();
86 undoManager->setUiInterface(new UndoUiInterface(this));
87
88 connect(undoManager, SIGNAL(undoAvailable(bool)),
89 this, SLOT(slotUndoAvailable(bool)));
90 connect(undoManager, SIGNAL(undoTextChanged(const QString&)),
91 this, SLOT(slotUndoTextChanged(const QString&)));
92 }
93
94 DolphinMainWindow::~DolphinMainWindow()
95 {
96 KonqUndoManager::decRef();
97 DolphinApplication::app()->removeMainWindow(this);
98 }
99
100 void DolphinMainWindow::setActiveView(DolphinView* view)
101 {
102 assert((view == m_view[PrimaryIdx]) || (view == m_view[SecondaryIdx]));
103 if (m_activeView == view) {
104 return;
105 }
106
107 m_activeView = view;
108
109 updateHistory();
110 updateEditActions();
111 updateViewActions();
112 updateGoActions();
113
114 setCaption(m_activeView->url().fileName());
115
116 emit activeViewChanged();
117 }
118
119 void DolphinMainWindow::dropUrls(const KUrl::List& urls,
120 const KUrl& destination)
121 {
122 Qt::DropAction action = Qt::CopyAction;
123
124 Qt::KeyboardModifiers modifier = QApplication::keyboardModifiers();
125 const bool shiftPressed = modifier & Qt::ShiftModifier;
126 const bool controlPressed = modifier & Qt::ControlModifier;
127 if (shiftPressed && controlPressed) {
128 // shortcut for 'Link Here' is used
129 action = Qt::LinkAction;
130 }
131 else if (shiftPressed) {
132 // shortcut for 'Move Here' is used
133 action = Qt::MoveAction;
134 }
135 else if (controlPressed) {
136 // shortcut for 'Copy Here' is used
137 action = Qt::CopyAction;
138 }
139 else {
140 // open a context menu which offers the following actions:
141 // - Move Here
142 // - Copy Here
143 // - Link Here
144 // - Cancel
145
146 KMenu popup(this);
147
148 QString seq = QKeySequence(Qt::ShiftModifier).toString();
149 seq.chop(1); // chop superfluous '+'
150 QAction* moveAction = popup.addAction(KIcon("goto"),
151 i18n("&Move Here") + "\t" + seq);
152
153 seq = QKeySequence(Qt::ControlModifier).toString();
154 seq.chop(1);
155 QAction* copyAction = popup.addAction(KIcon("editcopy"),
156 i18n("&Copy Here") + "\t" + seq);
157
158 seq = QKeySequence(Qt::ControlModifier + Qt::ShiftModifier).toString();
159 seq.chop(1);
160 QAction* linkAction = popup.addAction(KIcon("www"),
161 i18n("&Link Here") + "\t" + seq);
162
163 popup.addSeparator();
164 QAction* cancelAction = popup.addAction(KIcon("stop"), i18n("Cancel"));
165
166 QAction* activatedAction = popup.exec(QCursor::pos());
167 if (activatedAction == moveAction) {
168 action = Qt::MoveAction;
169 }
170 else if (activatedAction == copyAction) {
171 action = Qt::CopyAction;
172 }
173 else if (activatedAction == linkAction) {
174 action = Qt::LinkAction;
175 }
176 else if (activatedAction == cancelAction) {
177 return;
178 }
179 }
180
181 switch (action) {
182 case Qt::MoveAction:
183 moveUrls(urls, destination);
184 break;
185
186 case Qt::CopyAction:
187 copyUrls(urls, destination);
188 break;
189
190 case Qt::LinkAction:
191 linkUrls(urls, destination);
192 break;
193
194 default:
195 break;
196 }
197 }
198
199 void DolphinMainWindow::refreshViews()
200 {
201 const bool split = DolphinSettings::instance().generalSettings()->splitView();
202 const bool isPrimaryViewActive = (m_activeView == m_view[PrimaryIdx]);
203 KUrl url;
204 for (int i = PrimaryIdx; i <= SecondaryIdx; ++i) {
205 if (m_view[i] != 0) {
206 url = m_view[i]->url();
207
208 // delete view instance...
209 m_view[i]->close();
210 m_view[i]->deleteLater();
211 m_view[i] = 0;
212 }
213
214 if (split || (i == PrimaryIdx)) {
215 // ... and recreate it
216 ViewProperties props(url);
217 m_view[i] = new DolphinView(this,
218 m_splitter,
219 url,
220 props.viewMode(),
221 props.showHiddenFiles());
222 connectViewSignals(i);
223 m_view[i]->show();
224 }
225 }
226
227 m_activeView = isPrimaryViewActive ? m_view[PrimaryIdx] : m_view[SecondaryIdx];
228 assert(m_activeView != 0);
229
230 updateViewActions();
231 emit activeViewChanged();
232 }
233
234 void DolphinMainWindow::slotViewModeChanged()
235 {
236 updateViewActions();
237 }
238
239 void DolphinMainWindow::slotShowHiddenFilesChanged()
240 {
241 KToggleAction* showHiddenFilesAction =
242 static_cast<KToggleAction*>(actionCollection()->action("show_hidden_files"));
243 showHiddenFilesAction->setChecked(m_activeView->showHiddenFiles());
244 }
245
246 void DolphinMainWindow::slotSortingChanged(DolphinView::Sorting sorting)
247 {
248 QAction* action = 0;
249 switch (sorting) {
250 case DolphinView::SortByName:
251 action = actionCollection()->action("by_name");
252 break;
253 case DolphinView::SortBySize:
254 action = actionCollection()->action("by_size");
255 break;
256 case DolphinView::SortByDate:
257 action = actionCollection()->action("by_date");
258 break;
259 case DolphinView::SortByPermissions:
260 action = actionCollection()->action("by_permissions");
261 break;
262 case DolphinView::SortByOwner:
263 action = actionCollection()->action("by_owner");
264 break;
265 case DolphinView::SortByGroup:
266 action = actionCollection()->action("by_group");
267 break;
268 default:
269 break;
270 }
271
272 if (action != 0) {
273 KToggleAction* toggleAction = static_cast<KToggleAction*>(action);
274 toggleAction->setChecked(true);
275 }
276 }
277
278 void DolphinMainWindow::slotSortOrderChanged(Qt::SortOrder order)
279 {
280 KToggleAction* descending = static_cast<KToggleAction*>(actionCollection()->action("descending"));
281 const bool sortDescending = (order == Qt::Descending);
282 descending->setChecked(sortDescending);
283 }
284
285 void DolphinMainWindow::slotSelectionChanged()
286 {
287 updateEditActions();
288
289 assert(m_view[PrimaryIdx] != 0);
290 int selectedUrlsCount = m_view[PrimaryIdx]->selectedUrls().count();
291 if (m_view[SecondaryIdx] != 0) {
292 selectedUrlsCount += m_view[SecondaryIdx]->selectedUrls().count();
293 }
294
295 QAction* compareFilesAction = actionCollection()->action("compare_files");
296 compareFilesAction->setEnabled(selectedUrlsCount == 2);
297
298 m_activeView->updateStatusBar();
299
300 emit selectionChanged();
301 }
302
303 void DolphinMainWindow::slotHistoryChanged()
304 {
305 updateHistory();
306 }
307
308 void DolphinMainWindow::slotUrlChanged(const KUrl& url)
309 {
310 updateEditActions();
311 updateGoActions();
312 setCaption(url.fileName());
313 }
314
315 void DolphinMainWindow::updateFilterBarAction(bool show)
316 {
317 KToggleAction* showFilterBarAction =
318 static_cast<KToggleAction*>(actionCollection()->action("show_filter_bar"));
319 showFilterBarAction->setChecked(show);
320 }
321
322 void DolphinMainWindow::openNewMainWindow()
323 {
324 DolphinApplication::app()->createMainWindow()->show();
325 }
326
327 void DolphinMainWindow::closeEvent(QCloseEvent* event)
328 {
329 DolphinSettings& settings = DolphinSettings::instance();
330 GeneralSettings* generalSettings = settings.generalSettings();
331 generalSettings->setFirstRun(false);
332
333 settings.save();
334
335 // TODO: I assume there will be a generic way in KDE 4 to store the docks
336 // of the main window. In the meantime they are stored manually:
337 QString filename = KStandardDirs::locateLocal("data", KGlobal::mainComponent().componentName());
338 filename.append("/panels_layout");
339 QFile file(filename);
340 if (file.open(QIODevice::WriteOnly)) {
341 QByteArray data = saveState();
342 file.write(data);
343 file.close();
344 }
345
346 KMainWindow::closeEvent(event);
347 }
348
349 void DolphinMainWindow::saveProperties(KConfig* config)
350 {
351 config->setGroup("Primary view");
352 config->writeEntry("Url", m_view[PrimaryIdx]->url().url());
353 config->writeEntry("Editable Url", m_view[PrimaryIdx]->isUrlEditable());
354 if (m_view[SecondaryIdx] != 0) {
355 config->setGroup("Secondary view");
356 config->writeEntry("Url", m_view[SecondaryIdx]->url().url());
357 config->writeEntry("Editable Url", m_view[SecondaryIdx]->isUrlEditable());
358 }
359 }
360
361 void DolphinMainWindow::readProperties(KConfig* config)
362 {
363 config->setGroup("Primary view");
364 m_view[PrimaryIdx]->setUrl(config->readEntry("Url"));
365 m_view[PrimaryIdx]->setUrlEditable(config->readEntry("Editable Url", false));
366 if (config->hasGroup("Secondary view")) {
367 config->setGroup("Secondary view");
368 if (m_view[SecondaryIdx] == 0) {
369 toggleSplitView();
370 }
371 m_view[SecondaryIdx]->setUrl(config->readEntry("Url"));
372 m_view[SecondaryIdx]->setUrlEditable(config->readEntry("Editable Url", false));
373 }
374 else if (m_view[SecondaryIdx] != 0) {
375 toggleSplitView();
376 }
377 }
378
379 void DolphinMainWindow::updateNewMenu()
380 {
381 m_newMenu->slotCheckUpToDate();
382 m_newMenu->setPopupFiles(activeView()->url());
383 }
384
385 void DolphinMainWindow::rename()
386 {
387 clearStatusBar();
388 m_activeView->renameSelectedItems();
389 }
390
391 void DolphinMainWindow::moveToTrash()
392 {
393 clearStatusBar();
394 const KUrl::List selectedUrls = m_activeView->selectedUrls();
395 KonqOperations::del(this, KonqOperations::TRASH, selectedUrls);
396 m_undoOperations.append(KonqOperations::TRASH);
397 }
398
399 void DolphinMainWindow::deleteItems()
400 {
401 clearStatusBar();
402
403 KUrl::List list = m_activeView->selectedUrls();
404 const uint itemCount = list.count();
405 assert(itemCount >= 1);
406
407 QString text;
408 if (itemCount > 1) {
409 text = i18n("Do you really want to delete the %1 selected items?",itemCount);
410 }
411 else {
412 const KUrl& url = list.first();
413 text = i18n("Do you really want to delete '%1'?",url.fileName());
414 }
415
416 const bool del = KMessageBox::warningContinueCancel(this,
417 text,
418 QString::null,
419 KGuiItem(i18n("Delete"), KIcon("editdelete"))
420 ) == KMessageBox::Continue;
421 if (del) {
422 KIO::Job* job = KIO::del(list);
423 connect(job, SIGNAL(result(KJob*)),
424 this, SLOT(slotHandleJobError(KJob*)));
425 connect(job, SIGNAL(result(KJob*)),
426 this, SLOT(slotDeleteFileFinished(KJob*)));
427 }
428 }
429
430 void DolphinMainWindow::properties()
431 {
432 const KFileItemList list = m_activeView->selectedItems();
433 new KPropertiesDialog(list, this);
434 }
435
436 void DolphinMainWindow::quit()
437 {
438 close();
439 }
440
441 void DolphinMainWindow::slotHandleJobError(KJob* job)
442 {
443 if (job->error() != 0) {
444 DolphinStatusBar* statusBar = m_activeView->statusBar();
445 statusBar->setMessage(job->errorString(),
446 DolphinStatusBar::Error);
447 }
448 }
449
450 void DolphinMainWindow::slotDeleteFileFinished(KJob* job)
451 {
452 if (job->error() == 0) {
453 DolphinStatusBar* statusBar = m_activeView->statusBar();
454 statusBar->setMessage(i18n("Delete operation completed."),
455 DolphinStatusBar::OperationCompleted);
456 }
457 }
458
459 void DolphinMainWindow::slotUndoAvailable(bool available)
460 {
461 QAction* undoAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::Undo));
462 if (undoAction != 0) {
463 undoAction->setEnabled(available);
464 }
465
466 if (available && (m_undoOperations.count() > 0)) {
467 const KonqOperations::Operation op = m_undoOperations.takeFirst();
468 DolphinStatusBar* statusBar = m_activeView->statusBar();
469 switch (op) {
470 case KonqOperations::COPY:
471 statusBar->setMessage(i18n("Copy operation completed."),
472 DolphinStatusBar::OperationCompleted);
473 break;
474 case KonqOperations::MOVE:
475 statusBar->setMessage(i18n("Move operation completed."),
476 DolphinStatusBar::OperationCompleted);
477 break;
478 case KonqOperations::LINK:
479 statusBar->setMessage(i18n("Link operation completed."),
480 DolphinStatusBar::OperationCompleted);
481 break;
482 case KonqOperations::TRASH:
483 statusBar->setMessage(i18n("Move to trash operation completed."),
484 DolphinStatusBar::OperationCompleted);
485 break;
486 default:
487 break;
488 }
489
490 }
491 }
492
493 void DolphinMainWindow::slotUndoTextChanged(const QString& text)
494 {
495 QAction* undoAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::Undo));
496 if (undoAction != 0) {
497 undoAction->setText(text);
498 }
499 }
500
501 void DolphinMainWindow::undo()
502 {
503 clearStatusBar();
504 KonqUndoManager::self()->undo();
505 }
506
507 void DolphinMainWindow::cut()
508 {
509 QMimeData* mimeData = new QMimeData();
510 const KUrl::List kdeUrls = m_activeView->selectedUrls();
511 const KUrl::List mostLocalUrls;
512 KonqMimeData::populateMimeData(mimeData, kdeUrls, mostLocalUrls, true);
513 QApplication::clipboard()->setMimeData(mimeData);
514 }
515
516 void DolphinMainWindow::copy()
517 {
518 QMimeData* mimeData = new QMimeData();
519 const KUrl::List kdeUrls = m_activeView->selectedUrls();
520 const KUrl::List mostLocalUrls;
521 KonqMimeData::populateMimeData(mimeData, kdeUrls, mostLocalUrls, false);
522
523 QApplication::clipboard()->setMimeData(mimeData);
524 }
525
526 void DolphinMainWindow::paste()
527 {
528 QClipboard* clipboard = QApplication::clipboard();
529 const QMimeData* mimeData = clipboard->mimeData();
530
531 clearStatusBar();
532
533 const KUrl::List sourceUrls = KUrl::List::fromMimeData(mimeData);
534
535 // per default the pasting is done into the current Url of the view
536 KUrl destUrl(m_activeView->url());
537
538 // check whether the pasting should be done into a selected directory
539 KUrl::List selectedUrls = m_activeView->selectedUrls();
540 if (selectedUrls.count() == 1) {
541 const KFileItem fileItem(S_IFDIR,
542 KFileItem::Unknown,
543 selectedUrls.first(),
544 true);
545 if (fileItem.isDir()) {
546 // only one item is selected which is a directory, hence paste
547 // into this directory
548 destUrl = selectedUrls.first();
549 }
550 }
551
552 if (KonqMimeData::decodeIsCutSelection(mimeData)) {
553 moveUrls(sourceUrls, destUrl);
554 clipboard->clear();
555 }
556 else {
557 copyUrls(sourceUrls, destUrl);
558 }
559 }
560
561 void DolphinMainWindow::updatePasteAction()
562 {
563 QAction* pasteAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::Paste));
564 if (pasteAction == 0) {
565 return;
566 }
567
568 QString text(i18n("Paste"));
569 QClipboard* clipboard = QApplication::clipboard();
570 const QMimeData* mimeData = clipboard->mimeData();
571
572 KUrl::List urls = KUrl::List::fromMimeData(mimeData);
573 if (!urls.isEmpty()) {
574 pasteAction->setEnabled(true);
575
576 const int count = urls.count();
577 if (count == 1) {
578 pasteAction->setText(i18n("Paste 1 File"));
579 }
580 else {
581 pasteAction->setText(i18n("Paste %1 Files").arg(count));
582 }
583 }
584 else {
585 pasteAction->setEnabled(false);
586 pasteAction->setText(i18n("Paste"));
587 }
588
589 if (pasteAction->isEnabled()) {
590 KUrl::List urls = m_activeView->selectedUrls();
591 const uint count = urls.count();
592 if (count > 1) {
593 // pasting should not be allowed when more than one file
594 // is selected
595 pasteAction->setEnabled(false);
596 }
597 else if (count == 1) {
598 // Only one file is selected. Pasting is only allowed if this
599 // file is a directory.
600 // TODO: this doesn't work with remote protocols; instead we need a
601 // m_activeView->selectedFileItems() to get the real KFileItems
602 const KFileItem fileItem(S_IFDIR,
603 KFileItem::Unknown,
604 urls.first(),
605 true);
606 pasteAction->setEnabled(fileItem.isDir());
607 }
608 }
609 }
610
611 void DolphinMainWindow::selectAll()
612 {
613 clearStatusBar();
614 m_activeView->selectAll();
615 }
616
617 void DolphinMainWindow::invertSelection()
618 {
619 clearStatusBar();
620 m_activeView->invertSelection();
621 }
622 void DolphinMainWindow::setIconsView()
623 {
624 m_activeView->setMode(DolphinView::IconsView);
625 }
626
627 void DolphinMainWindow::setDetailsView()
628 {
629 m_activeView->setMode(DolphinView::DetailsView);
630 }
631
632 void DolphinMainWindow::sortByName()
633 {
634 m_activeView->setSorting(DolphinView::SortByName);
635 }
636
637 void DolphinMainWindow::sortBySize()
638 {
639 m_activeView->setSorting(DolphinView::SortBySize);
640 }
641
642 void DolphinMainWindow::sortByDate()
643 {
644 m_activeView->setSorting(DolphinView::SortByDate);
645 }
646
647 void DolphinMainWindow::sortByPermissions()
648 {
649 m_activeView->setSorting(DolphinView::SortByPermissions);
650 }
651
652 void DolphinMainWindow::sortByOwner()
653 {
654 m_activeView->setSorting(DolphinView::SortByOwner);
655 }
656
657 void DolphinMainWindow::sortByGroup()
658 {
659 m_activeView->setSorting(DolphinView::SortByGroup);
660 }
661
662 void DolphinMainWindow::toggleSortOrder()
663 {
664 const Qt::SortOrder order = (m_activeView->sortOrder() == Qt::Ascending) ?
665 Qt::Descending :
666 Qt::Ascending;
667 m_activeView->setSortOrder(order);
668 }
669
670 void DolphinMainWindow::toggleSplitView()
671 {
672 if (m_view[SecondaryIdx] == 0) {
673 const int newWidth = (m_view[PrimaryIdx]->width() - m_splitter->handleWidth()) / 2;
674 // create a secondary view
675 m_view[SecondaryIdx] = new DolphinView(this,
676 0,
677 m_view[PrimaryIdx]->url(),
678 m_view[PrimaryIdx]->mode(),
679 m_view[PrimaryIdx]->showHiddenFiles());
680 connectViewSignals(SecondaryIdx);
681 m_splitter->addWidget(m_view[SecondaryIdx]);
682 m_splitter->setSizes(QList<int>() << newWidth << newWidth);
683 m_view[SecondaryIdx]->show();
684 }
685 else {
686 // remove secondary view
687 if (m_activeView == m_view[PrimaryIdx]) {
688 m_view[SecondaryIdx]->close();
689 m_view[SecondaryIdx]->deleteLater();
690 m_view[SecondaryIdx] = 0;
691 setActiveView(m_view[PrimaryIdx]);
692 }
693 else {
694 // The secondary view is active, hence from the users point of view
695 // the content of the secondary view should be moved to the primary view.
696 // From an implementation point of view it is more efficient to close
697 // the primary view and exchange the internal pointers afterwards.
698 m_view[PrimaryIdx]->close();
699 delete m_view[PrimaryIdx];
700 m_view[PrimaryIdx] = m_view[SecondaryIdx];
701 m_view[SecondaryIdx] = 0;
702 setActiveView(m_view[PrimaryIdx]);
703 }
704 }
705 }
706
707 void DolphinMainWindow::reloadView()
708 {
709 clearStatusBar();
710 m_activeView->reload();
711 }
712
713 void DolphinMainWindow::stopLoading()
714 {
715 }
716
717 void DolphinMainWindow::togglePreview()
718 {
719 clearStatusBar();
720
721 const KToggleAction* showPreviewAction =
722 static_cast<KToggleAction*>(actionCollection()->action("show_preview"));
723 const bool show = showPreviewAction->isChecked();
724 m_activeView->setShowPreview(show);
725 }
726
727 void DolphinMainWindow::toggleShowHiddenFiles()
728 {
729 clearStatusBar();
730
731 const KToggleAction* showHiddenFilesAction =
732 static_cast<KToggleAction*>(actionCollection()->action("show_hidden_files"));
733 const bool show = showHiddenFilesAction->isChecked();
734 m_activeView->setShowHiddenFiles(show);
735 }
736
737 void DolphinMainWindow::showFilterBar()
738 {
739 const KToggleAction* showFilterBarAction =
740 static_cast<KToggleAction*>(actionCollection()->action("show_filter_bar"));
741 const bool show = showFilterBarAction->isChecked();
742 m_activeView->showFilterBar(show);
743 }
744
745 void DolphinMainWindow::zoomIn()
746 {
747 m_activeView->zoomIn();
748 updateViewActions();
749 }
750
751 void DolphinMainWindow::zoomOut()
752 {
753 m_activeView->zoomOut();
754 updateViewActions();
755 }
756
757 void DolphinMainWindow::toggleEditLocation()
758 {
759 clearStatusBar();
760
761 KToggleAction* action = static_cast<KToggleAction*>(actionCollection()->action("editable_location"));
762
763 bool editOrBrowse = action->isChecked();
764 m_activeView->setUrlEditable(editOrBrowse);
765 }
766
767 void DolphinMainWindow::editLocation()
768 {
769 KToggleAction* action = static_cast<KToggleAction*>(actionCollection()->action("editable_location"));
770 action->setChecked(true);
771 m_activeView->setUrlEditable(true);
772 }
773
774 void DolphinMainWindow::adjustViewProperties()
775 {
776 clearStatusBar();
777 ViewPropertiesDialog dlg(m_activeView);
778 dlg.exec();
779 }
780
781 void DolphinMainWindow::goBack()
782 {
783 clearStatusBar();
784 m_activeView->goBack();
785 }
786
787 void DolphinMainWindow::goForward()
788 {
789 clearStatusBar();
790 m_activeView->goForward();
791 }
792
793 void DolphinMainWindow::goUp()
794 {
795 clearStatusBar();
796 m_activeView->goUp();
797 }
798
799 void DolphinMainWindow::goHome()
800 {
801 clearStatusBar();
802 m_activeView->goHome();
803 }
804
805 void DolphinMainWindow::openTerminal()
806 {
807 QString command("konsole --workdir \"");
808 command.append(m_activeView->url().path());
809 command.append('\"');
810
811 KRun::runCommand(command, "Konsole", "konsole");
812 }
813
814 void DolphinMainWindow::findFile()
815 {
816 KRun::run("kfind", m_activeView->url());
817 }
818
819 void DolphinMainWindow::compareFiles()
820 {
821 // The method is only invoked if exactly 2 files have
822 // been selected. The selected files may be:
823 // - both in the primary view
824 // - both in the secondary view
825 // - one in the primary view and the other in the secondary
826 // view
827 assert(m_view[PrimaryIdx] != 0);
828
829 KUrl urlA;
830 KUrl urlB;
831 KUrl::List urls = m_view[PrimaryIdx]->selectedUrls();
832
833 switch (urls.count()) {
834 case 0: {
835 assert(m_view[SecondaryIdx] != 0);
836 urls = m_view[SecondaryIdx]->selectedUrls();
837 assert(urls.count() == 2);
838 urlA = urls[0];
839 urlB = urls[1];
840 break;
841 }
842
843 case 1: {
844 urlA = urls[0];
845 assert(m_view[SecondaryIdx] != 0);
846 urls = m_view[SecondaryIdx]->selectedUrls();
847 assert(urls.count() == 1);
848 urlB = urls[0];
849 break;
850 }
851
852 case 2: {
853 urlA = urls[0];
854 urlB = urls[1];
855 break;
856 }
857
858 default: {
859 // may not happen: compareFiles may only get invoked if 2
860 // files are selected
861 assert(false);
862 }
863 }
864
865 QString command("kompare -c \"");
866 command.append(urlA.pathOrUrl());
867 command.append("\" \"");
868 command.append(urlB.pathOrUrl());
869 command.append('\"');
870 KRun::runCommand(command, "Kompare", "kompare");
871
872 }
873
874 void DolphinMainWindow::editSettings()
875 {
876 // TODO: make a static method for opening the settings dialog
877 DolphinSettingsDialog dlg(this);
878 dlg.exec();
879 }
880
881 void DolphinMainWindow::init()
882 {
883 // Check whether Dolphin runs the first time. If yes then
884 // a proper default window size is given at the end of DolphinMainWindow::init().
885 GeneralSettings* generalSettings = DolphinSettings::instance().generalSettings();
886 const bool firstRun = generalSettings->firstRun();
887
888 setAcceptDrops(true);
889
890 m_splitter = new QSplitter(this);
891
892 DolphinSettings& settings = DolphinSettings::instance();
893
894 KBookmarkManager* manager = settings.bookmarkManager();
895 assert(manager != 0);
896 KBookmarkGroup root = manager->root();
897 if (root.first().isNull()) {
898 root.addBookmark(manager, i18n("Home"), settings.generalSettings()->homeUrl(), "folder_home");
899 root.addBookmark(manager, i18n("Storage Media"), KUrl("media:/"), "blockdevice");
900 root.addBookmark(manager, i18n("Network"), KUrl("remote:/"), "network_local");
901 root.addBookmark(manager, i18n("Root"), KUrl("/"), "folder_red");
902 root.addBookmark(manager, i18n("Trash"), KUrl("trash:/"), "trashcan_full");
903 }
904
905 setupActions();
906
907 const KUrl& homeUrl = root.first().url();
908 setCaption(homeUrl.fileName());
909 ViewProperties props(homeUrl);
910 m_view[PrimaryIdx] = new DolphinView(this,
911 m_splitter,
912 homeUrl,
913 props.viewMode(),
914 props.showHiddenFiles());
915 connectViewSignals(PrimaryIdx);
916 m_view[PrimaryIdx]->show();
917
918 m_activeView = m_view[PrimaryIdx];
919
920 setCentralWidget(m_splitter);
921 setupDockWidgets();
922
923 setupGUI(Keys|Save|Create|ToolBar);
924 createGUI();
925
926 stateChanged("new_file");
927 setAutoSaveSettings();
928
929 QClipboard* clipboard = QApplication::clipboard();
930 connect(clipboard, SIGNAL(dataChanged()),
931 this, SLOT(updatePasteAction()));
932 updatePasteAction();
933 updateGoActions();
934
935 loadSettings();
936
937 if (firstRun) {
938 // assure a proper default size if Dolphin runs the first time
939 resize(640, 480);
940 }
941 }
942
943 void DolphinMainWindow::loadSettings()
944 {
945 GeneralSettings* settings = DolphinSettings::instance().generalSettings();
946
947 KToggleAction* splitAction = static_cast<KToggleAction*>(actionCollection()->action("split_view"));
948 if (settings->splitView()) {
949 splitAction->setChecked(true);
950 toggleSplitView();
951 }
952
953 updateViewActions();
954
955 // TODO: I assume there will be a generic way in KDE 4 to restore the docks
956 // of the main window. In the meantime they are restored manually (see also
957 // DolphinMainWindow::closeEvent() for more details):
958 QString filename = KStandardDirs::locateLocal("data", KGlobal::mainComponent().componentName()); filename.append("/panels_layout");
959 QFile file(filename);
960 if (file.open(QIODevice::ReadOnly)) {
961 QByteArray data = file.readAll();
962 restoreState(data);
963 file.close();
964 }
965 }
966
967 void DolphinMainWindow::setupActions()
968 {
969 // setup 'File' menu
970 m_newMenu = new DolphinNewMenu(this);
971 KMenu* menu = m_newMenu->menu();
972 menu->setTitle(i18n("Create New..."));
973 menu->setIcon(SmallIcon("filenew"));
974 connect(menu, SIGNAL(aboutToShow()),
975 this, SLOT(updateNewMenu()));
976
977 QAction* action = actionCollection()->addAction("new_window");
978 action->setIcon(KIcon("window_new"));
979 action->setText(i18n("New &Window"));
980 connect(action, SIGNAL(triggered()), this, SLOT(openNewMainWindow()));
981
982 QAction* rename = actionCollection()->addAction("rename");
983 rename->setText(i18n("Rename"));
984 rename->setShortcut(Qt::Key_F2);
985 connect(rename, SIGNAL(triggered()), this, SLOT(rename()));
986
987 QAction* moveToTrash = actionCollection()->addAction("move_to_trash");
988 moveToTrash->setText(i18n("Move to Trash"));
989 moveToTrash->setIcon(KIcon("edittrash"));
990 moveToTrash->setShortcut(QKeySequence::Delete);
991 connect(moveToTrash, SIGNAL(triggered()), this, SLOT(moveToTrash()));
992
993 QAction* deleteAction = actionCollection()->addAction("delete");
994 deleteAction->setText(i18n("Delete"));
995 deleteAction->setShortcut(Qt::ALT | Qt::Key_Delete);
996 deleteAction->setIcon(KIcon("editdelete"));
997 connect(deleteAction, SIGNAL(triggered()), this, SLOT(deleteItems()));
998
999 QAction* properties = actionCollection()->addAction("properties");
1000 properties->setText(i18n("Propert&ies"));
1001 properties->setShortcut(Qt::Key_Alt | Qt::Key_Return);
1002 connect(properties, SIGNAL(triggered()), this, SLOT(properties()));
1003
1004 KStandardAction::quit(this, SLOT(quit()), actionCollection());
1005
1006 // setup 'Edit' menu
1007 KStandardAction::undo(this,
1008 SLOT(undo()),
1009 actionCollection());
1010
1011 KStandardAction::cut(this, SLOT(cut()), actionCollection());
1012 KStandardAction::copy(this, SLOT(copy()), actionCollection());
1013 KStandardAction::paste(this, SLOT(paste()), actionCollection());
1014
1015 QAction* selectAll = actionCollection()->addAction("select_all");
1016 selectAll->setText(i18n("Select All"));
1017 selectAll->setShortcut(Qt::CTRL + Qt::Key_A);
1018 connect(selectAll, SIGNAL(triggered()), this, SLOT(selectAll()));
1019
1020 QAction* invertSelection = actionCollection()->addAction("invert_selection");
1021 invertSelection->setText(i18n("Invert Selection"));
1022 invertSelection->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_A);
1023 connect(invertSelection, SIGNAL(triggered()), this, SLOT(invertSelection()));
1024
1025 // setup 'View' menu
1026 KStandardAction::zoomIn(this,
1027 SLOT(zoomIn()),
1028 actionCollection());
1029
1030 KStandardAction::zoomOut(this,
1031 SLOT(zoomOut()),
1032 actionCollection());
1033
1034 KToggleAction* iconsView = actionCollection()->add<KToggleAction>("icons");
1035 iconsView->setText(i18n("Icons"));
1036 iconsView->setShortcut(Qt::CTRL | Qt::Key_1);
1037 iconsView->setIcon(KIcon("view_icon"));
1038 connect(iconsView, SIGNAL(triggered()), this, SLOT(setIconsView()));
1039
1040 KToggleAction* detailsView = actionCollection()->add<KToggleAction>("details");
1041 detailsView->setText(i18n("Details"));
1042 detailsView->setShortcut(Qt::CTRL | Qt::Key_2);
1043 detailsView->setIcon(KIcon("view_text"));
1044 connect(detailsView, SIGNAL(triggered()), this, SLOT(setDetailsView()));
1045
1046 QActionGroup* viewModeGroup = new QActionGroup(this);
1047 viewModeGroup->addAction(iconsView);
1048 viewModeGroup->addAction(detailsView);
1049
1050 KToggleAction* sortByName = actionCollection()->add<KToggleAction>("by_name");
1051 sortByName->setText(i18n("By Name"));
1052 connect(sortByName, SIGNAL(triggered()), this, SLOT(sortByName()));
1053
1054 KToggleAction* sortBySize = actionCollection()->add<KToggleAction>("by_size");
1055 sortBySize->setText(i18n("By Size"));
1056 connect(sortBySize, SIGNAL(triggered()), this, SLOT(sortBySize()));
1057
1058 KToggleAction* sortByDate = actionCollection()->add<KToggleAction>("by_date");
1059 sortByDate->setText(i18n("By Date"));
1060 connect(sortByDate, SIGNAL(triggered()), this, SLOT(sortByDate()));
1061
1062 KToggleAction* sortByPermissions = actionCollection()->add<KToggleAction>("by_permissions");
1063 sortByPermissions->setText(i18n("By Permissions"));
1064 connect(sortByPermissions, SIGNAL(triggered()), this, SLOT(sortByPermissions()));
1065
1066 KToggleAction* sortByOwner = actionCollection()->add<KToggleAction>("by_owner");
1067 sortByOwner->setText(i18n("By Owner"));
1068 connect(sortByOwner, SIGNAL(triggered()), this, SLOT(sortByOwner()));
1069
1070 KToggleAction* sortByGroup = actionCollection()->add<KToggleAction>("by_group");
1071 sortByGroup->setText(i18n("By Group"));
1072 connect(sortByGroup, SIGNAL(triggered()), this, SLOT(sortByGroup()));
1073
1074 QActionGroup* sortGroup = new QActionGroup(this);
1075 sortGroup->addAction(sortByName);
1076 sortGroup->addAction(sortBySize);
1077 sortGroup->addAction(sortByDate);
1078 sortGroup->addAction(sortByPermissions);
1079 sortGroup->addAction(sortByOwner);
1080 sortGroup->addAction(sortByGroup);
1081
1082 KToggleAction* sortDescending = actionCollection()->add<KToggleAction>("descending");
1083 sortDescending->setText(i18n("Descending"));
1084 connect(sortDescending, SIGNAL(triggered()), this, SLOT(toggleSortOrder()));
1085
1086 KToggleAction* showPreview = actionCollection()->add<KToggleAction>("show_preview");
1087 showPreview->setText(i18n("Show Preview"));
1088 connect(showPreview, SIGNAL(triggered()), this, SLOT(togglePreview()));
1089
1090 KToggleAction* showHiddenFiles = actionCollection()->add<KToggleAction>("show_hidden_files");
1091 showHiddenFiles->setText(i18n("Show Hidden Files"));
1092 //showHiddenFiles->setShortcut(Qt::ALT | Qt::Key_ KDE4-TODO: what Qt-Key represents '.'?
1093 connect(showHiddenFiles, SIGNAL(triggered()), this, SLOT(toggleShowHiddenFiles()));
1094
1095 KToggleAction* split = actionCollection()->add<KToggleAction>("split_view");
1096 split->setText(i18n("Split View"));
1097 split->setShortcut(Qt::Key_F10);
1098 split->setIcon(KIcon("view_left_right"));
1099 connect(split, SIGNAL(triggered()), this, SLOT(toggleSplitView()));
1100
1101 QAction* reload = actionCollection()->addAction("reload");
1102 reload->setText(i18n("Reload"));
1103 reload->setShortcut(Qt::Key_F5);
1104 reload->setIcon(KIcon("reload"));
1105 connect(reload, SIGNAL(triggered()), this, SLOT(reloadView()));
1106
1107 QAction* stop = actionCollection()->addAction("stop");
1108 stop->setText(i18n("Stop"));
1109 stop->setIcon(KIcon("stop"));
1110 connect(stop, SIGNAL(triggered()), this, SLOT(stopLoading()));
1111
1112 KToggleAction* showFullLocation = actionCollection()->add<KToggleAction>("editable_location");
1113 showFullLocation->setText(i18n("Show Full Location"));
1114 showFullLocation->setShortcut(Qt::CTRL | Qt::Key_L);
1115 connect(showFullLocation, SIGNAL(triggered()), this, SLOT(toggleEditLocation()));
1116
1117 KToggleAction* editLocation = actionCollection()->add<KToggleAction>("edit_location");
1118 editLocation->setText(i18n("Edit Location"));
1119 editLocation->setShortcut(Qt::Key_F6);
1120 connect(editLocation, SIGNAL(triggered()), this, SLOT(editLocation()));
1121
1122 QAction* adjustViewProps = actionCollection()->addAction("view_properties");
1123 adjustViewProps->setText(i18n("Adjust View Properties..."));
1124 connect(adjustViewProps, SIGNAL(triggered()), this, SLOT(adjustViewProperties()));
1125
1126 // setup 'Go' menu
1127 KStandardAction::back(this, SLOT(goBack()), actionCollection());
1128 KStandardAction::forward(this, SLOT(goForward()), actionCollection());
1129 KStandardAction::up(this, SLOT(goUp()), actionCollection());
1130 KStandardAction::home(this, SLOT(goHome()), actionCollection());
1131
1132 // setup 'Tools' menu
1133 QAction* openTerminal = actionCollection()->addAction("open_terminal");
1134 openTerminal->setText(i18n("Open Terminal"));
1135 openTerminal->setShortcut(Qt::Key_F4);
1136 openTerminal->setIcon(KIcon("konsole"));
1137 connect(openTerminal, SIGNAL(triggered()), this, SLOT(openTerminal()));
1138
1139 QAction* findFile = actionCollection()->addAction("find_file");
1140 findFile->setText(i18n("Find File..."));
1141 findFile->setShortcut(Qt::Key_F);
1142 findFile->setIcon(KIcon("filefind"));
1143 connect(findFile, SIGNAL(triggered()), this, SLOT(findFile()));
1144
1145 KToggleAction* showFilterBar = actionCollection()->add<KToggleAction>("show_filter_bar");
1146 showFilterBar->setText(i18n("Show Filter Bar"));
1147 showFilterBar->setShortcut(Qt::Key_Slash);
1148 connect(showFilterBar, SIGNAL(triggered()), this, SLOT(showFilterBar()));
1149
1150 QAction* compareFiles = actionCollection()->addAction("compare_files");
1151 compareFiles->setText(i18n("Compare Files"));
1152 compareFiles->setIcon(KIcon("kompare"));
1153 compareFiles->setEnabled(false);
1154 connect(compareFiles, SIGNAL(triggered()), this, SLOT(compareFiles()));
1155
1156 // setup 'Settings' menu
1157 KStandardAction::preferences(this, SLOT(editSettings()), actionCollection());
1158 }
1159
1160 void DolphinMainWindow::setupDockWidgets()
1161 {
1162 QDockWidget* shortcutsDock = new QDockWidget(i18n("Bookmarks"));
1163 shortcutsDock->setObjectName("bookmarksDock");
1164 shortcutsDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
1165 shortcutsDock->setWidget(new BookmarksSidebarPage(this));
1166
1167 shortcutsDock->toggleViewAction()->setText(i18n("Show Bookmarks Panel"));
1168 actionCollection()->addAction("show_bookmarks_panel", shortcutsDock->toggleViewAction());
1169
1170 addDockWidget(Qt::LeftDockWidgetArea, shortcutsDock);
1171
1172 QDockWidget* infoDock = new QDockWidget(i18n("Information"));
1173 infoDock->setObjectName("infoDock");
1174 infoDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
1175 infoDock->setWidget(new InfoSidebarPage(this));
1176
1177 infoDock->toggleViewAction()->setText(i18n("Show Information Panel"));
1178 actionCollection()->addAction("show_info_panel", infoDock->toggleViewAction());
1179
1180 addDockWidget(Qt::RightDockWidgetArea, infoDock);
1181 }
1182
1183 void DolphinMainWindow::updateHistory()
1184 {
1185 int index = 0;
1186 const QLinkedList<UrlNavigator::HistoryElem> list = m_activeView->urlHistory(index);
1187
1188 QAction* backAction = actionCollection()->action("go_back");
1189 if (backAction != 0) {
1190 backAction->setEnabled(index < static_cast<int>(list.count()) - 1);
1191 }
1192
1193 QAction* forwardAction = actionCollection()->action("go_forward");
1194 if (forwardAction != 0) {
1195 forwardAction->setEnabled(index > 0);
1196 }
1197 }
1198
1199 void DolphinMainWindow::updateEditActions()
1200 {
1201 const KFileItemList list = m_activeView->selectedItems();
1202 if (list.isEmpty()) {
1203 stateChanged("has_no_selection");
1204 }
1205 else {
1206 stateChanged("has_selection");
1207
1208 QAction* renameAction = actionCollection()->action("rename");
1209 if (renameAction != 0) {
1210 renameAction->setEnabled(list.count() >= 1);
1211 }
1212
1213 bool enableMoveToTrash = true;
1214
1215 KFileItemList::const_iterator it = list.begin();
1216 const KFileItemList::const_iterator end = list.end();
1217 while (it != end) {
1218 KFileItem* item = *it;
1219 const KUrl& url = item->url();
1220 // only enable the 'Move to Trash' action for local files
1221 if (!url.isLocalFile()) {
1222 enableMoveToTrash = false;
1223 }
1224 ++it;
1225 }
1226
1227 QAction* moveToTrashAction = actionCollection()->action("move_to_trash");
1228 moveToTrashAction->setEnabled(enableMoveToTrash);
1229 }
1230 updatePasteAction();
1231 }
1232
1233 void DolphinMainWindow::updateViewActions()
1234 {
1235 QAction* zoomInAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::ZoomIn));
1236 if (zoomInAction != 0) {
1237 zoomInAction->setEnabled(m_activeView->isZoomInPossible());
1238 }
1239
1240 QAction* zoomOutAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::ZoomOut));
1241 if (zoomOutAction != 0) {
1242 zoomOutAction->setEnabled(m_activeView->isZoomOutPossible());
1243 }
1244
1245 QAction* action = 0;
1246 switch (m_activeView->mode()) {
1247 case DolphinView::IconsView:
1248 action = actionCollection()->action("icons");
1249 break;
1250 case DolphinView::DetailsView:
1251 action = actionCollection()->action("details");
1252 break;
1253 default:
1254 break;
1255 }
1256
1257 if (action != 0) {
1258 KToggleAction* toggleAction = static_cast<KToggleAction*>(action);
1259 toggleAction->setChecked(true);
1260 }
1261
1262 slotSortingChanged(m_activeView->sorting());
1263 slotSortOrderChanged(m_activeView->sortOrder());
1264
1265 KToggleAction* showFilterBarAction =
1266 static_cast<KToggleAction*>(actionCollection()->action("show_filter_bar"));
1267 showFilterBarAction->setChecked(m_activeView->isFilterBarVisible());
1268
1269 KToggleAction* showHiddenFilesAction =
1270 static_cast<KToggleAction*>(actionCollection()->action("show_hidden_files"));
1271 showHiddenFilesAction->setChecked(m_activeView->showHiddenFiles());
1272
1273 KToggleAction* splitAction = static_cast<KToggleAction*>(actionCollection()->action("split_view"));
1274 splitAction->setChecked(m_view[SecondaryIdx] != 0);
1275 }
1276
1277 void DolphinMainWindow::updateGoActions()
1278 {
1279 QAction* goUpAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::Up));
1280 const KUrl& currentUrl = m_activeView->url();
1281 goUpAction->setEnabled(currentUrl.upUrl() != currentUrl);
1282 }
1283
1284 void DolphinMainWindow::copyUrls(const KUrl::List& source, const KUrl& dest)
1285 {
1286 KonqOperations::copy(this, KonqOperations::COPY, source, dest);
1287 m_undoOperations.append(KonqOperations::COPY);
1288 }
1289
1290 void DolphinMainWindow::moveUrls(const KUrl::List& source, const KUrl& dest)
1291 {
1292 KonqOperations::copy(this, KonqOperations::MOVE, source, dest);
1293 m_undoOperations.append(KonqOperations::MOVE);
1294 }
1295
1296 void DolphinMainWindow::linkUrls(const KUrl::List& source, const KUrl& dest)
1297 {
1298 KonqOperations::copy(this, KonqOperations::LINK, source, dest);
1299 m_undoOperations.append(KonqOperations::LINK);
1300 }
1301
1302 void DolphinMainWindow::clearStatusBar()
1303 {
1304 m_activeView->statusBar()->clear();
1305 }
1306
1307 void DolphinMainWindow::connectViewSignals(int viewIndex)
1308 {
1309 DolphinView* view = m_view[viewIndex];
1310 connect(view, SIGNAL(modeChanged()),
1311 this, SLOT(slotViewModeChanged()));
1312 connect(view, SIGNAL(showHiddenFilesChanged()),
1313 this, SLOT(slotShowHiddenFilesChanged()));
1314 connect(view, SIGNAL(sortingChanged(DolphinView::Sorting)),
1315 this, SLOT(slotSortingChanged(DolphinView::Sorting)));
1316 connect(view, SIGNAL(sortOrderChanged(Qt::SortOrder)),
1317 this, SLOT(slotSortOrderChanged(Qt::SortOrder)));
1318 connect(view, SIGNAL(selectionChanged()),
1319 this, SLOT(slotSelectionChanged()));
1320 connect(view, SIGNAL(showFilterBarChanged(bool)),
1321 this, SLOT(updateFilterBarAction(bool)));
1322
1323 const UrlNavigator* navigator = view->urlNavigator();
1324 connect(navigator, SIGNAL(urlChanged(const KUrl&)),
1325 this, SLOT(slotUrlChanged(const KUrl&)));
1326 connect(navigator, SIGNAL(historyChanged()),
1327 this, SLOT(slotHistoryChanged()));
1328
1329 }
1330
1331 DolphinMainWindow::UndoUiInterface::UndoUiInterface(DolphinMainWindow* mainWin) :
1332 KonqUndoManager::UiInterface(mainWin),
1333 m_mainWin(mainWin)
1334 {
1335 assert(m_mainWin != 0);
1336 }
1337
1338 DolphinMainWindow::UndoUiInterface::~UndoUiInterface()
1339 {
1340 }
1341
1342 void DolphinMainWindow::UndoUiInterface::jobError(KIO::Job* job)
1343 {
1344 DolphinStatusBar* statusBar = m_mainWin->activeView()->statusBar();
1345 statusBar->setMessage(job->errorString(), DolphinStatusBar::Error);
1346 }
1347
1348 #include "dolphinmainwindow.moc"