diff --git a/CMakeLists.txt b/CMakeLists.txt index fe96723b6..c47b8d5cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,48 +1,48 @@ # 3.1 is required for `target_sources`. cmake_minimum_required(VERSION 3.1 FATAL_ERROR) # KDE Applications version, managed by release script. set(KDE_APPLICATIONS_VERSION_MAJOR "19") set(KDE_APPLICATIONS_VERSION_MINOR "11") set(KDE_APPLICATIONS_VERSION_MICRO "70") set(KDE_APPLICATIONS_VERSION "${KDE_APPLICATIONS_VERSION_MAJOR}.${KDE_APPLICATIONS_VERSION_MINOR}.${KDE_APPLICATIONS_VERSION_MICRO}") project(kate VERSION ${KDE_APPLICATIONS_VERSION}) -set(QT_MIN_VERSION "5.4.0") +set(QT_MIN_VERSION "5.10.0") set(KF5_DEP_VERSION "5.40.0") # We need some parts of the ECM CMake helpers. find_package(ECM ${KF5_DEP_VERSION} QUIET REQUIRED NO_MODULE) # We append to the module path so modules can be overriden from the command line. list(APPEND CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) # Allow adding Qt resource files with `add_executable` or `target_sources` instead of # `qt5_add_resources`. See https://cmake.org/cmake/help/v3.0/manual/cmake-qt.7.html#autorcc. set(CMAKE_AUTORCC ON) include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE) include(KDEInstallDirs) include(KDECMakeSettings) include(ECMOptionalAddSubdirectory) include(ECMAddAppIcon) include(ECMInstallIcons) include(FeatureSummary) # forbid some old things add_definitions(-DQT_NO_FOREACH) # Qt 5.13 deprecated QComboBox::currentIndexChanged(QString) and Qt 5.14 undid that... if (Qt5Widgets_VERSION VERSION_GREATER_EQUAL 5.14.0) add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050d00) endif() ecm_optional_add_subdirectory(addons) ecm_optional_add_subdirectory(kwrite) ecm_optional_add_subdirectory(kate) ecm_optional_add_subdirectory(doc) feature_summary(INCLUDE_QUIET_PACKAGES WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/addons/project/kateprojectviewtree.cpp b/addons/project/kateprojectviewtree.cpp index eb98d360c..09b7e51d9 100644 --- a/addons/project/kateprojectviewtree.cpp +++ b/addons/project/kateprojectviewtree.cpp @@ -1,167 +1,163 @@ /* This file is part of the Kate project. * * Copyright (C) 2012 Christoph Cullmann * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "kateprojectviewtree.h" #include "kateprojectpluginview.h" #include "kateprojecttreeviewcontextmenu.h" #include #include #include -#if (QT_VERSION < QT_VERSION_CHECK(5, 10, 0)) -#include -#else #include -#endif KateProjectViewTree::KateProjectViewTree(KateProjectPluginView *pluginView, KateProject *project) : QTreeView() , m_pluginView(pluginView) , m_project(project) { /** * default style */ setHeaderHidden(true); setEditTriggers(QAbstractItemView::NoEditTriggers); setAllColumnsShowFocus(true); setFocusPolicy(Qt::NoFocus); /** * attach view => project * do this once, model is stable for whole project life time * kill selection model * create sort proxy model */ QItemSelectionModel *m = selectionModel(); #if (QT_VERSION < QT_VERSION_CHECK(5, 10, 0)) QSortFilterProxyModel *sortModel = new KRecursiveFilterProxyModel(this); #else QSortFilterProxyModel *sortModel = new QSortFilterProxyModel(this); sortModel->setRecursiveFilteringEnabled(true); #endif // sortModel->setFilterRole(SortFilterRole); // sortModel->setSortRole(SortFilterRole); sortModel->setFilterCaseSensitivity(Qt::CaseInsensitive); sortModel->setSortCaseSensitivity(Qt::CaseInsensitive); sortModel->setSourceModel(m_project->model()); setModel(sortModel); delete m; /** * connect needed signals * we use activated + clicked as we want "always" single click activation + keyboard focus / enter working */ connect(this, &KateProjectViewTree::activated, this, &KateProjectViewTree::slotClicked); connect(this, &KateProjectViewTree::clicked, this, &KateProjectViewTree::slotClicked); connect(m_project, &KateProject::modelChanged, this, &KateProjectViewTree::slotModelChanged); /** * trigger once some slots */ slotModelChanged(); } KateProjectViewTree::~KateProjectViewTree() { } void KateProjectViewTree::selectFile(const QString &file) { /** * get item if any */ QStandardItem *item = m_project->itemForFile(file); if (!item) { return; } /** * select it */ QModelIndex index = static_cast(model())->mapFromSource(m_project->model()->indexFromItem(item)); scrollTo(index, QAbstractItemView::EnsureVisible); selectionModel()->setCurrentIndex(index, QItemSelectionModel::Clear | QItemSelectionModel::Select); } void KateProjectViewTree::openSelectedDocument() { /** * anything selected? */ QModelIndexList selecteStuff = selectedIndexes(); if (selecteStuff.isEmpty()) { return; } /** * open document for first element, if possible */ QString filePath = selecteStuff[0].data(Qt::UserRole).toString(); if (!filePath.isEmpty()) { m_pluginView->mainWindow()->openUrl(QUrl::fromLocalFile(filePath)); } } void KateProjectViewTree::slotClicked(const QModelIndex &index) { /** * open document, if any usable user data */ QString filePath = index.data(Qt::UserRole).toString(); if (!filePath.isEmpty()) { m_pluginView->mainWindow()->openUrl(QUrl::fromLocalFile(filePath)); selectionModel()->setCurrentIndex(index, QItemSelectionModel::Clear | QItemSelectionModel::Select); } } void KateProjectViewTree::slotModelChanged() { /** * model was updated * perhaps we need to highlight again new file */ KTextEditor::View *activeView = m_pluginView->mainWindow()->activeView(); if (activeView && activeView->document()->url().isLocalFile()) { selectFile(activeView->document()->url().toLocalFile()); } } void KateProjectViewTree::contextMenuEvent(QContextMenuEvent *event) { /** * get path file path or don't do anything */ QModelIndex index = selectionModel()->currentIndex(); QString filePath = index.data(Qt::UserRole).toString(); if (filePath.isEmpty()) { QTreeView::contextMenuEvent(event); return; } KateProjectTreeViewContextMenu menu; menu.exec(filePath, viewport()->mapToGlobal(event->pos()), this); event->accept(); }