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