1
0
mirror of https://invent.kde.org/system/dolphin synced 2024-07-04 17:30:55 +00:00

Merge branch 'frameworks'

This commit is contained in:
Emmanuel Pescosta 2015-02-27 11:30:27 +01:00
commit 9aee5d2251
279 changed files with 7082 additions and 4957 deletions

View File

@ -1,2 +1,127 @@
cmake_minimum_required(VERSION 2.8.12)
project(Dolphin)
set(DOLPHIN_VERSION "14.12.95")
set(QT_MIN_VERSION "5.4.0")
set(KF5_MIN_VERSION "5.7.0")
set(ECM_MIN_VERSION "1.6.0")
# ECM setup
find_package(ECM ${ECM_MIN_VERSION} CONFIG REQUIRED)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
include(ECMSetupVersion)
include(ECMGenerateHeaders)
include(ECMPackageConfigHelpers)
include(GenerateExportHeader)
include(FeatureSummary)
include(KDEInstallDirs)
include(KDECMakeSettings)
include(KDEFrameworkCompilerSettings)
ecm_setup_version(${DOLPHIN_VERSION} VARIABLE_PREFIX DOLPHINVCS
VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/dolphinvcs_version.h"
PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/DolphinVcsConfigVersion.cmake"
SOVERSION 5
)
ecm_setup_version(${DOLPHIN_VERSION} VARIABLE_PREFIX DOLPHINPRIVATE
SOVERSION 5
)
find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
Core
Widgets
Gui
DBus
Test
)
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
DocTools
Init
KCMUtils
NewStuff
CoreAddons
I18n
DBusAddons
Bookmarks
Config
KIO
Parts
Solid
IconThemes
Completion
TextEditor
WindowSystem
Notifications
)
find_package(KF5 ${KF5_MIN_VERSION} COMPONENTS
Activities
)
find_package(Phonon4Qt5 CONFIG REQUIRED)
find_package(KF5Baloo 4.97)
set_package_properties(KF5Baloo PROPERTIES DESCRIPTION "Baloo Core libraries"
URL "http://www.kde.org"
TYPE OPTIONAL
PURPOSE "For adding desktop-wide search and tagging support to dolphin"
)
find_package(KF5BalooWidgets 4.97)
set_package_properties(KF5BalooWidgets PROPERTIES DESCRIPTION "Baloos Widgets"
URL "http://www.kde.org"
TYPE OPTIONAL
)
find_package(KF5FileMetaData 4.97)
set_package_properties(KF5FileMetaData PROPERTIES
URL "https://projects.kde.org/kfilemetadata"
TYPE OPTIONAL
PURPOSE "For accessing file metadata labels"
)
if (KF5Baloo_FOUND AND KF5BalooWidgets_FOUND AND KF5FileMetaData_FOUND)
message(STATUS "Baloo packages are found")
set(HAVE_BALOO TRUE)
else()
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
KDELibs4Support # for KFileMetaDataWidget
)
endif()
add_subdirectory(src)
add_subdirectory(docs)
# CMake files
set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/DolphinVcs")
ecm_configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/DolphinVcsConfig.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/DolphinVcsConfig.cmake"
INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR}
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/DolphinVcsConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/DolphinVcsConfigVersion.cmake"
DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
COMPONENT Devel
)
install(EXPORT DolphinVcsTargets
DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
FILE DolphinVcsTargets.cmake
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/dolphinvcs_version.h"
DESTINATION "${KDE_INSTALL_INCLUDEDIR}/Dolphin"
COMPONENT Devel
)
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)

View File

@ -0,0 +1,6 @@
@PACKAGE_INIT@
find_dependency(Qt5Widgets)
find_dependency(KF5KIO)
include("${CMAKE_CURRENT_LIST_DIR}/DolphinVcsTargets.cmake")

2
docs/CMakeLists.txt Normal file
View File

@ -0,0 +1,2 @@
kdoctools_create_handbook(index.docbook INSTALL_DESTINATION ${HTML_INSTALL_DIR}/en SUBDIR dolphin)

BIN
docs/default-ui.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB

BIN
docs/grouping-view.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

2134
docs/index.docbook Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
docs/nepomuk-search.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

BIN
docs/preferences-trash.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

BIN
docs/toolbar-navigation.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

BIN
docs/toolbar.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

View File

