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