]> cloud.milkyroute.net Git - dolphin.git/blob - src/views/dolphinview.cpp
d50a7dd090db24a980cb093d79c2fe0e0114c3c9
[dolphin.git] / src / views / dolphinview.cpp
1 /***************************************************************************
2 * Copyright (C) 2006-2009 by Peter Penz <peter.penz19@gmail.com> *
3 * Copyright (C) 2006 by Gregor Kališnik <gregor@podnapisi.net> *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
19 ***************************************************************************/
20
21 #include "dolphinview.h"
22
23 #include <QAbstractItemView>
24 #include <QApplication>
25 #include <QBoxLayout>
26 #include <QClipboard>
27 #include <QDropEvent>
28 #include <QGraphicsSceneDragDropEvent>
29 #include <QKeyEvent>
30 #include <QItemSelection>
31 #include <QTimer>
32 #include <QScrollBar>
33
34 #include <KActionCollection>
35 #include <KColorScheme>
36 #include <KDirLister>
37 #include <KDirModel>
38 #include <KIconEffect>
39 #include <KFileItem>
40 #include <KFileItemListProperties>
41 #include <KLocale>
42 #include <kitemviews/kfileitemmodel.h>
43 #include <kitemviews/kfileitemlistview.h>
44 #include <kitemviews/kitemlistselectionmanager.h>
45 #include <kitemviews/kitemlistview.h>
46 #include <kitemviews/kitemlistcontroller.h>
47 #include <KIO/DeleteJob>
48 #include <KIO/NetAccess>
49 #include <KIO/PreviewJob>
50 #include <KJob>
51 #include <KMenu>
52 #include <KMessageBox>
53 #include <konq_fileitemcapabilities.h>
54 #include <konq_operations.h>
55 #include <konqmimedata.h>
56 #include <KToggleAction>
57 #include <KUrl>
58
59 #include "additionalinfoaccessor.h"
60 #include "dolphindirlister.h"
61 #include "dolphinnewfilemenuobserver.h"
62 #include "dolphin_detailsmodesettings.h"
63 #include "dolphin_generalsettings.h"
64 #include "dolphinitemlistcontainer.h"
65 #include "draganddrophelper.h"
66 #include "renamedialog.h"
67 #include "versioncontrol/versioncontrolobserver.h"
68 #include "viewmodecontroller.h"
69 #include "viewproperties.h"
70 #include "views/tooltips/tooltipmanager.h"
71 #include "zoomlevelinfo.h"
72
73 namespace {
74 const int MaxModeEnum = DolphinView::CompactView;
75 const int MaxSortingEnum = DolphinView::SortByPath;
76 };
77
78 DolphinView::DolphinView(const KUrl& url, QWidget* parent) :
79 QWidget(parent),
80 m_active(true),
81 m_tabsForFiles(false),
82 m_assureVisibleCurrentIndex(false),
83 m_isFolderWritable(true),
84 m_url(url),
85 m_mode(DolphinView::IconsView),
86 m_additionalInfoList(),
87 m_topLayout(0),
88 m_dirLister(0),
89 m_container(0),
90 m_toolTipManager(0),
91 m_selectionChangedTimer(0),
92 m_currentItemUrl(),
93 m_restoredContentsPosition(),
94 m_createdItemUrl(),
95 m_selectedUrls(),
96 m_versionControlObserver(0)
97 {
98 m_topLayout = new QVBoxLayout(this);
99 m_topLayout->setSpacing(0);
100 m_topLayout->setMargin(0);
101
102 // When a new item has been created by the "Create New..." menu, the item should
103 // get selected and it must be assured that the item will get visible. As the
104 // creation is done asynchronously, several signals must be checked:
105 connect(&DolphinNewFileMenuObserver::instance(), SIGNAL(itemCreated(KUrl)),
106 this, SLOT(observeCreatedItem(KUrl)));
107
108 m_selectionChangedTimer = new QTimer(this);
109 m_selectionChangedTimer->setSingleShot(true);
110 m_selectionChangedTimer->setInterval(300);
111 connect(m_selectionChangedTimer, SIGNAL(timeout()),
112 this, SLOT(emitSelectionChangedSignal()));
113
114 m_dirLister = new DolphinDirLister(this);
115 m_dirLister->setAutoUpdate(true);
116 m_dirLister->setDelayedMimeTypes(true);
117
118 connect(m_dirLister, SIGNAL(redirection(KUrl,KUrl)), this, SLOT(slotRedirection(KUrl,KUrl)));
119 connect(m_dirLister, SIGNAL(started(KUrl)), this, SLOT(slotDirListerStarted(KUrl)));
120 connect(m_dirLister, SIGNAL(refreshItems(QList<QPair<KFileItem,KFileItem> >)),
121 this, SLOT(slotRefreshItems()));
122
123 connect(m_dirLister, SIGNAL(clear()), this, SIGNAL(itemCountChanged()));
124 connect(m_dirLister, SIGNAL(newItems(KFileItemList)), this, SIGNAL(itemCountChanged()));
125 connect(m_dirLister, SIGNAL(infoMessage(QString)), this, SIGNAL(infoMessage(QString)));
126 connect(m_dirLister, SIGNAL(errorMessage(QString)), this, SIGNAL(infoMessage(QString)));
127 connect(m_dirLister, SIGNAL(percent(int)), this, SIGNAL(pathLoadingProgress(int)));
128 connect(m_dirLister, SIGNAL(urlIsFileError(KUrl)), this, SIGNAL(urlIsFileError(KUrl)));
129 connect(m_dirLister, SIGNAL(itemsDeleted(KFileItemList)), this, SIGNAL(itemCountChanged()));
130
131 m_container = new DolphinItemListContainer(m_dirLister, this);
132 m_container->setVisibleRoles(QList<QByteArray>() << "name");
133 m_container->installEventFilter(this);
134 setFocusProxy(m_container);
135
136 KItemListController* controller = m_container->controller();
137 controller->setSelectionBehavior(KItemListController::MultiSelection);
138 if (GeneralSettings::autoExpandFolders()) {
139 controller->setAutoActivationDelay(750);
140 }
141 connect(controller, SIGNAL(itemActivated(int)), this, SLOT(slotItemActivated(int)));
142 connect(controller, SIGNAL(itemsActivated(QSet<int>)), this, SLOT(slotItemsActivated(QSet<int>)));
143 connect(controller, SIGNAL(itemMiddleClicked(int)), this, SLOT(slotItemMiddleClicked(int)));
144 connect(controller, SIGNAL(itemContextMenuRequested(int,QPointF)), this, SLOT(slotItemContextMenuRequested(int,QPointF)));
145 connect(controller, SIGNAL(viewContextMenuRequested(QPointF)), this, SLOT(slotViewContextMenuRequested(QPointF)));
146 connect(controller, SIGNAL(headerContextMenuRequested(QPointF)), this, SLOT(slotHeaderContextMenuRequested(QPointF)));
147 connect(controller, SIGNAL(itemHovered(int)), this, SLOT(slotItemHovered(int)));
148 connect(controller, SIGNAL(itemUnhovered(int)), this, SLOT(slotItemUnhovered(int)));
149 connect(controller, SIGNAL(itemDropEvent(int,QGraphicsSceneDragDropEvent*)), this, SLOT(slotItemDropEvent(int,QGraphicsSceneDragDropEvent*)));
150 connect(controller, SIGNAL(modelChanged(KItemModelBase*,KItemModelBase*)), this, SLOT(slotModelChanged(KItemModelBase*,KItemModelBase*)));
151
152 KFileItemModel* model = fileItemModel();
153 if (model) {
154 connect(model, SIGNAL(loadingCompleted()), this, SLOT(slotLoadingCompleted()));
155 }
156
157 KItemListView* view = controller->view();
158 connect(view, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder)),
159 this, SLOT(slotSortOrderChangedByHeader(Qt::SortOrder,Qt::SortOrder)));
160 connect(view, SIGNAL(sortRoleChanged(QByteArray,QByteArray)),
161 this, SLOT(slotSortRoleChangedByHeader(QByteArray,QByteArray)));
162
163 KItemListSelectionManager* selectionManager = controller->selectionManager();
164 connect(selectionManager, SIGNAL(selectionChanged(QSet<int>,QSet<int>)),
165 this, SLOT(slotSelectionChanged(QSet<int>,QSet<int>)));
166
167 m_toolTipManager = new ToolTipManager(this);
168
169 m_versionControlObserver = new VersionControlObserver(this);
170 m_versionControlObserver->setModel(model);
171 connect(m_versionControlObserver, SIGNAL(infoMessage(QString)), this, SIGNAL(infoMessage(QString)));
172 connect(m_versionControlObserver, SIGNAL(errorMessage(QString)), this, SIGNAL(errorMessage(QString)));
173 connect(m_versionControlObserver, SIGNAL(operationCompletedMessage(QString)), this, SIGNAL(operationCompletedMessage(QString)));
174
175 applyViewProperties();
176 m_topLayout->addWidget(m_container);
177
178 loadDirectory(url);
179 }
180
181 DolphinView::~DolphinView()
182 {
183 }
184
185 KUrl DolphinView::url() const
186 {
187 return m_url;
188 }
189
190 void DolphinView::setActive(bool active)
191 {
192 if (active == m_active) {
193 return;
194 }
195
196 m_active = active;
197
198 QColor color = KColorScheme(QPalette::Active, KColorScheme::View).background().color();
199 if (!active) {
200 color.setAlpha(150);
201 }
202
203 QWidget* viewport = m_container->viewport();
204 if (viewport) {
205 QPalette palette;
206 palette.setColor(viewport->backgroundRole(), color);
207 viewport->setPalette(palette);
208 }
209
210 update();
211
212 if (active) {
213 m_container->setFocus();
214 emit activated();
215 emit writeStateChanged(m_isFolderWritable);
216 }
217 }
218
219 bool DolphinView::isActive() const
220 {
221 return m_active;
222 }
223
224 void DolphinView::setMode(Mode mode)
225 {
226 if (mode != m_mode) {
227 ViewProperties props(url());
228 props.setViewMode(mode);
229 props.save();
230
231 applyViewProperties();
232 }
233 }
234
235 DolphinView::Mode DolphinView::mode() const
236 {
237 return m_mode;
238 }
239
240 void DolphinView::setPreviewsShown(bool show)
241 {
242 if (previewsShown() == show) {
243 return;
244 }
245
246 ViewProperties props(url());
247 props.setPreviewsShown(show);
248
249 m_container->setPreviewsShown(show);
250 emit previewsShownChanged(show);
251 }
252
253 bool DolphinView::previewsShown() const
254 {
255 return m_container->previewsShown();
256 }
257
258 void DolphinView::setHiddenFilesShown(bool show)
259 {
260 if (m_dirLister->showingDotFiles() == show) {
261 return;
262 }
263
264 const KFileItemList itemList = selectedItems();
265 m_selectedUrls.clear();
266 m_selectedUrls = itemList.urlList();
267
268 ViewProperties props(url());
269 props.setHiddenFilesShown(show);
270
271 fileItemModel()->setShowHiddenFiles(show);
272 emit hiddenFilesShownChanged(show);
273 }
274
275 bool DolphinView::hiddenFilesShown() const
276 {
277 return m_dirLister->showingDotFiles();
278 }
279
280 void DolphinView::setGroupedSorting(bool grouped)
281 {
282 if (grouped == groupedSorting()) {
283 return;
284 }
285
286 ViewProperties props(url());
287 props.setGroupedSorting(grouped);
288 props.save();
289
290 m_container->controller()->model()->setGroupedSorting(grouped);
291
292 emit groupedSortingChanged(grouped);
293 }
294
295 bool DolphinView::groupedSorting() const
296 {
297 return fileItemModel()->groupedSorting();
298 }
299
300 KFileItemList DolphinView::items() const
301 {
302 return m_dirLister->items();
303 }
304
305 KFileItemList DolphinView::selectedItems() const
306 {
307 const KFileItemModel* model = fileItemModel();
308 const KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager();
309 const QSet<int> selectedIndexes = selectionManager->selectedItems();
310
311 QList<int> sortedIndexes = selectedIndexes.toList();
312 qSort(sortedIndexes);
313
314 KFileItemList selectedItems;
315 QListIterator<int> it(sortedIndexes);
316 while (it.hasNext()) {
317 const int index = it.next();
318 selectedItems.append(model->fileItem(index));
319 }
320 return selectedItems;
321 }
322
323 int DolphinView::selectedItemsCount() const
324 {
325 const KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager();
326 return selectionManager->selectedItems().count();
327 }
328
329 void DolphinView::markUrlsAsSelected(const QList<KUrl>& urls)
330 {
331 m_selectedUrls = urls;
332 }
333
334 void DolphinView::markUrlAsCurrent(const KUrl& url)
335 {
336 m_currentItemUrl = url;
337 }
338
339 void DolphinView::setItemSelectionEnabled(const QRegExp& pattern, bool enabled)
340 {
341 const KItemListSelectionManager::SelectionMode mode = enabled
342 ? KItemListSelectionManager::Select
343 : KItemListSelectionManager::Deselect;
344 const KFileItemModel* model = fileItemModel();
345 KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager();
346
347 for (int index = 0; index < model->count(); index++) {
348 const KFileItem item = model->fileItem(index);
349 if (pattern.exactMatch(item.text())) {
350 // An alternative approach would be to store the matching items in a QSet<int> and
351 // select them in one go after the loop, but we'd need a new function
352 // KItemListSelectionManager::setSelected(QSet<int>, SelectionMode mode)
353 // for that.
354 selectionManager->setSelected(index, 1, mode);
355 }
356 }
357 }
358
359 void DolphinView::setZoomLevel(int level)
360 {
361 const int oldZoomLevel = zoomLevel();
362 m_container->setZoomLevel(level);
363 if (zoomLevel() != oldZoomLevel) {
364 emit zoomLevelChanged(zoomLevel(), oldZoomLevel);
365 }
366 }
367
368 int DolphinView::zoomLevel() const
369 {
370 return m_container->zoomLevel();
371 }
372
373 void DolphinView::setSorting(Sorting sorting)
374 {
375 if (sorting != this->sorting()) {
376 updateSorting(sorting);
377 }
378 }
379
380 DolphinView::Sorting DolphinView::sorting() const
381 {
382 KItemModelBase* model = m_container->controller()->model();
383 return sortingForSortRole(model->sortRole());
384 }
385
386 void DolphinView::setSortOrder(Qt::SortOrder order)
387 {
388 if (sortOrder() != order) {
389 updateSortOrder(order);
390 }
391 }
392
393 Qt::SortOrder DolphinView::sortOrder() const
394 {
395 KItemModelBase* model = fileItemModel();
396 return model->sortOrder();
397 }
398
399 void DolphinView::setSortFoldersFirst(bool foldersFirst)
400 {
401 if (sortFoldersFirst() != foldersFirst) {
402 updateSortFoldersFirst(foldersFirst);
403 }
404 }
405
406 bool DolphinView::sortFoldersFirst() const
407 {
408 KFileItemModel* model = fileItemModel();
409 return model->sortFoldersFirst();
410 }
411
412 void DolphinView::setAdditionalInfoList(const QList<AdditionalInfo>& info)
413 {
414 const QList<AdditionalInfo> previousList = info;
415
416 ViewProperties props(url());
417 props.setAdditionalInfoList(info);
418
419 m_additionalInfoList = info;
420 applyAdditionalInfoListToView();
421
422 emit additionalInfoListChanged(m_additionalInfoList, previousList);
423 }
424
425 QList<DolphinView::AdditionalInfo> DolphinView::additionalInfoList() const
426 {
427 return m_additionalInfoList;
428 }
429
430 void DolphinView::reload()
431 {
432 QByteArray viewState;
433 QDataStream saveStream(&viewState, QIODevice::WriteOnly);
434 saveState(saveStream);
435
436 const KFileItemList itemList = selectedItems();
437 m_selectedUrls.clear();
438 m_selectedUrls = itemList.urlList();
439
440 setUrl(url());
441 loadDirectory(url(), true);
442
443 QDataStream restoreStream(viewState);
444 restoreState(restoreStream);
445 }
446
447 void DolphinView::stopLoading()
448 {
449 m_dirLister->stop();
450 }
451
452 void DolphinView::refresh()
453 {
454 GeneralSettings::self()->readConfig();
455 m_container->refresh();
456 applyViewProperties();
457 }
458
459 void DolphinView::setNameFilter(const QString& nameFilter)
460 {
461 fileItemModel()->setNameFilter(nameFilter);
462 }
463
464 QString DolphinView::nameFilter() const
465 {
466 return fileItemModel()->nameFilter();
467 }
468
469 void DolphinView::calculateItemCount(int& fileCount,
470 int& folderCount,
471 KIO::filesize_t& totalFileSize) const
472 {
473 foreach (const KFileItem& item, m_dirLister->items()) {
474 if (item.isDir()) {
475 ++folderCount;
476 } else {
477 ++fileCount;
478 totalFileSize += item.size();
479 }
480 }
481 }
482
483 QString DolphinView::statusBarText() const
484 {
485 QString summary;
486 QString foldersText;
487 QString filesText;
488
489 int folderCount = 0;
490 int fileCount = 0;
491 KIO::filesize_t totalFileSize = 0;
492
493 if (hasSelection()) {
494 // Give a summary of the status of the selected files
495 const KFileItemList list = selectedItems();
496 foreach (const KFileItem& item, list) {
497 if (item.isDir()) {
498 ++folderCount;
499 } else {
500 ++fileCount;
501 totalFileSize += item.size();
502 }
503 }
504
505 if (folderCount + fileCount == 1) {
506 // If only one item is selected, show the filename
507 filesText = i18nc("@info:status", "<filename>%1</filename> selected", list.first().text());
508 } else {
509 // At least 2 items are selected
510 foldersText = i18ncp("@info:status", "1 Folder selected", "%1 Folders selected", folderCount);
511 filesText = i18ncp("@info:status", "1 File selected", "%1 Files selected", fileCount);
512 }
513 } else {
514 calculateItemCount(fileCount, folderCount, totalFileSize);
515 foldersText = i18ncp("@info:status", "1 Folder", "%1 Folders", folderCount);
516 filesText = i18ncp("@info:status", "1 File", "%1 Files", fileCount);
517 }
518
519 if (fileCount > 0 && folderCount > 0) {
520 summary = i18nc("@info:status folders, files (size)", "%1, %2 (%3)",
521 foldersText, filesText, fileSizeText(totalFileSize));
522 } else if (fileCount > 0) {
523 summary = i18nc("@info:status files (size)", "%1 (%2)", filesText, fileSizeText(totalFileSize));
524 } else if (folderCount > 0) {
525 summary = foldersText;
526 }
527
528 return summary;
529 }
530
531 QList<QAction*> DolphinView::versionControlActions(const KFileItemList& items) const
532 {
533 QList<QAction*> actions;
534
535 if (items.isEmpty()) {
536 const KFileItem item = fileItemModel()->rootItem();
537 actions = m_versionControlObserver->actions(KFileItemList() << item);
538 } else {
539 actions = m_versionControlObserver->actions(items);
540 }
541
542 return actions;
543 }
544
545 void DolphinView::setUrl(const KUrl& url)
546 {
547 if (url == m_url) {
548 return;
549 }
550
551 emit urlAboutToBeChanged(url);
552 m_url = url;
553
554 if (GeneralSettings::showToolTips()) {
555 m_toolTipManager->hideToolTip();
556 }
557
558 // It is important to clear the items from the model before
559 // applying the view properties, otherwise expensive operations
560 // might be done on the existing items although they get cleared
561 // anyhow afterwards by loadDirectory().
562 fileItemModel()->clear();
563 applyViewProperties();
564 loadDirectory(url);
565
566 emit urlChanged(url);
567 }
568
569 void DolphinView::selectAll()
570 {
571 KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager();
572 selectionManager->setSelected(0, fileItemModel()->count());
573 }
574
575 void DolphinView::invertSelection()
576 {
577 KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager();
578 selectionManager->setSelected(0, fileItemModel()->count(), KItemListSelectionManager::Toggle);
579 }
580
581 void DolphinView::clearSelection()
582 {
583 m_container->controller()->selectionManager()->clearSelection();
584 }
585
586 void DolphinView::renameSelectedItems()
587 {
588 KFileItemList items = selectedItems();
589 const int itemCount = items.count();
590 if (itemCount < 1) {
591 return;
592 }
593
594 // TODO: The new view-engine introduced with Dolphin 2.0 does not support inline
595 // renaming yet.
596 /*if ((itemCount == 1) && DolphinSettings::instance().generalSettings()->renameInline()) {
597 const QModelIndex dirIndex = m_viewAccessor.dirModel()->indexForItem(items.first());
598 const QModelIndex proxyIndex = m_viewAccessor.proxyModel()->mapFromSource(dirIndex);
599 m_viewAccessor.itemView()->edit(proxyIndex);
600 } else {*/
601 RenameDialog* dialog = new RenameDialog(this, items);
602 dialog->setAttribute(Qt::WA_DeleteOnClose);
603 dialog->show();
604 dialog->raise();
605 dialog->activateWindow();
606 //}
607
608 // assure that the current index remains visible when KDirLister
609 // will notify the view about changed items
610 m_assureVisibleCurrentIndex = true;
611 }
612
613 void DolphinView::trashSelectedItems()
614 {
615 const KUrl::List list = simplifiedSelectedUrls();
616 KonqOperations::del(this, KonqOperations::TRASH, list);
617 }
618
619 void DolphinView::deleteSelectedItems()
620 {
621 const KUrl::List list = simplifiedSelectedUrls();
622 const bool del = KonqOperations::askDeleteConfirmation(list,
623 KonqOperations::DEL,
624 KonqOperations::DEFAULT_CONFIRMATION,
625 this);
626
627 if (del) {
628 KIO::Job* job = KIO::del(list);
629 connect(job, SIGNAL(result(KJob*)),
630 this, SLOT(slotDeleteFileFinished(KJob*)));
631 }
632 }
633
634 void DolphinView::cutSelectedItems()
635 {
636 QMimeData* mimeData = selectionMimeData();
637 KonqMimeData::addIsCutSelection(mimeData, true);
638 QApplication::clipboard()->setMimeData(mimeData);
639 }
640
641 void DolphinView::copySelectedItems()
642 {
643 QMimeData* mimeData = selectionMimeData();
644 QApplication::clipboard()->setMimeData(mimeData);
645 }
646
647 void DolphinView::paste()
648 {
649 pasteToUrl(url());
650 }
651
652 void DolphinView::pasteIntoFolder()
653 {
654 const KFileItemList items = selectedItems();
655 if ((items.count() == 1) && items.first().isDir()) {
656 pasteToUrl(items.first().url());
657 }
658 }
659
660 bool DolphinView::eventFilter(QObject* watched, QEvent* event)
661 {
662 switch (event->type()) {
663 case QEvent::FocusIn:
664 if (watched == m_container) {
665 setActive(true);
666 }
667 break;
668
669 default:
670 break;
671 }
672
673 return QWidget::eventFilter(watched, event);
674 }
675
676 void DolphinView::wheelEvent(QWheelEvent* event)
677 {
678 if (event->modifiers().testFlag(Qt::ControlModifier)) {
679 const int numDegrees = event->delta() / 8;
680 const int numSteps = numDegrees / 15;
681
682 setZoomLevel(zoomLevel() + numSteps);
683 event->accept();
684 } else {
685 event->ignore();
686 }
687 }
688
689 void DolphinView::activate()
690 {
691 setActive(true);
692 }
693
694 void DolphinView::slotItemActivated(int index)
695 {
696 const KFileItem item = fileItemModel()->fileItem(index);
697 if (!item.isNull()) {
698 emit itemActivated(item);
699 }
700 }
701
702 void DolphinView::slotItemsActivated(const QSet<int>& indexes)
703 {
704 Q_ASSERT(indexes.count() >= 2);
705
706 KFileItemList items;
707
708 KFileItemModel* model = fileItemModel();
709 QSetIterator<int> it(indexes);
710 while (it.hasNext()) {
711 const int index = it.next();
712 items.append(model->fileItem(index));
713 }
714
715 foreach (const KFileItem& item, items) {
716 if (item.isDir()) {
717 emit tabRequested(item.url());
718 } else {
719 emit itemActivated(item);
720 }
721 }
722 }
723
724 void DolphinView::slotItemMiddleClicked(int index)
725 {
726 const KFileItem item = fileItemModel()->fileItem(index);
727 if (item.isDir() || isTabsForFilesEnabled()) {
728 emit tabRequested(item.url());
729 }
730 }
731
732 void DolphinView::slotItemContextMenuRequested(int index, const QPointF& pos)
733 {
734 if (GeneralSettings::showToolTips()) {
735 m_toolTipManager->hideToolTip();
736 }
737 const KFileItem item = fileItemModel()->fileItem(index);
738 emit requestContextMenu(pos.toPoint(), item, url(), QList<QAction*>());
739 }
740
741 void DolphinView::slotViewContextMenuRequested(const QPointF& pos)
742 {
743 if (GeneralSettings::showToolTips()) {
744 m_toolTipManager->hideToolTip();
745 }
746 emit requestContextMenu(pos.toPoint(), KFileItem(), url(), QList<QAction*>());
747 }
748
749 void DolphinView::slotHeaderContextMenuRequested(const QPointF& pos)
750 {
751 QWeakPointer<KMenu> menu = new KMenu(QApplication::activeWindow());
752
753 KItemListView* view = m_container->controller()->view();
754 const QSet<QByteArray> visibleRolesSet = view->visibleRoles().toSet();
755
756 // Add all roles to the menu that can be shown or hidden by the user
757 const AdditionalInfoAccessor& infoAccessor = AdditionalInfoAccessor::instance();
758 const QList<DolphinView::AdditionalInfo> keys = infoAccessor.keys();
759 foreach (const DolphinView::AdditionalInfo info, keys) {
760 const QByteArray& role = infoAccessor.role(info);
761 if (role != "name") {
762 const QString text = fileItemModel()->roleDescription(role);
763
764 QAction* action = menu.data()->addAction(text);
765 action->setCheckable(true);
766 action->setChecked(visibleRolesSet.contains(role));
767 action->setData(info);
768 }
769 }
770
771 QAction* action = menu.data()->exec(pos.toPoint());
772 if (action) {
773 // Show or hide the selected role
774 const DolphinView::AdditionalInfo info =
775 static_cast<DolphinView::AdditionalInfo>(action->data().toInt());
776
777 ViewProperties props(url());
778 QList<DolphinView::AdditionalInfo> infoList = props.additionalInfoList();
779
780 const QByteArray selectedRole = infoAccessor.role(info);
781 QList<QByteArray> visibleRoles = view->visibleRoles();
782
783 if (action->isChecked()) {
784 const int index = keys.indexOf(info) + 1;
785 visibleRoles.insert(index, selectedRole);
786 infoList.insert(index, info);
787 } else {
788 visibleRoles.removeOne(selectedRole);
789 infoList.removeOne(info);
790 }
791
792 view->setVisibleRoles(visibleRoles);
793 props.setAdditionalInfoList(infoList);
794 }
795
796 delete menu.data();
797 }
798
799 void DolphinView::slotItemHovered(int index)
800 {
801 const KFileItem item = fileItemModel()->fileItem(index);
802
803 if (GeneralSettings::showToolTips()) {
804 QRectF itemRect = m_container->controller()->view()->itemContextRect(index);
805 const QPoint pos = m_container->mapToGlobal(itemRect.topLeft().toPoint());
806 itemRect.moveTo(pos);
807
808 m_toolTipManager->showToolTip(item, itemRect);
809 }
810
811 emit requestItemInfo(item);
812 }
813
814 void DolphinView::slotItemUnhovered(int index)
815 {
816 Q_UNUSED(index);
817 if (GeneralSettings::showToolTips()) {
818 m_toolTipManager->hideToolTip();
819 }
820 emit requestItemInfo(KFileItem());
821 }
822
823 void DolphinView::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event)
824 {
825 const KFileItem destItem = fileItemModel()->fileItem(index);
826
827 QDropEvent dropEvent(event->pos().toPoint(),
828 event->possibleActions(),
829 event->mimeData(),
830 event->buttons(),
831 event->modifiers());
832
833 const QString error = DragAndDropHelper::dropUrls(destItem, url(), &dropEvent);
834 if (!error.isEmpty()) {
835 emit errorMessage(error);
836 }
837 }
838
839 void DolphinView::slotModelChanged(KItemModelBase* current, KItemModelBase* previous)
840 {
841 if (previous != 0) {
842 disconnect(previous, SIGNAL(loadingCompleted()), this, SLOT(slotLoadingCompleted()));
843 }
844
845 Q_ASSERT(qobject_cast<KFileItemModel*>(current));
846 connect(current, SIGNAL(loadingCompleted()), this, SLOT(slotLoadingCompleted()));
847
848 KFileItemModel* fileItemModel = static_cast<KFileItemModel*>(current);
849 m_versionControlObserver->setModel(fileItemModel);
850 }
851
852 void DolphinView::slotSelectionChanged(const QSet<int>& current, const QSet<int>& previous)
853 {
854 const int currentCount = current.count();
855 const int previousCount = previous.count();
856 const bool selectionStateChanged = (currentCount == 0 && previousCount > 0) ||
857 (currentCount > 0 && previousCount == 0);
858
859 // If nothing has been selected before and something got selected (or if something
860 // was selected before and now nothing is selected) the selectionChangedSignal must
861 // be emitted asynchronously as fast as possible to update the edit-actions.
862 m_selectionChangedTimer->setInterval(selectionStateChanged ? 0 : 300);
863 m_selectionChangedTimer->start();
864 }
865
866 void DolphinView::emitSelectionChangedSignal()
867 {
868 m_selectionChangedTimer->stop();
869 emit selectionChanged(selectedItems());
870 }
871
872 void DolphinView::dropUrls(const KFileItem& destItem,
873 const KUrl& destPath,
874 QDropEvent* event)
875 {
876 Q_UNUSED(destItem);
877 Q_UNUSED(destPath);
878 markPastedUrlsAsSelected(event->mimeData());
879 //DragAndDropHelper::instance().dropUrls(destItem, destPath, event, this);
880 }
881
882 void DolphinView::updateSorting(DolphinView::Sorting sorting)
883 {
884 ViewProperties props(url());
885 props.setSorting(sorting);
886
887 KItemModelBase* model = m_container->controller()->model();
888 model->setSortRole(sortRoleForSorting(sorting));
889
890 emit sortingChanged(sorting);
891 }
892
893 void DolphinView::updateSortOrder(Qt::SortOrder order)
894 {
895 ViewProperties props(url());
896 props.setSortOrder(order);
897
898 KItemModelBase* model = fileItemModel();
899 model->setSortOrder(order);
900
901 emit sortOrderChanged(order);
902 }
903
904 void DolphinView::updateSortFoldersFirst(bool foldersFirst)
905 {
906 ViewProperties props(url());
907 props.setSortFoldersFirst(foldersFirst);
908
909 KFileItemModel* model = fileItemModel();
910 model->setSortFoldersFirst(foldersFirst);
911
912 emit sortFoldersFirstChanged(foldersFirst);
913 }
914
915 QPair<bool, QString> DolphinView::pasteInfo() const
916 {
917 return KonqOperations::pasteInfo(url());
918 }
919
920 void DolphinView::setTabsForFilesEnabled(bool tabsForFiles)
921 {
922 m_tabsForFiles = tabsForFiles;
923 }
924
925 bool DolphinView::isTabsForFilesEnabled() const
926 {
927 return m_tabsForFiles;
928 }
929
930 bool DolphinView::itemsExpandable() const
931 {
932 return m_mode == DetailsView;
933 }
934
935 void DolphinView::restoreState(QDataStream& stream)
936 {
937 // Restore the current item that had the keyboard focus
938 stream >> m_currentItemUrl;
939
940 // Restore the view position
941 stream >> m_restoredContentsPosition;
942
943 // Restore expanded folders (only relevant for the details view - will be ignored by the view in other view modes)
944 QSet<KUrl> urls;
945 stream >> urls;
946 fileItemModel()->restoreExpandedUrls(urls);
947 }
948
949 void DolphinView::saveState(QDataStream& stream)
950 {
951 // Save the current item that has the keyboard focus
952 const int currentIndex = m_container->controller()->selectionManager()->currentItem();
953 if (currentIndex != -1) {
954 KFileItem item = fileItemModel()->fileItem(currentIndex);
955 Q_ASSERT(!item.isNull()); // If the current index is valid a item must exist
956 KUrl currentItemUrl = item.url();
957 stream << currentItemUrl;
958 } else {
959 stream << KUrl();
960 }
961
962 // Save view position
963 const qreal x = m_container->horizontalScrollBar()->value();
964 const qreal y = m_container->verticalScrollBar()->value();
965 stream << QPoint(x, y);
966
967 // Save expanded folders (only relevant for the details view - the set will be empty in other view modes)
968 stream << fileItemModel()->expandedUrls();
969 }
970
971 bool DolphinView::hasSelection() const
972 {
973 return m_container->controller()->selectionManager()->hasSelection();
974 }
975
976 KFileItem DolphinView::rootItem() const
977 {
978 return m_dirLister->rootItem();
979 }
980
981 void DolphinView::observeCreatedItem(const KUrl& url)
982 {
983 m_createdItemUrl = url;
984 //connect(m_dirModel, SIGNAL(rowsInserted(QModelIndex,int,int)),
985 // this, SLOT(selectAndScrollToCreatedItem()));
986 }
987
988 void DolphinView::selectAndScrollToCreatedItem()
989 {
990 /*const QModelIndex dirIndex = m_viewAccessor.dirModel()->indexForUrl(m_createdItemUrl);
991 if (dirIndex.isValid()) {
992 const QModelIndex proxyIndex = m_viewAccessor.proxyModel()->mapFromSource(dirIndex);
993 QAbstractItemView* view = m_viewAccessor.itemView();
994 if (view) {
995 view->setCurrentIndex(proxyIndex);
996 }
997 }
998
999 disconnect(m_viewAccessor.dirModel(), SIGNAL(rowsInserted(QModelIndex,int,int)),
1000 this, SLOT(selectAndScrollToCreatedItem()));*/
1001 m_createdItemUrl = KUrl();
1002 }
1003
1004 void DolphinView::slotRedirection(const KUrl& oldUrl, const KUrl& newUrl)
1005 {
1006 if (oldUrl.equals(url(), KUrl::CompareWithoutTrailingSlash)) {
1007 emit redirection(oldUrl, newUrl);
1008 m_url = newUrl; // #186947
1009 }
1010 }
1011
1012 void DolphinView::updateViewState()
1013 {
1014 if (m_currentItemUrl != KUrl()) {
1015 KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager();
1016 const int currentIndex = fileItemModel()->index(m_currentItemUrl);
1017 if (currentIndex != -1) {
1018 selectionManager->setCurrentItem(currentIndex);
1019 } else {
1020 selectionManager->setCurrentItem(0);
1021 }
1022 m_currentItemUrl = KUrl();
1023 }
1024
1025 if (!m_restoredContentsPosition.isNull()) {
1026 const int x = m_restoredContentsPosition.x();
1027 const int y = m_restoredContentsPosition.y();
1028 m_restoredContentsPosition = QPoint();
1029
1030 m_container->horizontalScrollBar()->setValue(x);
1031 m_container->verticalScrollBar()->setValue(y);
1032 }
1033
1034 if (!m_selectedUrls.isEmpty()) {
1035 KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager();
1036 QSet<int> selectedItems = selectionManager->selectedItems();
1037 const KFileItemModel* model = fileItemModel();
1038
1039 foreach (const KUrl& url, m_selectedUrls) {
1040 const int index = model->index(url);
1041 if (index >= 0) {
1042 selectedItems.insert(index);
1043 }
1044 }
1045
1046 selectionManager->setSelectedItems(selectedItems);
1047 m_selectedUrls.clear();
1048 }
1049 }
1050
1051 void DolphinView::showHoverInformation(const KFileItem& item)
1052 {
1053 emit requestItemInfo(item);
1054 }
1055
1056 void DolphinView::clearHoverInformation()
1057 {
1058 emit requestItemInfo(KFileItem());
1059 }
1060
1061 void DolphinView::slotDeleteFileFinished(KJob* job)
1062 {
1063 if (job->error() == 0) {
1064 emit operationCompletedMessage(i18nc("@info:status", "Delete operation completed."));
1065 } else if (job->error() != KIO::ERR_USER_CANCELED) {
1066 emit errorMessage(job->errorString());
1067 }
1068 }
1069
1070 void DolphinView::slotDirListerStarted(const KUrl& url)
1071 {
1072 // Disable the writestate temporary until it can be determined in a fast way
1073 // in DolphinView::slotLoadingCompleted()
1074 if (m_isFolderWritable) {
1075 m_isFolderWritable = false;
1076 emit writeStateChanged(m_isFolderWritable);
1077 }
1078
1079 emit startedPathLoading(url);
1080 }
1081
1082 void DolphinView::slotLoadingCompleted()
1083 {
1084 // Update the view-state. This has to be done using a Qt::QueuedConnection
1085 // because the view might not be in its final state yet (the view also
1086 // listens to the completed()-signal from KDirLister and the order of
1087 // of slots is undefined).
1088 QTimer::singleShot(0, this, SLOT(updateViewState()));
1089
1090 emit finishedPathLoading(url());
1091
1092 updateWritableState();
1093 }
1094
1095 void DolphinView::slotRefreshItems()
1096 {
1097 if (m_assureVisibleCurrentIndex) {
1098 m_assureVisibleCurrentIndex = false;
1099 //QAbstractItemView* view = m_viewAccessor.itemView();
1100 //if (view) {
1101 // m_viewAccessor.itemView()->scrollTo(m_viewAccessor.itemView()->currentIndex());
1102 //}
1103 }
1104 }
1105
1106 void DolphinView::slotSortOrderChangedByHeader(Qt::SortOrder current, Qt::SortOrder previous)
1107 {
1108 Q_UNUSED(previous);
1109 Q_ASSERT(fileItemModel()->sortOrder() == current);
1110
1111 ViewProperties props(url());
1112 props.setSortOrder(current);
1113
1114 emit sortOrderChanged(current);
1115 }
1116
1117 void DolphinView::slotSortRoleChangedByHeader(const QByteArray& current, const QByteArray& previous)
1118 {
1119 Q_UNUSED(previous);
1120 Q_ASSERT(fileItemModel()->sortRole() == current);
1121
1122 ViewProperties props(url());
1123 const Sorting sorting = sortingForSortRole(current);
1124 props.setSorting(sorting);
1125
1126 emit sortingChanged(sorting);
1127 }
1128
1129 KFileItemModel* DolphinView::fileItemModel() const
1130 {
1131 return static_cast<KFileItemModel*>(m_container->controller()->model());
1132 }
1133
1134 void DolphinView::loadDirectory(const KUrl& url, bool reload)
1135 {
1136 if (!url.isValid()) {
1137 const QString location(url.pathOrUrl());
1138 if (location.isEmpty()) {
1139 emit errorMessage(i18nc("@info:status", "The location is empty."));
1140 } else {
1141 emit errorMessage(i18nc("@info:status", "The location '%1' is invalid.", location));
1142 }
1143 return;
1144 }
1145
1146 m_dirLister->openUrl(url, reload ? KDirLister::Reload : KDirLister::NoFlags);
1147 }
1148
1149 void DolphinView::applyViewProperties()
1150 {
1151 m_container->beginTransaction();
1152
1153 const ViewProperties props(url());
1154 KFileItemModel* model = fileItemModel();
1155
1156 const Mode mode = props.viewMode();
1157 if (m_mode != mode) {
1158 // Prevent an animated transition of the position and size of the items when switching
1159 // the view-mode by temporary clearing the model and updating it again after the view mode
1160 // has been modified.
1161 const bool restoreModel = (model->count() > 0);
1162 if (restoreModel) {
1163 const int currentItemIndex = m_container->controller()->selectionManager()->currentItem();
1164 if (currentItemIndex >= 0) {
1165 m_currentItemUrl = model->fileItem(currentItemIndex).url();
1166 }
1167 m_selectedUrls = selectedItems().urlList();
1168 model->clear();
1169 }
1170
1171 const Mode previousMode = m_mode;
1172 m_mode = mode;
1173
1174 // Changing the mode might result in changing
1175 // the zoom level. Remember the old zoom level so
1176 // that zoomLevelChanged() can get emitted.
1177 const int oldZoomLevel = m_container->zoomLevel();
1178
1179 switch (m_mode) {
1180 case IconsView: m_container->setItemLayout(KFileItemListView::IconsLayout); break;
1181 case CompactView: m_container->setItemLayout(KFileItemListView::CompactLayout); break;
1182 case DetailsView: m_container->setItemLayout(KFileItemListView::DetailsLayout); break;
1183 default: Q_ASSERT(false); break;
1184 }
1185
1186 emit modeChanged(m_mode, previousMode);
1187
1188 if (m_container->zoomLevel() != oldZoomLevel) {
1189 emit zoomLevelChanged(m_container->zoomLevel(), oldZoomLevel);
1190 }
1191
1192 if (restoreModel) {
1193 loadDirectory(url());
1194 }
1195 }
1196
1197 const bool hiddenFilesShown = props.hiddenFilesShown();
1198 if (hiddenFilesShown != model->showHiddenFiles()) {
1199 model->setShowHiddenFiles(hiddenFilesShown);
1200 emit hiddenFilesShownChanged(hiddenFilesShown);
1201 }
1202
1203 const bool groupedSorting = props.groupedSorting();
1204 if (groupedSorting != model->groupedSorting()) {
1205 model->setGroupedSorting(groupedSorting);
1206 emit groupedSortingChanged(groupedSorting);
1207 }
1208
1209 const DolphinView::Sorting sorting = props.sorting();
1210 const QByteArray newSortRole = sortRoleForSorting(sorting);
1211 if (newSortRole != model->sortRole()) {
1212 model->setSortRole(newSortRole);
1213 emit sortingChanged(sorting);
1214 }
1215
1216 const Qt::SortOrder sortOrder = props.sortOrder();
1217 if (sortOrder != model->sortOrder()) {
1218 model->setSortOrder(sortOrder);
1219 emit sortOrderChanged(sortOrder);
1220 }
1221
1222 const bool sortFoldersFirst = props.sortFoldersFirst();
1223 if (sortFoldersFirst != model->sortFoldersFirst()) {
1224 model->setSortFoldersFirst(sortFoldersFirst);
1225 emit sortFoldersFirstChanged(sortFoldersFirst);
1226 }
1227
1228 const QList<DolphinView::AdditionalInfo> infoList = props.additionalInfoList();
1229 if (infoList != m_additionalInfoList) {
1230 const QList<DolphinView::AdditionalInfo> previousList = m_additionalInfoList;
1231 m_additionalInfoList = infoList;
1232 applyAdditionalInfoListToView();
1233 emit additionalInfoListChanged(m_additionalInfoList, previousList);
1234 }
1235
1236 const bool previewsShown = props.previewsShown();
1237 if (previewsShown != m_container->previewsShown()) {
1238 const int oldZoomLevel = zoomLevel();
1239
1240 m_container->setPreviewsShown(previewsShown);
1241 emit previewsShownChanged(previewsShown);
1242
1243 // Changing the preview-state might result in a changed zoom-level
1244 if (oldZoomLevel != zoomLevel()) {
1245 emit zoomLevelChanged(zoomLevel(), oldZoomLevel);
1246 }
1247 }
1248
1249 m_container->endTransaction();
1250 }
1251
1252 void DolphinView::applyAdditionalInfoListToView()
1253 {
1254 const AdditionalInfoAccessor& infoAccessor = AdditionalInfoAccessor::instance();
1255
1256 QList<QByteArray> visibleRoles;
1257 visibleRoles.reserve(m_additionalInfoList.count() + 1);
1258 visibleRoles.append("name");
1259
1260 foreach (AdditionalInfo info, m_additionalInfoList) {
1261 visibleRoles.append(infoAccessor.role(info));
1262 }
1263
1264 m_container->setVisibleRoles(visibleRoles);
1265 }
1266
1267 void DolphinView::pasteToUrl(const KUrl& url)
1268 {
1269 markPastedUrlsAsSelected(QApplication::clipboard()->mimeData());
1270 KonqOperations::doPaste(this, url);
1271 }
1272
1273 KUrl::List DolphinView::simplifiedSelectedUrls() const
1274 {
1275 KUrl::List urls;
1276
1277 const KFileItemList items = selectedItems();
1278 foreach (const KFileItem &item, items) {
1279 urls.append(item.url());
1280 }
1281
1282 if (itemsExpandable()) {
1283 // TODO: Check if we still need KDirModel for this in KDE 5.0
1284 urls = KDirModel::simplifiedUrlList(urls);
1285 }
1286
1287 return urls;
1288 }
1289
1290 QMimeData* DolphinView::selectionMimeData() const
1291 {
1292 const KFileItemModel* model = fileItemModel();
1293 const KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager();
1294 const QSet<int> selectedIndexes = selectionManager->selectedItems();
1295
1296 return model->createMimeData(selectedIndexes);
1297 }
1298
1299 void DolphinView::markPastedUrlsAsSelected(const QMimeData* mimeData)
1300 {
1301 const KUrl::List urls = KUrl::List::fromMimeData(mimeData);
1302 markUrlsAsSelected(urls);
1303 }
1304
1305 void DolphinView::updateWritableState()
1306 {
1307 const bool wasFolderWritable = m_isFolderWritable;
1308 m_isFolderWritable = true;
1309
1310 const KFileItem item = m_dirLister->rootItem();
1311 if (!item.isNull()) {
1312 KFileItemListProperties capabilities(KFileItemList() << item);
1313 m_isFolderWritable = capabilities.supportsWriting();
1314 }
1315 if (m_isFolderWritable != wasFolderWritable) {
1316 emit writeStateChanged(m_isFolderWritable);
1317 }
1318 }
1319
1320 QByteArray DolphinView::sortRoleForSorting(Sorting sorting) const
1321 {
1322 switch (sorting) {
1323 case SortByName: return "name";
1324 case SortBySize: return "size";
1325 case SortByDate: return "date";
1326 case SortByPermissions: return "permissions";
1327 case SortByOwner: return "owner";
1328 case SortByGroup: return "group";
1329 case SortByType: return "type";
1330 case SortByDestination: return "destination";
1331 case SortByPath: return "path";
1332 default: break;
1333 }
1334
1335 return QByteArray();
1336 }
1337
1338 DolphinView::Sorting DolphinView::sortingForSortRole(const QByteArray& sortRole) const
1339 {
1340 static QHash<QByteArray, DolphinView::Sorting> sortHash;
1341 if (sortHash.isEmpty()) {
1342 sortHash.insert("name", SortByName);
1343 sortHash.insert("size", SortBySize);
1344 sortHash.insert("date", SortByDate);
1345 sortHash.insert("permissions", SortByPermissions);
1346 sortHash.insert("owner", SortByOwner);
1347 sortHash.insert("group", SortByGroup);
1348 sortHash.insert("type", SortByType);
1349 sortHash.insert("destination", SortByDestination);
1350 sortHash.insert("path", SortByPath);
1351 }
1352 return sortHash.value(sortRole);
1353 }
1354
1355 QString DolphinView::fileSizeText(KIO::filesize_t fileSize)
1356 {
1357 const KLocale* locale = KGlobal::locale();
1358 const unsigned int multiplier = (locale->binaryUnitDialect() == KLocale::MetricBinaryDialect)
1359 ? 1000 : 1024;
1360
1361 QString text;
1362 if (fileSize < multiplier) {
1363 // Show the size in bytes
1364 text = locale->formatByteSize(fileSize, 0, KLocale::DefaultBinaryDialect, KLocale::UnitByte);
1365 } else if (fileSize < multiplier * multiplier) {
1366 // Show the size in kilobytes and always round up. This is done
1367 // for consistency with the values shown e.g. in the "Size" column
1368 // of the details-view.
1369 fileSize += (multiplier / 2) - 1;
1370 text = locale->formatByteSize(fileSize, 0, KLocale::DefaultBinaryDialect, KLocale::UnitKiloByte);
1371 } else {
1372 // Show the size in the best fitting unit having one decimal
1373 text = locale->formatByteSize(fileSize, 1);
1374 }
1375 return text;
1376 }
1377
1378 #include "dolphinview.moc"