@ -1,39 +1,62 @@
macro_optional_find_package(Baloo)
set_package_properties(Baloo PROPERTIES DESCRIPTION "Baloo Core libraries"
URL "http://www.kde.org"
TYPE OPTIONAL
PURPOSE "For adding desktop-wide search and tagging support to dolphin"
)
macro_optional_find_package(BalooWidgets)
set_package_properties(BalooWidgets PROPERTIES DESCRIPTION "Baloos Widgets"
URL "http://www.kde.org"
TYPE OPTIONAL
)
configure_file(config-baloo.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-baloo.h)
macro_optional_find_package(KFileMetaData)
set_package_properties(KFileMetaData PROPERTIES
URL "https://projects.kde.org/kfilemetadata"
TYPE OPTIONAL
PURPOSE "For accessing file metadata labels"
)
configure_file(config-dolphin.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-dolphin.h)
if (Baloo_FOUND AND BalooWidgets_FOUND AND KFileMetaData_FOUND)
set(HAVE_BALOO TRUE)
add_definitions(
-DTRANSLATION_DOMAIN=\"dolphin\"
-DQT_USE_FAST_CONCATENATION
-DQT_USE_FAST_OPERATOR_PLUS
)
remove_definitions(
-DQT_NO_CAST_FROM_BYTEARRAY
-DQT_NO_URL_CAST_FROM_STRING
-DQT_NO_SIGNALS_SLOTS_KEYWORDS
-DQT_NO_CAST_FROM_ASCII
-DQT_NO_CAST_TO_ASCII
)
if(X11_Xrender_FOUND)
set(HAVE_XRENDER TRUE)
endif()
configure_file(config-baloo.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-baloo.h )
configure_file(config-X11.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-X11.h)
macro_bool_to_01(X11_Xrender_FOUND HAVE_XRENDER)
configure_file(config-X11.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-X11.h )
##########################################
include_directories( ${KACTIVITIES_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR} )
set(dolphinvcs_LIB_SRCS
views/versioncontrol/kversioncontrolplugin.cpp
)
if(HAVE_BALOO)
include_directories(${BALOO_INCLUDE_DIR} ${BALOO_WIDGETS_INCLUDE_DIR} ${KFILEMETADATA_INCLUDE_DIR})
endif()
add_library(dolphinvcs ${dolphinvcs_LIB_SRCS})
add_subdirectory(tests)
generate_export_header(dolphinvcs BASE_NAME dolphin)
target_link_libraries(
dolphinvcs PUBLIC
Qt5::Widgets
KF5::KIOCore
)
set_target_properties(dolphinvcs PROPERTIES
VERSION ${DOLPHINVCS_VERSION_STRING}
SOVERSION ${DOLPHINVCS_SOVERSION}
EXPORT_NAME DolphinVcs
)
ecm_generate_headers(dolphinvcs_LIB_HEADERS
HEADER_NAMES
KVersionControlPlugin
RELATIVE "views/versioncontrol"
REQUIRED_HEADERS dolphinvcs_LIB_HEADERS
)
install(TARGETS dolphinvcs EXPORT DolphinVcsTargets ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
install(FILES views/versioncontrol/fileviewversioncontrolplugin.desktop DESTINATION ${KDE_INSTALL_KSERVICETYPES5DIR})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/dolphin_export.h DESTINATION ${KDE_INSTALL_INCLUDEDIR} COMPONENT Devel)
install(FILES ${dolphinvcs_LIB_HEADERS} DESTINATION "${KDE_INSTALL_INCLUDEDIR}/Dolphin" COMPONENT Devel)
########### next target ###############
@ -95,6 +118,7 @@ set(dolphinprivate_LIB_SRCS
views/zoomlevelinfo.cpp
dolphinremoveaction.cpp
dolphinnewfilemenu.cpp
dolphindebug.cpp
)
if(HAVE_BALOO)
@ -104,7 +128,7 @@ if(HAVE_BALOO)
)
endif()
kde4_add_kcfg_files(dolphinprivate_LIB_SRCS
kconfig_add_kcfg_files(dolphinprivate_LIB_SRCS GENERATE_MOC
settings/dolphin_compactmodesettings.kcfgc
settings/dolphin_directoryviewpropertysettings.kcfgc
settings/dolphin_detailsmodesettings.kcfgc
@ -113,21 +137,35 @@ kde4_add_kcfg_files(dolphinprivate_LIB_SRCS
settings/dolphin_versioncontrolsettings.kcfgc
)
kde4_add_library(dolphinprivate SHARED ${dolphinprivate_LIB_SRCS})
add_library(dolphinprivate ${dolphinprivate_LIB_SRCS})
target_link_libraries(
dolphinprivate
${KDE4_KFILE_LIBS}
konq
${KDE4_KNEWSTUFF3_LIBS}
dolphinprivate PUBLIC
dolphinvcs
Qt5::Gui
KF5::I18n
KF5::IconThemes
KF5::KIOCore
KF5::KIOWidgets
KF5::KIOFileWidgets
KF5::Completion
KF5::TextEditor
KF5::WindowSystem
KF5::ConfigCore
KF5::NewStuff
)
if(HAVE_BALOO)
target_link_libraries(
dolphinprivate
${BALOO_LIBRARIES}
${BALOO_WIDGETS_LIBRARY}
${KFILEMETADATA_LIBRARY}
dolphinprivate PUBLIC
KF5::FileMetaData
KF5::Baloo
KF5::BalooWidgets
)
else()
target_link_libraries(
dolphinprivate PUBLIC
KF5::KDELibs4Support # for KFileMetaDataWidget
)
endif()
@ -135,38 +173,35 @@ if(X11_Xrender_FOUND)
target_link_libraries(dolphinprivate ${X11_Xrender_LIB})
endif(X11_Xrender_FOUND)
target_link_libraries(dolphinprivate ${KDE4_PLASMA_LIBS})
set_target_properties(dolphinprivate PROPERTIES
VERSION ${DOLPHINPRIVATE_VERSION_STRING}
SOVERSION ${DOLPHINPRIVATE_SOVERSION}
)
set_target_properties(dolphinprivate PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION} )
install(TARGETS dolphinprivate ${INSTALL_TARGETS_DEFAULT_ARGS})
install(TARGETS dolphinprivate ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
##########################################
set(dolphinpart_SRCS
dolphinpart.cpp
dolphinpart_ext.cpp
dolphindebug.cpp
)
# Add dolphinpart_ext.cpp conditionally, only with KDE > 4.9.1.
if (${KDE_VERSION} VERSION_GREATER "4.9.1")
set(dolphinpart_SRCS
${dolphinpart_SRCS}
dolphinpart_ext.cpp)
endif (${KDE_VERSION} VERSION_GREATER "4.9.1")
add_library(dolphinpart MODULE ${dolphinpart_SRCS})
kde4_add_plugin(dolphinpart ${dolphinpart_SRCS})
target_link_libraries(dolphinpart dolphinprivate konq ${KDE4_KPARTS_LIBS} ${KDE4_KFILE_LIBS})
target_link_libraries(dolphinpart
dolphinprivate
)
install(TARGETS dolphinpart DESTINATION ${PLUGIN_INSTALL_DIR})
install(FILES dolphinpart.rc DESTINATION ${DATA_INSTALL_DIR}/dolphinpart)
install(FILES dolphinpart.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
install(FILES views/versioncontrol/fileviewversioncontrolplugin.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR})
install(FILES dolphinpart.rc DESTINATION ${CMAKE_INSTALL_KXMLGUI5DIR}/dolphinpart)
install(FILES dolphinpart.desktop DESTINATION ${SERVICES_INSTALL_DIR})
##########################################
set(dolphin_SRCS
dolphinapplication.cpp
dolphindockwidget.cpp
dolphinmainwindow.cpp
dolphinviewcontainer.cpp
@ -217,12 +252,14 @@ set(dolphin_SRCS
statusbar/dolphinstatusbar.cpp
statusbar/mountpointobserver.cpp
statusbar/mountpointobservercache.cpp
statusbar/spaceinfotoolsmenu.cpp
statusbar/spaceinfoobserver.cpp
statusbar/statusbarspaceinfo.cpp
views/zoomlevelinfo.cpp
dolphindebug.cpp
)
kde4_add_kcfg_files(dolphin_SRCS
kconfig_add_kcfg_files(dolphin_SRCS GENERATE_MOC
panels/folders/dolphin_folderspanelsettings.kcfgc
panels/information/dolphin_informationpanelsettings.kcfgc
panels/places/dolphin_placespanelsettings.kcfgc
@ -236,40 +273,36 @@ kde4_add_kcfg_files(dolphin_SRCS
if(NOT WIN32)
set(dolphin_SRCS ${dolphin_SRCS} panels/terminal/terminalpanel.cpp)
endif(NOT WIN32)
endif()
kde4_add_app_icon(dolphin_SRCS "${KDE4_ICON_INSTALL_DIR}/oxygen/*/apps/system-file-manager.png")
# TODO Does anything replace kde4_add_app_icon ?
#kde4_add_app_icon(dolphin_SRCS "${KDE4_ICON_INSTALL_DIR}/oxygen/*/apps/system-file-manager.png")
kde4_add_kdeinit_executable(dolphin ${dolphin_SRCS})
kf5_add_kdeinit_executable(dolphin ${dolphin_SRCS})
target_include_directories(kdeinit_dolphin PRIVATE ${PHONON_INCLUDES})
target_link_libraries(kdeinit_dolphin
${KDE4_KDEPRINT_LIBS}
${KDE4_KFILE_LIBS}
${KDE4_KPARTS_LIBS}
${KDE4_KCMUTILS_LIBRARY}
konq
dolphinprivate
knewstuff3
${KDE4_SOLID_LIBS}
${KDE4_PHONON_LIBS}
KF5::Parts
KF5::KCMUtils
KF5::Solid
KF5::CoreAddons
KF5::DBusAddons
KF5::Bookmarks
KF5::Notifications
Phonon::phonon4qt5
)
if(HAVE_BALOO)
target_link_libraries(kdeinit_dolphin
${BALOO_LIBRARIES}
${BALOO_WIDGETS_LIBRARY}
if (KF5Activities_FOUND)
target_link_libraries(
kdeinit_dolphin
KF5::Activities
)
endif()
if (KActivities_FOUND)
target_link_libraries(
kdeinit_dolphin
${KACTIVITIES_LIBRARY}
)
endif (KActivities_FOUND)
install(TARGETS kdeinit_dolphin ${INSTALL_TARGETS_DEFAULT_ARGS})
install(TARGETS dolphin ${INSTALL_TARGETS_DEFAULT_ARGS})
install(TARGETS kdeinit_dolphin ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
install(TARGETS dolphin ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
##########################################
@ -302,7 +335,7 @@ set(kcm_dolphingeneral_PART_SRCS
settings/serviceitemdelegate.cpp
settings/servicemodel.cpp)
kde4_add_kcfg_files(kcm_dolphinviewmodes_PART_SRCS
kconfig_add_kcfg_files(kcm_dolphinviewmodes_PART_SRCS
settings/dolphin_compactmodesettings.kcfgc
settings/dolphin_directoryviewpropertysettings.kcfgc
settings/dolphin_detailsmodesettings.kcfgc
@ -311,42 +344,34 @@ kde4_add_kcfg_files(kcm_dolphinviewmodes_PART_SRCS
settings/dolphin_versioncontrolsettings.kcfgc
)
kde4_add_kcfg_files(kcm_dolphinnavigation_PART_SRCS
kconfig_add_kcfg_files(kcm_dolphinnavigation_PART_SRCS
settings/dolphin_generalsettings.kcfgc)
kde4_add_kcfg_files(kcm_dolphinservices_PART_SRCS
kconfig_add_kcfg_files(kcm_dolphinservices_PART_SRCS
settings/dolphin_generalsettings.kcfgc
settings/dolphin_versioncontrolsettings.kcfgc)
kde4_add_kcfg_files(kcm_dolphingeneral_PART_SRCS
kconfig_add_kcfg_files(kcm_dolphingeneral_PART_SRCS
settings/dolphin_generalsettings.kcfgc)
kde4_add_plugin(kcm_dolphinviewmodes ${kcm_dolphinviewmodes_PART_SRCS})
kde4_add_plugin(kcm_dolphinnavigation ${kcm_dolphinnavigation_PART_SRCS})
kde4_add_plugin(kcm_dolphinservices ${kcm_dolphinservices_PART_SRCS})
kde4_add_plugin(kcm_dolphingeneral ${kcm_dolphingeneral_PART_SRCS})
add_library(kcm_dolphinviewmodes MODULE ${kcm_dolphinviewmodes_PART_SRCS})
add_library(kcm_dolphinnavigation MODULE ${kcm_dolphinnavigation_PART_SRCS})
add_library(kcm_dolphinservices MODULE ${kcm_dolphinservices_PART_SRCS})
add_library(kcm_dolphingeneral MODULE ${kcm_dolphingeneral_PART_SRCS})
target_link_libraries(kcm_dolphinviewmodes ${KDE4_KDEUI_LIBS} ${KDE4_KFILE_LIBS} dolphinprivate)
target_link_libraries(kcm_dolphinnavigation ${KDE4_KDEUI_LIBS} ${KDE4_KFILE_LIBS} dolphinprivate)
target_link_libraries(kcm_dolphinservices ${KDE4_KDEUI_LIBS} ${KDE4_KFILE_LIBS} ${KDE4_KIO_LIBS} ${KDE4_KNEWSTUFF3_LIBRARY} dolphinprivate)
target_link_libraries(kcm_dolphingeneral ${KDE4_KDEUI_LIBS} ${KDE4_KFILE_LIBS} ${KDE4_KIO_LIBS} dolphinprivate)
target_link_libraries(kcm_dolphinviewmodes dolphinprivate)
target_link_libraries(kcm_dolphinnavigation dolphinprivate)
target_link_libraries(kcm_dolphinservices dolphinprivate)
target_link_libraries(kcm_dolphingeneral dolphinprivate)
install(TARGETS kcm_dolphinviewmodes DESTINATION ${PLUGIN_INSTALL_DIR} )
install(TARGETS kcm_dolphinnavigation DESTINATION ${PLUGIN_INSTALL_DIR} )
install(TARGETS kcm_dolphinservices DESTINATION ${PLUGIN_INSTALL_DIR} )
install(TARGETS kcm_dolphingeneral DESTINATION ${PLUGIN_INSTALL_DIR} )
#########################################
set(kio_search_PART_SRCS
search/filenamesearchprotocol.cpp)
kde4_add_plugin(kio_filenamesearch ${kio_search_PART_SRCS})
target_link_libraries(kio_filenamesearch ${KDE4_KIO_LIBS})
install(TARGETS kio_filenamesearch DESTINATION ${PLUGIN_INSTALL_DIR})
########### install files ###############
install( PROGRAMS dolphin.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} )
install( PROGRAMS org.kde.dolphin.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} )
install( FILES settings/dolphin_directoryviewpropertysettings.kcfg
settings/dolphin_generalsettings.kcfg
settings/dolphin_compactmodesettings.kcfg
@ -354,9 +379,8 @@ install( FILES settings/dolphin_directoryviewpropertysettings.kcfg
settings/dolphin_detailsmodesettings.kcfg
settings/dolphin_versioncontrolsettings.kcfg
DESTINATION ${KCFG_INSTALL_DIR} )
install( FILES dolphinui.rc DESTINATION ${DATA_INSTALL_DIR}/dolphin )
install( FILES dolphinui.rc DESTINATION ${CMAKE_INSTALL_KXMLGUI5DIR}/dolphin )
install( FILES dolphin.appdata.xml DESTINATION ${SHARE_INSTALL_PREFIX}/appdata )
install( FILES search/filenamesearch.protocol DESTINATION ${SERVICES_INSTALL_DIR} )
install( FILES settings/kcm/kcmdolphinviewmodes.desktop DESTINATION
${SERVICES_INSTALL_DIR} )
install( FILES settings/kcm/kcmdolphinnavigation.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
@ -366,3 +390,7 @@ install( FILES settings/services/servicemenu.knsrc DESTINATION ${CONFIG_INSTALL_
install( PROGRAMS settings/services/servicemenuinstallation DESTINATION ${BIN_INSTALL_DIR} )
install( PROGRAMS settings/services/servicemenudeinstallation DESTINATION ${BIN_INSTALL_DIR} )
if(BUILD_TESTING)
find_package(Qt5Test ${QT_MIN_VERSION} CONFIG REQUIRED)
add_subdirectory(tests)
endif()

View File

@ -0,0 +1,4 @@
/* Define to 1 if you have the KActivities library. */
#cmakedefine KF5Activities_FOUND 1

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<component type="desktop">
<id>dolphin.desktop</id>
<id>org.kde.dolphin.desktop</id>
<metadata_license>CC0-1.0</metadata_license>
<project_license>GPL-2.0+</project_license>
<name>Dolphin</name>

View File

@ -1,106 +0,0 @@
/***************************************************************************
* Copyright (C) 2006-2011 by Peter Penz <peter.penz19@gmail.com> *
* Copyright (C) 2006 by Holger 'zecke' Freyther <freyther@kde.org> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program 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 General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#include "dolphinapplication.h"
#include "dolphinmainwindow.h"
#include "dolphin_generalsettings.h"
#include <KCmdLineArgs>
#include <KDebug>
#include <KRun>
#include <KUrl>
DolphinApplication::DolphinApplication() :
m_mainWindow(0)
{
KGlobal::locale()->insertCatalog("libkonq"); // Needed for applications using libkonq
m_mainWindow = new DolphinMainWindow();
m_mainWindow->setAttribute(Qt::WA_DeleteOnClose);
KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
const int argsCount = args->count();
QList<KUrl> urls;
for (int i = 0; i < argsCount; ++i) {
const KUrl url = args->url(i);
if (url.isValid()) {
urls.append(url);
}
}
bool resetSplitSettings = false;
if (args->isSet("split") && !GeneralSettings::splitView()) {
// Dolphin should be opened with a split view although this is not
// set in the GeneralSettings. Temporary adjust the setting until
// all passed URLs have been opened.
GeneralSettings::setSplitView(true);
resetSplitSettings = true;
// We need 2 URLs to open Dolphin in split view mode
if (urls.isEmpty()) { // No URL given - Open home URL in all two views
urls.append(GeneralSettings::homeUrl());
urls.append(GeneralSettings::homeUrl());
} else if (urls.length() == 1) { // Only 1 URL given - Open given URL in all two views
urls.append(urls.at(0));
}
}
if (!urls.isEmpty()) {
if (args->isSet("select")) {
m_mainWindow->openFiles(urls);
} else {
m_mainWindow->openDirectories(urls);
}
} else {
const KUrl homeUrl(GeneralSettings::homeUrl());
m_mainWindow->openNewActivatedTab(homeUrl);
}
if (resetSplitSettings) {
GeneralSettings::setSplitView(false);
}
args->clear();
m_mainWindow->show();
}
DolphinApplication::~DolphinApplication()
{
}
DolphinApplication* DolphinApplication::app()
{
return qobject_cast<DolphinApplication*>(qApp);
}
void DolphinApplication::restoreSession()
{
const QString className = KXmlGuiWindow::classNameOfToplevel(1);
if (className == QLatin1String("DolphinMainWindow")) {
m_mainWindow->restore(1);
} else {
kWarning() << "Unknown class " << className << " in session saved data!";
}
}
#include "dolphinapplication.moc"

View File

@ -27,34 +27,30 @@
#include "dolphinremoveaction.h"
#include <KActionCollection>
#include <KDesktopFile>
#include <kfileitemactionplugin.h>
#include <kabstractfileitemactionplugin.h>
#include <KAbstractFileItemActionPlugin>
#include <KFileItemActions>
#include <KFileItemListProperties>
#include <KGlobal>
#include <KIconLoader>
#include <KIO/NetAccess>
#include <KMenu>
#include <KMenuBar>
#include <KMessageBox>
#include <KIO/RestoreJob>
#include <KIO/EmptyTrashJob>
#include <KIO/JobUiDelegate>
#include <KIO/Paste>
#include <KJobWidgets>
#include <KMimeTypeTrader>
#include <KNewFileMenu>
#include <konqmimedata.h>
#include <konq_operations.h>
#include <KService>
#include <KLocale>
#include <KPropertiesDialog>
#include <KLocalizedString>
#include <KStandardAction>
#include <KStandardDirs>
#include <KToolBar>
#include <QApplication>
#include <QClipboard>
#include <QKeyEvent>
#include <QMenuBar>
#include <QMenu>
#include <panels/places/placesitem.h>
#include <panels/places/placesitemmodel.h>
#include <QApplication>
#include <QClipboard>
#include <QDir>
#include "views/dolphinview.h"
#include "views/viewmodecontroller.h"
@ -62,8 +58,8 @@
DolphinContextMenu::DolphinContextMenu(DolphinMainWindow* parent,
const QPoint& pos,
const KFileItem& fileInfo,
const KUrl& baseUrl) :
KMenu(parent),
const QUrl& baseUrl) :
QMenu(parent),
m_pos(pos),
m_mainWindow(parent),
m_fileInfo(fileInfo),
@ -97,7 +93,7 @@ void DolphinContextMenu::setCustomActions(const QList<QAction*>& actions)
DolphinContextMenu::Command DolphinContextMenu::open()
{
// get the context information
if (m_baseUrl.protocol() == QLatin1String("trash")) {
if (m_baseUrl.scheme() == QLatin1String("trash")) {
m_context |= TrashContext;
}
@ -128,7 +124,7 @@ void DolphinContextMenu::keyPressEvent(QKeyEvent *ev)
if (m_removeAction && ev->key() == Qt::Key_Shift) {
m_removeAction->update();
}
KMenu::keyPressEvent(ev);
QMenu::keyPressEvent(ev);
}
void DolphinContextMenu::keyReleaseEvent(QKeyEvent *ev)
@ -136,14 +132,14 @@ void DolphinContextMenu::keyReleaseEvent(QKeyEvent *ev)
if (m_removeAction && ev->key() == Qt::Key_Shift) {
m_removeAction->update();
}
KMenu::keyReleaseEvent(ev);
QMenu::keyReleaseEvent(ev);
}
void DolphinContextMenu::openTrashContextMenu()
{
Q_ASSERT(m_context & TrashContext);
QAction* emptyTrashAction = new QAction(KIcon("trash-empty"), i18nc("@action:inmenu", "Empty Trash"), this);
QAction* emptyTrashAction = new QAction(QIcon::fromTheme("trash-empty"), i18nc("@action:inmenu", "Empty Trash"), this);
KConfig trashConfig("trashrc", KConfig::SimpleConfig);
emptyTrashAction->setEnabled(!trashConfig.group("Status").readEntry("Empty", true));
addAction(emptyTrashAction);
@ -156,7 +152,13 @@ void DolphinContextMenu::openTrashContextMenu()
addShowMenuBarAction();
if (exec(m_pos) == emptyTrashAction) {
KonqOperations::emptyTrash(m_mainWindow);
KIO::JobUiDelegate uiDelegate;
uiDelegate.setWindow(m_mainWindow);
if (uiDelegate.askDeleteConfirmation(QList<QUrl>(), KIO::JobUiDelegate::EmptyTrash, KIO::JobUiDelegate::DefaultConfirmation)) {
KIO::Job* job = KIO::emptyTrash();
KJobWidgets::setWindow(job, m_mainWindow);
job->ui()->setAutoErrorHandlingEnabled(true);
}
}
}
@ -175,12 +177,14 @@ void DolphinContextMenu::openTrashItemContextMenu()
addAction(propertiesAction);
if (exec(m_pos) == restoreAction) {
KUrl::List selectedUrls;
QList<QUrl> selectedUrls;
foreach (const KFileItem &item, m_selectedItems) {
selectedUrls.append(item.url());
}
KonqOperations::restoreTrashedItems(selectedUrls, m_mainWindow);
KIO::RestoreJob *job = KIO::restoreFromTrash(selectedUrls);
KJobWidgets::setWindow(job, m_mainWindow);
job->uiDelegate()->setAutoErrorHandlingEnabled(true);
}
}
@ -188,6 +192,7 @@ void DolphinContextMenu::openItemContextMenu()
{
Q_ASSERT(!m_fileInfo.isNull());
QAction* openParentAction = 0;
QAction* openParentInNewWindowAction = 0;
QAction* openParentInNewTabAction = 0;
QAction* addToPlacesAction = 0;
@ -202,12 +207,12 @@ void DolphinContextMenu::openItemContextMenu()
newFileMenu->checkUpToDate();
newFileMenu->setPopupFiles(m_fileInfo.url());
newFileMenu->setEnabled(selectedItemsProps.supportsWriting());
connect(newFileMenu, SIGNAL(fileCreated(KUrl)), newFileMenu, SLOT(deleteLater()));
connect(newFileMenu, SIGNAL(directoryCreated(KUrl)), newFileMenu, SLOT(deleteLater()));
connect(newFileMenu, &DolphinNewFileMenu::fileCreated, newFileMenu, &DolphinNewFileMenu::deleteLater);
connect(newFileMenu, &DolphinNewFileMenu::directoryCreated, newFileMenu, &DolphinNewFileMenu::deleteLater);
KMenu* menu = newFileMenu->menu();
QMenu* menu = newFileMenu->menu();
menu->setTitle(i18nc("@title:menu Create new folder, file, link, etc.", "Create New"));
menu->setIcon(KIcon("document-new"));
menu->setIcon(QIcon::fromTheme("document-new"));
addMenu(menu);
addSeparator();
@ -217,20 +222,26 @@ void DolphinContextMenu::openItemContextMenu()
// insert 'Add to Places' entry
if (!placeExists(m_fileInfo.url())) {
addToPlacesAction = addAction(KIcon("bookmark-new"),
addToPlacesAction = addAction(QIcon::fromTheme("bookmark-new"),
i18nc("@action:inmenu Add selected folder to places",
"Add to Places"));
}
addSeparator();
} else if (m_baseUrl.protocol().contains("search")) {
openParentInNewWindowAction = new QAction(KIcon("window-new"),
} else if (m_baseUrl.scheme().contains("search") || m_baseUrl.scheme().contains("timeline")) {
openParentAction = new QAction(QIcon::fromTheme("document-open-folder"),
i18nc("@action:inmenu",
"Open Path"),
this);
addAction(openParentAction);
openParentInNewWindowAction = new QAction(QIcon::fromTheme("window-new"),
i18nc("@action:inmenu",
"Open Path in New Window"),
this);
addAction(openParentInNewWindowAction);
openParentInNewTabAction = new QAction(KIcon("tab-new"),
openParentInNewTabAction = new QAction(QIcon::fromTheme("tab-new"),
i18nc("@action:inmenu",
"Open Path in New Tab"),
this);
@ -247,7 +258,7 @@ void DolphinContextMenu::openItemContextMenu()
} else {
bool selectionHasOnlyDirs = true;
foreach (const KFileItem& item, m_selectedItems) {
const KUrl& url = DolphinView::openItemAsFolderUrl(item);
const QUrl& url = DolphinView::openItemAsFolderUrl(item);
if (url.isEmpty()) {
selectionHasOnlyDirs = false;
break;
@ -275,8 +286,9 @@ void DolphinContextMenu::openItemContextMenu()
// insert 'Copy To' and 'Move To' sub menus
if (GeneralSettings::showCopyMoveMenu()) {
m_copyToMenu.setItems(m_selectedItems);
m_copyToMenu.setUrls(m_selectedItems.urlList());
m_copyToMenu.setReadOnly(!selectedItemsProps.supportsWriting());
m_copyToMenu.setAutoErrorHandlingEnabled(true);
m_copyToMenu.addActionsTo(this);
}
@ -287,13 +299,15 @@ void DolphinContextMenu::openItemContextMenu()
QAction* activatedAction = exec(m_pos);
if (activatedAction) {
if (activatedAction == addToPlacesAction) {
const KUrl selectedUrl(m_fileInfo.url());
const QUrl selectedUrl(m_fileInfo.url());
if (selectedUrl.isValid()) {
PlacesItemModel model;
const QString text = selectedUrl.fileName();
PlacesItem* item = model.createPlacesItem(text, selectedUrl);
model.appendItemToGroup(item);
}
} else if (activatedAction == openParentAction) {
m_command = OpenParentFolder;
} else if (activatedAction == openParentInNewWindowAction) {
m_command = OpenParentFolderInNewWindow;
} else if (activatedAction == openParentInNewTabAction) {
@ -321,7 +335,7 @@ void DolphinContextMenu::openViewportContextMenu()
// Insert 'Add to Places' entry if exactly one item is selected
QAction* addToPlacesAction = 0;
if (!placeExists(m_mainWindow->activeViewContainer()->url())) {
addToPlacesAction = addAction(KIcon("bookmark-new"),
addToPlacesAction = addAction(QIcon::fromTheme("bookmark-new"),
i18nc("@action:inmenu Add current folder to places", "Add to Places"));
}
@ -377,7 +391,7 @@ void DolphinContextMenu::insertDefaultItemActions(const KFileItemListProperties&
// Insert 'Move to Trash' and/or 'Delete'
if (properties.supportsDeleting()) {
const bool showDeleteAction = (KGlobal::config()->group("KDE").readEntry("ShowDeleteCommand", false) ||
const bool showDeleteAction = (KSharedConfig::openConfig()->group("KDE").readEntry("ShowDeleteCommand", false) ||
!properties.isLocal());
const bool showMoveToTrashAction = (properties.isLocal() &&
properties.supportsMoving());
@ -409,14 +423,14 @@ void DolphinContextMenu::addShowMenuBarAction()
}
}
bool DolphinContextMenu::placeExists(const KUrl& url) const
bool DolphinContextMenu::placeExists(const QUrl& url) const
{
PlacesItemModel model;
const int count = model.count();
for (int i = 0; i < count; ++i) {
const KUrl placeUrl = model.placesItem(i)->url();
if (placeUrl.equals(url, KUrl::CompareWithoutTrailingSlash)) {
const QUrl placeUrl = model.placesItem(i)->url();
if (placeUrl.matches(url, QUrl::StripTrailingSlash)) {
return true;
}
}
@ -429,10 +443,12 @@ QAction* DolphinContextMenu::createPasteAction()
QAction* action = 0;
const bool isDir = !m_fileInfo.isNull() && m_fileInfo.isDir();
if (isDir && (m_selectedItems.count() == 1)) {
const QPair<bool, QString> pasteInfo = KonqOperations::pasteInfo(m_fileInfo.url());
action = new QAction(KIcon("edit-paste"), i18nc("@action:inmenu", "Paste Into Folder"), this);
action->setEnabled(pasteInfo.first);
connect(action, SIGNAL(triggered()), m_mainWindow, SLOT(pasteIntoFolder()));
const QMimeData *mimeData = QApplication::clipboard()->mimeData();
bool canPaste;
const QString text = KIO::pasteActionText(mimeData, &canPaste, m_fileInfo);
action = new QAction(QIcon::fromTheme("edit-paste"), text, this);
action->setEnabled(canPaste);
connect(action, &QAction::triggered, m_mainWindow, &DolphinMainWindow::pasteIntoFolder);
} else {
action = m_mainWindow->actionCollection()->action(KStandardAction::name(KStandardAction::Paste));
}
@ -451,7 +467,7 @@ KFileItemListProperties& DolphinContextMenu::selectedItemsProperties() const
KFileItem DolphinContextMenu::baseFileItem()
{
if (!m_baseFileItem) {
m_baseFileItem = new KFileItem(KFileItem::Unknown, KFileItem::Unknown, m_baseUrl);
m_baseFileItem = new KFileItem(m_baseUrl);
}
return *m_baseFileItem;
}
@ -489,19 +505,12 @@ void DolphinContextMenu::addFileItemPluginActions()
const KConfig config("kservicemenurc", KConfig::NoGlobals);
const KConfigGroup showGroup = config.group("Show");
foreach (const KSharedPtr<KService>& service, pluginServices) {
foreach (const KService::Ptr& service, pluginServices) {
if (!showGroup.readEntry(service->desktopEntryName(), true)) {
// The plugin has been disabled
continue;
}
// Old API (kdelibs-4.6.0 only)
KFileItemActionPlugin* plugin = service->createInstance<KFileItemActionPlugin>();
if (plugin) {
plugin->setParent(this);
addActions(plugin->actions(props, m_mainWindow));
}
// New API (kdelibs >= 4.6.1)
KAbstractFileItemActionPlugin* abstractPlugin = service->createInstance<KAbstractFileItemActionPlugin>();
if (abstractPlugin) {
abstractPlugin->setParent(this);
@ -515,18 +524,13 @@ void DolphinContextMenu::addVersionControlPluginActions()
const DolphinView* view = m_mainWindow->activeViewContainer()->view();
const QList<QAction*> versionControlActions = view->versionControlActions(m_selectedItems);
if (!versionControlActions.isEmpty()) {
foreach (QAction* action, versionControlActions) {
addAction(action);
}
addActions(versionControlActions);
addSeparator();
}
}
void DolphinContextMenu::addCustomActions()
{
foreach (QAction* action, m_customActions) {
addAction(action);
}
addActions(m_customActions);
}
#include "dolphincontextmenu.moc"

View File

@ -21,16 +21,12 @@
#define DOLPHINCONTEXTMENU_H
#include <KFileItem>
#include <KService>
#include <KUrl>
#include <konq_copytomenu.h>
#include <KMenu>
#include <QUrl>
#include <KFileCopyToMenu>
#include <QMenu>
#include <QObject>
#include <QVector>
#include <QScopedPointer>
class QAction;
class DolphinMainWindow;
@ -50,7 +46,7 @@ class DolphinRemoveAction;
* - 'Actions': Contains all actions which can be applied to the
* given item.
*/
class DolphinContextMenu : public KMenu
class DolphinContextMenu : public QMenu
{
Q_OBJECT
@ -58,6 +54,7 @@ public:
enum Command
{
None,
OpenParentFolder,
OpenParentFolderInNewWindow,
OpenParentFolderInNewTab
};
@ -75,7 +72,7 @@ public:
DolphinContextMenu(DolphinMainWindow* parent,
const QPoint& pos,
const KFileItem& fileInfo,
const KUrl& baseUrl);
const QUrl& baseUrl);
virtual ~DolphinContextMenu();
@ -92,8 +89,8 @@ public:
Command open();
protected:
virtual void keyPressEvent(QKeyEvent *ev);
virtual void keyReleaseEvent(QKeyEvent *ev);
virtual void keyPressEvent(QKeyEvent *ev) Q_DECL_OVERRIDE;
virtual void keyReleaseEvent(QKeyEvent *ev) Q_DECL_OVERRIDE;
private:
void openTrashContextMenu();
@ -109,7 +106,7 @@ private:
*/
void addShowMenuBarAction();
bool placeExists(const KUrl& url) const;
bool placeExists(const QUrl& url) const;
QAction* createPasteAction();
@ -165,14 +162,14 @@ private:
KFileItem m_fileInfo;
KUrl m_baseUrl;
QUrl m_baseUrl;
KFileItem* m_baseFileItem; /// File item for m_baseUrl
KFileItemList m_selectedItems;
mutable KFileItemListProperties* m_selectedItemsProperties;
int m_context;
KonqCopyToMenu m_copyToMenu;
KFileCopyToMenu m_copyToMenu;
QList<QAction*> m_customActions;
Command m_command;

View File

@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (C) 2010 by Peter Penz <peter.penz19@gmail.com> *
* Copyright (C) 2015 by Emmanuel Pescosta <emmanuelpescosta099@gmail.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@ -17,44 +17,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#ifndef FILENAMESEARCHPROTOCOL_H
#define FILENAMESEARCHPROTOCOL_H
#include "dolphindebug.h"
#include <kio/slavebase.h>
class KFileItem;
class KUrl;
class QRegExp;
/**
* @brief Lists files where the filename matches do a given query.
*
* The query is defined as part of the "search" query item of the URL.
* The directory where the searching is started is defined in the "url" query
* item. If the query item "checkContent" is set to "yes", all files with
* a text MIME type will be checked for the content.
*/
class FileNameSearchProtocol : public KIO::SlaveBase {
public:
FileNameSearchProtocol(const QByteArray& pool, const QByteArray& app);
virtual ~FileNameSearchProtocol();
virtual void listDir(const KUrl& url);
private:
void searchDirectory(const KUrl& directory);
/**
* @return True, if the pattern m_searchPattern is part of
* the file \a fileName.
*/
bool contentContainsPattern(const KUrl& fileName) const;
void cleanup();
bool m_checkContent;
QRegExp* m_regExp;
QSet<QString> m_iteratedDirs;
};
#endif
Q_LOGGING_CATEGORY(DolphinDebug, "org.kde.dolphin")

View File

@ -1,6 +1,5 @@
/***************************************************************************
* Copyright (C) 2006-2011 by Peter Penz <peter.penz19@gmail.com> *
* Copyright (C) 2006 by Holger 'zecke' Freyther <freyther@kde.org> *
* Copyright (C) 2015 by Emmanuel Pescosta <emmanuelpescosta099@gmail.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@ -18,27 +17,11 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#ifndef DOLPHIN_APPLICATION_H
#define DOLPHIN_APPLICATION_H
#ifndef DOLPHIN_DEBUG_H
#define DOLPHIN_DEBUG_H
#include <KApplication>
#include <QLoggingCategory>
class DolphinMainWindow;
Q_DECLARE_LOGGING_CATEGORY(DolphinDebug)
class DolphinApplication : public KApplication
{
Q_OBJECT
public:
DolphinApplication();
virtual ~DolphinApplication();
static DolphinApplication* app();
void restoreSession();
private:
DolphinMainWindow* m_mainWindow;
};
#endif
#endif // DOLPHIN_DEBUG_H

View File

@ -91,4 +91,3 @@ bool DolphinDockWidget::isLocked() const
return m_locked;
}
#include "dolphindockwidget.moc"

File diff suppressed because it is too large Load Diff

View File

@ -24,30 +24,28 @@
#include <config-baloo.h>
#include <KFileItemDelegate>
#include <kio/fileundomanager.h>
#include <ksortablelist.h>
#include <kxmlguiwindow.h>
#include <KIcon>
#include <QIcon>
#include <QUrl>
#include <QList>
#include <QWeakPointer>
#include <QPointer>
typedef KIO::FileUndoManager::CommandType CommandType;
class DolphinViewActionHandler;
class DolphinApplication;
class DolphinSettingsDialog;
class DolphinViewContainer;
class DolphinRemoteEncoding;
class DolphinTabWidget;
class KAction;
class KFileItem;
class KFileItemList;
class KJob;
class KNewFileMenu;
class KUrl;
class QToolButton;
class QIcon;
/**
* @short Main window for Dolphin.
@ -59,7 +57,6 @@ class DolphinMainWindow: public KXmlGuiWindow
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.kde.dolphin.MainWindow")
Q_PROPERTY(int id READ getId SCRIPTABLE true)
friend class DolphinApplication;
public:
DolphinMainWindow();
@ -77,14 +74,14 @@ public:
* Opens each directory in \p dirs in a separate tab. If the "split view"
* option is enabled, 2 directories are collected within one tab.
*/
void openDirectories(const QList<KUrl>& dirs);
void openDirectories(const QList<QUrl> &dirs);
/**
* Opens the directory which contains the files \p files
* and selects all files (implements the --select option
* of Dolphin).
*/
void openFiles(const QList<KUrl>& files);
void openFiles(const QList<QUrl>& files);
/**
* Returns the 'Create New...' sub menu which also can be shared
@ -110,18 +107,23 @@ public slots:
* Inform all affected dolphin components (panels, views) of an URL
* change.
*/
void changeUrl(const KUrl& url);
void changeUrl(const QUrl& url);
/**
* The current directory of the Terminal Panel has changed, probably because
* the user entered a 'cd' command. This slot calls changeUrl(url) and makes
* sure that the panel keeps the keyboard focus.
*/
void slotTerminalDirectoryChanged(const KUrl& url);
void slotTerminalDirectoryChanged(const QUrl& url);
/** Stores all settings and quits Dolphin. */
void quit();
/**
* Opens a new tab showing the URL \a url and activates the tab.
*/
void openNewActivatedTab(const QUrl& url);
signals:
/**
* Is sent if the selection of the currently active view has
@ -133,7 +135,7 @@ signals:
* Is sent if the url of the currently active view has
* been changed.
*/
void urlChanged(const KUrl& url);
void urlChanged(const QUrl& url);
/**
* Is emitted if information of an item is requested to be shown e. g. in the panel.
@ -148,16 +150,16 @@ signals:
protected:
/** @see QWidget::showEvent() */
virtual void showEvent(QShowEvent* event);
virtual void showEvent(QShowEvent* event) Q_DECL_OVERRIDE;
/** @see QMainWindow::closeEvent() */
virtual void closeEvent(QCloseEvent* event);
virtual void closeEvent(QCloseEvent* event) Q_DECL_OVERRIDE;
/** @see KMainWindow::saveProperties() */
virtual void saveProperties(KConfigGroup& group);
virtual void saveProperties(KConfigGroup& group) Q_DECL_OVERRIDE;
/** @see KMainWindow::readProperties() */
virtual void readProperties(const KConfigGroup& group);
virtual void readProperties(const KConfigGroup& group) Q_DECL_OVERRIDE;
private slots:
/**
@ -313,9 +315,6 @@ private slots:
*/
void slotSelectionChanged(const KFileItemList& selection);
/** Emits the signal requestItemInfo(). */
void slotRequestItemInfo(const KFileItem&);
/**
* Updates the state of the 'Back' and 'Forward' menu
* actions corresponding to the current history.
@ -335,16 +334,9 @@ private slots:
void openNewActivatedTab();
/**
* Opens a new tab in the background showing the URL \a primaryUrl and the
* optional URL \a secondaryUrl.
* Opens a new tab in the background showing the URL \a url.
*/
void openNewTab(const KUrl& primaryUrl, const KUrl& secondaryUrl = KUrl());
/**
* Opens a new tab showing the URL \a primaryUrl and the optional URL
* \a secondaryUrl and activates the tab.
*/
void openNewActivatedTab(const KUrl& primaryUrl, const KUrl& secondaryUrl = KUrl());
void openNewTab(const QUrl& url);
/**
* Opens the selected folder in a new tab.
@ -366,7 +358,7 @@ private slots:
* If the URL can be listed, open it in the current view, otherwise
* run it through KRun.
*/
void handleUrl(const KUrl& url);
void handleUrl(const QUrl& url);
/**
* handleUrl() can trigger a stat job to see if the url can actually
@ -391,25 +383,19 @@ private slots:
*/
void openContextMenu(const QPoint& pos,
const KFileItem& item,
const KUrl& url,
const QUrl& url,
const QList<QAction*>& customActions);
void updateControlMenu();
void updateToolBar();
void slotControlButtonDeleted();
/**
* Is called if a panel emits an error-message and shows
* the error-message in the active view-container.
*/
void slotPanelErrorMessage(const QString& error);
/**
* Is called if the user clicked an item in the Places Panel.
* Reloads the view if \a url is the current URL already, and changes the
* current URL otherwise.
*/
void slotPlaceActivated(const KUrl& url);
void slotPlaceActivated(const QUrl& url);
/**
* Is called if the another view has been activated by changing the current
@ -433,7 +419,12 @@ private slots:
* Sets the window caption to url.fileName() if this is non-empty,
* "/" if the URL is "file:///", and url.protocol() otherwise.
*/
void setUrlAsCaption(const KUrl& url);
void setUrlAsCaption(const QUrl& url);
/**
* Is called when the view has finished loading the directory.
*/
void slotDirectoryLoadingCompleted();
private:
void setupActions();
@ -450,7 +441,7 @@ private:
* case if it has not added already to the toolbar.
* @return True if the action has been added to the menu.
*/
bool addActionToMenu(QAction* action, KMenu* menu);
bool addActionToMenu(QAction* action, QMenu* menu);
/**
* Connects the signals from the created DolphinView with
@ -476,7 +467,7 @@ private:
* as the action for toggling the dock visibility is done by Qt which
* is no KAction instance.
*/
void createPanelAction(const KIcon& icon,
void createPanelAction(const QIcon &icon,
const QKeySequence& shortcut,
QAction* dockAction,
const QString& actionName);
@ -492,7 +483,7 @@ private:
public:
UndoUiInterface();
virtual ~UndoUiInterface();
virtual void jobError(KIO::Job* job);
virtual void jobError(KIO::Job* job) Q_DECL_OVERRIDE;
};
KNewFileMenu* m_newFileMenu;
@ -502,7 +493,7 @@ private:
DolphinViewActionHandler* m_actionHandler;
DolphinRemoteEncoding* m_remoteEncoding;
QWeakPointer<DolphinSettingsDialog> m_settingsDialog;
QPointer<DolphinSettingsDialog> m_settingsDialog;
// Members for the toolbar menu that is shown when the menubar is hidden:
QToolButton* m_controlButton;

View File

@ -45,4 +45,3 @@ void DolphinNewFileMenu::slotResult(KJob* job)
}
}
#include "dolphinnewfilemenu.moc"

View File

@ -23,7 +23,7 @@
#include <KNewFileMenu>
#include "libdolphin_export.h"
#include "dolphin_export.h"
class KJob;
@ -35,7 +35,7 @@ class KJob;
* All errors are shown in the status bar of Dolphin
* instead as modal error dialog with an OK button.
*/
class LIBDOLPHINPRIVATE_EXPORT DolphinNewFileMenu : public KNewFileMenu
class DOLPHIN_EXPORT DolphinNewFileMenu : public KNewFileMenu
{
Q_OBJECT
@ -48,7 +48,7 @@ signals:
protected slots:
/** @see KNewFileMenu::slotResult() */
virtual void slotResult(KJob* job);
virtual void slotResult(KJob* job) Q_DECL_OVERRIDE;
};
#endif

View File

@ -21,31 +21,25 @@
#include "dolphinremoveaction.h"
#include <KFileItemListProperties>
#include <konq_operations.h>
#include <KAboutData>
#include <KActionCollection>
#include <KConfigGroup>
#include <KDebug>
#include <KGlobalSettings>
#include "dolphindebug.h"
#include <KIconLoader>
#include <KLocale>
#include <KLocalizedString>
#include <KMessageBox>
#include <KPluginFactory>
#include <KRun>
#include <KToggleAction>
#include <KIO/NetAccess>
#include <KToolInvocation>
#include <kauthorized.h>
#include <KMenu>
#include <KInputDialog>
#include <KProtocolInfo>
#include <QMenu>
#include <kdeversion.h>
#include <KSharedConfig>
#include <KConfigGroup>
#include <KMimeTypeEditor>
#include <KJobWidgets>
#if KDE_IS_VERSION(4, 9, 2)
#include "dolphinpart_ext.h"
#endif
#include "dolphinnewfilemenu.h"
#include "views/dolphinview.h"
#include "views/dolphinviewactionhandler.h"
@ -54,14 +48,16 @@
#include "kitemviews/kfileitemmodel.h"
#include "kitemviews/private/kfileitemmodeldirlister.h"
#include <QStandardPaths>
#include <QActionGroup>
#include <QTextDocument>
#include <QApplication>
#include <QClipboard>
#include <QDir>
#include <QTextDocument>
#include <QKeyEvent>
#include <QInputDialog>
K_PLUGIN_FACTORY(DolphinPartFactory, registerPlugin<DolphinPart>();)
K_EXPORT_PLUGIN(DolphinPartFactory("dolphinpart", "dolphin"))
DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantList& args)
: KParts::ReadOnlyPart(parent)
@ -69,83 +65,81 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantL
,m_removeAction(0)
{
Q_UNUSED(args)
setComponentData(DolphinPartFactory::componentData(), false);
setComponentData(*createAboutData(), false);
m_extension = new DolphinPartBrowserExtension(this);
// make sure that other apps using this part find Dolphin's view-file-columns icons
KIconLoader::global()->addAppDir("dolphin");
m_view = new DolphinView(KUrl(), parentWidget);
m_view = new DolphinView(QUrl(), parentWidget);
m_view->setTabsForFilesEnabled(true);
setWidget(m_view);
connect(&DolphinNewFileMenuObserver::instance(), SIGNAL(errorMessage(QString)),
this, SLOT(slotErrorMessage(QString)));
connect(&DolphinNewFileMenuObserver::instance(), &DolphinNewFileMenuObserver::errorMessage,
this, &DolphinPart::slotErrorMessage);
connect(m_view, SIGNAL(directoryLoadingCompleted()), this, SIGNAL(completed()));
connect(m_view, SIGNAL(directoryLoadingProgress(int)), this, SLOT(updateProgress(int)));
connect(m_view, SIGNAL(errorMessage(QString)), this, SLOT(slotErrorMessage(QString)));
connect(m_view, &DolphinView::directoryLoadingCompleted, this, static_cast<void(DolphinPart::*)()>(&DolphinPart::completed));
connect(m_view, &DolphinView::directoryLoadingProgress, this, &DolphinPart::updateProgress);
connect(m_view, &DolphinView::errorMessage, this, &DolphinPart::slotErrorMessage);
setXMLFile("dolphinpart.rc");
connect(m_view, SIGNAL(infoMessage(QString)),
this, SLOT(slotMessage(QString)));
connect(m_view, SIGNAL(operationCompletedMessage(QString)),
this, SLOT(slotMessage(QString)));
connect(m_view, SIGNAL(errorMessage(QString)),
this, SLOT(slotErrorMessage(QString)));
connect(m_view, SIGNAL(itemActivated(KFileItem)),
this, SLOT(slotItemActivated(KFileItem)));
connect(m_view, SIGNAL(itemsActivated(KFileItemList)),
this, SLOT(slotItemsActivated(KFileItemList)));
connect(m_view, SIGNAL(tabRequested(KUrl)),
this, SLOT(createNewWindow(KUrl)));
connect(m_view, SIGNAL(requestContextMenu(QPoint,KFileItem,KUrl,QList<QAction*>)),
this, SLOT(slotOpenContextMenu(QPoint,KFileItem,KUrl,QList<QAction*>)));
connect(m_view, SIGNAL(selectionChanged(KFileItemList)),
m_extension, SIGNAL(selectionInfo(KFileItemList)));
connect(m_view, SIGNAL(selectionChanged(KFileItemList)),
this, SLOT(slotSelectionChanged(KFileItemList)));
connect(m_view, SIGNAL(requestItemInfo(KFileItem)),
this, SLOT(slotRequestItemInfo(KFileItem)));
connect(m_view, SIGNAL(modeChanged(DolphinView::Mode,DolphinView::Mode)),
this, SIGNAL(viewModeChanged())); // relay signal
connect(m_view, SIGNAL(redirection(KUrl,KUrl)),
this, SLOT(slotDirectoryRedirection(KUrl,KUrl)));
connect(m_view, &DolphinView::infoMessage,
this, &DolphinPart::slotMessage);
connect(m_view, &DolphinView::operationCompletedMessage,
this, &DolphinPart::slotMessage);
connect(m_view, &DolphinView::errorMessage,
this, &DolphinPart::slotErrorMessage);
connect(m_view, &DolphinView::itemActivated,
this, &DolphinPart::slotItemActivated);
connect(m_view, &DolphinView::itemsActivated,
this, &DolphinPart::slotItemsActivated);
connect(m_view, &DolphinView::tabRequested,
this, &DolphinPart::createNewWindow);
connect(m_view, &DolphinView::requestContextMenu,
this, &DolphinPart::slotOpenContextMenu);
connect(m_view, &DolphinView::selectionChanged,
m_extension, static_cast<void(DolphinPartBrowserExtension::*)(const KFileItemList&)>(&DolphinPartBrowserExtension::selectionInfo));
connect(m_view, &DolphinView::selectionChanged,
this, &DolphinPart::slotSelectionChanged);
connect(m_view, &DolphinView::requestItemInfo,
this, &DolphinPart::slotRequestItemInfo);
connect(m_view, &DolphinView::modeChanged,
this, &DolphinPart::viewModeChanged); // relay signal
connect(m_view, &DolphinView::redirection,
this, &DolphinPart::slotDirectoryRedirection);
// Watch for changes that should result in updates to the
// status bar text.
connect(m_view, SIGNAL(itemCountChanged()), this, SLOT(updateStatusBar()));
connect(m_view, SIGNAL(selectionChanged(KFileItemList)), this, SLOT(updateStatusBar()));
connect(m_view, &DolphinView::itemCountChanged, this, &DolphinPart::updateStatusBar);
connect(m_view, &DolphinView::selectionChanged, this, &DolphinPart::updateStatusBar);
m_actionHandler = new DolphinViewActionHandler(actionCollection(), this);
m_actionHandler->setCurrentView(m_view);
connect(m_actionHandler, SIGNAL(createDirectory()), SLOT(createDirectory()));
connect(m_actionHandler, &DolphinViewActionHandler::createDirectory, this, &DolphinPart::createDirectory);
m_remoteEncoding = new DolphinRemoteEncoding(this, m_actionHandler);
connect(this, SIGNAL(aboutToOpenURL()),
m_remoteEncoding, SLOT(slotAboutToOpenUrl()));
connect(this, &DolphinPart::aboutToOpenURL,
m_remoteEncoding, &DolphinRemoteEncoding::slotAboutToOpenUrl);
QClipboard* clipboard = QApplication::clipboard();
connect(clipboard, SIGNAL(dataChanged()),
this, SLOT(updatePasteAction()));
connect(clipboard, &QClipboard::dataChanged,
this, &DolphinPart::updatePasteAction);
// Create file info and listing filter extensions.
// NOTE: Listing filter needs to be instantiated after the creation of the view.
new DolphinPartFileInfoExtension(this);
#if KDE_IS_VERSION(4, 9, 2)
new DolphinPartListingFilterExtension(this);
KDirLister* lister = m_view->m_model->m_dirLister;
if (lister) {
DolphinPartListingNotificationExtension* notifyExt = new DolphinPartListingNotificationExtension(this);
connect(lister, SIGNAL(newItems(KFileItemList)), notifyExt, SLOT(slotNewItems(KFileItemList)));
connect(lister, SIGNAL(itemsDeleted(KFileItemList)), notifyExt, SLOT(slotItemsDeleted(KFileItemList)));
connect(lister, &KDirLister::newItems, notifyExt, &DolphinPartListingNotificationExtension::slotNewItems);
connect(lister, &KDirLister::itemsDeleted, notifyExt, &DolphinPartListingNotificationExtension::slotItemsDeleted);
} else {
kWarning() << "NULL KDirLister object! KParts::ListingNotificationExtension will NOT be supported";
qCWarning(DolphinDebug) << "NULL KDirLister object! KParts::ListingNotificationExtension will NOT be supported";
}
#endif
createActions();
m_actionHandler->updateViewActions();
@ -171,70 +165,70 @@ void DolphinPart::createActions()
m_newFileMenu = new DolphinNewFileMenu(actionCollection(), this);
m_newFileMenu->setParentWidget(widget());
connect(m_newFileMenu->menu(), SIGNAL(aboutToShow()),
this, SLOT(updateNewMenu()));
connect(m_newFileMenu->menu(), &QMenu::aboutToShow,
this, &DolphinPart::updateNewMenu);
KAction *editMimeTypeAction = actionCollection()->addAction( "editMimeType" );
QAction *editMimeTypeAction = actionCollection()->addAction( "editMimeType" );
editMimeTypeAction->setText( i18nc("@action:inmenu Edit", "&Edit File Type..." ) );
connect(editMimeTypeAction, SIGNAL(triggered()), SLOT(slotEditMimeType()));
connect(editMimeTypeAction, &QAction::triggered, this, &DolphinPart::slotEditMimeType);
KAction* selectItemsMatching = actionCollection()->addAction("select_items_matching");
QAction* selectItemsMatching = actionCollection()->addAction("select_items_matching");
selectItemsMatching->setText(i18nc("@action:inmenu Edit", "Select Items Matching..."));
selectItemsMatching->setShortcut(Qt::CTRL | Qt::Key_S);
connect(selectItemsMatching, SIGNAL(triggered()), this, SLOT(slotSelectItemsMatchingPattern()));
actionCollection()->setDefaultShortcut(selectItemsMatching, Qt::CTRL | Qt::Key_S);
connect(selectItemsMatching, &QAction::triggered, this, &DolphinPart::slotSelectItemsMatchingPattern);
KAction* unselectItemsMatching = actionCollection()->addAction("unselect_items_matching");
QAction* unselectItemsMatching = actionCollection()->addAction("unselect_items_matching");
unselectItemsMatching->setText(i18nc("@action:inmenu Edit", "Unselect Items Matching..."));
connect(unselectItemsMatching, SIGNAL(triggered()), this, SLOT(slotUnselectItemsMatchingPattern()));
connect(unselectItemsMatching, &QAction::triggered, this, &DolphinPart::slotUnselectItemsMatchingPattern);
actionCollection()->addAction(KStandardAction::SelectAll, "select_all", m_view, SLOT(selectAll()));
KAction* unselectAll = actionCollection()->addAction("unselect_all");
QAction* unselectAll = actionCollection()->addAction("unselect_all");
unselectAll->setText(i18nc("@action:inmenu Edit", "Unselect All"));
connect(unselectAll, SIGNAL(triggered()), m_view, SLOT(clearSelection()));
connect(unselectAll, &QAction::triggered, m_view, &DolphinView::clearSelection);
KAction* invertSelection = actionCollection()->addAction("invert_selection");
QAction* invertSelection = actionCollection()->addAction("invert_selection");
invertSelection->setText(i18nc("@action:inmenu Edit", "Invert Selection"));
invertSelection->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_A);
connect(invertSelection, SIGNAL(triggered()), m_view, SLOT(invertSelection()));
actionCollection()->setDefaultShortcut(invertSelection, Qt::CTRL | Qt::SHIFT | Qt::Key_A);
connect(invertSelection, &QAction::triggered, m_view, &DolphinView::invertSelection);
// View menu: all done by DolphinViewActionHandler
// Go menu
QActionGroup* goActionGroup = new QActionGroup(this);
connect(goActionGroup, SIGNAL(triggered(QAction*)),
this, SLOT(slotGoTriggered(QAction*)));
connect(goActionGroup, &QActionGroup::triggered,
this, &DolphinPart::slotGoTriggered);
createGoAction("go_applications", "start-here-kde",
i18nc("@action:inmenu Go", "App&lications"), QString("programs:/"),
i18nc("@action:inmenu Go", "App&lications"), QStringLiteral("programs:/"),
goActionGroup);
createGoAction("go_network_folders", "folder-remote",
i18nc("@action:inmenu Go", "&Network Folders"), QString("remote:/"),
i18nc("@action:inmenu Go", "&Network Folders"), QStringLiteral("remote:/"),
goActionGroup);
createGoAction("go_settings", "preferences-system",
i18nc("@action:inmenu Go", "Sett&ings"), QString("settings:/"),
i18nc("@action:inmenu Go", "Sett&ings"), QStringLiteral("settings:/"),
goActionGroup);
createGoAction("go_trash", "user-trash",
i18nc("@action:inmenu Go", "Trash"), QString("trash:/"),
i18nc("@action:inmenu Go", "Trash"), QStringLiteral("trash:/"),
goActionGroup);
createGoAction("go_autostart", "",
i18nc("@action:inmenu Go", "Autostart"), KGlobalSettings::autostartPath(),
i18nc("@action:inmenu Go", "Autostart"), QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + "/autostart",
goActionGroup);
// Tools menu
m_findFileAction = actionCollection()->addAction("find_file");
m_findFileAction->setText(i18nc("@action:inmenu Tools", "Find File..."));
m_findFileAction->setShortcut(Qt::CTRL | Qt::Key_F);
m_findFileAction->setIcon(KIcon("edit-find"));
connect(m_findFileAction, SIGNAL(triggered()), this, SLOT(slotFindFile()));
actionCollection()->setDefaultShortcut(m_findFileAction, Qt::CTRL | Qt::Key_F);
m_findFileAction->setIcon(QIcon::fromTheme("edit-find"));
connect(m_findFileAction, &QAction::triggered, this, &DolphinPart::slotFindFile);
if (KAuthorized::authorizeKAction("shell_access")) {
m_openTerminalAction = actionCollection()->addAction("open_terminal");
m_openTerminalAction->setIcon(KIcon("utilities-terminal"));
m_openTerminalAction->setIcon(QIcon::fromTheme("utilities-terminal"));
m_openTerminalAction->setText(i18nc("@action:inmenu Tools", "Open &Terminal"));
connect(m_openTerminalAction, SIGNAL(triggered()), SLOT(slotOpenTerminal()));
m_openTerminalAction->setShortcut(Qt::Key_F4);
connect(m_openTerminalAction, &QAction::triggered, this, &DolphinPart::slotOpenTerminal);
actionCollection()->setDefaultShortcut(m_openTerminalAction, Qt::Key_F4);
}
}
@ -242,8 +236,8 @@ void DolphinPart::createGoAction(const char* name, const char* iconName,
const QString& text, const QString& url,
QActionGroup* actionGroup)
{
KAction* action = actionCollection()->addAction(name);
action->setIcon(KIcon(iconName));
QAction* action = actionCollection()->addAction(name);
action->setIcon(QIcon::fromTheme(iconName));
action->setText(text);
action->setData(url);
action->setActionGroup(actionGroup);
@ -252,7 +246,7 @@ void DolphinPart::createGoAction(const char* name, const char* iconName,
void DolphinPart::slotGoTriggered(QAction* action)
{
const QString url = action->data().toString();
emit m_extension->openUrlRequest(KUrl(url));
emit m_extension->openUrlRequest(QUrl(url));
}
void DolphinPart::slotSelectionChanged(const KFileItemList& selection)
@ -301,10 +295,10 @@ void DolphinPart::updatePasteAction()
KAboutData* DolphinPart::createAboutData()
{
return new KAboutData("dolphinpart", "dolphin", ki18nc("@title", "Dolphin Part"), "0.1");
return new KAboutData("dolphinpart", i18nc("@title", "Dolphin Part"), "0.1");
}
bool DolphinPart::openUrl(const KUrl& url)
bool DolphinPart::openUrl(const QUrl &url)
{
bool reload = arguments().reload();
// A bit of a workaround so that changing the namefilter works: force reload.
@ -315,11 +309,11 @@ bool DolphinPart::openUrl(const KUrl& url)
return true;
}
setUrl(url); // remember it at the KParts level
KUrl visibleUrl(url);
QUrl visibleUrl(url);
if (!m_nameFilter.isEmpty()) {
visibleUrl.addPath(m_nameFilter);
visibleUrl.setPath(visibleUrl.path() + '/' + m_nameFilter);
}
QString prettyUrl = visibleUrl.pathOrUrl();
QString prettyUrl = visibleUrl.toDisplayString(QUrl::PreferLocalFile);
emit setWindowCaption(prettyUrl);
emit m_extension->setLocationBarUrl(prettyUrl);
emit started(0); // get the wheel to spin
@ -346,7 +340,7 @@ void DolphinPart::slotMessage(const QString& msg)
void DolphinPart::slotErrorMessage(const QString& msg)
{
kDebug() << msg;
qCDebug(DolphinDebug) << msg;
emit canceled(msg);
//KMessageBox::error(m_view, msg);
}
@ -385,7 +379,7 @@ void DolphinPart::slotItemsActivated(const KFileItemList& items)
}
}
void DolphinPart::createNewWindow(const KUrl& url)
void DolphinPart::createNewWindow(const QUrl& url)
{
// TODO: Check issue N176832 for the missing QAIV signal; task 177399 - maybe this code
// should be moved into DolphinPart::slotItemActivated()
@ -394,7 +388,7 @@ void DolphinPart::createNewWindow(const KUrl& url)
void DolphinPart::slotOpenContextMenu(const QPoint& pos,
const KFileItem& _item,
const KUrl&,
const QUrl &,
const QList<QAction*>& customActions)
{
KParts::BrowserExtension::PopupFlags popupFlags = KParts::BrowserExtension::DefaultPopupItems
@ -407,7 +401,7 @@ void DolphinPart::slotOpenContextMenu(const QPoint& pos,
popupFlags |= KParts::BrowserExtension::ShowNavigationItems | KParts::BrowserExtension::ShowUp;
item = m_view->rootItem();
if (item.isNull())
item = KFileItem( S_IFDIR, (mode_t)-1, url() );
item = KFileItem(url());
else
item.setUrl(url()); // ensure we use the view url, not the canonical path (#213799)
}
@ -432,7 +426,7 @@ void DolphinPart::slotOpenContextMenu(const QPoint& pos,
const bool supportsMoving = capabilities.supportsMoving();
if (capabilities.supportsDeleting()) {
const bool showDeleteAction = (KGlobal::config()->group("KDE").readEntry("ShowDeleteCommand", false) ||
const bool showDeleteAction = (KSharedConfig::openConfig()->group("KDE").readEntry("ShowDeleteCommand", false) ||
!item.isLocalFile());
const bool showMoveToTrashAction = capabilities.isLocal() && supportsMoving;
@ -475,12 +469,12 @@ void DolphinPart::slotOpenContextMenu(const QPoint& pos,
actionGroups);
}
void DolphinPart::slotDirectoryRedirection(const KUrl& oldUrl, const KUrl& newUrl)
void DolphinPart::slotDirectoryRedirection(const QUrl &oldUrl, const QUrl &newUrl)
{
//kDebug() << oldUrl << newUrl << "currentUrl=" << url();
if (oldUrl.equals(url(), KUrl::CompareWithoutTrailingSlash /* #207572 */)) {
qCDebug(DolphinDebug) << oldUrl << newUrl << "currentUrl=" << url();
if (oldUrl.matches(url(), QUrl::StripTrailingSlash /* #207572 */)) {
KParts::ReadOnlyPart::setUrl(newUrl);
const QString prettyUrl = newUrl.pathOrUrl();
const QString prettyUrl = newUrl.toDisplayString(QUrl::PreferLocalFile);
emit m_extension->setLocationBarUrl(prettyUrl);
}
}
@ -490,7 +484,7 @@ void DolphinPart::slotEditMimeType()
{
const KFileItemList items = m_view->selectedItems();
if (!items.isEmpty()) {
KonqOperations::editMimeType(items.first().mimetype(), m_view);
KMimeTypeEditor::editMimeType(items.first().mimetype(), m_view);
}
}
@ -511,7 +505,7 @@ void DolphinPart::slotUnselectItemsMatchingPattern()
void DolphinPart::openSelectionDialog(const QString& title, const QString& text, bool selectItems)
{
bool okClicked;
QString pattern = KInputDialog::getText(title, text, "*", &okClicked, m_view);
const QString pattern = QInputDialog::getText(m_view, title, text, QLineEdit::Normal, "*", &okClicked);
if (okClicked && !pattern.isEmpty()) {
QRegExp patternRegExp(pattern, Qt::CaseSensitive, QRegExp::Wildcard);
@ -543,11 +537,14 @@ void DolphinPart::slotOpenTerminal()
{
QString dir(QDir::homePath());
KUrl u(url());
QUrl u(url());
// If the given directory is not local, it can still be the URL of an
// ioslave using UDS_LOCAL_PATH which to be converted first.
u = KIO::NetAccess::mostLocalUrl(u, widget());
KIO::StatJob* statJob = KIO::mostLocalUrl(u);
KJobWidgets::setWindow(statJob, widget());
statJob->exec();
u = statJob->mostLocalUrl();
//If the URL is local after the above conversion, set the directory.
if (u.isLocalFile()) {
@ -559,7 +556,7 @@ void DolphinPart::slotOpenTerminal()
void DolphinPart::slotFindFile()
{
KRun::run("kfind", url(), widget());
KRun::run("kfind", {url()}, widget());
}
void DolphinPart::updateNewMenu()
@ -589,7 +586,7 @@ void DolphinPart::createDirectory()
m_newFileMenu->createDirectory();
}
void DolphinPart::setFilesToSelect(const KUrl::List& files)
void DolphinPart::setFilesToSelect(const QList<QUrl>& files)
{
if (files.isEmpty()) {
return;

View File

@ -20,20 +20,17 @@
#ifndef DOLPHINPART_H
#define DOLPHINPART_H
#include <kparts/part.h>
#include <KParts/ReadOnlyPart>
#include <QUrl>
#include <QItemSelectionModel>
class DolphinNewFileMenu;
class DolphinViewActionHandler;
class QActionGroup;
class KAction;
class KFileItemList;
class KFileItem;
class DolphinPartBrowserExtension;
class DolphinSortFilterProxyModel;
class DolphinRemoteEncoding;
class DolphinModel;
class KDirLister;
class DolphinView;
class KAboutData;
@ -53,7 +50,7 @@ class DolphinPart : public KParts::ReadOnlyPart
Q_PROPERTY( QString nameFilter READ nameFilter WRITE setNameFilter )
// Used by konqueror to implement the --select command-line option
Q_PROPERTY( KUrl::List filesToSelect READ filesToSelect WRITE setFilesToSelect )
Q_PROPERTY( QList<QUrl> filesToSelect READ filesToSelect WRITE setFilesToSelect )
public:
explicit DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantList& args);
@ -65,7 +62,7 @@ public:
* Standard KParts::ReadOnlyPart openUrl method.
* Called by Konqueror to view a directory in DolphinPart.
*/
virtual bool openUrl(const KUrl& url);
virtual bool openUrl(const QUrl& url) Q_DECL_OVERRIDE;
/// see the supportsUndo property
bool supportsUndo() const { return true; }
@ -134,7 +131,7 @@ private Q_SLOTS:
/**
* Creates a new window showing the content of \a url.
*/
void createNewWindow(const KUrl& url);
void createNewWindow(const QUrl &url);
/**
* Opens the context menu on the current mouse position.
* @pos Position in screen coordinates.
@ -146,7 +143,7 @@ private Q_SLOTS:
*/
void slotOpenContextMenu(const QPoint& pos,
const KFileItem& item,
const KUrl& url,
const QUrl& url,
const QList<QAction*>& customActions);
/**
@ -155,7 +152,7 @@ private Q_SLOTS:
* Testcase 1: fish://localhost
* Testcase 2: showing a directory that is being renamed by another window (#180156)
*/
void slotDirectoryRedirection(const KUrl& oldUrl, const KUrl& newUrl);
void slotDirectoryRedirection(const QUrl& oldUrl, const QUrl& newUrl);
/**
* Updates the state of the 'Edit' menu actions and emits
@ -223,10 +220,10 @@ private Q_SLOTS:
/**
* Called by konqueror --select
*/
void setFilesToSelect(const KUrl::List& files);
KUrl::List filesToSelect() const { return KUrl::List(); } // silence moc
void setFilesToSelect(const QList<QUrl> &files);
QList<QUrl> filesToSelect() const { return QList<QUrl>(); } // silence moc
virtual bool eventFilter(QObject*, QEvent*);
virtual bool eventFilter(QObject*, QEvent*) Q_DECL_OVERRIDE;
private:
void createActions();
@ -243,8 +240,8 @@ private:
DolphinRemoteEncoding* m_remoteEncoding;
DolphinPartBrowserExtension* m_extension;
DolphinNewFileMenu* m_newFileMenu;
KAction* m_findFileAction;
KAction* m_openTerminalAction;
QAction* m_findFileAction;
QAction* m_openTerminalAction;
QString m_nameFilter;
DolphinRemoveAction* m_removeAction;
Q_DISABLE_COPY(DolphinPart)

View File

@ -1,5 +1,5 @@
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui name="dolphinpart" version="10" >
<kpartgui name="dolphinpart" version="11" translationDomain="dolphin">
<MenuBar>
<Menu name="edit"><text>&amp;Edit</text>
<Action name="new_menu"/>

View File

@ -24,7 +24,7 @@
#include <QVariant>
#include <KFileItemList>
#include <KFileItem>
DolphinPartBrowserExtension::DolphinPartBrowserExtension(DolphinPart* part)
@ -61,7 +61,7 @@ void DolphinPartBrowserExtension::paste()
m_part->view()->paste();
}
void DolphinPartBrowserExtension::pasteTo(const KUrl&)
void DolphinPartBrowserExtension::pasteTo(const QUrl&)
{
m_part->view()->pasteIntoFolder();
}
@ -190,4 +190,3 @@ void DolphinPartListingNotificationExtension::slotItemsDeleted(const KFileItemLi
emit listingEvent(KParts::ListingNotificationExtension::ItemsDeleted, items);
}
#include "dolphinpart_ext.moc"

View File

@ -23,6 +23,7 @@
#include <kparts/browserextension.h>
#include <kparts/fileinfoextension.h>
#include <kparts/listingextension.h>
#include <QUrl>
class DolphinPart;
@ -31,14 +32,14 @@ class DolphinPartBrowserExtension : public KParts::BrowserExtension
Q_OBJECT
public:
DolphinPartBrowserExtension( DolphinPart* part );
virtual void restoreState(QDataStream &stream);
virtual void saveState(QDataStream &stream);
virtual void restoreState(QDataStream &stream) Q_DECL_OVERRIDE;
virtual void saveState(QDataStream &stream) Q_DECL_OVERRIDE;
public Q_SLOTS:
void cut();
void copy();
void paste();
void pasteTo(const KUrl&);
void pasteTo(const QUrl &);
void reparseConfiguration();
private:
@ -52,10 +53,10 @@ class DolphinPartFileInfoExtension : public KParts::FileInfoExtension
public:
DolphinPartFileInfoExtension(DolphinPart* part);
virtual QueryModes supportedQueryModes() const;
virtual bool hasSelection() const;
virtual QueryModes supportedQueryModes() const Q_DECL_OVERRIDE;
virtual bool hasSelection() const Q_DECL_OVERRIDE;
virtual KFileItemList queryFor(QueryMode mode) const;
virtual KFileItemList queryFor(QueryMode mode) const Q_DECL_OVERRIDE;
private:
DolphinPart* m_part;
@ -67,10 +68,10 @@ class DolphinPartListingFilterExtension : public KParts::ListingFilterExtension
public:
DolphinPartListingFilterExtension(DolphinPart* part);
virtual FilterModes supportedFilterModes() const;
virtual bool supportsMultipleFilters(FilterMode mode) const;
virtual QVariant filter(FilterMode mode) const;
virtual void setFilter(FilterMode mode, const QVariant& filter);
virtual FilterModes supportedFilterModes() const Q_DECL_OVERRIDE;
virtual bool supportsMultipleFilters(FilterMode mode) const Q_DECL_OVERRIDE;
virtual QVariant filter(FilterMode mode) const Q_DECL_OVERRIDE;
virtual void setFilter(FilterMode mode, const QVariant& filter) Q_DECL_OVERRIDE;
private:
DolphinPart* m_part;
@ -82,7 +83,7 @@ class DolphinPartListingNotificationExtension : public KParts::ListingNotificati
public:
DolphinPartListingNotificationExtension(DolphinPart* part);
virtual NotificationEventTypes supportedNotificationEventTypes() const;
virtual NotificationEventTypes supportedNotificationEventTypes() const Q_DECL_OVERRIDE;
public Q_SLOTS:
void slotNewItems(const KFileItemList&);

View File

@ -21,17 +21,17 @@
#include <KLocalizedString>
#include <KAcceleratorManager>
#include <KMimeType>
#include <KMenu>
#include <kio/global.h>
#include <QMenu>
DolphinRecentTabsMenu::DolphinRecentTabsMenu(QObject* parent) :
KActionMenu(KIcon("edit-undo"), i18n("Recently Closed Tabs"), parent)
KActionMenu(QIcon::fromTheme("edit-undo"), i18n("Recently Closed Tabs"), parent)
{
setDelayed(false);
setEnabled(false);
m_clearListAction = new QAction(i18n("Empty Recently Closed Tabs"), this);
m_clearListAction->setIcon(KIcon("edit-clear-list"));
m_clearListAction->setIcon(QIcon::fromTheme("edit-clear-list"));
addAction(m_clearListAction);
addSeparator();
@ -40,13 +40,13 @@ DolphinRecentTabsMenu::DolphinRecentTabsMenu(QObject* parent) :
this, SLOT(handleAction(QAction*)));
}
void DolphinRecentTabsMenu::rememberClosedTab(const KUrl& url, const QByteArray& state)
void DolphinRecentTabsMenu::rememberClosedTab(const QUrl& url, const QByteArray& state)
{
QAction* action = new QAction(menu());
action->setText(url.path());
action->setData(state);
const QString iconName = KMimeType::iconNameForUrl(url);
action->setIcon(KIcon(iconName));
const QString iconName = KIO::iconNameForUrl(url);
action->setIcon(QIcon::fromTheme(iconName));
// Add the closed tab menu entry after the separator and
// "Empty Recently Closed Tabs" entry
@ -94,4 +94,4 @@ void DolphinRecentTabsMenu::handleAction(QAction* action)
if (menu()->actions().count() <= 2) {
setEnabled(false);
}
}
}

View File

@ -21,9 +21,8 @@
#define DOLPHIN_RECENT_TABS_MENU_H
#include <KActionMenu>
#include <KUrl>
#include <QUrl>
class DolphinTabPage;
class QAction;
class DolphinRecentTabsMenu : public KActionMenu
@ -34,7 +33,7 @@ public:
explicit DolphinRecentTabsMenu(QObject* parent);
public slots:
void rememberClosedTab(const KUrl& url, const QByteArray& state);
void rememberClosedTab(const QUrl& url, const QByteArray& state);
void undoCloseTab();
signals:
@ -48,4 +47,4 @@ private:
QAction* m_clearListAction;
};
#endif
#endif

View File

@ -29,7 +29,7 @@ DolphinRemoveAction::DolphinRemoveAction(QObject* parent, KActionCollection* col
m_collection(collection)
{
update();
connect(this, SIGNAL(triggered()), this, SLOT(slotRemoveActionTriggered()));
connect(this, &DolphinRemoveAction::triggered, this, &DolphinRemoveAction::slotRemoveActionTriggered);
}
void DolphinRemoveAction::slotRemoveActionTriggered()
@ -55,7 +55,7 @@ void DolphinRemoveAction::update()
if (m_action) {
setIcon(m_action->icon());
setShortcuts(m_action->shortcuts());
m_collection->setDefaultShortcuts(this, m_action->shortcuts());
setEnabled(m_action->isEnabled());
}
}

View File

@ -20,7 +20,7 @@
#ifndef DOLPHINREMOVEACTION_H
#define DOLPHINREMOVEACTION_H
#include "libdolphin_export.h"
#include "dolphin_export.h"
#include <QAction>
#include <QPointer>
@ -34,7 +34,7 @@
* This class expects the presence of both the "move_to_trash" and "delete"
* actions in @ref collection.
*/
class LIBDOLPHINPRIVATE_EXPORT DolphinRemoveAction : public QAction
class DOLPHIN_EXPORT DolphinRemoveAction : public QAction
{
Q_OBJECT
public:

View File

@ -22,9 +22,10 @@
#include <QTimer>
#include <QDragEnterEvent>
#include <KLocalizedString>
#include <KMenu>
#include <KIcon>
#include <KUrl>
#include <QMenu>
#include <QIcon>
#include <QUrl>
#include <QMimeData>
DolphinTabBar::DolphinTabBar(QWidget* parent) :
QTabBar(parent),
@ -47,7 +48,7 @@ void DolphinTabBar::dragEnterEvent(QDragEnterEvent* event)
const QMimeData* mimeData = event->mimeData();
const int index = tabAt(event->pos());
if (KUrl::List::canDecode(mimeData)) {
if (mimeData->hasUrls()) {
event->acceptProposedAction();
updateAutoActivationTimer(index);
}
@ -67,7 +68,7 @@ void DolphinTabBar::dragMoveEvent(QDragMoveEvent* event)
const QMimeData* mimeData = event->mimeData();
const int index = tabAt(event->pos());
if (KUrl::List::canDecode(mimeData)) {
if (mimeData->hasUrls()) {
updateAutoActivationTimer(index);
}
@ -82,7 +83,7 @@ void DolphinTabBar::dropEvent(QDropEvent* event)
const QMimeData* mimeData = event->mimeData();
const int index = tabAt(event->pos());
if (index >= 0 && KUrl::List::canDecode(mimeData)) {
if (index >= 0 && mimeData->hasUrls()) {
emit tabDropEvent(index, event);
}
@ -122,12 +123,12 @@ void DolphinTabBar::contextMenuEvent(QContextMenuEvent* event)
if (index >= 0) {
// Tab context menu
KMenu menu(this);
QMenu menu(this);
QAction* newTabAction = menu.addAction(KIcon("tab-new"), i18nc("@action:inmenu", "New Tab"));
QAction* detachTabAction = menu.addAction(KIcon("tab-detach"), i18nc("@action:inmenu", "Detach Tab"));
QAction* closeOtherTabsAction = menu.addAction(KIcon("tab-close-other"), i18nc("@action:inmenu", "Close Other Tabs"));
QAction* closeTabAction = menu.addAction(KIcon("tab-close"), i18nc("@action:inmenu", "Close Tab"));
QAction* newTabAction = menu.addAction(QIcon::fromTheme("tab-new"), i18nc("@action:inmenu", "New Tab"));
QAction* detachTabAction = menu.addAction(QIcon::fromTheme("tab-detach"), i18nc("@action:inmenu", "Detach Tab"));
QAction* closeOtherTabsAction = menu.addAction(QIcon::fromTheme("tab-close-other"), i18nc("@action:inmenu", "Close Other Tabs"));
QAction* closeTabAction = menu.addAction(QIcon::fromTheme("tab-close"), i18nc("@action:inmenu", "Close Tab"));
QAction* selectedAction = menu.exec(event->globalPos());
if (selectedAction == newTabAction) {

View File

@ -35,17 +35,17 @@ signals:
void tabDetachRequested(int index);
protected:
virtual void dragEnterEvent(QDragEnterEvent* event);
virtual void dragLeaveEvent(QDragLeaveEvent* event);
virtual void dragMoveEvent(QDragMoveEvent* event);
virtual void dropEvent(QDropEvent* event);
virtual void mousePressEvent(QMouseEvent* event);
virtual void mouseDoubleClickEvent(QMouseEvent* event);
virtual void dragEnterEvent(QDragEnterEvent* event) Q_DECL_OVERRIDE;
virtual void dragLeaveEvent(QDragLeaveEvent* event) Q_DECL_OVERRIDE;
virtual void dragMoveEvent(QDragMoveEvent* event) Q_DECL_OVERRIDE;
virtual void dropEvent(QDropEvent* event) Q_DECL_OVERRIDE;
virtual void mousePressEvent(QMouseEvent* event) Q_DECL_OVERRIDE;
virtual void mouseDoubleClickEvent(QMouseEvent* event) Q_DECL_OVERRIDE;
/**
* Opens a context menu for the tab on the \a event position.
*/
virtual void contextMenuEvent(QContextMenuEvent* event);
virtual void contextMenuEvent(QContextMenuEvent* event) Q_DECL_OVERRIDE;
private slots:
void slotAutoActivationTimeout();

View File

@ -23,8 +23,9 @@
#include "dolphin_generalsettings.h"
#include <QSplitter>
#include <QVBoxLayout>
DolphinTabPage::DolphinTabPage(const KUrl& primaryUrl, const KUrl& secondaryUrl, QWidget* parent) :
DolphinTabPage::DolphinTabPage(const QUrl &primaryUrl, const QUrl &secondaryUrl, QWidget* parent) :
QWidget(parent),
m_primaryViewActive(true),
m_splitViewEnabled(false)
@ -39,10 +40,10 @@ DolphinTabPage::DolphinTabPage(const KUrl& primaryUrl, const KUrl& secondaryUrl,
// Create a new primary view
m_primaryViewContainer = createViewContainer(primaryUrl);
connect(m_primaryViewContainer->view(), SIGNAL(urlChanged(KUrl)),
this, SIGNAL(activeViewUrlChanged(KUrl)));
connect(m_primaryViewContainer->view(), SIGNAL(redirection(KUrl,KUrl)),
this, SLOT(slotViewUrlRedirection(KUrl,KUrl)));
connect(m_primaryViewContainer->view(), SIGNAL(urlChanged(QUrl)),
this, SIGNAL(activeViewUrlChanged(QUrl)));
connect(m_primaryViewContainer->view(), SIGNAL(redirection(QUrl,QUrl)),
this, SLOT(slotViewUrlRedirection(QUrl,QUrl)));
m_splitter->addWidget(m_primaryViewContainer);
m_primaryViewContainer->show();
@ -51,7 +52,7 @@ DolphinTabPage::DolphinTabPage(const KUrl& primaryUrl, const KUrl& secondaryUrl,
// Provide a secondary view, if the given secondary url is valid or if the
// startup settings are set this way (use the url of the primary view).
m_splitViewEnabled = true;
const KUrl& url = secondaryUrl.isValid() ? secondaryUrl : primaryUrl;
const QUrl& url = secondaryUrl.isValid() ? secondaryUrl : primaryUrl;
m_secondaryViewContainer = createViewContainer(url);
m_splitter->addWidget(m_secondaryViewContainer);
m_secondaryViewContainer->show();
@ -76,7 +77,7 @@ void DolphinTabPage::setSplitViewEnabled(bool enabled)
m_splitViewEnabled = enabled;
if (enabled) {
const KUrl& url = m_primaryViewContainer->url();
const QUrl& url = m_primaryViewContainer->url();
m_secondaryViewContainer = createViewContainer(url);
const bool placesSelectorVisible = m_primaryViewContainer->urlNavigator()->isPlacesSelectorVisible();
@ -134,7 +135,7 @@ int DolphinTabPage::selectedItemsCount() const
return selectedItemsCount;
}
void DolphinTabPage::markUrlsAsSelected(const QList<KUrl>& urls)
void DolphinTabPage::markUrlsAsSelected(const QList<QUrl>& urls)
{
m_primaryViewContainer->view()->markUrlsAsSelected(urls);
if (m_splitViewEnabled) {
@ -142,7 +143,7 @@ void DolphinTabPage::markUrlsAsSelected(const QList<KUrl>& urls)
}
}
void DolphinTabPage::markUrlAsCurrent(const KUrl& url)
void DolphinTabPage::markUrlAsCurrent(const QUrl& url)
{
m_primaryViewContainer->view()->markUrlAsCurrent(url);
if (m_splitViewEnabled) {
@ -212,7 +213,7 @@ void DolphinTabPage::restoreState(const QByteArray& state)
stream >> isSplitViewEnabled;
setSplitViewEnabled(isSplitViewEnabled);
KUrl primaryUrl;
QUrl primaryUrl;
stream >> primaryUrl;
m_primaryViewContainer->setUrl(primaryUrl);
bool primaryUrlEditable;
@ -221,7 +222,7 @@ void DolphinTabPage::restoreState(const QByteArray& state)
m_primaryViewContainer->view()->restoreState(stream);
if (isSplitViewEnabled) {
KUrl secondaryUrl;
QUrl secondaryUrl;
stream >> secondaryUrl;
m_secondaryViewContainer->setUrl(secondaryUrl);
bool secondaryUrlEditable;
@ -256,7 +257,7 @@ void DolphinTabPage::restoreStateV1(const QByteArray& state)
stream >> isSplitViewEnabled;
setSplitViewEnabled(isSplitViewEnabled);
KUrl primaryUrl;
QUrl primaryUrl;
stream >> primaryUrl;
m_primaryViewContainer->setUrl(primaryUrl);
bool primaryUrlEditable;
@ -264,7 +265,7 @@ void DolphinTabPage::restoreStateV1(const QByteArray& state)
m_primaryViewContainer->urlNavigator()->setUrlEditable(primaryUrlEditable);
if (isSplitViewEnabled) {
KUrl secondaryUrl;
QUrl secondaryUrl;
stream >> secondaryUrl;
m_secondaryViewContainer->setUrl(secondaryUrl);
bool secondaryUrlEditable;
@ -301,28 +302,28 @@ void DolphinTabPage::slotViewActivated()
const DolphinView* newActiveView = activeViewContainer()->view();
if (newActiveView != oldActiveView) {
disconnect(oldActiveView, SIGNAL(urlChanged(KUrl)),
this, SIGNAL(activeViewUrlChanged(KUrl)));
disconnect(oldActiveView, SIGNAL(redirection(KUrl,KUrl)),
this, SLOT(slotViewUrlRedirection(KUrl,KUrl)));
connect(newActiveView, SIGNAL(urlChanged(KUrl)),
this, SIGNAL(activeViewUrlChanged(KUrl)));
connect(newActiveView, SIGNAL(redirection(KUrl,KUrl)),
this, SLOT(slotViewUrlRedirection(KUrl,KUrl)));
disconnect(oldActiveView, SIGNAL(urlChanged(QUrl)),
this, SIGNAL(activeViewUrlChanged(QUrl)));
disconnect(oldActiveView, SIGNAL(redirection(QUrl,QUrl)),
this, SLOT(slotViewUrlRedirection(QUrl,QUrl)));
connect(newActiveView, SIGNAL(urlChanged(QUrl)),
this, SIGNAL(activeViewUrlChanged(QUrl)));
connect(newActiveView, SIGNAL(redirection(QUrl,QUrl)),
this, SLOT(slotViewUrlRedirection(QUrl,QUrl)));
}
emit activeViewUrlChanged(activeViewContainer()->url());
emit activeViewChanged(activeViewContainer());
}
void DolphinTabPage::slotViewUrlRedirection(const KUrl& oldUrl, const KUrl& newUrl)
void DolphinTabPage::slotViewUrlRedirection(const QUrl& oldUrl, const QUrl& newUrl)
{
Q_UNUSED(oldUrl);
emit activeViewUrlChanged(newUrl);
}
DolphinViewContainer* DolphinTabPage::createViewContainer(const KUrl& url) const
DolphinViewContainer* DolphinTabPage::createViewContainer(const QUrl& url) const
{
DolphinViewContainer* container = new DolphinViewContainer(url, m_splitter);
container->setActive(false);

View File

@ -22,7 +22,7 @@
#include <QWidget>
#include <QPointer>
#include <KUrl>
#include <QUrl>
class QSplitter;
class DolphinViewContainer;
@ -33,7 +33,7 @@ class DolphinTabPage : public QWidget
Q_OBJECT
public:
explicit DolphinTabPage(const KUrl& primaryUrl, const KUrl& secondaryUrl = KUrl(), QWidget* parent = 0);
explicit DolphinTabPage(const QUrl& primaryUrl, const QUrl& secondaryUrl = QUrl(), QWidget* parent = 0);
/**
* @return True if primary view is the active view in this tab.
@ -85,13 +85,13 @@ public:
* gets selected if no loading of a directory has been triggered
* by DolphinView::setUrl() or DolphinView::reload().
*/
void markUrlsAsSelected(const QList<KUrl>& urls);
void markUrlsAsSelected(const QList<QUrl> &urls);
/**
* Marks the item indicated by \p url to be scrolled to and as the
* current item after directory DolphinView::url() has been loaded.
*/
void markUrlAsCurrent(const KUrl& url);
void markUrlAsCurrent(const QUrl& url);
/**
* Sets the places selector visible, if \a visible is true.
@ -131,7 +131,7 @@ public:
signals:
void activeViewChanged(DolphinViewContainer* viewContainer);
void activeViewUrlChanged(const KUrl& url);
void activeViewUrlChanged(const QUrl& url);
private slots:
/**
@ -147,13 +147,13 @@ private slots:
*
* It emits the activeViewUrlChanged signal with the url \a newUrl.
*/
void slotViewUrlRedirection(const KUrl& oldUrl, const KUrl& newUrl);
void slotViewUrlRedirection(const QUrl& oldUrl, const QUrl& newUrl);
private:
/**
* Creates a new view container and does the default initialization.
*/
DolphinViewContainer* createViewContainer(const KUrl& url) const;
DolphinViewContainer* createViewContainer(const QUrl& url) const;
private:
QSplitter* m_splitter;

View File

@ -23,11 +23,10 @@
#include "dolphintabpage.h"
#include "dolphinviewcontainer.h"
#include "dolphin_generalsettings.h"
#include "views/draganddrophelper.h"
#include <QApplication>
#include <KConfigGroup>
#include <KIcon>
#include <kio/global.h>
#include <KRun>
DolphinTabWidget::DolphinTabWidget(QWidget* parent) :
@ -130,13 +129,13 @@ void DolphinTabWidget::openNewActivatedTab()
}
}
void DolphinTabWidget::openNewActivatedTab(const KUrl& primaryUrl, const KUrl& secondaryUrl)
void DolphinTabWidget::openNewActivatedTab(const QUrl& primaryUrl, const QUrl& secondaryUrl)
{
openNewTab(primaryUrl, secondaryUrl);
setCurrentIndex(count() - 1);
}
void DolphinTabWidget::openNewTab(const KUrl& primaryUrl, const KUrl& secondaryUrl)
void DolphinTabWidget::openNewTab(const QUrl& primaryUrl, const QUrl& secondaryUrl)
{
QWidget* focusWidget = QApplication::focusWidget();
@ -144,9 +143,9 @@ void DolphinTabWidget::openNewTab(const KUrl& primaryUrl, const KUrl& secondaryU
tabPage->setPlacesSelectorVisible(m_placesSelectorVisible);
connect(tabPage, SIGNAL(activeViewChanged(DolphinViewContainer*)),
this, SIGNAL(activeViewChanged(DolphinViewContainer*)));
connect(tabPage, SIGNAL(activeViewUrlChanged(KUrl)),
this, SLOT(tabUrlChanged(KUrl)));
addTab(tabPage, KIcon(KMimeType::iconNameForUrl(primaryUrl)), tabName(primaryUrl));
connect(tabPage, SIGNAL(activeViewUrlChanged(QUrl)),
this, SLOT(tabUrlChanged(QUrl)));
addTab(tabPage, QIcon::fromTheme(KIO::iconNameForUrl(primaryUrl)), tabName(primaryUrl));
if (focusWidget) {
// The DolphinViewContainer grabbed the keyboard focus. As the tab is opened
@ -155,17 +154,17 @@ void DolphinTabWidget::openNewTab(const KUrl& primaryUrl, const KUrl& secondaryU
}
}
void DolphinTabWidget::openDirectories(const QList<KUrl>& dirs)
void DolphinTabWidget::openDirectories(const QList<QUrl>& dirs)
{
const bool hasSplitView = GeneralSettings::splitView();
// Open each directory inside a new tab. If the "split view" option has been enabled,
// always show two directories within one tab.
QList<KUrl>::const_iterator it = dirs.constBegin();
QList<QUrl>::const_iterator it = dirs.constBegin();
while (it != dirs.constEnd()) {
const KUrl& primaryUrl = *(it++);
const QUrl& primaryUrl = *(it++);
if (hasSplitView && (it != dirs.constEnd())) {
const KUrl& secondaryUrl = *(it++);
const QUrl& secondaryUrl = *(it++);
openNewTab(primaryUrl, secondaryUrl);
} else {
openNewTab(primaryUrl);
@ -173,7 +172,7 @@ void DolphinTabWidget::openDirectories(const QList<KUrl>& dirs)
}
}
void DolphinTabWidget::openFiles(const QList<KUrl>& files)
void DolphinTabWidget::openFiles(const QList<QUrl>& files)
{
if (files.isEmpty()) {
return;
@ -182,9 +181,9 @@ void DolphinTabWidget::openFiles(const QList<KUrl>& files)
// Get all distinct directories from 'files' and open a tab
// for each directory. If the "split view" option is enabled, two
// directories are shown inside one tab (see openDirectories()).
QList<KUrl> dirs;
foreach (const KUrl& url, files) {
const KUrl dir(url.directory());
QList<QUrl> dirs;
foreach (const QUrl& url, files) {
const QUrl dir(url.adjusted(QUrl::RemoveFilename));
if (!dirs.contains(dir)) {
dirs.append(dir);
}
@ -286,22 +285,17 @@ void DolphinTabWidget::openNewActivatedTab(int index)
void DolphinTabWidget::tabDropEvent(int index, QDropEvent* event)
{
if (index >= 0) {
const DolphinView* view = tabPageAt(index)->activeViewContainer()->view();
QString error;
DragAndDropHelper::dropUrls(view->rootItem(), view->url(), event, error);
if (!error.isEmpty()) {
currentTabPage()->activeViewContainer()->showMessage(error, DolphinViewContainer::Error);
}
DolphinView* view = tabPageAt(index)->activeViewContainer()->view();
view->dropUrls(view->url(), event);
}
}
void DolphinTabWidget::tabUrlChanged(const KUrl& url)
void DolphinTabWidget::tabUrlChanged(const QUrl& url)
{
const int index = indexOf(qobject_cast<QWidget*>(sender()));
if (index >= 0) {
tabBar()->setTabText(index, tabName(url));
tabBar()->setTabIcon(index, KIcon(KMimeType::iconNameForUrl(url)));
tabBar()->setTabIcon(index, QIcon::fromTheme(KIO::iconNameForUrl(url)));
// Emit the currentUrlChanged signal if the url of the current tab has been changed.
if (index == currentIndex()) {
@ -342,15 +336,15 @@ void DolphinTabWidget::tabRemoved(int index)
emit tabCountChanged(count());
}
QString DolphinTabWidget::tabName(const KUrl& url) const
QString DolphinTabWidget::tabName(const QUrl& url) const
{
QString name;
if (url.equals(KUrl("file:///"))) {
if (url == QUrl("file:///")) {
name = '/';
} else {
name = url.fileName();
name = url.adjusted(QUrl::StripTrailingSlash).fileName();
if (name.isEmpty()) {
name = url.protocol();
name = url.scheme();
} else {
// Make sure that a '&' inside the directory name is displayed correctly
// and not misinterpreted as a keyboard shortcut in QTabBar::setTabText()

View File

@ -21,7 +21,7 @@
#define DOLPHIN_TAB_WIDGET_H
#include <QTabWidget>
#include <KUrl>
#include <QUrl>
class DolphinViewContainer;
class DolphinTabPage;
@ -70,13 +70,13 @@ signals:
/**
* Is emitted when a tab has been closed.
*/
void rememberClosedTab(const KUrl& url, const QByteArray& state);
void rememberClosedTab(const QUrl& url, const QByteArray& state);
/**
* Is emitted when the url of the current tab has been changed. This signal
* is also emitted when the active view has been changed.
*/
void currentUrlChanged(const KUrl& url);
void currentUrlChanged(const QUrl& url);
public slots:
/**
@ -89,26 +89,26 @@ public slots:
* Opens a new tab showing the URL \a primaryUrl and the optional URL
* \a secondaryUrl and activates the tab.
*/
void openNewActivatedTab(const KUrl& primaryUrl, const KUrl& secondaryUrl = KUrl());
void openNewActivatedTab(const QUrl& primaryUrl, const QUrl& secondaryUrl = QUrl());
/**
* Opens a new tab in the background showing the URL \a primaryUrl and the
* optional URL \a secondaryUrl.
*/
void openNewTab(const KUrl& primaryUrl, const KUrl& secondaryUrl = KUrl());
void openNewTab(const QUrl &primaryUrl, const QUrl &secondaryUrl = QUrl());
/**
* Opens each directory in \p dirs in a separate tab. If the "split view"
* option is enabled, 2 directories are collected within one tab.
*/
void openDirectories(const QList<KUrl>& dirs);
void openDirectories(const QList<QUrl>& dirs);
/**
* Opens the directory which contains the files \p files
* and selects all files (implements the --select option
* of Dolphin).
*/
void openFiles(const QList<KUrl>& files);
void openFiles(const QList<QUrl> &files);
/**
* Closes the currently active tab.
@ -168,23 +168,23 @@ private slots:
* The active view url of a tab has been changed so update the text and the
* icon of the corresponding tab.
*/
void tabUrlChanged(const KUrl& url);
void tabUrlChanged(const QUrl& url);
void currentTabChanged(int index);
protected:
virtual void tabInserted(int index);
virtual void tabRemoved(int index);
virtual void tabInserted(int index) Q_DECL_OVERRIDE;
virtual void tabRemoved(int index) Q_DECL_OVERRIDE;
private:
/**
* Returns the name of the tab for the URL \a url.
*/
QString tabName(const KUrl& url) const;
QString tabName(const QUrl& url) const;
private:
/** Caches the (negated) places panel visibility */
bool m_placesSelectorVisible;
};
#endif
#endif

View File

@ -20,44 +20,33 @@
#include "dolphinviewcontainer.h"
#include <KProtocolManager>
#include <QApplication>
#include <QKeyEvent>
#include <QItemSelection>
#include <QBoxLayout>
#include <QDropEvent>
#include <QTimer>
#include <QScrollBar>
#include <QMimeData>
#include <QVBoxLayout>
#include <KDesktopFile>
#include <KFileItemDelegate>
#include <KFileItemActions>
#include <KFilePlacesModel>
#include <KLocale>
#include <KIconEffect>
#include <KIO/NetAccess>
#include <KLocalizedString>
#include <KIO/PreviewJob>
#include <KMessageWidget>
#include <KNewFileMenu>
#include <konqmimedata.h>
#include <konq_operations.h>
#include <KShell>
#include <KUrl>
#include <QUrl>
#include <KUrlComboBox>
#include <KUrlNavigator>
#include <KRun>
#ifdef KActivities_FOUND
#include <KActivities/ResourceInstance>
#endif
#include "dolphin_generalsettings.h"
#include "filterbar/filterbar.h"
#include "search/dolphinsearchbox.h"
#include "statusbar/dolphinstatusbar.h"
#include "views/draganddrophelper.h"
#include "views/viewmodecontroller.h"
#include "views/viewproperties.h"
DolphinViewContainer::DolphinViewContainer(const KUrl& url, QWidget* parent) :
DolphinViewContainer::DolphinViewContainer(const QUrl& url, QWidget* parent) :
QWidget(parent),
m_topLayout(0),
m_urlNavigator(0),
@ -68,9 +57,7 @@ DolphinViewContainer::DolphinViewContainer(const KUrl& url, QWidget* parent) :
m_statusBar(0),
m_statusBarTimer(0),
m_statusBarTimestamp(),
m_autoGrabFocus(true),
m_dropDestination(),
m_dropEvent(0)
m_autoGrabFocus(true)
#ifdef KActivities_FOUND
, m_activityResourceInstance(0)
#endif
@ -82,92 +69,117 @@ DolphinViewContainer::DolphinViewContainer(const KUrl& url, QWidget* parent) :
m_topLayout->setMargin(0);
m_urlNavigator = new KUrlNavigator(new KFilePlacesModel(this), url, this);
connect(m_urlNavigator, SIGNAL(urlsDropped(KUrl,QDropEvent*)),
this, SLOT(dropUrls(KUrl,QDropEvent*)));
connect(m_urlNavigator, SIGNAL(activated()),
this, SLOT(activate()));
connect(m_urlNavigator->editor(), SIGNAL(completionModeChanged(KGlobalSettings::Completion)),
this, SLOT(saveUrlCompletionMode(KGlobalSettings::Completion)));
connect(m_urlNavigator, &KUrlNavigator::activated,
this, &DolphinViewContainer::activate);
connect(m_urlNavigator->editor(), &KUrlComboBox::completionModeChanged,
this, &DolphinViewContainer::saveUrlCompletionMode);
const GeneralSettings* settings = GeneralSettings::self();
m_urlNavigator->setUrlEditable(settings->editableUrl());
m_urlNavigator->setShowFullPath(settings->showFullPath());
m_urlNavigator->setHomeUrl(KUrl(settings->homeUrl()));
m_urlNavigator->setHomeUrl(QUrl::fromLocalFile(settings->homeUrl()));
KUrlComboBox* editor = m_urlNavigator->editor();
editor->setCompletionMode(KGlobalSettings::Completion(settings->urlCompletionMode()));
editor->setCompletionMode(KCompletion::CompletionMode(settings->urlCompletionMode()));
m_searchBox = new DolphinSearchBox(this);
m_searchBox->hide();
connect(m_searchBox, SIGNAL(activated()), this, SLOT(activate()));
connect(m_searchBox, SIGNAL(closeRequest()), this, SLOT(closeSearchBox()));
connect(m_searchBox, SIGNAL(searchRequest()), this, SLOT(startSearching()));
connect(m_searchBox, SIGNAL(returnPressed(QString)), this, SLOT(requestFocus()));
connect(m_searchBox, &DolphinSearchBox::activated, this, &DolphinViewContainer::activate);
connect(m_searchBox, &DolphinSearchBox::closeRequest, this, &DolphinViewContainer::closeSearchBox);
connect(m_searchBox, &DolphinSearchBox::searchRequest, this, &DolphinViewContainer::startSearching);
connect(m_searchBox, &DolphinSearchBox::returnPressed, this, &DolphinViewContainer::requestFocus);
m_messageWidget = new KMessageWidget(this);
m_messageWidget->setCloseButtonVisible(true);
m_messageWidget->hide();
m_view = new DolphinView(url, this);
connect(m_view, SIGNAL(urlChanged(KUrl)), m_urlNavigator, SLOT(setUrl(KUrl)));
connect(m_view, SIGNAL(urlChanged(KUrl)), m_messageWidget, SLOT(hide()));
connect(m_view, SIGNAL(directoryLoadingCompleted()), m_messageWidget, SLOT(hide()));
connect(m_view, SIGNAL(writeStateChanged(bool)), this, SIGNAL(writeStateChanged(bool)));
connect(m_view, SIGNAL(requestItemInfo(KFileItem)), this, SLOT(showItemInfo(KFileItem)));
connect(m_view, SIGNAL(itemActivated(KFileItem)), this, SLOT(slotItemActivated(KFileItem)));
connect(m_view, SIGNAL(itemsActivated(KFileItemList)), this, SLOT(slotItemsActivated(KFileItemList)));
connect(m_view, SIGNAL(redirection(KUrl,KUrl)), this, SLOT(redirect(KUrl,KUrl)));
connect(m_view, SIGNAL(directoryLoadingStarted()), this, SLOT(slotDirectoryLoadingStarted()));
connect(m_view, SIGNAL(directoryLoadingCompleted()), this, SLOT(slotDirectoryLoadingCompleted()));
connect(m_view, SIGNAL(directoryLoadingCanceled()), this, SLOT(slotDirectoryLoadingCanceled()));
connect(m_view, SIGNAL(itemCountChanged()), this, SLOT(delayedStatusBarUpdate()));
connect(m_view, SIGNAL(directoryLoadingProgress(int)), this, SLOT(updateDirectoryLoadingProgress(int)));
connect(m_view, SIGNAL(directorySortingProgress(int)), this, SLOT(updateDirectorySortingProgress(int)));
connect(m_view, SIGNAL(selectionChanged(KFileItemList)), this, SLOT(delayedStatusBarUpdate()));
connect(m_view, SIGNAL(urlAboutToBeChanged(KUrl)), this, SLOT(slotViewUrlAboutToBeChanged(KUrl)));
connect(m_view, SIGNAL(errorMessage(QString)), this, SLOT(showErrorMessage(QString)));
connect(m_view, SIGNAL(urlIsFileError(KUrl)), this, SLOT(slotUrlIsFileError(KUrl)));
connect(m_view, SIGNAL(activated()), this, SLOT(activate()));
connect(m_view, &DolphinView::urlChanged,
m_urlNavigator, &KUrlNavigator::setUrl);
connect(m_view, &DolphinView::urlChanged,
m_messageWidget, &KMessageWidget::hide);
connect(m_view, &DolphinView::directoryLoadingCompleted,
m_messageWidget, &KMessageWidget::hide);
connect(m_view, &DolphinView::writeStateChanged,
this, &DolphinViewContainer::writeStateChanged);
connect(m_view, &DolphinView::requestItemInfo,
this, &DolphinViewContainer::showItemInfo);
connect(m_view, &DolphinView::itemActivated,
this, &DolphinViewContainer::slotItemActivated);
connect(m_view, &DolphinView::itemsActivated,
this, &DolphinViewContainer::slotItemsActivated);
connect(m_view, &DolphinView::redirection,
this, &DolphinViewContainer::redirect);
connect(m_view, &DolphinView::directoryLoadingStarted,
this, &DolphinViewContainer::slotDirectoryLoadingStarted);
connect(m_view, &DolphinView::directoryLoadingCompleted,
this, &DolphinViewContainer::slotDirectoryLoadingCompleted);
connect(m_view, &DolphinView::directoryLoadingCanceled,
this, &DolphinViewContainer::slotDirectoryLoadingCanceled);
connect(m_view, &DolphinView::itemCountChanged,
this, &DolphinViewContainer::delayedStatusBarUpdate);
connect(m_view, &DolphinView::directoryLoadingProgress,
this, &DolphinViewContainer::updateDirectoryLoadingProgress);
connect(m_view, &DolphinView::directorySortingProgress,
this, &DolphinViewContainer::updateDirectorySortingProgress);
connect(m_view, &DolphinView::selectionChanged,
this, &DolphinViewContainer::delayedStatusBarUpdate);
connect(m_view, &DolphinView::urlAboutToBeChanged,
this, &DolphinViewContainer::slotViewUrlAboutToBeChanged);
connect(m_view, &DolphinView::errorMessage,
this, &DolphinViewContainer::showErrorMessage);
connect(m_view, &DolphinView::urlIsFileError,
this, &DolphinViewContainer::slotUrlIsFileError);
connect(m_view, &DolphinView::activated,
this, &DolphinViewContainer::activate);
connect(m_urlNavigator, SIGNAL(urlAboutToBeChanged(KUrl)),
this, SLOT(slotUrlNavigatorLocationAboutToBeChanged(KUrl)));
connect(m_urlNavigator, SIGNAL(urlChanged(KUrl)),
this, SLOT(slotUrlNavigatorLocationChanged(KUrl)));
connect(m_urlNavigator, SIGNAL(historyChanged()),
this, SLOT(slotHistoryChanged()));
connect(m_urlNavigator, SIGNAL(returnPressed()),
this, SLOT(slotReturnPressed()));
connect(m_urlNavigator, &KUrlNavigator::urlAboutToBeChanged,
this, &DolphinViewContainer::slotUrlNavigatorLocationAboutToBeChanged);
connect(m_urlNavigator, &KUrlNavigator::urlChanged,
this, &DolphinViewContainer::slotUrlNavigatorLocationChanged);
connect(m_urlNavigator, &KUrlNavigator::historyChanged,
this, &DolphinViewContainer::slotHistoryChanged);
connect(m_urlNavigator, &KUrlNavigator::returnPressed,
this, &DolphinViewContainer::slotReturnPressed);
connect(m_urlNavigator, &KUrlNavigator::urlsDropped,
m_view, &DolphinView::dropUrls);
// Initialize status bar
m_statusBar = new DolphinStatusBar(this);
m_statusBar->setUrl(m_view->url());
m_statusBar->setZoomLevel(m_view->zoomLevel());
connect(m_view, SIGNAL(urlChanged(KUrl)), m_statusBar, SLOT(setUrl(KUrl)));
connect(m_view, SIGNAL(zoomLevelChanged(int,int)), m_statusBar, SLOT(setZoomLevel(int)));
connect(m_view, SIGNAL(infoMessage(QString)), m_statusBar, SLOT(setText(QString)));
connect(m_view, SIGNAL(operationCompletedMessage(QString)), m_statusBar, SLOT(setText(QString)));
connect(m_statusBar, SIGNAL(stopPressed()), this, SLOT(stopDirectoryLoading()));
connect(m_statusBar, SIGNAL(zoomLevelChanged(int)), this, SLOT(slotStatusBarZoomLevelChanged(int)));
connect(m_view, &DolphinView::urlChanged,
m_statusBar, &DolphinStatusBar::setUrl);
connect(m_view, &DolphinView::zoomLevelChanged,
m_statusBar, &DolphinStatusBar::setZoomLevel);
connect(m_view, &DolphinView::infoMessage,
m_statusBar, &DolphinStatusBar::setText);
connect(m_view, &DolphinView::operationCompletedMessage,
m_statusBar, &DolphinStatusBar::setText);
connect(m_statusBar, &DolphinStatusBar::stopPressed,
this, &DolphinViewContainer::stopDirectoryLoading);
connect(m_statusBar, &DolphinStatusBar::zoomLevelChanged,
this, &DolphinViewContainer::slotStatusBarZoomLevelChanged);
m_statusBarTimer = new QTimer(this);
m_statusBarTimer->setSingleShot(true);
m_statusBarTimer->setInterval(300);
connect(m_statusBarTimer, SIGNAL(timeout()), this, SLOT(updateStatusBar()));
connect(m_statusBarTimer, &QTimer::timeout, this, &DolphinViewContainer::updateStatusBar);
KIO::FileUndoManager* undoManager = KIO::FileUndoManager::self();
connect(undoManager, SIGNAL(jobRecordingFinished(CommandType)),
this, SLOT(delayedStatusBarUpdate()));
connect(undoManager, &KIO::FileUndoManager::jobRecordingFinished,
this, &DolphinViewContainer::delayedStatusBarUpdate);
// Initialize filter bar
m_filterBar = new FilterBar(this);
m_filterBar->setVisible(settings->filterBar());
connect(m_filterBar, SIGNAL(filterChanged(QString)),
this, SLOT(setNameFilter(QString)));
connect(m_filterBar, SIGNAL(closeRequest()),
this, SLOT(closeFilterBar()));
connect(m_filterBar, SIGNAL(focusViewRequest()),
this, SLOT(requestFocus()));
connect(m_view, SIGNAL(urlChanged(KUrl)),
m_filterBar, SLOT(slotUrlChanged()));
connect(m_filterBar, &FilterBar::filterChanged,
this, &DolphinViewContainer::setNameFilter);
connect(m_filterBar, &FilterBar::closeRequest,
this, &DolphinViewContainer::closeFilterBar);
connect(m_filterBar, &FilterBar::focusViewRequest,
this, &DolphinViewContainer::requestFocus);
connect(m_view, &DolphinView::urlChanged,
m_filterBar, &FilterBar::slotUrlChanged);
m_topLayout->addWidget(m_urlNavigator);
m_topLayout->addWidget(m_searchBox);
@ -191,7 +203,7 @@ DolphinViewContainer::~DolphinViewContainer()
{
}
KUrl DolphinViewContainer::url() const
QUrl DolphinViewContainer::url() const
{
return m_view->url();
}
@ -292,7 +304,7 @@ void DolphinViewContainer::readSettings()
// settings of the URL navigator and the filterbar.
m_urlNavigator->setUrlEditable(GeneralSettings::editableUrl());
m_urlNavigator->setShowFullPath(GeneralSettings::showFullPath());
m_urlNavigator->setHomeUrl(KUrl(GeneralSettings::homeUrl()));
m_urlNavigator->setHomeUrl(QUrl::fromLocalFile(GeneralSettings::homeUrl()));
setFilterBarVisible(GeneralSettings::filterBar());
}
@ -319,16 +331,16 @@ void DolphinViewContainer::setSearchModeEnabled(bool enabled)
m_urlNavigator->setVisible(!enabled);
if (enabled) {
const KUrl& locationUrl = m_urlNavigator->locationUrl();
const QUrl& locationUrl = m_urlNavigator->locationUrl();
m_searchBox->fromSearchUrl(locationUrl);
} else {
m_view->setViewPropertiesContext(QString());
// Restore the URL for the URL navigator. If Dolphin has been
// started with a search-URL, the home URL is used as fallback.
KUrl url = m_searchBox->searchPath();
QUrl url = m_searchBox->searchPath();
if (url.isEmpty() || !url.isValid() || isSearchUrl(url)) {
url = GeneralSettings::self()->homeUrl();
url = QUrl::fromLocalFile(GeneralSettings::self()->homeUrl());
}
m_urlNavigator->setLocationUrl(url);
}
@ -355,7 +367,7 @@ QString DolphinViewContainer::placesText() const
return text;
}
void DolphinViewContainer::setUrl(const KUrl& newUrl)
void DolphinViewContainer::setUrl(const QUrl& newUrl)
{
if (newUrl != m_urlNavigator->locationUrl()) {
m_urlNavigator->setLocationUrl(newUrl);
@ -460,14 +472,14 @@ void DolphinViewContainer::slotDirectoryLoadingCanceled()
m_statusBar->setText(QString());
}
void DolphinViewContainer::slotUrlIsFileError(const KUrl& url)
void DolphinViewContainer::slotUrlIsFileError(const QUrl& url)
{
const KFileItem item(KFileItem::Unknown, KFileItem::Unknown, url);
const KFileItem item(url);
// Find out if the file can be opened in the view (for example, this is the
// case if the file is an archive). The mime type must be known for that.
item.determineMimeType();
const KUrl& folderUrl = DolphinView::openItemAsFolderUrl(item, true);
const QUrl& folderUrl = DolphinView::openItemAsFolderUrl(item, true);
if (!folderUrl.isEmpty()) {
m_view->setUrl(folderUrl);
} else {
@ -482,13 +494,14 @@ void DolphinViewContainer::slotItemActivated(const KFileItem& item)
// results in an active view.
m_view->setActive(true);
const KUrl& url = DolphinView::openItemAsFolderUrl(item, GeneralSettings::browseThroughArchives());
const QUrl& url = DolphinView::openItemAsFolderUrl(item, GeneralSettings::browseThroughArchives());
if (!url.isEmpty()) {
m_view->setUrl(url);
return;
}
item.run();
KRun *run = new KRun(item.targetUrl(), this);
run->setShowScriptExecutionPrompt(true);
}
void DolphinViewContainer::slotItemsActivated(const KFileItemList& items)
@ -526,7 +539,7 @@ void DolphinViewContainer::activate()
setActive(true);
}
void DolphinViewContainer::slotViewUrlAboutToBeChanged(const KUrl& url)
void DolphinViewContainer::slotViewUrlAboutToBeChanged(const QUrl& url)
{
// URL changes of the view can happen in two ways:
// 1. The URL navigator gets changed and will trigger the view to update its URL
@ -538,7 +551,7 @@ void DolphinViewContainer::slotViewUrlAboutToBeChanged(const KUrl& url)
}
}
void DolphinViewContainer::slotUrlNavigatorLocationAboutToBeChanged(const KUrl& url)
void DolphinViewContainer::slotUrlNavigatorLocationAboutToBeChanged(const QUrl& url)
{
// URL changes of the view can happen in two ways:
// 1. The URL navigator gets changed and will trigger the view to update its URL
@ -550,7 +563,7 @@ void DolphinViewContainer::slotUrlNavigatorLocationAboutToBeChanged(const KUrl&
}
}
void DolphinViewContainer::slotUrlNavigatorLocationChanged(const KUrl& url)
void DolphinViewContainer::slotUrlNavigatorLocationChanged(const QUrl& url)
{
slotReturnPressed();
@ -566,7 +579,7 @@ void DolphinViewContainer::slotUrlNavigatorLocationChanged(const KUrl& url)
}
} else if (KProtocolManager::isSourceProtocol(url)) {
QString app = "konqueror";
if (url.protocol().startsWith(QLatin1String("http"))) {
if (url.scheme().startsWith(QLatin1String("http"))) {
showMessage(i18nc("@info:status", // krazy:exclude=qmethods
"Dolphin does not support web pages, the web browser has been launched"),
Information);
@ -586,7 +599,7 @@ void DolphinViewContainer::slotUrlNavigatorLocationChanged(const KUrl& url)
Information);
}
const QString secureUrl = KShell::quoteArg(url.pathOrUrl());
const QString secureUrl = KShell::quoteArg(url.toDisplayString(QUrl::PreferLocalFile));
const QString command = app + ' ' + secureUrl;
KRun::runCommand(command, app, app, this);
} else {
@ -594,42 +607,7 @@ void DolphinViewContainer::slotUrlNavigatorLocationChanged(const KUrl& url)
}
}
void DolphinViewContainer::dropUrls(const KUrl& destination, QDropEvent* event)
{
m_dropDestination = destination;
const QMimeData* mimeData = event->mimeData();
QMimeData* mimeDataCopy = new QMimeData;
foreach (const QString& format, mimeData->formats()) {
mimeDataCopy->setData(format, mimeData->data(format));
}
m_dropEvent.reset(new QDropEvent(event->pos(),
event->possibleActions(),
mimeDataCopy,
event->mouseButtons(),
event->keyboardModifiers()));
QTimer::singleShot(0, this, SLOT(dropUrlsDelayed()));
}
void DolphinViewContainer::dropUrlsDelayed()
{
if (m_dropEvent.isNull()) {
return;
}
QString error;
DragAndDropHelper::dropUrls(KFileItem(), m_dropDestination, m_dropEvent.data(), error);
if (!error.isEmpty()) {
showMessage(error, Error);
}
delete m_dropEvent->mimeData();
m_dropEvent.reset();
}
void DolphinViewContainer::redirect(const KUrl& oldUrl, const KUrl& newUrl)
void DolphinViewContainer::redirect(const QUrl& oldUrl, const QUrl& newUrl)
{
Q_UNUSED(oldUrl);
const bool block = m_urlNavigator->signalsBlocked();
@ -650,7 +628,7 @@ void DolphinViewContainer::requestFocus()
m_view->setFocus();
}
void DolphinViewContainer::saveUrlCompletionMode(KGlobalSettings::Completion completion)
void DolphinViewContainer::saveUrlCompletionMode(KCompletion::CompletionMode completion)
{
GeneralSettings::setUrlCompletionMode(completion);
}
@ -673,7 +651,7 @@ void DolphinViewContainer::slotReturnPressed()
void DolphinViewContainer::startSearching()
{
const KUrl url = m_searchBox->urlForSearching();
const QUrl url = m_searchBox->urlForSearching();
if (url.isValid() && !url.isEmpty()) {
m_view->setViewPropertiesContext("search");
m_urlNavigator->setLocationUrl(url);
@ -701,10 +679,9 @@ void DolphinViewContainer::showErrorMessage(const QString& msg)
showMessage(msg, Error);
}
bool DolphinViewContainer::isSearchUrl(const KUrl& url) const
bool DolphinViewContainer::isSearchUrl(const QUrl& url) const
{
const QString protocol = url.protocol();
return protocol.contains("search");
return url.scheme().contains("search");
}
void DolphinViewContainer::saveViewState()
@ -714,5 +691,3 @@ void DolphinViewContainer::saveViewState()
m_view->saveState(stream);
m_urlNavigator->saveLocationState(locationState);
}
#include "dolphinviewcontainer.moc"

View File

@ -21,8 +21,7 @@
#define DOLPHINVIEWCONTAINER_H
#include <KFileItem>
#include <KFileItemDelegate>
#include <KGlobalSettings>
#include <KCompletion>
#include <KIO/Job>
#include <KUrlNavigator>
@ -31,9 +30,9 @@
#include <QWidget>
#include <views/dolphinview.h>
#include <config-apps.h>
#include <config-dolphin.h>
#ifdef KActivities_FOUND
#ifdef KF5Activities_FOUND
namespace KActivities {
class ResourceInstance;
}
@ -41,7 +40,7 @@ namespace KActivities {
class FilterBar;
class KMessageWidget;
class KUrl;
class QUrl;
class KUrlNavigator;
class DolphinSearchBox;
class DolphinStatusBar;
@ -70,14 +69,14 @@ public:
Error
};
DolphinViewContainer(const KUrl& url, QWidget* parent);
DolphinViewContainer(const QUrl& url, QWidget* parent);
virtual ~DolphinViewContainer();
/**
* Returns the current active URL, where all actions are applied.
* The URL navigator is synchronized with this URL.
*/
KUrl url() const;
QUrl url() const;
/**
* If \a active is true, the view container will marked as active. The active
@ -138,7 +137,7 @@ public slots:
* are emitted.
* @see DolphinViewContainer::urlNavigator()
*/
void setUrl(const KUrl& url);
void setUrl(const QUrl& url);
/**
* Popups the filter bar above the status bar if \a visible is true.
@ -205,7 +204,7 @@ private slots:
* Is called if the URL set by DolphinView::setUrl() represents
* a file and not a directory. Takes care to activate the file.
*/
void slotUrlIsFileError(const KUrl& url);
void slotUrlIsFileError(const QUrl& url);
/**
* Handles clicking on an item. If the item is a directory, the
@ -244,44 +243,26 @@ private slots:
* Is invoked if the signal urlAboutToBeChanged() from the DolphinView
* is emitted. Tries to save the view-state.
*/
void slotViewUrlAboutToBeChanged(const KUrl& url);
void slotViewUrlAboutToBeChanged(const QUrl& url);
/**
* Is invoked if the signal urlAboutToBeChanged() from the URL navigator
* is emitted. Tries to save the view-state.
*/
void slotUrlNavigatorLocationAboutToBeChanged(const KUrl& url);
void slotUrlNavigatorLocationAboutToBeChanged(const QUrl& url);
/**
* Restores the current view to show \a url and assures
* that the root URL of the view is respected.
*/
void slotUrlNavigatorLocationChanged(const KUrl& url);
/**
* Is connected with the URL navigator and drops the URLs
* above the destination \a destination.
*
* Creates a copy of \a event and invokes \a dropUrlsDelayed with a
* queued connection.
*/
void dropUrls(const KUrl& destination, QDropEvent* event);
/**
* Is invoked with a queued connection by \a dropUrls to prevent that the
* drop actions are executed in the URL navigator menu's nested event loop,
* which might cause a crash. Simply using a queued connection from the URL
* navigator to \a dropUrls would not work because the \a event pointer
* would be dangling then.
*/
void dropUrlsDelayed();
void slotUrlNavigatorLocationChanged(const QUrl& url);
/**
* Is invoked when a redirection is done and changes the
* URL of the URL navigator to \a newUrl without triggering
* a reloading of the directory.
*/
void redirect(const KUrl& oldUrl, const KUrl& newUrl);
void redirect(const QUrl& oldUrl, const QUrl& newUrl);
/** Requests the focus for the view \a m_view. */
void requestFocus();
@ -290,7 +271,7 @@ private slots:
* Saves the currently used URL completion mode of
* the URL navigator.
*/
void saveUrlCompletionMode(KGlobalSettings::Completion completion);
void saveUrlCompletionMode(KCompletion::CompletionMode completion);
void slotHistoryChanged();
@ -319,7 +300,7 @@ private:
/**
* @return True if the URL protocol is a search URL (e. g. baloosearch:// or filenamesearch://).
*/
bool isSearchUrl(const KUrl& url) const;
bool isSearchUrl(const QUrl& url) const;
/**
* Saves the state of the current view: contents position,
@ -342,10 +323,7 @@ private:
QElapsedTimer m_statusBarTimestamp; // Time in ms since last update
bool m_autoGrabFocus;
KUrl m_dropDestination;
QScopedPointer<QDropEvent> m_dropEvent;
#ifdef KActivities_FOUND
#ifdef KF5Activities_FOUND
private:
KActivities::ResourceInstance * m_activityResourceInstance;
#endif

View File

@ -20,15 +20,14 @@
***************************************************************************/
#include "filterbar.h"
#include <QBoxLayout>
#include <QKeyEvent>
#include <QLabel>
#include <QToolButton>
#include <QHBoxLayout>
#include <KIcon>
#include <KLocale>
#include <KLineEdit>
#include <KIconLoader>
#include <QIcon>
#include <KLocalizedString>
#include <QLineEdit>
FilterBar::FilterBar(QWidget* parent) :
QWidget(parent)
@ -36,27 +35,27 @@ FilterBar::FilterBar(QWidget* parent) :
// Create close button
QToolButton *closeButton = new QToolButton(this);
closeButton->setAutoRaise(true);
closeButton->setIcon(KIcon("dialog-close"));
closeButton->setIcon(QIcon::fromTheme("dialog-close"));
closeButton->setToolTip(i18nc("@info:tooltip", "Hide Filter Bar"));
connect(closeButton, SIGNAL(clicked()), this, SIGNAL(closeRequest()));
connect(closeButton, &QToolButton::clicked, this, &FilterBar::closeRequest);
// Create button to lock text when changing folders
m_lockButton = new QToolButton(this);
m_lockButton->setAutoRaise(true);
m_lockButton->setCheckable(true);
m_lockButton->setIcon(KIcon("object-unlocked"));
m_lockButton->setIcon(QIcon::fromTheme("object-unlocked"));
m_lockButton->setToolTip(i18nc("@info:tooltip", "Keep Filter When Changing Folders"));
connect(m_lockButton, SIGNAL(toggled(bool)), this, SLOT(slotToggleLockButton(bool)));
connect(m_lockButton, &QToolButton::toggled, this, &FilterBar::slotToggleLockButton);
// Create label
QLabel* filterLabel = new QLabel(i18nc("@label:textbox", "Filter:"), this);
// Create filter editor
m_filterInput = new KLineEdit(this);
m_filterInput = new QLineEdit(this);
m_filterInput->setLayoutDirection(Qt::LeftToRight);
m_filterInput->setClearButtonShown(true);
connect(m_filterInput, SIGNAL(textChanged(QString)),
this, SIGNAL(filterChanged(QString)));
m_filterInput->setClearButtonEnabled(true);
connect(m_filterInput, &QLineEdit::textChanged,
this, &FilterBar::filterChanged);
setFocusProxy(m_filterInput);
// Apply layout
@ -103,9 +102,9 @@ void FilterBar::slotUrlChanged()
void FilterBar::slotToggleLockButton(bool checked)
{
if (checked) {
m_lockButton->setIcon(KIcon("object-locked"));
m_lockButton->setIcon(QIcon::fromTheme("object-locked"));
} else {
m_lockButton->setIcon(KIcon("object-unlocked"));
m_lockButton->setIcon(QIcon::fromTheme("object-unlocked"));
clear();
}
}
@ -140,4 +139,3 @@ void FilterBar::keyReleaseEvent(QKeyEvent* event)
}
}
#include "filterbar.moc"

View File

@ -24,7 +24,7 @@
#include <QWidget>
class KLineEdit;
class QLineEdit;
class QToolButton;
/**
@ -74,11 +74,11 @@ signals:
void focusViewRequest();
protected:
virtual void showEvent(QShowEvent* event);
virtual void keyReleaseEvent(QKeyEvent* event);
virtual void showEvent(QShowEvent* event) Q_DECL_OVERRIDE;
virtual void keyReleaseEvent(QKeyEvent* event) Q_DECL_OVERRIDE;
private:
KLineEdit* m_filterInput;
QLineEdit* m_filterInput;
QToolButton* m_lockButton;
};

View File

@ -22,16 +22,12 @@
#include "kfileitemmodelrolesupdater.h"
#include "kfileitemlistwidget.h"
#include "kfileitemmodel.h"
#include <KLocale>
#include <KStringHandler>
#include "private/kpixmapmodifier.h"
#include <KDebug>
#include <KIcon>
#include <KTextEdit>
#include <QIcon>
#include <KIconLoader>
#include <QPainter>
#include <QTextLine>
#include <QTimer>
// #define KFILEITEMLISTVIEW_DEBUG
@ -62,14 +58,14 @@ KFileItemListView::KFileItemListView(QGraphicsWidget* parent) :
m_updateVisibleIndexRangeTimer = new QTimer(this);
m_updateVisibleIndexRangeTimer->setSingleShot(true);
m_updateVisibleIndexRangeTimer->setInterval(ShortInterval);
connect(m_updateVisibleIndexRangeTimer, SIGNAL(timeout()), this, SLOT(updateVisibleIndexRange()));
connect(m_updateVisibleIndexRangeTimer, &QTimer::timeout, this, &KFileItemListView::updateVisibleIndexRange);
m_updateIconSizeTimer = new QTimer(this);
m_updateIconSizeTimer->setSingleShot(true);
m_updateIconSizeTimer->setInterval(LongInterval);
connect(m_updateIconSizeTimer, SIGNAL(timeout()), this, SLOT(updateIconSize()));
connect(m_updateIconSizeTimer, &QTimer::timeout, this, &KFileItemListView::updateIconSize);
setVisibleRoles(QList<QByteArray>() << "text");
setVisibleRoles({"text"});
}
KFileItemListView::~KFileItemListView()
@ -169,7 +165,7 @@ QPixmap KFileItemListView::createDragPixmap(const KItemSet& indexes) const
foreach (int index, indexes) {
QPixmap pixmap = model()->data(index).value("iconPixmap").value<QPixmap>();
if (pixmap.isNull()) {
KIcon icon(model()->data(index).value("iconName").toString());
QIcon icon = QIcon::fromTheme(model()->data(index).value("iconName").toString());
pixmap = icon.pixmap(size, size);
} else {
KPixmapModifier::scale(pixmap, QSize(size, size));
@ -208,7 +204,7 @@ void KFileItemListView::initializeItemListWidget(KItemListWidget* item)
const KFileItem fileItem = fileItemModel->fileItem(item->index());
data.insert("iconName", fileItem.iconName());
item->setData(data, QSet<QByteArray>() << "iconName");
item->setData(data, {"iconName"});
}
}
@ -421,4 +417,3 @@ QSize KFileItemListView::availableIconSize() const
return QSize(iconSize, iconSize);
}
#include "kfileitemlistview.moc"

View File

@ -20,7 +20,7 @@
#ifndef KFILEITEMLISTVIEW_H
#define KFILEITEMLISTVIEW_H
#include <libdolphin_export.h>
#include "dolphin_export.h"
#include <kitemviews/kstandarditemlistview.h>
@ -36,7 +36,7 @@ class QTimer;
* KItemListView::setWidgetCreator() and KItemListView::setGroupHeaderCreator()
* to apply customized generators.
*/
class LIBDOLPHINPRIVATE_EXPORT KFileItemListView : public KStandardItemListView
class DOLPHIN_EXPORT KFileItemListView : public KStandardItemListView
{
Q_OBJECT
@ -72,28 +72,27 @@ public:
*/
QStringList enabledPlugins() const;
/** @reimp */
virtual QPixmap createDragPixmap(const KItemSet& indexes) const;
virtual QPixmap createDragPixmap(const KItemSet& indexes) const Q_DECL_OVERRIDE;
protected:
virtual KItemListWidgetCreatorBase* defaultWidgetCreator() const;
virtual void initializeItemListWidget(KItemListWidget* item);
virtual KItemListWidgetCreatorBase* defaultWidgetCreator() const Q_DECL_OVERRIDE;
virtual void initializeItemListWidget(KItemListWidget* item) Q_DECL_OVERRIDE;
virtual void onPreviewsShownChanged(bool shown);
virtual void onItemLayoutChanged(ItemLayout current, ItemLayout previous);
virtual void onModelChanged(KItemModelBase* current, KItemModelBase* previous);
virtual void onScrollOrientationChanged(Qt::Orientation current, Qt::Orientation previous);
virtual void onItemSizeChanged(const QSizeF& current, const QSizeF& previous);
virtual void onScrollOffsetChanged(qreal current, qreal previous);
virtual void onVisibleRolesChanged(const QList<QByteArray>& current, const QList<QByteArray>& previous);
virtual void onStyleOptionChanged(const KItemListStyleOption& current, const KItemListStyleOption& previous);
virtual void onSupportsItemExpandingChanged(bool supportsExpanding);
virtual void onTransactionBegin();
virtual void onTransactionEnd();
virtual void resizeEvent(QGraphicsSceneResizeEvent* event);
virtual void onItemLayoutChanged(ItemLayout current, ItemLayout previous) Q_DECL_OVERRIDE;
virtual void onModelChanged(KItemModelBase* current, KItemModelBase* previous) Q_DECL_OVERRIDE;
virtual void onScrollOrientationChanged(Qt::Orientation current, Qt::Orientation previous) Q_DECL_OVERRIDE;
virtual void onItemSizeChanged(const QSizeF& current, const QSizeF& previous) Q_DECL_OVERRIDE;
virtual void onScrollOffsetChanged(qreal current, qreal previous) Q_DECL_OVERRIDE;
virtual void onVisibleRolesChanged(const QList<QByteArray>& current, const QList<QByteArray>& previous) Q_DECL_OVERRIDE;
virtual void onStyleOptionChanged(const KItemListStyleOption& current, const KItemListStyleOption& previous) Q_DECL_OVERRIDE;
virtual void onSupportsItemExpandingChanged(bool supportsExpanding) Q_DECL_OVERRIDE;
virtual void onTransactionBegin() Q_DECL_OVERRIDE;
virtual void onTransactionEnd() Q_DECL_OVERRIDE;
virtual void resizeEvent(QGraphicsSceneResizeEvent* event) Q_DECL_OVERRIDE;
protected slots:
virtual void slotItemsRemoved(const KItemRangeList& itemRanges);
virtual void slotSortRoleChanged(const QByteArray& current, const QByteArray& previous);
virtual void slotItemsRemoved(const KItemRangeList& itemRanges) Q_DECL_OVERRIDE;
virtual void slotSortRoleChanged(const QByteArray& current, const QByteArray& previous) Q_DECL_OVERRIDE;
private slots:
void triggerVisibleIndexRangeUpdate();

View File

@ -21,12 +21,12 @@
#include "kfileitemmodel.h"
#include "kitemlistview.h"
#include <kmimetype.h>
#include <KDebug>
#include <KGlobal>
#include <KLocale>
#include <KLocalizedString>
#include <KIO/MetaData>
#include <QDateTime>
#include <KFormat>
#include <QMimeDatabase>
#include <QLocale>
KFileItemListWidgetInformant::KFileItemListWidgetInformant() :
KStandardItemListWidgetInformant()
@ -78,11 +78,11 @@ QString KFileItemListWidgetInformant::roleText(const QByteArray& role,
}
} else {
const KIO::filesize_t size = roleValue.value<KIO::filesize_t>();
text = KGlobal::locale()->formatByteSize(size);
text = KFormat().formatByteSize(size);
}
} else if (role == "date") {
const QDateTime dateTime = roleValue.toDateTime();
text = KGlobal::locale()->formatDateTime(dateTime);
text = QLocale().toString(dateTime, QLocale::ShortFormat);
} else {
text = KStandardItemListWidgetInformant::roleText(role, values);
}
@ -142,7 +142,8 @@ int KFileItemListWidget::selectionLength(const QString& text) const
return selectionLength;
}
const QString extension = KMimeType::extractKnownExtension(text);
QMimeDatabase db;
const QString extension = db.suffixForFileName(text);
if (extension.isEmpty()) {
// For an unknown extension just exclude the extension after
// the last point. This does not work for multiple extensions like
@ -161,4 +162,3 @@ int KFileItemListWidget::selectionLength(const QString& text) const
return selectionLength;
}
#include "kfileitemlistwidget.moc"

View File

@ -20,24 +20,24 @@
#ifndef KFILEITEMLISTWIDGET_H
#define KFILEITEMLISTWIDGET_H
#include <libdolphin_export.h>
#include "dolphin_export.h"
#include <kitemviews/kstandarditemlistwidget.h>
class LIBDOLPHINPRIVATE_EXPORT KFileItemListWidgetInformant : public KStandardItemListWidgetInformant
class DOLPHIN_EXPORT KFileItemListWidgetInformant : public KStandardItemListWidgetInformant
{
public:
KFileItemListWidgetInformant();
virtual ~KFileItemListWidgetInformant();
protected:
virtual QString itemText(int index, const KItemListView* view) const;
virtual bool itemIsLink(int index, const KItemListView* view) const;
virtual QString roleText(const QByteArray& role, const QHash<QByteArray, QVariant>& values) const;
virtual QFont customizedFontForLinks(const QFont& baseFont) const;
virtual QString itemText(int index, const KItemListView* view) const Q_DECL_OVERRIDE;
virtual bool itemIsLink(int index, const KItemListView* view) const Q_DECL_OVERRIDE;
virtual QString roleText(const QByteArray& role, const QHash<QByteArray, QVariant>& values) const Q_DECL_OVERRIDE;
virtual QFont customizedFontForLinks(const QFont& baseFont) const Q_DECL_OVERRIDE;
};
class LIBDOLPHINPRIVATE_EXPORT KFileItemListWidget : public KStandardItemListWidget
class DOLPHIN_EXPORT KFileItemListWidget : public KStandardItemListWidget
{
Q_OBJECT
@ -48,14 +48,14 @@ public:
static KItemListWidgetInformant* createInformant();
protected:
virtual bool isRoleRightAligned(const QByteArray& role) const;
virtual bool isHidden() const;
virtual QFont customizedFont(const QFont& baseFont) const;
virtual bool isRoleRightAligned(const QByteArray& role) const Q_DECL_OVERRIDE;
virtual bool isHidden() const Q_DECL_OVERRIDE;
virtual QFont customizedFont(const QFont& baseFont) const Q_DECL_OVERRIDE;
/**
* @return Selection length without MIME-type extension
*/
virtual int selectionLength(const QString& text) const;
virtual int selectionLength(const QString& text) const Q_DECL_OVERRIDE;
};
#endif

View File

@ -21,15 +21,14 @@
#include "kfileitemmodel.h"
#include <KGlobalSettings>
#include <KLocale>
#include <KStringHandler>
#include <KDebug>
#include "dolphin_generalsettings.h"
#include <KLocalizedString>
#include "dolphindebug.h"
#include "private/kfileitemmodelsortalgorithm.h"
#include "private/kfileitemmodeldirlister.h"
#include <QApplication>
#include <QMimeData>
#include <QTimer>
#include <QWidget>
@ -42,12 +41,11 @@
KFileItemModel::KFileItemModel(QObject* parent) :
KItemModelBase("text", parent),
m_dirLister(0),
m_naturalSorting(KGlobalSettings::naturalSorting()),
m_naturalSorting(GeneralSettings::naturalSorting()),
m_sortDirsFirst(true),
m_sortRole(NameRole),
m_sortingProgressPercent(-1),
m_roles(),
m_caseSensitivity(Qt::CaseInsensitive),
m_itemData(),
m_items(),
m_filter(),
@ -60,6 +58,9 @@ KFileItemModel::KFileItemModel(QObject* parent) :
m_expandedDirs(),
m_urlsToExpand()
{
m_collator.setCaseSensitivity(Qt::CaseInsensitive);
m_collator.setNumericMode(true);
m_dirLister = new KFileItemModelDirLister(this);
m_dirLister->setDelayedMimeTypes(true);
@ -68,17 +69,17 @@ KFileItemModel::KFileItemModel(QObject* parent) :
m_dirLister->setMainWindow(parentWidget->window());
}
connect(m_dirLister, SIGNAL(started(KUrl)), this, SIGNAL(directoryLoadingStarted()));
connect(m_dirLister, SIGNAL(canceled()), this, SLOT(slotCanceled()));
connect(m_dirLister, SIGNAL(completed(KUrl)), this, SLOT(slotCompleted()));
connect(m_dirLister, SIGNAL(itemsAdded(KUrl,KFileItemList)), this, SLOT(slotItemsAdded(KUrl,KFileItemList)));
connect(m_dirLister, SIGNAL(itemsDeleted(KFileItemList)), this, SLOT(slotItemsDeleted(KFileItemList)));
connect(m_dirLister, SIGNAL(refreshItems(QList<QPair<KFileItem,KFileItem> >)), this, SLOT(slotRefreshItems(QList<QPair<KFileItem,KFileItem> >)));
connect(m_dirLister, SIGNAL(clear()), this, SLOT(slotClear()));
connect(m_dirLister, SIGNAL(infoMessage(QString)), this, SIGNAL(infoMessage(QString)));
connect(m_dirLister, SIGNAL(errorMessage(QString)), this, SIGNAL(errorMessage(QString)));
connect(m_dirLister, SIGNAL(redirection(KUrl,KUrl)), this, SIGNAL(directoryRedirection(KUrl,KUrl)));
connect(m_dirLister, SIGNAL(urlIsFileError(KUrl)), this, SIGNAL(urlIsFileError(KUrl)));
connect(m_dirLister, &KFileItemModelDirLister::started, this, &KFileItemModel::directoryLoadingStarted);
connect(m_dirLister, static_cast<void(KFileItemModelDirLister::*)()>(&KFileItemModelDirLister::canceled), this, &KFileItemModel::slotCanceled);
connect(m_dirLister, static_cast<void(KFileItemModelDirLister::*)(const QUrl&)>(&KFileItemModelDirLister::completed), this, &KFileItemModel::slotCompleted);
connect(m_dirLister, &KFileItemModelDirLister::itemsAdded, this, &KFileItemModel::slotItemsAdded);
connect(m_dirLister, &KFileItemModelDirLister::itemsDeleted, this, &KFileItemModel::slotItemsDeleted);
connect(m_dirLister, &KFileItemModelDirLister::refreshItems, this, &KFileItemModel::slotRefreshItems);
connect(m_dirLister, static_cast<void(KFileItemModelDirLister::*)()>(&KFileItemModelDirLister::clear), this, &KFileItemModel::slotClear);
connect(m_dirLister, &KFileItemModelDirLister::infoMessage, this, &KFileItemModel::infoMessage);
connect(m_dirLister, &KFileItemModelDirLister::errorMessage, this, &KFileItemModel::errorMessage);
connect(m_dirLister, static_cast<void(KFileItemModelDirLister::*)(const QUrl&, const QUrl&)>(&KFileItemModelDirLister::redirection), this, &KFileItemModel::directoryRedirection);
connect(m_dirLister, &KFileItemModelDirLister::urlIsFileError, this, &KFileItemModel::urlIsFileError);
// Apply default roles that should be determined
resetRoles();
@ -94,7 +95,7 @@ KFileItemModel::KFileItemModel(QObject* parent) :
m_maximumUpdateIntervalTimer = new QTimer(this);
m_maximumUpdateIntervalTimer->setInterval(2000);
m_maximumUpdateIntervalTimer->setSingleShot(true);
connect(m_maximumUpdateIntervalTimer, SIGNAL(timeout()), this, SLOT(dispatchPendingItemsToInsert()));
connect(m_maximumUpdateIntervalTimer, &QTimer::timeout, this, &KFileItemModel::dispatchPendingItemsToInsert);
// When changing the value of an item which represents the sort-role a resorting must be
// triggered. Especially in combination with KFileItemModelRolesUpdater this might be done
@ -103,9 +104,10 @@ KFileItemModel::KFileItemModel(QObject* parent) :
m_resortAllItemsTimer = new QTimer(this);
m_resortAllItemsTimer->setInterval(500);
m_resortAllItemsTimer->setSingleShot(true);
connect(m_resortAllItemsTimer, SIGNAL(timeout()), this, SLOT(resortAllItems()));
connect(m_resortAllItemsTimer, &QTimer::timeout, this, &KFileItemModel::resortAllItems);
connect(KGlobalSettings::self(), SIGNAL(naturalSortingChanged()), this, SLOT(slotNaturalSortingChanged()));
connect(GeneralSettings::self(), &GeneralSettings::naturalSortingChanged,
this, &KFileItemModel::slotNaturalSortingChanged);
}
KFileItemModel::~KFileItemModel()
@ -115,15 +117,15 @@ KFileItemModel::~KFileItemModel()
qDeleteAll(m_pendingItemsToInsert);
}
void KFileItemModel::loadDirectory(const KUrl& url)
void KFileItemModel::loadDirectory(const QUrl &url)
{
m_dirLister->openUrl(url);
}
void KFileItemModel::refreshDirectory(const KUrl& url)
void KFileItemModel::refreshDirectory(const QUrl &url)
{
// Refresh all expanded directories first (Bug 295300)
QHashIterator<KUrl, KUrl> expandedDirs(m_expandedDirs);
QHashIterator<QUrl, QUrl> expandedDirs(m_expandedDirs);
while (expandedDirs.hasNext()) {
expandedDirs.next();
m_dirLister->openUrl(expandedDirs.value(), KDirLister::Reload);
@ -132,7 +134,7 @@ void KFileItemModel::refreshDirectory(const KUrl& url)
m_dirLister->openUrl(url, KDirLister::Reload);
}
KUrl KFileItemModel::directory() const
QUrl KFileItemModel::directory() const
{
return m_dirLister->url();
}
@ -188,8 +190,9 @@ bool KFileItemModel::setData(int index, const QHash<QByteArray, QVariant>& value
m_itemData[index]->values = currentValues;
if (changedRoles.contains("text")) {
KUrl url = m_itemData[index]->item.url();
url.setFileName(currentValues["text"].toString());
QUrl url = m_itemData[index]->item.url();
url = url.adjusted(QUrl::RemoveFilename);
url.setPath(url.path() + currentValues["text"].toString());
m_itemData[index]->item.setUrl(url);
}
@ -242,8 +245,8 @@ QMimeData* KFileItemModel::createMimeData(const KItemSet& indexes) const
// The following code has been taken from KDirModel::mimeData()
// (kdelibs/kio/kio/kdirmodel.cpp)
// Copyright (C) 2006 David Faure <faure@kde.org>
KUrl::List urls;
KUrl::List mostLocalUrls;
QList<QUrl> urls;
QList<QUrl> mostLocalUrls;
bool canUseMostLocalUrls = true;
const ItemData* lastAddedItem = 0;
@ -275,9 +278,9 @@ QMimeData* KFileItemModel::createMimeData(const KItemSet& indexes) const
const bool different = canUseMostLocalUrls && mostLocalUrls != urls;
if (different) {
urls.populateMimeData(mostLocalUrls, data);
data->setUrls(mostLocalUrls);
} else {
urls.populateMimeData(data);
data->setUrls(urls);
}
return data;
@ -336,7 +339,7 @@ QList<QPair<int, QVariant> > KFileItemModel::groups() const
}
#ifdef KFILEITEMMODEL_DEBUG
kDebug() << "[TIME] Calculating groups for" << count() << "items:" << timer.elapsed();
qCDebug(DolphinDebug) << "[TIME] Calculating groups for" << count() << "items:" << timer.elapsed();
#endif
}
@ -352,7 +355,7 @@ KFileItem KFileItemModel::fileItem(int index) const
return KFileItem();
}
KFileItem KFileItemModel::fileItem(const KUrl& url) const
KFileItem KFileItemModel::fileItem(const QUrl &url) const
{
const int indexForUrl = index(url);
if (indexForUrl >= 0) {
@ -366,10 +369,9 @@ int KFileItemModel::index(const KFileItem& item) const
return index(item.url());
}
int KFileItemModel::index(const KUrl& url) const
int KFileItemModel::index(const QUrl& url) const
{
KUrl urlToFind = url;
urlToFind.adjustPath(KUrl::RemoveTrailingSlash);
const QUrl urlToFind = url.adjusted(QUrl::StripTrailingSlash);
const int itemCount = m_itemData.count();
int itemsInHash = m_items.count();
@ -387,7 +389,7 @@ int KFileItemModel::index(const KUrl& url) const
const int blockSize = 1000;
const int currentBlockEnd = qMin(itemsInHash + blockSize, itemCount);
for (int i = itemsInHash; i < currentBlockEnd; ++i) {
const KUrl nextUrl = m_itemData.at(i)->item.url();
const QUrl nextUrl = m_itemData.at(i)->item.url();
m_items.insert(nextUrl, i);
}
@ -406,24 +408,24 @@ int KFileItemModel::index(const KUrl& url) const
if (m_items.count() != m_itemData.count() && printDebugInfo) {
printDebugInfo = false;
kWarning() << "The model is in an inconsistent state.";
kWarning() << "m_items.count() ==" << m_items.count();
kWarning() << "m_itemData.count() ==" << m_itemData.count();
qCWarning(DolphinDebug) << "The model is in an inconsistent state.";
qCWarning(DolphinDebug) << "m_items.count() ==" << m_items.count();
qCWarning(DolphinDebug) << "m_itemData.count() ==" << m_itemData.count();
// Check if there are multiple items with the same URL.
QMultiHash<KUrl, int> indexesForUrl;
QMultiHash<QUrl, int> indexesForUrl;
for (int i = 0; i < m_itemData.count(); ++i) {
indexesForUrl.insert(m_itemData.at(i)->item.url(), i);
}
foreach (const KUrl& url, indexesForUrl.uniqueKeys()) {
foreach (const QUrl& url, indexesForUrl.uniqueKeys()) {
if (indexesForUrl.count(url) > 1) {
kWarning() << "Multiple items found with the URL" << url;
qCWarning(DolphinDebug) << "Multiple items found with the URL" << url;
foreach (int index, indexesForUrl.values(url)) {
const ItemData* data = m_itemData.at(index);
kWarning() << "index" << index << ":" << data->item;
qCWarning(DolphinDebug) << "index" << index << ":" << data->item;
if (data->parent) {
kWarning() << "parent" << data->parent->item;
qCWarning(DolphinDebug) << "parent" << data->parent->item;
}
}
}
@ -510,15 +512,15 @@ bool KFileItemModel::setExpanded(int index, bool expanded)
}
const KFileItem item = m_itemData.at(index)->item;
const KUrl url = item.url();
const KUrl targetUrl = item.targetUrl();
const QUrl url = item.url();
const QUrl targetUrl = item.targetUrl();
if (expanded) {
m_expandedDirs.insert(targetUrl, url);
m_dirLister->openUrl(url, KDirLister::Keep);
const KUrl::List previouslyExpandedChildren = m_itemData.at(index)->values.value("previouslyExpandedChildren").value<KUrl::List>();
foreach (const KUrl& url, previouslyExpandedChildren) {
m_urlsToExpand.insert(url);
const QVariantList previouslyExpandedChildren = m_itemData.at(index)->values.value("previouslyExpandedChildren").value<QVariantList>();
foreach (const QVariant& var, previouslyExpandedChildren) {
m_urlsToExpand.insert(var.toUrl());
}
} else {
// Note that there might be (indirect) children of the folder which is to be collapsed in
@ -540,14 +542,14 @@ bool KFileItemModel::setExpanded(int index, bool expanded)
const int itemCount = m_itemData.count();
const int firstChildIndex = index + 1;
KUrl::List expandedChildren;
QVariantList expandedChildren;
int childIndex = firstChildIndex;
while (childIndex < itemCount && expandedParentsCount(childIndex) > parentLevel) {
ItemData* itemData = m_itemData.at(childIndex);
if (itemData->values.value("isExpanded").toBool()) {
const KUrl targetUrl = itemData->item.targetUrl();
const KUrl url = itemData->item.url();
const QUrl targetUrl = itemData->item.targetUrl();
const QUrl url = itemData->item.url();
m_expandedDirs.remove(targetUrl);
m_dirLister->stop(url); // TODO: try to unit-test this, see https://bugs.kde.org/show_bug.cgi?id=332102#c11
expandedChildren.append(targetUrl);
@ -591,17 +593,17 @@ int KFileItemModel::expandedParentsCount(int index) const
return 0;
}
QSet<KUrl> KFileItemModel::expandedDirectories() const
QSet<QUrl> KFileItemModel::expandedDirectories() const
{
return m_expandedDirs.values().toSet();
}
void KFileItemModel::restoreExpandedDirectories(const QSet<KUrl>& urls)
void KFileItemModel::restoreExpandedDirectories(const QSet<QUrl> &urls)
{
m_urlsToExpand = urls;
}
void KFileItemModel::expandParentDirectories(const KUrl& url)
void KFileItemModel::expandParentDirectories(const QUrl &url)
{
const int pos = m_dirLister->url().path().length();
@ -609,17 +611,17 @@ void KFileItemModel::expandParentDirectories(const KUrl& url)
// expanded is added to m_urlsToExpand. KDirLister
// does not care whether the parent-URL has already been
// expanded.
KUrl urlToExpand = m_dirLister->url();
QUrl urlToExpand = m_dirLister->url();
const QStringList subDirs = url.path().mid(pos).split(QDir::separator());
for (int i = 0; i < subDirs.count() - 1; ++i) {
urlToExpand.addPath(subDirs.at(i));
urlToExpand.setPath(urlToExpand.path() + '/' + subDirs.at(i));
m_urlsToExpand.insert(urlToExpand);
}
// KDirLister::open() must called at least once to trigger an initial
// loading. The pending URLs that must be restored are handled
// in slotCompleted().
QSetIterator<KUrl> it2(m_urlsToExpand);
QSetIterator<QUrl> it2(m_urlsToExpand);
while (it2.hasNext()) {
const int idx = index(it2.next());
if (idx >= 0 && !isExpanded(idx)) {
@ -793,14 +795,14 @@ void KFileItemModel::resortAllItems()
#ifdef KFILEITEMMODEL_DEBUG
QElapsedTimer timer;
timer.start();
kDebug() << "===========================================================";
kDebug() << "Resorting" << itemCount << "items";
qCDebug(DolphinDebug) << "===========================================================";
qCDebug(DolphinDebug) << "Resorting" << itemCount << "items";
#endif
// Remember the order of the current URLs so
// that it can be determined which indexes have
// been moved because of the resorting.
QList<KUrl> oldUrls;
QList<QUrl> oldUrls;
oldUrls.reserve(itemCount);
foreach (const ItemData* itemData, m_itemData) {
oldUrls.append(itemData->item.url());
@ -856,7 +858,7 @@ void KFileItemModel::resortAllItems()
}
#ifdef KFILEITEMMODEL_DEBUG
kDebug() << "[TIME] Resorting of" << itemCount << "items:" << timer.elapsed();
qCDebug(DolphinDebug) << "[TIME] Resorting of" << itemCount << "items:" << timer.elapsed();
#endif
}
@ -869,7 +871,7 @@ void KFileItemModel::slotCompleted()
// Note that the parent folder must be expanded before any of its subfolders become visible.
// Therefore, some URLs in m_restoredExpandedUrls might not be visible yet
// -> we expand the first visible URL we find in m_restoredExpandedUrls.
foreach (const KUrl& url, m_urlsToExpand) {
foreach (const QUrl& url, m_urlsToExpand) {
const int indexForUrl = index(url);
if (indexForUrl >= 0) {
m_urlsToExpand.remove(url);
@ -897,16 +899,15 @@ void KFileItemModel::slotCanceled()
emit directoryLoadingCanceled();
}
void KFileItemModel::slotItemsAdded(const KUrl& directoryUrl, const KFileItemList& items)
void KFileItemModel::slotItemsAdded(const QUrl &directoryUrl, const KFileItemList& items)
{
Q_ASSERT(!items.isEmpty());
KUrl parentUrl;
QUrl parentUrl;
if (m_expandedDirs.contains(directoryUrl)) {
parentUrl = m_expandedDirs.value(directoryUrl);
} else {
parentUrl = directoryUrl;
parentUrl.adjustPath(KUrl::RemoveTrailingSlash);
parentUrl = directoryUrl.adjusted(QUrl::StripTrailingSlash);
}
if (m_requestRole[ExpandedParentsCountRole]) {
@ -1012,7 +1013,7 @@ void KFileItemModel::slotRefreshItems(const QList<QPair<KFileItem, KFileItem> >&
{
Q_ASSERT(!items.isEmpty());
#ifdef KFILEITEMMODEL_DEBUG
kDebug() << "Refreshing" << items.count() << "items";
qCDebug(DolphinDebug) << "Refreshing" << items.count() << "items";
#endif
// Get the indexes of all items that have been refreshed
@ -1078,7 +1079,7 @@ void KFileItemModel::slotRefreshItems(const QList<QPair<KFileItem, KFileItem> >&
void KFileItemModel::slotClear()
{
#ifdef KFILEITEMMODEL_DEBUG
kDebug() << "Clearing all items";
qCDebug(DolphinDebug) << "Clearing all items";
#endif
qDeleteAll(m_filteredItems.values());
@ -1104,7 +1105,7 @@ void KFileItemModel::slotClear()
void KFileItemModel::slotNaturalSortingChanged()
{
m_naturalSorting = KGlobalSettings::naturalSorting();
m_naturalSorting = GeneralSettings::naturalSorting();
resortAllItems();
}
@ -1125,8 +1126,8 @@ void KFileItemModel::insertItems(QList<ItemData*>& newItems)
#ifdef KFILEITEMMODEL_DEBUG
QElapsedTimer timer;
timer.start();
kDebug() << "===========================================================";
kDebug() << "Inserting" << newItems.count() << "items";
qCDebug(DolphinDebug) << "===========================================================";
qCDebug(DolphinDebug) << "Inserting" << newItems.count() << "items";
#endif
m_groups.clear();
@ -1143,7 +1144,7 @@ void KFileItemModel::insertItems(QList<ItemData*>& newItems)
sort(newItems.begin(), newItems.end());
#ifdef KFILEITEMMODEL_DEBUG
kDebug() << "[TIME] Sorting:" << timer.elapsed();
qCDebug(DolphinDebug) << "[TIME] Sorting:" << timer.elapsed();
#endif
KItemRangeList itemRanges;
@ -1172,7 +1173,7 @@ void KFileItemModel::insertItems(QList<ItemData*>& newItems)
while (sourceIndexNewItems >= 0) {
ItemData* newItem = newItems.at(sourceIndexNewItems);
if (sourceIndexExistingItems >= 0 && lessThan(newItem, m_itemData.at(sourceIndexExistingItems))) {
if (sourceIndexExistingItems >= 0 && lessThan(newItem, m_itemData.at(sourceIndexExistingItems), m_collator)) {
// Move an existing item to its new position. If any new items
// are behind it, push the item range to itemRanges.
if (rangeCount > 0) {
@ -1201,13 +1202,13 @@ void KFileItemModel::insertItems(QList<ItemData*>& newItems)
}
// The indexes in m_items are not correct anymore. Therefore, we clear m_items.
// It will be re-populated with the updated indices if index(const KUrl&) is called.
// It will be re-populated with the updated indices if index(const QUrl&) is called.
m_items.clear();
emit itemsInserted(itemRanges);
#ifdef KFILEITEMMODEL_DEBUG
kDebug() << "[TIME] Inserting of" << newItems.count() << "items:" << timer.elapsed();
qCDebug(DolphinDebug) << "[TIME] Inserting of" << newItems.count() << "items:" << timer.elapsed();
#endif
}
@ -1254,13 +1255,13 @@ void KFileItemModel::removeItems(const KItemRangeList& itemRanges, RemoveItemsBe
m_itemData.erase(m_itemData.end() - removedItemsCount, m_itemData.end());
// The indexes in m_items are not correct anymore. Therefore, we clear m_items.
// It will be re-populated with the updated indices if index(const KUrl&) is called.
// It will be re-populated with the updated indices if index(const QUrl&) is called.
m_items.clear();
emit itemsRemoved(itemRanges);
}
QList<KFileItemModel::ItemData*> KFileItemModel::createItemDataList(const KUrl& parentUrl, const KFileItemList& items) const
QList<KFileItemModel::ItemData*> KFileItemModel::createItemDataList(const QUrl& parentUrl, const KFileItemList& items) const
{
if (m_sortRole == TypeRole) {
// Try to resolve the MIME-types synchronously to prevent a reordering of
@ -1388,14 +1389,14 @@ void KFileItemModel::emitItemsChangedAndTriggerResorting(const KItemRangeList& i
// (b) the successor of the last item is "lessThan" the last item, or
// (c) the internal order of the items in the range is incorrect.
if (first > 0
&& lessThan(m_itemData.at(first), m_itemData.at(first - 1))) {
&& lessThan(m_itemData.at(first), m_itemData.at(first - 1), m_collator)) {
needsResorting = true;
} else if (last < count() - 1
&& lessThan(m_itemData.at(last + 1), m_itemData.at(last))) {
&& lessThan(m_itemData.at(last + 1), m_itemData.at(last), m_collator)) {
needsResorting = true;
} else {
for (int index = first; index < last; ++index) {
if (lessThan(m_itemData.at(index + 1), m_itemData.at(index))) {
if (lessThan(m_itemData.at(index + 1), m_itemData.at(index), m_collator)) {
needsResorting = true;
break;
}
@ -1510,8 +1511,8 @@ QHash<QByteArray, QVariant> KFileItemModel::retrieveData(const KFileItem& item,
// Don't use KFileItem::timeString() as this is too expensive when
// having several thousands of items. Instead the formatting of the
// date-time will be done on-demand by the view when the date will be shown.
const KDateTime dateTime = item.time(KFileItem::ModificationTime);
data.insert(sharedValue("date"), dateTime.dateTime());
const QDateTime dateTime = item.time(KFileItem::ModificationTime);
data.insert(sharedValue("date"), dateTime);
}
if (m_requestRole[PermissionsRole]) {
@ -1536,7 +1537,7 @@ QHash<QByteArray, QVariant> KFileItemModel::retrieveData(const KFileItem& item,
if (m_requestRole[PathRole]) {
QString path;
if (item.url().protocol() == QLatin1String("trash")) {
if (item.url().scheme() == QLatin1String("trash")) {
path = item.entry().stringValue(KIO::UDSEntry::UDS_EXTRA);
} else {
// For performance reasons cache the home-path in a static QString
@ -1582,7 +1583,7 @@ QHash<QByteArray, QVariant> KFileItemModel::retrieveData(const KFileItem& item,
return data;
}
bool KFileItemModel::lessThan(const ItemData* a, const ItemData* b) const
bool KFileItemModel::lessThan(const ItemData* a, const ItemData* b, const QCollator& collator) const
{
int result = 0;
@ -1627,7 +1628,7 @@ bool KFileItemModel::lessThan(const ItemData* a, const ItemData* b) const
}
}
result = sortRoleCompare(a, b);
result = sortRoleCompare(a, b, collator);
return (sortOrder() == Qt::AscendingOrder) ? result < 0 : result > 0;
}
@ -1638,24 +1639,36 @@ bool KFileItemModel::lessThan(const ItemData* a, const ItemData* b) const
class KFileItemModelLessThan
{
public:
KFileItemModelLessThan(const KFileItemModel* model) :
m_model(model)
KFileItemModelLessThan(const KFileItemModel* model, const QCollator& collator) :
m_model(model),
m_collator(collator)
{
}
KFileItemModelLessThan(const KFileItemModelLessThan& other) :
m_model(other.m_model),
m_collator()
{
m_collator.setCaseSensitivity(other.m_collator.caseSensitivity());
m_collator.setIgnorePunctuation(other.m_collator.ignorePunctuation());
m_collator.setLocale(other.m_collator.locale());
m_collator.setNumericMode(other.m_collator.numericMode());
}
bool operator()(const KFileItemModel::ItemData* a, const KFileItemModel::ItemData* b) const
{
return m_model->lessThan(a, b);
return m_model->lessThan(a, b, m_collator);
}
private:
const KFileItemModel* m_model;
QCollator m_collator;
};
void KFileItemModel::sort(QList<KFileItemModel::ItemData*>::iterator begin,
QList<KFileItemModel::ItemData*>::iterator end) const
{
KFileItemModelLessThan lessThan(this);
KFileItemModelLessThan lessThan(this, m_collator);
if (m_sortRole == NameRole) {
// Sorting by name can be expensive, in particular if natural sorting is
@ -1670,7 +1683,7 @@ void KFileItemModel::sort(QList<KFileItemModel::ItemData*>::iterator begin,
}
}
int KFileItemModel::sortRoleCompare(const ItemData* a, const ItemData* b) const
int KFileItemModel::sortRoleCompare(const ItemData* a, const ItemData* b, const QCollator& collator) const
{
const KFileItem& itemA = a->item;
const KFileItem& itemB = b->item;
@ -1715,8 +1728,8 @@ int KFileItemModel::sortRoleCompare(const ItemData* a, const ItemData* b) const
}
case DateRole: {
const KDateTime dateTimeA = itemA.time(KFileItem::ModificationTime);
const KDateTime dateTimeB = itemB.time(KFileItem::ModificationTime);
const QDateTime dateTimeA = itemA.time(KFileItem::ModificationTime);
const QDateTime dateTimeB = itemB.time(KFileItem::ModificationTime);
if (dateTimeA < dateTimeB) {
result = -1;
} else if (dateTimeA > dateTimeB) {
@ -1733,9 +1746,8 @@ int KFileItemModel::sortRoleCompare(const ItemData* a, const ItemData* b) const
case ImageSizeRole: {
// Alway use a natural comparing to interpret the numbers of a string like
// "1600 x 1200" for having a correct sorting.
result = KStringHandler::naturalCompare(a->values.value("imageSize").toString(),
b->values.value("imageSize").toString(),
Qt::CaseSensitive);
result = collator.compare(a->values.value("imageSize").toString(),
b->values.value("imageSize").toString());
break;
}
@ -1754,14 +1766,13 @@ int KFileItemModel::sortRoleCompare(const ItemData* a, const ItemData* b) const
}
// Fallback #1: Compare the text of the items
result = stringCompare(itemA.text(), itemB.text());
result = stringCompare(itemA.text(), itemB.text(), collator);
if (result != 0) {
return result;
}
// Fallback #2: KFileItem::text() may not be unique in case UDS_DISPLAY_NAME is used
result = stringCompare(itemA.name(m_caseSensitivity == Qt::CaseInsensitive),
itemB.name(m_caseSensitivity == Qt::CaseInsensitive));
result = stringCompare(itemA.name(), itemB.name(), collator);
if (result != 0) {
return result;
}
@ -1772,26 +1783,21 @@ int KFileItemModel::sortRoleCompare(const ItemData* a, const ItemData* b) const
return QString::compare(itemA.url().url(), itemB.url().url(), Qt::CaseSensitive);
}
int KFileItemModel::stringCompare(const QString& a, const QString& b) const
int KFileItemModel::stringCompare(const QString& a, const QString& b, const QCollator& collator) const
{
// Taken from KDirSortFilterProxyModel (kdelibs/kfile/kdirsortfilterproxymodel.*)
// Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at>
// Copyright (C) 2006 by Dominic Battre <dominic@battre.de>
// Copyright (C) 2006 by Martin Pool <mbp@canonical.com>
if (m_caseSensitivity == Qt::CaseInsensitive) {
const int result = m_naturalSorting ? KStringHandler::naturalCompare(a, b, Qt::CaseInsensitive)
: QString::compare(a, b, Qt::CaseInsensitive);
if (result != 0) {
// Only return the result, if the strings are not equal. If they are equal by a case insensitive
// comparison, still a deterministic sort order is required. A case sensitive
// comparison is done as fallback.
return result;
}
if (m_naturalSorting) {
return collator.compare(a, b);
}
return m_naturalSorting ? KStringHandler::naturalCompare(a, b, Qt::CaseSensitive)
: QString::compare(a, b, Qt::CaseSensitive);
const int result = QString::compare(a, b, collator.caseSensitivity());
if (result != 0 || collator.caseSensitivity() == Qt::CaseSensitive) {
// Only return the result, if the strings are not equal. If they are equal by a case insensitive
// comparison, still a deterministic sort order is required. A case sensitive
// comparison is done as fallback.
return result;
}
return QString::compare(a, b, Qt::CaseSensitive);
}
bool KFileItemModel::useMaximumUpdateInterval() const
@ -1799,11 +1805,6 @@ bool KFileItemModel::useMaximumUpdateInterval() const
return !m_dirLister->url().isLocalFile();
}
static bool localeAwareLessThan(const QChar& c1, const QChar& c2)
{
return QString::localeAwareCompare(c1, c2) < 0;
}
QList<QPair<int, QVariant> > KFileItemModel::nameRoleGroups() const
{
Q_ASSERT(!m_itemData.isEmpty());
@ -1837,6 +1838,10 @@ QList<QPair<int, QVariant> > KFileItemModel::nameRoleGroups() const
}
}
auto localeAwareLessThan = [this](const QChar& c1, const QChar& c2) -> bool {
return m_collator.compare(c1, c2) < 0;
};
std::vector<QChar>::iterator it = std::lower_bound(lettersAtoZ.begin(), lettersAtoZ.end(), newFirstChar, localeAwareLessThan);
if (it != lettersAtoZ.end()) {
if (localeAwareLessThan(newFirstChar, *it) && it != lettersAtoZ.begin()) {
@ -1908,7 +1913,7 @@ QList<QPair<int, QVariant> > KFileItemModel::dateRoleGroups() const
const int maxIndex = count() - 1;
QList<QPair<int, QVariant> > groups;
const QDate currentDate = KDateTime::currentLocalDateTime().date();
const QDate currentDate = QDate::currentDate();
QDate previousModifiedDate;
QString groupValue;
@ -1917,7 +1922,7 @@ QList<QPair<int, QVariant> > KFileItemModel::dateRoleGroups() const
continue;
}
const KDateTime modifiedTime = m_itemData.at(i)->item.time(KFileItem::ModificationTime);
const QDateTime modifiedTime = m_itemData.at(i)->item.time(KFileItem::ModificationTime);
const QDate modifiedDate = modifiedTime.date();
if (modifiedDate == previousModifiedDate) {
// The current item is in the same group as the previous item
@ -1934,7 +1939,7 @@ QList<QPair<int, QVariant> > KFileItemModel::dateRoleGroups() const
switch (daysDistance) {
case 0: newGroupValue = i18nc("@title:group Date", "Today"); break;
case 1: newGroupValue = i18nc("@title:group Date", "Yesterday"); break;
default: newGroupValue = modifiedTime.toString(i18nc("@title:group The week day name: %A", "%A"));
default: newGroupValue = modifiedTime.toString(i18nc("@title:group The week day name: dddd", "dddd"));
}
break;
case 1:
@ -1957,20 +1962,20 @@ QList<QPair<int, QVariant> > KFileItemModel::dateRoleGroups() const
const QDate lastMonthDate = currentDate.addMonths(-1);
if (lastMonthDate.year() == modifiedDate.year() && lastMonthDate.month() == modifiedDate.month()) {
if (daysDistance == 1) {
newGroupValue = modifiedTime.toString(i18nc("@title:group Date: %B is full month name in current locale, and %Y is full year number", "Yesterday (%B, %Y)"));
newGroupValue = modifiedTime.toString(i18nc("@title:group Date: MMMM is full month name in current locale, and yyyy is full year number", "'Yesterday' (MMMM, yyyy)"));
} else if (daysDistance <= 7) {
newGroupValue = modifiedTime.toString(i18nc("@title:group The week day name: %A, %B is full month name in current locale, and %Y is full year number", "%A (%B, %Y)"));
newGroupValue = modifiedTime.toString(i18nc("@title:group The week day name: dddd, MMMM is full month name in current locale, and yyyy is full year number", "dddd (MMMM, yyyy)"));
} else if (daysDistance <= 7 * 2) {
newGroupValue = modifiedTime.toString(i18nc("@title:group Date: %B is full month name in current locale, and %Y is full year number", "One Week Ago (%B, %Y)"));
newGroupValue = modifiedTime.toString(i18nc("@title:group Date: MMMM is full month name in current locale, and yyyy is full year number", "'One Week Ago' (MMMM, yyyy)"));
} else if (daysDistance <= 7 * 3) {
newGroupValue = modifiedTime.toString(i18nc("@title:group Date: %B is full month name in current locale, and %Y is full year number", "Two Weeks Ago (%B, %Y)"));
newGroupValue = modifiedTime.toString(i18nc("@title:group Date: MMMM is full month name in current locale, and yyyy is full year number", "'Two Weeks Ago' (MMMM, yyyy)"));
} else if (daysDistance <= 7 * 4) {
newGroupValue = modifiedTime.toString(i18nc("@title:group Date: %B is full month name in current locale, and %Y is full year number", "Three Weeks Ago (%B, %Y)"));
newGroupValue = modifiedTime.toString(i18nc("@title:group Date: MMMM is full month name in current locale, and yyyy is full year number", "'Three Weeks Ago' (MMMM, yyyy)"));
} else {
newGroupValue = modifiedTime.toString(i18nc("@title:group Date: %B is full month name in current locale, and %Y is full year number", "Earlier on %B, %Y"));
newGroupValue = modifiedTime.toString(i18nc("@title:group Date: MMMM is full month name in current locale, and yyyy is full year number", "'Earlier on' MMMM, yyyy"));
}
} else {
newGroupValue = modifiedTime.toString(i18nc("@title:group The month and year: %B is full month name in current locale, and %Y is full year number", "%B, %Y"));
newGroupValue = modifiedTime.toString(i18nc("@title:group The month and year: MMMM is full month name in current locale, and yyyy is full year number", "MMMM, yyyy"));
}
}
@ -2004,7 +2009,7 @@ QList<QPair<int, QVariant> > KFileItemModel::permissionRoleGroups() const
}
permissionsString = newPermissionsString;
const QFileInfo info(itemData->item.url().pathOrUrl());
const QFileInfo info(itemData->item.url().toLocalFile());
// Set user string
QString user;
@ -2199,7 +2204,7 @@ QByteArray KFileItemModel::sharedValue(const QByteArray& value)
bool KFileItemModel::isConsistent() const
{
// m_items may contain less items than m_itemData because m_items
// is populated lazily, see KFileItemModel::index(const KUrl& url).
// is populated lazily, see KFileItemModel::index(const QUrl& url).
if (m_items.count() > m_itemData.count()) {
return false;
}
@ -2208,19 +2213,19 @@ bool KFileItemModel::isConsistent() const
// Check if m_items and m_itemData are consistent.
const KFileItem item = fileItem(i);
if (item.isNull()) {
qWarning() << "Item" << i << "is null";
qCWarning(DolphinDebug) << "Item" << i << "is null";
return false;
}
const int itemIndex = index(item);
if (itemIndex != i) {
qWarning() << "Item" << i << "has a wrong index:" << itemIndex;
qCWarning(DolphinDebug) << "Item" << i << "has a wrong index:" << itemIndex;
return false;
}
// Check if the items are sorted correctly.
if (i > 0 && !lessThan(m_itemData.at(i - 1), m_itemData.at(i))) {
qWarning() << "The order of items" << i - 1 << "and" << i << "is wrong:"
if (i > 0 && !lessThan(m_itemData.at(i - 1), m_itemData.at(i), m_collator)) {
qCWarning(DolphinDebug) << "The order of items" << i - 1 << "and" << i << "is wrong:"
<< fileItem(i - 1) << fileItem(i);
return false;
}
@ -2230,13 +2235,13 @@ bool KFileItemModel::isConsistent() const
const ItemData* parent = data->parent;
if (parent) {
if (expandedParentsCount(data) != expandedParentsCount(parent) + 1) {
qWarning() << "expandedParentsCount is inconsistent for parent" << parent->item << "and child" << data->item;
qCWarning(DolphinDebug) << "expandedParentsCount is inconsistent for parent" << parent->item << "and child" << data->item;
return false;
}
const int parentIndex = index(parent->item);
if (parentIndex >= i) {
qWarning() << "Index" << parentIndex << "of parent" << parent->item << "is not smaller than index" << i << "of child" << data->item;
qCWarning(DolphinDebug) << "Index" << parentIndex << "of parent" << parent->item << "is not smaller than index" << i << "of child" << data->item;
return false;
}
}
@ -2245,4 +2250,3 @@ bool KFileItemModel::isConsistent() const
return true;
}
#include "kfileitemmodel.moc"

View File

@ -20,12 +20,13 @@
#ifndef KFILEITEMMODEL_H
#define KFILEITEMMODEL_H
#include <libdolphin_export.h>
#include <KFileItemList>
#include <KUrl>
#include "dolphin_export.h"
#include <KFileItem>
#include <QUrl>
#include <kitemviews/kitemmodelbase.h>
#include <kitemviews/private/kfileitemmodelfilter.h>
#include <QCollator>
#include <QHash>
#include <QSet>
@ -42,7 +43,7 @@ class QTimer;
* Recursive expansion of sub-directories is supported by
* KFileItemModel::setExpanded().
*/
class LIBDOLPHINPRIVATE_EXPORT KFileItemModel : public KItemModelBase
class DOLPHIN_EXPORT KFileItemModel : public KItemModelBase
{
Q_OBJECT
@ -56,13 +57,13 @@ public:
* indicate the current state of the loading process. The items
* of the directory are added after the loading has been completed.
*/
void loadDirectory(const KUrl& url);
void loadDirectory(const QUrl& url);
/**
* Throws away all currently loaded items and refreshes the directory
* by reloading all items again.
*/
void refreshDirectory(const KUrl& url);
void refreshDirectory(const QUrl& url);
/**
* @return Parent directory of the items that are shown. In case
@ -70,7 +71,7 @@ public:
* the root-parent of all items.
* @see rootItem()
*/
KUrl directory() const;
QUrl directory() const;
/**
* Cancels the loading of a directory which has been started by either
@ -78,9 +79,9 @@ public:
*/
void cancelDirectoryLoading();
virtual int count() const;
virtual QHash<QByteArray, QVariant> data(int index) const;
virtual bool setData(int index, const QHash<QByteArray, QVariant>& values);
virtual int count() const Q_DECL_OVERRIDE;
virtual QHash<QByteArray, QVariant> data(int index) const Q_DECL_OVERRIDE;
virtual bool setData(int index, const QHash<QByteArray, QVariant>& values) Q_DECL_OVERRIDE;
/**
* Sets a separate sorting with directories first (true) or a mixed
@ -99,20 +100,15 @@ public:
void setShowDirectoriesOnly(bool enabled);
bool showDirectoriesOnly() const;
/** @reimp */
virtual QMimeData* createMimeData(const KItemSet& indexes) const;
virtual QMimeData* createMimeData(const KItemSet& indexes) const Q_DECL_OVERRIDE;
/** @reimp */
virtual int indexForKeyboardSearch(const QString& text, int startFromIndex = 0) const;
virtual int indexForKeyboardSearch(const QString& text, int startFromIndex = 0) const Q_DECL_OVERRIDE;
/** @reimp */
virtual bool supportsDropping(int index) const;
virtual bool supportsDropping(int index) const Q_DECL_OVERRIDE;
/** @reimp */
virtual QString roleDescription(const QByteArray& role) const;
virtual QString roleDescription(const QByteArray& role) const Q_DECL_OVERRIDE;
/** @reimp */
virtual QList<QPair<int, QVariant> > groups() const;
virtual QList<QPair<int, QVariant> > groups() const Q_DECL_OVERRIDE;
/**
* @return The file-item for the index \a index. If the index is in a valid
@ -126,7 +122,7 @@ public:
* URL is found KFileItem::isNull() will be true for the returned
* file-item. The runtime complexity of this call is O(1).
*/
KFileItem fileItem(const KUrl& url) const;
KFileItem fileItem(const QUrl& url) const;
/**
* @return The index for the file-item \a item. -1 is returned if no file-item
@ -139,7 +135,7 @@ public:
* @return The index for the URL \a url. -1 is returned if no file-item
* is found. The amortized runtime complexity of this call is O(1).
*/
int index(const KUrl& url) const;
int index(const QUrl &url) const;
/**
* @return Root item of all items representing the item
@ -158,24 +154,24 @@ public:
void setRoles(const QSet<QByteArray>& roles);
QSet<QByteArray> roles() const;
virtual bool setExpanded(int index, bool expanded);
virtual bool isExpanded(int index) const;
virtual bool isExpandable(int index) const;
virtual int expandedParentsCount(int index) const;
virtual bool setExpanded(int index, bool expanded) Q_DECL_OVERRIDE;
virtual bool isExpanded(int index) const Q_DECL_OVERRIDE;
virtual bool isExpandable(int index) const Q_DECL_OVERRIDE;
virtual int expandedParentsCount(int index) const Q_DECL_OVERRIDE;
QSet<KUrl> expandedDirectories() const;
QSet<QUrl> expandedDirectories() const;
/**
* Marks the URLs in \a urls as sub-directories which were expanded previously.
* After calling loadDirectory() or refreshDirectory() the marked sub-directories
* will be expanded step-by-step.
*/
void restoreExpandedDirectories(const QSet<KUrl>& urls);
void restoreExpandedDirectories(const QSet<QUrl>& urls);
/**
* Expands all parent-directories of the item \a url.
*/
void expandParentDirectories(const KUrl& url);
void expandParentDirectories(const QUrl& url);
void setNameFilter(const QString& nameFilter);
QString nameFilter() const;
@ -251,18 +247,18 @@ signals:
* Is emitted if a redirection from the current URL \a oldUrl
* to the new URL \a newUrl has been done.
*/
void directoryRedirection(const KUrl& oldUrl, const KUrl& newUrl);
void directoryRedirection(const QUrl& oldUrl, const QUrl& newUrl);
/**
* Is emitted when the URL passed by KFileItemModel::setUrl() represents a file.
* In this case no signal errorMessage() will be emitted.
*/
void urlIsFileError(const KUrl& url);
void urlIsFileError(const QUrl& url);
protected:
virtual void onGroupedSortingChanged(bool current);
virtual void onSortRoleChanged(const QByteArray& current, const QByteArray& previous);
virtual void onSortOrderChanged(Qt::SortOrder current, Qt::SortOrder previous);
virtual void onGroupedSortingChanged(bool current) Q_DECL_OVERRIDE;
virtual void onSortRoleChanged(const QByteArray& current, const QByteArray& previous) Q_DECL_OVERRIDE;
virtual void onSortOrderChanged(Qt::SortOrder current, Qt::SortOrder previous) Q_DECL_OVERRIDE;
private slots:
/**
@ -273,7 +269,7 @@ private slots:
void slotCompleted();
void slotCanceled();
void slotItemsAdded(const KUrl& directoryUrl, const KFileItemList& items);
void slotItemsAdded(const QUrl& directoryUrl, const KFileItemList& items);
void slotItemsDeleted(const KFileItemList& items);
void slotRefreshItems(const QList<QPair<KFileItem, KFileItem> >& items);
void slotClear();
@ -317,7 +313,7 @@ private:
* Note that the ItemData instances are created dynamically and
* must be deleted by the caller.
*/
QList<ItemData*> createItemDataList(const KUrl& parentUrl, const KFileItemList& items) const;
QList<ItemData*> createItemDataList(const QUrl& parentUrl, const KFileItemList& items) const;
/**
* Prepares the items for sorting. Normally, the hash 'values' in ItemData is filled
@ -366,7 +362,7 @@ private:
* @return True if the item-data \a a should be ordered before the item-data
* \b. The item-data may have different parent-items.
*/
bool lessThan(const ItemData* a, const ItemData* b) const;
bool lessThan(const ItemData* a, const ItemData* b, const QCollator& collator) const;
/**
* Sorts the items between \a begin and \a end using the comparison
@ -379,9 +375,9 @@ private:
* the passed item-data using m_sortRole as criteria. Both items must
* have the same parent item, otherwise the comparison will be wrong.
*/
int sortRoleCompare(const ItemData* a, const ItemData* b) const;
int sortRoleCompare(const ItemData* a, const ItemData* b, const QCollator& collator) const;
int stringCompare(const QString& a, const QString& b) const;
int stringCompare(const QString& a, const QString& b, const QCollator& collator) const;
bool useMaximumUpdateInterval() const;
@ -460,21 +456,21 @@ private:
private:
KFileItemModelDirLister* m_dirLister;
QCollator m_collator;
bool m_naturalSorting;
bool m_sortDirsFirst;
RoleType m_sortRole;
int m_sortingProgressPercent; // Value of directorySortingProgress() signal
QSet<QByteArray> m_roles;
Qt::CaseSensitivity m_caseSensitivity;
QList<ItemData*> m_itemData;
// m_items is a cache for the method index(const KUrl&). If it contains N
// m_items is a cache for the method index(const QUrl&). If it contains N
// entries, it is guaranteed that these correspond to the first N items in
// the model, i.e., that (for every i between 0 and N - 1)
// m_items.value(fileItem(i).url()) == i
mutable QHash<KUrl, int> m_items;
mutable QHash<QUrl, int> m_items;
KFileItemModelFilter m_filter;
QHash<KFileItem, ItemData*> m_filteredItems; // Items that got hidden by KFileItemModel::setNameFilter()
@ -489,11 +485,11 @@ private:
mutable QList<QPair<int, QVariant> > m_groups;
// Stores the URLs (key: target url, value: url) of the expanded directories.
QHash<KUrl, KUrl> m_expandedDirs;
QHash<QUrl, QUrl> m_expandedDirs;
// URLs that must be expanded. The expanding is initially triggered in setExpanded()
// and done step after step in slotCompleted().
QSet<KUrl> m_urlsToExpand;
QSet<QUrl> m_urlsToExpand;
friend class KFileItemModelLessThan; // Accesses lessThan() method
friend class KFileItemModelRolesUpdater; // Accesses emitSortProgress() method

View File

@ -23,9 +23,10 @@
#include <KConfig>
#include <KConfigGroup>
#include <KDebug>
#include <KSharedConfig>
#include <KFileItem>
#include <KGlobal>
#include <KIconLoader>
#include <KJobWidgets>
#include <KIO/JobUiDelegate>
#include <KIO/PreviewJob>
@ -42,9 +43,8 @@
#ifdef HAVE_BALOO
#include "private/kbaloorolesprovider.h"
#include <baloo/file.h>
#include <baloo/filefetchjob.h>
#include <baloo/filemonitor.h>
#include <Baloo/File>
#include <Baloo/FileMonitor>
#endif
// #define KFILEITEMMODELROLESUPDATER_DEBUG
@ -95,29 +95,29 @@ KFileItemModelRolesUpdater::KFileItemModelRolesUpdater(KFileItemModel* model, QO
{
Q_ASSERT(model);
const KConfigGroup globalConfig(KGlobal::config(), "PreviewSettings");
const KConfigGroup globalConfig(KSharedConfig::openConfig(), "PreviewSettings");
m_enabledPlugins = globalConfig.readEntry("Plugins", QStringList()
<< "directorythumbnail"
<< "imagethumbnail"
<< "jpegthumbnail");
connect(m_model, SIGNAL(itemsInserted(KItemRangeList)),
this, SLOT(slotItemsInserted(KItemRangeList)));
connect(m_model, SIGNAL(itemsRemoved(KItemRangeList)),
this, SLOT(slotItemsRemoved(KItemRangeList)));
connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
connect(m_model, SIGNAL(itemsMoved(KItemRange,QList<int>)),
this, SLOT(slotItemsMoved(KItemRange,QList<int>)));
connect(m_model, SIGNAL(sortRoleChanged(QByteArray,QByteArray)),
this, SLOT(slotSortRoleChanged(QByteArray,QByteArray)));
connect(m_model, &KFileItemModel::itemsInserted,
this, &KFileItemModelRolesUpdater::slotItemsInserted);
connect(m_model, &KFileItemModel::itemsRemoved,
this, &KFileItemModelRolesUpdater::slotItemsRemoved);
connect(m_model, &KFileItemModel::itemsChanged,
this, &KFileItemModelRolesUpdater::slotItemsChanged);
connect(m_model, &KFileItemModel::itemsMoved,
this, &KFileItemModelRolesUpdater::slotItemsMoved);
connect(m_model, &KFileItemModel::sortRoleChanged,
this, &KFileItemModelRolesUpdater::slotSortRoleChanged);
// Use a timer to prevent that each call of slotItemsChanged() results in a synchronous
// resolving of the roles. Postpone the resolving until no update has been done for 1 second.
m_recentlyChangedItemsTimer = new QTimer(this);
m_recentlyChangedItemsTimer->setInterval(1000);
m_recentlyChangedItemsTimer->setSingleShot(true);
connect(m_recentlyChangedItemsTimer, SIGNAL(timeout()), this, SLOT(resolveRecentlyChangedItems()));
connect(m_recentlyChangedItemsTimer, &QTimer::timeout, this, &KFileItemModelRolesUpdater::resolveRecentlyChangedItems);
m_resolvableRoles.insert("size");
m_resolvableRoles.insert("type");
@ -127,8 +127,8 @@ KFileItemModelRolesUpdater::KFileItemModelRolesUpdater(KFileItemModel* model, QO
#endif
m_directoryContentsCounter = new KDirectoryContentsCounter(m_model, this);
connect(m_directoryContentsCounter, SIGNAL(result(QString,int)),
this, SLOT(slotDirectoryContentsCountReceived(QString,int)));
connect(m_directoryContentsCounter, &KDirectoryContentsCounter::result,
this, &KFileItemModelRolesUpdater::slotDirectoryContentsCountReceived);
}
KFileItemModelRolesUpdater::~KFileItemModelRolesUpdater()
@ -280,8 +280,8 @@ void KFileItemModelRolesUpdater::setRoles(const QSet<QByteArray>& roles)
if (hasBalooRole && !m_balooFileMonitor) {
m_balooFileMonitor = new Baloo::FileMonitor(this);
connect(m_balooFileMonitor, SIGNAL(fileMetaDataChanged(QString)),
this, SLOT(applyChangedBalooRoles(QString)));
connect(m_balooFileMonitor, &Baloo::FileMonitor::fileMetaDataChanged,
this, &KFileItemModelRolesUpdater::applyChangedBalooRoles);
} else if (!hasBalooRole && m_balooFileMonitor) {
delete m_balooFileMonitor;
m_balooFileMonitor = 0;
@ -543,11 +543,11 @@ void KFileItemModelRolesUpdater::slotGotPreview(const KFileItem& item, const QPi
data.insert("iconPixmap", scaledPixmap);
disconnect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
disconnect(m_model, &KFileItemModel::itemsChanged,
this, &KFileItemModelRolesUpdater::slotItemsChanged);
m_model->setData(index, data);
connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
connect(m_model, &KFileItemModel::itemsChanged,
this, &KFileItemModelRolesUpdater::slotItemsChanged);
m_finishedItems.insert(item);
}
@ -565,11 +565,11 @@ void KFileItemModelRolesUpdater::slotPreviewFailed(const KFileItem& item)
QHash<QByteArray, QVariant> data;
data.insert("iconPixmap", QPixmap());
disconnect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
disconnect(m_model, &KFileItemModel::itemsChanged,
this, &KFileItemModelRolesUpdater::slotItemsChanged);
m_model->setData(index, data);
connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
connect(m_model, &KFileItemModel::itemsChanged,
this, &KFileItemModelRolesUpdater::slotItemsChanged);
applyResolvedRoles(index, ResolveAll);
m_finishedItems.insert(item);
@ -625,11 +625,11 @@ void KFileItemModelRolesUpdater::resolveNextSortRole()
m_state = Idle;
// Prevent that we try to update the items twice.
disconnect(m_model, SIGNAL(itemsMoved(KItemRange,QList<int>)),
this, SLOT(slotItemsMoved(KItemRange,QList<int>)));
disconnect(m_model, &KFileItemModel::itemsMoved,
this, &KFileItemModelRolesUpdater::slotItemsMoved);
applySortProgressToModel();
connect(m_model, SIGNAL(itemsMoved(KItemRange,QList<int>)),
this, SLOT(slotItemsMoved(KItemRange,QList<int>)));
connect(m_model, &KFileItemModel::itemsMoved,
this, &KFileItemModelRolesUpdater::slotItemsMoved);
startUpdating();
}
}
@ -665,15 +665,15 @@ void KFileItemModelRolesUpdater::resolveNextPendingRoles()
QHash<QByteArray, QVariant> data;
data.insert("iconPixmap", QPixmap());
disconnect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
disconnect(m_model, &KFileItemModel::itemsChanged,
this, &KFileItemModelRolesUpdater::slotItemsChanged);
for (int index = 0; index <= m_model->count(); ++index) {
if (m_model->data(index).contains("iconPixmap")) {
m_model->setData(index, data);
}
}
connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
connect(m_model, &KFileItemModel::itemsChanged,
this, &KFileItemModelRolesUpdater::slotItemsChanged);
}
m_clearPreviews = false;
@ -703,21 +703,8 @@ void KFileItemModelRolesUpdater::applyChangedBalooRoles(const QString& itemUrl)
return;
}
Baloo::FileFetchJob* job = new Baloo::FileFetchJob(item.localPath());
connect(job, SIGNAL(finished(KJob*)), this, SLOT(applyChangedBalooRolesJobFinished(KJob*)));
job->setProperty("item", QVariant::fromValue(item));
job->start();
#else
#ifndef Q_CC_MSVC
Q_UNUSED(itemUrl);
#endif
#endif
}
void KFileItemModelRolesUpdater::applyChangedBalooRolesJobFinished(KJob* kjob)
{
#ifdef HAVE_BALOO
const KFileItem item = kjob->property("item").value<KFileItem>();
Baloo::File file(item.localPath());
file.load();
const KBalooRolesProvider& rolesProvider = KBalooRolesProvider::instance();
QHash<QByteArray, QVariant> data;
@ -729,19 +716,22 @@ void KFileItemModelRolesUpdater::applyChangedBalooRolesJobFinished(KJob* kjob)
data.insert(role, QVariant());
}
Baloo::FileFetchJob* job = static_cast<Baloo::FileFetchJob*>(kjob);
QHashIterator<QByteArray, QVariant> it(rolesProvider.roleValues(job->file(), m_roles));
QHashIterator<QByteArray, QVariant> it(rolesProvider.roleValues(file, m_roles));
while (it.hasNext()) {
it.next();
data.insert(it.key(), it.value());
}
disconnect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
disconnect(m_model, &KFileItemModel::itemsChanged,
this, &KFileItemModelRolesUpdater::slotItemsChanged);
const int index = m_model->index(item);
m_model->setData(index, data);
connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
connect(m_model, &KFileItemModel::itemsChanged,
this, &KFileItemModelRolesUpdater::slotItemsChanged);
#else
#ifndef Q_CC_MSVC
Q_UNUSED(itemUrl);
#endif
#endif
}
@ -751,7 +741,7 @@ void KFileItemModelRolesUpdater::slotDirectoryContentsCountReceived(const QStrin
const bool getIsExpandableRole = m_roles.contains("isExpandable");
if (getSizeRole || getIsExpandableRole) {
const int index = m_model->index(KUrl(path));
const int index = m_model->index(QUrl::fromLocalFile(path));
if (index >= 0) {
QHash<QByteArray, QVariant> data;
@ -762,11 +752,11 @@ void KFileItemModelRolesUpdater::slotDirectoryContentsCountReceived(const QStrin
data.insert("isExpandable", count > 0);
}
disconnect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
disconnect(m_model, &KFileItemModel::itemsChanged,
this, &KFileItemModelRolesUpdater::slotItemsChanged);
m_model->setData(index, data);
connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
connect(m_model, &KFileItemModel::itemsChanged,
this, &KFileItemModelRolesUpdater::slotItemsChanged);
}
}
}
@ -897,15 +887,15 @@ void KFileItemModelRolesUpdater::startPreviewJob()
job->setIgnoreMaximumSize(itemSubSet.first().isLocalFile());
if (job->ui()) {
job->ui()->setWindow(qApp->activeWindow());
KJobWidgets::setWindow(job, qApp->activeWindow());
}
connect(job, SIGNAL(gotPreview(KFileItem,QPixmap)),
this, SLOT(slotGotPreview(KFileItem,QPixmap)));
connect(job, SIGNAL(failed(KFileItem)),
this, SLOT(slotPreviewFailed(KFileItem)));
connect(job, SIGNAL(finished(KJob*)),
this, SLOT(slotPreviewJobFinished()));
connect(job, &KIO::PreviewJob::gotPreview,
this, &KFileItemModelRolesUpdater::slotGotPreview);
connect(job, &KIO::PreviewJob::failed,
this, &KFileItemModelRolesUpdater::slotPreviewFailed);
connect(job, &KIO::PreviewJob::finished,
this, &KFileItemModelRolesUpdater::slotPreviewJobFinished);
m_previewJob = job;
}
@ -998,11 +988,11 @@ void KFileItemModelRolesUpdater::applySortRole(int index)
data = rolesData(item);
}
disconnect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
disconnect(m_model, &KFileItemModel::itemsChanged,
this, &KFileItemModelRolesUpdater::slotItemsChanged);
m_model->setData(index, data);
connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
connect(m_model, &KFileItemModel::itemsChanged,
this, &KFileItemModelRolesUpdater::slotItemsChanged);
}
void KFileItemModelRolesUpdater::applySortProgressToModel()
@ -1042,11 +1032,11 @@ bool KFileItemModelRolesUpdater::applyResolvedRoles(int index, ResolveHint hint)
data.insert("iconPixmap", QPixmap());
}
disconnect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
disconnect(m_model, &KFileItemModel::itemsChanged,
this, &KFileItemModelRolesUpdater::slotItemsChanged);
m_model->setData(index, data);
connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
connect(m_model, &KFileItemModel::itemsChanged,
this, &KFileItemModelRolesUpdater::slotItemsChanged);
return true;
}
@ -1099,12 +1089,12 @@ void KFileItemModelRolesUpdater::updateAllPreviews()
void KFileItemModelRolesUpdater::killPreviewJob()
{
if (m_previewJob) {
disconnect(m_previewJob, SIGNAL(gotPreview(KFileItem,QPixmap)),
this, SLOT(slotGotPreview(KFileItem,QPixmap)));
disconnect(m_previewJob, SIGNAL(failed(KFileItem)),
this, SLOT(slotPreviewFailed(KFileItem)));
disconnect(m_previewJob, SIGNAL(finished(KJob*)),
this, SLOT(slotPreviewJobFinished()));
disconnect(m_previewJob, &KIO::PreviewJob::gotPreview,
this, &KFileItemModelRolesUpdater::slotGotPreview);
disconnect(m_previewJob, &KIO::PreviewJob::failed,
this, &KFileItemModelRolesUpdater::slotPreviewFailed);
disconnect(m_previewJob, &KIO::PreviewJob::finished,
this, &KFileItemModelRolesUpdater::slotPreviewJobFinished);
m_previewJob->kill();
m_previewJob = 0;
m_pendingPreviewItems.clear();
@ -1168,4 +1158,3 @@ QList<int> KFileItemModelRolesUpdater::indexesToResolve() const
return result;
}
#include "kfileitemmodelrolesupdater.moc"

View File

@ -25,7 +25,7 @@
#include <KFileItem>
#include <kitemviews/kitemmodelbase.h>
#include <libdolphin_export.h>
#include "dolphin_export.h"
#include <QObject>
#include <QSet>
@ -34,10 +34,13 @@
class KDirectoryContentsCounter;
class KFileItemModel;
class KJob;
class QPixmap;
class QTimer;
namespace KIO {
class PreviewJob;
}
#ifdef HAVE_BALOO
namespace Baloo
{
@ -84,7 +87,7 @@ class QTimer;
* 3. Finally, the entire process is repeated for any items that might have
* changed in the mean time.
*/
class LIBDOLPHINPRIVATE_EXPORT KFileItemModelRolesUpdater : public QObject
class DOLPHIN_EXPORT KFileItemModelRolesUpdater : public QObject
{
Q_OBJECT
@ -201,7 +204,6 @@ private slots:
void resolveRecentlyChangedItems();
void applyChangedBalooRoles(const QString& file);
void applyChangedBalooRolesJobFinished(KJob* job);
void slotDirectoryContentsCountReceived(const QString& path, int count);
@ -316,7 +318,7 @@ private:
// A new preview job will be started from them once the first one finishes.
KFileItemList m_pendingPreviewItems;
KJob* m_previewJob;
KIO::PreviewJob* m_previewJob;
// When downloading or copying large files, the slot slotItemsChanged()
// will be called periodically within a quite short delay. To prevent

View File

@ -31,12 +31,10 @@
#include <QApplication>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QPropertyAnimation>
#include <QScrollBar>
#include <QStyle>
#include <QStyleOption>
#include <KDebug>
/**
* Replaces the default viewport of KItemListContainer by a
@ -89,10 +87,10 @@ KItemListContainer::KItemListContainer(KItemListController* controller, QWidget*
slotViewChanged(controller->view(), 0);
}
connect(controller, SIGNAL(modelChanged(KItemModelBase*,KItemModelBase*)),
this, SLOT(slotModelChanged(KItemModelBase*,KItemModelBase*)));
connect(controller, SIGNAL(viewChanged(KItemListView*,KItemListView*)),
this, SLOT(slotViewChanged(KItemListView*,KItemListView*)));
connect(controller, &KItemListController::modelChanged,
this, &KItemListContainer::slotModelChanged);
connect(controller, &KItemListController::viewChanged,
this, &KItemListContainer::slotViewChanged);
}
KItemListContainer::~KItemListContainer()
@ -185,11 +183,15 @@ void KItemListContainer::wheelEvent(QWheelEvent* event)
KItemListSmoothScroller* smoothScroller = scrollHorizontally ?
m_horizontalSmoothScroller : m_verticalSmoothScroller;
const int numDegrees = event->delta() / 8;
const int numSteps = numDegrees / 15;
const QScrollBar* scrollBar = smoothScroller->scrollBar();
smoothScroller->scrollTo(scrollBar->value() - numSteps * scrollBar->pageStep() / 4);
if (!event->pixelDelta().isNull()) {
const int numPixels = event->pixelDelta().y();
smoothScroller->scrollTo(scrollBar->value() - numPixels);
} else {
const int numDegrees = event->angleDelta().y() / 8;
const int numSteps = numDegrees / 15;
smoothScroller->scrollTo(scrollBar->value() - numSteps * scrollBar->pageStep() / 4);
}
event->accept();
}
@ -211,23 +213,33 @@ void KItemListContainer::slotViewChanged(KItemListView* current, KItemListView*
QGraphicsScene* scene = static_cast<QGraphicsView*>(viewport())->scene();
if (previous) {
scene->removeItem(previous);
disconnect(previous, SIGNAL(scrollOrientationChanged(Qt::Orientation,Qt::Orientation)), this, SLOT(slotScrollOrientationChanged(Qt::Orientation,Qt::Orientation)));
disconnect(previous, SIGNAL(scrollOffsetChanged(qreal,qreal)), this, SLOT(updateScrollOffsetScrollBar()));
disconnect(previous, SIGNAL(maximumScrollOffsetChanged(qreal,qreal)), this, SLOT(updateScrollOffsetScrollBar()));
disconnect(previous, SIGNAL(itemOffsetChanged(qreal,qreal)), this, SLOT(updateItemOffsetScrollBar()));
disconnect(previous, SIGNAL(maximumItemOffsetChanged(qreal,qreal)), this, SLOT(updateItemOffsetScrollBar()));
disconnect(previous, SIGNAL(scrollTo(qreal)), this, SLOT(scrollTo(qreal)));
disconnect(previous, &KItemListView::scrollOrientationChanged,
this, &KItemListContainer::slotScrollOrientationChanged);
disconnect(previous, &KItemListView::scrollOffsetChanged,
this, &KItemListContainer::updateScrollOffsetScrollBar);
disconnect(previous, &KItemListView::maximumScrollOffsetChanged,
this, &KItemListContainer::updateScrollOffsetScrollBar);
disconnect(previous, &KItemListView::itemOffsetChanged,
this, &KItemListContainer::updateItemOffsetScrollBar);
disconnect(previous, &KItemListView::maximumItemOffsetChanged,
this, &KItemListContainer::updateItemOffsetScrollBar);
disconnect(previous, &KItemListView::scrollTo, this, &KItemListContainer::scrollTo);
m_horizontalSmoothScroller->setTargetObject(0);
m_verticalSmoothScroller->setTargetObject(0);
}
if (current) {
scene->addItem(current);
connect(current, SIGNAL(scrollOrientationChanged(Qt::Orientation,Qt::Orientation)), this, SLOT(slotScrollOrientationChanged(Qt::Orientation,Qt::Orientation)));
connect(current, SIGNAL(scrollOffsetChanged(qreal,qreal)), this, SLOT(updateScrollOffsetScrollBar()));
connect(current, SIGNAL(maximumScrollOffsetChanged(qreal,qreal)), this, SLOT(updateScrollOffsetScrollBar()));
connect(current, SIGNAL(itemOffsetChanged(qreal,qreal)), this, SLOT(updateItemOffsetScrollBar()));
connect(current, SIGNAL(maximumItemOffsetChanged(qreal,qreal)), this, SLOT(updateItemOffsetScrollBar()));
connect(current, SIGNAL(scrollTo(qreal)), this, SLOT(scrollTo(qreal)));
connect(current, &KItemListView::scrollOrientationChanged,
this, &KItemListContainer::slotScrollOrientationChanged);
connect(current, &KItemListView::scrollOffsetChanged,
this, &KItemListContainer::updateScrollOffsetScrollBar);
connect(current, &KItemListView::maximumScrollOffsetChanged,
this, &KItemListContainer::updateScrollOffsetScrollBar);
connect(current, &KItemListView::itemOffsetChanged,
this, &KItemListContainer::updateItemOffsetScrollBar);
connect(current, &KItemListView::maximumItemOffsetChanged,
this, &KItemListContainer::updateItemOffsetScrollBar);
connect(current, &KItemListView::scrollTo, this, &KItemListContainer::scrollTo);
m_horizontalSmoothScroller->setTargetObject(current);
m_verticalSmoothScroller->setTargetObject(current);
updateSmoothScrollers(current->scrollOrientation());
@ -403,4 +415,3 @@ void KItemListContainer::updateScrollOffsetScrollBarPolicy()
}
}
#include "kitemlistcontainer.moc"

View File

@ -23,16 +23,14 @@
#ifndef KITEMLISTCONTAINER_H
#define KITEMLISTCONTAINER_H
#include <libdolphin_export.h>
#include "dolphin_export.h"
#include <QAbstractAnimation>
#include <QAbstractScrollArea>
class KItemListController;
class KItemListSmoothScroller;
class KItemListView;
class KItemModelBase;
class QPropertyAnimation;
/**
* @brief Provides a QWidget based scrolling view for a KItemListController.
@ -41,7 +39,7 @@ class QPropertyAnimation;
*
* @see KItemListController
*/
class LIBDOLPHINPRIVATE_EXPORT KItemListContainer : public QAbstractScrollArea
class DOLPHIN_EXPORT KItemListContainer : public QAbstractScrollArea
{
Q_OBJECT
@ -60,11 +58,11 @@ public:
bool enabledFrame() const;
protected:
virtual void keyPressEvent(QKeyEvent* event);
virtual void showEvent(QShowEvent* event);
virtual void resizeEvent(QResizeEvent* event);
virtual void scrollContentsBy(int dx, int dy);
virtual void wheelEvent(QWheelEvent* event);
virtual void keyPressEvent(QKeyEvent* event) Q_DECL_OVERRIDE;
virtual void showEvent(QShowEvent* event) Q_DECL_OVERRIDE;
virtual void resizeEvent(QResizeEvent* event) Q_DECL_OVERRIDE;
virtual void scrollContentsBy(int dx, int dy) Q_DECL_OVERRIDE;
virtual void wheelEvent(QWheelEvent* event) Q_DECL_OVERRIDE;
private slots:
void slotScrollOrientationChanged(Qt::Orientation current, Qt::Orientation previous);

View File

@ -23,8 +23,6 @@
#include "kitemlistcontroller.h"
#include <KGlobalSettings>
#include <KDebug>
#include "kitemlistview.h"
#include "kitemlistselectionmanager.h"
@ -61,15 +59,15 @@ KItemListController::KItemListController(KItemModelBase* model, KItemListView* v
m_keyboardAnchorIndex(-1),
m_keyboardAnchorPos(0)
{
connect(m_keyboardManager, SIGNAL(changeCurrentItem(QString,bool)),
this, SLOT(slotChangeCurrentItem(QString,bool)));
connect(m_selectionManager, SIGNAL(currentChanged(int,int)),
m_keyboardManager, SLOT(slotCurrentChanged(int,int)));
connect(m_keyboardManager, &KItemListKeyboardSearchManager::changeCurrentItem,
this, &KItemListController::slotChangeCurrentItem);
connect(m_selectionManager, &KItemListSelectionManager::currentChanged,
m_keyboardManager, &KItemListKeyboardSearchManager::slotCurrentChanged);
m_autoActivationTimer = new QTimer(this);
m_autoActivationTimer->setSingleShot(true);
m_autoActivationTimer->setInterval(-1);
connect(m_autoActivationTimer, SIGNAL(timeout()), this, SLOT(slotAutoActivationTimeout()));
connect(m_autoActivationTimer, &QTimer::timeout, this, &KItemListController::slotAutoActivationTimeout);
setModel(model);
setView(view);
@ -127,7 +125,7 @@ void KItemListController::setView(KItemListView* view)
KItemListView* oldView = m_view;
if (oldView) {
disconnect(oldView, SIGNAL(scrollOffsetChanged(qreal,qreal)), this, SLOT(slotViewScrollOffsetChanged(qreal,qreal)));
disconnect(oldView, &KItemListView::scrollOffsetChanged, this, &KItemListController::slotViewScrollOffsetChanged);
oldView->deleteLater();
}
@ -137,7 +135,7 @@ void KItemListController::setView(KItemListView* view)
m_view->setParent(this);
m_view->setController(this);
m_view->setModel(m_model);
connect(m_view, SIGNAL(scrollOffsetChanged(qreal,qreal)), this, SLOT(slotViewScrollOffsetChanged(qreal,qreal)));
connect(m_view, &KItemListView::scrollOffsetChanged, this, &KItemListController::slotViewScrollOffsetChanged);
updateExtendedSelectionRegion();
}
@ -538,8 +536,7 @@ bool KItemListController::mousePressEvent(QGraphicsSceneMouseEvent* event, const
m_pressedIndex = m_view->itemAt(m_pressedMousePos);
emit mouseButtonPressed(m_pressedIndex, event->buttons());
// TODO: Qt5: Replace Qt::XButton1 by Qt::BackButton and Qt::XButton2 by Qt::ForwardButton
if (event->buttons() & (Qt::XButton1 | Qt::XButton2)) {
if (event->buttons() & (Qt::BackButton | Qt::ForwardButton)) {
// Do not select items when clicking the back/forward buttons, see
// https://bugs.kde.org/show_bug.cgi?id=327412.
return true;
@ -655,7 +652,7 @@ bool KItemListController::mousePressEvent(QGraphicsSceneMouseEvent* event, const
rubberBand->setStartPosition(startPos);
rubberBand->setEndPosition(startPos);
rubberBand->setActive(true);
connect(rubberBand, SIGNAL(endPositionChanged(QPointF,QPointF)), this, SLOT(slotRubberBandChanged()));
connect(rubberBand, &KItemListRubberBand::endPositionChanged, this, &KItemListController::slotRubberBandChanged);
m_view->setAutoScroll(true);
}
@ -743,7 +740,7 @@ bool KItemListController::mouseReleaseEvent(QGraphicsSceneMouseEvent* event, con
KItemListRubberBand* rubberBand = m_view->rubberBand();
if (rubberBand->isActive()) {
disconnect(rubberBand, SIGNAL(endPositionChanged(QPointF,QPointF)), this, SLOT(slotRubberBandChanged()));
disconnect(rubberBand, &KItemListRubberBand::endPositionChanged, this, &KItemListController::slotRubberBandChanged);
rubberBand->setActive(false);
m_oldSelection.clear();
m_view->setAutoScroll(false);
@ -774,7 +771,7 @@ bool KItemListController::mouseReleaseEvent(QGraphicsSceneMouseEvent* event, con
} else if (shiftOrControlPressed) {
// The mouse click should only update the selection, not trigger the item
emitItemActivated = false;
} else if (!(KGlobalSettings::singleClick() || m_singleClickActivationEnforced)) {
} else if (!(m_view->style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick) || m_singleClickActivationEnforced)) {
emitItemActivated = false;
}
if (emitItemActivated) {
@ -804,7 +801,7 @@ bool KItemListController::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event,
}
}
bool emitItemActivated = !(KGlobalSettings::singleClick() || m_singleClickActivationEnforced) &&
bool emitItemActivated = !(m_view->style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick) || m_singleClickActivationEnforced) &&
(event->button() & Qt::LeftButton) &&
index >= 0 && index < m_model->count();
if (emitItemActivated) {
@ -920,7 +917,8 @@ bool KItemListController::dropEvent(QGraphicsSceneDragDropEvent* event, const QT
emit itemDropEvent(m_view->itemAt(pos), event);
}
QAccessible::updateAccessibility(view(), 0, QAccessible::DragDropEnd);
QAccessibleEvent accessibilityEvent(view(), QAccessible::DragDropEnd);
QAccessible::updateAccessibility(&accessibilityEvent);
return true;
}
@ -1174,7 +1172,9 @@ void KItemListController::startDragging()
drag->setHotSpot(hotSpot);
drag->exec(Qt::MoveAction | Qt::CopyAction | Qt::LinkAction, Qt::CopyAction);
QAccessible::updateAccessibility(view(), 0, QAccessible::DragDropStart);
QAccessibleEvent accessibilityEvent(view(), QAccessible::DragDropStart);
QAccessible::updateAccessibility(&accessibilityEvent);
}
KItemListWidget* KItemListController::hoveredWidget() const
@ -1310,4 +1310,3 @@ void KItemListController::updateExtendedSelectionRegion()
}
}
#include "kitemlistcontroller.moc"

View File

@ -23,14 +23,13 @@
#ifndef KITEMLISTCONTROLLER_H
#define KITEMLISTCONTROLLER_H
#include <libdolphin_export.h>
#include "dolphin_export.h"
#include "kitemset.h"
#include <QObject>
#include <QPixmap>
#include <QPointF>
class QTimer;
class KItemModelBase;
class KItemListKeyboardSearchManager;
class KItemListSelectionManager;
@ -44,7 +43,6 @@ class QGraphicsSceneWheelEvent;
class QHideEvent;
class QInputMethodEvent;
class QKeyEvent;
class QMimeData;
class QShowEvent;
class QTransform;
@ -58,7 +56,7 @@ class QTransform;
* @see KItemModelBase
* @see KItemListSelectionManager
*/
class LIBDOLPHINPRIVATE_EXPORT KItemListController : public QObject
class DOLPHIN_EXPORT KItemListController : public QObject
{
Q_OBJECT
Q_ENUMS(SelectionBehavior)
@ -131,7 +129,7 @@ public:
/**
* If set to true, the signals itemActivated() and itemsActivated() are emitted
* after a single-click of the left mouse button. If set to false (the default),
* the setting from KGlobalSettings::singleClick() is used.
* the setting from style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick) is used.
*/
void setSingleClickActivationEnforced(bool singleClick);
bool singleClickActivationEnforced() const;

View File

@ -27,7 +27,6 @@
#include <QGraphicsSceneResizeEvent>
#include <QPainter>
#include <QStyleOptionGraphicsItem>
#include <KDebug>
KItemListGroupHeader::KItemListGroupHeader(QGraphicsWidget* parent) :
QGraphicsWidget(parent, 0),
@ -233,4 +232,3 @@ QColor KItemListGroupHeader::baseColor() const
return styleOption().palette.color(group, normalBaseColorRole());
}
#include "kitemlistgroupheader.moc"

View File

@ -20,7 +20,7 @@
#ifndef KITEMLISTGROUPHEADER_H
#define KITEMLISTGROUPHEADER_H
#include <libdolphin_export.h>
#include "dolphin_export.h"
#include <kitemviews/kitemliststyleoption.h>
@ -37,7 +37,7 @@ class KItemListView;
* the method paint() and draw the role within the given roleBounds() with
* the color roleColor().
*/
class LIBDOLPHINPRIVATE_EXPORT KItemListGroupHeader : public QGraphicsWidget
class DOLPHIN_EXPORT KItemListGroupHeader : public QGraphicsWidget
{
Q_OBJECT
@ -65,7 +65,7 @@ public:
void setItemIndex(int index);
int itemIndex() const;
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0) Q_DECL_OVERRIDE;
protected:
virtual void paintRole(QPainter* painter, const QRectF& roleBounds, const QColor& color) = 0;
@ -101,8 +101,7 @@ protected:
*/
virtual void itemIndexChanged(int current, int previous);
/** @reimp */
virtual void resizeEvent(QGraphicsSceneResizeEvent* event);
virtual void resizeEvent(QGraphicsSceneResizeEvent* event) Q_DECL_OVERRIDE;
virtual QPalette::ColorRole normalTextColorRole() const;
virtual QPalette::ColorRole normalBaseColorRole() const;

View File

@ -81,8 +81,7 @@ KItemListHeader::KItemListHeader(KItemListView* listView) :
m_headerWidget = m_view->m_headerWidget;
Q_ASSERT(m_headerWidget);
connect(m_headerWidget, SIGNAL(columnWidthChanged(QByteArray,qreal,qreal)),
this, SIGNAL(columnWidthChanged(QByteArray,qreal,qreal)));
connect(m_headerWidget, &KItemListHeaderWidget::columnWidthChanged,
this, &KItemListHeader::columnWidthChanged);
}
#include "kitemlistheader.moc"

View File

@ -20,7 +20,7 @@
#ifndef KITEMLISTHEADER_H
#define KITEMLISTHEADER_H
#include <libdolphin_export.h>
#include "dolphin_export.h"
#include <QHash>
#include <QObject>
@ -33,7 +33,7 @@ class KItemListView;
* Each column of the header represents a visible role
* accessible by KItemListView::visibleRoles().
*/
class LIBDOLPHINPRIVATE_EXPORT KItemListHeader : public QObject
class DOLPHIN_EXPORT KItemListHeader : public QObject
{
Q_OBJECT

View File

@ -24,7 +24,6 @@
#include "kitemlistselectionmanager.h"
#include "kitemmodelbase.h"
#include <KDebug>
KItemListSelectionManager::KItemListSelectionManager(QObject* parent) :
QObject(parent),
@ -396,4 +395,4 @@ int KItemListSelectionManager::indexAfterRangesRemoving(int index, const KItemRa
}
return qBound(-1, index - dec, m_model->count() - 1);
}
#include "kitemlistselectionmanager.moc"

View File

@ -23,7 +23,7 @@
#ifndef KITEMLISTSELECTIONMANAGER_H
#define KITEMLISTSELECTIONMANAGER_H
#include <libdolphin_export.h>
#include "dolphin_export.h"
#include <kitemviews/kitemmodelbase.h>
#include <kitemviews/kitemset.h>
@ -35,7 +35,7 @@ class KItemModelBase;
/**
* @brief Allows to select and deselect items of a KItemListView.
*/
class LIBDOLPHINPRIVATE_EXPORT KItemListSelectionManager : public QObject
class DOLPHIN_EXPORT KItemListSelectionManager : public QObject
{
Q_OBJECT

View File

@ -19,7 +19,6 @@
#include "kitemliststyleoption.h"
#include <KIconLoader>
KItemListStyleOption::KItemListStyleOption() :
rect(),

View File

@ -20,14 +20,14 @@
#ifndef KITEMLISTSTYLEOPTION_H
#define KITEMLISTSTYLEOPTION_H
#include <libdolphin_export.h>
#include "dolphin_export.h"
#include <QFont>
#include <QFontMetrics>
#include <QPalette>
#include <QRect>
class LIBDOLPHINPRIVATE_EXPORT KItemListStyleOption
class DOLPHIN_EXPORT KItemListStyleOption
{
public:
KItemListStyleOption();

View File

@ -22,7 +22,7 @@
#include "kitemlistview.h"
#include <KDebug>
#include "dolphindebug.h"
#include "kitemlistcontainer.h"
#include "kitemlistcontroller.h"
#include "kitemlistheader.h"
@ -35,14 +35,13 @@
#include "private/kitemlistviewlayouter.h"
#include "private/kitemlistviewanimation.h"
#include <QCursor>
#include <QGraphicsSceneMouseEvent>
#include <QGraphicsView>
#include <QPainter>
#include <QPropertyAnimation>
#include <QStyle>
#include <QStyleOptionRubberBand>
#include <QTimer>
#include <QElapsedTimer>
#include <algorithm>
@ -58,7 +57,7 @@ namespace {
}
#ifndef QT_NO_ACCESSIBILITY
QAccessibleInterface* accessibleInterfaceFactory(const QString &key, QObject *object)
QAccessibleInterface* accessibleInterfaceFactory(const QString& key, QObject* object)
{
Q_UNUSED(key)
@ -114,16 +113,16 @@ KItemListView::KItemListView(QGraphicsWidget* parent) :
m_layouter = new KItemListViewLayouter(m_sizeHintResolver, this);
m_animation = new KItemListViewAnimation(this);
connect(m_animation, SIGNAL(finished(QGraphicsWidget*,KItemListViewAnimation::AnimationType)),
this, SLOT(slotAnimationFinished(QGraphicsWidget*,KItemListViewAnimation::AnimationType)));
connect(m_animation, &KItemListViewAnimation::finished,
this, &KItemListView::slotAnimationFinished);
m_layoutTimer = new QTimer(this);
m_layoutTimer->setInterval(300);
m_layoutTimer->setSingleShot(true);
connect(m_layoutTimer, SIGNAL(timeout()), this, SLOT(slotLayoutTimerFinished()));
connect(m_layoutTimer, &QTimer::timeout, this, &KItemListView::slotLayoutTimerFinished);
m_rubberBand = new KItemListRubberBand(this);
connect(m_rubberBand, SIGNAL(activationChanged(bool)), this, SLOT(slotRubberBandActivationChanged(bool)));
connect(m_rubberBand, &KItemListRubberBand::activationChanged, this, &KItemListView::slotRubberBandActivationChanged);
m_headerWidget = new KItemListHeaderWidget(this);
m_headerWidget->setVisible(false);
@ -267,7 +266,7 @@ void KItemListView::setAutoScroll(bool enabled)
if (enabled && !m_autoScrollTimer) {
m_autoScrollTimer = new QTimer(this);
m_autoScrollTimer->setSingleShot(true);
connect(m_autoScrollTimer, SIGNAL(timeout()), this, SLOT(triggerAutoScrolling()));
connect(m_autoScrollTimer, &QTimer::timeout, this, &KItemListView::triggerAutoScrolling);
m_autoScrollTimer->start(InitialAutoScrollDelay);
} else if (!enabled && m_autoScrollTimer) {
delete m_autoScrollTimer;
@ -544,7 +543,7 @@ void KItemListView::endTransaction()
--m_activeTransactions;
if (m_activeTransactions < 0) {
m_activeTransactions = 0;
kWarning() << "Mismatch between beginTransaction()/endTransaction()";
qCWarning(DolphinDebug) << "Mismatch between beginTransaction()/endTransaction()";
}
if (m_activeTransactions == 0) {
@ -572,26 +571,26 @@ void KItemListView::setHeaderVisible(bool visible)
m_headerWidget->setColumns(m_visibleRoles);
m_headerWidget->setZValue(1);
connect(m_headerWidget, SIGNAL(columnWidthChanged(QByteArray,qreal,qreal)),
this, SLOT(slotHeaderColumnWidthChanged(QByteArray,qreal,qreal)));
connect(m_headerWidget, SIGNAL(columnMoved(QByteArray,int,int)),
this, SLOT(slotHeaderColumnMoved(QByteArray,int,int)));
connect(m_headerWidget, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder)),
this, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder)));
connect(m_headerWidget, SIGNAL(sortRoleChanged(QByteArray,QByteArray)),
this, SIGNAL(sortRoleChanged(QByteArray,QByteArray)));
connect(m_headerWidget, &KItemListHeaderWidget::columnWidthChanged,
this, &KItemListView::slotHeaderColumnWidthChanged);
connect(m_headerWidget, &KItemListHeaderWidget::columnMoved,
this, &KItemListView::slotHeaderColumnMoved);
connect(m_headerWidget, &KItemListHeaderWidget::sortOrderChanged,
this, &KItemListView::sortOrderChanged);
connect(m_headerWidget, &KItemListHeaderWidget::sortRoleChanged,
this, &KItemListView::sortRoleChanged);
m_layouter->setHeaderHeight(headerSize.height());
m_headerWidget->setVisible(true);
} else if (!visible && m_headerWidget->isVisible()) {
disconnect(m_headerWidget, SIGNAL(columnWidthChanged(QByteArray,qreal,qreal)),
this, SLOT(slotHeaderColumnWidthChanged(QByteArray,qreal,qreal)));
disconnect(m_headerWidget, SIGNAL(columnMoved(QByteArray,int,int)),
this, SLOT(slotHeaderColumnMoved(QByteArray,int,int)));
disconnect(m_headerWidget, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder)),
this, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder)));
disconnect(m_headerWidget, SIGNAL(sortRoleChanged(QByteArray,QByteArray)),
this, SIGNAL(sortRoleChanged(QByteArray,QByteArray)));
disconnect(m_headerWidget, &KItemListHeaderWidget::columnWidthChanged,
this, &KItemListView::slotHeaderColumnWidthChanged);
disconnect(m_headerWidget, &KItemListHeaderWidget::columnMoved,
this, &KItemListView::slotHeaderColumnMoved);
disconnect(m_headerWidget, &KItemListHeaderWidget::sortOrderChanged,
this, &KItemListView::sortOrderChanged);
disconnect(m_headerWidget, &KItemListHeaderWidget::sortRoleChanged,
this, &KItemListView::sortRoleChanged);
m_layouter->setHeaderHeight(0);
m_headerWidget->setVisible(false);
@ -637,10 +636,10 @@ void KItemListView::editRole(int index, const QByteArray& role)
m_editingRole = true;
widget->setEditedRole(role);
connect(widget, SIGNAL(roleEditingCanceled(int,QByteArray,QVariant)),
this, SLOT(slotRoleEditingCanceled(int,QByteArray,QVariant)));
connect(widget, SIGNAL(roleEditingFinished(int,QByteArray,QVariant)),
this, SLOT(slotRoleEditingFinished(int,QByteArray,QVariant)));
connect(widget, &KItemListWidget::roleEditingCanceled,
this, &KItemListView::slotRoleEditingCanceled);
connect(widget, &KItemListWidget::roleEditingFinished,
this, &KItemListView::slotRoleEditingFinished);
}
void KItemListView::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
@ -936,7 +935,7 @@ void KItemListView::dragEnterEvent(QGraphicsSceneDragDropEvent* event)
setAutoScroll(true);
}
void KItemListView::dragMoveEvent(QGraphicsSceneDragDropEvent *event)
void KItemListView::dragMoveEvent(QGraphicsSceneDragDropEvent* event)
{
QGraphicsWidget::dragMoveEvent(event);
@ -946,7 +945,7 @@ void KItemListView::dragMoveEvent(QGraphicsSceneDragDropEvent *event)
}
}
void KItemListView::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)
void KItemListView::dragLeaveEvent(QGraphicsSceneDragDropEvent* event)
{
QGraphicsWidget::dragLeaveEvent(event);
setAutoScroll(false);
@ -1007,7 +1006,7 @@ void KItemListView::slotItemsInserted(const KItemRangeList& itemRanges)
const int index = range.index + previouslyInsertedCount;
const int count = range.count;
if (index < 0 || count <= 0) {
kWarning() << "Invalid item range (index:" << index << ", count:" << count << ")";
qCWarning(DolphinDebug) << "Invalid item range (index:" << index << ", count:" << count << ")";
continue;
}
previouslyInsertedCount += count;
@ -1115,7 +1114,7 @@ void KItemListView::slotItemsRemoved(const KItemRangeList& itemRanges)
const int index = range.index;
const int count = range.count;
if (index < 0 || count <= 0) {
kWarning() << "Invalid item range (index:" << index << ", count:" << count << ")";
qCWarning(DolphinDebug) << "Invalid item range (index:" << index << ", count:" << count << ")";
continue;
}
@ -1268,8 +1267,12 @@ void KItemListView::slotItemsChanged(const KItemRangeList& itemRanges,
updateVisibleGroupHeaders();
doLayout(NoAnimation);
}
QAccessibleTableModelChangeEvent ev(this, QAccessibleTableModelChangeEvent::DataChanged);
ev.setFirstRow(itemRange.index);
ev.setLastRow(itemRange.index + itemRange.count);
QAccessible::updateAccessibility(&ev);
}
QAccessible::updateAccessibility(this, 0, QAccessible::TableModelChanged);
}
void KItemListView::slotGroupsChanged()
@ -1345,7 +1348,10 @@ void KItemListView::slotCurrentChanged(int current, int previous)
currentWidget->setCurrent(true);
}
}
QAccessible::updateAccessibility(this, current+1, QAccessible::Focus);
QAccessibleEvent ev(this, QAccessible::Focus);
ev.setChild(current);
QAccessible::updateAccessibility(&ev);
}
void KItemListView::slotSelectionChanged(const KItemSet& current, const KItemSet& previous)
@ -1412,12 +1418,12 @@ void KItemListView::slotRubberBandPosChanged()
void KItemListView::slotRubberBandActivationChanged(bool active)
{
if (active) {
connect(m_rubberBand, SIGNAL(startPositionChanged(QPointF,QPointF)), this, SLOT(slotRubberBandPosChanged()));
connect(m_rubberBand, SIGNAL(endPositionChanged(QPointF,QPointF)), this, SLOT(slotRubberBandPosChanged()));
connect(m_rubberBand, &KItemListRubberBand::startPositionChanged, this, &KItemListView::slotRubberBandPosChanged);
connect(m_rubberBand, &KItemListRubberBand::endPositionChanged, this, &KItemListView::slotRubberBandPosChanged);
m_skipAutoScrollForRubberBand = true;
} else {
disconnect(m_rubberBand, SIGNAL(startPositionChanged(QPointF,QPointF)), this, SLOT(slotRubberBandPosChanged()));
disconnect(m_rubberBand, SIGNAL(endPositionChanged(QPointF,QPointF)), this, SLOT(slotRubberBandPosChanged()));
disconnect(m_rubberBand, &KItemListRubberBand::startPositionChanged, this, &KItemListView::slotRubberBandPosChanged);
disconnect(m_rubberBand, &KItemListRubberBand::endPositionChanged, this, &KItemListView::slotRubberBandPosChanged);
m_skipAutoScrollForRubberBand = false;
}
@ -1544,16 +1550,16 @@ void KItemListView::setController(KItemListController* controller)
KItemListController* previous = m_controller;
if (previous) {
KItemListSelectionManager* selectionManager = previous->selectionManager();
disconnect(selectionManager, SIGNAL(currentChanged(int,int)), this, SLOT(slotCurrentChanged(int,int)));
disconnect(selectionManager, SIGNAL(selectionChanged(KItemSet,KItemSet)), this, SLOT(slotSelectionChanged(KItemSet,KItemSet)));
disconnect(selectionManager, &KItemListSelectionManager::currentChanged, this, &KItemListView::slotCurrentChanged);
disconnect(selectionManager, &KItemListSelectionManager::selectionChanged, this, &KItemListView::slotSelectionChanged);
}
m_controller = controller;
if (controller) {
KItemListSelectionManager* selectionManager = controller->selectionManager();
connect(selectionManager, SIGNAL(currentChanged(int,int)), this, SLOT(slotCurrentChanged(int,int)));
connect(selectionManager, SIGNAL(selectionChanged(KItemSet,KItemSet)), this, SLOT(slotSelectionChanged(KItemSet,KItemSet)));
connect(selectionManager, &KItemListSelectionManager::currentChanged, this, &KItemListView::slotCurrentChanged);
connect(selectionManager, &KItemListSelectionManager::selectionChanged, this, &KItemListView::slotSelectionChanged);
}
onControllerChanged(controller, previous);
@ -1569,22 +1575,22 @@ void KItemListView::setModel(KItemModelBase* model)
KItemModelBase* previous = m_model;
if (m_model) {
disconnect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
disconnect(m_model, SIGNAL(itemsInserted(KItemRangeList)),
this, SLOT(slotItemsInserted(KItemRangeList)));
disconnect(m_model, SIGNAL(itemsRemoved(KItemRangeList)),
this, SLOT(slotItemsRemoved(KItemRangeList)));
disconnect(m_model, SIGNAL(itemsMoved(KItemRange,QList<int>)),
this, SLOT(slotItemsMoved(KItemRange,QList<int>)));
disconnect(m_model, SIGNAL(groupsChanged()),
this, SLOT(slotGroupsChanged()));
disconnect(m_model, SIGNAL(groupedSortingChanged(bool)),
this, SLOT(slotGroupedSortingChanged(bool)));
disconnect(m_model, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder)),
this, SLOT(slotSortOrderChanged(Qt::SortOrder,Qt::SortOrder)));
disconnect(m_model, SIGNAL(sortRoleChanged(QByteArray,QByteArray)),
this, SLOT(slotSortRoleChanged(QByteArray,QByteArray)));
disconnect(m_model, &KItemModelBase::itemsChanged,
this, &KItemListView::slotItemsChanged);
disconnect(m_model, &KItemModelBase::itemsInserted,
this, &KItemListView::slotItemsInserted);
disconnect(m_model, &KItemModelBase::itemsRemoved,
this, &KItemListView::slotItemsRemoved);
disconnect(m_model, &KItemModelBase::itemsMoved,
this, &KItemListView::slotItemsMoved);
disconnect(m_model, &KItemModelBase::groupsChanged,
this, &KItemListView::slotGroupsChanged);
disconnect(m_model, &KItemModelBase::groupedSortingChanged,
this, &KItemListView::slotGroupedSortingChanged);
disconnect(m_model, &KItemModelBase::sortOrderChanged,
this, &KItemListView::slotSortOrderChanged);
disconnect(m_model, &KItemModelBase::sortRoleChanged,
this, &KItemListView::slotSortRoleChanged);
m_sizeHintResolver->itemsRemoved(KItemRangeList() << KItemRange(0, m_model->count()));
}
@ -1594,22 +1600,22 @@ void KItemListView::setModel(KItemModelBase* model)
m_grouped = model->groupedSorting();
if (m_model) {
connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
connect(m_model, SIGNAL(itemsInserted(KItemRangeList)),
this, SLOT(slotItemsInserted(KItemRangeList)));
connect(m_model, SIGNAL(itemsRemoved(KItemRangeList)),
this, SLOT(slotItemsRemoved(KItemRangeList)));
connect(m_model, SIGNAL(itemsMoved(KItemRange,QList<int>)),
this, SLOT(slotItemsMoved(KItemRange,QList<int>)));
connect(m_model, SIGNAL(groupsChanged()),
this, SLOT(slotGroupsChanged()));
connect(m_model, SIGNAL(groupedSortingChanged(bool)),
this, SLOT(slotGroupedSortingChanged(bool)));
connect(m_model, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder)),
this, SLOT(slotSortOrderChanged(Qt::SortOrder,Qt::SortOrder)));
connect(m_model, SIGNAL(sortRoleChanged(QByteArray,QByteArray)),
this, SLOT(slotSortRoleChanged(QByteArray,QByteArray)));
connect(m_model, &KItemModelBase::itemsChanged,
this, &KItemListView::slotItemsChanged);
connect(m_model, &KItemModelBase::itemsInserted,
this, &KItemListView::slotItemsInserted);
connect(m_model, &KItemModelBase::itemsRemoved,
this, &KItemListView::slotItemsRemoved);
connect(m_model, &KItemModelBase::itemsMoved,
this, &KItemListView::slotItemsMoved);
connect(m_model, &KItemModelBase::groupsChanged,
this, &KItemListView::slotGroupsChanged);
connect(m_model, &KItemModelBase::groupedSortingChanged,
this, &KItemListView::slotGroupedSortingChanged);
connect(m_model, &KItemModelBase::sortOrderChanged,
this, &KItemListView::slotSortOrderChanged);
connect(m_model, &KItemModelBase::sortRoleChanged,
this, &KItemListView::slotSortRoleChanged);
const int itemCount = m_model->count();
if (itemCount > 0) {
@ -2023,7 +2029,7 @@ void KItemListView::updateGroupHeaderForWidget(KItemListWidget* widget)
groupHeader = groupHeaderCreator()->create(this);
groupHeader->setParentItem(widget);
m_visibleGroups.insert(widget, groupHeader);
connect(widget, SIGNAL(geometryChanged()), this, SLOT(slotGeometryOfGroupHeaderParentChanged()));
connect(widget, &KItemListWidget::geometryChanged, this, &KItemListView::slotGeometryOfGroupHeaderParentChanged);
}
Q_ASSERT(groupHeader->parentItem() == widget);
@ -2070,7 +2076,7 @@ void KItemListView::recycleGroupHeaderForWidget(KItemListWidget* widget)
header->setParentItem(0);
groupHeaderCreator()->recycle(header);
m_visibleGroups.remove(widget);
disconnect(widget, SIGNAL(geometryChanged()), this, SLOT(slotGeometryOfGroupHeaderParentChanged()));
disconnect(widget, &KItemListWidget::geometryChanged, this, &KItemListView::slotGeometryOfGroupHeaderParentChanged);
}
}
@ -2624,8 +2630,8 @@ void KItemListView::disconnectRoleEditingSignals(int index)
return;
}
widget->disconnect(SIGNAL(roleEditingCanceled(int,QByteArray,QVariant)), this);
widget->disconnect(SIGNAL(roleEditingFinished(int,QByteArray,QVariant)), this);
disconnect(widget, &KItemListWidget::roleEditingCanceled, this, nullptr);
disconnect(widget, &KItemListWidget::roleEditingFinished, this, nullptr);
}
int KItemListView::calculateAutoScrollingIncrement(int pos, int range, int oldInc)
@ -2719,4 +2725,3 @@ void KItemListGroupHeaderCreatorBase::recycle(KItemListGroupHeader* header)
pushRecycleableWidget(header);
}
#include "kitemlistview.moc"

View File

@ -23,7 +23,7 @@
#ifndef KITEMLISTVIEW_H
#define KITEMLISTVIEW_H
#include <libdolphin_export.h>
#include "dolphin_export.h"
#include <kitemviews/kstandarditemlistgroupheader.h>
#include <kitemviews/kitemliststyleoption.h>
@ -44,7 +44,6 @@ class KItemListViewLayouter;
class KItemListWidget;
class KItemListWidgetInformant;
class KItemListWidgetCreatorBase;
class KItemListViewCreatorBase;
class QTimer;
/**
@ -60,7 +59,7 @@ class QTimer;
* @see KItemListWidget
* @see KItemModelBase
*/
class LIBDOLPHINPRIVATE_EXPORT KItemListView : public QGraphicsWidget
class DOLPHIN_EXPORT KItemListView : public QGraphicsWidget
{
Q_OBJECT
@ -161,8 +160,7 @@ public:
const KItemListStyleOption& styleOption() const;
/** @reimp */
virtual void setGeometry(const QRectF& rect);
virtual void setGeometry(const QRectF& rect) Q_DECL_OVERRIDE;
/**
* @return The page step which should be used by the vertical scroll bar.
@ -280,10 +278,7 @@ public:
*/
void editRole(int index, const QByteArray& role);
/**
* @reimp
*/
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0) Q_DECL_OVERRIDE;
signals:
void scrollOrientationChanged(Qt::Orientation current, Qt::Orientation previous);
@ -323,7 +318,7 @@ signals:
void roleEditingFinished(int index, const QByteArray& role, const QVariant& value);
protected:
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value) Q_DECL_OVERRIDE;
void setItemSize(const QSizeF& size);
void setStyleOption(const KItemListStyleOption& option);
@ -380,13 +375,13 @@ protected:
virtual void onTransactionBegin();
virtual void onTransactionEnd();
virtual bool event(QEvent* event);
virtual void mousePressEvent(QGraphicsSceneMouseEvent* event);
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
virtual void dragEnterEvent(QGraphicsSceneDragDropEvent* event);
virtual void dragMoveEvent(QGraphicsSceneDragDropEvent* event);
virtual void dragLeaveEvent(QGraphicsSceneDragDropEvent* event);
virtual void dropEvent(QGraphicsSceneDragDropEvent* event);
virtual bool event(QEvent* event) Q_DECL_OVERRIDE;
virtual void mousePressEvent(QGraphicsSceneMouseEvent* event) Q_DECL_OVERRIDE;
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent* event) Q_DECL_OVERRIDE;
virtual void dragEnterEvent(QGraphicsSceneDragDropEvent* event) Q_DECL_OVERRIDE;
virtual void dragMoveEvent(QGraphicsSceneDragDropEvent* event) Q_DECL_OVERRIDE;
virtual void dragLeaveEvent(QGraphicsSceneDragDropEvent* event) Q_DECL_OVERRIDE;
virtual void dropEvent(QGraphicsSceneDragDropEvent* event) Q_DECL_OVERRIDE;
QList<KItemListWidget*> visibleItemListWidgets() const;
@ -774,7 +769,7 @@ private:
* KItemListWidgetCreatorBase and KItemListGroupHeaderCreatorBase.
* @internal
*/
class LIBDOLPHINPRIVATE_EXPORT KItemListCreatorBase
class DOLPHIN_EXPORT KItemListCreatorBase
{
public:
virtual ~KItemListCreatorBase();
@ -798,7 +793,7 @@ private:
* expensive instantiations and deletions of KItemListWidgets by recycling existing widget
* instances.
*/
class LIBDOLPHINPRIVATE_EXPORT KItemListWidgetCreatorBase : public KItemListCreatorBase
class DOLPHIN_EXPORT KItemListWidgetCreatorBase : public KItemListCreatorBase
{
public:
virtual ~KItemListWidgetCreatorBase();
@ -880,7 +875,7 @@ qreal KItemListWidgetCreator<T>::preferredRoleColumnWidth(const QByteArray& role
* The intention of the group-header creator is to prevent repetitive and expensive instantiations and
* deletions of KItemListGroupHeaders by recycling existing header instances.
*/
class LIBDOLPHINPRIVATE_EXPORT KItemListGroupHeaderCreatorBase : public KItemListCreatorBase
class DOLPHIN_EXPORT KItemListGroupHeaderCreatorBase : public KItemListCreatorBase
{
public:
virtual ~KItemListGroupHeaderCreatorBase();

View File

@ -27,11 +27,10 @@
#include "kitemlistview.h"
#include "private/kitemlistviewlayouter.h"
#include <QtGui/qaccessible2.h>
#include <qaccessible.h>
#include <qgraphicsscene.h>
#include <qgraphicsview.h>
#include <KDebug>
#include <QHash>
KItemListView* KItemListViewAccessible::view() const
@ -40,35 +39,52 @@ KItemListView* KItemListViewAccessible::view() const
}
KItemListViewAccessible::KItemListViewAccessible(KItemListView* view_) :
QAccessibleObjectEx(view_)
QAccessibleObject(view_)
{
Q_ASSERT(view());
m_cells.resize(childCount());
}
KItemListViewAccessible::~KItemListViewAccessible()
{
foreach (QAccessibleInterface* child, m_cells) {
if (child) {
QAccessible::Id childId = QAccessible::uniqueId(child);
QAccessible::deleteAccessibleInterface(childId);
}
}
}
void* KItemListViewAccessible::interface_cast(QAccessible::InterfaceType type)
{
if (type == QAccessible::TableInterface) {
return static_cast<QAccessibleTableInterface*>(this);
}
return Q_NULLPTR;
}
void KItemListViewAccessible::modelReset()
{
}
QAccessible::Role KItemListViewAccessible::cellRole() const
{
return QAccessible::Cell;
}
QAccessibleTable2CellInterface* KItemListViewAccessible::cell(int index) const
QAccessibleInterface* KItemListViewAccessible::cell(int index) const
{
if (index < 0 || index >= view()->model()->count()) {
return 0;
} else {
return new KItemListAccessibleCell(view(), index);
}
if (m_cells.size() < index - 1)
m_cells.resize(childCount());
QAccessibleInterface* child = m_cells.at(index);
if (!child) {
child = new KItemListAccessibleCell(view(), index);
QAccessible::registerAccessibleInterface(child);
}
return child;
}
QVariant KItemListViewAccessible::invokeMethodEx(Method, int, const QVariantList&)
{
return QVariant();
}
QAccessibleTable2CellInterface* KItemListViewAccessible::cellAt(int row, int column) const
QAccessibleInterface* KItemListViewAccessible::cellAt(int row, int column) const
{
return cell(columnCount() * row + column);
}
@ -127,9 +143,9 @@ QString KItemListViewAccessible::rowDescription(int) const
return QString();
}
QList<QAccessibleTable2CellInterface*> KItemListViewAccessible::selectedCells() const
QList<QAccessibleInterface*> KItemListViewAccessible::selectedCells() const
{
QList<QAccessibleTable2CellInterface*> cells;
QList<QAccessibleInterface*> cells;
Q_FOREACH (int index, view()->controller()->selectionManager()->selectedItems()) {
cells.append(cell(index));
}
@ -181,42 +197,31 @@ bool KItemListViewAccessible::unselectColumn(int)
return true;
}
QAccessible2::TableModelChange KItemListViewAccessible::modelChange() const
void KItemListViewAccessible::modelChange(QAccessibleTableModelChangeEvent* /*event*/)
{}
QAccessible::Role KItemListViewAccessible::role() const
{
QAccessible2::TableModelChange change;
change.lastRow = rowCount();
change.lastColumn = columnCount();
return change;
return QAccessible::Table;
}
QAccessible::Role KItemListViewAccessible::role(int child) const
QAccessible::State KItemListViewAccessible::state() const
{
Q_ASSERT(child >= 0);
if (child > 0) {
return QAccessible::Cell;
} else {
return QAccessible::Table;
}
QAccessible::State s;
return s;
}
QAccessible::State KItemListViewAccessible::state(int child) const
QAccessibleInterface* KItemListViewAccessible::childAt(int x, int y) const
{
if (child) {
QAccessibleInterface* interface = 0;
navigate(Child, child, &interface);
if (interface) {
return interface->state(0);
}
}
return QAccessible::Normal | QAccessible::HasInvokeExtension;
const QPointF point = QPointF(x, y);
int itemIndex = view()->itemAt(view()->mapFromScene(point));
return child(itemIndex);
}
int KItemListViewAccessible::childAt(int x, int y) const
QAccessibleInterface* KItemListViewAccessible::parent() const
{
const QPointF point = QPointF(x,y);
return view()->itemAt(view()->mapFromScene(point));
// FIXME: return KItemListContainerAccessible here
return Q_NULLPTR;
}
int KItemListViewAccessible::childCount() const
@ -227,18 +232,16 @@ int KItemListViewAccessible::childCount() const
int KItemListViewAccessible::indexOfChild(const QAccessibleInterface* interface) const
{
const KItemListAccessibleCell* widget = static_cast<const KItemListAccessibleCell*>(interface);
return widget->index() + 1;
return widget->index();
}
QString KItemListViewAccessible::text(Text, int child) const
QString KItemListViewAccessible::text(QAccessible::Text) const
{
Q_ASSERT(child == 0);
return QString();
}
QRect KItemListViewAccessible::rect(int child) const
QRect KItemListViewAccessible::rect() const
{
Q_UNUSED(child)
if (!view()->isVisible()) {
return QRect();
}
@ -253,50 +256,14 @@ QRect KItemListViewAccessible::rect(int child) const
}
}
int KItemListViewAccessible::navigate(RelationFlag relation, int index, QAccessibleInterface** interface) const
QAccessibleInterface* KItemListViewAccessible::child(int index) const
{
*interface = 0;
switch (relation) {
case QAccessible::Child:
Q_ASSERT(index > 0);
*interface = cell(index - 1);
if (*interface) {
return 0;
}
break;
default:
break;
if (index >= 0 && index < childCount()) {
return cell(index);
}
return -1;
return Q_NULLPTR;
}
QAccessible::Relation KItemListViewAccessible::relationTo(int, const QAccessibleInterface*, int) const
{
return QAccessible::Unrelated;
}
#ifndef QT_NO_ACTION
int KItemListViewAccessible::userActionCount(int) const
{
return 0;
}
QString KItemListViewAccessible::actionText(int, Text, int) const
{
return QString();
}
bool KItemListViewAccessible::doAction(int, int, const QVariantList&)
{
return false;
}
#endif
// Table Cell
KItemListAccessibleCell::KItemListAccessibleCell(KItemListView* view, int index) :
@ -306,6 +273,14 @@ KItemListAccessibleCell::KItemListAccessibleCell(KItemListView* view, int index)
Q_ASSERT(index >= 0 && index < view->model()->count());
}
void* KItemListAccessibleCell::interface_cast(QAccessible::InterfaceType type)
{
if (type == QAccessible::TableCellInterface) {
return static_cast<QAccessibleTableCellInterface*>(this);
}
return Q_NULLPTR;
}
int KItemListAccessibleCell::columnExtent() const
{
return 1;
@ -341,52 +316,39 @@ bool KItemListAccessibleCell::isSelected() const
return m_view->controller()->selectionManager()->isSelected(m_index);
}
void KItemListAccessibleCell::rowColumnExtents(int* row, int* column, int* rowExtents, int* columnExtents, bool* selected) const
QAccessibleInterface* KItemListAccessibleCell::table() const
{
const KItemListViewLayouter* layouter = m_view->m_layouter;
*row = layouter->itemRow(m_index);
*column = layouter->itemColumn(m_index);
*rowExtents = 1;
*columnExtents = 1;
*selected = isSelected();
return QAccessible::queryAccessibleInterface(m_view);
}
QAccessibleTable2Interface* KItemListAccessibleCell::table() const
QAccessible::Role KItemListAccessibleCell::role() const
{
return QAccessible::queryAccessibleInterface(m_view)->table2Interface();
}
QAccessible::Role KItemListAccessibleCell::role(int child) const
{
Q_ASSERT(child == 0);
return QAccessible::Cell;
}
QAccessible::State KItemListAccessibleCell::state(int child) const
QAccessible::State KItemListAccessibleCell::state() const
{
Q_ASSERT(child == 0);
QAccessible::State state = Normal;
QAccessible::State state;
state.selectable = true;
if (isSelected()) {
state |= Selected;
state.selected = true;
}
state.focusable = true;
if (m_view->controller()->selectionManager()->currentItem() == m_index) {
state |= Focused;
state.focused = true;
}
state |= Selectable;
state |= Focusable;
if (m_view->controller()->selectionBehavior() == KItemListController::MultiSelection) {
state |= MultiSelectable;
state.multiSelectable = true;
}
if (m_view->model()->isExpandable(m_index)) {
if (m_view->model()->isExpanded(m_index)) {
state |= Expanded;
state.expanded = true;
} else {
state |= Collapsed;
state.collapsed = true;
}
}
@ -398,7 +360,7 @@ bool KItemListAccessibleCell::isExpandable() const
return m_view->model()->isExpandable(m_index);
}
QRect KItemListAccessibleCell::rect(int) const
QRect KItemListAccessibleCell::rect() const
{
QRect rect = m_view->itemRect(m_index).toRect();
@ -411,13 +373,9 @@ QRect KItemListAccessibleCell::rect(int) const
return rect;
}
QString KItemListAccessibleCell::text(QAccessible::Text t, int child) const
QString KItemListAccessibleCell::text(QAccessible::Text t) const
{
Q_ASSERT(child == 0);
Q_UNUSED(child)
switch (t) {
case QAccessible::Value:
case QAccessible::Name: {
const QHash<QByteArray, QVariant> data = m_view->model()->data(m_index);
return data["text"].toString();
@ -430,9 +388,13 @@ QString KItemListAccessibleCell::text(QAccessible::Text t, int child) const
return QString();
}
void KItemListAccessibleCell::setText(QAccessible::Text, int child, const QString&)
void KItemListAccessibleCell::setText(QAccessible::Text, const QString&)
{
Q_ASSERT(child == 0);
}
QAccessibleInterface* KItemListAccessibleCell::child(int) const
{
return Q_NULLPTR;
}
bool KItemListAccessibleCell::isValid() const
@ -440,9 +402,9 @@ bool KItemListAccessibleCell::isValid() const
return m_view && (m_index >= 0) && (m_index < m_view->model()->count());
}
int KItemListAccessibleCell::childAt(int, int) const
QAccessibleInterface* KItemListAccessibleCell::childAt(int, int) const
{
return 0;
return Q_NULLPTR;
}
int KItemListAccessibleCell::childCount() const
@ -456,43 +418,11 @@ int KItemListAccessibleCell::indexOfChild(const QAccessibleInterface* child) con
return -1;
}
int KItemListAccessibleCell::navigate(RelationFlag relation, int index, QAccessibleInterface** interface) const
QAccessibleInterface* KItemListAccessibleCell::parent() const
{
if (relation == Ancestor && index == 1) {
*interface = new KItemListViewAccessible(m_view);
return 0;
}
*interface = 0;
return -1;
return QAccessible::queryAccessibleInterface(m_view);
}
QAccessible::Relation KItemListAccessibleCell::relationTo(int child, const QAccessibleInterface* , int otherChild) const
{
Q_ASSERT(child == 0);
Q_ASSERT(otherChild == 0);
return QAccessible::Unrelated;
}
#ifndef QT_NO_ACTION
int KItemListAccessibleCell::userActionCount(int) const
{
return 0;
}
QString KItemListAccessibleCell::actionText(int, Text, int) const
{
return QString();
}
bool KItemListAccessibleCell::doAction(int, int, const QVariantList&)
{
return false;
}
#endif
int KItemListAccessibleCell::index() const
{
return m_index;
@ -505,7 +435,7 @@ QObject* KItemListAccessibleCell::object() const
// Container Interface
KItemListContainerAccessible::KItemListContainerAccessible(KItemListContainer* container) :
QAccessibleWidgetEx(container)
QAccessibleWidget(container)
{
}
@ -521,20 +451,17 @@ int KItemListContainerAccessible::childCount() const
int KItemListContainerAccessible::indexOfChild(const QAccessibleInterface* child) const
{
if (child->object() == container()->controller()->view()) {
return 1;
} else {
return -1;
return 0;
}
return -1;
}
int KItemListContainerAccessible::navigate(QAccessible::RelationFlag relation, int index, QAccessibleInterface** target) const
QAccessibleInterface* KItemListContainerAccessible::child(int index) const
{
if (relation == QAccessible::Child) {
*target = new KItemListViewAccessible(container()->controller()->view());
return 0;
} else {
return QAccessibleWidgetEx::navigate(relation, index, target);
if (index == 0) {
return QAccessible::queryAccessibleInterface(container()->controller()->view());
}
return Q_NULLPTR;
}
const KItemListContainer* KItemListContainerAccessible::container() const

View File

@ -22,118 +22,104 @@
#ifndef QT_NO_ACCESSIBILITY
#include "dolphin_export.h"
#include <QtCore/qpointer.h>
#include <QtGui/qaccessible.h>
#include <QtGui/qaccessible2.h>
#include <QtGui/qaccessiblewidget.h>
#include <QtGui/qaccessibleobject.h>
#include <qaccessible.h>
#include <qaccessibleobject.h>
#include <QtWidgets/qaccessiblewidget.h>
class KItemListView;
class KItemListContainer;
class KItemListViewAccessible: public QAccessibleTable2Interface, public QAccessibleObjectEx
class DOLPHIN_EXPORT KItemListViewAccessible: public QAccessibleObject, public QAccessibleTableInterface
{
Q_ACCESSIBLE_OBJECT
public:
explicit KItemListViewAccessible(KItemListView* view);
~KItemListViewAccessible();
Role role(int child) const;
State state(int child) const;
QString text(Text t, int child) const;
QRect rect(int child) const;
void* interface_cast(QAccessible::InterfaceType type) Q_DECL_OVERRIDE;
int childAt(int x, int y) const;
int childCount() const;
int indexOfChild(const QAccessibleInterface*) const;
QAccessible::Role role() const Q_DECL_OVERRIDE;
QAccessible::State state() const Q_DECL_OVERRIDE;
QString text(QAccessible::Text t) const Q_DECL_OVERRIDE;
QRect rect() const Q_DECL_OVERRIDE;
int navigate(RelationFlag relation, int index, QAccessibleInterface** interface) const;
Relation relationTo(int child, const QAccessibleInterface* other, int otherChild) const;
QAccessibleInterface* child(int index) const Q_DECL_OVERRIDE;
int childCount() const Q_DECL_OVERRIDE;
int indexOfChild(const QAccessibleInterface*) const Q_DECL_OVERRIDE;
QAccessibleInterface* childAt(int x, int y) const Q_DECL_OVERRIDE;
QAccessibleInterface* parent() const Q_DECL_OVERRIDE;
#ifndef QT_NO_ACTION
int userActionCount(int child) const;
QString actionText(int action, Text t, int child) const;
bool doAction(int action, int child, const QVariantList& params);
#endif
QVariant invokeMethodEx(Method, int, const QVariantList&);
// Table2 interface
virtual QAccessibleTable2CellInterface* cellAt(int row, int column) const;
virtual QAccessibleInterface* caption() const;
virtual QAccessibleInterface* summary() const;
virtual QString columnDescription(int column) const;
virtual QString rowDescription(int row) const;
virtual int columnCount() const;
virtual int rowCount() const;
virtual QAccessible2::TableModelChange modelChange() const;
virtual void rowsInserted(const QModelIndex&, int, int) {}
virtual void rowsRemoved(const QModelIndex&, int, int) {}
virtual void columnsInserted(const QModelIndex&, int, int) {}
virtual void columnsRemoved(const QModelIndex&, int, int) {}
virtual void rowsMoved(const QModelIndex&, int, int, const QModelIndex&, int) {}
virtual void columnsMoved(const QModelIndex&, int, int, const QModelIndex&, int) {}
// Table interface
virtual QAccessibleInterface* cellAt(int row, int column) const Q_DECL_OVERRIDE;
virtual QAccessibleInterface* caption() const Q_DECL_OVERRIDE;
virtual QAccessibleInterface* summary() const Q_DECL_OVERRIDE;
virtual QString columnDescription(int column) const Q_DECL_OVERRIDE;
virtual QString rowDescription(int row) const Q_DECL_OVERRIDE;
virtual int columnCount() const Q_DECL_OVERRIDE;
virtual int rowCount() const Q_DECL_OVERRIDE;
// Selection
virtual int selectedCellCount() const;
virtual int selectedColumnCount() const;
virtual int selectedRowCount() const;
virtual QList<QAccessibleTable2CellInterface*> selectedCells() const;
virtual QList<int> selectedColumns() const;
virtual QList<int> selectedRows() const;
virtual bool isColumnSelected(int column) const;
virtual bool isRowSelected(int row) const;
virtual bool selectRow(int row);
virtual bool selectColumn(int column);
virtual bool unselectRow(int row);
virtual bool unselectColumn(int column);
virtual int selectedCellCount() const Q_DECL_OVERRIDE;
virtual int selectedColumnCount() const Q_DECL_OVERRIDE;
virtual int selectedRowCount() const Q_DECL_OVERRIDE;
virtual QList<QAccessibleInterface*> selectedCells() const Q_DECL_OVERRIDE;
virtual QList<int> selectedColumns() const Q_DECL_OVERRIDE;
virtual QList<int> selectedRows() const Q_DECL_OVERRIDE;
virtual bool isColumnSelected(int column) const Q_DECL_OVERRIDE;
virtual bool isRowSelected(int row) const Q_DECL_OVERRIDE;
virtual bool selectRow(int row) Q_DECL_OVERRIDE;
virtual bool selectColumn(int column) Q_DECL_OVERRIDE;
virtual bool unselectRow(int row) Q_DECL_OVERRIDE;
virtual bool unselectColumn(int column) Q_DECL_OVERRIDE;
virtual void modelChange(QAccessibleTableModelChangeEvent*) Q_DECL_OVERRIDE;
KItemListView* view() const;
protected:
virtual void modelReset();
/**
* Create an QAccessibleTable2CellInterface representing the table
* Create an QAccessibleTableCellInterface representing the table
* cell at the @index. Index is 0-based.
*/
inline QAccessibleTable2CellInterface* cell(int index) const;
inline QAccessible::Role cellRole() const;
inline QAccessibleInterface* cell(int index) const;
private:
mutable QVector<QAccessibleInterface*> m_cells;
};
class KItemListAccessibleCell: public QAccessibleTable2CellInterface
class DOLPHIN_EXPORT KItemListAccessibleCell: public QAccessibleInterface, public QAccessibleTableCellInterface
{
public:
KItemListAccessibleCell(KItemListView* view, int m_index);
QObject* object() const;
Role role(int) const;
State state(int) const;
QRect rect(int) const;
bool isValid() const;
int childAt(int, int) const;
int childCount() const;
int indexOfChild(const QAccessibleInterface*) const;
QString text(Text t, int child) const;
void setText(Text t, int child, const QString& text);
int navigate(RelationFlag relation, int m_index, QAccessibleInterface** interface) const;
Relation relationTo(int child, const QAccessibleInterface* other, int otherChild) const;
void* interface_cast(QAccessible::InterfaceType type) Q_DECL_OVERRIDE;
QObject* object() const Q_DECL_OVERRIDE;
bool isValid() const Q_DECL_OVERRIDE;
QAccessible::Role role() const Q_DECL_OVERRIDE;
QAccessible::State state() const Q_DECL_OVERRIDE;
QRect rect() const Q_DECL_OVERRIDE;
QString text(QAccessible::Text t) const Q_DECL_OVERRIDE;
void setText(QAccessible::Text t, const QString& text) Q_DECL_OVERRIDE;
QAccessibleInterface* child(int index) const Q_DECL_OVERRIDE;
int childCount() const Q_DECL_OVERRIDE;
QAccessibleInterface* childAt(int x, int y) const Q_DECL_OVERRIDE;
int indexOfChild(const QAccessibleInterface*) const Q_DECL_OVERRIDE;
QAccessibleInterface* parent() const Q_DECL_OVERRIDE;
bool isExpandable() const;
#ifndef QT_NO_ACTION
int userActionCount(int child) const;
QString actionText(int action, Text t, int child) const;
bool doAction(int action, int child, const QVariantList& params);
#endif
// Cell Interface
virtual int columnExtent() const;
virtual QList<QAccessibleInterface*> columnHeaderCells() const;
virtual int columnIndex() const;
virtual int rowExtent() const;
virtual QList<QAccessibleInterface*> rowHeaderCells() const;
virtual int rowIndex() const;
virtual bool isSelected() const;
virtual void rowColumnExtents(int* row, int* column, int* rowExtents, int* columnExtents, bool* selected) const;
virtual QAccessibleTable2Interface* table() const;
virtual int columnExtent() const Q_DECL_OVERRIDE;
virtual QList<QAccessibleInterface*> columnHeaderCells() const Q_DECL_OVERRIDE;
virtual int columnIndex() const Q_DECL_OVERRIDE;
virtual int rowExtent() const Q_DECL_OVERRIDE;
virtual QList<QAccessibleInterface*> rowHeaderCells() const Q_DECL_OVERRIDE;
virtual int rowIndex() const Q_DECL_OVERRIDE;
virtual bool isSelected() const Q_DECL_OVERRIDE;
virtual QAccessibleInterface* table() const Q_DECL_OVERRIDE;
inline int index() const;
@ -142,17 +128,15 @@ private:
int m_index;
};
class KItemListContainerAccessible : public QAccessibleWidgetEx
class DOLPHIN_EXPORT KItemListContainerAccessible : public QAccessibleWidget
{
Q_ACCESSIBLE_OBJECT
public:
explicit KItemListContainerAccessible(KItemListContainer* container);
virtual ~KItemListContainerAccessible();
int childCount() const;
int indexOfChild(const QAccessibleInterface* child) const;
int navigate(RelationFlag relation, int entry, QAccessibleInterface** target) const;
QAccessibleInterface* child(int index) const Q_DECL_OVERRIDE;
int childCount() const Q_DECL_OVERRIDE;
int indexOfChild(const QAccessibleInterface* child) const Q_DECL_OVERRIDE;
private:
const KItemListContainer* container() const;

View File

@ -27,9 +27,7 @@
#include "private/kitemlistselectiontoggle.h"
#include <KDebug>
#include <KGlobalSettings>
#include <QApplication>
#include <QPainter>
#include <QPropertyAnimation>
@ -250,9 +248,9 @@ void KItemListWidget::setHovered(bool hovered)
if (!m_hoverAnimation) {
m_hoverAnimation = new QPropertyAnimation(this, "hoverOpacity", this);
const int duration = (KGlobalSettings::graphicEffectsLevel() == KGlobalSettings::NoEffects) ? 1 : 200;
const int duration = style()->styleHint(QStyle::SH_Widget_Animate) ? 200 : 1;
m_hoverAnimation->setDuration(duration);
connect(m_hoverAnimation, SIGNAL(finished()), this, SLOT(slotHoverAnimationFinished()));
connect(m_hoverAnimation, &QPropertyAnimation::finished, this, &KItemListWidget::slotHoverAnimationFinished);
}
m_hoverAnimation->stop();
@ -526,4 +524,3 @@ void KItemListWidget::drawItemStyleOption(QPainter* painter, QWidget* widget, QS
widget->style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &viewItemOption, painter, widget);
}
#include "kitemlistwidget.moc"

View File

@ -23,7 +23,7 @@
#ifndef KITEMLISTWIDGET_H
#define KITEMLISTWIDGET_H
#include <libdolphin_export.h>
#include "dolphin_export.h"
#include <kitemviews/kitemliststyleoption.h>
@ -43,7 +43,7 @@ class QPropertyAnimation;
* size for the invisible items must be accessible. KItemListWidgetInformant
* provides this information.
*/
class LIBDOLPHINPRIVATE_EXPORT KItemListWidgetInformant
class DOLPHIN_EXPORT KItemListWidgetInformant
{
public:
KItemListWidgetInformant();
@ -63,7 +63,7 @@ public:
* All properties are set by KItemListView, for each property there is a corresponding
* virtual protected method that allows to react on property changes.
*/
class LIBDOLPHINPRIVATE_EXPORT KItemListWidget : public QGraphicsWidget
class DOLPHIN_EXPORT KItemListWidget : public QGraphicsWidget
{
Q_OBJECT
@ -82,7 +82,7 @@ public:
* to show the data of the custom model provided by KItemListWidget::data().
* @reimp
*/
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0) Q_DECL_OVERRIDE;
void setVisibleRoles(const QList<QByteArray>& roles);
QList<QByteArray> visibleRoles() const;
@ -203,7 +203,7 @@ protected:
virtual void alternateBackgroundChanged(bool enabled);
virtual void siblingsInformationChanged(const QBitArray& current, const QBitArray& previous);
virtual void editedRoleChanged(const QByteArray& current, const QByteArray& previous);
virtual void resizeEvent(QGraphicsSceneResizeEvent* event);
virtual void resizeEvent(QGraphicsSceneResizeEvent* event) Q_DECL_OVERRIDE;
/**
* @return The current opacity of the hover-animation. When implementing a custom painting-code for a hover-state

View File

@ -159,4 +159,3 @@ void KItemModelBase::onSortOrderChanged(Qt::SortOrder current, Qt::SortOrder pre
Q_UNUSED(previous);
}
#include "kitemmodelbase.moc"

View File

@ -23,7 +23,7 @@
#ifndef KITEMMODELBASE_H
#define KITEMMODELBASE_H
#include <libdolphin_export.h>
#include "dolphin_export.h"
#include <kitemviews/kitemrange.h>
#include <kitemviews/kitemset.h>
@ -49,7 +49,7 @@ class QMimeData;
* Also optionally it is possible to provide a tree of items by implementing the methods
* setExpanded(), isExpanded(), isExpandable() and expandedParentsCount().
*/
class LIBDOLPHINPRIVATE_EXPORT KItemModelBase : public QObject
class DOLPHIN_EXPORT KItemModelBase : public QObject
{
Q_OBJECT

View File

@ -18,8 +18,8 @@
***************************************************************************/
#include "kstandarditem.h"
#include <KDebug>
#include <QSet>
#include <QByteArray>
#include "kstandarditemmodel.h"
KStandardItem::KStandardItem(KStandardItem* parent) :

View File

@ -20,11 +20,10 @@
#ifndef KSTANDARDITEM_H
#define KSTANDARDITEM_H
#include <libdolphin_export.h>
#include "dolphin_export.h"
#include <QByteArray>
#include <QHash>
#include <QIcon>
#include <QList>
#include <QVariant>
@ -37,7 +36,7 @@ class KStandardItemModel;
* used roles. It is possible to assign values for custom
* roles by using setDataValue().
*/
class LIBDOLPHINPRIVATE_EXPORT KStandardItem
class DOLPHIN_EXPORT KStandardItem
{
public:

View File

@ -22,7 +22,7 @@
#include "kstandarditemlistgroupheader.h"
#include <kratingpainter.h>
#include <KRatingPainter>
#include <QPainter>
KStandardItemListGroupHeader::KStandardItemListGroupHeader(QGraphicsWidget* parent) :
@ -122,4 +122,3 @@ void KStandardItemListGroupHeader::updateCache()
}
}
#include "kstandarditemlistgroupheader.moc"

View File

@ -20,14 +20,14 @@
#ifndef KSTANDARDITEMLISTGROUPHEADER_H
#define KSTANDARDITEMLISTGROUPHEADER_H
#include <libdolphin_export.h>
#include "dolphin_export.h"
#include <kitemviews/kitemlistgroupheader.h>
#include <QPixmap>
#include <QStaticText>
class LIBDOLPHINPRIVATE_EXPORT KStandardItemListGroupHeader : public KItemListGroupHeader
class DOLPHIN_EXPORT KStandardItemListGroupHeader : public KItemListGroupHeader
{
Q_OBJECT
@ -35,14 +35,14 @@ public:
KStandardItemListGroupHeader(QGraphicsWidget* parent = 0);
virtual ~KStandardItemListGroupHeader();
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0) Q_DECL_OVERRIDE;
protected:
virtual void paintRole(QPainter* painter, const QRectF& roleBounds, const QColor& color);
virtual void paintSeparator(QPainter* painter, const QColor& color);
virtual void roleChanged(const QByteArray &current, const QByteArray &previous);
virtual void dataChanged(const QVariant& current, const QVariant& previous);
virtual void resizeEvent(QGraphicsSceneResizeEvent* event);
virtual void paintRole(QPainter* painter, const QRectF& roleBounds, const QColor& color) Q_DECL_OVERRIDE;
virtual void paintSeparator(QPainter* painter, const QColor& color) Q_DECL_OVERRIDE;
virtual void roleChanged(const QByteArray &current, const QByteArray &previous) Q_DECL_OVERRIDE;
virtual void dataChanged(const QVariant& current, const QVariant& previous) Q_DECL_OVERRIDE;
virtual void resizeEvent(QGraphicsSceneResizeEvent* event) Q_DECL_OVERRIDE;
private:
void updateCache();

View File

@ -19,7 +19,6 @@
#include "kstandarditemlistview.h"
#include <KDebug>
#include <KIconLoader>
#include "kstandarditemlistwidget.h"
#include "kstandarditemlistgroupheader.h"
@ -30,7 +29,7 @@ KStandardItemListView::KStandardItemListView(QGraphicsWidget* parent) :
{
setAcceptDrops(true);
setScrollOrientation(Qt::Vertical);
setVisibleRoles(QList<QByteArray>() << "text");
setVisibleRoles({"text"});
}
KStandardItemListView::~KStandardItemListView()
@ -179,4 +178,3 @@ void KStandardItemListView::updateLayoutOfVisibleItems()
}
}
#include "kstandarditemlistview.moc"

View File

@ -20,7 +20,7 @@
#ifndef KSTANDARDITEMLISTVIEW_H
#define KSTANDARDITEMLISTVIEW_H
#include <libdolphin_export.h>
#include "dolphin_export.h"
#include <kitemviews/kitemlistview.h>
@ -40,7 +40,7 @@
* KItemListContainer* container = new KItemListContainer(controller, parentWidget);
* </code>
*/
class LIBDOLPHINPRIVATE_EXPORT KStandardItemListView : public KItemListView
class DOLPHIN_EXPORT KStandardItemListView : public KItemListView
{
Q_OBJECT
@ -59,15 +59,15 @@ public:
ItemLayout itemLayout() const;
protected:
virtual KItemListWidgetCreatorBase* defaultWidgetCreator() const;
virtual KItemListGroupHeaderCreatorBase* defaultGroupHeaderCreator() const;
virtual void initializeItemListWidget(KItemListWidget* item);
virtual bool itemSizeHintUpdateRequired(const QSet<QByteArray>& changedRoles) const;
virtual KItemListWidgetCreatorBase* defaultWidgetCreator() const Q_DECL_OVERRIDE;
virtual KItemListGroupHeaderCreatorBase* defaultGroupHeaderCreator() const Q_DECL_OVERRIDE;
virtual void initializeItemListWidget(KItemListWidget* item) Q_DECL_OVERRIDE;
virtual bool itemSizeHintUpdateRequired(const QSet<QByteArray>& changedRoles) const Q_DECL_OVERRIDE;
virtual bool itemLayoutSupportsItemExpanding(ItemLayout layout) const;
virtual void onItemLayoutChanged(ItemLayout current, ItemLayout previous);
virtual void onScrollOrientationChanged(Qt::Orientation current, Qt::Orientation previous);
virtual void onSupportsItemExpandingChanged(bool supportsExpanding);
virtual void polishEvent();
virtual void onScrollOrientationChanged(Qt::Orientation current, Qt::Orientation previous) Q_DECL_OVERRIDE;
virtual void onSupportsItemExpandingChanged(bool supportsExpanding) Q_DECL_OVERRIDE;
virtual void polishEvent() Q_DECL_OVERRIDE;
private:
void applyDefaultStyleOption(int iconSize, int padding, int horizontalMargin, int verticalMargin);

View File

@ -22,19 +22,16 @@
#include "kfileitemlistview.h"
#include "kfileitemmodel.h"
#include <KIcon>
#include <QIcon>
#include <KIconEffect>
#include <KIconLoader>
#include <KLocale>
#include <kratingpainter.h>
#include <KRatingPainter>
#include <KStringHandler>
#include <KDebug>
#include "private/kfileitemclipboard.h"
#include "private/kitemlistroleeditor.h"
#include "private/kpixmapmodifier.h"
#include <QFontMetricsF>
#include <QGraphicsScene>
#include <QGraphicsSceneResizeEvent>
#include <QGraphicsView>
@ -120,6 +117,8 @@ QString KStandardItemListWidgetInformant::itemText(int index, const KItemListVie
bool KStandardItemListWidgetInformant::itemIsLink(int index, const KItemListView* view) const
{
Q_UNUSED(index);
Q_UNUSED(view);
return false;
}
@ -682,7 +681,7 @@ void KStandardItemListWidget::dataChanged(const QHash<QByteArray, QVariant>& cur
// The URL might have changed (i.e., if the sort order of the items has
// been changed). Therefore, the "is cut" state must be updated.
KFileItemClipboard* clipboard = KFileItemClipboard::instance();
const KUrl itemUrl = data().value("url").value<KUrl>();
const QUrl itemUrl = data().value("url").value<QUrl>();
m_isCut = clipboard->isCut(itemUrl);
// The icon-state might depend from other roles and hence is
@ -758,10 +757,10 @@ void KStandardItemListWidget::editedRoleChanged(const QByteArray& current, const
if (m_roleEditor) {
emit roleEditingCanceled(index(), current, data().value(current));
disconnect(m_roleEditor, SIGNAL(roleEditingCanceled(QByteArray,QVariant)),
this, SLOT(slotRoleEditingCanceled(QByteArray,QVariant)));
disconnect(m_roleEditor, SIGNAL(roleEditingFinished(QByteArray,QVariant)),
this, SLOT(slotRoleEditingFinished(QByteArray,QVariant)));
disconnect(m_roleEditor, &KItemListRoleEditor::roleEditingCanceled,
this, &KStandardItemListWidget::slotRoleEditingCanceled);
disconnect(m_roleEditor, &KItemListRoleEditor::roleEditingFinished,
this, &KStandardItemListWidget::slotRoleEditingFinished);
if (m_oldRoleEditor) {
m_oldRoleEditor->deleteLater();
@ -796,10 +795,10 @@ void KStandardItemListWidget::editedRoleChanged(const QByteArray& current, const
m_roleEditor->setTextCursor(cursor);
}
connect(m_roleEditor, SIGNAL(roleEditingCanceled(QByteArray,QVariant)),
this, SLOT(slotRoleEditingCanceled(QByteArray,QVariant)));
connect(m_roleEditor, SIGNAL(roleEditingFinished(QByteArray,QVariant)),
this, SLOT(slotRoleEditingFinished(QByteArray,QVariant)));
connect(m_roleEditor, &KItemListRoleEditor::roleEditingCanceled,
this, &KStandardItemListWidget::slotRoleEditingCanceled);
connect(m_roleEditor, &KItemListRoleEditor::roleEditingFinished,
this, &KStandardItemListWidget::slotRoleEditingFinished);
// Adjust the geometry of the editor
QRectF rect = roleEditingRect(current);
@ -833,24 +832,24 @@ void KStandardItemListWidget::showEvent(QShowEvent* event)
// Listen to changes of the clipboard to mark the item as cut/uncut
KFileItemClipboard* clipboard = KFileItemClipboard::instance();
const KUrl itemUrl = data().value("url").value<KUrl>();
const QUrl itemUrl = data().value("url").value<QUrl>();
m_isCut = clipboard->isCut(itemUrl);
connect(clipboard, SIGNAL(cutItemsChanged()),
this, SLOT(slotCutItemsChanged()));
connect(clipboard, &KFileItemClipboard::cutItemsChanged,
this, &KStandardItemListWidget::slotCutItemsChanged);
}
void KStandardItemListWidget::hideEvent(QHideEvent* event)
{
disconnect(KFileItemClipboard::instance(), SIGNAL(cutItemsChanged()),
this, SLOT(slotCutItemsChanged()));
disconnect(KFileItemClipboard::instance(), &KFileItemClipboard::cutItemsChanged,
this, &KStandardItemListWidget::slotCutItemsChanged);
KItemListWidget::hideEvent(event);
}
void KStandardItemListWidget::slotCutItemsChanged()
{
const KUrl itemUrl = data().value("url").value<KUrl>();
const QUrl itemUrl = data().value("url").value<QUrl>();
const bool isCut = KFileItemClipboard::instance()->isCut(itemUrl);
if (m_isCut != isCut) {
m_isCut = isCut;
@ -1415,10 +1414,10 @@ QRectF KStandardItemListWidget::roleEditingRect(const QByteArray& role) const
void KStandardItemListWidget::closeRoleEditor()
{
disconnect(m_roleEditor, SIGNAL(roleEditingCanceled(QByteArray,QVariant)),
this, SLOT(slotRoleEditingCanceled(QByteArray,QVariant)));
disconnect(m_roleEditor, SIGNAL(roleEditingFinished(QByteArray,QVariant)),
this, SLOT(slotRoleEditingFinished(QByteArray,QVariant)));
disconnect(m_roleEditor, &KItemListRoleEditor::roleEditingCanceled,
this, &KStandardItemListWidget::slotRoleEditingCanceled);
disconnect(m_roleEditor, &KItemListRoleEditor::roleEditingFinished,
this, &KStandardItemListWidget::slotRoleEditingFinished);
if (m_roleEditor->hasFocus()) {
// If the editing was not ended by a FocusOut event, we have
@ -1440,7 +1439,7 @@ QPixmap KStandardItemListWidget::pixmapForIcon(const QString& name, const QStrin
QPixmap pixmap;
if (!QPixmapCache::find(key, pixmap)) {
const KIcon icon(name);
const QIcon icon = QIcon::fromTheme(name);
int requestedSize;
if (size <= KIconLoader::SizeSmall) {
@ -1497,4 +1496,3 @@ qreal KStandardItemListWidget::columnPadding(const KItemListStyleOption& option)
return option.padding * 6;
}
#include "kstandarditemlistwidget.moc"

View File

@ -20,7 +20,7 @@
#ifndef KSTANDARDITEMLISTWIDGET_H
#define KSTANDARDITEMLISTWIDGET_H
#include <libdolphin_export.h>
#include "dolphin_export.h"
#include <kitemviews/kitemlistwidget.h>
@ -32,17 +32,17 @@ class KItemListRoleEditor;
class KItemListStyleOption;
class KItemListView;
class LIBDOLPHINPRIVATE_EXPORT KStandardItemListWidgetInformant : public KItemListWidgetInformant
class DOLPHIN_EXPORT KStandardItemListWidgetInformant : public KItemListWidgetInformant
{
public:
KStandardItemListWidgetInformant();
virtual ~KStandardItemListWidgetInformant();
virtual void calculateItemSizeHints(QVector<qreal>& logicalHeightHints, qreal& logicalWidthHint, const KItemListView* view) const;
virtual void calculateItemSizeHints(QVector<qreal>& logicalHeightHints, qreal& logicalWidthHint, const KItemListView* view) const Q_DECL_OVERRIDE;
virtual qreal preferredRoleColumnWidth(const QByteArray& role,
int index,
const KItemListView* view) const;
const KItemListView* view) const Q_DECL_OVERRIDE;
protected:
/**
* @return The value of the "text" role. The default implementation returns
@ -83,7 +83,7 @@ protected:
/**
* @brief Itemlist widget implementation for KStandardItemView and KStandardItemModel.
*/
class LIBDOLPHINPRIVATE_EXPORT KStandardItemListWidget : public KItemListWidget
class DOLPHIN_EXPORT KStandardItemListWidget : public KItemListWidget
{
Q_OBJECT
@ -106,13 +106,13 @@ public:
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
virtual QRectF iconRect() const;
virtual QRectF textRect() const;
virtual QRectF textFocusRect() const;
virtual QRectF selectionRect() const;
virtual QRectF expansionToggleRect() const;
virtual QRectF selectionToggleRect() const;
virtual QPixmap createDragPixmap(const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
virtual QRectF iconRect() const Q_DECL_OVERRIDE;
virtual QRectF textRect() const Q_DECL_OVERRIDE;
virtual QRectF textFocusRect() const Q_DECL_OVERRIDE;
virtual QRectF selectionRect() const Q_DECL_OVERRIDE;
virtual QRectF expansionToggleRect() const Q_DECL_OVERRIDE;
virtual QRectF selectionToggleRect() const Q_DECL_OVERRIDE;
virtual QPixmap createDragPixmap(const QStyleOptionGraphicsItem* option, QWidget* widget = 0) Q_DECL_OVERRIDE;
static KItemListWidgetInformant* createInformant();
@ -172,17 +172,17 @@ protected:
*/
virtual int selectionLength(const QString& text) const;
virtual void dataChanged(const QHash<QByteArray, QVariant>& current, const QSet<QByteArray>& roles = QSet<QByteArray>());
virtual void visibleRolesChanged(const QList<QByteArray>& current, const QList<QByteArray>& previous);
virtual void columnWidthChanged(const QByteArray& role, qreal current, qreal previous);
virtual void styleOptionChanged(const KItemListStyleOption& current, const KItemListStyleOption& previous);
virtual void hoveredChanged(bool hovered);
virtual void selectedChanged(bool selected);
virtual void siblingsInformationChanged(const QBitArray& current, const QBitArray& previous);
virtual void editedRoleChanged(const QByteArray& current, const QByteArray& previous);
virtual void resizeEvent(QGraphicsSceneResizeEvent* event);
virtual void showEvent(QShowEvent* event);
virtual void hideEvent(QHideEvent* event);
virtual void dataChanged(const QHash<QByteArray, QVariant>& current, const QSet<QByteArray>& roles = QSet<QByteArray>()) Q_DECL_OVERRIDE;
virtual void visibleRolesChanged(const QList<QByteArray>& current, const QList<QByteArray>& previous) Q_DECL_OVERRIDE;
virtual void columnWidthChanged(const QByteArray& role, qreal current, qreal previous) Q_DECL_OVERRIDE;
virtual void styleOptionChanged(const KItemListStyleOption& current, const KItemListStyleOption& previous) Q_DECL_OVERRIDE;
virtual void hoveredChanged(bool hovered) Q_DECL_OVERRIDE;
virtual void selectedChanged(bool selected) Q_DECL_OVERRIDE;
virtual void siblingsInformationChanged(const QBitArray& current, const QBitArray& previous) Q_DECL_OVERRIDE;
virtual void editedRoleChanged(const QByteArray& current, const QByteArray& previous) Q_DECL_OVERRIDE;
virtual void resizeEvent(QGraphicsSceneResizeEvent* event) Q_DECL_OVERRIDE;
virtual void showEvent(QShowEvent* event) Q_DECL_OVERRIDE;
virtual void hideEvent(QHideEvent* event) Q_DECL_OVERRIDE;
private slots:
void slotCutItemsChanged();
@ -274,5 +274,3 @@ private:
};
#endif

View File

@ -19,9 +19,9 @@
#include "kstandarditemmodel.h"
#include <KDebug>
#include "kstandarditem.h"
#include <QSet>
#include <QByteArray>
KStandardItemModel::KStandardItemModel(QObject* parent) :
KItemModelBase(parent),
m_items(),
@ -237,5 +237,3 @@ void KStandardItemModel::onItemRemoved(int index, KStandardItem* removedItem)
Q_UNUSED(removedItem);
}
#include "kstandarditemmodel.moc"

View File

@ -20,7 +20,7 @@
#ifndef KSTANDARDITEMMODEL_H
#define KSTANDARDITEMMODEL_H
#include <libdolphin_export.h>
#include "dolphin_export.h"
#include <kitemviews/kitemmodelbase.h>
#include <QHash>
#include <QList>
@ -35,7 +35,7 @@ class KStandardItem;
*
* @see KStandardItem
*/
class LIBDOLPHINPRIVATE_EXPORT KStandardItemModel : public KItemModelBase
class DOLPHIN_EXPORT KStandardItemModel : public KItemModelBase
{
Q_OBJECT
@ -69,14 +69,14 @@ public:
*/
void appendItem(KStandardItem* item);
virtual int count() const;
virtual QHash<QByteArray, QVariant> data(int index) const;
virtual bool setData(int index, const QHash<QByteArray, QVariant>& values);
virtual QMimeData* createMimeData(const KItemSet& indexes) const;
virtual int indexForKeyboardSearch(const QString& text, int startFromIndex = 0) const;
virtual bool supportsDropping(int index) const;
virtual QString roleDescription(const QByteArray& role) const;
virtual QList<QPair<int, QVariant> > groups() const;
virtual int count() const Q_DECL_OVERRIDE;
virtual QHash<QByteArray, QVariant> data(int index) const Q_DECL_OVERRIDE;
virtual bool setData(int index, const QHash<QByteArray, QVariant>& values) Q_DECL_OVERRIDE;
virtual QMimeData* createMimeData(const KItemSet& indexes) const Q_DECL_OVERRIDE;
virtual int indexForKeyboardSearch(const QString& text, int startFromIndex = 0) const Q_DECL_OVERRIDE;
virtual bool supportsDropping(int index) const Q_DECL_OVERRIDE;
virtual QString roleDescription(const QByteArray& role) const Q_DECL_OVERRIDE;
virtual QList<QPair<int, QVariant> > groups() const Q_DECL_OVERRIDE;
virtual void clear();
protected:

View File

@ -20,12 +20,12 @@
#include "kbaloorolesprovider.h"
#include <KDebug>
#include <KGlobal>
#include <KLocale>
#include <QDebug>
#include <KLocalizedString>
#include <baloo/file.h>
#include <kfilemetadata/propertyinfo.h>
#include <Baloo/File>
#include <KFileMetaData/PropertyInfo>
#include <KFileMetaData/UserMetaData>
#include <QTime>
#include <QMap>
@ -34,7 +34,7 @@ struct KBalooRolesProviderSingleton
{
KBalooRolesProvider instance;
};
K_GLOBAL_STATIC(KBalooRolesProviderSingleton, s_balooRolesProvider)
Q_GLOBAL_STATIC(KBalooRolesProviderSingleton, s_balooRolesProvider)
KBalooRolesProvider& KBalooRolesProvider::instance()
@ -99,14 +99,15 @@ QHash<QByteArray, QVariant> KBalooRolesProvider::roleValues(const Baloo::File& f
}
}
KFileMetaData::UserMetaData md(file.path());
if (roles.contains("tags")) {
values.insert("tags", tagsFromValues(file.tags()));
values.insert("tags", tagsFromValues(md.tags()));
}
if (roles.contains("rating")) {
values.insert("rating", QString::number(file.rating()));
values.insert("rating", QString::number(md.rating()));
}
if (roles.contains("comment")) {
values.insert("comment", file.userComment());
values.insert("comment", md.userComment());
}
return values;

View File

@ -21,12 +21,11 @@
#ifndef KBALOO_ROLESPROVIDER_H
#define KBALOO_ROLESPROVIDER_H
#include <libdolphin_export.h>
#include "dolphin_export.h"
#include <QHash>
#include <QSet>
#include <QUrl>
#include <QVariant>
namespace Baloo {
class File;
}
@ -37,7 +36,7 @@ namespace Baloo {
* Is a helper class for KFileItemModelRolesUpdater to retrieve roles that
* are only accessible with Baloo.
*/
class LIBDOLPHINPRIVATE_EXPORT KBalooRolesProvider
class DOLPHIN_EXPORT KBalooRolesProvider
{
public:
static KBalooRolesProvider& instance();

View File

@ -35,8 +35,8 @@ KDirectoryContentsCounter::KDirectoryContentsCounter(KFileItemModel* model, QObj
m_dirWatcher(0),
m_watchedDirs()
{
connect(m_model, SIGNAL(itemsRemoved(KItemRangeList)),
this, SLOT(slotItemsRemoved()));
connect(m_model, &KFileItemModel::itemsRemoved,
this, &KDirectoryContentsCounter::slotItemsRemoved);
if (!m_workerThread) {
m_workerThread = new QThread();
@ -47,13 +47,13 @@ KDirectoryContentsCounter::KDirectoryContentsCounter(KFileItemModel* model, QObj
m_worker->moveToThread(m_workerThread);
++m_workersCount;
connect(this, SIGNAL(requestDirectoryContentsCount(QString,KDirectoryContentsCounterWorker::Options)),
m_worker, SLOT(countDirectoryContents(QString,KDirectoryContentsCounterWorker::Options)));
connect(m_worker, SIGNAL(result(QString,int)),
this, SLOT(slotResult(QString,int)));
connect(this, &KDirectoryContentsCounter::requestDirectoryContentsCount,
m_worker, &KDirectoryContentsCounterWorker::countDirectoryContents);
connect(m_worker, &KDirectoryContentsCounterWorker::result,
this, &KDirectoryContentsCounter::slotResult);
m_dirWatcher = new KDirWatch(this);
connect(m_dirWatcher, SIGNAL(dirty(QString)), this, SLOT(slotDirWatchDirty(QString)));
connect(m_dirWatcher, &KDirWatch::dirty, this, &KDirectoryContentsCounter::slotDirWatchDirty);
}
KDirectoryContentsCounter::~KDirectoryContentsCounter()
@ -122,7 +122,7 @@ void KDirectoryContentsCounter::slotResult(const QString& path, int count)
void KDirectoryContentsCounter::slotDirWatchDirty(const QString& path)
{
const int index = m_model->index(KUrl(path));
const int index = m_model->index(QUrl::fromLocalFile(path));
if (index >= 0) {
if (!m_model->fileItem(index).isDir()) {
// If INotify is used, KDirWatch issues the dirty() signal
@ -151,7 +151,7 @@ void KDirectoryContentsCounter::slotItemsRemoved()
QMutableSetIterator<QString> it(m_watchedDirs);
while (it.hasNext()) {
const QString& path = it.next();
if (m_model->index(KUrl(path)) < 0) {
if (m_model->index(QUrl::fromLocalFile(path)) < 0) {
m_dirWatcher->removeDir(path);
it.remove();
}
@ -181,4 +181,4 @@ void KDirectoryContentsCounter::startWorker(const QString& path)
}
QThread* KDirectoryContentsCounter::m_workerThread = 0;
int KDirectoryContentsCounter::m_workersCount = 0;
int KDirectoryContentsCounter::m_workersCount = 0;

View File

@ -20,7 +20,6 @@
#ifndef KDIRECTORYCONTENTENTSCOUNTERWORKER_H
#define KDIRECTORYCONTENTENTSCOUNTERWORKER_H
#include <QFlags>
#include <QMetaType>
#include <QObject>

View File

@ -19,17 +19,17 @@
#include "kfileitemclipboard.h"
#include <KGlobal>
#include <QApplication>
#include <QClipboard>
#include <QMimeData>
#include <KUrlMimeData>
class KFileItemClipboardSingleton
{
public:
KFileItemClipboard instance;
};
K_GLOBAL_STATIC(KFileItemClipboardSingleton, s_KFileItemClipboard)
Q_GLOBAL_STATIC(KFileItemClipboardSingleton, s_KFileItemClipboard)
@ -38,12 +38,12 @@ KFileItemClipboard* KFileItemClipboard::instance()
return &s_KFileItemClipboard->instance;
}
bool KFileItemClipboard::isCut(const KUrl& url) const
bool KFileItemClipboard::isCut(const QUrl& url) const
{
return m_cutItems.contains(url);
}
QList<KUrl> KFileItemClipboard::cutItems() const
QList<QUrl> KFileItemClipboard::cutItems() const
{
return m_cutItems.toList();
}
@ -66,7 +66,7 @@ void KFileItemClipboard::updateCutItems()
const QByteArray data = mimeData->data("application/x-kde-cutselection");
const bool isCutSelection = (!data.isEmpty() && data.at(0) == QLatin1Char('1'));
if (isCutSelection) {
m_cutItems = KUrl::List::fromMimeData(mimeData).toSet();
m_cutItems = KUrlMimeData::urlsFromMimeData(mimeData).toSet();
} else {
m_cutItems.clear();
}
@ -79,8 +79,6 @@ KFileItemClipboard::KFileItemClipboard() :
{
updateCutItems();
connect(QApplication::clipboard(), SIGNAL(dataChanged()),
this, SLOT(updateCutItems()));
connect(QApplication::clipboard(), &QClipboard::dataChanged,
this, &KFileItemClipboard::updateCutItems);
}
#include "kfileitemclipboard.moc"

View File

@ -20,27 +20,27 @@
#ifndef KFILEITEMCLIPBOARD_H
#define KFILEITEMCLIPBOARD_H
#include <KUrl>
#include <QUrl>
#include <QList>
#include <QSet>
#include <QObject>
#include "libdolphin_export.h"
#include "dolphin_export.h"
/**
* @brief Wrapper for QClipboard to provide fast access for checking
* whether a KFileItem has been clipped.
*/
class LIBDOLPHINPRIVATE_EXPORT KFileItemClipboard : public QObject
class DOLPHIN_EXPORT KFileItemClipboard : public QObject
{
Q_OBJECT
public:
static KFileItemClipboard* instance();
bool isCut(const KUrl& url) const;
bool isCut(const QUrl& url) const;
QList<KUrl> cutItems() const;
QList<QUrl> cutItems() const;
signals:
void cutItemsChanged();
@ -54,7 +54,7 @@ private slots:
private:
KFileItemClipboard();
QSet<KUrl> m_cutItems;
QSet<QUrl> m_cutItems;
friend class KFileItemClipboardSingleton;
};

View File

@ -18,8 +18,8 @@
***************************************************************************/
#include "kfileitemmodeldirlister.h"
#include <KLocale>
#include <KIO/JobClasses>
#include <KLocalizedString>
#include <KIO/Job>
KFileItemModelDirLister::KFileItemModelDirLister(QObject* parent) :
KDirLister(parent)
@ -45,4 +45,3 @@ void KFileItemModelDirLister::handleError(KIO::Job* job)
}
}
#include "kfileitemmodeldirlister.moc"

Some files were not shown because too many files have changed in this diff Show More