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