Changeset View
Changeset View
Standalone View
Standalone View
src/views/dolphinview.cpp
Show First 20 Lines • Show All 72 Lines • ▼ Show 20 Line(s) | 72 | DolphinView::DolphinView(const QUrl& url, QWidget* parent) : | |||
---|---|---|---|---|---|
73 | QWidget(parent), | 73 | QWidget(parent), | ||
74 | m_active(true), | 74 | m_active(true), | ||
75 | m_tabsForFiles(false), | 75 | m_tabsForFiles(false), | ||
76 | m_assureVisibleCurrentIndex(false), | 76 | m_assureVisibleCurrentIndex(false), | ||
77 | m_isFolderWritable(true), | 77 | m_isFolderWritable(true), | ||
78 | m_dragging(false), | 78 | m_dragging(false), | ||
79 | m_url(url), | 79 | m_url(url), | ||
80 | m_viewPropertiesContext(), | 80 | m_viewPropertiesContext(), | ||
81 | m_mode(DolphinView::IconsView), | 81 | m_mode(DolphinView::Mode::IconsView), | ||
82 | m_visibleRoles(), | 82 | m_visibleRoles(), | ||
83 | m_topLayout(nullptr), | 83 | m_topLayout(nullptr), | ||
84 | m_model(nullptr), | 84 | m_model(nullptr), | ||
85 | m_view(nullptr), | 85 | m_view(nullptr), | ||
86 | m_container(nullptr), | 86 | m_container(nullptr), | ||
87 | m_toolTipManager(nullptr), | 87 | m_toolTipManager(nullptr), | ||
88 | m_selectionChangedTimer(nullptr), | 88 | m_selectionChangedTimer(nullptr), | ||
89 | m_currentItemUrl(), | 89 | m_currentItemUrl(), | ||
Show All 36 Lines | 97 | { | |||
126 | m_view->setEnlargeSmallPreviews(GeneralSettings::enlargeSmallPreviews()); | 126 | m_view->setEnlargeSmallPreviews(GeneralSettings::enlargeSmallPreviews()); | ||
127 | 127 | | |||
128 | m_container = new KItemListContainer(controller, this); | 128 | m_container = new KItemListContainer(controller, this); | ||
129 | m_container->installEventFilter(this); | 129 | m_container->installEventFilter(this); | ||
130 | setFocusProxy(m_container); | 130 | setFocusProxy(m_container); | ||
131 | connect(m_container->horizontalScrollBar(), &QScrollBar::valueChanged, this, &DolphinView::hideToolTip); | 131 | connect(m_container->horizontalScrollBar(), &QScrollBar::valueChanged, this, &DolphinView::hideToolTip); | ||
132 | connect(m_container->verticalScrollBar(), &QScrollBar::valueChanged, this, &DolphinView::hideToolTip); | 132 | connect(m_container->verticalScrollBar(), &QScrollBar::valueChanged, this, &DolphinView::hideToolTip); | ||
133 | 133 | | |||
134 | controller->setSelectionBehavior(KItemListController::MultiSelection); | 134 | controller->setSelectionBehavior(KItemListController::SelectionBehavior::MultiSelection); | ||
135 | connect(controller, &KItemListController::itemActivated, this, &DolphinView::slotItemActivated); | 135 | connect(controller, &KItemListController::itemActivated, this, &DolphinView::slotItemActivated); | ||
136 | connect(controller, &KItemListController::itemsActivated, this, &DolphinView::slotItemsActivated); | 136 | connect(controller, &KItemListController::itemsActivated, this, &DolphinView::slotItemsActivated); | ||
137 | connect(controller, &KItemListController::itemMiddleClicked, this, &DolphinView::slotItemMiddleClicked); | 137 | connect(controller, &KItemListController::itemMiddleClicked, this, &DolphinView::slotItemMiddleClicked); | ||
138 | connect(controller, &KItemListController::itemContextMenuRequested, this, &DolphinView::slotItemContextMenuRequested); | 138 | connect(controller, &KItemListController::itemContextMenuRequested, this, &DolphinView::slotItemContextMenuRequested); | ||
139 | connect(controller, &KItemListController::viewContextMenuRequested, this, &DolphinView::slotViewContextMenuRequested); | 139 | connect(controller, &KItemListController::viewContextMenuRequested, this, &DolphinView::slotViewContextMenuRequested); | ||
140 | connect(controller, &KItemListController::headerContextMenuRequested, this, &DolphinView::slotHeaderContextMenuRequested); | 140 | connect(controller, &KItemListController::headerContextMenuRequested, this, &DolphinView::slotHeaderContextMenuRequested); | ||
141 | connect(controller, &KItemListController::mouseButtonPressed, this, &DolphinView::slotMouseButtonPressed); | 141 | connect(controller, &KItemListController::mouseButtonPressed, this, &DolphinView::slotMouseButtonPressed); | ||
142 | connect(controller, &KItemListController::itemHovered, this, &DolphinView::slotItemHovered); | 142 | connect(controller, &KItemListController::itemHovered, this, &DolphinView::slotItemHovered); | ||
▲ Show 20 Lines • Show All 214 Lines • ▼ Show 20 Line(s) | |||||
357 | { | 357 | { | ||
358 | m_currentItemUrl = url; | 358 | m_currentItemUrl = url; | ||
359 | m_scrollToCurrentItem = true; | 359 | m_scrollToCurrentItem = true; | ||
360 | } | 360 | } | ||
361 | 361 | | |||
362 | void DolphinView::selectItems(const QRegExp& pattern, bool enabled) | 362 | void DolphinView::selectItems(const QRegExp& pattern, bool enabled) | ||
363 | { | 363 | { | ||
364 | const KItemListSelectionManager::SelectionMode mode = enabled | 364 | const KItemListSelectionManager::SelectionMode mode = enabled | ||
365 | ? KItemListSelectionManager::Select | 365 | ? KItemListSelectionManager::SelectionMode::Select | ||
366 | : KItemListSelectionManager::Deselect; | 366 | : KItemListSelectionManager::SelectionMode::Deselect; | ||
367 | KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager(); | 367 | KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager(); | ||
368 | 368 | | |||
369 | for (int index = 0; index < m_model->count(); index++) { | 369 | for (int index = 0; index < m_model->count(); index++) { | ||
370 | const KFileItem item = m_model->fileItem(index); | 370 | const KFileItem item = m_model->fileItem(index); | ||
371 | if (pattern.exactMatch(item.text())) { | 371 | if (pattern.exactMatch(item.text())) { | ||
372 | // An alternative approach would be to store the matching items in a KItemSet and | 372 | // An alternative approach would be to store the matching items in a KItemSet and | ||
373 | // select them in one go after the loop, but we'd need a new function | 373 | // select them in one go after the loop, but we'd need a new function | ||
374 | // KItemListSelectionManager::setSelected(KItemSet, SelectionMode mode) | 374 | // KItemListSelectionManager::setSelected(KItemSet, SelectionMode mode) | ||
▲ Show 20 Lines • Show All 228 Lines • ▼ Show 20 Line(s) | |||||
603 | { | 603 | { | ||
604 | KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager(); | 604 | KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager(); | ||
605 | selectionManager->setSelected(0, m_model->count()); | 605 | selectionManager->setSelected(0, m_model->count()); | ||
606 | } | 606 | } | ||
607 | 607 | | |||
608 | void DolphinView::invertSelection() | 608 | void DolphinView::invertSelection() | ||
609 | { | 609 | { | ||
610 | KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager(); | 610 | KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager(); | ||
611 | selectionManager->setSelected(0, m_model->count(), KItemListSelectionManager::Toggle); | 611 | selectionManager->setSelected(0, m_model->count(), KItemListSelectionManager::SelectionMode::Toggle); | ||
612 | } | 612 | } | ||
613 | 613 | | |||
614 | void DolphinView::clearSelection() | 614 | void DolphinView::clearSelection() | ||
615 | { | 615 | { | ||
616 | m_selectedUrls.clear(); | 616 | m_selectedUrls.clear(); | ||
617 | m_container->controller()->selectionManager()->clearSelection(); | 617 | m_container->controller()->selectionManager()->clearSelection(); | ||
618 | } | 618 | } | ||
619 | 619 | | |||
▲ Show 20 Lines • Show All 592 Lines • ▼ Show 20 Line(s) | |||||
1212 | 1212 | | |||
1213 | bool DolphinView::isTabsForFilesEnabled() const | 1213 | bool DolphinView::isTabsForFilesEnabled() const | ||
1214 | { | 1214 | { | ||
1215 | return m_tabsForFiles; | 1215 | return m_tabsForFiles; | ||
1216 | } | 1216 | } | ||
1217 | 1217 | | |||
1218 | bool DolphinView::itemsExpandable() const | 1218 | bool DolphinView::itemsExpandable() const | ||
1219 | { | 1219 | { | ||
1220 | return m_mode == DetailsView; | 1220 | return m_mode == Mode::DetailsView; | ||
1221 | } | 1221 | } | ||
1222 | 1222 | | |||
1223 | void DolphinView::restoreState(QDataStream& stream) | 1223 | void DolphinView::restoreState(QDataStream& stream) | ||
1224 | { | 1224 | { | ||
1225 | // Read the version number of the view state and check if the version is supported. | 1225 | // Read the version number of the view state and check if the version is supported. | ||
1226 | quint32 version = 0; | 1226 | quint32 version = 0; | ||
1227 | stream >> version; | 1227 | stream >> version; | ||
1228 | if (version != 1) { | 1228 | if (version != 1) { | ||
▲ Show 20 Lines • Show All 486 Lines • ▼ Show 20 Line(s) | 1627 | { | |||
1715 | } | 1715 | } | ||
1716 | 1716 | | |||
1717 | m_view->endTransaction(); | 1717 | m_view->endTransaction(); | ||
1718 | } | 1718 | } | ||
1719 | 1719 | | |||
1720 | void DolphinView::applyModeToView() | 1720 | void DolphinView::applyModeToView() | ||
1721 | { | 1721 | { | ||
1722 | switch (m_mode) { | 1722 | switch (m_mode) { | ||
1723 | case IconsView: m_view->setItemLayout(KFileItemListView::IconsLayout); break; | 1723 | case Mode::IconsView: m_view->setItemLayout(KFileItemListView::ItemLayout::Icons); break; | ||
1724 | case CompactView: m_view->setItemLayout(KFileItemListView::CompactLayout); break; | 1724 | case Mode::CompactView: m_view->setItemLayout(KFileItemListView::ItemLayout::Compact); break; | ||
1725 | case DetailsView: m_view->setItemLayout(KFileItemListView::DetailsLayout); break; | 1725 | case Mode::DetailsView: m_view->setItemLayout(KFileItemListView::ItemLayout::Details); break; | ||
1726 | default: Q_ASSERT(false); break; | 1726 | default: Q_ASSERT(false); break; | ||
1727 | } | 1727 | } | ||
1728 | } | 1728 | } | ||
1729 | 1729 | | |||
1730 | void DolphinView::pasteToUrl(const QUrl& url) | 1730 | void DolphinView::pasteToUrl(const QUrl& url) | ||
1731 | { | 1731 | { | ||
1732 | KIO::PasteJob *job = KIO::paste(QApplication::clipboard()->mimeData(), url); | 1732 | KIO::PasteJob *job = KIO::paste(QApplication::clipboard()->mimeData(), url); | ||
1733 | KJobWidgets::setWindow(job, this); | 1733 | KJobWidgets::setWindow(job, this); | ||
▲ Show 20 Lines • Show All 77 Lines • Show Last 20 Lines |