]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinmainwindow.cpp
Fixed shortcuts, removed warnings.
[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 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 {
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 emit activeViewChanged();
706 }
707
708 void DolphinMainWindow::reloadView()
709 {
710 clearStatusBar();
711 m_activeView->reload();
712 }
713
714 void DolphinMainWindow::stopLoading()
715 {
716 }
717
718 void DolphinMainWindow::togglePreview()
719 {
720 clearStatusBar();
721
722 const KToggleAction* showPreviewAction =
723 static_cast<KToggleAction*>(actionCollection()->action("show_preview"));
724 const bool show = showPreviewAction->isChecked();
725 m_activeView->setShowPreview(show);
726 }
727
728 void DolphinMainWindow::toggleShowHiddenFiles()
729 {
730 clearStatusBar();
731
732 const KToggleAction* showHiddenFilesAction =
733 static_cast<KToggleAction*>(actionCollection()->action("show_hidden_files"));
734 const bool show = showHiddenFilesAction->isChecked();
735 m_activeView->setShowHiddenFiles(show);
736 }
737
738 void DolphinMainWindow::showFilterBar()
739 {
740 const KToggleAction* showFilterBarAction =
741 static_cast<KToggleAction*>(actionCollection()->action("show_filter_bar"));
742 const bool show = showFilterBarAction->isChecked();
743 m_activeView->showFilterBar(show);
744 }
745
746 void DolphinMainWindow::zoomIn()
747 {
748 m_activeView->zoomIn();
749 updateViewActions();
750 }
751
752 void DolphinMainWindow::zoomOut()
753 {
754 m_activeView->zoomOut();
755 updateViewActions();
756 }
757
758 void DolphinMainWindow::toggleEditLocation()
759 {
760 clearStatusBar();
761
762 KToggleAction* action = static_cast<KToggleAction*>(actionCollection()->action("editable_location"));
763
764 bool editOrBrowse = action->isChecked();
765 m_activeView->setUrlEditable(editOrBrowse);
766 }
767
768 void DolphinMainWindow::editLocation()
769 {
770 m_activeView->setUrlEditable(true);
771 }
772
773 void DolphinMainWindow::adjustViewProperties()
774 {
775 clearStatusBar();
776 ViewPropertiesDialog dlg(m_activeView);
777 dlg.exec();
778 }
779
780 void DolphinMainWindow::goBack()
781 {
782 clearStatusBar();
783 m_activeView->goBack();
784 }
785
786 void DolphinMainWindow::goForward()
787 {
788 clearStatusBar();
789 m_activeView->goForward();
790 }
791
792 void DolphinMainWindow::goUp()
793 {
794 clearStatusBar();
795 m_activeView->goUp();
796 }
797
798 void DolphinMainWindow::goHome()
799 {
800 clearStatusBar();
801 m_activeView->goHome();
802 }
803
804 void DolphinMainWindow::openTerminal()
805 {
806 QString command("konsole --workdir \"");
807 command.append(m_activeView->url().path());
808 command.append('\"');
809
810 KRun::runCommand(command, "Konsole", "konsole");
811 }
812
813 void DolphinMainWindow::findFile()
814 {
815 KRun::run("kfind", m_activeView->url());
816 }
817
818 void DolphinMainWindow::compareFiles()
819 {
820 // The method is only invoked if exactly 2 files have
821 // been selected. The selected files may be:
822 // - both in the primary view
823 // - both in the secondary view
824 // - one in the primary view and the other in the secondary
825 // view
826 assert(m_view[PrimaryIdx] != 0);
827
828 KUrl urlA;
829 KUrl urlB;
830 KUrl::List urls = m_view[PrimaryIdx]->selectedUrls();
831
832 switch (urls.count()) {
833 case 0: {
834 assert(m_view[SecondaryIdx] != 0);
835 urls = m_view[SecondaryIdx]->selectedUrls();
836 assert(urls.count() == 2);
837 urlA = urls[0];
838 urlB = urls[1];
839 break;
840 }
841
842 case 1: {
843 urlA = urls[0];
844 assert(m_view[SecondaryIdx] != 0);
845 urls = m_view[SecondaryIdx]->selectedUrls();
846 assert(urls.count() == 1);
847 urlB = urls[0];
848 break;
849 }
850
851 case 2: {
852 urlA = urls[0];
853 urlB = urls[1];
854 break;
855 }
856
857 default: {
858 // may not happen: compareFiles may only get invoked if 2
859 // files are selected
860 assert(false);
861 }
862 }
863
864 QString command("kompare -c \"");
865 command.append(urlA.pathOrUrl());
866 command.append("\" \"");
867 command.append(urlB.pathOrUrl());
868 command.append('\"');
869 KRun::runCommand(command, "Kompare", "kompare");
870
871 }
872
873 void DolphinMainWindow::editSettings()
874 {
875 // TODO: make a static method for opening the settings dialog
876 DolphinSettingsDialog dlg(this);
877 dlg.exec();
878 }
879
880 void DolphinMainWindow::init()
881 {
882 // Check whether Dolphin runs the first time. If yes then
883 // a proper default window size is given at the end of DolphinMainWindow::init().
884 GeneralSettings* generalSettings = DolphinSettings::instance().generalSettings();
885 const bool firstRun = generalSettings->firstRun();
886
887 setAcceptDrops(true);
888
889 m_splitter = new QSplitter(this);
890
891 DolphinSettings& settings = DolphinSettings::instance();
892
893 KBookmarkManager* manager = settings.bookmarkManager();
894 assert(manager != 0);
895 KBookmarkGroup root = manager->root();
896 if (root.first().isNull()) {
897 root.addBookmark(manager, i18n("Home"), settings.generalSettings()->homeUrl(), "folder_home");
898 root.addBookmark(manager, i18n("Storage Media"), KUrl("media:/"), "blockdevice");
899 root.addBookmark(manager, i18n("Network"), KUrl("remote:/"), "network_local");
900 root.addBookmark(manager, i18n("Root"), KUrl("/"), "folder_red");
901 root.addBookmark(manager, i18n("Trash"), KUrl("trash:/"), "trashcan_full");
902 }
903
904 setupActions();
905
906 const KUrl& homeUrl = root.first().url();
907 setCaption(homeUrl.fileName());
908 ViewProperties props(homeUrl);
909 m_view[PrimaryIdx] = new DolphinView(this,
910 m_splitter,
911 homeUrl,
912 props.viewMode(),
913 props.showHiddenFiles());
914 connectViewSignals(PrimaryIdx);
915 m_view[PrimaryIdx]->show();
916
917 m_activeView = m_view[PrimaryIdx];
918
919 setCentralWidget(m_splitter);
920 setupDockWidgets();
921
922 setupGUI(Keys|Save|Create|ToolBar);
923 createGUI();
924
925 stateChanged("new_file");
926 setAutoSaveSettings();
927
928 QClipboard* clipboard = QApplication::clipboard();
929 connect(clipboard, SIGNAL(dataChanged()),
930 this, SLOT(updatePasteAction()));
931 updatePasteAction();
932 updateGoActions();
933
934 loadSettings();
935
936 if (firstRun) {
937 // assure a proper default size if Dolphin runs the first time
938 resize(640, 480);
939 }
940 }
941
942 void DolphinMainWindow::loadSettings()
943 {
944 GeneralSettings* settings = DolphinSettings::instance().generalSettings();
945
946 KToggleAction* splitAction = static_cast<KToggleAction*>(actionCollection()->action("split_view"));
947 if (settings->splitView()) {
948 splitAction->setChecked(true);
949 toggleSplitView();
950 }
951
952 updateViewActions();
953
954 // TODO: I assume there will be a generic way in KDE 4 to restore the docks
955 // of the main window. In the meantime they are restored manually (see also
956 // DolphinMainWindow::closeEvent() for more details):
957 QString filename = KStandardDirs::locateLocal("data", KGlobal::mainComponent().componentName()); filename.append("/panels_layout");
958 QFile file(filename);
959 if (file.open(QIODevice::ReadOnly)) {
960 QByteArray data = file.readAll();
961 restoreState(data);
962 file.close();
963 }
964 }
965
966 void DolphinMainWindow::setupActions()
967 {
968 // setup 'File' menu
969 m_newMenu = new DolphinNewMenu(this);
970 KMenu* menu = m_newMenu->menu();
971 menu->setTitle(i18n("Create New..."));
972 menu->setIcon(SmallIcon("filenew"));
973 connect(menu, SIGNAL(aboutToShow()),
974 this, SLOT(updateNewMenu()));
975
976 QAction* action = actionCollection()->addAction("new_window");
977 action->setIcon(KIcon("window_new"));
978 action->setText(i18n("New &Window"));
979 connect(action, SIGNAL(triggered()), this, SLOT(openNewMainWindow()));
980
981 QAction* rename = actionCollection()->addAction("rename");
982 rename->setText(i18n("Rename"));
983 rename->setShortcut(Qt::Key_F2);
984 connect(rename, SIGNAL(triggered()), this, SLOT(rename()));
985
986 QAction* moveToTrash = actionCollection()->addAction("move_to_trash");
987 moveToTrash->setText(i18n("Move to Trash"));
988 moveToTrash->setIcon(KIcon("edittrash"));
989 moveToTrash->setShortcut(QKeySequence::Delete);
990 connect(moveToTrash, SIGNAL(triggered()), this, SLOT(moveToTrash()));
991
992 QAction* deleteAction = actionCollection()->addAction("delete");
993 deleteAction->setText(i18n("Delete"));
994 deleteAction->setShortcut(Qt::ALT | Qt::Key_Delete);
995 deleteAction->setIcon(KIcon("editdelete"));
996 connect(deleteAction, SIGNAL(triggered()), this, SLOT(deleteItems()));
997
998 QAction* properties = actionCollection()->addAction("properties");
999 properties->setText(i18n("Properties"));
1000 properties->setShortcut(Qt::ALT | Qt::Key_Return);
1001 connect(properties, SIGNAL(triggered()), this, SLOT(properties()));
1002
1003 KStandardAction::quit(this, SLOT(quit()), actionCollection());
1004
1005 // setup 'Edit' menu
1006 KStandardAction::undo(this,
1007 SLOT(undo()),
1008 actionCollection());
1009
1010 KStandardAction::cut(this, SLOT(cut()), actionCollection());
1011 KStandardAction::copy(this, SLOT(copy()), actionCollection());
1012 KStandardAction::paste(this, SLOT(paste()), actionCollection());
1013
1014 QAction* selectAll = actionCollection()->addAction("select_all");
1015 selectAll->setText(i18n("Select All"));
1016 selectAll->setShortcut(Qt::CTRL + Qt::Key_A);
1017 connect(selectAll, SIGNAL(triggered()), this, SLOT(selectAll()));
1018
1019 QAction* invertSelection = actionCollection()->addAction("invert_selection");
1020 invertSelection->setText(i18n("Invert Selection"));
1021 invertSelection->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_A);
1022 connect(invertSelection, SIGNAL(triggered()), this, SLOT(invertSelection()));
1023
1024 // setup 'View' menu
1025 KStandardAction::zoomIn(this,
1026 SLOT(zoomIn()),
1027 actionCollection());
1028
1029 KStandardAction::zoomOut(this,
1030 SLOT(zoomOut()),
1031 actionCollection());
1032
1033 KToggleAction* iconsView = actionCollection()->add<KToggleAction>("icons");
1034 iconsView->setText(i18n("Icons"));
1035 iconsView->setShortcut(Qt::CTRL | Qt::Key_1);
1036 iconsView->setIcon(KIcon("view_icon"));
1037 connect(iconsView, SIGNAL(triggered()), this, SLOT(setIconsView()));
1038
1039 KToggleAction* detailsView = actionCollection()->add<KToggleAction>("details");
1040 detailsView->setText(i18n("Details"));
1041 detailsView->setShortcut(Qt::CTRL | Qt::Key_2);
1042 detailsView->setIcon(KIcon("view_text"));
1043 connect(detailsView, SIGNAL(triggered()), this, SLOT(setDetailsView()));
1044
1045 QActionGroup* viewModeGroup = new QActionGroup(this);
1046 viewModeGroup->addAction(iconsView);
1047 viewModeGroup->addAction(detailsView);
1048
1049 KToggleAction* sortByName = actionCollection()->add<KToggleAction>("by_name");
1050 sortByName->setText(i18n("By Name"));
1051 connect(sortByName, SIGNAL(triggered()), this, SLOT(sortByName()));
1052
1053 KToggleAction* sortBySize = actionCollection()->add<KToggleAction>("by_size");
1054 sortBySize->setText(i18n("By Size"));
1055 connect(sortBySize, SIGNAL(triggered()), this, SLOT(sortBySize()));
1056
1057 KToggleAction* sortByDate = actionCollection()->add<KToggleAction>("by_date");
1058 sortByDate->setText(i18n("By Date"));
1059 connect(sortByDate, SIGNAL(triggered()), this, SLOT(sortByDate()));
1060
1061 KToggleAction* sortByPermissions = actionCollection()->add<KToggleAction>("by_permissions");
1062 sortByPermissions->setText(i18n("By Permissions"));
1063 connect(sortByPermissions, SIGNAL(triggered()), this, SLOT(sortByPermissions()));
1064
1065 KToggleAction* sortByOwner = actionCollection()->add<KToggleAction>("by_owner");
1066 sortByOwner->setText(i18n("By Owner"));
1067 connect(sortByOwner, SIGNAL(triggered()), this, SLOT(sortByOwner()));
1068
1069 KToggleAction* sortByGroup = actionCollection()->add<KToggleAction>("by_group");
1070 sortByGroup->setText(i18n("By Group"));
1071 connect(sortByGroup, SIGNAL(triggered()), this, SLOT(sortByGroup()));
1072
1073 QActionGroup* sortGroup = new QActionGroup(this);
1074 sortGroup->addAction(sortByName);
1075 sortGroup->addAction(sortBySize);
1076 sortGroup->addAction(sortByDate);
1077 sortGroup->addAction(sortByPermissions);
1078 sortGroup->addAction(sortByOwner);
1079 sortGroup->addAction(sortByGroup);
1080
1081 KToggleAction* sortDescending = actionCollection()->add<KToggleAction>("descending");
1082 sortDescending->setText(i18n("Descending"));
1083 connect(sortDescending, SIGNAL(triggered()), this, SLOT(toggleSortOrder()));
1084
1085 KToggleAction* showPreview = actionCollection()->add<KToggleAction>("show_preview");
1086 showPreview->setText(i18n("Show Preview"));
1087 connect(showPreview, SIGNAL(triggered()), this, SLOT(togglePreview()));
1088
1089 KToggleAction* showHiddenFiles = actionCollection()->add<KToggleAction>("show_hidden_files");
1090 showHiddenFiles->setText(i18n("Show Hidden Files"));
1091 showHiddenFiles->setShortcut(Qt::ALT | Qt::Key_Period);
1092 connect(showHiddenFiles, SIGNAL(triggered()), this, SLOT(toggleShowHiddenFiles()));
1093
1094 KToggleAction* split = actionCollection()->add<KToggleAction>("split_view");
1095 split->setText(i18n("Split View"));
1096 split->setShortcut(Qt::Key_F10);
1097 split->setIcon(KIcon("view_left_right"));
1098 connect(split, SIGNAL(triggered()), this, SLOT(toggleSplitView()));
1099
1100 QAction* reload = actionCollection()->addAction("reload");
1101 reload->setText(i18n("Reload"));
1102 reload->setShortcut(Qt::Key_F5);
1103 reload->setIcon(KIcon("reload"));
1104 connect(reload, SIGNAL(triggered()), this, SLOT(reloadView()));
1105
1106 QAction* stop = actionCollection()->addAction("stop");
1107 stop->setText(i18n("Stop"));
1108 stop->setIcon(KIcon("stop"));
1109 connect(stop, SIGNAL(triggered()), this, SLOT(stopLoading()));
1110
1111 // TODO: the URL navigator must emit a signal if the editable state has been
1112 // changed, so that the corresponding showFullLocation action is updated. Also
1113 // the naming "Show full Location" is currently confusing...
1114 KToggleAction* showFullLocation = actionCollection()->add<KToggleAction>("editable_location");
1115 showFullLocation->setText(i18n("Show Full Location"));
1116 showFullLocation->setShortcut(Qt::CTRL | Qt::Key_L);
1117 connect(showFullLocation, SIGNAL(triggered()), this, SLOT(toggleEditLocation()));
1118
1119 QAction* editLocation = actionCollection()->addAction("edit_location");
1120 editLocation->setText(i18n("Edit Location"));
1121 editLocation->setShortcut(Qt::Key_F6);
1122 connect(editLocation, SIGNAL(triggered()), this, SLOT(editLocation()));
1123
1124 QAction* adjustViewProps = actionCollection()->addAction("view_properties");
1125 adjustViewProps->setText(i18n("Adjust View Properties..."));
1126 connect(adjustViewProps, SIGNAL(triggered()), this, SLOT(adjustViewProperties()));
1127
1128 // setup 'Go' menu
1129 KStandardAction::back(this, SLOT(goBack()), actionCollection());
1130 KStandardAction::forward(this, SLOT(goForward()), actionCollection());
1131 KStandardAction::up(this, SLOT(goUp()), actionCollection());
1132 KStandardAction::home(this, SLOT(goHome()), actionCollection());
1133
1134 // setup 'Tools' menu
1135 QAction* openTerminal = actionCollection()->addAction("open_terminal");
1136 openTerminal->setText(i18n("Open Terminal"));
1137 openTerminal->setShortcut(Qt::Key_F4);
1138 openTerminal->setIcon(KIcon("konsole"));
1139 connect(openTerminal, SIGNAL(triggered()), this, SLOT(openTerminal()));
1140
1141 QAction* findFile = actionCollection()->addAction("find_file");
1142 findFile->setText(i18n("Find File..."));
1143 findFile->setShortcut(Qt::Key_F);
1144 findFile->setIcon(KIcon("filefind"));
1145 connect(findFile, SIGNAL(triggered()), this, SLOT(findFile()));
1146
1147 KToggleAction* showFilterBar = actionCollection()->add<KToggleAction>("show_filter_bar");
1148 showFilterBar->setText(i18n("Show Filter Bar"));
1149 showFilterBar->setShortcut(Qt::Key_Slash);
1150 connect(showFilterBar, SIGNAL(triggered()), this, SLOT(showFilterBar()));
1151
1152 QAction* compareFiles = actionCollection()->addAction("compare_files");
1153 compareFiles->setText(i18n("Compare Files"));
1154 compareFiles->setIcon(KIcon("kompare"));
1155 compareFiles->setEnabled(false);
1156 connect(compareFiles, SIGNAL(triggered()), this, SLOT(compareFiles()));
1157
1158 // setup 'Settings' menu
1159 KStandardAction::preferences(this, SLOT(editSettings()), actionCollection());
1160 }
1161
1162 void DolphinMainWindow::setupDockWidgets()
1163 {
1164 QDockWidget* shortcutsDock = new QDockWidget(i18n("Bookmarks"));
1165 shortcutsDock->setObjectName("bookmarksDock");
1166 shortcutsDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
1167 shortcutsDock->setWidget(new BookmarksSidebarPage(this));
1168
1169 shortcutsDock->toggleViewAction()->setText(i18n("Show Bookmarks Panel"));
1170 actionCollection()->addAction("show_bookmarks_panel", shortcutsDock->toggleViewAction());
1171
1172 addDockWidget(Qt::LeftDockWidgetArea, shortcutsDock);
1173
1174 QDockWidget* infoDock = new QDockWidget(i18n("Information"));
1175 infoDock->setObjectName("infoDock");
1176 infoDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
1177 infoDock->setWidget(new InfoSidebarPage(this));
1178
1179 infoDock->toggleViewAction()->setText(i18n("Show Information Panel"));
1180 actionCollection()->addAction("show_info_panel", infoDock->toggleViewAction());
1181
1182 addDockWidget(Qt::RightDockWidgetArea, infoDock);
1183 }
1184
1185 void DolphinMainWindow::updateHistory()
1186 {
1187 int index = 0;
1188 const QLinkedList<UrlNavigator::HistoryElem> list = m_activeView->urlHistory(index);
1189
1190 QAction* backAction = actionCollection()->action("go_back");
1191 if (backAction != 0) {
1192 backAction->setEnabled(index < static_cast<int>(list.count()) - 1);
1193 }
1194
1195 QAction* forwardAction = actionCollection()->action("go_forward");
1196 if (forwardAction != 0) {
1197 forwardAction->setEnabled(index > 0);
1198 }
1199 }
1200
1201 void DolphinMainWindow::updateEditActions()
1202 {
1203 const KFileItemList list = m_activeView->selectedItems();
1204 if (list.isEmpty()) {
1205 stateChanged("has_no_selection");
1206 }
1207 else {
1208 stateChanged("has_selection");
1209
1210 QAction* renameAction = actionCollection()->action("rename");
1211 if (renameAction != 0) {
1212 renameAction->setEnabled(list.count() >= 1);
1213 }
1214
1215 bool enableMoveToTrash = true;
1216
1217 KFileItemList::const_iterator it = list.begin();
1218 const KFileItemList::const_iterator end = list.end();
1219 while (it != end) {
1220 KFileItem* item = *it;
1221 const KUrl& url = item->url();
1222 // only enable the 'Move to Trash' action for local files
1223 if (!url.isLocalFile()) {
1224 enableMoveToTrash = false;
1225 }
1226 ++it;
1227 }
1228
1229 QAction* moveToTrashAction = actionCollection()->action("move_to_trash");
1230 moveToTrashAction->setEnabled(enableMoveToTrash);
1231 }
1232 updatePasteAction();
1233 }
1234
1235 void DolphinMainWindow::updateViewActions()
1236 {
1237 QAction* zoomInAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::ZoomIn));
1238 if (zoomInAction != 0) {
1239 zoomInAction->setEnabled(m_activeView->isZoomInPossible());
1240 }
1241
1242 QAction* zoomOutAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::ZoomOut));
1243 if (zoomOutAction != 0) {
1244 zoomOutAction->setEnabled(m_activeView->isZoomOutPossible());
1245 }
1246
1247 QAction* action = 0;
1248 switch (m_activeView->mode()) {
1249 case DolphinView::IconsView:
1250 action = actionCollection()->action("icons");
1251 break;
1252 case DolphinView::DetailsView:
1253 action = actionCollection()->action("details");
1254 break;
1255 default:
1256 break;
1257 }
1258
1259 if (action != 0) {
1260 KToggleAction* toggleAction = static_cast<KToggleAction*>(action);
1261 toggleAction->setChecked(true);
1262 }
1263
1264 slotSortingChanged(m_activeView->sorting());
1265 slotSortOrderChanged(m_activeView->sortOrder());
1266
1267 KToggleAction* showFilterBarAction =
1268 static_cast<KToggleAction*>(actionCollection()->action("show_filter_bar"));
1269 showFilterBarAction->setChecked(m_activeView->isFilterBarVisible());
1270
1271 KToggleAction* showHiddenFilesAction =
1272 static_cast<KToggleAction*>(actionCollection()->action("show_hidden_files"));
1273 showHiddenFilesAction->setChecked(m_activeView->showHiddenFiles());
1274
1275 KToggleAction* splitAction = static_cast<KToggleAction*>(actionCollection()->action("split_view"));
1276 splitAction->setChecked(m_view[SecondaryIdx] != 0);
1277
1278 KToggleAction* editableLocactionAction =
1279 static_cast<KToggleAction*>(actionCollection()->action("editable_location"));
1280 editableLocactionAction->setChecked(m_activeView->isUrlEditable());
1281 }
1282
1283 void DolphinMainWindow::updateGoActions()
1284 {
1285 QAction* goUpAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::Up));
1286 const KUrl& currentUrl = m_activeView->url();
1287 goUpAction->setEnabled(currentUrl.upUrl() != currentUrl);
1288 }
1289
1290 void DolphinMainWindow::copyUrls(const KUrl::List& source, const KUrl& dest)
1291 {
1292 KonqOperations::copy(this, KonqOperations::COPY, source, dest);
1293 m_undoOperations.append(KonqOperations::COPY);
1294 }
1295
1296 void DolphinMainWindow::moveUrls(const KUrl::List& source, const KUrl& dest)
1297 {
1298 KonqOperations::copy(this, KonqOperations::MOVE, source, dest);
1299 m_undoOperations.append(KonqOperations::MOVE);
1300 }
1301
1302 void DolphinMainWindow::linkUrls(const KUrl::List& source, const KUrl& dest)
1303 {
1304 KonqOperations::copy(this, KonqOperations::LINK, source, dest);
1305 m_undoOperations.append(KonqOperations::LINK);
1306 }
1307
1308 void DolphinMainWindow::clearStatusBar()
1309 {
1310 m_activeView->statusBar()->clear();
1311 }
1312
1313 void DolphinMainWindow::connectViewSignals(int viewIndex)
1314 {
1315 DolphinView* view = m_view[viewIndex];
1316 connect(view, SIGNAL(modeChanged()),
1317 this, SLOT(slotViewModeChanged()));
1318 connect(view, SIGNAL(showHiddenFilesChanged()),
1319 this, SLOT(slotShowHiddenFilesChanged()));
1320 connect(view, SIGNAL(sortingChanged(DolphinView::Sorting)),
1321 this, SLOT(slotSortingChanged(DolphinView::Sorting)));
1322 connect(view, SIGNAL(sortOrderChanged(Qt::SortOrder)),
1323 this, SLOT(slotSortOrderChanged(Qt::SortOrder)));
1324 connect(view, SIGNAL(selectionChanged()),
1325 this, SLOT(slotSelectionChanged()));
1326 connect(view, SIGNAL(showFilterBarChanged(bool)),
1327 this, SLOT(updateFilterBarAction(bool)));
1328
1329 const UrlNavigator* navigator = view->urlNavigator();
1330 connect(navigator, SIGNAL(urlChanged(const KUrl&)),
1331 this, SLOT(slotUrlChanged(const KUrl&)));
1332 connect(navigator, SIGNAL(historyChanged()),
1333 this, SLOT(slotHistoryChanged()));
1334
1335 }
1336
1337 DolphinMainWindow::UndoUiInterface::UndoUiInterface(DolphinMainWindow* mainWin) :
1338 KonqUndoManager::UiInterface(mainWin),
1339 m_mainWin(mainWin)
1340 {
1341 assert(m_mainWin != 0);
1342 }
1343
1344 DolphinMainWindow::UndoUiInterface::~UndoUiInterface()
1345 {
1346 }
1347
1348 void DolphinMainWindow::UndoUiInterface::jobError(KIO::Job* job)
1349 {
1350 DolphinStatusBar* statusBar = m_mainWin->activeView()->statusBar();
1351 statusBar->setMessage(job->errorString(), DolphinStatusBar::Error);
1352 }
1353
1354 #include "dolphinmainwindow.moc"