Merge branch 'frameworks'
125
CMakeLists.txt
|
@ -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(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)
|
||||||
|
|
||||||
|
|
6
DolphinVcsConfig.cmake.in
Normal 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
|
@ -0,0 +1,2 @@
|
||||||
|
|
||||||
|
kdoctools_create_handbook(index.docbook INSTALL_DESTINATION ${HTML_INSTALL_DIR}/en SUBDIR dolphin)
|
BIN
docs/default-ui.png
Normal file
After Width: | Height: | Size: 120 KiB |
BIN
docs/grouping-view.png
Normal file
After Width: | Height: | Size: 61 KiB |
2134
docs/index.docbook
Normal file
BIN
docs/locationbar-breadcrumb.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
docs/locationbar-context-menu.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
docs/locationbar-editable.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
docs/locationbar-kioslaves-menu.png
Normal file
After Width: | Height: | Size: 9.2 KiB |
BIN
docs/locationbar-places-icon.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
docs/nepomuk-search-more-options.png
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
docs/nepomuk-search.png
Normal file
After Width: | Height: | Size: 8.7 KiB |
BIN
docs/preferences-general-behavior.png
Normal file
After Width: | Height: | Size: 59 KiB |
BIN
docs/preferences-navigation.png
Normal file
After Width: | Height: | Size: 37 KiB |
BIN
docs/preferences-services.png
Normal file
After Width: | Height: | Size: 51 KiB |
BIN
docs/preferences-startup.png
Normal file
After Width: | Height: | Size: 38 KiB |
BIN
docs/preferences-trash.png
Normal file
After Width: | Height: | Size: 36 KiB |
BIN
docs/preferences-viewmodes-icons.png
Normal file
After Width: | Height: | Size: 43 KiB |
BIN
docs/toolbar-navigation.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
docs/toolbar-view-appearance.png
Normal file
After Width: | Height: | Size: 6.3 KiB |
BIN
docs/toolbar.png
Normal file
After Width: | Height: | Size: 8.6 KiB |
BIN
docs/viewproperties-dialog.png
Normal file
After Width: | Height: | Size: 33 KiB |
|
@ -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)
|
configure_file(config-baloo.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-baloo.h)
|
||||||
set_package_properties(BalooWidgets PROPERTIES DESCRIPTION "Baloos Widgets"
|
|
||||||
URL "http://www.kde.org"
|
|
||||||
TYPE OPTIONAL
|
|
||||||
)
|
|
||||||
|
|
||||||
macro_optional_find_package(KFileMetaData)
|
configure_file(config-dolphin.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-dolphin.h)
|
||||||
set_package_properties(KFileMetaData PROPERTIES
|
|
||||||
URL "https://projects.kde.org/kfilemetadata"
|
|
||||||
TYPE OPTIONAL
|
|
||||||
PURPOSE "For accessing file metadata labels"
|
|
||||||
)
|
|
||||||
|
|
||||||
if (Baloo_FOUND AND BalooWidgets_FOUND AND KFileMetaData_FOUND)
|
add_definitions(
|
||||||
set(HAVE_BALOO TRUE)
|
-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()
|
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)
|
add_library(dolphinvcs ${dolphinvcs_LIB_SRCS})
|
||||||
include_directories(${BALOO_INCLUDE_DIR} ${BALOO_WIDGETS_INCLUDE_DIR} ${KFILEMETADATA_INCLUDE_DIR})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
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 ###############
|
########### next target ###############
|
||||||
|
|
||||||
|
@ -95,6 +118,7 @@ set(dolphinprivate_LIB_SRCS
|
||||||
views/zoomlevelinfo.cpp
|
views/zoomlevelinfo.cpp
|
||||||
dolphinremoveaction.cpp
|
dolphinremoveaction.cpp
|
||||||
dolphinnewfilemenu.cpp
|
dolphinnewfilemenu.cpp
|
||||||
|
dolphindebug.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
if(HAVE_BALOO)
|
if(HAVE_BALOO)
|
||||||
|
@ -104,7 +128,7 @@ if(HAVE_BALOO)
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
kde4_add_kcfg_files(dolphinprivate_LIB_SRCS
|
kconfig_add_kcfg_files(dolphinprivate_LIB_SRCS GENERATE_MOC
|
||||||
settings/dolphin_compactmodesettings.kcfgc
|
settings/dolphin_compactmodesettings.kcfgc
|
||||||
settings/dolphin_directoryviewpropertysettings.kcfgc
|
settings/dolphin_directoryviewpropertysettings.kcfgc
|
||||||
settings/dolphin_detailsmodesettings.kcfgc
|
settings/dolphin_detailsmodesettings.kcfgc
|
||||||
|
@ -113,21 +137,35 @@ kde4_add_kcfg_files(dolphinprivate_LIB_SRCS
|
||||||
settings/dolphin_versioncontrolsettings.kcfgc
|
settings/dolphin_versioncontrolsettings.kcfgc
|
||||||
)
|
)
|
||||||
|
|
||||||
kde4_add_library(dolphinprivate SHARED ${dolphinprivate_LIB_SRCS})
|
add_library(dolphinprivate ${dolphinprivate_LIB_SRCS})
|
||||||
|
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
dolphinprivate
|
dolphinprivate PUBLIC
|
||||||
${KDE4_KFILE_LIBS}
|
dolphinvcs
|
||||||
konq
|
Qt5::Gui
|
||||||
${KDE4_KNEWSTUFF3_LIBS}
|
KF5::I18n
|
||||||
|
KF5::IconThemes
|
||||||
|
KF5::KIOCore
|
||||||
|
KF5::KIOWidgets
|
||||||
|
KF5::KIOFileWidgets
|
||||||
|
KF5::Completion
|
||||||
|
KF5::TextEditor
|
||||||
|
KF5::WindowSystem
|
||||||
|
KF5::ConfigCore
|
||||||
|
KF5::NewStuff
|
||||||
)
|
)
|
||||||
|
|
||||||
if(HAVE_BALOO)
|
if(HAVE_BALOO)
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
dolphinprivate
|
dolphinprivate PUBLIC
|
||||||
${BALOO_LIBRARIES}
|
KF5::FileMetaData
|
||||||
${BALOO_WIDGETS_LIBRARY}
|
KF5::Baloo
|
||||||
${KFILEMETADATA_LIBRARY}
|
KF5::BalooWidgets
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
target_link_libraries(
|
||||||
|
dolphinprivate PUBLIC
|
||||||
|
KF5::KDELibs4Support # for KFileMetaDataWidget
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -135,38 +173,35 @@ if(X11_Xrender_FOUND)
|
||||||
target_link_libraries(dolphinprivate ${X11_Xrender_LIB})
|
target_link_libraries(dolphinprivate ${X11_Xrender_LIB})
|
||||||
endif(X11_Xrender_FOUND)
|
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 ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
|
||||||
install(TARGETS dolphinprivate ${INSTALL_TARGETS_DEFAULT_ARGS})
|
|
||||||
|
|
||||||
##########################################
|
##########################################
|
||||||
|
|
||||||
set(dolphinpart_SRCS
|
set(dolphinpart_SRCS
|
||||||
dolphinpart.cpp
|
dolphinpart.cpp
|
||||||
|
dolphinpart_ext.cpp
|
||||||
|
dolphindebug.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
# Add dolphinpart_ext.cpp conditionally, only with KDE > 4.9.1.
|
add_library(dolphinpart MODULE ${dolphinpart_SRCS})
|
||||||
if (${KDE_VERSION} VERSION_GREATER "4.9.1")
|
|
||||||
set(dolphinpart_SRCS
|
|
||||||
${dolphinpart_SRCS}
|
|
||||||
dolphinpart_ext.cpp)
|
|
||||||
endif (${KDE_VERSION} VERSION_GREATER "4.9.1")
|
|
||||||
|
|
||||||
kde4_add_plugin(dolphinpart ${dolphinpart_SRCS})
|
target_link_libraries(dolphinpart
|
||||||
|
dolphinprivate
|
||||||
target_link_libraries(dolphinpart dolphinprivate konq ${KDE4_KPARTS_LIBS} ${KDE4_KFILE_LIBS})
|
)
|
||||||
|
|
||||||
install(TARGETS dolphinpart DESTINATION ${PLUGIN_INSTALL_DIR})
|
install(TARGETS dolphinpart DESTINATION ${PLUGIN_INSTALL_DIR})
|
||||||
|
|
||||||
install(FILES dolphinpart.rc DESTINATION ${DATA_INSTALL_DIR}/dolphinpart)
|
install(FILES dolphinpart.rc DESTINATION ${CMAKE_INSTALL_KXMLGUI5DIR}/dolphinpart)
|
||||||
install(FILES dolphinpart.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
|
install(FILES dolphinpart.desktop DESTINATION ${SERVICES_INSTALL_DIR})
|
||||||
install(FILES views/versioncontrol/fileviewversioncontrolplugin.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR})
|
|
||||||
|
|
||||||
##########################################
|
##########################################
|
||||||
|
|
||||||
set(dolphin_SRCS
|
set(dolphin_SRCS
|
||||||
dolphinapplication.cpp
|
|
||||||
dolphindockwidget.cpp
|
dolphindockwidget.cpp
|
||||||
dolphinmainwindow.cpp
|
dolphinmainwindow.cpp
|
||||||
dolphinviewcontainer.cpp
|
dolphinviewcontainer.cpp
|
||||||
|
@ -217,12 +252,14 @@ set(dolphin_SRCS
|
||||||
statusbar/dolphinstatusbar.cpp
|
statusbar/dolphinstatusbar.cpp
|
||||||
statusbar/mountpointobserver.cpp
|
statusbar/mountpointobserver.cpp
|
||||||
statusbar/mountpointobservercache.cpp
|
statusbar/mountpointobservercache.cpp
|
||||||
|
statusbar/spaceinfotoolsmenu.cpp
|
||||||
statusbar/spaceinfoobserver.cpp
|
statusbar/spaceinfoobserver.cpp
|
||||||
statusbar/statusbarspaceinfo.cpp
|
statusbar/statusbarspaceinfo.cpp
|
||||||
views/zoomlevelinfo.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/folders/dolphin_folderspanelsettings.kcfgc
|
||||||
panels/information/dolphin_informationpanelsettings.kcfgc
|
panels/information/dolphin_informationpanelsettings.kcfgc
|
||||||
panels/places/dolphin_placespanelsettings.kcfgc
|
panels/places/dolphin_placespanelsettings.kcfgc
|
||||||
|
@ -236,40 +273,36 @@ kde4_add_kcfg_files(dolphin_SRCS
|
||||||
|
|
||||||
if(NOT WIN32)
|
if(NOT WIN32)
|
||||||
set(dolphin_SRCS ${dolphin_SRCS} panels/terminal/terminalpanel.cpp)
|
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
|
target_link_libraries(kdeinit_dolphin
|
||||||
${KDE4_KDEPRINT_LIBS}
|
|
||||||
${KDE4_KFILE_LIBS}
|
|
||||||
${KDE4_KPARTS_LIBS}
|
|
||||||
${KDE4_KCMUTILS_LIBRARY}
|
|
||||||
konq
|
|
||||||
dolphinprivate
|
dolphinprivate
|
||||||
knewstuff3
|
KF5::Parts
|
||||||
${KDE4_SOLID_LIBS}
|
KF5::KCMUtils
|
||||||
${KDE4_PHONON_LIBS}
|
KF5::Solid
|
||||||
|
KF5::CoreAddons
|
||||||
|
KF5::DBusAddons
|
||||||
|
KF5::Bookmarks
|
||||||
|
KF5::Notifications
|
||||||
|
Phonon::phonon4qt5
|
||||||
)
|
)
|
||||||
|
|
||||||
if(HAVE_BALOO)
|
if (KF5Activities_FOUND)
|
||||||
target_link_libraries(kdeinit_dolphin
|
target_link_libraries(
|
||||||
${BALOO_LIBRARIES}
|
kdeinit_dolphin
|
||||||
${BALOO_WIDGETS_LIBRARY}
|
KF5::Activities
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (KActivities_FOUND)
|
install(TARGETS kdeinit_dolphin ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
|
||||||
target_link_libraries(
|
install(TARGETS dolphin ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
|
||||||
kdeinit_dolphin
|
|
||||||
${KACTIVITIES_LIBRARY}
|
|
||||||
)
|
|
||||||
endif (KActivities_FOUND)
|
|
||||||
|
|
||||||
install(TARGETS kdeinit_dolphin ${INSTALL_TARGETS_DEFAULT_ARGS})
|
|
||||||
install(TARGETS dolphin ${INSTALL_TARGETS_DEFAULT_ARGS})
|
|
||||||
|
|
||||||
##########################################
|
##########################################
|
||||||
|
|
||||||
|
@ -302,7 +335,7 @@ set(kcm_dolphingeneral_PART_SRCS
|
||||||
settings/serviceitemdelegate.cpp
|
settings/serviceitemdelegate.cpp
|
||||||
settings/servicemodel.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_compactmodesettings.kcfgc
|
||||||
settings/dolphin_directoryviewpropertysettings.kcfgc
|
settings/dolphin_directoryviewpropertysettings.kcfgc
|
||||||
settings/dolphin_detailsmodesettings.kcfgc
|
settings/dolphin_detailsmodesettings.kcfgc
|
||||||
|
@ -311,42 +344,34 @@ kde4_add_kcfg_files(kcm_dolphinviewmodes_PART_SRCS
|
||||||
settings/dolphin_versioncontrolsettings.kcfgc
|
settings/dolphin_versioncontrolsettings.kcfgc
|
||||||
)
|
)
|
||||||
|
|
||||||
kde4_add_kcfg_files(kcm_dolphinnavigation_PART_SRCS
|
kconfig_add_kcfg_files(kcm_dolphinnavigation_PART_SRCS
|
||||||
settings/dolphin_generalsettings.kcfgc)
|
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_generalsettings.kcfgc
|
||||||
settings/dolphin_versioncontrolsettings.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)
|
settings/dolphin_generalsettings.kcfgc)
|
||||||
|
|
||||||
kde4_add_plugin(kcm_dolphinviewmodes ${kcm_dolphinviewmodes_PART_SRCS})
|
add_library(kcm_dolphinviewmodes MODULE ${kcm_dolphinviewmodes_PART_SRCS})
|
||||||
kde4_add_plugin(kcm_dolphinnavigation ${kcm_dolphinnavigation_PART_SRCS})
|
add_library(kcm_dolphinnavigation MODULE ${kcm_dolphinnavigation_PART_SRCS})
|
||||||
kde4_add_plugin(kcm_dolphinservices ${kcm_dolphinservices_PART_SRCS})
|
add_library(kcm_dolphinservices MODULE ${kcm_dolphinservices_PART_SRCS})
|
||||||
kde4_add_plugin(kcm_dolphingeneral ${kcm_dolphingeneral_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_dolphinviewmodes dolphinprivate)
|
||||||
target_link_libraries(kcm_dolphinnavigation ${KDE4_KDEUI_LIBS} ${KDE4_KFILE_LIBS} dolphinprivate)
|
target_link_libraries(kcm_dolphinnavigation dolphinprivate)
|
||||||
target_link_libraries(kcm_dolphinservices ${KDE4_KDEUI_LIBS} ${KDE4_KFILE_LIBS} ${KDE4_KIO_LIBS} ${KDE4_KNEWSTUFF3_LIBRARY} dolphinprivate)
|
target_link_libraries(kcm_dolphinservices dolphinprivate)
|
||||||
target_link_libraries(kcm_dolphingeneral ${KDE4_KDEUI_LIBS} ${KDE4_KFILE_LIBS} ${KDE4_KIO_LIBS} dolphinprivate)
|
target_link_libraries(kcm_dolphingeneral dolphinprivate)
|
||||||
|
|
||||||
install(TARGETS kcm_dolphinviewmodes DESTINATION ${PLUGIN_INSTALL_DIR} )
|
install(TARGETS kcm_dolphinviewmodes DESTINATION ${PLUGIN_INSTALL_DIR} )
|
||||||
install(TARGETS kcm_dolphinnavigation DESTINATION ${PLUGIN_INSTALL_DIR} )
|
install(TARGETS kcm_dolphinnavigation DESTINATION ${PLUGIN_INSTALL_DIR} )
|
||||||
install(TARGETS kcm_dolphinservices DESTINATION ${PLUGIN_INSTALL_DIR} )
|
install(TARGETS kcm_dolphinservices DESTINATION ${PLUGIN_INSTALL_DIR} )
|
||||||
install(TARGETS kcm_dolphingeneral 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 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
|
install( FILES settings/dolphin_directoryviewpropertysettings.kcfg
|
||||||
settings/dolphin_generalsettings.kcfg
|
settings/dolphin_generalsettings.kcfg
|
||||||
settings/dolphin_compactmodesettings.kcfg
|
settings/dolphin_compactmodesettings.kcfg
|
||||||
|
@ -354,9 +379,8 @@ install( FILES settings/dolphin_directoryviewpropertysettings.kcfg
|
||||||
settings/dolphin_detailsmodesettings.kcfg
|
settings/dolphin_detailsmodesettings.kcfg
|
||||||
settings/dolphin_versioncontrolsettings.kcfg
|
settings/dolphin_versioncontrolsettings.kcfg
|
||||||
DESTINATION ${KCFG_INSTALL_DIR} )
|
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 dolphin.appdata.xml DESTINATION ${SHARE_INSTALL_PREFIX}/appdata )
|
||||||
install( FILES search/filenamesearch.protocol DESTINATION ${SERVICES_INSTALL_DIR} )
|
|
||||||
install( FILES settings/kcm/kcmdolphinviewmodes.desktop DESTINATION
|
install( FILES settings/kcm/kcmdolphinviewmodes.desktop DESTINATION
|
||||||
${SERVICES_INSTALL_DIR} )
|
${SERVICES_INSTALL_DIR} )
|
||||||
install( FILES settings/kcm/kcmdolphinnavigation.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/servicemenuinstallation DESTINATION ${BIN_INSTALL_DIR} )
|
||||||
install( PROGRAMS settings/services/servicemenudeinstallation 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()
|
||||||
|
|
4
src/config-dolphin.h.cmake
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
|
||||||
|
/* Define to 1 if you have the KActivities library. */
|
||||||
|
#cmakedefine KF5Activities_FOUND 1
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<component type="desktop">
|
<component type="desktop">
|
||||||
<id>dolphin.desktop</id>
|
<id>org.kde.dolphin.desktop</id>
|
||||||
<metadata_license>CC0-1.0</metadata_license>
|
<metadata_license>CC0-1.0</metadata_license>
|
||||||
<project_license>GPL-2.0+</project_license>
|
<project_license>GPL-2.0+</project_license>
|
||||||
<name>Dolphin</name>
|
<name>Dolphin</name>
|
||||||
|
|
|
@ -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"
|
|
|
@ -27,34 +27,30 @@
|
||||||
#include "dolphinremoveaction.h"
|
#include "dolphinremoveaction.h"
|
||||||
|
|
||||||
#include <KActionCollection>
|
#include <KActionCollection>
|
||||||
#include <KDesktopFile>
|
#include <KAbstractFileItemActionPlugin>
|
||||||
#include <kfileitemactionplugin.h>
|
|
||||||
#include <kabstractfileitemactionplugin.h>
|
|
||||||
#include <KFileItemActions>
|
#include <KFileItemActions>
|
||||||
#include <KFileItemListProperties>
|
#include <KFileItemListProperties>
|
||||||
#include <KGlobal>
|
#include <KIO/RestoreJob>
|
||||||
#include <KIconLoader>
|
#include <KIO/EmptyTrashJob>
|
||||||
#include <KIO/NetAccess>
|
#include <KIO/JobUiDelegate>
|
||||||
#include <KMenu>
|
#include <KIO/Paste>
|
||||||
#include <KMenuBar>
|
#include <KJobWidgets>
|
||||||
#include <KMessageBox>
|
|
||||||
#include <KMimeTypeTrader>
|
#include <KMimeTypeTrader>
|
||||||
#include <KNewFileMenu>
|
#include <KNewFileMenu>
|
||||||
#include <konqmimedata.h>
|
|
||||||
#include <konq_operations.h>
|
|
||||||
#include <KService>
|
#include <KService>
|
||||||
#include <KLocale>
|
#include <KLocalizedString>
|
||||||
#include <KPropertiesDialog>
|
|
||||||
#include <KStandardAction>
|
#include <KStandardAction>
|
||||||
#include <KStandardDirs>
|
|
||||||
#include <KToolBar>
|
#include <KToolBar>
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QClipboard>
|
||||||
|
#include <QKeyEvent>
|
||||||
|
#include <QMenuBar>
|
||||||
|
#include <QMenu>
|
||||||
|
|
||||||
#include <panels/places/placesitem.h>
|
#include <panels/places/placesitem.h>
|
||||||
#include <panels/places/placesitemmodel.h>
|
#include <panels/places/placesitemmodel.h>
|
||||||
|
|
||||||
#include <QApplication>
|
|
||||||
#include <QClipboard>
|
|
||||||
#include <QDir>
|
|
||||||
|
|
||||||
#include "views/dolphinview.h"
|
#include "views/dolphinview.h"
|
||||||
#include "views/viewmodecontroller.h"
|
#include "views/viewmodecontroller.h"
|
||||||
|
@ -62,8 +58,8 @@
|
||||||
DolphinContextMenu::DolphinContextMenu(DolphinMainWindow* parent,
|
DolphinContextMenu::DolphinContextMenu(DolphinMainWindow* parent,
|
||||||
const QPoint& pos,
|
const QPoint& pos,
|
||||||
const KFileItem& fileInfo,
|
const KFileItem& fileInfo,
|
||||||
const KUrl& baseUrl) :
|
const QUrl& baseUrl) :
|
||||||
KMenu(parent),
|
QMenu(parent),
|
||||||
m_pos(pos),
|
m_pos(pos),
|
||||||
m_mainWindow(parent),
|
m_mainWindow(parent),
|
||||||
m_fileInfo(fileInfo),
|
m_fileInfo(fileInfo),
|
||||||
|
@ -97,7 +93,7 @@ void DolphinContextMenu::setCustomActions(const QList<QAction*>& actions)
|
||||||
DolphinContextMenu::Command DolphinContextMenu::open()
|
DolphinContextMenu::Command DolphinContextMenu::open()
|
||||||
{
|
{
|
||||||
// get the context information
|
// get the context information
|
||||||
if (m_baseUrl.protocol() == QLatin1String("trash")) {
|
if (m_baseUrl.scheme() == QLatin1String("trash")) {
|
||||||
m_context |= TrashContext;
|
m_context |= TrashContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,7 +124,7 @@ void DolphinContextMenu::keyPressEvent(QKeyEvent *ev)
|
||||||
if (m_removeAction && ev->key() == Qt::Key_Shift) {
|
if (m_removeAction && ev->key() == Qt::Key_Shift) {
|
||||||
m_removeAction->update();
|
m_removeAction->update();
|
||||||
}
|
}
|
||||||
KMenu::keyPressEvent(ev);
|
QMenu::keyPressEvent(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinContextMenu::keyReleaseEvent(QKeyEvent *ev)
|
void DolphinContextMenu::keyReleaseEvent(QKeyEvent *ev)
|
||||||
|
@ -136,14 +132,14 @@ void DolphinContextMenu::keyReleaseEvent(QKeyEvent *ev)
|
||||||
if (m_removeAction && ev->key() == Qt::Key_Shift) {
|
if (m_removeAction && ev->key() == Qt::Key_Shift) {
|
||||||
m_removeAction->update();
|
m_removeAction->update();
|
||||||
}
|
}
|
||||||
KMenu::keyReleaseEvent(ev);
|
QMenu::keyReleaseEvent(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinContextMenu::openTrashContextMenu()
|
void DolphinContextMenu::openTrashContextMenu()
|
||||||
{
|
{
|
||||||
Q_ASSERT(m_context & TrashContext);
|
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);
|
KConfig trashConfig("trashrc", KConfig::SimpleConfig);
|
||||||
emptyTrashAction->setEnabled(!trashConfig.group("Status").readEntry("Empty", true));
|
emptyTrashAction->setEnabled(!trashConfig.group("Status").readEntry("Empty", true));
|
||||||
addAction(emptyTrashAction);
|
addAction(emptyTrashAction);
|
||||||
|
@ -156,7 +152,13 @@ void DolphinContextMenu::openTrashContextMenu()
|
||||||
addShowMenuBarAction();
|
addShowMenuBarAction();
|
||||||
|
|
||||||
if (exec(m_pos) == emptyTrashAction) {
|
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);
|
addAction(propertiesAction);
|
||||||
|
|
||||||
if (exec(m_pos) == restoreAction) {
|
if (exec(m_pos) == restoreAction) {
|
||||||
KUrl::List selectedUrls;
|
QList<QUrl> selectedUrls;
|
||||||
foreach (const KFileItem &item, m_selectedItems) {
|
foreach (const KFileItem &item, m_selectedItems) {
|
||||||
selectedUrls.append(item.url());
|
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());
|
Q_ASSERT(!m_fileInfo.isNull());
|
||||||
|
|
||||||
|
QAction* openParentAction = 0;
|
||||||
QAction* openParentInNewWindowAction = 0;
|
QAction* openParentInNewWindowAction = 0;
|
||||||
QAction* openParentInNewTabAction = 0;
|
QAction* openParentInNewTabAction = 0;
|
||||||
QAction* addToPlacesAction = 0;
|
QAction* addToPlacesAction = 0;
|
||||||
|
@ -202,12 +207,12 @@ void DolphinContextMenu::openItemContextMenu()
|
||||||
newFileMenu->checkUpToDate();
|
newFileMenu->checkUpToDate();
|
||||||
newFileMenu->setPopupFiles(m_fileInfo.url());
|
newFileMenu->setPopupFiles(m_fileInfo.url());
|
||||||
newFileMenu->setEnabled(selectedItemsProps.supportsWriting());
|
newFileMenu->setEnabled(selectedItemsProps.supportsWriting());
|
||||||
connect(newFileMenu, SIGNAL(fileCreated(KUrl)), newFileMenu, SLOT(deleteLater()));
|
connect(newFileMenu, &DolphinNewFileMenu::fileCreated, newFileMenu, &DolphinNewFileMenu::deleteLater);
|
||||||
connect(newFileMenu, SIGNAL(directoryCreated(KUrl)), newFileMenu, SLOT(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->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);
|
addMenu(menu);
|
||||||
addSeparator();
|
addSeparator();
|
||||||
|
|
||||||
|
@ -217,20 +222,26 @@ void DolphinContextMenu::openItemContextMenu()
|
||||||
|
|
||||||
// insert 'Add to Places' entry
|
// insert 'Add to Places' entry
|
||||||
if (!placeExists(m_fileInfo.url())) {
|
if (!placeExists(m_fileInfo.url())) {
|
||||||
addToPlacesAction = addAction(KIcon("bookmark-new"),
|
addToPlacesAction = addAction(QIcon::fromTheme("bookmark-new"),
|
||||||
i18nc("@action:inmenu Add selected folder to places",
|
i18nc("@action:inmenu Add selected folder to places",
|
||||||
"Add to Places"));
|
"Add to Places"));
|
||||||
}
|
}
|
||||||
|
|
||||||
addSeparator();
|
addSeparator();
|
||||||
} else if (m_baseUrl.protocol().contains("search")) {
|
} else if (m_baseUrl.scheme().contains("search") || m_baseUrl.scheme().contains("timeline")) {
|
||||||
openParentInNewWindowAction = new QAction(KIcon("window-new"),
|
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",
|
i18nc("@action:inmenu",
|
||||||
"Open Path in New Window"),
|
"Open Path in New Window"),
|
||||||
this);
|
this);
|
||||||
addAction(openParentInNewWindowAction);
|
addAction(openParentInNewWindowAction);
|
||||||
|
|
||||||
openParentInNewTabAction = new QAction(KIcon("tab-new"),
|
openParentInNewTabAction = new QAction(QIcon::fromTheme("tab-new"),
|
||||||
i18nc("@action:inmenu",
|
i18nc("@action:inmenu",
|
||||||
"Open Path in New Tab"),
|
"Open Path in New Tab"),
|
||||||
this);
|
this);
|
||||||
|
@ -247,7 +258,7 @@ void DolphinContextMenu::openItemContextMenu()
|
||||||
} else {
|
} else {
|
||||||
bool selectionHasOnlyDirs = true;
|
bool selectionHasOnlyDirs = true;
|
||||||
foreach (const KFileItem& item, m_selectedItems) {
|
foreach (const KFileItem& item, m_selectedItems) {
|
||||||
const KUrl& url = DolphinView::openItemAsFolderUrl(item);
|
const QUrl& url = DolphinView::openItemAsFolderUrl(item);
|
||||||
if (url.isEmpty()) {
|
if (url.isEmpty()) {
|
||||||
selectionHasOnlyDirs = false;
|
selectionHasOnlyDirs = false;
|
||||||
break;
|
break;
|
||||||
|
@ -275,8 +286,9 @@ void DolphinContextMenu::openItemContextMenu()
|
||||||
|
|
||||||
// insert 'Copy To' and 'Move To' sub menus
|
// insert 'Copy To' and 'Move To' sub menus
|
||||||
if (GeneralSettings::showCopyMoveMenu()) {
|
if (GeneralSettings::showCopyMoveMenu()) {
|
||||||
m_copyToMenu.setItems(m_selectedItems);
|
m_copyToMenu.setUrls(m_selectedItems.urlList());
|
||||||
m_copyToMenu.setReadOnly(!selectedItemsProps.supportsWriting());
|
m_copyToMenu.setReadOnly(!selectedItemsProps.supportsWriting());
|
||||||
|
m_copyToMenu.setAutoErrorHandlingEnabled(true);
|
||||||
m_copyToMenu.addActionsTo(this);
|
m_copyToMenu.addActionsTo(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,13 +299,15 @@ void DolphinContextMenu::openItemContextMenu()
|
||||||
QAction* activatedAction = exec(m_pos);
|
QAction* activatedAction = exec(m_pos);
|
||||||
if (activatedAction) {
|
if (activatedAction) {
|
||||||
if (activatedAction == addToPlacesAction) {
|
if (activatedAction == addToPlacesAction) {
|
||||||
const KUrl selectedUrl(m_fileInfo.url());
|
const QUrl selectedUrl(m_fileInfo.url());
|
||||||
if (selectedUrl.isValid()) {
|
if (selectedUrl.isValid()) {
|
||||||
PlacesItemModel model;
|
PlacesItemModel model;
|
||||||
const QString text = selectedUrl.fileName();
|
const QString text = selectedUrl.fileName();
|
||||||
PlacesItem* item = model.createPlacesItem(text, selectedUrl);
|
PlacesItem* item = model.createPlacesItem(text, selectedUrl);
|
||||||
model.appendItemToGroup(item);
|
model.appendItemToGroup(item);
|
||||||
}
|
}
|
||||||
|
} else if (activatedAction == openParentAction) {
|
||||||
|
m_command = OpenParentFolder;
|
||||||
} else if (activatedAction == openParentInNewWindowAction) {
|
} else if (activatedAction == openParentInNewWindowAction) {
|
||||||
m_command = OpenParentFolderInNewWindow;
|
m_command = OpenParentFolderInNewWindow;
|
||||||
} else if (activatedAction == openParentInNewTabAction) {
|
} else if (activatedAction == openParentInNewTabAction) {
|
||||||
|
@ -321,7 +335,7 @@ void DolphinContextMenu::openViewportContextMenu()
|
||||||
// Insert 'Add to Places' entry if exactly one item is selected
|
// Insert 'Add to Places' entry if exactly one item is selected
|
||||||
QAction* addToPlacesAction = 0;
|
QAction* addToPlacesAction = 0;
|
||||||
if (!placeExists(m_mainWindow->activeViewContainer()->url())) {
|
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"));
|
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'
|
// Insert 'Move to Trash' and/or 'Delete'
|
||||||
if (properties.supportsDeleting()) {
|
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());
|
!properties.isLocal());
|
||||||
const bool showMoveToTrashAction = (properties.isLocal() &&
|
const bool showMoveToTrashAction = (properties.isLocal() &&
|
||||||
properties.supportsMoving());
|
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;
|
PlacesItemModel model;
|
||||||
|
|
||||||
const int count = model.count();
|
const int count = model.count();
|
||||||
for (int i = 0; i < count; ++i) {
|
for (int i = 0; i < count; ++i) {
|
||||||
const KUrl placeUrl = model.placesItem(i)->url();
|
const QUrl placeUrl = model.placesItem(i)->url();
|
||||||
if (placeUrl.equals(url, KUrl::CompareWithoutTrailingSlash)) {
|
if (placeUrl.matches(url, QUrl::StripTrailingSlash)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -429,10 +443,12 @@ QAction* DolphinContextMenu::createPasteAction()
|
||||||
QAction* action = 0;
|
QAction* action = 0;
|
||||||
const bool isDir = !m_fileInfo.isNull() && m_fileInfo.isDir();
|
const bool isDir = !m_fileInfo.isNull() && m_fileInfo.isDir();
|
||||||
if (isDir && (m_selectedItems.count() == 1)) {
|
if (isDir && (m_selectedItems.count() == 1)) {
|
||||||
const QPair<bool, QString> pasteInfo = KonqOperations::pasteInfo(m_fileInfo.url());
|
const QMimeData *mimeData = QApplication::clipboard()->mimeData();
|
||||||
action = new QAction(KIcon("edit-paste"), i18nc("@action:inmenu", "Paste Into Folder"), this);
|
bool canPaste;
|
||||||
action->setEnabled(pasteInfo.first);
|
const QString text = KIO::pasteActionText(mimeData, &canPaste, m_fileInfo);
|
||||||
connect(action, SIGNAL(triggered()), m_mainWindow, SLOT(pasteIntoFolder()));
|
action = new QAction(QIcon::fromTheme("edit-paste"), text, this);
|
||||||
|
action->setEnabled(canPaste);
|
||||||
|
connect(action, &QAction::triggered, m_mainWindow, &DolphinMainWindow::pasteIntoFolder);
|
||||||
} else {
|
} else {
|
||||||
action = m_mainWindow->actionCollection()->action(KStandardAction::name(KStandardAction::Paste));
|
action = m_mainWindow->actionCollection()->action(KStandardAction::name(KStandardAction::Paste));
|
||||||
}
|
}
|
||||||
|
@ -451,7 +467,7 @@ KFileItemListProperties& DolphinContextMenu::selectedItemsProperties() const
|
||||||
KFileItem DolphinContextMenu::baseFileItem()
|
KFileItem DolphinContextMenu::baseFileItem()
|
||||||
{
|
{
|
||||||
if (!m_baseFileItem) {
|
if (!m_baseFileItem) {
|
||||||
m_baseFileItem = new KFileItem(KFileItem::Unknown, KFileItem::Unknown, m_baseUrl);
|
m_baseFileItem = new KFileItem(m_baseUrl);
|
||||||
}
|
}
|
||||||
return *m_baseFileItem;
|
return *m_baseFileItem;
|
||||||
}
|
}
|
||||||
|
@ -489,19 +505,12 @@ void DolphinContextMenu::addFileItemPluginActions()
|
||||||
const KConfig config("kservicemenurc", KConfig::NoGlobals);
|
const KConfig config("kservicemenurc", KConfig::NoGlobals);
|
||||||
const KConfigGroup showGroup = config.group("Show");
|
const KConfigGroup showGroup = config.group("Show");
|
||||||
|
|
||||||
foreach (const KSharedPtr<KService>& service, pluginServices) {
|
foreach (const KService::Ptr& service, pluginServices) {
|
||||||
if (!showGroup.readEntry(service->desktopEntryName(), true)) {
|
if (!showGroup.readEntry(service->desktopEntryName(), true)) {
|
||||||
// The plugin has been disabled
|
// The plugin has been disabled
|
||||||
continue;
|
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>();
|
KAbstractFileItemActionPlugin* abstractPlugin = service->createInstance<KAbstractFileItemActionPlugin>();
|
||||||
if (abstractPlugin) {
|
if (abstractPlugin) {
|
||||||
abstractPlugin->setParent(this);
|
abstractPlugin->setParent(this);
|
||||||
|
@ -515,18 +524,13 @@ void DolphinContextMenu::addVersionControlPluginActions()
|
||||||
const DolphinView* view = m_mainWindow->activeViewContainer()->view();
|
const DolphinView* view = m_mainWindow->activeViewContainer()->view();
|
||||||
const QList<QAction*> versionControlActions = view->versionControlActions(m_selectedItems);
|
const QList<QAction*> versionControlActions = view->versionControlActions(m_selectedItems);
|
||||||
if (!versionControlActions.isEmpty()) {
|
if (!versionControlActions.isEmpty()) {
|
||||||
foreach (QAction* action, versionControlActions) {
|
addActions(versionControlActions);
|
||||||
addAction(action);
|
|
||||||
}
|
|
||||||
addSeparator();
|
addSeparator();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinContextMenu::addCustomActions()
|
void DolphinContextMenu::addCustomActions()
|
||||||
{
|
{
|
||||||
foreach (QAction* action, m_customActions) {
|
addActions(m_customActions);
|
||||||
addAction(action);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "dolphincontextmenu.moc"
|
|
||||||
|
|
|
@ -21,16 +21,12 @@
|
||||||
#define DOLPHINCONTEXTMENU_H
|
#define DOLPHINCONTEXTMENU_H
|
||||||
|
|
||||||
#include <KFileItem>
|
#include <KFileItem>
|
||||||
#include <KService>
|
#include <QUrl>
|
||||||
#include <KUrl>
|
#include <KFileCopyToMenu>
|
||||||
#include <konq_copytomenu.h>
|
#include <QMenu>
|
||||||
#include <KMenu>
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
#include <QVector>
|
|
||||||
|
|
||||||
#include <QScopedPointer>
|
|
||||||
|
|
||||||
class QAction;
|
class QAction;
|
||||||
class DolphinMainWindow;
|
class DolphinMainWindow;
|
||||||
|
@ -50,7 +46,7 @@ class DolphinRemoveAction;
|
||||||
* - 'Actions': Contains all actions which can be applied to the
|
* - 'Actions': Contains all actions which can be applied to the
|
||||||
* given item.
|
* given item.
|
||||||
*/
|
*/
|
||||||
class DolphinContextMenu : public KMenu
|
class DolphinContextMenu : public QMenu
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -58,6 +54,7 @@ public:
|
||||||
enum Command
|
enum Command
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
|
OpenParentFolder,
|
||||||
OpenParentFolderInNewWindow,
|
OpenParentFolderInNewWindow,
|
||||||
OpenParentFolderInNewTab
|
OpenParentFolderInNewTab
|
||||||
};
|
};
|
||||||
|
@ -75,7 +72,7 @@ public:
|
||||||
DolphinContextMenu(DolphinMainWindow* parent,
|
DolphinContextMenu(DolphinMainWindow* parent,
|
||||||
const QPoint& pos,
|
const QPoint& pos,
|
||||||
const KFileItem& fileInfo,
|
const KFileItem& fileInfo,
|
||||||
const KUrl& baseUrl);
|
const QUrl& baseUrl);
|
||||||
|
|
||||||
virtual ~DolphinContextMenu();
|
virtual ~DolphinContextMenu();
|
||||||
|
|
||||||
|
@ -92,8 +89,8 @@ public:
|
||||||
Command open();
|
Command open();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void keyPressEvent(QKeyEvent *ev);
|
virtual void keyPressEvent(QKeyEvent *ev) Q_DECL_OVERRIDE;
|
||||||
virtual void keyReleaseEvent(QKeyEvent *ev);
|
virtual void keyReleaseEvent(QKeyEvent *ev) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void openTrashContextMenu();
|
void openTrashContextMenu();
|
||||||
|
@ -109,7 +106,7 @@ private:
|
||||||
*/
|
*/
|
||||||
void addShowMenuBarAction();
|
void addShowMenuBarAction();
|
||||||
|
|
||||||
bool placeExists(const KUrl& url) const;
|
bool placeExists(const QUrl& url) const;
|
||||||
|
|
||||||
QAction* createPasteAction();
|
QAction* createPasteAction();
|
||||||
|
|
||||||
|
@ -165,14 +162,14 @@ private:
|
||||||
|
|
||||||
KFileItem m_fileInfo;
|
KFileItem m_fileInfo;
|
||||||
|
|
||||||
KUrl m_baseUrl;
|
QUrl m_baseUrl;
|
||||||
KFileItem* m_baseFileItem; /// File item for m_baseUrl
|
KFileItem* m_baseFileItem; /// File item for m_baseUrl
|
||||||
|
|
||||||
KFileItemList m_selectedItems;
|
KFileItemList m_selectedItems;
|
||||||
mutable KFileItemListProperties* m_selectedItemsProperties;
|
mutable KFileItemListProperties* m_selectedItemsProperties;
|
||||||
|
|
||||||
int m_context;
|
int m_context;
|
||||||
KonqCopyToMenu m_copyToMenu;
|
KFileCopyToMenu m_copyToMenu;
|
||||||
QList<QAction*> m_customActions;
|
QList<QAction*> m_customActions;
|
||||||
|
|
||||||
Command m_command;
|
Command m_command;
|
||||||
|
|
|
@ -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 *
|
* 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 *
|
* 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 *
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#ifndef FILENAMESEARCHPROTOCOL_H
|
#include "dolphindebug.h"
|
||||||
#define FILENAMESEARCHPROTOCOL_H
|
|
||||||
|
|
||||||
#include <kio/slavebase.h>
|
Q_LOGGING_CATEGORY(DolphinDebug, "org.kde.dolphin")
|
||||||
|
|
||||||
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
|
|
|
@ -1,6 +1,5 @@
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* Copyright (C) 2006-2011 by Peter Penz <peter.penz19@gmail.com> *
|
* Copyright (C) 2015 by Emmanuel Pescosta <emmanuelpescosta099@gmail.com> *
|
||||||
* Copyright (C) 2006 by Holger 'zecke' Freyther <freyther@kde.org> *
|
|
||||||
* *
|
* *
|
||||||
* This program is free software; you can redistribute it and/or modify *
|
* 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 *
|
* 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 *
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#ifndef DOLPHIN_APPLICATION_H
|
#ifndef DOLPHIN_DEBUG_H
|
||||||
#define DOLPHIN_APPLICATION_H
|
#define DOLPHIN_DEBUG_H
|
||||||
|
|
||||||
#include <KApplication>
|
#include <QLoggingCategory>
|
||||||
|
|
||||||
class DolphinMainWindow;
|
Q_DECLARE_LOGGING_CATEGORY(DolphinDebug)
|
||||||
|
|
||||||
class DolphinApplication : public KApplication
|
#endif // DOLPHIN_DEBUG_H
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
DolphinApplication();
|
|
||||||
virtual ~DolphinApplication();
|
|
||||||
|
|
||||||
static DolphinApplication* app();
|
|
||||||
|
|
||||||
void restoreSession();
|
|
||||||
|
|
||||||
private:
|
|
||||||
DolphinMainWindow* m_mainWindow;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -91,4 +91,3 @@ bool DolphinDockWidget::isLocked() const
|
||||||
return m_locked;
|
return m_locked;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "dolphindockwidget.moc"
|
|
||||||
|
|
|
@ -24,30 +24,28 @@
|
||||||
|
|
||||||
#include <config-baloo.h>
|
#include <config-baloo.h>
|
||||||
|
|
||||||
#include <KFileItemDelegate>
|
|
||||||
#include <kio/fileundomanager.h>
|
#include <kio/fileundomanager.h>
|
||||||
#include <ksortablelist.h>
|
#include <ksortablelist.h>
|
||||||
#include <kxmlguiwindow.h>
|
#include <kxmlguiwindow.h>
|
||||||
#include <KIcon>
|
#include <QIcon>
|
||||||
|
#include <QUrl>
|
||||||
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QWeakPointer>
|
#include <QPointer>
|
||||||
|
|
||||||
typedef KIO::FileUndoManager::CommandType CommandType;
|
typedef KIO::FileUndoManager::CommandType CommandType;
|
||||||
|
|
||||||
class DolphinViewActionHandler;
|
class DolphinViewActionHandler;
|
||||||
class DolphinApplication;
|
|
||||||
class DolphinSettingsDialog;
|
class DolphinSettingsDialog;
|
||||||
class DolphinViewContainer;
|
class DolphinViewContainer;
|
||||||
class DolphinRemoteEncoding;
|
class DolphinRemoteEncoding;
|
||||||
class DolphinTabWidget;
|
class DolphinTabWidget;
|
||||||
class KAction;
|
|
||||||
class KFileItem;
|
class KFileItem;
|
||||||
class KFileItemList;
|
class KFileItemList;
|
||||||
class KJob;
|
class KJob;
|
||||||
class KNewFileMenu;
|
class KNewFileMenu;
|
||||||
class KUrl;
|
|
||||||
class QToolButton;
|
class QToolButton;
|
||||||
|
class QIcon;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @short Main window for Dolphin.
|
* @short Main window for Dolphin.
|
||||||
|
@ -59,7 +57,6 @@ class DolphinMainWindow: public KXmlGuiWindow
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_CLASSINFO("D-Bus Interface", "org.kde.dolphin.MainWindow")
|
Q_CLASSINFO("D-Bus Interface", "org.kde.dolphin.MainWindow")
|
||||||
Q_PROPERTY(int id READ getId SCRIPTABLE true)
|
Q_PROPERTY(int id READ getId SCRIPTABLE true)
|
||||||
friend class DolphinApplication;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DolphinMainWindow();
|
DolphinMainWindow();
|
||||||
|
@ -77,14 +74,14 @@ public:
|
||||||
* Opens each directory in \p dirs in a separate tab. If the "split view"
|
* Opens each directory in \p dirs in a separate tab. If the "split view"
|
||||||
* option is enabled, 2 directories are collected within one tab.
|
* 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
|
* Opens the directory which contains the files \p files
|
||||||
* and selects all files (implements the --select option
|
* and selects all files (implements the --select option
|
||||||
* of Dolphin).
|
* 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
|
* 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
|
* Inform all affected dolphin components (panels, views) of an URL
|
||||||
* change.
|
* change.
|
||||||
*/
|
*/
|
||||||
void changeUrl(const KUrl& url);
|
void changeUrl(const QUrl& url);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current directory of the Terminal Panel has changed, probably because
|
* The current directory of the Terminal Panel has changed, probably because
|
||||||
* the user entered a 'cd' command. This slot calls changeUrl(url) and makes
|
* the user entered a 'cd' command. This slot calls changeUrl(url) and makes
|
||||||
* sure that the panel keeps the keyboard focus.
|
* sure that the panel keeps the keyboard focus.
|
||||||
*/
|
*/
|
||||||
void slotTerminalDirectoryChanged(const KUrl& url);
|
void slotTerminalDirectoryChanged(const QUrl& url);
|
||||||
|
|
||||||
/** Stores all settings and quits Dolphin. */
|
/** Stores all settings and quits Dolphin. */
|
||||||
void quit();
|
void quit();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens a new tab showing the URL \a url and activates the tab.
|
||||||
|
*/
|
||||||
|
void openNewActivatedTab(const QUrl& url);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/**
|
/**
|
||||||
* Is sent if the selection of the currently active view has
|
* 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
|
* Is sent if the url of the currently active view has
|
||||||
* been changed.
|
* 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.
|
* Is emitted if information of an item is requested to be shown e. g. in the panel.
|
||||||
|
@ -148,16 +150,16 @@ signals:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** @see QWidget::showEvent() */
|
/** @see QWidget::showEvent() */
|
||||||
virtual void showEvent(QShowEvent* event);
|
virtual void showEvent(QShowEvent* event) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
/** @see QMainWindow::closeEvent() */
|
/** @see QMainWindow::closeEvent() */
|
||||||
virtual void closeEvent(QCloseEvent* event);
|
virtual void closeEvent(QCloseEvent* event) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
/** @see KMainWindow::saveProperties() */
|
/** @see KMainWindow::saveProperties() */
|
||||||
virtual void saveProperties(KConfigGroup& group);
|
virtual void saveProperties(KConfigGroup& group) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
/** @see KMainWindow::readProperties() */
|
/** @see KMainWindow::readProperties() */
|
||||||
virtual void readProperties(const KConfigGroup& group);
|
virtual void readProperties(const KConfigGroup& group) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
/**
|
/**
|
||||||
|
@ -313,9 +315,6 @@ private slots:
|
||||||
*/
|
*/
|
||||||
void slotSelectionChanged(const KFileItemList& selection);
|
void slotSelectionChanged(const KFileItemList& selection);
|
||||||
|
|
||||||
/** Emits the signal requestItemInfo(). */
|
|
||||||
void slotRequestItemInfo(const KFileItem&);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the state of the 'Back' and 'Forward' menu
|
* Updates the state of the 'Back' and 'Forward' menu
|
||||||
* actions corresponding to the current history.
|
* actions corresponding to the current history.
|
||||||
|
@ -335,16 +334,9 @@ private slots:
|
||||||
void openNewActivatedTab();
|
void openNewActivatedTab();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens a new tab in the background showing the URL \a primaryUrl and the
|
* Opens a new tab in the background showing the URL \a url.
|
||||||
* optional URL \a secondaryUrl.
|
|
||||||
*/
|
*/
|
||||||
void openNewTab(const KUrl& primaryUrl, const KUrl& secondaryUrl = KUrl());
|
void openNewTab(const QUrl& url);
|
||||||
|
|
||||||
/**
|
|
||||||
* 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());
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens the selected folder in a new tab.
|
* 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
|
* If the URL can be listed, open it in the current view, otherwise
|
||||||
* run it through KRun.
|
* 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
|
* handleUrl() can trigger a stat job to see if the url can actually
|
||||||
|
@ -391,25 +383,19 @@ private slots:
|
||||||
*/
|
*/
|
||||||
void openContextMenu(const QPoint& pos,
|
void openContextMenu(const QPoint& pos,
|
||||||
const KFileItem& item,
|
const KFileItem& item,
|
||||||
const KUrl& url,
|
const QUrl& url,
|
||||||
const QList<QAction*>& customActions);
|
const QList<QAction*>& customActions);
|
||||||
|
|
||||||
void updateControlMenu();
|
void updateControlMenu();
|
||||||
void updateToolBar();
|
void updateToolBar();
|
||||||
void slotControlButtonDeleted();
|
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.
|
* 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
|
* Reloads the view if \a url is the current URL already, and changes the
|
||||||
* current URL otherwise.
|
* 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
|
* 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,
|
* Sets the window caption to url.fileName() if this is non-empty,
|
||||||
* "/" if the URL is "file:///", and url.protocol() otherwise.
|
* "/" 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:
|
private:
|
||||||
void setupActions();
|
void setupActions();
|
||||||
|
@ -450,7 +441,7 @@ private:
|
||||||
* case if it has not added already to the toolbar.
|
* case if it has not added already to the toolbar.
|
||||||
* @return True if the action has been added to the menu.
|
* @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
|
* 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
|
* as the action for toggling the dock visibility is done by Qt which
|
||||||
* is no KAction instance.
|
* is no KAction instance.
|
||||||
*/
|
*/
|
||||||
void createPanelAction(const KIcon& icon,
|
void createPanelAction(const QIcon &icon,
|
||||||
const QKeySequence& shortcut,
|
const QKeySequence& shortcut,
|
||||||
QAction* dockAction,
|
QAction* dockAction,
|
||||||
const QString& actionName);
|
const QString& actionName);
|
||||||
|
@ -492,7 +483,7 @@ private:
|
||||||
public:
|
public:
|
||||||
UndoUiInterface();
|
UndoUiInterface();
|
||||||
virtual ~UndoUiInterface();
|
virtual ~UndoUiInterface();
|
||||||
virtual void jobError(KIO::Job* job);
|
virtual void jobError(KIO::Job* job) Q_DECL_OVERRIDE;
|
||||||
};
|
};
|
||||||
|
|
||||||
KNewFileMenu* m_newFileMenu;
|
KNewFileMenu* m_newFileMenu;
|
||||||
|
@ -502,7 +493,7 @@ private:
|
||||||
|
|
||||||
DolphinViewActionHandler* m_actionHandler;
|
DolphinViewActionHandler* m_actionHandler;
|
||||||
DolphinRemoteEncoding* m_remoteEncoding;
|
DolphinRemoteEncoding* m_remoteEncoding;
|
||||||
QWeakPointer<DolphinSettingsDialog> m_settingsDialog;
|
QPointer<DolphinSettingsDialog> m_settingsDialog;
|
||||||
|
|
||||||
// Members for the toolbar menu that is shown when the menubar is hidden:
|
// Members for the toolbar menu that is shown when the menubar is hidden:
|
||||||
QToolButton* m_controlButton;
|
QToolButton* m_controlButton;
|
||||||
|
|
|
@ -45,4 +45,3 @@ void DolphinNewFileMenu::slotResult(KJob* job)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "dolphinnewfilemenu.moc"
|
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
#include <KNewFileMenu>
|
#include <KNewFileMenu>
|
||||||
|
|
||||||
#include "libdolphin_export.h"
|
#include "dolphin_export.h"
|
||||||
|
|
||||||
class KJob;
|
class KJob;
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ class KJob;
|
||||||
* All errors are shown in the status bar of Dolphin
|
* All errors are shown in the status bar of Dolphin
|
||||||
* instead as modal error dialog with an OK button.
|
* instead as modal error dialog with an OK button.
|
||||||
*/
|
*/
|
||||||
class LIBDOLPHINPRIVATE_EXPORT DolphinNewFileMenu : public KNewFileMenu
|
class DOLPHIN_EXPORT DolphinNewFileMenu : public KNewFileMenu
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ signals:
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
/** @see KNewFileMenu::slotResult() */
|
/** @see KNewFileMenu::slotResult() */
|
||||||
virtual void slotResult(KJob* job);
|
virtual void slotResult(KJob* job) Q_DECL_OVERRIDE;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -21,31 +21,25 @@
|
||||||
#include "dolphinremoveaction.h"
|
#include "dolphinremoveaction.h"
|
||||||
|
|
||||||
#include <KFileItemListProperties>
|
#include <KFileItemListProperties>
|
||||||
#include <konq_operations.h>
|
|
||||||
|
|
||||||
#include <KAboutData>
|
#include <KAboutData>
|
||||||
#include <KActionCollection>
|
#include <KActionCollection>
|
||||||
#include <KConfigGroup>
|
#include "dolphindebug.h"
|
||||||
#include <KDebug>
|
|
||||||
#include <KGlobalSettings>
|
|
||||||
#include <KIconLoader>
|
#include <KIconLoader>
|
||||||
#include <KLocale>
|
#include <KLocalizedString>
|
||||||
#include <KMessageBox>
|
#include <KMessageBox>
|
||||||
#include <KPluginFactory>
|
#include <KPluginFactory>
|
||||||
#include <KRun>
|
#include <KRun>
|
||||||
#include <KToggleAction>
|
|
||||||
#include <KIO/NetAccess>
|
|
||||||
#include <KToolInvocation>
|
#include <KToolInvocation>
|
||||||
#include <kauthorized.h>
|
#include <kauthorized.h>
|
||||||
#include <KMenu>
|
#include <QMenu>
|
||||||
#include <KInputDialog>
|
|
||||||
#include <KProtocolInfo>
|
|
||||||
#include <kdeversion.h>
|
#include <kdeversion.h>
|
||||||
|
#include <KSharedConfig>
|
||||||
|
#include <KConfigGroup>
|
||||||
|
#include <KMimeTypeEditor>
|
||||||
|
#include <KJobWidgets>
|
||||||
|
|
||||||
#if KDE_IS_VERSION(4, 9, 2)
|
|
||||||
#include "dolphinpart_ext.h"
|
#include "dolphinpart_ext.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "dolphinnewfilemenu.h"
|
#include "dolphinnewfilemenu.h"
|
||||||
#include "views/dolphinview.h"
|
#include "views/dolphinview.h"
|
||||||
#include "views/dolphinviewactionhandler.h"
|
#include "views/dolphinviewactionhandler.h"
|
||||||
|
@ -54,14 +48,16 @@
|
||||||
#include "kitemviews/kfileitemmodel.h"
|
#include "kitemviews/kfileitemmodel.h"
|
||||||
#include "kitemviews/private/kfileitemmodeldirlister.h"
|
#include "kitemviews/private/kfileitemmodeldirlister.h"
|
||||||
|
|
||||||
|
#include <QStandardPaths>
|
||||||
#include <QActionGroup>
|
#include <QActionGroup>
|
||||||
|
#include <QTextDocument>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QTextDocument>
|
#include <QKeyEvent>
|
||||||
|
#include <QInputDialog>
|
||||||
|
|
||||||
K_PLUGIN_FACTORY(DolphinPartFactory, registerPlugin<DolphinPart>();)
|
K_PLUGIN_FACTORY(DolphinPartFactory, registerPlugin<DolphinPart>();)
|
||||||
K_EXPORT_PLUGIN(DolphinPartFactory("dolphinpart", "dolphin"))
|
|
||||||
|
|
||||||
DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantList& args)
|
DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantList& args)
|
||||||
: KParts::ReadOnlyPart(parent)
|
: KParts::ReadOnlyPart(parent)
|
||||||
|
@ -69,83 +65,81 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantL
|
||||||
,m_removeAction(0)
|
,m_removeAction(0)
|
||||||
{
|
{
|
||||||
Q_UNUSED(args)
|
Q_UNUSED(args)
|
||||||
setComponentData(DolphinPartFactory::componentData(), false);
|
setComponentData(*createAboutData(), false);
|
||||||
m_extension = new DolphinPartBrowserExtension(this);
|
m_extension = new DolphinPartBrowserExtension(this);
|
||||||
|
|
||||||
// make sure that other apps using this part find Dolphin's view-file-columns icons
|
// make sure that other apps using this part find Dolphin's view-file-columns icons
|
||||||
KIconLoader::global()->addAppDir("dolphin");
|
KIconLoader::global()->addAppDir("dolphin");
|
||||||
|
|
||||||
m_view = new DolphinView(KUrl(), parentWidget);
|
m_view = new DolphinView(QUrl(), parentWidget);
|
||||||
m_view->setTabsForFilesEnabled(true);
|
m_view->setTabsForFilesEnabled(true);
|
||||||
setWidget(m_view);
|
setWidget(m_view);
|
||||||
|
|
||||||
connect(&DolphinNewFileMenuObserver::instance(), SIGNAL(errorMessage(QString)),
|
connect(&DolphinNewFileMenuObserver::instance(), &DolphinNewFileMenuObserver::errorMessage,
|
||||||
this, SLOT(slotErrorMessage(QString)));
|
this, &DolphinPart::slotErrorMessage);
|
||||||
|
|
||||||
connect(m_view, SIGNAL(directoryLoadingCompleted()), this, SIGNAL(completed()));
|
connect(m_view, &DolphinView::directoryLoadingCompleted, this, static_cast<void(DolphinPart::*)()>(&DolphinPart::completed));
|
||||||
connect(m_view, SIGNAL(directoryLoadingProgress(int)), this, SLOT(updateProgress(int)));
|
connect(m_view, &DolphinView::directoryLoadingProgress, this, &DolphinPart::updateProgress);
|
||||||
connect(m_view, SIGNAL(errorMessage(QString)), this, SLOT(slotErrorMessage(QString)));
|
connect(m_view, &DolphinView::errorMessage, this, &DolphinPart::slotErrorMessage);
|
||||||
|
|
||||||
setXMLFile("dolphinpart.rc");
|
setXMLFile("dolphinpart.rc");
|
||||||
|
|
||||||
connect(m_view, SIGNAL(infoMessage(QString)),
|
connect(m_view, &DolphinView::infoMessage,
|
||||||
this, SLOT(slotMessage(QString)));
|
this, &DolphinPart::slotMessage);
|
||||||
connect(m_view, SIGNAL(operationCompletedMessage(QString)),
|
connect(m_view, &DolphinView::operationCompletedMessage,
|
||||||
this, SLOT(slotMessage(QString)));
|
this, &DolphinPart::slotMessage);
|
||||||
connect(m_view, SIGNAL(errorMessage(QString)),
|
connect(m_view, &DolphinView::errorMessage,
|
||||||
this, SLOT(slotErrorMessage(QString)));
|
this, &DolphinPart::slotErrorMessage);
|
||||||
connect(m_view, SIGNAL(itemActivated(KFileItem)),
|
connect(m_view, &DolphinView::itemActivated,
|
||||||
this, SLOT(slotItemActivated(KFileItem)));
|
this, &DolphinPart::slotItemActivated);
|
||||||
connect(m_view, SIGNAL(itemsActivated(KFileItemList)),
|
connect(m_view, &DolphinView::itemsActivated,
|
||||||
this, SLOT(slotItemsActivated(KFileItemList)));
|
this, &DolphinPart::slotItemsActivated);
|
||||||
connect(m_view, SIGNAL(tabRequested(KUrl)),
|
connect(m_view, &DolphinView::tabRequested,
|
||||||
this, SLOT(createNewWindow(KUrl)));
|
this, &DolphinPart::createNewWindow);
|
||||||
connect(m_view, SIGNAL(requestContextMenu(QPoint,KFileItem,KUrl,QList<QAction*>)),
|
connect(m_view, &DolphinView::requestContextMenu,
|
||||||
this, SLOT(slotOpenContextMenu(QPoint,KFileItem,KUrl,QList<QAction*>)));
|
this, &DolphinPart::slotOpenContextMenu);
|
||||||
connect(m_view, SIGNAL(selectionChanged(KFileItemList)),
|
connect(m_view, &DolphinView::selectionChanged,
|
||||||
m_extension, SIGNAL(selectionInfo(KFileItemList)));
|
m_extension, static_cast<void(DolphinPartBrowserExtension::*)(const KFileItemList&)>(&DolphinPartBrowserExtension::selectionInfo));
|
||||||
connect(m_view, SIGNAL(selectionChanged(KFileItemList)),
|
connect(m_view, &DolphinView::selectionChanged,
|
||||||
this, SLOT(slotSelectionChanged(KFileItemList)));
|
this, &DolphinPart::slotSelectionChanged);
|
||||||
connect(m_view, SIGNAL(requestItemInfo(KFileItem)),
|
connect(m_view, &DolphinView::requestItemInfo,
|
||||||
this, SLOT(slotRequestItemInfo(KFileItem)));
|
this, &DolphinPart::slotRequestItemInfo);
|
||||||
connect(m_view, SIGNAL(modeChanged(DolphinView::Mode,DolphinView::Mode)),
|
connect(m_view, &DolphinView::modeChanged,
|
||||||
this, SIGNAL(viewModeChanged())); // relay signal
|
this, &DolphinPart::viewModeChanged); // relay signal
|
||||||
connect(m_view, SIGNAL(redirection(KUrl,KUrl)),
|
connect(m_view, &DolphinView::redirection,
|
||||||
this, SLOT(slotDirectoryRedirection(KUrl,KUrl)));
|
this, &DolphinPart::slotDirectoryRedirection);
|
||||||
|
|
||||||
// Watch for changes that should result in updates to the
|
// Watch for changes that should result in updates to the
|
||||||
// status bar text.
|
// status bar text.
|
||||||
connect(m_view, SIGNAL(itemCountChanged()), this, SLOT(updateStatusBar()));
|
connect(m_view, &DolphinView::itemCountChanged, this, &DolphinPart::updateStatusBar);
|
||||||
connect(m_view, SIGNAL(selectionChanged(KFileItemList)), this, SLOT(updateStatusBar()));
|
connect(m_view, &DolphinView::selectionChanged, this, &DolphinPart::updateStatusBar);
|
||||||
|
|
||||||
m_actionHandler = new DolphinViewActionHandler(actionCollection(), this);
|
m_actionHandler = new DolphinViewActionHandler(actionCollection(), this);
|
||||||
m_actionHandler->setCurrentView(m_view);
|
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);
|
m_remoteEncoding = new DolphinRemoteEncoding(this, m_actionHandler);
|
||||||
connect(this, SIGNAL(aboutToOpenURL()),
|
connect(this, &DolphinPart::aboutToOpenURL,
|
||||||
m_remoteEncoding, SLOT(slotAboutToOpenUrl()));
|
m_remoteEncoding, &DolphinRemoteEncoding::slotAboutToOpenUrl);
|
||||||
|
|
||||||
QClipboard* clipboard = QApplication::clipboard();
|
QClipboard* clipboard = QApplication::clipboard();
|
||||||
connect(clipboard, SIGNAL(dataChanged()),
|
connect(clipboard, &QClipboard::dataChanged,
|
||||||
this, SLOT(updatePasteAction()));
|
this, &DolphinPart::updatePasteAction);
|
||||||
|
|
||||||
// Create file info and listing filter extensions.
|
// Create file info and listing filter extensions.
|
||||||
// NOTE: Listing filter needs to be instantiated after the creation of the view.
|
// NOTE: Listing filter needs to be instantiated after the creation of the view.
|
||||||
new DolphinPartFileInfoExtension(this);
|
new DolphinPartFileInfoExtension(this);
|
||||||
|
|
||||||
#if KDE_IS_VERSION(4, 9, 2)
|
|
||||||
new DolphinPartListingFilterExtension(this);
|
new DolphinPartListingFilterExtension(this);
|
||||||
|
|
||||||
KDirLister* lister = m_view->m_model->m_dirLister;
|
KDirLister* lister = m_view->m_model->m_dirLister;
|
||||||
if (lister) {
|
if (lister) {
|
||||||
DolphinPartListingNotificationExtension* notifyExt = new DolphinPartListingNotificationExtension(this);
|
DolphinPartListingNotificationExtension* notifyExt = new DolphinPartListingNotificationExtension(this);
|
||||||
connect(lister, SIGNAL(newItems(KFileItemList)), notifyExt, SLOT(slotNewItems(KFileItemList)));
|
connect(lister, &KDirLister::newItems, notifyExt, &DolphinPartListingNotificationExtension::slotNewItems);
|
||||||
connect(lister, SIGNAL(itemsDeleted(KFileItemList)), notifyExt, SLOT(slotItemsDeleted(KFileItemList)));
|
connect(lister, &KDirLister::itemsDeleted, notifyExt, &DolphinPartListingNotificationExtension::slotItemsDeleted);
|
||||||
} else {
|
} else {
|
||||||
kWarning() << "NULL KDirLister object! KParts::ListingNotificationExtension will NOT be supported";
|
qCWarning(DolphinDebug) << "NULL KDirLister object! KParts::ListingNotificationExtension will NOT be supported";
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
createActions();
|
createActions();
|
||||||
m_actionHandler->updateViewActions();
|
m_actionHandler->updateViewActions();
|
||||||
|
@ -171,70 +165,70 @@ void DolphinPart::createActions()
|
||||||
|
|
||||||
m_newFileMenu = new DolphinNewFileMenu(actionCollection(), this);
|
m_newFileMenu = new DolphinNewFileMenu(actionCollection(), this);
|
||||||
m_newFileMenu->setParentWidget(widget());
|
m_newFileMenu->setParentWidget(widget());
|
||||||
connect(m_newFileMenu->menu(), SIGNAL(aboutToShow()),
|
connect(m_newFileMenu->menu(), &QMenu::aboutToShow,
|
||||||
this, SLOT(updateNewMenu()));
|
this, &DolphinPart::updateNewMenu);
|
||||||
|
|
||||||
KAction *editMimeTypeAction = actionCollection()->addAction( "editMimeType" );
|
QAction *editMimeTypeAction = actionCollection()->addAction( "editMimeType" );
|
||||||
editMimeTypeAction->setText( i18nc("@action:inmenu Edit", "&Edit File Type..." ) );
|
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->setText(i18nc("@action:inmenu Edit", "Select Items Matching..."));
|
||||||
selectItemsMatching->setShortcut(Qt::CTRL | Qt::Key_S);
|
actionCollection()->setDefaultShortcut(selectItemsMatching, Qt::CTRL | Qt::Key_S);
|
||||||
connect(selectItemsMatching, SIGNAL(triggered()), this, SLOT(slotSelectItemsMatchingPattern()));
|
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..."));
|
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()));
|
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"));
|
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->setText(i18nc("@action:inmenu Edit", "Invert Selection"));
|
||||||
invertSelection->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_A);
|
actionCollection()->setDefaultShortcut(invertSelection, Qt::CTRL | Qt::SHIFT | Qt::Key_A);
|
||||||
connect(invertSelection, SIGNAL(triggered()), m_view, SLOT(invertSelection()));
|
connect(invertSelection, &QAction::triggered, m_view, &DolphinView::invertSelection);
|
||||||
|
|
||||||
// View menu: all done by DolphinViewActionHandler
|
// View menu: all done by DolphinViewActionHandler
|
||||||
|
|
||||||
// Go menu
|
// Go menu
|
||||||
|
|
||||||
QActionGroup* goActionGroup = new QActionGroup(this);
|
QActionGroup* goActionGroup = new QActionGroup(this);
|
||||||
connect(goActionGroup, SIGNAL(triggered(QAction*)),
|
connect(goActionGroup, &QActionGroup::triggered,
|
||||||
this, SLOT(slotGoTriggered(QAction*)));
|
this, &DolphinPart::slotGoTriggered);
|
||||||
|
|
||||||
createGoAction("go_applications", "start-here-kde",
|
createGoAction("go_applications", "start-here-kde",
|
||||||
i18nc("@action:inmenu Go", "App&lications"), QString("programs:/"),
|
i18nc("@action:inmenu Go", "App&lications"), QStringLiteral("programs:/"),
|
||||||
goActionGroup);
|
goActionGroup);
|
||||||
createGoAction("go_network_folders", "folder-remote",
|
createGoAction("go_network_folders", "folder-remote",
|
||||||
i18nc("@action:inmenu Go", "&Network Folders"), QString("remote:/"),
|
i18nc("@action:inmenu Go", "&Network Folders"), QStringLiteral("remote:/"),
|
||||||
goActionGroup);
|
goActionGroup);
|
||||||
createGoAction("go_settings", "preferences-system",
|
createGoAction("go_settings", "preferences-system",
|
||||||
i18nc("@action:inmenu Go", "Sett&ings"), QString("settings:/"),
|
i18nc("@action:inmenu Go", "Sett&ings"), QStringLiteral("settings:/"),
|
||||||
goActionGroup);
|
goActionGroup);
|
||||||
createGoAction("go_trash", "user-trash",
|
createGoAction("go_trash", "user-trash",
|
||||||
i18nc("@action:inmenu Go", "Trash"), QString("trash:/"),
|
i18nc("@action:inmenu Go", "Trash"), QStringLiteral("trash:/"),
|
||||||
goActionGroup);
|
goActionGroup);
|
||||||
createGoAction("go_autostart", "",
|
createGoAction("go_autostart", "",
|
||||||
i18nc("@action:inmenu Go", "Autostart"), KGlobalSettings::autostartPath(),
|
i18nc("@action:inmenu Go", "Autostart"), QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + "/autostart",
|
||||||
goActionGroup);
|
goActionGroup);
|
||||||
|
|
||||||
// Tools menu
|
// Tools menu
|
||||||
m_findFileAction = actionCollection()->addAction("find_file");
|
m_findFileAction = actionCollection()->addAction("find_file");
|
||||||
m_findFileAction->setText(i18nc("@action:inmenu Tools", "Find File..."));
|
m_findFileAction->setText(i18nc("@action:inmenu Tools", "Find File..."));
|
||||||
m_findFileAction->setShortcut(Qt::CTRL | Qt::Key_F);
|
actionCollection()->setDefaultShortcut(m_findFileAction, Qt::CTRL | Qt::Key_F);
|
||||||
m_findFileAction->setIcon(KIcon("edit-find"));
|
m_findFileAction->setIcon(QIcon::fromTheme("edit-find"));
|
||||||
connect(m_findFileAction, SIGNAL(triggered()), this, SLOT(slotFindFile()));
|
connect(m_findFileAction, &QAction::triggered, this, &DolphinPart::slotFindFile);
|
||||||
|
|
||||||
if (KAuthorized::authorizeKAction("shell_access")) {
|
if (KAuthorized::authorizeKAction("shell_access")) {
|
||||||
m_openTerminalAction = actionCollection()->addAction("open_terminal");
|
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"));
|
m_openTerminalAction->setText(i18nc("@action:inmenu Tools", "Open &Terminal"));
|
||||||
connect(m_openTerminalAction, SIGNAL(triggered()), SLOT(slotOpenTerminal()));
|
connect(m_openTerminalAction, &QAction::triggered, this, &DolphinPart::slotOpenTerminal);
|
||||||
m_openTerminalAction->setShortcut(Qt::Key_F4);
|
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,
|
const QString& text, const QString& url,
|
||||||
QActionGroup* actionGroup)
|
QActionGroup* actionGroup)
|
||||||
{
|
{
|
||||||
KAction* action = actionCollection()->addAction(name);
|
QAction* action = actionCollection()->addAction(name);
|
||||||
action->setIcon(KIcon(iconName));
|
action->setIcon(QIcon::fromTheme(iconName));
|
||||||
action->setText(text);
|
action->setText(text);
|
||||||
action->setData(url);
|
action->setData(url);
|
||||||
action->setActionGroup(actionGroup);
|
action->setActionGroup(actionGroup);
|
||||||
|
@ -252,7 +246,7 @@ void DolphinPart::createGoAction(const char* name, const char* iconName,
|
||||||
void DolphinPart::slotGoTriggered(QAction* action)
|
void DolphinPart::slotGoTriggered(QAction* action)
|
||||||
{
|
{
|
||||||
const QString url = action->data().toString();
|
const QString url = action->data().toString();
|
||||||
emit m_extension->openUrlRequest(KUrl(url));
|
emit m_extension->openUrlRequest(QUrl(url));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinPart::slotSelectionChanged(const KFileItemList& selection)
|
void DolphinPart::slotSelectionChanged(const KFileItemList& selection)
|
||||||
|
@ -301,10 +295,10 @@ void DolphinPart::updatePasteAction()
|
||||||
|
|
||||||
KAboutData* DolphinPart::createAboutData()
|
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();
|
bool reload = arguments().reload();
|
||||||
// A bit of a workaround so that changing the namefilter works: force 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;
|
return true;
|
||||||
}
|
}
|
||||||
setUrl(url); // remember it at the KParts level
|
setUrl(url); // remember it at the KParts level
|
||||||
KUrl visibleUrl(url);
|
QUrl visibleUrl(url);
|
||||||
if (!m_nameFilter.isEmpty()) {
|
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 setWindowCaption(prettyUrl);
|
||||||
emit m_extension->setLocationBarUrl(prettyUrl);
|
emit m_extension->setLocationBarUrl(prettyUrl);
|
||||||
emit started(0); // get the wheel to spin
|
emit started(0); // get the wheel to spin
|
||||||
|
@ -346,7 +340,7 @@ void DolphinPart::slotMessage(const QString& msg)
|
||||||
|
|
||||||
void DolphinPart::slotErrorMessage(const QString& msg)
|
void DolphinPart::slotErrorMessage(const QString& msg)
|
||||||
{
|
{
|
||||||
kDebug() << msg;
|
qCDebug(DolphinDebug) << msg;
|
||||||
emit canceled(msg);
|
emit canceled(msg);
|
||||||
//KMessageBox::error(m_view, 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
|
// TODO: Check issue N176832 for the missing QAIV signal; task 177399 - maybe this code
|
||||||
// should be moved into DolphinPart::slotItemActivated()
|
// should be moved into DolphinPart::slotItemActivated()
|
||||||
|
@ -394,7 +388,7 @@ void DolphinPart::createNewWindow(const KUrl& url)
|
||||||
|
|
||||||
void DolphinPart::slotOpenContextMenu(const QPoint& pos,
|
void DolphinPart::slotOpenContextMenu(const QPoint& pos,
|
||||||
const KFileItem& _item,
|
const KFileItem& _item,
|
||||||
const KUrl&,
|
const QUrl &,
|
||||||
const QList<QAction*>& customActions)
|
const QList<QAction*>& customActions)
|
||||||
{
|
{
|
||||||
KParts::BrowserExtension::PopupFlags popupFlags = KParts::BrowserExtension::DefaultPopupItems
|
KParts::BrowserExtension::PopupFlags popupFlags = KParts::BrowserExtension::DefaultPopupItems
|
||||||
|
@ -407,7 +401,7 @@ void DolphinPart::slotOpenContextMenu(const QPoint& pos,
|
||||||
popupFlags |= KParts::BrowserExtension::ShowNavigationItems | KParts::BrowserExtension::ShowUp;
|
popupFlags |= KParts::BrowserExtension::ShowNavigationItems | KParts::BrowserExtension::ShowUp;
|
||||||
item = m_view->rootItem();
|
item = m_view->rootItem();
|
||||||
if (item.isNull())
|
if (item.isNull())
|
||||||
item = KFileItem( S_IFDIR, (mode_t)-1, url() );
|
item = KFileItem(url());
|
||||||
else
|
else
|
||||||
item.setUrl(url()); // ensure we use the view url, not the canonical path (#213799)
|
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();
|
const bool supportsMoving = capabilities.supportsMoving();
|
||||||
|
|
||||||
if (capabilities.supportsDeleting()) {
|
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());
|
!item.isLocalFile());
|
||||||
const bool showMoveToTrashAction = capabilities.isLocal() && supportsMoving;
|
const bool showMoveToTrashAction = capabilities.isLocal() && supportsMoving;
|
||||||
|
|
||||||
|
@ -475,12 +469,12 @@ void DolphinPart::slotOpenContextMenu(const QPoint& pos,
|
||||||
actionGroups);
|
actionGroups);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinPart::slotDirectoryRedirection(const KUrl& oldUrl, const KUrl& newUrl)
|
void DolphinPart::slotDirectoryRedirection(const QUrl &oldUrl, const QUrl &newUrl)
|
||||||
{
|
{
|
||||||
//kDebug() << oldUrl << newUrl << "currentUrl=" << url();
|
qCDebug(DolphinDebug) << oldUrl << newUrl << "currentUrl=" << url();
|
||||||
if (oldUrl.equals(url(), KUrl::CompareWithoutTrailingSlash /* #207572 */)) {
|
if (oldUrl.matches(url(), QUrl::StripTrailingSlash /* #207572 */)) {
|
||||||
KParts::ReadOnlyPart::setUrl(newUrl);
|
KParts::ReadOnlyPart::setUrl(newUrl);
|
||||||
const QString prettyUrl = newUrl.pathOrUrl();
|
const QString prettyUrl = newUrl.toDisplayString(QUrl::PreferLocalFile);
|
||||||
emit m_extension->setLocationBarUrl(prettyUrl);
|
emit m_extension->setLocationBarUrl(prettyUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -490,7 +484,7 @@ void DolphinPart::slotEditMimeType()
|
||||||
{
|
{
|
||||||
const KFileItemList items = m_view->selectedItems();
|
const KFileItemList items = m_view->selectedItems();
|
||||||
if (!items.isEmpty()) {
|
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)
|
void DolphinPart::openSelectionDialog(const QString& title, const QString& text, bool selectItems)
|
||||||
{
|
{
|
||||||
bool okClicked;
|
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()) {
|
if (okClicked && !pattern.isEmpty()) {
|
||||||
QRegExp patternRegExp(pattern, Qt::CaseSensitive, QRegExp::Wildcard);
|
QRegExp patternRegExp(pattern, Qt::CaseSensitive, QRegExp::Wildcard);
|
||||||
|
@ -543,11 +537,14 @@ void DolphinPart::slotOpenTerminal()
|
||||||
{
|
{
|
||||||
QString dir(QDir::homePath());
|
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
|
// 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.
|
// 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 the URL is local after the above conversion, set the directory.
|
||||||
if (u.isLocalFile()) {
|
if (u.isLocalFile()) {
|
||||||
|
@ -559,7 +556,7 @@ void DolphinPart::slotOpenTerminal()
|
||||||
|
|
||||||
void DolphinPart::slotFindFile()
|
void DolphinPart::slotFindFile()
|
||||||
{
|
{
|
||||||
KRun::run("kfind", url(), widget());
|
KRun::run("kfind", {url()}, widget());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinPart::updateNewMenu()
|
void DolphinPart::updateNewMenu()
|
||||||
|
@ -589,7 +586,7 @@ void DolphinPart::createDirectory()
|
||||||
m_newFileMenu->createDirectory();
|
m_newFileMenu->createDirectory();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinPart::setFilesToSelect(const KUrl::List& files)
|
void DolphinPart::setFilesToSelect(const QList<QUrl>& files)
|
||||||
{
|
{
|
||||||
if (files.isEmpty()) {
|
if (files.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -20,20 +20,17 @@
|
||||||
#ifndef DOLPHINPART_H
|
#ifndef DOLPHINPART_H
|
||||||
#define DOLPHINPART_H
|
#define DOLPHINPART_H
|
||||||
|
|
||||||
#include <kparts/part.h>
|
#include <KParts/ReadOnlyPart>
|
||||||
|
#include <QUrl>
|
||||||
|
|
||||||
#include <QItemSelectionModel>
|
|
||||||
|
|
||||||
class DolphinNewFileMenu;
|
class DolphinNewFileMenu;
|
||||||
class DolphinViewActionHandler;
|
class DolphinViewActionHandler;
|
||||||
class QActionGroup;
|
class QActionGroup;
|
||||||
class KAction;
|
|
||||||
class KFileItemList;
|
class KFileItemList;
|
||||||
class KFileItem;
|
class KFileItem;
|
||||||
class DolphinPartBrowserExtension;
|
class DolphinPartBrowserExtension;
|
||||||
class DolphinSortFilterProxyModel;
|
|
||||||
class DolphinRemoteEncoding;
|
class DolphinRemoteEncoding;
|
||||||
class DolphinModel;
|
|
||||||
class KDirLister;
|
class KDirLister;
|
||||||
class DolphinView;
|
class DolphinView;
|
||||||
class KAboutData;
|
class KAboutData;
|
||||||
|
@ -53,7 +50,7 @@ class DolphinPart : public KParts::ReadOnlyPart
|
||||||
Q_PROPERTY( QString nameFilter READ nameFilter WRITE setNameFilter )
|
Q_PROPERTY( QString nameFilter READ nameFilter WRITE setNameFilter )
|
||||||
|
|
||||||
// Used by konqueror to implement the --select command-line option
|
// 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:
|
public:
|
||||||
explicit DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantList& args);
|
explicit DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantList& args);
|
||||||
|
@ -65,7 +62,7 @@ public:
|
||||||
* Standard KParts::ReadOnlyPart openUrl method.
|
* Standard KParts::ReadOnlyPart openUrl method.
|
||||||
* Called by Konqueror to view a directory in DolphinPart.
|
* 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
|
/// see the supportsUndo property
|
||||||
bool supportsUndo() const { return true; }
|
bool supportsUndo() const { return true; }
|
||||||
|
@ -134,7 +131,7 @@ private Q_SLOTS:
|
||||||
/**
|
/**
|
||||||
* Creates a new window showing the content of \a url.
|
* 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.
|
* Opens the context menu on the current mouse position.
|
||||||
* @pos Position in screen coordinates.
|
* @pos Position in screen coordinates.
|
||||||
|
@ -146,7 +143,7 @@ private Q_SLOTS:
|
||||||
*/
|
*/
|
||||||
void slotOpenContextMenu(const QPoint& pos,
|
void slotOpenContextMenu(const QPoint& pos,
|
||||||
const KFileItem& item,
|
const KFileItem& item,
|
||||||
const KUrl& url,
|
const QUrl& url,
|
||||||
const QList<QAction*>& customActions);
|
const QList<QAction*>& customActions);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -155,7 +152,7 @@ private Q_SLOTS:
|
||||||
* Testcase 1: fish://localhost
|
* Testcase 1: fish://localhost
|
||||||
* Testcase 2: showing a directory that is being renamed by another window (#180156)
|
* 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
|
* Updates the state of the 'Edit' menu actions and emits
|
||||||
|
@ -223,10 +220,10 @@ private Q_SLOTS:
|
||||||
/**
|
/**
|
||||||
* Called by konqueror --select
|
* Called by konqueror --select
|
||||||
*/
|
*/
|
||||||
void setFilesToSelect(const KUrl::List& files);
|
void setFilesToSelect(const QList<QUrl> &files);
|
||||||
KUrl::List filesToSelect() const { return KUrl::List(); } // silence moc
|
QList<QUrl> filesToSelect() const { return QList<QUrl>(); } // silence moc
|
||||||
|
|
||||||
virtual bool eventFilter(QObject*, QEvent*);
|
virtual bool eventFilter(QObject*, QEvent*) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void createActions();
|
void createActions();
|
||||||
|
@ -243,8 +240,8 @@ private:
|
||||||
DolphinRemoteEncoding* m_remoteEncoding;
|
DolphinRemoteEncoding* m_remoteEncoding;
|
||||||
DolphinPartBrowserExtension* m_extension;
|
DolphinPartBrowserExtension* m_extension;
|
||||||
DolphinNewFileMenu* m_newFileMenu;
|
DolphinNewFileMenu* m_newFileMenu;
|
||||||
KAction* m_findFileAction;
|
QAction* m_findFileAction;
|
||||||
KAction* m_openTerminalAction;
|
QAction* m_openTerminalAction;
|
||||||
QString m_nameFilter;
|
QString m_nameFilter;
|
||||||
DolphinRemoveAction* m_removeAction;
|
DolphinRemoveAction* m_removeAction;
|
||||||
Q_DISABLE_COPY(DolphinPart)
|
Q_DISABLE_COPY(DolphinPart)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
|
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
|
||||||
<kpartgui name="dolphinpart" version="10" >
|
<kpartgui name="dolphinpart" version="11" translationDomain="dolphin">
|
||||||
<MenuBar>
|
<MenuBar>
|
||||||
<Menu name="edit"><text>&Edit</text>
|
<Menu name="edit"><text>&Edit</text>
|
||||||
<Action name="new_menu"/>
|
<Action name="new_menu"/>
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
#include <KFileItemList>
|
#include <KFileItem>
|
||||||
|
|
||||||
|
|
||||||
DolphinPartBrowserExtension::DolphinPartBrowserExtension(DolphinPart* part)
|
DolphinPartBrowserExtension::DolphinPartBrowserExtension(DolphinPart* part)
|
||||||
|
@ -61,7 +61,7 @@ void DolphinPartBrowserExtension::paste()
|
||||||
m_part->view()->paste();
|
m_part->view()->paste();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinPartBrowserExtension::pasteTo(const KUrl&)
|
void DolphinPartBrowserExtension::pasteTo(const QUrl&)
|
||||||
{
|
{
|
||||||
m_part->view()->pasteIntoFolder();
|
m_part->view()->pasteIntoFolder();
|
||||||
}
|
}
|
||||||
|
@ -190,4 +190,3 @@ void DolphinPartListingNotificationExtension::slotItemsDeleted(const KFileItemLi
|
||||||
emit listingEvent(KParts::ListingNotificationExtension::ItemsDeleted, items);
|
emit listingEvent(KParts::ListingNotificationExtension::ItemsDeleted, items);
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "dolphinpart_ext.moc"
|
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include <kparts/browserextension.h>
|
#include <kparts/browserextension.h>
|
||||||
#include <kparts/fileinfoextension.h>
|
#include <kparts/fileinfoextension.h>
|
||||||
#include <kparts/listingextension.h>
|
#include <kparts/listingextension.h>
|
||||||
|
#include <QUrl>
|
||||||
|
|
||||||
class DolphinPart;
|
class DolphinPart;
|
||||||
|
|
||||||
|
@ -31,14 +32,14 @@ class DolphinPartBrowserExtension : public KParts::BrowserExtension
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
DolphinPartBrowserExtension( DolphinPart* part );
|
DolphinPartBrowserExtension( DolphinPart* part );
|
||||||
virtual void restoreState(QDataStream &stream);
|
virtual void restoreState(QDataStream &stream) Q_DECL_OVERRIDE;
|
||||||
virtual void saveState(QDataStream &stream);
|
virtual void saveState(QDataStream &stream) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void cut();
|
void cut();
|
||||||
void copy();
|
void copy();
|
||||||
void paste();
|
void paste();
|
||||||
void pasteTo(const KUrl&);
|
void pasteTo(const QUrl &);
|
||||||
void reparseConfiguration();
|
void reparseConfiguration();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -52,10 +53,10 @@ class DolphinPartFileInfoExtension : public KParts::FileInfoExtension
|
||||||
public:
|
public:
|
||||||
DolphinPartFileInfoExtension(DolphinPart* part);
|
DolphinPartFileInfoExtension(DolphinPart* part);
|
||||||
|
|
||||||
virtual QueryModes supportedQueryModes() const;
|
virtual QueryModes supportedQueryModes() const Q_DECL_OVERRIDE;
|
||||||
virtual bool hasSelection() const;
|
virtual bool hasSelection() const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
virtual KFileItemList queryFor(QueryMode mode) const;
|
virtual KFileItemList queryFor(QueryMode mode) const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DolphinPart* m_part;
|
DolphinPart* m_part;
|
||||||
|
@ -67,10 +68,10 @@ class DolphinPartListingFilterExtension : public KParts::ListingFilterExtension
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DolphinPartListingFilterExtension(DolphinPart* part);
|
DolphinPartListingFilterExtension(DolphinPart* part);
|
||||||
virtual FilterModes supportedFilterModes() const;
|
virtual FilterModes supportedFilterModes() const Q_DECL_OVERRIDE;
|
||||||
virtual bool supportsMultipleFilters(FilterMode mode) const;
|
virtual bool supportsMultipleFilters(FilterMode mode) const Q_DECL_OVERRIDE;
|
||||||
virtual QVariant filter(FilterMode mode) const;
|
virtual QVariant filter(FilterMode mode) const Q_DECL_OVERRIDE;
|
||||||
virtual void setFilter(FilterMode mode, const QVariant& filter);
|
virtual void setFilter(FilterMode mode, const QVariant& filter) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DolphinPart* m_part;
|
DolphinPart* m_part;
|
||||||
|
@ -82,7 +83,7 @@ class DolphinPartListingNotificationExtension : public KParts::ListingNotificati
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DolphinPartListingNotificationExtension(DolphinPart* part);
|
DolphinPartListingNotificationExtension(DolphinPart* part);
|
||||||
virtual NotificationEventTypes supportedNotificationEventTypes() const;
|
virtual NotificationEventTypes supportedNotificationEventTypes() const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void slotNewItems(const KFileItemList&);
|
void slotNewItems(const KFileItemList&);
|
||||||
|
|
|
@ -21,17 +21,17 @@
|
||||||
|
|
||||||
#include <KLocalizedString>
|
#include <KLocalizedString>
|
||||||
#include <KAcceleratorManager>
|
#include <KAcceleratorManager>
|
||||||
#include <KMimeType>
|
#include <kio/global.h>
|
||||||
#include <KMenu>
|
#include <QMenu>
|
||||||
|
|
||||||
DolphinRecentTabsMenu::DolphinRecentTabsMenu(QObject* parent) :
|
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);
|
setDelayed(false);
|
||||||
setEnabled(false);
|
setEnabled(false);
|
||||||
|
|
||||||
m_clearListAction = new QAction(i18n("Empty Recently Closed Tabs"), this);
|
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);
|
addAction(m_clearListAction);
|
||||||
|
|
||||||
addSeparator();
|
addSeparator();
|
||||||
|
@ -40,13 +40,13 @@ DolphinRecentTabsMenu::DolphinRecentTabsMenu(QObject* parent) :
|
||||||
this, SLOT(handleAction(QAction*)));
|
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());
|
QAction* action = new QAction(menu());
|
||||||
action->setText(url.path());
|
action->setText(url.path());
|
||||||
action->setData(state);
|
action->setData(state);
|
||||||
const QString iconName = KMimeType::iconNameForUrl(url);
|
const QString iconName = KIO::iconNameForUrl(url);
|
||||||
action->setIcon(KIcon(iconName));
|
action->setIcon(QIcon::fromTheme(iconName));
|
||||||
|
|
||||||
// Add the closed tab menu entry after the separator and
|
// Add the closed tab menu entry after the separator and
|
||||||
// "Empty Recently Closed Tabs" entry
|
// "Empty Recently Closed Tabs" entry
|
||||||
|
|
|
@ -21,9 +21,8 @@
|
||||||
#define DOLPHIN_RECENT_TABS_MENU_H
|
#define DOLPHIN_RECENT_TABS_MENU_H
|
||||||
|
|
||||||
#include <KActionMenu>
|
#include <KActionMenu>
|
||||||
#include <KUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
class DolphinTabPage;
|
|
||||||
class QAction;
|
class QAction;
|
||||||
|
|
||||||
class DolphinRecentTabsMenu : public KActionMenu
|
class DolphinRecentTabsMenu : public KActionMenu
|
||||||
|
@ -34,7 +33,7 @@ public:
|
||||||
explicit DolphinRecentTabsMenu(QObject* parent);
|
explicit DolphinRecentTabsMenu(QObject* parent);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void rememberClosedTab(const KUrl& url, const QByteArray& state);
|
void rememberClosedTab(const QUrl& url, const QByteArray& state);
|
||||||
void undoCloseTab();
|
void undoCloseTab();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
|
@ -29,7 +29,7 @@ DolphinRemoveAction::DolphinRemoveAction(QObject* parent, KActionCollection* col
|
||||||
m_collection(collection)
|
m_collection(collection)
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
connect(this, SIGNAL(triggered()), this, SLOT(slotRemoveActionTriggered()));
|
connect(this, &DolphinRemoveAction::triggered, this, &DolphinRemoveAction::slotRemoveActionTriggered);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinRemoveAction::slotRemoveActionTriggered()
|
void DolphinRemoveAction::slotRemoveActionTriggered()
|
||||||
|
@ -55,7 +55,7 @@ void DolphinRemoveAction::update()
|
||||||
|
|
||||||
if (m_action) {
|
if (m_action) {
|
||||||
setIcon(m_action->icon());
|
setIcon(m_action->icon());
|
||||||
setShortcuts(m_action->shortcuts());
|
m_collection->setDefaultShortcuts(this, m_action->shortcuts());
|
||||||
setEnabled(m_action->isEnabled());
|
setEnabled(m_action->isEnabled());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#ifndef DOLPHINREMOVEACTION_H
|
#ifndef DOLPHINREMOVEACTION_H
|
||||||
#define DOLPHINREMOVEACTION_H
|
#define DOLPHINREMOVEACTION_H
|
||||||
|
|
||||||
#include "libdolphin_export.h"
|
#include "dolphin_export.h"
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
@ -34,7 +34,7 @@
|
||||||
* This class expects the presence of both the "move_to_trash" and "delete"
|
* This class expects the presence of both the "move_to_trash" and "delete"
|
||||||
* actions in @ref collection.
|
* actions in @ref collection.
|
||||||
*/
|
*/
|
||||||
class LIBDOLPHINPRIVATE_EXPORT DolphinRemoveAction : public QAction
|
class DOLPHIN_EXPORT DolphinRemoveAction : public QAction
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -22,9 +22,10 @@
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QDragEnterEvent>
|
#include <QDragEnterEvent>
|
||||||
#include <KLocalizedString>
|
#include <KLocalizedString>
|
||||||
#include <KMenu>
|
#include <QMenu>
|
||||||
#include <KIcon>
|
#include <QIcon>
|
||||||
#include <KUrl>
|
#include <QUrl>
|
||||||
|
#include <QMimeData>
|
||||||
|
|
||||||
DolphinTabBar::DolphinTabBar(QWidget* parent) :
|
DolphinTabBar::DolphinTabBar(QWidget* parent) :
|
||||||
QTabBar(parent),
|
QTabBar(parent),
|
||||||
|
@ -47,7 +48,7 @@ void DolphinTabBar::dragEnterEvent(QDragEnterEvent* event)
|
||||||
const QMimeData* mimeData = event->mimeData();
|
const QMimeData* mimeData = event->mimeData();
|
||||||
const int index = tabAt(event->pos());
|
const int index = tabAt(event->pos());
|
||||||
|
|
||||||
if (KUrl::List::canDecode(mimeData)) {
|
if (mimeData->hasUrls()) {
|
||||||
event->acceptProposedAction();
|
event->acceptProposedAction();
|
||||||
updateAutoActivationTimer(index);
|
updateAutoActivationTimer(index);
|
||||||
}
|
}
|
||||||
|
@ -67,7 +68,7 @@ void DolphinTabBar::dragMoveEvent(QDragMoveEvent* event)
|
||||||
const QMimeData* mimeData = event->mimeData();
|
const QMimeData* mimeData = event->mimeData();
|
||||||
const int index = tabAt(event->pos());
|
const int index = tabAt(event->pos());
|
||||||
|
|
||||||
if (KUrl::List::canDecode(mimeData)) {
|
if (mimeData->hasUrls()) {
|
||||||
updateAutoActivationTimer(index);
|
updateAutoActivationTimer(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +83,7 @@ void DolphinTabBar::dropEvent(QDropEvent* event)
|
||||||
const QMimeData* mimeData = event->mimeData();
|
const QMimeData* mimeData = event->mimeData();
|
||||||
const int index = tabAt(event->pos());
|
const int index = tabAt(event->pos());
|
||||||
|
|
||||||
if (index >= 0 && KUrl::List::canDecode(mimeData)) {
|
if (index >= 0 && mimeData->hasUrls()) {
|
||||||
emit tabDropEvent(index, event);
|
emit tabDropEvent(index, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,12 +123,12 @@ void DolphinTabBar::contextMenuEvent(QContextMenuEvent* event)
|
||||||
|
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
// Tab context menu
|
// Tab context menu
|
||||||
KMenu menu(this);
|
QMenu menu(this);
|
||||||
|
|
||||||
QAction* newTabAction = menu.addAction(KIcon("tab-new"), i18nc("@action:inmenu", "New Tab"));
|
QAction* newTabAction = menu.addAction(QIcon::fromTheme("tab-new"), i18nc("@action:inmenu", "New Tab"));
|
||||||
QAction* detachTabAction = menu.addAction(KIcon("tab-detach"), i18nc("@action:inmenu", "Detach Tab"));
|
QAction* detachTabAction = menu.addAction(QIcon::fromTheme("tab-detach"), i18nc("@action:inmenu", "Detach Tab"));
|
||||||
QAction* closeOtherTabsAction = menu.addAction(KIcon("tab-close-other"), i18nc("@action:inmenu", "Close Other Tabs"));
|
QAction* closeOtherTabsAction = menu.addAction(QIcon::fromTheme("tab-close-other"), i18nc("@action:inmenu", "Close Other Tabs"));
|
||||||
QAction* closeTabAction = menu.addAction(KIcon("tab-close"), i18nc("@action:inmenu", "Close Tab"));
|
QAction* closeTabAction = menu.addAction(QIcon::fromTheme("tab-close"), i18nc("@action:inmenu", "Close Tab"));
|
||||||
|
|
||||||
QAction* selectedAction = menu.exec(event->globalPos());
|
QAction* selectedAction = menu.exec(event->globalPos());
|
||||||
if (selectedAction == newTabAction) {
|
if (selectedAction == newTabAction) {
|
||||||
|
|
|
@ -35,17 +35,17 @@ signals:
|
||||||
void tabDetachRequested(int index);
|
void tabDetachRequested(int index);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void dragEnterEvent(QDragEnterEvent* event);
|
virtual void dragEnterEvent(QDragEnterEvent* event) Q_DECL_OVERRIDE;
|
||||||
virtual void dragLeaveEvent(QDragLeaveEvent* event);
|
virtual void dragLeaveEvent(QDragLeaveEvent* event) Q_DECL_OVERRIDE;
|
||||||
virtual void dragMoveEvent(QDragMoveEvent* event);
|
virtual void dragMoveEvent(QDragMoveEvent* event) Q_DECL_OVERRIDE;
|
||||||
virtual void dropEvent(QDropEvent* event);
|
virtual void dropEvent(QDropEvent* event) Q_DECL_OVERRIDE;
|
||||||
virtual void mousePressEvent(QMouseEvent* event);
|
virtual void mousePressEvent(QMouseEvent* event) Q_DECL_OVERRIDE;
|
||||||
virtual void mouseDoubleClickEvent(QMouseEvent* event);
|
virtual void mouseDoubleClickEvent(QMouseEvent* event) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens a context menu for the tab on the \a event position.
|
* 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:
|
private slots:
|
||||||
void slotAutoActivationTimeout();
|
void slotAutoActivationTimeout();
|
||||||
|
|
|
@ -23,8 +23,9 @@
|
||||||
#include "dolphin_generalsettings.h"
|
#include "dolphin_generalsettings.h"
|
||||||
|
|
||||||
#include <QSplitter>
|
#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),
|
QWidget(parent),
|
||||||
m_primaryViewActive(true),
|
m_primaryViewActive(true),
|
||||||
m_splitViewEnabled(false)
|
m_splitViewEnabled(false)
|
||||||
|
@ -39,10 +40,10 @@ DolphinTabPage::DolphinTabPage(const KUrl& primaryUrl, const KUrl& secondaryUrl,
|
||||||
|
|
||||||
// Create a new primary view
|
// Create a new primary view
|
||||||
m_primaryViewContainer = createViewContainer(primaryUrl);
|
m_primaryViewContainer = createViewContainer(primaryUrl);
|
||||||
connect(m_primaryViewContainer->view(), SIGNAL(urlChanged(KUrl)),
|
connect(m_primaryViewContainer->view(), SIGNAL(urlChanged(QUrl)),
|
||||||
this, SIGNAL(activeViewUrlChanged(KUrl)));
|
this, SIGNAL(activeViewUrlChanged(QUrl)));
|
||||||
connect(m_primaryViewContainer->view(), SIGNAL(redirection(KUrl,KUrl)),
|
connect(m_primaryViewContainer->view(), SIGNAL(redirection(QUrl,QUrl)),
|
||||||
this, SLOT(slotViewUrlRedirection(KUrl,KUrl)));
|
this, SLOT(slotViewUrlRedirection(QUrl,QUrl)));
|
||||||
|
|
||||||
m_splitter->addWidget(m_primaryViewContainer);
|
m_splitter->addWidget(m_primaryViewContainer);
|
||||||
m_primaryViewContainer->show();
|
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
|
// 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).
|
// startup settings are set this way (use the url of the primary view).
|
||||||
m_splitViewEnabled = true;
|
m_splitViewEnabled = true;
|
||||||
const KUrl& url = secondaryUrl.isValid() ? secondaryUrl : primaryUrl;
|
const QUrl& url = secondaryUrl.isValid() ? secondaryUrl : primaryUrl;
|
||||||
m_secondaryViewContainer = createViewContainer(url);
|
m_secondaryViewContainer = createViewContainer(url);
|
||||||
m_splitter->addWidget(m_secondaryViewContainer);
|
m_splitter->addWidget(m_secondaryViewContainer);
|
||||||
m_secondaryViewContainer->show();
|
m_secondaryViewContainer->show();
|
||||||
|
@ -76,7 +77,7 @@ void DolphinTabPage::setSplitViewEnabled(bool enabled)
|
||||||
m_splitViewEnabled = enabled;
|
m_splitViewEnabled = enabled;
|
||||||
|
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
const KUrl& url = m_primaryViewContainer->url();
|
const QUrl& url = m_primaryViewContainer->url();
|
||||||
m_secondaryViewContainer = createViewContainer(url);
|
m_secondaryViewContainer = createViewContainer(url);
|
||||||
|
|
||||||
const bool placesSelectorVisible = m_primaryViewContainer->urlNavigator()->isPlacesSelectorVisible();
|
const bool placesSelectorVisible = m_primaryViewContainer->urlNavigator()->isPlacesSelectorVisible();
|
||||||
|
@ -134,7 +135,7 @@ int DolphinTabPage::selectedItemsCount() const
|
||||||
return selectedItemsCount;
|
return selectedItemsCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinTabPage::markUrlsAsSelected(const QList<KUrl>& urls)
|
void DolphinTabPage::markUrlsAsSelected(const QList<QUrl>& urls)
|
||||||
{
|
{
|
||||||
m_primaryViewContainer->view()->markUrlsAsSelected(urls);
|
m_primaryViewContainer->view()->markUrlsAsSelected(urls);
|
||||||
if (m_splitViewEnabled) {
|
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);
|
m_primaryViewContainer->view()->markUrlAsCurrent(url);
|
||||||
if (m_splitViewEnabled) {
|
if (m_splitViewEnabled) {
|
||||||
|
@ -212,7 +213,7 @@ void DolphinTabPage::restoreState(const QByteArray& state)
|
||||||
stream >> isSplitViewEnabled;
|
stream >> isSplitViewEnabled;
|
||||||
setSplitViewEnabled(isSplitViewEnabled);
|
setSplitViewEnabled(isSplitViewEnabled);
|
||||||
|
|
||||||
KUrl primaryUrl;
|
QUrl primaryUrl;
|
||||||
stream >> primaryUrl;
|
stream >> primaryUrl;
|
||||||
m_primaryViewContainer->setUrl(primaryUrl);
|
m_primaryViewContainer->setUrl(primaryUrl);
|
||||||
bool primaryUrlEditable;
|
bool primaryUrlEditable;
|
||||||
|
@ -221,7 +222,7 @@ void DolphinTabPage::restoreState(const QByteArray& state)
|
||||||
m_primaryViewContainer->view()->restoreState(stream);
|
m_primaryViewContainer->view()->restoreState(stream);
|
||||||
|
|
||||||
if (isSplitViewEnabled) {
|
if (isSplitViewEnabled) {
|
||||||
KUrl secondaryUrl;
|
QUrl secondaryUrl;
|
||||||
stream >> secondaryUrl;
|
stream >> secondaryUrl;
|
||||||
m_secondaryViewContainer->setUrl(secondaryUrl);
|
m_secondaryViewContainer->setUrl(secondaryUrl);
|
||||||
bool secondaryUrlEditable;
|
bool secondaryUrlEditable;
|
||||||
|
@ -256,7 +257,7 @@ void DolphinTabPage::restoreStateV1(const QByteArray& state)
|
||||||
stream >> isSplitViewEnabled;
|
stream >> isSplitViewEnabled;
|
||||||
setSplitViewEnabled(isSplitViewEnabled);
|
setSplitViewEnabled(isSplitViewEnabled);
|
||||||
|
|
||||||
KUrl primaryUrl;
|
QUrl primaryUrl;
|
||||||
stream >> primaryUrl;
|
stream >> primaryUrl;
|
||||||
m_primaryViewContainer->setUrl(primaryUrl);
|
m_primaryViewContainer->setUrl(primaryUrl);
|
||||||
bool primaryUrlEditable;
|
bool primaryUrlEditable;
|
||||||
|
@ -264,7 +265,7 @@ void DolphinTabPage::restoreStateV1(const QByteArray& state)
|
||||||
m_primaryViewContainer->urlNavigator()->setUrlEditable(primaryUrlEditable);
|
m_primaryViewContainer->urlNavigator()->setUrlEditable(primaryUrlEditable);
|
||||||
|
|
||||||
if (isSplitViewEnabled) {
|
if (isSplitViewEnabled) {
|
||||||
KUrl secondaryUrl;
|
QUrl secondaryUrl;
|
||||||
stream >> secondaryUrl;
|
stream >> secondaryUrl;
|
||||||
m_secondaryViewContainer->setUrl(secondaryUrl);
|
m_secondaryViewContainer->setUrl(secondaryUrl);
|
||||||
bool secondaryUrlEditable;
|
bool secondaryUrlEditable;
|
||||||
|
@ -301,28 +302,28 @@ void DolphinTabPage::slotViewActivated()
|
||||||
const DolphinView* newActiveView = activeViewContainer()->view();
|
const DolphinView* newActiveView = activeViewContainer()->view();
|
||||||
|
|
||||||
if (newActiveView != oldActiveView) {
|
if (newActiveView != oldActiveView) {
|
||||||
disconnect(oldActiveView, SIGNAL(urlChanged(KUrl)),
|
disconnect(oldActiveView, SIGNAL(urlChanged(QUrl)),
|
||||||
this, SIGNAL(activeViewUrlChanged(KUrl)));
|
this, SIGNAL(activeViewUrlChanged(QUrl)));
|
||||||
disconnect(oldActiveView, SIGNAL(redirection(KUrl,KUrl)),
|
disconnect(oldActiveView, SIGNAL(redirection(QUrl,QUrl)),
|
||||||
this, SLOT(slotViewUrlRedirection(KUrl,KUrl)));
|
this, SLOT(slotViewUrlRedirection(QUrl,QUrl)));
|
||||||
connect(newActiveView, SIGNAL(urlChanged(KUrl)),
|
connect(newActiveView, SIGNAL(urlChanged(QUrl)),
|
||||||
this, SIGNAL(activeViewUrlChanged(KUrl)));
|
this, SIGNAL(activeViewUrlChanged(QUrl)));
|
||||||
connect(newActiveView, SIGNAL(redirection(KUrl,KUrl)),
|
connect(newActiveView, SIGNAL(redirection(QUrl,QUrl)),
|
||||||
this, SLOT(slotViewUrlRedirection(KUrl,KUrl)));
|
this, SLOT(slotViewUrlRedirection(QUrl,QUrl)));
|
||||||
}
|
}
|
||||||
|
|
||||||
emit activeViewUrlChanged(activeViewContainer()->url());
|
emit activeViewUrlChanged(activeViewContainer()->url());
|
||||||
emit activeViewChanged(activeViewContainer());
|
emit activeViewChanged(activeViewContainer());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinTabPage::slotViewUrlRedirection(const KUrl& oldUrl, const KUrl& newUrl)
|
void DolphinTabPage::slotViewUrlRedirection(const QUrl& oldUrl, const QUrl& newUrl)
|
||||||
{
|
{
|
||||||
Q_UNUSED(oldUrl);
|
Q_UNUSED(oldUrl);
|
||||||
|
|
||||||
emit activeViewUrlChanged(newUrl);
|
emit activeViewUrlChanged(newUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
DolphinViewContainer* DolphinTabPage::createViewContainer(const KUrl& url) const
|
DolphinViewContainer* DolphinTabPage::createViewContainer(const QUrl& url) const
|
||||||
{
|
{
|
||||||
DolphinViewContainer* container = new DolphinViewContainer(url, m_splitter);
|
DolphinViewContainer* container = new DolphinViewContainer(url, m_splitter);
|
||||||
container->setActive(false);
|
container->setActive(false);
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <KUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
class QSplitter;
|
class QSplitter;
|
||||||
class DolphinViewContainer;
|
class DolphinViewContainer;
|
||||||
|
@ -33,7 +33,7 @@ class DolphinTabPage : public QWidget
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
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.
|
* @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
|
* gets selected if no loading of a directory has been triggered
|
||||||
* by DolphinView::setUrl() or DolphinView::reload().
|
* 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
|
* Marks the item indicated by \p url to be scrolled to and as the
|
||||||
* current item after directory DolphinView::url() has been loaded.
|
* 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.
|
* Sets the places selector visible, if \a visible is true.
|
||||||
|
@ -131,7 +131,7 @@ public:
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void activeViewChanged(DolphinViewContainer* viewContainer);
|
void activeViewChanged(DolphinViewContainer* viewContainer);
|
||||||
void activeViewUrlChanged(const KUrl& url);
|
void activeViewUrlChanged(const QUrl& url);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
/**
|
/**
|
||||||
|
@ -147,13 +147,13 @@ private slots:
|
||||||
*
|
*
|
||||||
* It emits the activeViewUrlChanged signal with the url \a newUrl.
|
* 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:
|
private:
|
||||||
/**
|
/**
|
||||||
* Creates a new view container and does the default initialization.
|
* Creates a new view container and does the default initialization.
|
||||||
*/
|
*/
|
||||||
DolphinViewContainer* createViewContainer(const KUrl& url) const;
|
DolphinViewContainer* createViewContainer(const QUrl& url) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSplitter* m_splitter;
|
QSplitter* m_splitter;
|
||||||
|
|
|
@ -23,11 +23,10 @@
|
||||||
#include "dolphintabpage.h"
|
#include "dolphintabpage.h"
|
||||||
#include "dolphinviewcontainer.h"
|
#include "dolphinviewcontainer.h"
|
||||||
#include "dolphin_generalsettings.h"
|
#include "dolphin_generalsettings.h"
|
||||||
#include "views/draganddrophelper.h"
|
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <KConfigGroup>
|
#include <KConfigGroup>
|
||||||
#include <KIcon>
|
#include <kio/global.h>
|
||||||
#include <KRun>
|
#include <KRun>
|
||||||
|
|
||||||
DolphinTabWidget::DolphinTabWidget(QWidget* parent) :
|
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);
|
openNewTab(primaryUrl, secondaryUrl);
|
||||||
setCurrentIndex(count() - 1);
|
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();
|
QWidget* focusWidget = QApplication::focusWidget();
|
||||||
|
|
||||||
|
@ -144,9 +143,9 @@ void DolphinTabWidget::openNewTab(const KUrl& primaryUrl, const KUrl& secondaryU
|
||||||
tabPage->setPlacesSelectorVisible(m_placesSelectorVisible);
|
tabPage->setPlacesSelectorVisible(m_placesSelectorVisible);
|
||||||
connect(tabPage, SIGNAL(activeViewChanged(DolphinViewContainer*)),
|
connect(tabPage, SIGNAL(activeViewChanged(DolphinViewContainer*)),
|
||||||
this, SIGNAL(activeViewChanged(DolphinViewContainer*)));
|
this, SIGNAL(activeViewChanged(DolphinViewContainer*)));
|
||||||
connect(tabPage, SIGNAL(activeViewUrlChanged(KUrl)),
|
connect(tabPage, SIGNAL(activeViewUrlChanged(QUrl)),
|
||||||
this, SLOT(tabUrlChanged(KUrl)));
|
this, SLOT(tabUrlChanged(QUrl)));
|
||||||
addTab(tabPage, KIcon(KMimeType::iconNameForUrl(primaryUrl)), tabName(primaryUrl));
|
addTab(tabPage, QIcon::fromTheme(KIO::iconNameForUrl(primaryUrl)), tabName(primaryUrl));
|
||||||
|
|
||||||
if (focusWidget) {
|
if (focusWidget) {
|
||||||
// The DolphinViewContainer grabbed the keyboard focus. As the tab is opened
|
// 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();
|
const bool hasSplitView = GeneralSettings::splitView();
|
||||||
|
|
||||||
// Open each directory inside a new tab. If the "split view" option has been enabled,
|
// Open each directory inside a new tab. If the "split view" option has been enabled,
|
||||||
// always show two directories within one tab.
|
// 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()) {
|
while (it != dirs.constEnd()) {
|
||||||
const KUrl& primaryUrl = *(it++);
|
const QUrl& primaryUrl = *(it++);
|
||||||
if (hasSplitView && (it != dirs.constEnd())) {
|
if (hasSplitView && (it != dirs.constEnd())) {
|
||||||
const KUrl& secondaryUrl = *(it++);
|
const QUrl& secondaryUrl = *(it++);
|
||||||
openNewTab(primaryUrl, secondaryUrl);
|
openNewTab(primaryUrl, secondaryUrl);
|
||||||
} else {
|
} else {
|
||||||
openNewTab(primaryUrl);
|
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()) {
|
if (files.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
|
@ -182,9 +181,9 @@ void DolphinTabWidget::openFiles(const QList<KUrl>& files)
|
||||||
// Get all distinct directories from 'files' and open a tab
|
// Get all distinct directories from 'files' and open a tab
|
||||||
// for each directory. If the "split view" option is enabled, two
|
// for each directory. If the "split view" option is enabled, two
|
||||||
// directories are shown inside one tab (see openDirectories()).
|
// directories are shown inside one tab (see openDirectories()).
|
||||||
QList<KUrl> dirs;
|
QList<QUrl> dirs;
|
||||||
foreach (const KUrl& url, files) {
|
foreach (const QUrl& url, files) {
|
||||||
const KUrl dir(url.directory());
|
const QUrl dir(url.adjusted(QUrl::RemoveFilename));
|
||||||
if (!dirs.contains(dir)) {
|
if (!dirs.contains(dir)) {
|
||||||
dirs.append(dir);
|
dirs.append(dir);
|
||||||
}
|
}
|
||||||
|
@ -286,22 +285,17 @@ void DolphinTabWidget::openNewActivatedTab(int index)
|
||||||
void DolphinTabWidget::tabDropEvent(int index, QDropEvent* event)
|
void DolphinTabWidget::tabDropEvent(int index, QDropEvent* event)
|
||||||
{
|
{
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
const DolphinView* view = tabPageAt(index)->activeViewContainer()->view();
|
DolphinView* view = tabPageAt(index)->activeViewContainer()->view();
|
||||||
|
view->dropUrls(view->url(), event);
|
||||||
QString error;
|
|
||||||
DragAndDropHelper::dropUrls(view->rootItem(), view->url(), event, error);
|
|
||||||
if (!error.isEmpty()) {
|
|
||||||
currentTabPage()->activeViewContainer()->showMessage(error, DolphinViewContainer::Error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinTabWidget::tabUrlChanged(const KUrl& url)
|
void DolphinTabWidget::tabUrlChanged(const QUrl& url)
|
||||||
{
|
{
|
||||||
const int index = indexOf(qobject_cast<QWidget*>(sender()));
|
const int index = indexOf(qobject_cast<QWidget*>(sender()));
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
tabBar()->setTabText(index, tabName(url));
|
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.
|
// Emit the currentUrlChanged signal if the url of the current tab has been changed.
|
||||||
if (index == currentIndex()) {
|
if (index == currentIndex()) {
|
||||||
|
@ -342,15 +336,15 @@ void DolphinTabWidget::tabRemoved(int index)
|
||||||
emit tabCountChanged(count());
|
emit tabCountChanged(count());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DolphinTabWidget::tabName(const KUrl& url) const
|
QString DolphinTabWidget::tabName(const QUrl& url) const
|
||||||
{
|
{
|
||||||
QString name;
|
QString name;
|
||||||
if (url.equals(KUrl("file:///"))) {
|
if (url == QUrl("file:///")) {
|
||||||
name = '/';
|
name = '/';
|
||||||
} else {
|
} else {
|
||||||
name = url.fileName();
|
name = url.adjusted(QUrl::StripTrailingSlash).fileName();
|
||||||
if (name.isEmpty()) {
|
if (name.isEmpty()) {
|
||||||
name = url.protocol();
|
name = url.scheme();
|
||||||
} else {
|
} else {
|
||||||
// Make sure that a '&' inside the directory name is displayed correctly
|
// Make sure that a '&' inside the directory name is displayed correctly
|
||||||
// and not misinterpreted as a keyboard shortcut in QTabBar::setTabText()
|
// and not misinterpreted as a keyboard shortcut in QTabBar::setTabText()
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#define DOLPHIN_TAB_WIDGET_H
|
#define DOLPHIN_TAB_WIDGET_H
|
||||||
|
|
||||||
#include <QTabWidget>
|
#include <QTabWidget>
|
||||||
#include <KUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
class DolphinViewContainer;
|
class DolphinViewContainer;
|
||||||
class DolphinTabPage;
|
class DolphinTabPage;
|
||||||
|
@ -70,13 +70,13 @@ signals:
|
||||||
/**
|
/**
|
||||||
* Is emitted when a tab has been closed.
|
* 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 emitted when the url of the current tab has been changed. This signal
|
||||||
* is also emitted when the active view has been changed.
|
* is also emitted when the active view has been changed.
|
||||||
*/
|
*/
|
||||||
void currentUrlChanged(const KUrl& url);
|
void currentUrlChanged(const QUrl& url);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
/**
|
/**
|
||||||
|
@ -89,26 +89,26 @@ public slots:
|
||||||
* Opens a new tab showing the URL \a primaryUrl and the optional URL
|
* Opens a new tab showing the URL \a primaryUrl and the optional URL
|
||||||
* \a secondaryUrl and activates the tab.
|
* \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
|
* Opens a new tab in the background showing the URL \a primaryUrl and the
|
||||||
* optional URL \a secondaryUrl.
|
* 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"
|
* Opens each directory in \p dirs in a separate tab. If the "split view"
|
||||||
* option is enabled, 2 directories are collected within one tab.
|
* 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
|
* Opens the directory which contains the files \p files
|
||||||
* and selects all files (implements the --select option
|
* and selects all files (implements the --select option
|
||||||
* of Dolphin).
|
* of Dolphin).
|
||||||
*/
|
*/
|
||||||
void openFiles(const QList<KUrl>& files);
|
void openFiles(const QList<QUrl> &files);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Closes the currently active tab.
|
* Closes the currently active tab.
|
||||||
|
@ -168,19 +168,19 @@ private slots:
|
||||||
* The active view url of a tab has been changed so update the text and the
|
* The active view url of a tab has been changed so update the text and the
|
||||||
* icon of the corresponding tab.
|
* icon of the corresponding tab.
|
||||||
*/
|
*/
|
||||||
void tabUrlChanged(const KUrl& url);
|
void tabUrlChanged(const QUrl& url);
|
||||||
|
|
||||||
void currentTabChanged(int index);
|
void currentTabChanged(int index);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void tabInserted(int index);
|
virtual void tabInserted(int index) Q_DECL_OVERRIDE;
|
||||||
virtual void tabRemoved(int index);
|
virtual void tabRemoved(int index) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* Returns the name of the tab for the URL \a url.
|
* Returns the name of the tab for the URL \a url.
|
||||||
*/
|
*/
|
||||||
QString tabName(const KUrl& url) const;
|
QString tabName(const QUrl& url) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** Caches the (negated) places panel visibility */
|
/** Caches the (negated) places panel visibility */
|
||||||
|
|
|
@ -20,44 +20,33 @@
|
||||||
#include "dolphinviewcontainer.h"
|
#include "dolphinviewcontainer.h"
|
||||||
#include <KProtocolManager>
|
#include <KProtocolManager>
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QDropEvent>
|
||||||
#include <QKeyEvent>
|
|
||||||
#include <QItemSelection>
|
|
||||||
#include <QBoxLayout>
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QScrollBar>
|
#include <QMimeData>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
#include <KDesktopFile>
|
|
||||||
#include <KFileItemDelegate>
|
|
||||||
#include <KFileItemActions>
|
#include <KFileItemActions>
|
||||||
#include <KFilePlacesModel>
|
#include <KFilePlacesModel>
|
||||||
#include <KLocale>
|
#include <KLocalizedString>
|
||||||
#include <KIconEffect>
|
|
||||||
#include <KIO/NetAccess>
|
|
||||||
#include <KIO/PreviewJob>
|
#include <KIO/PreviewJob>
|
||||||
#include <KMessageWidget>
|
#include <KMessageWidget>
|
||||||
#include <KNewFileMenu>
|
|
||||||
#include <konqmimedata.h>
|
|
||||||
#include <konq_operations.h>
|
|
||||||
#include <KShell>
|
#include <KShell>
|
||||||
#include <KUrl>
|
#include <QUrl>
|
||||||
#include <KUrlComboBox>
|
#include <KUrlComboBox>
|
||||||
#include <KUrlNavigator>
|
#include <KUrlNavigator>
|
||||||
#include <KRun>
|
#include <KRun>
|
||||||
|
|
||||||
#ifdef KActivities_FOUND
|
#ifdef KActivities_FOUND
|
||||||
#include <KActivities/ResourceInstance>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "dolphin_generalsettings.h"
|
#include "dolphin_generalsettings.h"
|
||||||
#include "filterbar/filterbar.h"
|
#include "filterbar/filterbar.h"
|
||||||
#include "search/dolphinsearchbox.h"
|
#include "search/dolphinsearchbox.h"
|
||||||
#include "statusbar/dolphinstatusbar.h"
|
#include "statusbar/dolphinstatusbar.h"
|
||||||
#include "views/draganddrophelper.h"
|
|
||||||
#include "views/viewmodecontroller.h"
|
#include "views/viewmodecontroller.h"
|
||||||
#include "views/viewproperties.h"
|
#include "views/viewproperties.h"
|
||||||
|
|
||||||
DolphinViewContainer::DolphinViewContainer(const KUrl& url, QWidget* parent) :
|
DolphinViewContainer::DolphinViewContainer(const QUrl& url, QWidget* parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
m_topLayout(0),
|
m_topLayout(0),
|
||||||
m_urlNavigator(0),
|
m_urlNavigator(0),
|
||||||
|
@ -68,9 +57,7 @@ DolphinViewContainer::DolphinViewContainer(const KUrl& url, QWidget* parent) :
|
||||||
m_statusBar(0),
|
m_statusBar(0),
|
||||||
m_statusBarTimer(0),
|
m_statusBarTimer(0),
|
||||||
m_statusBarTimestamp(),
|
m_statusBarTimestamp(),
|
||||||
m_autoGrabFocus(true),
|
m_autoGrabFocus(true)
|
||||||
m_dropDestination(),
|
|
||||||
m_dropEvent(0)
|
|
||||||
#ifdef KActivities_FOUND
|
#ifdef KActivities_FOUND
|
||||||
, m_activityResourceInstance(0)
|
, m_activityResourceInstance(0)
|
||||||
#endif
|
#endif
|
||||||
|
@ -82,92 +69,117 @@ DolphinViewContainer::DolphinViewContainer(const KUrl& url, QWidget* parent) :
|
||||||
m_topLayout->setMargin(0);
|
m_topLayout->setMargin(0);
|
||||||
|
|
||||||
m_urlNavigator = new KUrlNavigator(new KFilePlacesModel(this), url, this);
|
m_urlNavigator = new KUrlNavigator(new KFilePlacesModel(this), url, this);
|
||||||
connect(m_urlNavigator, SIGNAL(urlsDropped(KUrl,QDropEvent*)),
|
connect(m_urlNavigator, &KUrlNavigator::activated,
|
||||||
this, SLOT(dropUrls(KUrl,QDropEvent*)));
|
this, &DolphinViewContainer::activate);
|
||||||
connect(m_urlNavigator, SIGNAL(activated()),
|
connect(m_urlNavigator->editor(), &KUrlComboBox::completionModeChanged,
|
||||||
this, SLOT(activate()));
|
this, &DolphinViewContainer::saveUrlCompletionMode);
|
||||||
connect(m_urlNavigator->editor(), SIGNAL(completionModeChanged(KGlobalSettings::Completion)),
|
|
||||||
this, SLOT(saveUrlCompletionMode(KGlobalSettings::Completion)));
|
|
||||||
|
|
||||||
const GeneralSettings* settings = GeneralSettings::self();
|
const GeneralSettings* settings = GeneralSettings::self();
|
||||||
m_urlNavigator->setUrlEditable(settings->editableUrl());
|
m_urlNavigator->setUrlEditable(settings->editableUrl());
|
||||||
m_urlNavigator->setShowFullPath(settings->showFullPath());
|
m_urlNavigator->setShowFullPath(settings->showFullPath());
|
||||||
m_urlNavigator->setHomeUrl(KUrl(settings->homeUrl()));
|
m_urlNavigator->setHomeUrl(QUrl::fromLocalFile(settings->homeUrl()));
|
||||||
KUrlComboBox* editor = m_urlNavigator->editor();
|
KUrlComboBox* editor = m_urlNavigator->editor();
|
||||||
editor->setCompletionMode(KGlobalSettings::Completion(settings->urlCompletionMode()));
|
editor->setCompletionMode(KCompletion::CompletionMode(settings->urlCompletionMode()));
|
||||||
|
|
||||||
m_searchBox = new DolphinSearchBox(this);
|
m_searchBox = new DolphinSearchBox(this);
|
||||||
m_searchBox->hide();
|
m_searchBox->hide();
|
||||||
connect(m_searchBox, SIGNAL(activated()), this, SLOT(activate()));
|
connect(m_searchBox, &DolphinSearchBox::activated, this, &DolphinViewContainer::activate);
|
||||||
connect(m_searchBox, SIGNAL(closeRequest()), this, SLOT(closeSearchBox()));
|
connect(m_searchBox, &DolphinSearchBox::closeRequest, this, &DolphinViewContainer::closeSearchBox);
|
||||||
connect(m_searchBox, SIGNAL(searchRequest()), this, SLOT(startSearching()));
|
connect(m_searchBox, &DolphinSearchBox::searchRequest, this, &DolphinViewContainer::startSearching);
|
||||||
connect(m_searchBox, SIGNAL(returnPressed(QString)), this, SLOT(requestFocus()));
|
connect(m_searchBox, &DolphinSearchBox::returnPressed, this, &DolphinViewContainer::requestFocus);
|
||||||
|
|
||||||
m_messageWidget = new KMessageWidget(this);
|
m_messageWidget = new KMessageWidget(this);
|
||||||
m_messageWidget->setCloseButtonVisible(true);
|
m_messageWidget->setCloseButtonVisible(true);
|
||||||
m_messageWidget->hide();
|
m_messageWidget->hide();
|
||||||
|
|
||||||
m_view = new DolphinView(url, this);
|
m_view = new DolphinView(url, this);
|
||||||
connect(m_view, SIGNAL(urlChanged(KUrl)), m_urlNavigator, SLOT(setUrl(KUrl)));
|
connect(m_view, &DolphinView::urlChanged,
|
||||||
connect(m_view, SIGNAL(urlChanged(KUrl)), m_messageWidget, SLOT(hide()));
|
m_urlNavigator, &KUrlNavigator::setUrl);
|
||||||
connect(m_view, SIGNAL(directoryLoadingCompleted()), m_messageWidget, SLOT(hide()));
|
connect(m_view, &DolphinView::urlChanged,
|
||||||
connect(m_view, SIGNAL(writeStateChanged(bool)), this, SIGNAL(writeStateChanged(bool)));
|
m_messageWidget, &KMessageWidget::hide);
|
||||||
connect(m_view, SIGNAL(requestItemInfo(KFileItem)), this, SLOT(showItemInfo(KFileItem)));
|
connect(m_view, &DolphinView::directoryLoadingCompleted,
|
||||||
connect(m_view, SIGNAL(itemActivated(KFileItem)), this, SLOT(slotItemActivated(KFileItem)));
|
m_messageWidget, &KMessageWidget::hide);
|
||||||
connect(m_view, SIGNAL(itemsActivated(KFileItemList)), this, SLOT(slotItemsActivated(KFileItemList)));
|
connect(m_view, &DolphinView::writeStateChanged,
|
||||||
connect(m_view, SIGNAL(redirection(KUrl,KUrl)), this, SLOT(redirect(KUrl,KUrl)));
|
this, &DolphinViewContainer::writeStateChanged);
|
||||||
connect(m_view, SIGNAL(directoryLoadingStarted()), this, SLOT(slotDirectoryLoadingStarted()));
|
connect(m_view, &DolphinView::requestItemInfo,
|
||||||
connect(m_view, SIGNAL(directoryLoadingCompleted()), this, SLOT(slotDirectoryLoadingCompleted()));
|
this, &DolphinViewContainer::showItemInfo);
|
||||||
connect(m_view, SIGNAL(directoryLoadingCanceled()), this, SLOT(slotDirectoryLoadingCanceled()));
|
connect(m_view, &DolphinView::itemActivated,
|
||||||
connect(m_view, SIGNAL(itemCountChanged()), this, SLOT(delayedStatusBarUpdate()));
|
this, &DolphinViewContainer::slotItemActivated);
|
||||||
connect(m_view, SIGNAL(directoryLoadingProgress(int)), this, SLOT(updateDirectoryLoadingProgress(int)));
|
connect(m_view, &DolphinView::itemsActivated,
|
||||||
connect(m_view, SIGNAL(directorySortingProgress(int)), this, SLOT(updateDirectorySortingProgress(int)));
|
this, &DolphinViewContainer::slotItemsActivated);
|
||||||
connect(m_view, SIGNAL(selectionChanged(KFileItemList)), this, SLOT(delayedStatusBarUpdate()));
|
connect(m_view, &DolphinView::redirection,
|
||||||
connect(m_view, SIGNAL(urlAboutToBeChanged(KUrl)), this, SLOT(slotViewUrlAboutToBeChanged(KUrl)));
|
this, &DolphinViewContainer::redirect);
|
||||||
connect(m_view, SIGNAL(errorMessage(QString)), this, SLOT(showErrorMessage(QString)));
|
connect(m_view, &DolphinView::directoryLoadingStarted,
|
||||||
connect(m_view, SIGNAL(urlIsFileError(KUrl)), this, SLOT(slotUrlIsFileError(KUrl)));
|
this, &DolphinViewContainer::slotDirectoryLoadingStarted);
|
||||||
connect(m_view, SIGNAL(activated()), this, SLOT(activate()));
|
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)),
|
connect(m_urlNavigator, &KUrlNavigator::urlAboutToBeChanged,
|
||||||
this, SLOT(slotUrlNavigatorLocationAboutToBeChanged(KUrl)));
|
this, &DolphinViewContainer::slotUrlNavigatorLocationAboutToBeChanged);
|
||||||
connect(m_urlNavigator, SIGNAL(urlChanged(KUrl)),
|
connect(m_urlNavigator, &KUrlNavigator::urlChanged,
|
||||||
this, SLOT(slotUrlNavigatorLocationChanged(KUrl)));
|
this, &DolphinViewContainer::slotUrlNavigatorLocationChanged);
|
||||||
connect(m_urlNavigator, SIGNAL(historyChanged()),
|
connect(m_urlNavigator, &KUrlNavigator::historyChanged,
|
||||||
this, SLOT(slotHistoryChanged()));
|
this, &DolphinViewContainer::slotHistoryChanged);
|
||||||
connect(m_urlNavigator, SIGNAL(returnPressed()),
|
connect(m_urlNavigator, &KUrlNavigator::returnPressed,
|
||||||
this, SLOT(slotReturnPressed()));
|
this, &DolphinViewContainer::slotReturnPressed);
|
||||||
|
connect(m_urlNavigator, &KUrlNavigator::urlsDropped,
|
||||||
|
m_view, &DolphinView::dropUrls);
|
||||||
|
|
||||||
// Initialize status bar
|
// Initialize status bar
|
||||||
m_statusBar = new DolphinStatusBar(this);
|
m_statusBar = new DolphinStatusBar(this);
|
||||||
m_statusBar->setUrl(m_view->url());
|
m_statusBar->setUrl(m_view->url());
|
||||||
m_statusBar->setZoomLevel(m_view->zoomLevel());
|
m_statusBar->setZoomLevel(m_view->zoomLevel());
|
||||||
connect(m_view, SIGNAL(urlChanged(KUrl)), m_statusBar, SLOT(setUrl(KUrl)));
|
connect(m_view, &DolphinView::urlChanged,
|
||||||
connect(m_view, SIGNAL(zoomLevelChanged(int,int)), m_statusBar, SLOT(setZoomLevel(int)));
|
m_statusBar, &DolphinStatusBar::setUrl);
|
||||||
connect(m_view, SIGNAL(infoMessage(QString)), m_statusBar, SLOT(setText(QString)));
|
connect(m_view, &DolphinView::zoomLevelChanged,
|
||||||
connect(m_view, SIGNAL(operationCompletedMessage(QString)), m_statusBar, SLOT(setText(QString)));
|
m_statusBar, &DolphinStatusBar::setZoomLevel);
|
||||||
connect(m_statusBar, SIGNAL(stopPressed()), this, SLOT(stopDirectoryLoading()));
|
connect(m_view, &DolphinView::infoMessage,
|
||||||
connect(m_statusBar, SIGNAL(zoomLevelChanged(int)), this, SLOT(slotStatusBarZoomLevelChanged(int)));
|
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 = new QTimer(this);
|
||||||
m_statusBarTimer->setSingleShot(true);
|
m_statusBarTimer->setSingleShot(true);
|
||||||
m_statusBarTimer->setInterval(300);
|
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();
|
KIO::FileUndoManager* undoManager = KIO::FileUndoManager::self();
|
||||||
connect(undoManager, SIGNAL(jobRecordingFinished(CommandType)),
|
connect(undoManager, &KIO::FileUndoManager::jobRecordingFinished,
|
||||||
this, SLOT(delayedStatusBarUpdate()));
|
this, &DolphinViewContainer::delayedStatusBarUpdate);
|
||||||
|
|
||||||
// Initialize filter bar
|
// Initialize filter bar
|
||||||
m_filterBar = new FilterBar(this);
|
m_filterBar = new FilterBar(this);
|
||||||
m_filterBar->setVisible(settings->filterBar());
|
m_filterBar->setVisible(settings->filterBar());
|
||||||
connect(m_filterBar, SIGNAL(filterChanged(QString)),
|
connect(m_filterBar, &FilterBar::filterChanged,
|
||||||
this, SLOT(setNameFilter(QString)));
|
this, &DolphinViewContainer::setNameFilter);
|
||||||
connect(m_filterBar, SIGNAL(closeRequest()),
|
connect(m_filterBar, &FilterBar::closeRequest,
|
||||||
this, SLOT(closeFilterBar()));
|
this, &DolphinViewContainer::closeFilterBar);
|
||||||
connect(m_filterBar, SIGNAL(focusViewRequest()),
|
connect(m_filterBar, &FilterBar::focusViewRequest,
|
||||||
this, SLOT(requestFocus()));
|
this, &DolphinViewContainer::requestFocus);
|
||||||
connect(m_view, SIGNAL(urlChanged(KUrl)),
|
connect(m_view, &DolphinView::urlChanged,
|
||||||
m_filterBar, SLOT(slotUrlChanged()));
|
m_filterBar, &FilterBar::slotUrlChanged);
|
||||||
|
|
||||||
m_topLayout->addWidget(m_urlNavigator);
|
m_topLayout->addWidget(m_urlNavigator);
|
||||||
m_topLayout->addWidget(m_searchBox);
|
m_topLayout->addWidget(m_searchBox);
|
||||||
|
@ -191,7 +203,7 @@ DolphinViewContainer::~DolphinViewContainer()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
KUrl DolphinViewContainer::url() const
|
QUrl DolphinViewContainer::url() const
|
||||||
{
|
{
|
||||||
return m_view->url();
|
return m_view->url();
|
||||||
}
|
}
|
||||||
|
@ -292,7 +304,7 @@ void DolphinViewContainer::readSettings()
|
||||||
// settings of the URL navigator and the filterbar.
|
// settings of the URL navigator and the filterbar.
|
||||||
m_urlNavigator->setUrlEditable(GeneralSettings::editableUrl());
|
m_urlNavigator->setUrlEditable(GeneralSettings::editableUrl());
|
||||||
m_urlNavigator->setShowFullPath(GeneralSettings::showFullPath());
|
m_urlNavigator->setShowFullPath(GeneralSettings::showFullPath());
|
||||||
m_urlNavigator->setHomeUrl(KUrl(GeneralSettings::homeUrl()));
|
m_urlNavigator->setHomeUrl(QUrl::fromLocalFile(GeneralSettings::homeUrl()));
|
||||||
setFilterBarVisible(GeneralSettings::filterBar());
|
setFilterBarVisible(GeneralSettings::filterBar());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,16 +331,16 @@ void DolphinViewContainer::setSearchModeEnabled(bool enabled)
|
||||||
m_urlNavigator->setVisible(!enabled);
|
m_urlNavigator->setVisible(!enabled);
|
||||||
|
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
const KUrl& locationUrl = m_urlNavigator->locationUrl();
|
const QUrl& locationUrl = m_urlNavigator->locationUrl();
|
||||||
m_searchBox->fromSearchUrl(locationUrl);
|
m_searchBox->fromSearchUrl(locationUrl);
|
||||||
} else {
|
} else {
|
||||||
m_view->setViewPropertiesContext(QString());
|
m_view->setViewPropertiesContext(QString());
|
||||||
|
|
||||||
// Restore the URL for the URL navigator. If Dolphin has been
|
// Restore the URL for the URL navigator. If Dolphin has been
|
||||||
// started with a search-URL, the home URL is used as fallback.
|
// 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)) {
|
if (url.isEmpty() || !url.isValid() || isSearchUrl(url)) {
|
||||||
url = GeneralSettings::self()->homeUrl();
|
url = QUrl::fromLocalFile(GeneralSettings::self()->homeUrl());
|
||||||
}
|
}
|
||||||
m_urlNavigator->setLocationUrl(url);
|
m_urlNavigator->setLocationUrl(url);
|
||||||
}
|
}
|
||||||
|
@ -355,7 +367,7 @@ QString DolphinViewContainer::placesText() const
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinViewContainer::setUrl(const KUrl& newUrl)
|
void DolphinViewContainer::setUrl(const QUrl& newUrl)
|
||||||
{
|
{
|
||||||
if (newUrl != m_urlNavigator->locationUrl()) {
|
if (newUrl != m_urlNavigator->locationUrl()) {
|
||||||
m_urlNavigator->setLocationUrl(newUrl);
|
m_urlNavigator->setLocationUrl(newUrl);
|
||||||
|
@ -460,14 +472,14 @@ void DolphinViewContainer::slotDirectoryLoadingCanceled()
|
||||||
m_statusBar->setText(QString());
|
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
|
// 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.
|
// case if the file is an archive). The mime type must be known for that.
|
||||||
item.determineMimeType();
|
item.determineMimeType();
|
||||||
const KUrl& folderUrl = DolphinView::openItemAsFolderUrl(item, true);
|
const QUrl& folderUrl = DolphinView::openItemAsFolderUrl(item, true);
|
||||||
if (!folderUrl.isEmpty()) {
|
if (!folderUrl.isEmpty()) {
|
||||||
m_view->setUrl(folderUrl);
|
m_view->setUrl(folderUrl);
|
||||||
} else {
|
} else {
|
||||||
|
@ -482,13 +494,14 @@ void DolphinViewContainer::slotItemActivated(const KFileItem& item)
|
||||||
// results in an active view.
|
// results in an active view.
|
||||||
m_view->setActive(true);
|
m_view->setActive(true);
|
||||||
|
|
||||||
const KUrl& url = DolphinView::openItemAsFolderUrl(item, GeneralSettings::browseThroughArchives());
|
const QUrl& url = DolphinView::openItemAsFolderUrl(item, GeneralSettings::browseThroughArchives());
|
||||||
if (!url.isEmpty()) {
|
if (!url.isEmpty()) {
|
||||||
m_view->setUrl(url);
|
m_view->setUrl(url);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
item.run();
|
KRun *run = new KRun(item.targetUrl(), this);
|
||||||
|
run->setShowScriptExecutionPrompt(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinViewContainer::slotItemsActivated(const KFileItemList& items)
|
void DolphinViewContainer::slotItemsActivated(const KFileItemList& items)
|
||||||
|
@ -526,7 +539,7 @@ void DolphinViewContainer::activate()
|
||||||
setActive(true);
|
setActive(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinViewContainer::slotViewUrlAboutToBeChanged(const KUrl& url)
|
void DolphinViewContainer::slotViewUrlAboutToBeChanged(const QUrl& url)
|
||||||
{
|
{
|
||||||
// URL changes of the view can happen in two ways:
|
// 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
|
// 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:
|
// 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
|
// 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();
|
slotReturnPressed();
|
||||||
|
|
||||||
|
@ -566,7 +579,7 @@ void DolphinViewContainer::slotUrlNavigatorLocationChanged(const KUrl& url)
|
||||||
}
|
}
|
||||||
} else if (KProtocolManager::isSourceProtocol(url)) {
|
} else if (KProtocolManager::isSourceProtocol(url)) {
|
||||||
QString app = "konqueror";
|
QString app = "konqueror";
|
||||||
if (url.protocol().startsWith(QLatin1String("http"))) {
|
if (url.scheme().startsWith(QLatin1String("http"))) {
|
||||||
showMessage(i18nc("@info:status", // krazy:exclude=qmethods
|
showMessage(i18nc("@info:status", // krazy:exclude=qmethods
|
||||||
"Dolphin does not support web pages, the web browser has been launched"),
|
"Dolphin does not support web pages, the web browser has been launched"),
|
||||||
Information);
|
Information);
|
||||||
|
@ -586,7 +599,7 @@ void DolphinViewContainer::slotUrlNavigatorLocationChanged(const KUrl& url)
|
||||||
Information);
|
Information);
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString secureUrl = KShell::quoteArg(url.pathOrUrl());
|
const QString secureUrl = KShell::quoteArg(url.toDisplayString(QUrl::PreferLocalFile));
|
||||||
const QString command = app + ' ' + secureUrl;
|
const QString command = app + ' ' + secureUrl;
|
||||||
KRun::runCommand(command, app, app, this);
|
KRun::runCommand(command, app, app, this);
|
||||||
} else {
|
} else {
|
||||||
|
@ -594,42 +607,7 @@ void DolphinViewContainer::slotUrlNavigatorLocationChanged(const KUrl& url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinViewContainer::dropUrls(const KUrl& destination, QDropEvent* event)
|
void DolphinViewContainer::redirect(const QUrl& oldUrl, const QUrl& newUrl)
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
Q_UNUSED(oldUrl);
|
Q_UNUSED(oldUrl);
|
||||||
const bool block = m_urlNavigator->signalsBlocked();
|
const bool block = m_urlNavigator->signalsBlocked();
|
||||||
|
@ -650,7 +628,7 @@ void DolphinViewContainer::requestFocus()
|
||||||
m_view->setFocus();
|
m_view->setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinViewContainer::saveUrlCompletionMode(KGlobalSettings::Completion completion)
|
void DolphinViewContainer::saveUrlCompletionMode(KCompletion::CompletionMode completion)
|
||||||
{
|
{
|
||||||
GeneralSettings::setUrlCompletionMode(completion);
|
GeneralSettings::setUrlCompletionMode(completion);
|
||||||
}
|
}
|
||||||
|
@ -673,7 +651,7 @@ void DolphinViewContainer::slotReturnPressed()
|
||||||
|
|
||||||
void DolphinViewContainer::startSearching()
|
void DolphinViewContainer::startSearching()
|
||||||
{
|
{
|
||||||
const KUrl url = m_searchBox->urlForSearching();
|
const QUrl url = m_searchBox->urlForSearching();
|
||||||
if (url.isValid() && !url.isEmpty()) {
|
if (url.isValid() && !url.isEmpty()) {
|
||||||
m_view->setViewPropertiesContext("search");
|
m_view->setViewPropertiesContext("search");
|
||||||
m_urlNavigator->setLocationUrl(url);
|
m_urlNavigator->setLocationUrl(url);
|
||||||
|
@ -701,10 +679,9 @@ void DolphinViewContainer::showErrorMessage(const QString& msg)
|
||||||
showMessage(msg, Error);
|
showMessage(msg, Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DolphinViewContainer::isSearchUrl(const KUrl& url) const
|
bool DolphinViewContainer::isSearchUrl(const QUrl& url) const
|
||||||
{
|
{
|
||||||
const QString protocol = url.protocol();
|
return url.scheme().contains("search");
|
||||||
return protocol.contains("search");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinViewContainer::saveViewState()
|
void DolphinViewContainer::saveViewState()
|
||||||
|
@ -714,5 +691,3 @@ void DolphinViewContainer::saveViewState()
|
||||||
m_view->saveState(stream);
|
m_view->saveState(stream);
|
||||||
m_urlNavigator->saveLocationState(locationState);
|
m_urlNavigator->saveLocationState(locationState);
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "dolphinviewcontainer.moc"
|
|
||||||
|
|
|
@ -21,8 +21,7 @@
|
||||||
#define DOLPHINVIEWCONTAINER_H
|
#define DOLPHINVIEWCONTAINER_H
|
||||||
|
|
||||||
#include <KFileItem>
|
#include <KFileItem>
|
||||||
#include <KFileItemDelegate>
|
#include <KCompletion>
|
||||||
#include <KGlobalSettings>
|
|
||||||
#include <KIO/Job>
|
#include <KIO/Job>
|
||||||
|
|
||||||
#include <KUrlNavigator>
|
#include <KUrlNavigator>
|
||||||
|
@ -31,9 +30,9 @@
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
#include <views/dolphinview.h>
|
#include <views/dolphinview.h>
|
||||||
#include <config-apps.h>
|
#include <config-dolphin.h>
|
||||||
|
|
||||||
#ifdef KActivities_FOUND
|
#ifdef KF5Activities_FOUND
|
||||||
namespace KActivities {
|
namespace KActivities {
|
||||||
class ResourceInstance;
|
class ResourceInstance;
|
||||||
}
|
}
|
||||||
|
@ -41,7 +40,7 @@ namespace KActivities {
|
||||||
|
|
||||||
class FilterBar;
|
class FilterBar;
|
||||||
class KMessageWidget;
|
class KMessageWidget;
|
||||||
class KUrl;
|
class QUrl;
|
||||||
class KUrlNavigator;
|
class KUrlNavigator;
|
||||||
class DolphinSearchBox;
|
class DolphinSearchBox;
|
||||||
class DolphinStatusBar;
|
class DolphinStatusBar;
|
||||||
|
@ -70,14 +69,14 @@ public:
|
||||||
Error
|
Error
|
||||||
};
|
};
|
||||||
|
|
||||||
DolphinViewContainer(const KUrl& url, QWidget* parent);
|
DolphinViewContainer(const QUrl& url, QWidget* parent);
|
||||||
virtual ~DolphinViewContainer();
|
virtual ~DolphinViewContainer();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current active URL, where all actions are applied.
|
* Returns the current active URL, where all actions are applied.
|
||||||
* The URL navigator is synchronized with this URL.
|
* 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
|
* If \a active is true, the view container will marked as active. The active
|
||||||
|
@ -138,7 +137,7 @@ public slots:
|
||||||
* are emitted.
|
* are emitted.
|
||||||
* @see DolphinViewContainer::urlNavigator()
|
* @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.
|
* 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
|
* Is called if the URL set by DolphinView::setUrl() represents
|
||||||
* a file and not a directory. Takes care to activate the file.
|
* 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
|
* 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 invoked if the signal urlAboutToBeChanged() from the DolphinView
|
||||||
* is emitted. Tries to save the view-state.
|
* 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 invoked if the signal urlAboutToBeChanged() from the URL navigator
|
||||||
* is emitted. Tries to save the view-state.
|
* 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
|
* Restores the current view to show \a url and assures
|
||||||
* that the root URL of the view is respected.
|
* that the root URL of the view is respected.
|
||||||
*/
|
*/
|
||||||
void slotUrlNavigatorLocationChanged(const KUrl& url);
|
void slotUrlNavigatorLocationChanged(const QUrl& 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();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is invoked when a redirection is done and changes the
|
* Is invoked when a redirection is done and changes the
|
||||||
* URL of the URL navigator to \a newUrl without triggering
|
* URL of the URL navigator to \a newUrl without triggering
|
||||||
* a reloading of the directory.
|
* 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. */
|
/** Requests the focus for the view \a m_view. */
|
||||||
void requestFocus();
|
void requestFocus();
|
||||||
|
@ -290,7 +271,7 @@ private slots:
|
||||||
* Saves the currently used URL completion mode of
|
* Saves the currently used URL completion mode of
|
||||||
* the URL navigator.
|
* the URL navigator.
|
||||||
*/
|
*/
|
||||||
void saveUrlCompletionMode(KGlobalSettings::Completion completion);
|
void saveUrlCompletionMode(KCompletion::CompletionMode completion);
|
||||||
|
|
||||||
void slotHistoryChanged();
|
void slotHistoryChanged();
|
||||||
|
|
||||||
|
@ -319,7 +300,7 @@ private:
|
||||||
/**
|
/**
|
||||||
* @return True if the URL protocol is a search URL (e. g. baloosearch:// or filenamesearch://).
|
* @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,
|
* Saves the state of the current view: contents position,
|
||||||
|
@ -342,10 +323,7 @@ private:
|
||||||
QElapsedTimer m_statusBarTimestamp; // Time in ms since last update
|
QElapsedTimer m_statusBarTimestamp; // Time in ms since last update
|
||||||
bool m_autoGrabFocus;
|
bool m_autoGrabFocus;
|
||||||
|
|
||||||
KUrl m_dropDestination;
|
#ifdef KF5Activities_FOUND
|
||||||
QScopedPointer<QDropEvent> m_dropEvent;
|
|
||||||
|
|
||||||
#ifdef KActivities_FOUND
|
|
||||||
private:
|
private:
|
||||||
KActivities::ResourceInstance * m_activityResourceInstance;
|
KActivities::ResourceInstance * m_activityResourceInstance;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -20,15 +20,14 @@
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#include "filterbar.h"
|
#include "filterbar.h"
|
||||||
|
|
||||||
#include <QBoxLayout>
|
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
|
||||||
#include <KIcon>
|
#include <QIcon>
|
||||||
#include <KLocale>
|
#include <KLocalizedString>
|
||||||
#include <KLineEdit>
|
#include <QLineEdit>
|
||||||
#include <KIconLoader>
|
|
||||||
|
|
||||||
FilterBar::FilterBar(QWidget* parent) :
|
FilterBar::FilterBar(QWidget* parent) :
|
||||||
QWidget(parent)
|
QWidget(parent)
|
||||||
|
@ -36,27 +35,27 @@ FilterBar::FilterBar(QWidget* parent) :
|
||||||
// Create close button
|
// Create close button
|
||||||
QToolButton *closeButton = new QToolButton(this);
|
QToolButton *closeButton = new QToolButton(this);
|
||||||
closeButton->setAutoRaise(true);
|
closeButton->setAutoRaise(true);
|
||||||
closeButton->setIcon(KIcon("dialog-close"));
|
closeButton->setIcon(QIcon::fromTheme("dialog-close"));
|
||||||
closeButton->setToolTip(i18nc("@info:tooltip", "Hide Filter Bar"));
|
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
|
// Create button to lock text when changing folders
|
||||||
m_lockButton = new QToolButton(this);
|
m_lockButton = new QToolButton(this);
|
||||||
m_lockButton->setAutoRaise(true);
|
m_lockButton->setAutoRaise(true);
|
||||||
m_lockButton->setCheckable(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"));
|
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
|
// Create label
|
||||||
QLabel* filterLabel = new QLabel(i18nc("@label:textbox", "Filter:"), this);
|
QLabel* filterLabel = new QLabel(i18nc("@label:textbox", "Filter:"), this);
|
||||||
|
|
||||||
// Create filter editor
|
// Create filter editor
|
||||||
m_filterInput = new KLineEdit(this);
|
m_filterInput = new QLineEdit(this);
|
||||||
m_filterInput->setLayoutDirection(Qt::LeftToRight);
|
m_filterInput->setLayoutDirection(Qt::LeftToRight);
|
||||||
m_filterInput->setClearButtonShown(true);
|
m_filterInput->setClearButtonEnabled(true);
|
||||||
connect(m_filterInput, SIGNAL(textChanged(QString)),
|
connect(m_filterInput, &QLineEdit::textChanged,
|
||||||
this, SIGNAL(filterChanged(QString)));
|
this, &FilterBar::filterChanged);
|
||||||
setFocusProxy(m_filterInput);
|
setFocusProxy(m_filterInput);
|
||||||
|
|
||||||
// Apply layout
|
// Apply layout
|
||||||
|
@ -103,9 +102,9 @@ void FilterBar::slotUrlChanged()
|
||||||
void FilterBar::slotToggleLockButton(bool checked)
|
void FilterBar::slotToggleLockButton(bool checked)
|
||||||
{
|
{
|
||||||
if (checked) {
|
if (checked) {
|
||||||
m_lockButton->setIcon(KIcon("object-locked"));
|
m_lockButton->setIcon(QIcon::fromTheme("object-locked"));
|
||||||
} else {
|
} else {
|
||||||
m_lockButton->setIcon(KIcon("object-unlocked"));
|
m_lockButton->setIcon(QIcon::fromTheme("object-unlocked"));
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,4 +139,3 @@ void FilterBar::keyReleaseEvent(QKeyEvent* event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "filterbar.moc"
|
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
class KLineEdit;
|
class QLineEdit;
|
||||||
class QToolButton;
|
class QToolButton;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -74,11 +74,11 @@ signals:
|
||||||
void focusViewRequest();
|
void focusViewRequest();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void showEvent(QShowEvent* event);
|
virtual void showEvent(QShowEvent* event) Q_DECL_OVERRIDE;
|
||||||
virtual void keyReleaseEvent(QKeyEvent* event);
|
virtual void keyReleaseEvent(QKeyEvent* event) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
KLineEdit* m_filterInput;
|
QLineEdit* m_filterInput;
|
||||||
QToolButton* m_lockButton;
|
QToolButton* m_lockButton;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -22,16 +22,12 @@
|
||||||
#include "kfileitemmodelrolesupdater.h"
|
#include "kfileitemmodelrolesupdater.h"
|
||||||
#include "kfileitemlistwidget.h"
|
#include "kfileitemlistwidget.h"
|
||||||
#include "kfileitemmodel.h"
|
#include "kfileitemmodel.h"
|
||||||
#include <KLocale>
|
|
||||||
#include <KStringHandler>
|
|
||||||
#include "private/kpixmapmodifier.h"
|
#include "private/kpixmapmodifier.h"
|
||||||
|
|
||||||
#include <KDebug>
|
#include <QIcon>
|
||||||
#include <KIcon>
|
#include <KIconLoader>
|
||||||
#include <KTextEdit>
|
|
||||||
|
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QTextLine>
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
// #define KFILEITEMLISTVIEW_DEBUG
|
// #define KFILEITEMLISTVIEW_DEBUG
|
||||||
|
@ -62,14 +58,14 @@ KFileItemListView::KFileItemListView(QGraphicsWidget* parent) :
|
||||||
m_updateVisibleIndexRangeTimer = new QTimer(this);
|
m_updateVisibleIndexRangeTimer = new QTimer(this);
|
||||||
m_updateVisibleIndexRangeTimer->setSingleShot(true);
|
m_updateVisibleIndexRangeTimer->setSingleShot(true);
|
||||||
m_updateVisibleIndexRangeTimer->setInterval(ShortInterval);
|
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 = new QTimer(this);
|
||||||
m_updateIconSizeTimer->setSingleShot(true);
|
m_updateIconSizeTimer->setSingleShot(true);
|
||||||
m_updateIconSizeTimer->setInterval(LongInterval);
|
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()
|
KFileItemListView::~KFileItemListView()
|
||||||
|
@ -169,7 +165,7 @@ QPixmap KFileItemListView::createDragPixmap(const KItemSet& indexes) const
|
||||||
foreach (int index, indexes) {
|
foreach (int index, indexes) {
|
||||||
QPixmap pixmap = model()->data(index).value("iconPixmap").value<QPixmap>();
|
QPixmap pixmap = model()->data(index).value("iconPixmap").value<QPixmap>();
|
||||||
if (pixmap.isNull()) {
|
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);
|
pixmap = icon.pixmap(size, size);
|
||||||
} else {
|
} else {
|
||||||
KPixmapModifier::scale(pixmap, QSize(size, size));
|
KPixmapModifier::scale(pixmap, QSize(size, size));
|
||||||
|
@ -208,7 +204,7 @@ void KFileItemListView::initializeItemListWidget(KItemListWidget* item)
|
||||||
|
|
||||||
const KFileItem fileItem = fileItemModel->fileItem(item->index());
|
const KFileItem fileItem = fileItemModel->fileItem(item->index());
|
||||||
data.insert("iconName", fileItem.iconName());
|
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);
|
return QSize(iconSize, iconSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "kfileitemlistview.moc"
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#ifndef KFILEITEMLISTVIEW_H
|
#ifndef KFILEITEMLISTVIEW_H
|
||||||
#define KFILEITEMLISTVIEW_H
|
#define KFILEITEMLISTVIEW_H
|
||||||
|
|
||||||
#include <libdolphin_export.h>
|
#include "dolphin_export.h"
|
||||||
|
|
||||||
#include <kitemviews/kstandarditemlistview.h>
|
#include <kitemviews/kstandarditemlistview.h>
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ class QTimer;
|
||||||
* KItemListView::setWidgetCreator() and KItemListView::setGroupHeaderCreator()
|
* KItemListView::setWidgetCreator() and KItemListView::setGroupHeaderCreator()
|
||||||
* to apply customized generators.
|
* to apply customized generators.
|
||||||
*/
|
*/
|
||||||
class LIBDOLPHINPRIVATE_EXPORT KFileItemListView : public KStandardItemListView
|
class DOLPHIN_EXPORT KFileItemListView : public KStandardItemListView
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -72,28 +72,27 @@ public:
|
||||||
*/
|
*/
|
||||||
QStringList enabledPlugins() const;
|
QStringList enabledPlugins() const;
|
||||||
|
|
||||||
/** @reimp */
|
virtual QPixmap createDragPixmap(const KItemSet& indexes) const Q_DECL_OVERRIDE;
|
||||||
virtual QPixmap createDragPixmap(const KItemSet& indexes) const;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual KItemListWidgetCreatorBase* defaultWidgetCreator() const;
|
virtual KItemListWidgetCreatorBase* defaultWidgetCreator() const Q_DECL_OVERRIDE;
|
||||||
virtual void initializeItemListWidget(KItemListWidget* item);
|
virtual void initializeItemListWidget(KItemListWidget* item) Q_DECL_OVERRIDE;
|
||||||
virtual void onPreviewsShownChanged(bool shown);
|
virtual void onPreviewsShownChanged(bool shown);
|
||||||
virtual void onItemLayoutChanged(ItemLayout current, ItemLayout previous);
|
virtual void onItemLayoutChanged(ItemLayout current, ItemLayout previous) Q_DECL_OVERRIDE;
|
||||||
virtual void onModelChanged(KItemModelBase* current, KItemModelBase* previous);
|
virtual void onModelChanged(KItemModelBase* current, KItemModelBase* previous) Q_DECL_OVERRIDE;
|
||||||
virtual void onScrollOrientationChanged(Qt::Orientation current, Qt::Orientation previous);
|
virtual void onScrollOrientationChanged(Qt::Orientation current, Qt::Orientation previous) Q_DECL_OVERRIDE;
|
||||||
virtual void onItemSizeChanged(const QSizeF& current, const QSizeF& previous);
|
virtual void onItemSizeChanged(const QSizeF& current, const QSizeF& previous) Q_DECL_OVERRIDE;
|
||||||
virtual void onScrollOffsetChanged(qreal current, qreal previous);
|
virtual void onScrollOffsetChanged(qreal current, qreal previous) Q_DECL_OVERRIDE;
|
||||||
virtual void onVisibleRolesChanged(const QList<QByteArray>& current, const QList<QByteArray>& previous);
|
virtual void onVisibleRolesChanged(const QList<QByteArray>& current, const QList<QByteArray>& previous) Q_DECL_OVERRIDE;
|
||||||
virtual void onStyleOptionChanged(const KItemListStyleOption& current, const KItemListStyleOption& previous);
|
virtual void onStyleOptionChanged(const KItemListStyleOption& current, const KItemListStyleOption& previous) Q_DECL_OVERRIDE;
|
||||||
virtual void onSupportsItemExpandingChanged(bool supportsExpanding);
|
virtual void onSupportsItemExpandingChanged(bool supportsExpanding) Q_DECL_OVERRIDE;
|
||||||
virtual void onTransactionBegin();
|
virtual void onTransactionBegin() Q_DECL_OVERRIDE;
|
||||||
virtual void onTransactionEnd();
|
virtual void onTransactionEnd() Q_DECL_OVERRIDE;
|
||||||
virtual void resizeEvent(QGraphicsSceneResizeEvent* event);
|
virtual void resizeEvent(QGraphicsSceneResizeEvent* event) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
virtual void slotItemsRemoved(const KItemRangeList& itemRanges);
|
virtual void slotItemsRemoved(const KItemRangeList& itemRanges) Q_DECL_OVERRIDE;
|
||||||
virtual void slotSortRoleChanged(const QByteArray& current, const QByteArray& previous);
|
virtual void slotSortRoleChanged(const QByteArray& current, const QByteArray& previous) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void triggerVisibleIndexRangeUpdate();
|
void triggerVisibleIndexRangeUpdate();
|
||||||
|
|
|
@ -21,12 +21,12 @@
|
||||||
#include "kfileitemmodel.h"
|
#include "kfileitemmodel.h"
|
||||||
#include "kitemlistview.h"
|
#include "kitemlistview.h"
|
||||||
|
|
||||||
#include <kmimetype.h>
|
#include <KLocalizedString>
|
||||||
#include <KDebug>
|
|
||||||
#include <KGlobal>
|
|
||||||
#include <KLocale>
|
|
||||||
#include <KIO/MetaData>
|
#include <KIO/MetaData>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
#include <KFormat>
|
||||||
|
#include <QMimeDatabase>
|
||||||
|
#include <QLocale>
|
||||||
|
|
||||||
KFileItemListWidgetInformant::KFileItemListWidgetInformant() :
|
KFileItemListWidgetInformant::KFileItemListWidgetInformant() :
|
||||||
KStandardItemListWidgetInformant()
|
KStandardItemListWidgetInformant()
|
||||||
|
@ -78,11 +78,11 @@ QString KFileItemListWidgetInformant::roleText(const QByteArray& role,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const KIO::filesize_t size = roleValue.value<KIO::filesize_t>();
|
const KIO::filesize_t size = roleValue.value<KIO::filesize_t>();
|
||||||
text = KGlobal::locale()->formatByteSize(size);
|
text = KFormat().formatByteSize(size);
|
||||||
}
|
}
|
||||||
} else if (role == "date") {
|
} else if (role == "date") {
|
||||||
const QDateTime dateTime = roleValue.toDateTime();
|
const QDateTime dateTime = roleValue.toDateTime();
|
||||||
text = KGlobal::locale()->formatDateTime(dateTime);
|
text = QLocale().toString(dateTime, QLocale::ShortFormat);
|
||||||
} else {
|
} else {
|
||||||
text = KStandardItemListWidgetInformant::roleText(role, values);
|
text = KStandardItemListWidgetInformant::roleText(role, values);
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,8 @@ int KFileItemListWidget::selectionLength(const QString& text) const
|
||||||
return selectionLength;
|
return selectionLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString extension = KMimeType::extractKnownExtension(text);
|
QMimeDatabase db;
|
||||||
|
const QString extension = db.suffixForFileName(text);
|
||||||
if (extension.isEmpty()) {
|
if (extension.isEmpty()) {
|
||||||
// For an unknown extension just exclude the extension after
|
// For an unknown extension just exclude the extension after
|
||||||
// the last point. This does not work for multiple extensions like
|
// the last point. This does not work for multiple extensions like
|
||||||
|
@ -161,4 +162,3 @@ int KFileItemListWidget::selectionLength(const QString& text) const
|
||||||
return selectionLength;
|
return selectionLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "kfileitemlistwidget.moc"
|
|
||||||
|
|
|
@ -20,24 +20,24 @@
|
||||||
#ifndef KFILEITEMLISTWIDGET_H
|
#ifndef KFILEITEMLISTWIDGET_H
|
||||||
#define KFILEITEMLISTWIDGET_H
|
#define KFILEITEMLISTWIDGET_H
|
||||||
|
|
||||||
#include <libdolphin_export.h>
|
#include "dolphin_export.h"
|
||||||
|
|
||||||
#include <kitemviews/kstandarditemlistwidget.h>
|
#include <kitemviews/kstandarditemlistwidget.h>
|
||||||
|
|
||||||
class LIBDOLPHINPRIVATE_EXPORT KFileItemListWidgetInformant : public KStandardItemListWidgetInformant
|
class DOLPHIN_EXPORT KFileItemListWidgetInformant : public KStandardItemListWidgetInformant
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
KFileItemListWidgetInformant();
|
KFileItemListWidgetInformant();
|
||||||
virtual ~KFileItemListWidgetInformant();
|
virtual ~KFileItemListWidgetInformant();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual QString itemText(int index, const KItemListView* view) const;
|
virtual QString itemText(int index, const KItemListView* view) const Q_DECL_OVERRIDE;
|
||||||
virtual bool itemIsLink(int index, const KItemListView* view) const;
|
virtual bool itemIsLink(int index, const KItemListView* view) const Q_DECL_OVERRIDE;
|
||||||
virtual QString roleText(const QByteArray& role, const QHash<QByteArray, QVariant>& values) const;
|
virtual QString roleText(const QByteArray& role, const QHash<QByteArray, QVariant>& values) const Q_DECL_OVERRIDE;
|
||||||
virtual QFont customizedFontForLinks(const QFont& baseFont) const;
|
virtual QFont customizedFontForLinks(const QFont& baseFont) const Q_DECL_OVERRIDE;
|
||||||
};
|
};
|
||||||
|
|
||||||
class LIBDOLPHINPRIVATE_EXPORT KFileItemListWidget : public KStandardItemListWidget
|
class DOLPHIN_EXPORT KFileItemListWidget : public KStandardItemListWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -48,14 +48,14 @@ public:
|
||||||
static KItemListWidgetInformant* createInformant();
|
static KItemListWidgetInformant* createInformant();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool isRoleRightAligned(const QByteArray& role) const;
|
virtual bool isRoleRightAligned(const QByteArray& role) const Q_DECL_OVERRIDE;
|
||||||
virtual bool isHidden() const;
|
virtual bool isHidden() const Q_DECL_OVERRIDE;
|
||||||
virtual QFont customizedFont(const QFont& baseFont) const;
|
virtual QFont customizedFont(const QFont& baseFont) const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Selection length without MIME-type extension
|
* @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
|
#endif
|
||||||
|
|
|
@ -21,15 +21,14 @@
|
||||||
|
|
||||||
#include "kfileitemmodel.h"
|
#include "kfileitemmodel.h"
|
||||||
|
|
||||||
#include <KGlobalSettings>
|
#include "dolphin_generalsettings.h"
|
||||||
#include <KLocale>
|
|
||||||
#include <KStringHandler>
|
#include <KLocalizedString>
|
||||||
#include <KDebug>
|
#include "dolphindebug.h"
|
||||||
|
|
||||||
#include "private/kfileitemmodelsortalgorithm.h"
|
#include "private/kfileitemmodelsortalgorithm.h"
|
||||||
#include "private/kfileitemmodeldirlister.h"
|
#include "private/kfileitemmodeldirlister.h"
|
||||||
|
|
||||||
#include <QApplication>
|
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
@ -42,12 +41,11 @@
|
||||||
KFileItemModel::KFileItemModel(QObject* parent) :
|
KFileItemModel::KFileItemModel(QObject* parent) :
|
||||||
KItemModelBase("text", parent),
|
KItemModelBase("text", parent),
|
||||||
m_dirLister(0),
|
m_dirLister(0),
|
||||||
m_naturalSorting(KGlobalSettings::naturalSorting()),
|
m_naturalSorting(GeneralSettings::naturalSorting()),
|
||||||
m_sortDirsFirst(true),
|
m_sortDirsFirst(true),
|
||||||
m_sortRole(NameRole),
|
m_sortRole(NameRole),
|
||||||
m_sortingProgressPercent(-1),
|
m_sortingProgressPercent(-1),
|
||||||
m_roles(),
|
m_roles(),
|
||||||
m_caseSensitivity(Qt::CaseInsensitive),
|
|
||||||
m_itemData(),
|
m_itemData(),
|
||||||
m_items(),
|
m_items(),
|
||||||
m_filter(),
|
m_filter(),
|
||||||
|
@ -60,6 +58,9 @@ KFileItemModel::KFileItemModel(QObject* parent) :
|
||||||
m_expandedDirs(),
|
m_expandedDirs(),
|
||||||
m_urlsToExpand()
|
m_urlsToExpand()
|
||||||
{
|
{
|
||||||
|
m_collator.setCaseSensitivity(Qt::CaseInsensitive);
|
||||||
|
m_collator.setNumericMode(true);
|
||||||
|
|
||||||
m_dirLister = new KFileItemModelDirLister(this);
|
m_dirLister = new KFileItemModelDirLister(this);
|
||||||
m_dirLister->setDelayedMimeTypes(true);
|
m_dirLister->setDelayedMimeTypes(true);
|
||||||
|
|
||||||
|
@ -68,17 +69,17 @@ KFileItemModel::KFileItemModel(QObject* parent) :
|
||||||
m_dirLister->setMainWindow(parentWidget->window());
|
m_dirLister->setMainWindow(parentWidget->window());
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(m_dirLister, SIGNAL(started(KUrl)), this, SIGNAL(directoryLoadingStarted()));
|
connect(m_dirLister, &KFileItemModelDirLister::started, this, &KFileItemModel::directoryLoadingStarted);
|
||||||
connect(m_dirLister, SIGNAL(canceled()), this, SLOT(slotCanceled()));
|
connect(m_dirLister, static_cast<void(KFileItemModelDirLister::*)()>(&KFileItemModelDirLister::canceled), this, &KFileItemModel::slotCanceled);
|
||||||
connect(m_dirLister, SIGNAL(completed(KUrl)), this, SLOT(slotCompleted()));
|
connect(m_dirLister, static_cast<void(KFileItemModelDirLister::*)(const QUrl&)>(&KFileItemModelDirLister::completed), this, &KFileItemModel::slotCompleted);
|
||||||
connect(m_dirLister, SIGNAL(itemsAdded(KUrl,KFileItemList)), this, SLOT(slotItemsAdded(KUrl,KFileItemList)));
|
connect(m_dirLister, &KFileItemModelDirLister::itemsAdded, this, &KFileItemModel::slotItemsAdded);
|
||||||
connect(m_dirLister, SIGNAL(itemsDeleted(KFileItemList)), this, SLOT(slotItemsDeleted(KFileItemList)));
|
connect(m_dirLister, &KFileItemModelDirLister::itemsDeleted, this, &KFileItemModel::slotItemsDeleted);
|
||||||
connect(m_dirLister, SIGNAL(refreshItems(QList<QPair<KFileItem,KFileItem> >)), this, SLOT(slotRefreshItems(QList<QPair<KFileItem,KFileItem> >)));
|
connect(m_dirLister, &KFileItemModelDirLister::refreshItems, this, &KFileItemModel::slotRefreshItems);
|
||||||
connect(m_dirLister, SIGNAL(clear()), this, SLOT(slotClear()));
|
connect(m_dirLister, static_cast<void(KFileItemModelDirLister::*)()>(&KFileItemModelDirLister::clear), this, &KFileItemModel::slotClear);
|
||||||
connect(m_dirLister, SIGNAL(infoMessage(QString)), this, SIGNAL(infoMessage(QString)));
|
connect(m_dirLister, &KFileItemModelDirLister::infoMessage, this, &KFileItemModel::infoMessage);
|
||||||
connect(m_dirLister, SIGNAL(errorMessage(QString)), this, SIGNAL(errorMessage(QString)));
|
connect(m_dirLister, &KFileItemModelDirLister::errorMessage, this, &KFileItemModel::errorMessage);
|
||||||
connect(m_dirLister, SIGNAL(redirection(KUrl,KUrl)), this, SIGNAL(directoryRedirection(KUrl,KUrl)));
|
connect(m_dirLister, static_cast<void(KFileItemModelDirLister::*)(const QUrl&, const QUrl&)>(&KFileItemModelDirLister::redirection), this, &KFileItemModel::directoryRedirection);
|
||||||
connect(m_dirLister, SIGNAL(urlIsFileError(KUrl)), this, SIGNAL(urlIsFileError(KUrl)));
|
connect(m_dirLister, &KFileItemModelDirLister::urlIsFileError, this, &KFileItemModel::urlIsFileError);
|
||||||
|
|
||||||
// Apply default roles that should be determined
|
// Apply default roles that should be determined
|
||||||
resetRoles();
|
resetRoles();
|
||||||
|
@ -94,7 +95,7 @@ KFileItemModel::KFileItemModel(QObject* parent) :
|
||||||
m_maximumUpdateIntervalTimer = new QTimer(this);
|
m_maximumUpdateIntervalTimer = new QTimer(this);
|
||||||
m_maximumUpdateIntervalTimer->setInterval(2000);
|
m_maximumUpdateIntervalTimer->setInterval(2000);
|
||||||
m_maximumUpdateIntervalTimer->setSingleShot(true);
|
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
|
// 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
|
// 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 = new QTimer(this);
|
||||||
m_resortAllItemsTimer->setInterval(500);
|
m_resortAllItemsTimer->setInterval(500);
|
||||||
m_resortAllItemsTimer->setSingleShot(true);
|
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()
|
KFileItemModel::~KFileItemModel()
|
||||||
|
@ -115,15 +117,15 @@ KFileItemModel::~KFileItemModel()
|
||||||
qDeleteAll(m_pendingItemsToInsert);
|
qDeleteAll(m_pendingItemsToInsert);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KFileItemModel::loadDirectory(const KUrl& url)
|
void KFileItemModel::loadDirectory(const QUrl &url)
|
||||||
{
|
{
|
||||||
m_dirLister->openUrl(url);
|
m_dirLister->openUrl(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KFileItemModel::refreshDirectory(const KUrl& url)
|
void KFileItemModel::refreshDirectory(const QUrl &url)
|
||||||
{
|
{
|
||||||
// Refresh all expanded directories first (Bug 295300)
|
// Refresh all expanded directories first (Bug 295300)
|
||||||
QHashIterator<KUrl, KUrl> expandedDirs(m_expandedDirs);
|
QHashIterator<QUrl, QUrl> expandedDirs(m_expandedDirs);
|
||||||
while (expandedDirs.hasNext()) {
|
while (expandedDirs.hasNext()) {
|
||||||
expandedDirs.next();
|
expandedDirs.next();
|
||||||
m_dirLister->openUrl(expandedDirs.value(), KDirLister::Reload);
|
m_dirLister->openUrl(expandedDirs.value(), KDirLister::Reload);
|
||||||
|
@ -132,7 +134,7 @@ void KFileItemModel::refreshDirectory(const KUrl& url)
|
||||||
m_dirLister->openUrl(url, KDirLister::Reload);
|
m_dirLister->openUrl(url, KDirLister::Reload);
|
||||||
}
|
}
|
||||||
|
|
||||||
KUrl KFileItemModel::directory() const
|
QUrl KFileItemModel::directory() const
|
||||||
{
|
{
|
||||||
return m_dirLister->url();
|
return m_dirLister->url();
|
||||||
}
|
}
|
||||||
|
@ -188,8 +190,9 @@ bool KFileItemModel::setData(int index, const QHash<QByteArray, QVariant>& value
|
||||||
|
|
||||||
m_itemData[index]->values = currentValues;
|
m_itemData[index]->values = currentValues;
|
||||||
if (changedRoles.contains("text")) {
|
if (changedRoles.contains("text")) {
|
||||||
KUrl url = m_itemData[index]->item.url();
|
QUrl url = m_itemData[index]->item.url();
|
||||||
url.setFileName(currentValues["text"].toString());
|
url = url.adjusted(QUrl::RemoveFilename);
|
||||||
|
url.setPath(url.path() + currentValues["text"].toString());
|
||||||
m_itemData[index]->item.setUrl(url);
|
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()
|
// The following code has been taken from KDirModel::mimeData()
|
||||||
// (kdelibs/kio/kio/kdirmodel.cpp)
|
// (kdelibs/kio/kio/kdirmodel.cpp)
|
||||||
// Copyright (C) 2006 David Faure <faure@kde.org>
|
// Copyright (C) 2006 David Faure <faure@kde.org>
|
||||||
KUrl::List urls;
|
QList<QUrl> urls;
|
||||||
KUrl::List mostLocalUrls;
|
QList<QUrl> mostLocalUrls;
|
||||||
bool canUseMostLocalUrls = true;
|
bool canUseMostLocalUrls = true;
|
||||||
const ItemData* lastAddedItem = 0;
|
const ItemData* lastAddedItem = 0;
|
||||||
|
|
||||||
|
@ -275,9 +278,9 @@ QMimeData* KFileItemModel::createMimeData(const KItemSet& indexes) const
|
||||||
|
|
||||||
const bool different = canUseMostLocalUrls && mostLocalUrls != urls;
|
const bool different = canUseMostLocalUrls && mostLocalUrls != urls;
|
||||||
if (different) {
|
if (different) {
|
||||||
urls.populateMimeData(mostLocalUrls, data);
|
data->setUrls(mostLocalUrls);
|
||||||
} else {
|
} else {
|
||||||
urls.populateMimeData(data);
|
data->setUrls(urls);
|
||||||
}
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
@ -336,7 +339,7 @@ QList<QPair<int, QVariant> > KFileItemModel::groups() const
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef KFILEITEMMODEL_DEBUG
|
#ifdef KFILEITEMMODEL_DEBUG
|
||||||
kDebug() << "[TIME] Calculating groups for" << count() << "items:" << timer.elapsed();
|
qCDebug(DolphinDebug) << "[TIME] Calculating groups for" << count() << "items:" << timer.elapsed();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -352,7 +355,7 @@ KFileItem KFileItemModel::fileItem(int index) const
|
||||||
return KFileItem();
|
return KFileItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
KFileItem KFileItemModel::fileItem(const KUrl& url) const
|
KFileItem KFileItemModel::fileItem(const QUrl &url) const
|
||||||
{
|
{
|
||||||
const int indexForUrl = index(url);
|
const int indexForUrl = index(url);
|
||||||
if (indexForUrl >= 0) {
|
if (indexForUrl >= 0) {
|
||||||
|
@ -366,10 +369,9 @@ int KFileItemModel::index(const KFileItem& item) const
|
||||||
return index(item.url());
|
return index(item.url());
|
||||||
}
|
}
|
||||||
|
|
||||||
int KFileItemModel::index(const KUrl& url) const
|
int KFileItemModel::index(const QUrl& url) const
|
||||||
{
|
{
|
||||||
KUrl urlToFind = url;
|
const QUrl urlToFind = url.adjusted(QUrl::StripTrailingSlash);
|
||||||
urlToFind.adjustPath(KUrl::RemoveTrailingSlash);
|
|
||||||
|
|
||||||
const int itemCount = m_itemData.count();
|
const int itemCount = m_itemData.count();
|
||||||
int itemsInHash = m_items.count();
|
int itemsInHash = m_items.count();
|
||||||
|
@ -387,7 +389,7 @@ int KFileItemModel::index(const KUrl& url) const
|
||||||
const int blockSize = 1000;
|
const int blockSize = 1000;
|
||||||
const int currentBlockEnd = qMin(itemsInHash + blockSize, itemCount);
|
const int currentBlockEnd = qMin(itemsInHash + blockSize, itemCount);
|
||||||
for (int i = itemsInHash; i < currentBlockEnd; ++i) {
|
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);
|
m_items.insert(nextUrl, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -406,24 +408,24 @@ int KFileItemModel::index(const KUrl& url) const
|
||||||
if (m_items.count() != m_itemData.count() && printDebugInfo) {
|
if (m_items.count() != m_itemData.count() && printDebugInfo) {
|
||||||
printDebugInfo = false;
|
printDebugInfo = false;
|
||||||
|
|
||||||
kWarning() << "The model is in an inconsistent state.";
|
qCWarning(DolphinDebug) << "The model is in an inconsistent state.";
|
||||||
kWarning() << "m_items.count() ==" << m_items.count();
|
qCWarning(DolphinDebug) << "m_items.count() ==" << m_items.count();
|
||||||
kWarning() << "m_itemData.count() ==" << m_itemData.count();
|
qCWarning(DolphinDebug) << "m_itemData.count() ==" << m_itemData.count();
|
||||||
|
|
||||||
// Check if there are multiple items with the same URL.
|
// 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) {
|
for (int i = 0; i < m_itemData.count(); ++i) {
|
||||||
indexesForUrl.insert(m_itemData.at(i)->item.url(), 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) {
|
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)) {
|
foreach (int index, indexesForUrl.values(url)) {
|
||||||
const ItemData* data = m_itemData.at(index);
|
const ItemData* data = m_itemData.at(index);
|
||||||
kWarning() << "index" << index << ":" << data->item;
|
qCWarning(DolphinDebug) << "index" << index << ":" << data->item;
|
||||||
if (data->parent) {
|
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 KFileItem item = m_itemData.at(index)->item;
|
||||||
const KUrl url = item.url();
|
const QUrl url = item.url();
|
||||||
const KUrl targetUrl = item.targetUrl();
|
const QUrl targetUrl = item.targetUrl();
|
||||||
if (expanded) {
|
if (expanded) {
|
||||||
m_expandedDirs.insert(targetUrl, url);
|
m_expandedDirs.insert(targetUrl, url);
|
||||||
m_dirLister->openUrl(url, KDirLister::Keep);
|
m_dirLister->openUrl(url, KDirLister::Keep);
|
||||||
|
|
||||||
const KUrl::List previouslyExpandedChildren = m_itemData.at(index)->values.value("previouslyExpandedChildren").value<KUrl::List>();
|
const QVariantList previouslyExpandedChildren = m_itemData.at(index)->values.value("previouslyExpandedChildren").value<QVariantList>();
|
||||||
foreach (const KUrl& url, previouslyExpandedChildren) {
|
foreach (const QVariant& var, previouslyExpandedChildren) {
|
||||||
m_urlsToExpand.insert(url);
|
m_urlsToExpand.insert(var.toUrl());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Note that there might be (indirect) children of the folder which is to be collapsed in
|
// 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 itemCount = m_itemData.count();
|
||||||
const int firstChildIndex = index + 1;
|
const int firstChildIndex = index + 1;
|
||||||
|
|
||||||
KUrl::List expandedChildren;
|
QVariantList expandedChildren;
|
||||||
|
|
||||||
int childIndex = firstChildIndex;
|
int childIndex = firstChildIndex;
|
||||||
while (childIndex < itemCount && expandedParentsCount(childIndex) > parentLevel) {
|
while (childIndex < itemCount && expandedParentsCount(childIndex) > parentLevel) {
|
||||||
ItemData* itemData = m_itemData.at(childIndex);
|
ItemData* itemData = m_itemData.at(childIndex);
|
||||||
if (itemData->values.value("isExpanded").toBool()) {
|
if (itemData->values.value("isExpanded").toBool()) {
|
||||||
const KUrl targetUrl = itemData->item.targetUrl();
|
const QUrl targetUrl = itemData->item.targetUrl();
|
||||||
const KUrl url = itemData->item.url();
|
const QUrl url = itemData->item.url();
|
||||||
m_expandedDirs.remove(targetUrl);
|
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
|
m_dirLister->stop(url); // TODO: try to unit-test this, see https://bugs.kde.org/show_bug.cgi?id=332102#c11
|
||||||
expandedChildren.append(targetUrl);
|
expandedChildren.append(targetUrl);
|
||||||
|
@ -591,17 +593,17 @@ int KFileItemModel::expandedParentsCount(int index) const
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSet<KUrl> KFileItemModel::expandedDirectories() const
|
QSet<QUrl> KFileItemModel::expandedDirectories() const
|
||||||
{
|
{
|
||||||
return m_expandedDirs.values().toSet();
|
return m_expandedDirs.values().toSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KFileItemModel::restoreExpandedDirectories(const QSet<KUrl>& urls)
|
void KFileItemModel::restoreExpandedDirectories(const QSet<QUrl> &urls)
|
||||||
{
|
{
|
||||||
m_urlsToExpand = urls;
|
m_urlsToExpand = urls;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KFileItemModel::expandParentDirectories(const KUrl& url)
|
void KFileItemModel::expandParentDirectories(const QUrl &url)
|
||||||
{
|
{
|
||||||
const int pos = m_dirLister->url().path().length();
|
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
|
// expanded is added to m_urlsToExpand. KDirLister
|
||||||
// does not care whether the parent-URL has already been
|
// does not care whether the parent-URL has already been
|
||||||
// expanded.
|
// expanded.
|
||||||
KUrl urlToExpand = m_dirLister->url();
|
QUrl urlToExpand = m_dirLister->url();
|
||||||
const QStringList subDirs = url.path().mid(pos).split(QDir::separator());
|
const QStringList subDirs = url.path().mid(pos).split(QDir::separator());
|
||||||
for (int i = 0; i < subDirs.count() - 1; ++i) {
|
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);
|
m_urlsToExpand.insert(urlToExpand);
|
||||||
}
|
}
|
||||||
|
|
||||||
// KDirLister::open() must called at least once to trigger an initial
|
// KDirLister::open() must called at least once to trigger an initial
|
||||||
// loading. The pending URLs that must be restored are handled
|
// loading. The pending URLs that must be restored are handled
|
||||||
// in slotCompleted().
|
// in slotCompleted().
|
||||||
QSetIterator<KUrl> it2(m_urlsToExpand);
|
QSetIterator<QUrl> it2(m_urlsToExpand);
|
||||||
while (it2.hasNext()) {
|
while (it2.hasNext()) {
|
||||||
const int idx = index(it2.next());
|
const int idx = index(it2.next());
|
||||||
if (idx >= 0 && !isExpanded(idx)) {
|
if (idx >= 0 && !isExpanded(idx)) {
|
||||||
|
@ -793,14 +795,14 @@ void KFileItemModel::resortAllItems()
|
||||||
#ifdef KFILEITEMMODEL_DEBUG
|
#ifdef KFILEITEMMODEL_DEBUG
|
||||||
QElapsedTimer timer;
|
QElapsedTimer timer;
|
||||||
timer.start();
|
timer.start();
|
||||||
kDebug() << "===========================================================";
|
qCDebug(DolphinDebug) << "===========================================================";
|
||||||
kDebug() << "Resorting" << itemCount << "items";
|
qCDebug(DolphinDebug) << "Resorting" << itemCount << "items";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Remember the order of the current URLs so
|
// Remember the order of the current URLs so
|
||||||
// that it can be determined which indexes have
|
// that it can be determined which indexes have
|
||||||
// been moved because of the resorting.
|
// been moved because of the resorting.
|
||||||
QList<KUrl> oldUrls;
|
QList<QUrl> oldUrls;
|
||||||
oldUrls.reserve(itemCount);
|
oldUrls.reserve(itemCount);
|
||||||
foreach (const ItemData* itemData, m_itemData) {
|
foreach (const ItemData* itemData, m_itemData) {
|
||||||
oldUrls.append(itemData->item.url());
|
oldUrls.append(itemData->item.url());
|
||||||
|
@ -856,7 +858,7 @@ void KFileItemModel::resortAllItems()
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef KFILEITEMMODEL_DEBUG
|
#ifdef KFILEITEMMODEL_DEBUG
|
||||||
kDebug() << "[TIME] Resorting of" << itemCount << "items:" << timer.elapsed();
|
qCDebug(DolphinDebug) << "[TIME] Resorting of" << itemCount << "items:" << timer.elapsed();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -869,7 +871,7 @@ void KFileItemModel::slotCompleted()
|
||||||
// Note that the parent folder must be expanded before any of its subfolders become visible.
|
// 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
|
// Therefore, some URLs in m_restoredExpandedUrls might not be visible yet
|
||||||
// -> we expand the first visible URL we find in m_restoredExpandedUrls.
|
// -> 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);
|
const int indexForUrl = index(url);
|
||||||
if (indexForUrl >= 0) {
|
if (indexForUrl >= 0) {
|
||||||
m_urlsToExpand.remove(url);
|
m_urlsToExpand.remove(url);
|
||||||
|
@ -897,16 +899,15 @@ void KFileItemModel::slotCanceled()
|
||||||
emit directoryLoadingCanceled();
|
emit directoryLoadingCanceled();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KFileItemModel::slotItemsAdded(const KUrl& directoryUrl, const KFileItemList& items)
|
void KFileItemModel::slotItemsAdded(const QUrl &directoryUrl, const KFileItemList& items)
|
||||||
{
|
{
|
||||||
Q_ASSERT(!items.isEmpty());
|
Q_ASSERT(!items.isEmpty());
|
||||||
|
|
||||||
KUrl parentUrl;
|
QUrl parentUrl;
|
||||||
if (m_expandedDirs.contains(directoryUrl)) {
|
if (m_expandedDirs.contains(directoryUrl)) {
|
||||||
parentUrl = m_expandedDirs.value(directoryUrl);
|
parentUrl = m_expandedDirs.value(directoryUrl);
|
||||||
} else {
|
} else {
|
||||||
parentUrl = directoryUrl;
|
parentUrl = directoryUrl.adjusted(QUrl::StripTrailingSlash);
|
||||||
parentUrl.adjustPath(KUrl::RemoveTrailingSlash);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_requestRole[ExpandedParentsCountRole]) {
|
if (m_requestRole[ExpandedParentsCountRole]) {
|
||||||
|
@ -1012,7 +1013,7 @@ void KFileItemModel::slotRefreshItems(const QList<QPair<KFileItem, KFileItem> >&
|
||||||
{
|
{
|
||||||
Q_ASSERT(!items.isEmpty());
|
Q_ASSERT(!items.isEmpty());
|
||||||
#ifdef KFILEITEMMODEL_DEBUG
|
#ifdef KFILEITEMMODEL_DEBUG
|
||||||
kDebug() << "Refreshing" << items.count() << "items";
|
qCDebug(DolphinDebug) << "Refreshing" << items.count() << "items";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Get the indexes of all items that have been refreshed
|
// 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()
|
void KFileItemModel::slotClear()
|
||||||
{
|
{
|
||||||
#ifdef KFILEITEMMODEL_DEBUG
|
#ifdef KFILEITEMMODEL_DEBUG
|
||||||
kDebug() << "Clearing all items";
|
qCDebug(DolphinDebug) << "Clearing all items";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
qDeleteAll(m_filteredItems.values());
|
qDeleteAll(m_filteredItems.values());
|
||||||
|
@ -1104,7 +1105,7 @@ void KFileItemModel::slotClear()
|
||||||
|
|
||||||
void KFileItemModel::slotNaturalSortingChanged()
|
void KFileItemModel::slotNaturalSortingChanged()
|
||||||
{
|
{
|
||||||
m_naturalSorting = KGlobalSettings::naturalSorting();
|
m_naturalSorting = GeneralSettings::naturalSorting();
|
||||||
resortAllItems();
|
resortAllItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1125,8 +1126,8 @@ void KFileItemModel::insertItems(QList<ItemData*>& newItems)
|
||||||
#ifdef KFILEITEMMODEL_DEBUG
|
#ifdef KFILEITEMMODEL_DEBUG
|
||||||
QElapsedTimer timer;
|
QElapsedTimer timer;
|
||||||
timer.start();
|
timer.start();
|
||||||
kDebug() << "===========================================================";
|
qCDebug(DolphinDebug) << "===========================================================";
|
||||||
kDebug() << "Inserting" << newItems.count() << "items";
|
qCDebug(DolphinDebug) << "Inserting" << newItems.count() << "items";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_groups.clear();
|
m_groups.clear();
|
||||||
|
@ -1143,7 +1144,7 @@ void KFileItemModel::insertItems(QList<ItemData*>& newItems)
|
||||||
sort(newItems.begin(), newItems.end());
|
sort(newItems.begin(), newItems.end());
|
||||||
|
|
||||||
#ifdef KFILEITEMMODEL_DEBUG
|
#ifdef KFILEITEMMODEL_DEBUG
|
||||||
kDebug() << "[TIME] Sorting:" << timer.elapsed();
|
qCDebug(DolphinDebug) << "[TIME] Sorting:" << timer.elapsed();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
KItemRangeList itemRanges;
|
KItemRangeList itemRanges;
|
||||||
|
@ -1172,7 +1173,7 @@ void KFileItemModel::insertItems(QList<ItemData*>& newItems)
|
||||||
|
|
||||||
while (sourceIndexNewItems >= 0) {
|
while (sourceIndexNewItems >= 0) {
|
||||||
ItemData* newItem = newItems.at(sourceIndexNewItems);
|
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
|
// Move an existing item to its new position. If any new items
|
||||||
// are behind it, push the item range to itemRanges.
|
// are behind it, push the item range to itemRanges.
|
||||||
if (rangeCount > 0) {
|
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.
|
// 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();
|
m_items.clear();
|
||||||
|
|
||||||
emit itemsInserted(itemRanges);
|
emit itemsInserted(itemRanges);
|
||||||
|
|
||||||
#ifdef KFILEITEMMODEL_DEBUG
|
#ifdef KFILEITEMMODEL_DEBUG
|
||||||
kDebug() << "[TIME] Inserting of" << newItems.count() << "items:" << timer.elapsed();
|
qCDebug(DolphinDebug) << "[TIME] Inserting of" << newItems.count() << "items:" << timer.elapsed();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1254,13 +1255,13 @@ void KFileItemModel::removeItems(const KItemRangeList& itemRanges, RemoveItemsBe
|
||||||
m_itemData.erase(m_itemData.end() - removedItemsCount, m_itemData.end());
|
m_itemData.erase(m_itemData.end() - removedItemsCount, m_itemData.end());
|
||||||
|
|
||||||
// The indexes in m_items are not correct anymore. Therefore, we clear m_items.
|
// 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();
|
m_items.clear();
|
||||||
|
|
||||||
emit itemsRemoved(itemRanges);
|
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) {
|
if (m_sortRole == TypeRole) {
|
||||||
// Try to resolve the MIME-types synchronously to prevent a reordering of
|
// 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
|
// (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.
|
// (c) the internal order of the items in the range is incorrect.
|
||||||
if (first > 0
|
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;
|
needsResorting = true;
|
||||||
} else if (last < count() - 1
|
} 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;
|
needsResorting = true;
|
||||||
} else {
|
} else {
|
||||||
for (int index = first; index < last; ++index) {
|
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;
|
needsResorting = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1510,8 +1511,8 @@ QHash<QByteArray, QVariant> KFileItemModel::retrieveData(const KFileItem& item,
|
||||||
// Don't use KFileItem::timeString() as this is too expensive when
|
// Don't use KFileItem::timeString() as this is too expensive when
|
||||||
// having several thousands of items. Instead the formatting of the
|
// 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.
|
// date-time will be done on-demand by the view when the date will be shown.
|
||||||
const KDateTime dateTime = item.time(KFileItem::ModificationTime);
|
const QDateTime dateTime = item.time(KFileItem::ModificationTime);
|
||||||
data.insert(sharedValue("date"), dateTime.dateTime());
|
data.insert(sharedValue("date"), dateTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_requestRole[PermissionsRole]) {
|
if (m_requestRole[PermissionsRole]) {
|
||||||
|
@ -1536,7 +1537,7 @@ QHash<QByteArray, QVariant> KFileItemModel::retrieveData(const KFileItem& item,
|
||||||
|
|
||||||
if (m_requestRole[PathRole]) {
|
if (m_requestRole[PathRole]) {
|
||||||
QString path;
|
QString path;
|
||||||
if (item.url().protocol() == QLatin1String("trash")) {
|
if (item.url().scheme() == QLatin1String("trash")) {
|
||||||
path = item.entry().stringValue(KIO::UDSEntry::UDS_EXTRA);
|
path = item.entry().stringValue(KIO::UDSEntry::UDS_EXTRA);
|
||||||
} else {
|
} else {
|
||||||
// For performance reasons cache the home-path in a static QString
|
// 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;
|
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;
|
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;
|
return (sortOrder() == Qt::AscendingOrder) ? result < 0 : result > 0;
|
||||||
}
|
}
|
||||||
|
@ -1638,24 +1639,36 @@ bool KFileItemModel::lessThan(const ItemData* a, const ItemData* b) const
|
||||||
class KFileItemModelLessThan
|
class KFileItemModelLessThan
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
KFileItemModelLessThan(const KFileItemModel* model) :
|
KFileItemModelLessThan(const KFileItemModel* model, const QCollator& collator) :
|
||||||
m_model(model)
|
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
|
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:
|
private:
|
||||||
const KFileItemModel* m_model;
|
const KFileItemModel* m_model;
|
||||||
|
QCollator m_collator;
|
||||||
};
|
};
|
||||||
|
|
||||||
void KFileItemModel::sort(QList<KFileItemModel::ItemData*>::iterator begin,
|
void KFileItemModel::sort(QList<KFileItemModel::ItemData*>::iterator begin,
|
||||||
QList<KFileItemModel::ItemData*>::iterator end) const
|
QList<KFileItemModel::ItemData*>::iterator end) const
|
||||||
{
|
{
|
||||||
KFileItemModelLessThan lessThan(this);
|
KFileItemModelLessThan lessThan(this, m_collator);
|
||||||
|
|
||||||
if (m_sortRole == NameRole) {
|
if (m_sortRole == NameRole) {
|
||||||
// Sorting by name can be expensive, in particular if natural sorting is
|
// 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& itemA = a->item;
|
||||||
const KFileItem& itemB = b->item;
|
const KFileItem& itemB = b->item;
|
||||||
|
@ -1715,8 +1728,8 @@ int KFileItemModel::sortRoleCompare(const ItemData* a, const ItemData* b) const
|
||||||
}
|
}
|
||||||
|
|
||||||
case DateRole: {
|
case DateRole: {
|
||||||
const KDateTime dateTimeA = itemA.time(KFileItem::ModificationTime);
|
const QDateTime dateTimeA = itemA.time(KFileItem::ModificationTime);
|
||||||
const KDateTime dateTimeB = itemB.time(KFileItem::ModificationTime);
|
const QDateTime dateTimeB = itemB.time(KFileItem::ModificationTime);
|
||||||
if (dateTimeA < dateTimeB) {
|
if (dateTimeA < dateTimeB) {
|
||||||
result = -1;
|
result = -1;
|
||||||
} else if (dateTimeA > dateTimeB) {
|
} else if (dateTimeA > dateTimeB) {
|
||||||
|
@ -1733,9 +1746,8 @@ int KFileItemModel::sortRoleCompare(const ItemData* a, const ItemData* b) const
|
||||||
case ImageSizeRole: {
|
case ImageSizeRole: {
|
||||||
// Alway use a natural comparing to interpret the numbers of a string like
|
// Alway use a natural comparing to interpret the numbers of a string like
|
||||||
// "1600 x 1200" for having a correct sorting.
|
// "1600 x 1200" for having a correct sorting.
|
||||||
result = KStringHandler::naturalCompare(a->values.value("imageSize").toString(),
|
result = collator.compare(a->values.value("imageSize").toString(),
|
||||||
b->values.value("imageSize").toString(),
|
b->values.value("imageSize").toString());
|
||||||
Qt::CaseSensitive);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1754,14 +1766,13 @@ int KFileItemModel::sortRoleCompare(const ItemData* a, const ItemData* b) const
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback #1: Compare the text of the items
|
// Fallback #1: Compare the text of the items
|
||||||
result = stringCompare(itemA.text(), itemB.text());
|
result = stringCompare(itemA.text(), itemB.text(), collator);
|
||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback #2: KFileItem::text() may not be unique in case UDS_DISPLAY_NAME is used
|
// Fallback #2: KFileItem::text() may not be unique in case UDS_DISPLAY_NAME is used
|
||||||
result = stringCompare(itemA.name(m_caseSensitivity == Qt::CaseInsensitive),
|
result = stringCompare(itemA.name(), itemB.name(), collator);
|
||||||
itemB.name(m_caseSensitivity == Qt::CaseInsensitive));
|
|
||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
return result;
|
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);
|
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.*)
|
if (m_naturalSorting) {
|
||||||
// Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at>
|
return collator.compare(a, b);
|
||||||
// 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 = QString::compare(a, b, collator.caseSensitivity());
|
||||||
const int result = m_naturalSorting ? KStringHandler::naturalCompare(a, b, Qt::CaseInsensitive)
|
if (result != 0 || collator.caseSensitivity() == Qt::CaseSensitive) {
|
||||||
: 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
|
// 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, still a deterministic sort order is required. A case sensitive
|
||||||
// comparison is done as fallback.
|
// comparison is done as fallback.
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return m_naturalSorting ? KStringHandler::naturalCompare(a, b, Qt::CaseSensitive)
|
return QString::compare(a, b, Qt::CaseSensitive);
|
||||||
: QString::compare(a, b, Qt::CaseSensitive);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KFileItemModel::useMaximumUpdateInterval() const
|
bool KFileItemModel::useMaximumUpdateInterval() const
|
||||||
|
@ -1799,11 +1805,6 @@ bool KFileItemModel::useMaximumUpdateInterval() const
|
||||||
return !m_dirLister->url().isLocalFile();
|
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
|
QList<QPair<int, QVariant> > KFileItemModel::nameRoleGroups() const
|
||||||
{
|
{
|
||||||
Q_ASSERT(!m_itemData.isEmpty());
|
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);
|
std::vector<QChar>::iterator it = std::lower_bound(lettersAtoZ.begin(), lettersAtoZ.end(), newFirstChar, localeAwareLessThan);
|
||||||
if (it != lettersAtoZ.end()) {
|
if (it != lettersAtoZ.end()) {
|
||||||
if (localeAwareLessThan(newFirstChar, *it) && it != lettersAtoZ.begin()) {
|
if (localeAwareLessThan(newFirstChar, *it) && it != lettersAtoZ.begin()) {
|
||||||
|
@ -1908,7 +1913,7 @@ QList<QPair<int, QVariant> > KFileItemModel::dateRoleGroups() const
|
||||||
const int maxIndex = count() - 1;
|
const int maxIndex = count() - 1;
|
||||||
QList<QPair<int, QVariant> > groups;
|
QList<QPair<int, QVariant> > groups;
|
||||||
|
|
||||||
const QDate currentDate = KDateTime::currentLocalDateTime().date();
|
const QDate currentDate = QDate::currentDate();
|
||||||
|
|
||||||
QDate previousModifiedDate;
|
QDate previousModifiedDate;
|
||||||
QString groupValue;
|
QString groupValue;
|
||||||
|
@ -1917,7 +1922,7 @@ QList<QPair<int, QVariant> > KFileItemModel::dateRoleGroups() const
|
||||||
continue;
|
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();
|
const QDate modifiedDate = modifiedTime.date();
|
||||||
if (modifiedDate == previousModifiedDate) {
|
if (modifiedDate == previousModifiedDate) {
|
||||||
// The current item is in the same group as the previous item
|
// 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) {
|
switch (daysDistance) {
|
||||||
case 0: newGroupValue = i18nc("@title:group Date", "Today"); break;
|
case 0: newGroupValue = i18nc("@title:group Date", "Today"); break;
|
||||||
case 1: newGroupValue = i18nc("@title:group Date", "Yesterday"); 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;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -1957,20 +1962,20 @@ QList<QPair<int, QVariant> > KFileItemModel::dateRoleGroups() const
|
||||||
const QDate lastMonthDate = currentDate.addMonths(-1);
|
const QDate lastMonthDate = currentDate.addMonths(-1);
|
||||||
if (lastMonthDate.year() == modifiedDate.year() && lastMonthDate.month() == modifiedDate.month()) {
|
if (lastMonthDate.year() == modifiedDate.year() && lastMonthDate.month() == modifiedDate.month()) {
|
||||||
if (daysDistance == 1) {
|
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) {
|
} 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) {
|
} 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) {
|
} 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) {
|
} 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 {
|
} 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 {
|
} 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;
|
permissionsString = newPermissionsString;
|
||||||
|
|
||||||
const QFileInfo info(itemData->item.url().pathOrUrl());
|
const QFileInfo info(itemData->item.url().toLocalFile());
|
||||||
|
|
||||||
// Set user string
|
// Set user string
|
||||||
QString user;
|
QString user;
|
||||||
|
@ -2199,7 +2204,7 @@ QByteArray KFileItemModel::sharedValue(const QByteArray& value)
|
||||||
bool KFileItemModel::isConsistent() const
|
bool KFileItemModel::isConsistent() const
|
||||||
{
|
{
|
||||||
// m_items may contain less items than m_itemData because m_items
|
// 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()) {
|
if (m_items.count() > m_itemData.count()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -2208,19 +2213,19 @@ bool KFileItemModel::isConsistent() const
|
||||||
// Check if m_items and m_itemData are consistent.
|
// Check if m_items and m_itemData are consistent.
|
||||||
const KFileItem item = fileItem(i);
|
const KFileItem item = fileItem(i);
|
||||||
if (item.isNull()) {
|
if (item.isNull()) {
|
||||||
qWarning() << "Item" << i << "is null";
|
qCWarning(DolphinDebug) << "Item" << i << "is null";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int itemIndex = index(item);
|
const int itemIndex = index(item);
|
||||||
if (itemIndex != i) {
|
if (itemIndex != i) {
|
||||||
qWarning() << "Item" << i << "has a wrong index:" << itemIndex;
|
qCWarning(DolphinDebug) << "Item" << i << "has a wrong index:" << itemIndex;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the items are sorted correctly.
|
// Check if the items are sorted correctly.
|
||||||
if (i > 0 && !lessThan(m_itemData.at(i - 1), m_itemData.at(i))) {
|
if (i > 0 && !lessThan(m_itemData.at(i - 1), m_itemData.at(i), m_collator)) {
|
||||||
qWarning() << "The order of items" << i - 1 << "and" << i << "is wrong:"
|
qCWarning(DolphinDebug) << "The order of items" << i - 1 << "and" << i << "is wrong:"
|
||||||
<< fileItem(i - 1) << fileItem(i);
|
<< fileItem(i - 1) << fileItem(i);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -2230,13 +2235,13 @@ bool KFileItemModel::isConsistent() const
|
||||||
const ItemData* parent = data->parent;
|
const ItemData* parent = data->parent;
|
||||||
if (parent) {
|
if (parent) {
|
||||||
if (expandedParentsCount(data) != expandedParentsCount(parent) + 1) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int parentIndex = index(parent->item);
|
const int parentIndex = index(parent->item);
|
||||||
if (parentIndex >= i) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2245,4 +2250,3 @@ bool KFileItemModel::isConsistent() const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "kfileitemmodel.moc"
|
|
||||||
|
|
|
@ -20,12 +20,13 @@
|
||||||
#ifndef KFILEITEMMODEL_H
|
#ifndef KFILEITEMMODEL_H
|
||||||
#define KFILEITEMMODEL_H
|
#define KFILEITEMMODEL_H
|
||||||
|
|
||||||
#include <libdolphin_export.h>
|
#include "dolphin_export.h"
|
||||||
#include <KFileItemList>
|
#include <KFileItem>
|
||||||
#include <KUrl>
|
#include <QUrl>
|
||||||
#include <kitemviews/kitemmodelbase.h>
|
#include <kitemviews/kitemmodelbase.h>
|
||||||
#include <kitemviews/private/kfileitemmodelfilter.h>
|
#include <kitemviews/private/kfileitemmodelfilter.h>
|
||||||
|
|
||||||
|
#include <QCollator>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
|
|
||||||
|
@ -42,7 +43,7 @@ class QTimer;
|
||||||
* Recursive expansion of sub-directories is supported by
|
* Recursive expansion of sub-directories is supported by
|
||||||
* KFileItemModel::setExpanded().
|
* KFileItemModel::setExpanded().
|
||||||
*/
|
*/
|
||||||
class LIBDOLPHINPRIVATE_EXPORT KFileItemModel : public KItemModelBase
|
class DOLPHIN_EXPORT KFileItemModel : public KItemModelBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -56,13 +57,13 @@ public:
|
||||||
* indicate the current state of the loading process. The items
|
* indicate the current state of the loading process. The items
|
||||||
* of the directory are added after the loading has been completed.
|
* 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
|
* Throws away all currently loaded items and refreshes the directory
|
||||||
* by reloading all items again.
|
* 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
|
* @return Parent directory of the items that are shown. In case
|
||||||
|
@ -70,7 +71,7 @@ public:
|
||||||
* the root-parent of all items.
|
* the root-parent of all items.
|
||||||
* @see rootItem()
|
* @see rootItem()
|
||||||
*/
|
*/
|
||||||
KUrl directory() const;
|
QUrl directory() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cancels the loading of a directory which has been started by either
|
* Cancels the loading of a directory which has been started by either
|
||||||
|
@ -78,9 +79,9 @@ public:
|
||||||
*/
|
*/
|
||||||
void cancelDirectoryLoading();
|
void cancelDirectoryLoading();
|
||||||
|
|
||||||
virtual int count() const;
|
virtual int count() const Q_DECL_OVERRIDE;
|
||||||
virtual QHash<QByteArray, QVariant> data(int index) const;
|
virtual QHash<QByteArray, QVariant> data(int index) const Q_DECL_OVERRIDE;
|
||||||
virtual bool setData(int index, const QHash<QByteArray, QVariant>& values);
|
virtual bool setData(int index, const QHash<QByteArray, QVariant>& values) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a separate sorting with directories first (true) or a mixed
|
* Sets a separate sorting with directories first (true) or a mixed
|
||||||
|
@ -99,20 +100,15 @@ public:
|
||||||
void setShowDirectoriesOnly(bool enabled);
|
void setShowDirectoriesOnly(bool enabled);
|
||||||
bool showDirectoriesOnly() const;
|
bool showDirectoriesOnly() const;
|
||||||
|
|
||||||
/** @reimp */
|
virtual QMimeData* createMimeData(const KItemSet& indexes) const Q_DECL_OVERRIDE;
|
||||||
virtual QMimeData* createMimeData(const KItemSet& indexes) const;
|
|
||||||
|
|
||||||
/** @reimp */
|
virtual int indexForKeyboardSearch(const QString& text, int startFromIndex = 0) const Q_DECL_OVERRIDE;
|
||||||
virtual int indexForKeyboardSearch(const QString& text, int startFromIndex = 0) const;
|
|
||||||
|
|
||||||
/** @reimp */
|
virtual bool supportsDropping(int index) const Q_DECL_OVERRIDE;
|
||||||
virtual bool supportsDropping(int index) const;
|
|
||||||
|
|
||||||
/** @reimp */
|
virtual QString roleDescription(const QByteArray& role) const Q_DECL_OVERRIDE;
|
||||||
virtual QString roleDescription(const QByteArray& role) const;
|
|
||||||
|
|
||||||
/** @reimp */
|
virtual QList<QPair<int, QVariant> > groups() const Q_DECL_OVERRIDE;
|
||||||
virtual QList<QPair<int, QVariant> > groups() const;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The file-item for the index \a index. If the index is in a valid
|
* @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
|
* URL is found KFileItem::isNull() will be true for the returned
|
||||||
* file-item. The runtime complexity of this call is O(1).
|
* 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
|
* @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
|
* @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).
|
* 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
|
* @return Root item of all items representing the item
|
||||||
|
@ -158,24 +154,24 @@ public:
|
||||||
void setRoles(const QSet<QByteArray>& roles);
|
void setRoles(const QSet<QByteArray>& roles);
|
||||||
QSet<QByteArray> roles() const;
|
QSet<QByteArray> roles() const;
|
||||||
|
|
||||||
virtual bool setExpanded(int index, bool expanded);
|
virtual bool setExpanded(int index, bool expanded) Q_DECL_OVERRIDE;
|
||||||
virtual bool isExpanded(int index) const;
|
virtual bool isExpanded(int index) const Q_DECL_OVERRIDE;
|
||||||
virtual bool isExpandable(int index) const;
|
virtual bool isExpandable(int index) const Q_DECL_OVERRIDE;
|
||||||
virtual int expandedParentsCount(int index) const;
|
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.
|
* Marks the URLs in \a urls as sub-directories which were expanded previously.
|
||||||
* After calling loadDirectory() or refreshDirectory() the marked sub-directories
|
* After calling loadDirectory() or refreshDirectory() the marked sub-directories
|
||||||
* will be expanded step-by-step.
|
* 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.
|
* Expands all parent-directories of the item \a url.
|
||||||
*/
|
*/
|
||||||
void expandParentDirectories(const KUrl& url);
|
void expandParentDirectories(const QUrl& url);
|
||||||
|
|
||||||
void setNameFilter(const QString& nameFilter);
|
void setNameFilter(const QString& nameFilter);
|
||||||
QString nameFilter() const;
|
QString nameFilter() const;
|
||||||
|
@ -251,18 +247,18 @@ signals:
|
||||||
* Is emitted if a redirection from the current URL \a oldUrl
|
* Is emitted if a redirection from the current URL \a oldUrl
|
||||||
* to the new URL \a newUrl has been done.
|
* 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.
|
* Is emitted when the URL passed by KFileItemModel::setUrl() represents a file.
|
||||||
* In this case no signal errorMessage() will be emitted.
|
* In this case no signal errorMessage() will be emitted.
|
||||||
*/
|
*/
|
||||||
void urlIsFileError(const KUrl& url);
|
void urlIsFileError(const QUrl& url);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void onGroupedSortingChanged(bool current);
|
virtual void onGroupedSortingChanged(bool current) Q_DECL_OVERRIDE;
|
||||||
virtual void onSortRoleChanged(const QByteArray& current, const QByteArray& previous);
|
virtual void onSortRoleChanged(const QByteArray& current, const QByteArray& previous) Q_DECL_OVERRIDE;
|
||||||
virtual void onSortOrderChanged(Qt::SortOrder current, Qt::SortOrder previous);
|
virtual void onSortOrderChanged(Qt::SortOrder current, Qt::SortOrder previous) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
/**
|
/**
|
||||||
|
@ -273,7 +269,7 @@ private slots:
|
||||||
|
|
||||||
void slotCompleted();
|
void slotCompleted();
|
||||||
void slotCanceled();
|
void slotCanceled();
|
||||||
void slotItemsAdded(const KUrl& directoryUrl, const KFileItemList& items);
|
void slotItemsAdded(const QUrl& directoryUrl, const KFileItemList& items);
|
||||||
void slotItemsDeleted(const KFileItemList& items);
|
void slotItemsDeleted(const KFileItemList& items);
|
||||||
void slotRefreshItems(const QList<QPair<KFileItem, KFileItem> >& items);
|
void slotRefreshItems(const QList<QPair<KFileItem, KFileItem> >& items);
|
||||||
void slotClear();
|
void slotClear();
|
||||||
|
@ -317,7 +313,7 @@ private:
|
||||||
* Note that the ItemData instances are created dynamically and
|
* Note that the ItemData instances are created dynamically and
|
||||||
* must be deleted by the caller.
|
* 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
|
* 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
|
* @return True if the item-data \a a should be ordered before the item-data
|
||||||
* \b. The item-data may have different parent-items.
|
* \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
|
* 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
|
* the passed item-data using m_sortRole as criteria. Both items must
|
||||||
* have the same parent item, otherwise the comparison will be wrong.
|
* 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;
|
bool useMaximumUpdateInterval() const;
|
||||||
|
|
||||||
|
@ -460,21 +456,21 @@ private:
|
||||||
private:
|
private:
|
||||||
KFileItemModelDirLister* m_dirLister;
|
KFileItemModelDirLister* m_dirLister;
|
||||||
|
|
||||||
|
QCollator m_collator;
|
||||||
bool m_naturalSorting;
|
bool m_naturalSorting;
|
||||||
bool m_sortDirsFirst;
|
bool m_sortDirsFirst;
|
||||||
|
|
||||||
RoleType m_sortRole;
|
RoleType m_sortRole;
|
||||||
int m_sortingProgressPercent; // Value of directorySortingProgress() signal
|
int m_sortingProgressPercent; // Value of directorySortingProgress() signal
|
||||||
QSet<QByteArray> m_roles;
|
QSet<QByteArray> m_roles;
|
||||||
Qt::CaseSensitivity m_caseSensitivity;
|
|
||||||
|
|
||||||
QList<ItemData*> m_itemData;
|
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
|
// 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)
|
// the model, i.e., that (for every i between 0 and N - 1)
|
||||||
// m_items.value(fileItem(i).url()) == i
|
// m_items.value(fileItem(i).url()) == i
|
||||||
mutable QHash<KUrl, int> m_items;
|
mutable QHash<QUrl, int> m_items;
|
||||||
|
|
||||||
KFileItemModelFilter m_filter;
|
KFileItemModelFilter m_filter;
|
||||||
QHash<KFileItem, ItemData*> m_filteredItems; // Items that got hidden by KFileItemModel::setNameFilter()
|
QHash<KFileItem, ItemData*> m_filteredItems; // Items that got hidden by KFileItemModel::setNameFilter()
|
||||||
|
@ -489,11 +485,11 @@ private:
|
||||||
mutable QList<QPair<int, QVariant> > m_groups;
|
mutable QList<QPair<int, QVariant> > m_groups;
|
||||||
|
|
||||||
// Stores the URLs (key: target url, value: url) of the expanded directories.
|
// 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()
|
// URLs that must be expanded. The expanding is initially triggered in setExpanded()
|
||||||
// and done step after step in slotCompleted().
|
// and done step after step in slotCompleted().
|
||||||
QSet<KUrl> m_urlsToExpand;
|
QSet<QUrl> m_urlsToExpand;
|
||||||
|
|
||||||
friend class KFileItemModelLessThan; // Accesses lessThan() method
|
friend class KFileItemModelLessThan; // Accesses lessThan() method
|
||||||
friend class KFileItemModelRolesUpdater; // Accesses emitSortProgress() method
|
friend class KFileItemModelRolesUpdater; // Accesses emitSortProgress() method
|
||||||
|
|
|
@ -23,9 +23,10 @@
|
||||||
|
|
||||||
#include <KConfig>
|
#include <KConfig>
|
||||||
#include <KConfigGroup>
|
#include <KConfigGroup>
|
||||||
#include <KDebug>
|
#include <KSharedConfig>
|
||||||
#include <KFileItem>
|
#include <KFileItem>
|
||||||
#include <KGlobal>
|
#include <KIconLoader>
|
||||||
|
#include <KJobWidgets>
|
||||||
#include <KIO/JobUiDelegate>
|
#include <KIO/JobUiDelegate>
|
||||||
#include <KIO/PreviewJob>
|
#include <KIO/PreviewJob>
|
||||||
|
|
||||||
|
@ -42,9 +43,8 @@
|
||||||
|
|
||||||
#ifdef HAVE_BALOO
|
#ifdef HAVE_BALOO
|
||||||
#include "private/kbaloorolesprovider.h"
|
#include "private/kbaloorolesprovider.h"
|
||||||
#include <baloo/file.h>
|
#include <Baloo/File>
|
||||||
#include <baloo/filefetchjob.h>
|
#include <Baloo/FileMonitor>
|
||||||
#include <baloo/filemonitor.h>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// #define KFILEITEMMODELROLESUPDATER_DEBUG
|
// #define KFILEITEMMODELROLESUPDATER_DEBUG
|
||||||
|
@ -95,29 +95,29 @@ KFileItemModelRolesUpdater::KFileItemModelRolesUpdater(KFileItemModel* model, QO
|
||||||
{
|
{
|
||||||
Q_ASSERT(model);
|
Q_ASSERT(model);
|
||||||
|
|
||||||
const KConfigGroup globalConfig(KGlobal::config(), "PreviewSettings");
|
const KConfigGroup globalConfig(KSharedConfig::openConfig(), "PreviewSettings");
|
||||||
m_enabledPlugins = globalConfig.readEntry("Plugins", QStringList()
|
m_enabledPlugins = globalConfig.readEntry("Plugins", QStringList()
|
||||||
<< "directorythumbnail"
|
<< "directorythumbnail"
|
||||||
<< "imagethumbnail"
|
<< "imagethumbnail"
|
||||||
<< "jpegthumbnail");
|
<< "jpegthumbnail");
|
||||||
|
|
||||||
connect(m_model, SIGNAL(itemsInserted(KItemRangeList)),
|
connect(m_model, &KFileItemModel::itemsInserted,
|
||||||
this, SLOT(slotItemsInserted(KItemRangeList)));
|
this, &KFileItemModelRolesUpdater::slotItemsInserted);
|
||||||
connect(m_model, SIGNAL(itemsRemoved(KItemRangeList)),
|
connect(m_model, &KFileItemModel::itemsRemoved,
|
||||||
this, SLOT(slotItemsRemoved(KItemRangeList)));
|
this, &KFileItemModelRolesUpdater::slotItemsRemoved);
|
||||||
connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
|
connect(m_model, &KFileItemModel::itemsChanged,
|
||||||
this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
|
this, &KFileItemModelRolesUpdater::slotItemsChanged);
|
||||||
connect(m_model, SIGNAL(itemsMoved(KItemRange,QList<int>)),
|
connect(m_model, &KFileItemModel::itemsMoved,
|
||||||
this, SLOT(slotItemsMoved(KItemRange,QList<int>)));
|
this, &KFileItemModelRolesUpdater::slotItemsMoved);
|
||||||
connect(m_model, SIGNAL(sortRoleChanged(QByteArray,QByteArray)),
|
connect(m_model, &KFileItemModel::sortRoleChanged,
|
||||||
this, SLOT(slotSortRoleChanged(QByteArray,QByteArray)));
|
this, &KFileItemModelRolesUpdater::slotSortRoleChanged);
|
||||||
|
|
||||||
// Use a timer to prevent that each call of slotItemsChanged() results in a synchronous
|
// 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.
|
// resolving of the roles. Postpone the resolving until no update has been done for 1 second.
|
||||||
m_recentlyChangedItemsTimer = new QTimer(this);
|
m_recentlyChangedItemsTimer = new QTimer(this);
|
||||||
m_recentlyChangedItemsTimer->setInterval(1000);
|
m_recentlyChangedItemsTimer->setInterval(1000);
|
||||||
m_recentlyChangedItemsTimer->setSingleShot(true);
|
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("size");
|
||||||
m_resolvableRoles.insert("type");
|
m_resolvableRoles.insert("type");
|
||||||
|
@ -127,8 +127,8 @@ KFileItemModelRolesUpdater::KFileItemModelRolesUpdater(KFileItemModel* model, QO
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_directoryContentsCounter = new KDirectoryContentsCounter(m_model, this);
|
m_directoryContentsCounter = new KDirectoryContentsCounter(m_model, this);
|
||||||
connect(m_directoryContentsCounter, SIGNAL(result(QString,int)),
|
connect(m_directoryContentsCounter, &KDirectoryContentsCounter::result,
|
||||||
this, SLOT(slotDirectoryContentsCountReceived(QString,int)));
|
this, &KFileItemModelRolesUpdater::slotDirectoryContentsCountReceived);
|
||||||
}
|
}
|
||||||
|
|
||||||
KFileItemModelRolesUpdater::~KFileItemModelRolesUpdater()
|
KFileItemModelRolesUpdater::~KFileItemModelRolesUpdater()
|
||||||
|
@ -280,8 +280,8 @@ void KFileItemModelRolesUpdater::setRoles(const QSet<QByteArray>& roles)
|
||||||
|
|
||||||
if (hasBalooRole && !m_balooFileMonitor) {
|
if (hasBalooRole && !m_balooFileMonitor) {
|
||||||
m_balooFileMonitor = new Baloo::FileMonitor(this);
|
m_balooFileMonitor = new Baloo::FileMonitor(this);
|
||||||
connect(m_balooFileMonitor, SIGNAL(fileMetaDataChanged(QString)),
|
connect(m_balooFileMonitor, &Baloo::FileMonitor::fileMetaDataChanged,
|
||||||
this, SLOT(applyChangedBalooRoles(QString)));
|
this, &KFileItemModelRolesUpdater::applyChangedBalooRoles);
|
||||||
} else if (!hasBalooRole && m_balooFileMonitor) {
|
} else if (!hasBalooRole && m_balooFileMonitor) {
|
||||||
delete m_balooFileMonitor;
|
delete m_balooFileMonitor;
|
||||||
m_balooFileMonitor = 0;
|
m_balooFileMonitor = 0;
|
||||||
|
@ -543,11 +543,11 @@ void KFileItemModelRolesUpdater::slotGotPreview(const KFileItem& item, const QPi
|
||||||
|
|
||||||
data.insert("iconPixmap", scaledPixmap);
|
data.insert("iconPixmap", scaledPixmap);
|
||||||
|
|
||||||
disconnect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
|
disconnect(m_model, &KFileItemModel::itemsChanged,
|
||||||
this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
|
this, &KFileItemModelRolesUpdater::slotItemsChanged);
|
||||||
m_model->setData(index, data);
|
m_model->setData(index, data);
|
||||||
connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
|
connect(m_model, &KFileItemModel::itemsChanged,
|
||||||
this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
|
this, &KFileItemModelRolesUpdater::slotItemsChanged);
|
||||||
|
|
||||||
m_finishedItems.insert(item);
|
m_finishedItems.insert(item);
|
||||||
}
|
}
|
||||||
|
@ -565,11 +565,11 @@ void KFileItemModelRolesUpdater::slotPreviewFailed(const KFileItem& item)
|
||||||
QHash<QByteArray, QVariant> data;
|
QHash<QByteArray, QVariant> data;
|
||||||
data.insert("iconPixmap", QPixmap());
|
data.insert("iconPixmap", QPixmap());
|
||||||
|
|
||||||
disconnect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
|
disconnect(m_model, &KFileItemModel::itemsChanged,
|
||||||
this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
|
this, &KFileItemModelRolesUpdater::slotItemsChanged);
|
||||||
m_model->setData(index, data);
|
m_model->setData(index, data);
|
||||||
connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
|
connect(m_model, &KFileItemModel::itemsChanged,
|
||||||
this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
|
this, &KFileItemModelRolesUpdater::slotItemsChanged);
|
||||||
|
|
||||||
applyResolvedRoles(index, ResolveAll);
|
applyResolvedRoles(index, ResolveAll);
|
||||||
m_finishedItems.insert(item);
|
m_finishedItems.insert(item);
|
||||||
|
@ -625,11 +625,11 @@ void KFileItemModelRolesUpdater::resolveNextSortRole()
|
||||||
m_state = Idle;
|
m_state = Idle;
|
||||||
|
|
||||||
// Prevent that we try to update the items twice.
|
// Prevent that we try to update the items twice.
|
||||||
disconnect(m_model, SIGNAL(itemsMoved(KItemRange,QList<int>)),
|
disconnect(m_model, &KFileItemModel::itemsMoved,
|
||||||
this, SLOT(slotItemsMoved(KItemRange,QList<int>)));
|
this, &KFileItemModelRolesUpdater::slotItemsMoved);
|
||||||
applySortProgressToModel();
|
applySortProgressToModel();
|
||||||
connect(m_model, SIGNAL(itemsMoved(KItemRange,QList<int>)),
|
connect(m_model, &KFileItemModel::itemsMoved,
|
||||||
this, SLOT(slotItemsMoved(KItemRange,QList<int>)));
|
this, &KFileItemModelRolesUpdater::slotItemsMoved);
|
||||||
startUpdating();
|
startUpdating();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -665,15 +665,15 @@ void KFileItemModelRolesUpdater::resolveNextPendingRoles()
|
||||||
QHash<QByteArray, QVariant> data;
|
QHash<QByteArray, QVariant> data;
|
||||||
data.insert("iconPixmap", QPixmap());
|
data.insert("iconPixmap", QPixmap());
|
||||||
|
|
||||||
disconnect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
|
disconnect(m_model, &KFileItemModel::itemsChanged,
|
||||||
this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
|
this, &KFileItemModelRolesUpdater::slotItemsChanged);
|
||||||
for (int index = 0; index <= m_model->count(); ++index) {
|
for (int index = 0; index <= m_model->count(); ++index) {
|
||||||
if (m_model->data(index).contains("iconPixmap")) {
|
if (m_model->data(index).contains("iconPixmap")) {
|
||||||
m_model->setData(index, data);
|
m_model->setData(index, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
|
connect(m_model, &KFileItemModel::itemsChanged,
|
||||||
this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
|
this, &KFileItemModelRolesUpdater::slotItemsChanged);
|
||||||
|
|
||||||
}
|
}
|
||||||
m_clearPreviews = false;
|
m_clearPreviews = false;
|
||||||
|
@ -703,21 +703,8 @@ void KFileItemModelRolesUpdater::applyChangedBalooRoles(const QString& itemUrl)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Baloo::FileFetchJob* job = new Baloo::FileFetchJob(item.localPath());
|
Baloo::File file(item.localPath());
|
||||||
connect(job, SIGNAL(finished(KJob*)), this, SLOT(applyChangedBalooRolesJobFinished(KJob*)));
|
file.load();
|
||||||
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>();
|
|
||||||
|
|
||||||
const KBalooRolesProvider& rolesProvider = KBalooRolesProvider::instance();
|
const KBalooRolesProvider& rolesProvider = KBalooRolesProvider::instance();
|
||||||
QHash<QByteArray, QVariant> data;
|
QHash<QByteArray, QVariant> data;
|
||||||
|
@ -729,19 +716,22 @@ void KFileItemModelRolesUpdater::applyChangedBalooRolesJobFinished(KJob* kjob)
|
||||||
data.insert(role, QVariant());
|
data.insert(role, QVariant());
|
||||||
}
|
}
|
||||||
|
|
||||||
Baloo::FileFetchJob* job = static_cast<Baloo::FileFetchJob*>(kjob);
|
QHashIterator<QByteArray, QVariant> it(rolesProvider.roleValues(file, m_roles));
|
||||||
QHashIterator<QByteArray, QVariant> it(rolesProvider.roleValues(job->file(), m_roles));
|
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
it.next();
|
it.next();
|
||||||
data.insert(it.key(), it.value());
|
data.insert(it.key(), it.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
disconnect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
|
disconnect(m_model, &KFileItemModel::itemsChanged,
|
||||||
this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
|
this, &KFileItemModelRolesUpdater::slotItemsChanged);
|
||||||
const int index = m_model->index(item);
|
const int index = m_model->index(item);
|
||||||
m_model->setData(index, data);
|
m_model->setData(index, data);
|
||||||
connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
|
connect(m_model, &KFileItemModel::itemsChanged,
|
||||||
this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
|
this, &KFileItemModelRolesUpdater::slotItemsChanged);
|
||||||
|
#else
|
||||||
|
#ifndef Q_CC_MSVC
|
||||||
|
Q_UNUSED(itemUrl);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -751,7 +741,7 @@ void KFileItemModelRolesUpdater::slotDirectoryContentsCountReceived(const QStrin
|
||||||
const bool getIsExpandableRole = m_roles.contains("isExpandable");
|
const bool getIsExpandableRole = m_roles.contains("isExpandable");
|
||||||
|
|
||||||
if (getSizeRole || getIsExpandableRole) {
|
if (getSizeRole || getIsExpandableRole) {
|
||||||
const int index = m_model->index(KUrl(path));
|
const int index = m_model->index(QUrl::fromLocalFile(path));
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
QHash<QByteArray, QVariant> data;
|
QHash<QByteArray, QVariant> data;
|
||||||
|
|
||||||
|
@ -762,11 +752,11 @@ void KFileItemModelRolesUpdater::slotDirectoryContentsCountReceived(const QStrin
|
||||||
data.insert("isExpandable", count > 0);
|
data.insert("isExpandable", count > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
disconnect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
|
disconnect(m_model, &KFileItemModel::itemsChanged,
|
||||||
this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
|
this, &KFileItemModelRolesUpdater::slotItemsChanged);
|
||||||
m_model->setData(index, data);
|
m_model->setData(index, data);
|
||||||
connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
|
connect(m_model, &KFileItemModel::itemsChanged,
|
||||||
this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
|
this, &KFileItemModelRolesUpdater::slotItemsChanged);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -897,15 +887,15 @@ void KFileItemModelRolesUpdater::startPreviewJob()
|
||||||
|
|
||||||
job->setIgnoreMaximumSize(itemSubSet.first().isLocalFile());
|
job->setIgnoreMaximumSize(itemSubSet.first().isLocalFile());
|
||||||
if (job->ui()) {
|
if (job->ui()) {
|
||||||
job->ui()->setWindow(qApp->activeWindow());
|
KJobWidgets::setWindow(job, qApp->activeWindow());
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(job, SIGNAL(gotPreview(KFileItem,QPixmap)),
|
connect(job, &KIO::PreviewJob::gotPreview,
|
||||||
this, SLOT(slotGotPreview(KFileItem,QPixmap)));
|
this, &KFileItemModelRolesUpdater::slotGotPreview);
|
||||||
connect(job, SIGNAL(failed(KFileItem)),
|
connect(job, &KIO::PreviewJob::failed,
|
||||||
this, SLOT(slotPreviewFailed(KFileItem)));
|
this, &KFileItemModelRolesUpdater::slotPreviewFailed);
|
||||||
connect(job, SIGNAL(finished(KJob*)),
|
connect(job, &KIO::PreviewJob::finished,
|
||||||
this, SLOT(slotPreviewJobFinished()));
|
this, &KFileItemModelRolesUpdater::slotPreviewJobFinished);
|
||||||
|
|
||||||
m_previewJob = job;
|
m_previewJob = job;
|
||||||
}
|
}
|
||||||
|
@ -998,11 +988,11 @@ void KFileItemModelRolesUpdater::applySortRole(int index)
|
||||||
data = rolesData(item);
|
data = rolesData(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
disconnect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
|
disconnect(m_model, &KFileItemModel::itemsChanged,
|
||||||
this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
|
this, &KFileItemModelRolesUpdater::slotItemsChanged);
|
||||||
m_model->setData(index, data);
|
m_model->setData(index, data);
|
||||||
connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
|
connect(m_model, &KFileItemModel::itemsChanged,
|
||||||
this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
|
this, &KFileItemModelRolesUpdater::slotItemsChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KFileItemModelRolesUpdater::applySortProgressToModel()
|
void KFileItemModelRolesUpdater::applySortProgressToModel()
|
||||||
|
@ -1042,11 +1032,11 @@ bool KFileItemModelRolesUpdater::applyResolvedRoles(int index, ResolveHint hint)
|
||||||
data.insert("iconPixmap", QPixmap());
|
data.insert("iconPixmap", QPixmap());
|
||||||
}
|
}
|
||||||
|
|
||||||
disconnect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
|
disconnect(m_model, &KFileItemModel::itemsChanged,
|
||||||
this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
|
this, &KFileItemModelRolesUpdater::slotItemsChanged);
|
||||||
m_model->setData(index, data);
|
m_model->setData(index, data);
|
||||||
connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
|
connect(m_model, &KFileItemModel::itemsChanged,
|
||||||
this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
|
this, &KFileItemModelRolesUpdater::slotItemsChanged);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1099,12 +1089,12 @@ void KFileItemModelRolesUpdater::updateAllPreviews()
|
||||||
void KFileItemModelRolesUpdater::killPreviewJob()
|
void KFileItemModelRolesUpdater::killPreviewJob()
|
||||||
{
|
{
|
||||||
if (m_previewJob) {
|
if (m_previewJob) {
|
||||||
disconnect(m_previewJob, SIGNAL(gotPreview(KFileItem,QPixmap)),
|
disconnect(m_previewJob, &KIO::PreviewJob::gotPreview,
|
||||||
this, SLOT(slotGotPreview(KFileItem,QPixmap)));
|
this, &KFileItemModelRolesUpdater::slotGotPreview);
|
||||||
disconnect(m_previewJob, SIGNAL(failed(KFileItem)),
|
disconnect(m_previewJob, &KIO::PreviewJob::failed,
|
||||||
this, SLOT(slotPreviewFailed(KFileItem)));
|
this, &KFileItemModelRolesUpdater::slotPreviewFailed);
|
||||||
disconnect(m_previewJob, SIGNAL(finished(KJob*)),
|
disconnect(m_previewJob, &KIO::PreviewJob::finished,
|
||||||
this, SLOT(slotPreviewJobFinished()));
|
this, &KFileItemModelRolesUpdater::slotPreviewJobFinished);
|
||||||
m_previewJob->kill();
|
m_previewJob->kill();
|
||||||
m_previewJob = 0;
|
m_previewJob = 0;
|
||||||
m_pendingPreviewItems.clear();
|
m_pendingPreviewItems.clear();
|
||||||
|
@ -1168,4 +1158,3 @@ QList<int> KFileItemModelRolesUpdater::indexesToResolve() const
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "kfileitemmodelrolesupdater.moc"
|
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#include <KFileItem>
|
#include <KFileItem>
|
||||||
#include <kitemviews/kitemmodelbase.h>
|
#include <kitemviews/kitemmodelbase.h>
|
||||||
|
|
||||||
#include <libdolphin_export.h>
|
#include "dolphin_export.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
|
@ -34,10 +34,13 @@
|
||||||
|
|
||||||
class KDirectoryContentsCounter;
|
class KDirectoryContentsCounter;
|
||||||
class KFileItemModel;
|
class KFileItemModel;
|
||||||
class KJob;
|
|
||||||
class QPixmap;
|
class QPixmap;
|
||||||
class QTimer;
|
class QTimer;
|
||||||
|
|
||||||
|
namespace KIO {
|
||||||
|
class PreviewJob;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_BALOO
|
#ifdef HAVE_BALOO
|
||||||
namespace Baloo
|
namespace Baloo
|
||||||
{
|
{
|
||||||
|
@ -84,7 +87,7 @@ class QTimer;
|
||||||
* 3. Finally, the entire process is repeated for any items that might have
|
* 3. Finally, the entire process is repeated for any items that might have
|
||||||
* changed in the mean time.
|
* changed in the mean time.
|
||||||
*/
|
*/
|
||||||
class LIBDOLPHINPRIVATE_EXPORT KFileItemModelRolesUpdater : public QObject
|
class DOLPHIN_EXPORT KFileItemModelRolesUpdater : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -201,7 +204,6 @@ private slots:
|
||||||
void resolveRecentlyChangedItems();
|
void resolveRecentlyChangedItems();
|
||||||
|
|
||||||
void applyChangedBalooRoles(const QString& file);
|
void applyChangedBalooRoles(const QString& file);
|
||||||
void applyChangedBalooRolesJobFinished(KJob* job);
|
|
||||||
|
|
||||||
void slotDirectoryContentsCountReceived(const QString& path, int count);
|
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.
|
// A new preview job will be started from them once the first one finishes.
|
||||||
KFileItemList m_pendingPreviewItems;
|
KFileItemList m_pendingPreviewItems;
|
||||||
|
|
||||||
KJob* m_previewJob;
|
KIO::PreviewJob* m_previewJob;
|
||||||
|
|
||||||
// When downloading or copying large files, the slot slotItemsChanged()
|
// When downloading or copying large files, the slot slotItemsChanged()
|
||||||
// will be called periodically within a quite short delay. To prevent
|
// will be called periodically within a quite short delay. To prevent
|
||||||
|
|
|
@ -31,12 +31,10 @@
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QGraphicsScene>
|
#include <QGraphicsScene>
|
||||||
#include <QGraphicsView>
|
#include <QGraphicsView>
|
||||||
#include <QPropertyAnimation>
|
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
#include <QStyle>
|
#include <QStyle>
|
||||||
#include <QStyleOption>
|
#include <QStyleOption>
|
||||||
|
|
||||||
#include <KDebug>
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replaces the default viewport of KItemListContainer by a
|
* Replaces the default viewport of KItemListContainer by a
|
||||||
|
@ -89,10 +87,10 @@ KItemListContainer::KItemListContainer(KItemListController* controller, QWidget*
|
||||||
slotViewChanged(controller->view(), 0);
|
slotViewChanged(controller->view(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(controller, SIGNAL(modelChanged(KItemModelBase*,KItemModelBase*)),
|
connect(controller, &KItemListController::modelChanged,
|
||||||
this, SLOT(slotModelChanged(KItemModelBase*,KItemModelBase*)));
|
this, &KItemListContainer::slotModelChanged);
|
||||||
connect(controller, SIGNAL(viewChanged(KItemListView*,KItemListView*)),
|
connect(controller, &KItemListController::viewChanged,
|
||||||
this, SLOT(slotViewChanged(KItemListView*,KItemListView*)));
|
this, &KItemListContainer::slotViewChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
KItemListContainer::~KItemListContainer()
|
KItemListContainer::~KItemListContainer()
|
||||||
|
@ -185,11 +183,15 @@ void KItemListContainer::wheelEvent(QWheelEvent* event)
|
||||||
KItemListSmoothScroller* smoothScroller = scrollHorizontally ?
|
KItemListSmoothScroller* smoothScroller = scrollHorizontally ?
|
||||||
m_horizontalSmoothScroller : m_verticalSmoothScroller;
|
m_horizontalSmoothScroller : m_verticalSmoothScroller;
|
||||||
|
|
||||||
const int numDegrees = event->delta() / 8;
|
|
||||||
const int numSteps = numDegrees / 15;
|
|
||||||
|
|
||||||
const QScrollBar* scrollBar = smoothScroller->scrollBar();
|
const QScrollBar* scrollBar = smoothScroller->scrollBar();
|
||||||
|
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);
|
smoothScroller->scrollTo(scrollBar->value() - numSteps * scrollBar->pageStep() / 4);
|
||||||
|
}
|
||||||
|
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
@ -211,23 +213,33 @@ void KItemListContainer::slotViewChanged(KItemListView* current, KItemListView*
|
||||||
QGraphicsScene* scene = static_cast<QGraphicsView*>(viewport())->scene();
|
QGraphicsScene* scene = static_cast<QGraphicsView*>(viewport())->scene();
|
||||||
if (previous) {
|
if (previous) {
|
||||||
scene->removeItem(previous);
|
scene->removeItem(previous);
|
||||||
disconnect(previous, SIGNAL(scrollOrientationChanged(Qt::Orientation,Qt::Orientation)), this, SLOT(slotScrollOrientationChanged(Qt::Orientation,Qt::Orientation)));
|
disconnect(previous, &KItemListView::scrollOrientationChanged,
|
||||||
disconnect(previous, SIGNAL(scrollOffsetChanged(qreal,qreal)), this, SLOT(updateScrollOffsetScrollBar()));
|
this, &KItemListContainer::slotScrollOrientationChanged);
|
||||||
disconnect(previous, SIGNAL(maximumScrollOffsetChanged(qreal,qreal)), this, SLOT(updateScrollOffsetScrollBar()));
|
disconnect(previous, &KItemListView::scrollOffsetChanged,
|
||||||
disconnect(previous, SIGNAL(itemOffsetChanged(qreal,qreal)), this, SLOT(updateItemOffsetScrollBar()));
|
this, &KItemListContainer::updateScrollOffsetScrollBar);
|
||||||
disconnect(previous, SIGNAL(maximumItemOffsetChanged(qreal,qreal)), this, SLOT(updateItemOffsetScrollBar()));
|
disconnect(previous, &KItemListView::maximumScrollOffsetChanged,
|
||||||
disconnect(previous, SIGNAL(scrollTo(qreal)), this, SLOT(scrollTo(qreal)));
|
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_horizontalSmoothScroller->setTargetObject(0);
|
||||||
m_verticalSmoothScroller->setTargetObject(0);
|
m_verticalSmoothScroller->setTargetObject(0);
|
||||||
}
|
}
|
||||||
if (current) {
|
if (current) {
|
||||||
scene->addItem(current);
|
scene->addItem(current);
|
||||||
connect(current, SIGNAL(scrollOrientationChanged(Qt::Orientation,Qt::Orientation)), this, SLOT(slotScrollOrientationChanged(Qt::Orientation,Qt::Orientation)));
|
connect(current, &KItemListView::scrollOrientationChanged,
|
||||||
connect(current, SIGNAL(scrollOffsetChanged(qreal,qreal)), this, SLOT(updateScrollOffsetScrollBar()));
|
this, &KItemListContainer::slotScrollOrientationChanged);
|
||||||
connect(current, SIGNAL(maximumScrollOffsetChanged(qreal,qreal)), this, SLOT(updateScrollOffsetScrollBar()));
|
connect(current, &KItemListView::scrollOffsetChanged,
|
||||||
connect(current, SIGNAL(itemOffsetChanged(qreal,qreal)), this, SLOT(updateItemOffsetScrollBar()));
|
this, &KItemListContainer::updateScrollOffsetScrollBar);
|
||||||
connect(current, SIGNAL(maximumItemOffsetChanged(qreal,qreal)), this, SLOT(updateItemOffsetScrollBar()));
|
connect(current, &KItemListView::maximumScrollOffsetChanged,
|
||||||
connect(current, SIGNAL(scrollTo(qreal)), this, SLOT(scrollTo(qreal)));
|
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_horizontalSmoothScroller->setTargetObject(current);
|
||||||
m_verticalSmoothScroller->setTargetObject(current);
|
m_verticalSmoothScroller->setTargetObject(current);
|
||||||
updateSmoothScrollers(current->scrollOrientation());
|
updateSmoothScrollers(current->scrollOrientation());
|
||||||
|
@ -403,4 +415,3 @@ void KItemListContainer::updateScrollOffsetScrollBarPolicy()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "kitemlistcontainer.moc"
|
|
||||||
|
|
|
@ -23,16 +23,14 @@
|
||||||
#ifndef KITEMLISTCONTAINER_H
|
#ifndef KITEMLISTCONTAINER_H
|
||||||
#define KITEMLISTCONTAINER_H
|
#define KITEMLISTCONTAINER_H
|
||||||
|
|
||||||
#include <libdolphin_export.h>
|
#include "dolphin_export.h"
|
||||||
|
|
||||||
#include <QAbstractAnimation>
|
|
||||||
#include <QAbstractScrollArea>
|
#include <QAbstractScrollArea>
|
||||||
|
|
||||||
class KItemListController;
|
class KItemListController;
|
||||||
class KItemListSmoothScroller;
|
class KItemListSmoothScroller;
|
||||||
class KItemListView;
|
class KItemListView;
|
||||||
class KItemModelBase;
|
class KItemModelBase;
|
||||||
class QPropertyAnimation;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Provides a QWidget based scrolling view for a KItemListController.
|
* @brief Provides a QWidget based scrolling view for a KItemListController.
|
||||||
|
@ -41,7 +39,7 @@ class QPropertyAnimation;
|
||||||
*
|
*
|
||||||
* @see KItemListController
|
* @see KItemListController
|
||||||
*/
|
*/
|
||||||
class LIBDOLPHINPRIVATE_EXPORT KItemListContainer : public QAbstractScrollArea
|
class DOLPHIN_EXPORT KItemListContainer : public QAbstractScrollArea
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -60,11 +58,11 @@ public:
|
||||||
bool enabledFrame() const;
|
bool enabledFrame() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void keyPressEvent(QKeyEvent* event);
|
virtual void keyPressEvent(QKeyEvent* event) Q_DECL_OVERRIDE;
|
||||||
virtual void showEvent(QShowEvent* event);
|
virtual void showEvent(QShowEvent* event) Q_DECL_OVERRIDE;
|
||||||
virtual void resizeEvent(QResizeEvent* event);
|
virtual void resizeEvent(QResizeEvent* event) Q_DECL_OVERRIDE;
|
||||||
virtual void scrollContentsBy(int dx, int dy);
|
virtual void scrollContentsBy(int dx, int dy) Q_DECL_OVERRIDE;
|
||||||
virtual void wheelEvent(QWheelEvent* event);
|
virtual void wheelEvent(QWheelEvent* event) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void slotScrollOrientationChanged(Qt::Orientation current, Qt::Orientation previous);
|
void slotScrollOrientationChanged(Qt::Orientation current, Qt::Orientation previous);
|
||||||
|
|
|
@ -23,8 +23,6 @@
|
||||||
|
|
||||||
#include "kitemlistcontroller.h"
|
#include "kitemlistcontroller.h"
|
||||||
|
|
||||||
#include <KGlobalSettings>
|
|
||||||
#include <KDebug>
|
|
||||||
|
|
||||||
#include "kitemlistview.h"
|
#include "kitemlistview.h"
|
||||||
#include "kitemlistselectionmanager.h"
|
#include "kitemlistselectionmanager.h"
|
||||||
|
@ -61,15 +59,15 @@ KItemListController::KItemListController(KItemModelBase* model, KItemListView* v
|
||||||
m_keyboardAnchorIndex(-1),
|
m_keyboardAnchorIndex(-1),
|
||||||
m_keyboardAnchorPos(0)
|
m_keyboardAnchorPos(0)
|
||||||
{
|
{
|
||||||
connect(m_keyboardManager, SIGNAL(changeCurrentItem(QString,bool)),
|
connect(m_keyboardManager, &KItemListKeyboardSearchManager::changeCurrentItem,
|
||||||
this, SLOT(slotChangeCurrentItem(QString,bool)));
|
this, &KItemListController::slotChangeCurrentItem);
|
||||||
connect(m_selectionManager, SIGNAL(currentChanged(int,int)),
|
connect(m_selectionManager, &KItemListSelectionManager::currentChanged,
|
||||||
m_keyboardManager, SLOT(slotCurrentChanged(int,int)));
|
m_keyboardManager, &KItemListKeyboardSearchManager::slotCurrentChanged);
|
||||||
|
|
||||||
m_autoActivationTimer = new QTimer(this);
|
m_autoActivationTimer = new QTimer(this);
|
||||||
m_autoActivationTimer->setSingleShot(true);
|
m_autoActivationTimer->setSingleShot(true);
|
||||||
m_autoActivationTimer->setInterval(-1);
|
m_autoActivationTimer->setInterval(-1);
|
||||||
connect(m_autoActivationTimer, SIGNAL(timeout()), this, SLOT(slotAutoActivationTimeout()));
|
connect(m_autoActivationTimer, &QTimer::timeout, this, &KItemListController::slotAutoActivationTimeout);
|
||||||
|
|
||||||
setModel(model);
|
setModel(model);
|
||||||
setView(view);
|
setView(view);
|
||||||
|
@ -127,7 +125,7 @@ void KItemListController::setView(KItemListView* view)
|
||||||
|
|
||||||
KItemListView* oldView = m_view;
|
KItemListView* oldView = m_view;
|
||||||
if (oldView) {
|
if (oldView) {
|
||||||
disconnect(oldView, SIGNAL(scrollOffsetChanged(qreal,qreal)), this, SLOT(slotViewScrollOffsetChanged(qreal,qreal)));
|
disconnect(oldView, &KItemListView::scrollOffsetChanged, this, &KItemListController::slotViewScrollOffsetChanged);
|
||||||
oldView->deleteLater();
|
oldView->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,7 +135,7 @@ void KItemListController::setView(KItemListView* view)
|
||||||
m_view->setParent(this);
|
m_view->setParent(this);
|
||||||
m_view->setController(this);
|
m_view->setController(this);
|
||||||
m_view->setModel(m_model);
|
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();
|
updateExtendedSelectionRegion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -538,8 +536,7 @@ bool KItemListController::mousePressEvent(QGraphicsSceneMouseEvent* event, const
|
||||||
m_pressedIndex = m_view->itemAt(m_pressedMousePos);
|
m_pressedIndex = m_view->itemAt(m_pressedMousePos);
|
||||||
emit mouseButtonPressed(m_pressedIndex, event->buttons());
|
emit mouseButtonPressed(m_pressedIndex, event->buttons());
|
||||||
|
|
||||||
// TODO: Qt5: Replace Qt::XButton1 by Qt::BackButton and Qt::XButton2 by Qt::ForwardButton
|
if (event->buttons() & (Qt::BackButton | Qt::ForwardButton)) {
|
||||||
if (event->buttons() & (Qt::XButton1 | Qt::XButton2)) {
|
|
||||||
// Do not select items when clicking the back/forward buttons, see
|
// Do not select items when clicking the back/forward buttons, see
|
||||||
// https://bugs.kde.org/show_bug.cgi?id=327412.
|
// https://bugs.kde.org/show_bug.cgi?id=327412.
|
||||||
return true;
|
return true;
|
||||||
|
@ -655,7 +652,7 @@ bool KItemListController::mousePressEvent(QGraphicsSceneMouseEvent* event, const
|
||||||
rubberBand->setStartPosition(startPos);
|
rubberBand->setStartPosition(startPos);
|
||||||
rubberBand->setEndPosition(startPos);
|
rubberBand->setEndPosition(startPos);
|
||||||
rubberBand->setActive(true);
|
rubberBand->setActive(true);
|
||||||
connect(rubberBand, SIGNAL(endPositionChanged(QPointF,QPointF)), this, SLOT(slotRubberBandChanged()));
|
connect(rubberBand, &KItemListRubberBand::endPositionChanged, this, &KItemListController::slotRubberBandChanged);
|
||||||
m_view->setAutoScroll(true);
|
m_view->setAutoScroll(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -743,7 +740,7 @@ bool KItemListController::mouseReleaseEvent(QGraphicsSceneMouseEvent* event, con
|
||||||
|
|
||||||
KItemListRubberBand* rubberBand = m_view->rubberBand();
|
KItemListRubberBand* rubberBand = m_view->rubberBand();
|
||||||
if (rubberBand->isActive()) {
|
if (rubberBand->isActive()) {
|
||||||
disconnect(rubberBand, SIGNAL(endPositionChanged(QPointF,QPointF)), this, SLOT(slotRubberBandChanged()));
|
disconnect(rubberBand, &KItemListRubberBand::endPositionChanged, this, &KItemListController::slotRubberBandChanged);
|
||||||
rubberBand->setActive(false);
|
rubberBand->setActive(false);
|
||||||
m_oldSelection.clear();
|
m_oldSelection.clear();
|
||||||
m_view->setAutoScroll(false);
|
m_view->setAutoScroll(false);
|
||||||
|
@ -774,7 +771,7 @@ bool KItemListController::mouseReleaseEvent(QGraphicsSceneMouseEvent* event, con
|
||||||
} else if (shiftOrControlPressed) {
|
} else if (shiftOrControlPressed) {
|
||||||
// The mouse click should only update the selection, not trigger the item
|
// The mouse click should only update the selection, not trigger the item
|
||||||
emitItemActivated = false;
|
emitItemActivated = false;
|
||||||
} else if (!(KGlobalSettings::singleClick() || m_singleClickActivationEnforced)) {
|
} else if (!(m_view->style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick) || m_singleClickActivationEnforced)) {
|
||||||
emitItemActivated = false;
|
emitItemActivated = false;
|
||||||
}
|
}
|
||||||
if (emitItemActivated) {
|
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) &&
|
(event->button() & Qt::LeftButton) &&
|
||||||
index >= 0 && index < m_model->count();
|
index >= 0 && index < m_model->count();
|
||||||
if (emitItemActivated) {
|
if (emitItemActivated) {
|
||||||
|
@ -920,7 +917,8 @@ bool KItemListController::dropEvent(QGraphicsSceneDragDropEvent* event, const QT
|
||||||
emit itemDropEvent(m_view->itemAt(pos), event);
|
emit itemDropEvent(m_view->itemAt(pos), event);
|
||||||
}
|
}
|
||||||
|
|
||||||
QAccessible::updateAccessibility(view(), 0, QAccessible::DragDropEnd);
|
QAccessibleEvent accessibilityEvent(view(), QAccessible::DragDropEnd);
|
||||||
|
QAccessible::updateAccessibility(&accessibilityEvent);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1174,7 +1172,9 @@ void KItemListController::startDragging()
|
||||||
drag->setHotSpot(hotSpot);
|
drag->setHotSpot(hotSpot);
|
||||||
|
|
||||||
drag->exec(Qt::MoveAction | Qt::CopyAction | Qt::LinkAction, Qt::CopyAction);
|
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
|
KItemListWidget* KItemListController::hoveredWidget() const
|
||||||
|
@ -1310,4 +1310,3 @@ void KItemListController::updateExtendedSelectionRegion()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "kitemlistcontroller.moc"
|
|
||||||
|
|
|
@ -23,14 +23,13 @@
|
||||||
#ifndef KITEMLISTCONTROLLER_H
|
#ifndef KITEMLISTCONTROLLER_H
|
||||||
#define KITEMLISTCONTROLLER_H
|
#define KITEMLISTCONTROLLER_H
|
||||||
|
|
||||||
#include <libdolphin_export.h>
|
#include "dolphin_export.h"
|
||||||
|
|
||||||
#include "kitemset.h"
|
#include "kitemset.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QPixmap>
|
|
||||||
#include <QPointF>
|
#include <QPointF>
|
||||||
|
class QTimer;
|
||||||
class KItemModelBase;
|
class KItemModelBase;
|
||||||
class KItemListKeyboardSearchManager;
|
class KItemListKeyboardSearchManager;
|
||||||
class KItemListSelectionManager;
|
class KItemListSelectionManager;
|
||||||
|
@ -44,7 +43,6 @@ class QGraphicsSceneWheelEvent;
|
||||||
class QHideEvent;
|
class QHideEvent;
|
||||||
class QInputMethodEvent;
|
class QInputMethodEvent;
|
||||||
class QKeyEvent;
|
class QKeyEvent;
|
||||||
class QMimeData;
|
|
||||||
class QShowEvent;
|
class QShowEvent;
|
||||||
class QTransform;
|
class QTransform;
|
||||||
|
|
||||||
|
@ -58,7 +56,7 @@ class QTransform;
|
||||||
* @see KItemModelBase
|
* @see KItemModelBase
|
||||||
* @see KItemListSelectionManager
|
* @see KItemListSelectionManager
|
||||||
*/
|
*/
|
||||||
class LIBDOLPHINPRIVATE_EXPORT KItemListController : public QObject
|
class DOLPHIN_EXPORT KItemListController : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_ENUMS(SelectionBehavior)
|
Q_ENUMS(SelectionBehavior)
|
||||||
|
@ -131,7 +129,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* If set to true, the signals itemActivated() and itemsActivated() are emitted
|
* 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),
|
* 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);
|
void setSingleClickActivationEnforced(bool singleClick);
|
||||||
bool singleClickActivationEnforced() const;
|
bool singleClickActivationEnforced() const;
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
#include <QGraphicsSceneResizeEvent>
|
#include <QGraphicsSceneResizeEvent>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QStyleOptionGraphicsItem>
|
#include <QStyleOptionGraphicsItem>
|
||||||
#include <KDebug>
|
|
||||||
|
|
||||||
KItemListGroupHeader::KItemListGroupHeader(QGraphicsWidget* parent) :
|
KItemListGroupHeader::KItemListGroupHeader(QGraphicsWidget* parent) :
|
||||||
QGraphicsWidget(parent, 0),
|
QGraphicsWidget(parent, 0),
|
||||||
|
@ -233,4 +232,3 @@ QColor KItemListGroupHeader::baseColor() const
|
||||||
return styleOption().palette.color(group, normalBaseColorRole());
|
return styleOption().palette.color(group, normalBaseColorRole());
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "kitemlistgroupheader.moc"
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#ifndef KITEMLISTGROUPHEADER_H
|
#ifndef KITEMLISTGROUPHEADER_H
|
||||||
#define KITEMLISTGROUPHEADER_H
|
#define KITEMLISTGROUPHEADER_H
|
||||||
|
|
||||||
#include <libdolphin_export.h>
|
#include "dolphin_export.h"
|
||||||
|
|
||||||
#include <kitemviews/kitemliststyleoption.h>
|
#include <kitemviews/kitemliststyleoption.h>
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ class KItemListView;
|
||||||
* the method paint() and draw the role within the given roleBounds() with
|
* the method paint() and draw the role within the given roleBounds() with
|
||||||
* the color roleColor().
|
* the color roleColor().
|
||||||
*/
|
*/
|
||||||
class LIBDOLPHINPRIVATE_EXPORT KItemListGroupHeader : public QGraphicsWidget
|
class DOLPHIN_EXPORT KItemListGroupHeader : public QGraphicsWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ public:
|
||||||
void setItemIndex(int index);
|
void setItemIndex(int index);
|
||||||
int itemIndex() const;
|
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:
|
protected:
|
||||||
virtual void paintRole(QPainter* painter, const QRectF& roleBounds, const QColor& color) = 0;
|
virtual void paintRole(QPainter* painter, const QRectF& roleBounds, const QColor& color) = 0;
|
||||||
|
@ -101,8 +101,7 @@ protected:
|
||||||
*/
|
*/
|
||||||
virtual void itemIndexChanged(int current, int previous);
|
virtual void itemIndexChanged(int current, int previous);
|
||||||
|
|
||||||
/** @reimp */
|
virtual void resizeEvent(QGraphicsSceneResizeEvent* event) Q_DECL_OVERRIDE;
|
||||||
virtual void resizeEvent(QGraphicsSceneResizeEvent* event);
|
|
||||||
|
|
||||||
virtual QPalette::ColorRole normalTextColorRole() const;
|
virtual QPalette::ColorRole normalTextColorRole() const;
|
||||||
virtual QPalette::ColorRole normalBaseColorRole() const;
|
virtual QPalette::ColorRole normalBaseColorRole() const;
|
||||||
|
|
|
@ -81,8 +81,7 @@ KItemListHeader::KItemListHeader(KItemListView* listView) :
|
||||||
m_headerWidget = m_view->m_headerWidget;
|
m_headerWidget = m_view->m_headerWidget;
|
||||||
Q_ASSERT(m_headerWidget);
|
Q_ASSERT(m_headerWidget);
|
||||||
|
|
||||||
connect(m_headerWidget, SIGNAL(columnWidthChanged(QByteArray,qreal,qreal)),
|
connect(m_headerWidget, &KItemListHeaderWidget::columnWidthChanged,
|
||||||
this, SIGNAL(columnWidthChanged(QByteArray,qreal,qreal)));
|
this, &KItemListHeader::columnWidthChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "kitemlistheader.moc"
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#ifndef KITEMLISTHEADER_H
|
#ifndef KITEMLISTHEADER_H
|
||||||
#define KITEMLISTHEADER_H
|
#define KITEMLISTHEADER_H
|
||||||
|
|
||||||
#include <libdolphin_export.h>
|
#include "dolphin_export.h"
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ class KItemListView;
|
||||||
* Each column of the header represents a visible role
|
* Each column of the header represents a visible role
|
||||||
* accessible by KItemListView::visibleRoles().
|
* accessible by KItemListView::visibleRoles().
|
||||||
*/
|
*/
|
||||||
class LIBDOLPHINPRIVATE_EXPORT KItemListHeader : public QObject
|
class DOLPHIN_EXPORT KItemListHeader : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
#include "kitemlistselectionmanager.h"
|
#include "kitemlistselectionmanager.h"
|
||||||
|
|
||||||
#include "kitemmodelbase.h"
|
#include "kitemmodelbase.h"
|
||||||
#include <KDebug>
|
|
||||||
|
|
||||||
KItemListSelectionManager::KItemListSelectionManager(QObject* parent) :
|
KItemListSelectionManager::KItemListSelectionManager(QObject* parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
|
@ -396,4 +395,4 @@ int KItemListSelectionManager::indexAfterRangesRemoving(int index, const KItemRa
|
||||||
}
|
}
|
||||||
return qBound(-1, index - dec, m_model->count() - 1);
|
return qBound(-1, index - dec, m_model->count() - 1);
|
||||||
}
|
}
|
||||||
#include "kitemlistselectionmanager.moc"
|
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#ifndef KITEMLISTSELECTIONMANAGER_H
|
#ifndef KITEMLISTSELECTIONMANAGER_H
|
||||||
#define KITEMLISTSELECTIONMANAGER_H
|
#define KITEMLISTSELECTIONMANAGER_H
|
||||||
|
|
||||||
#include <libdolphin_export.h>
|
#include "dolphin_export.h"
|
||||||
|
|
||||||
#include <kitemviews/kitemmodelbase.h>
|
#include <kitemviews/kitemmodelbase.h>
|
||||||
#include <kitemviews/kitemset.h>
|
#include <kitemviews/kitemset.h>
|
||||||
|
@ -35,7 +35,7 @@ class KItemModelBase;
|
||||||
/**
|
/**
|
||||||
* @brief Allows to select and deselect items of a KItemListView.
|
* @brief Allows to select and deselect items of a KItemListView.
|
||||||
*/
|
*/
|
||||||
class LIBDOLPHINPRIVATE_EXPORT KItemListSelectionManager : public QObject
|
class DOLPHIN_EXPORT KItemListSelectionManager : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
#include "kitemliststyleoption.h"
|
#include "kitemliststyleoption.h"
|
||||||
|
|
||||||
#include <KIconLoader>
|
|
||||||
|
|
||||||
KItemListStyleOption::KItemListStyleOption() :
|
KItemListStyleOption::KItemListStyleOption() :
|
||||||
rect(),
|
rect(),
|
||||||
|
|
|
@ -20,14 +20,14 @@
|
||||||
#ifndef KITEMLISTSTYLEOPTION_H
|
#ifndef KITEMLISTSTYLEOPTION_H
|
||||||
#define KITEMLISTSTYLEOPTION_H
|
#define KITEMLISTSTYLEOPTION_H
|
||||||
|
|
||||||
#include <libdolphin_export.h>
|
#include "dolphin_export.h"
|
||||||
|
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
#include <QFontMetrics>
|
#include <QFontMetrics>
|
||||||
#include <QPalette>
|
#include <QPalette>
|
||||||
#include <QRect>
|
#include <QRect>
|
||||||
|
|
||||||
class LIBDOLPHINPRIVATE_EXPORT KItemListStyleOption
|
class DOLPHIN_EXPORT KItemListStyleOption
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
KItemListStyleOption();
|
KItemListStyleOption();
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
#include "kitemlistview.h"
|
#include "kitemlistview.h"
|
||||||
|
|
||||||
#include <KDebug>
|
#include "dolphindebug.h"
|
||||||
#include "kitemlistcontainer.h"
|
#include "kitemlistcontainer.h"
|
||||||
#include "kitemlistcontroller.h"
|
#include "kitemlistcontroller.h"
|
||||||
#include "kitemlistheader.h"
|
#include "kitemlistheader.h"
|
||||||
|
@ -35,14 +35,13 @@
|
||||||
#include "private/kitemlistviewlayouter.h"
|
#include "private/kitemlistviewlayouter.h"
|
||||||
#include "private/kitemlistviewanimation.h"
|
#include "private/kitemlistviewanimation.h"
|
||||||
|
|
||||||
#include <QCursor>
|
|
||||||
#include <QGraphicsSceneMouseEvent>
|
#include <QGraphicsSceneMouseEvent>
|
||||||
#include <QGraphicsView>
|
#include <QGraphicsView>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QPropertyAnimation>
|
|
||||||
#include <QStyle>
|
#include <QStyle>
|
||||||
#include <QStyleOptionRubberBand>
|
#include <QStyleOptionRubberBand>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include <QElapsedTimer>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
@ -58,7 +57,7 @@ namespace {
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef QT_NO_ACCESSIBILITY
|
#ifndef QT_NO_ACCESSIBILITY
|
||||||
QAccessibleInterface* accessibleInterfaceFactory(const QString &key, QObject *object)
|
QAccessibleInterface* accessibleInterfaceFactory(const QString& key, QObject* object)
|
||||||
{
|
{
|
||||||
Q_UNUSED(key)
|
Q_UNUSED(key)
|
||||||
|
|
||||||
|
@ -114,16 +113,16 @@ KItemListView::KItemListView(QGraphicsWidget* parent) :
|
||||||
m_layouter = new KItemListViewLayouter(m_sizeHintResolver, this);
|
m_layouter = new KItemListViewLayouter(m_sizeHintResolver, this);
|
||||||
|
|
||||||
m_animation = new KItemListViewAnimation(this);
|
m_animation = new KItemListViewAnimation(this);
|
||||||
connect(m_animation, SIGNAL(finished(QGraphicsWidget*,KItemListViewAnimation::AnimationType)),
|
connect(m_animation, &KItemListViewAnimation::finished,
|
||||||
this, SLOT(slotAnimationFinished(QGraphicsWidget*,KItemListViewAnimation::AnimationType)));
|
this, &KItemListView::slotAnimationFinished);
|
||||||
|
|
||||||
m_layoutTimer = new QTimer(this);
|
m_layoutTimer = new QTimer(this);
|
||||||
m_layoutTimer->setInterval(300);
|
m_layoutTimer->setInterval(300);
|
||||||
m_layoutTimer->setSingleShot(true);
|
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);
|
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 = new KItemListHeaderWidget(this);
|
||||||
m_headerWidget->setVisible(false);
|
m_headerWidget->setVisible(false);
|
||||||
|
@ -267,7 +266,7 @@ void KItemListView::setAutoScroll(bool enabled)
|
||||||
if (enabled && !m_autoScrollTimer) {
|
if (enabled && !m_autoScrollTimer) {
|
||||||
m_autoScrollTimer = new QTimer(this);
|
m_autoScrollTimer = new QTimer(this);
|
||||||
m_autoScrollTimer->setSingleShot(true);
|
m_autoScrollTimer->setSingleShot(true);
|
||||||
connect(m_autoScrollTimer, SIGNAL(timeout()), this, SLOT(triggerAutoScrolling()));
|
connect(m_autoScrollTimer, &QTimer::timeout, this, &KItemListView::triggerAutoScrolling);
|
||||||
m_autoScrollTimer->start(InitialAutoScrollDelay);
|
m_autoScrollTimer->start(InitialAutoScrollDelay);
|
||||||
} else if (!enabled && m_autoScrollTimer) {
|
} else if (!enabled && m_autoScrollTimer) {
|
||||||
delete m_autoScrollTimer;
|
delete m_autoScrollTimer;
|
||||||
|
@ -544,7 +543,7 @@ void KItemListView::endTransaction()
|
||||||
--m_activeTransactions;
|
--m_activeTransactions;
|
||||||
if (m_activeTransactions < 0) {
|
if (m_activeTransactions < 0) {
|
||||||
m_activeTransactions = 0;
|
m_activeTransactions = 0;
|
||||||
kWarning() << "Mismatch between beginTransaction()/endTransaction()";
|
qCWarning(DolphinDebug) << "Mismatch between beginTransaction()/endTransaction()";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_activeTransactions == 0) {
|
if (m_activeTransactions == 0) {
|
||||||
|
@ -572,26 +571,26 @@ void KItemListView::setHeaderVisible(bool visible)
|
||||||
m_headerWidget->setColumns(m_visibleRoles);
|
m_headerWidget->setColumns(m_visibleRoles);
|
||||||
m_headerWidget->setZValue(1);
|
m_headerWidget->setZValue(1);
|
||||||
|
|
||||||
connect(m_headerWidget, SIGNAL(columnWidthChanged(QByteArray,qreal,qreal)),
|
connect(m_headerWidget, &KItemListHeaderWidget::columnWidthChanged,
|
||||||
this, SLOT(slotHeaderColumnWidthChanged(QByteArray,qreal,qreal)));
|
this, &KItemListView::slotHeaderColumnWidthChanged);
|
||||||
connect(m_headerWidget, SIGNAL(columnMoved(QByteArray,int,int)),
|
connect(m_headerWidget, &KItemListHeaderWidget::columnMoved,
|
||||||
this, SLOT(slotHeaderColumnMoved(QByteArray,int,int)));
|
this, &KItemListView::slotHeaderColumnMoved);
|
||||||
connect(m_headerWidget, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder)),
|
connect(m_headerWidget, &KItemListHeaderWidget::sortOrderChanged,
|
||||||
this, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder)));
|
this, &KItemListView::sortOrderChanged);
|
||||||
connect(m_headerWidget, SIGNAL(sortRoleChanged(QByteArray,QByteArray)),
|
connect(m_headerWidget, &KItemListHeaderWidget::sortRoleChanged,
|
||||||
this, SIGNAL(sortRoleChanged(QByteArray,QByteArray)));
|
this, &KItemListView::sortRoleChanged);
|
||||||
|
|
||||||
m_layouter->setHeaderHeight(headerSize.height());
|
m_layouter->setHeaderHeight(headerSize.height());
|
||||||
m_headerWidget->setVisible(true);
|
m_headerWidget->setVisible(true);
|
||||||
} else if (!visible && m_headerWidget->isVisible()) {
|
} else if (!visible && m_headerWidget->isVisible()) {
|
||||||
disconnect(m_headerWidget, SIGNAL(columnWidthChanged(QByteArray,qreal,qreal)),
|
disconnect(m_headerWidget, &KItemListHeaderWidget::columnWidthChanged,
|
||||||
this, SLOT(slotHeaderColumnWidthChanged(QByteArray,qreal,qreal)));
|
this, &KItemListView::slotHeaderColumnWidthChanged);
|
||||||
disconnect(m_headerWidget, SIGNAL(columnMoved(QByteArray,int,int)),
|
disconnect(m_headerWidget, &KItemListHeaderWidget::columnMoved,
|
||||||
this, SLOT(slotHeaderColumnMoved(QByteArray,int,int)));
|
this, &KItemListView::slotHeaderColumnMoved);
|
||||||
disconnect(m_headerWidget, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder)),
|
disconnect(m_headerWidget, &KItemListHeaderWidget::sortOrderChanged,
|
||||||
this, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder)));
|
this, &KItemListView::sortOrderChanged);
|
||||||
disconnect(m_headerWidget, SIGNAL(sortRoleChanged(QByteArray,QByteArray)),
|
disconnect(m_headerWidget, &KItemListHeaderWidget::sortRoleChanged,
|
||||||
this, SIGNAL(sortRoleChanged(QByteArray,QByteArray)));
|
this, &KItemListView::sortRoleChanged);
|
||||||
|
|
||||||
m_layouter->setHeaderHeight(0);
|
m_layouter->setHeaderHeight(0);
|
||||||
m_headerWidget->setVisible(false);
|
m_headerWidget->setVisible(false);
|
||||||
|
@ -637,10 +636,10 @@ void KItemListView::editRole(int index, const QByteArray& role)
|
||||||
m_editingRole = true;
|
m_editingRole = true;
|
||||||
widget->setEditedRole(role);
|
widget->setEditedRole(role);
|
||||||
|
|
||||||
connect(widget, SIGNAL(roleEditingCanceled(int,QByteArray,QVariant)),
|
connect(widget, &KItemListWidget::roleEditingCanceled,
|
||||||
this, SLOT(slotRoleEditingCanceled(int,QByteArray,QVariant)));
|
this, &KItemListView::slotRoleEditingCanceled);
|
||||||
connect(widget, SIGNAL(roleEditingFinished(int,QByteArray,QVariant)),
|
connect(widget, &KItemListWidget::roleEditingFinished,
|
||||||
this, SLOT(slotRoleEditingFinished(int,QByteArray,QVariant)));
|
this, &KItemListView::slotRoleEditingFinished);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KItemListView::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
void KItemListView::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
||||||
|
@ -936,7 +935,7 @@ void KItemListView::dragEnterEvent(QGraphicsSceneDragDropEvent* event)
|
||||||
setAutoScroll(true);
|
setAutoScroll(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KItemListView::dragMoveEvent(QGraphicsSceneDragDropEvent *event)
|
void KItemListView::dragMoveEvent(QGraphicsSceneDragDropEvent* event)
|
||||||
{
|
{
|
||||||
QGraphicsWidget::dragMoveEvent(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);
|
QGraphicsWidget::dragLeaveEvent(event);
|
||||||
setAutoScroll(false);
|
setAutoScroll(false);
|
||||||
|
@ -1007,7 +1006,7 @@ void KItemListView::slotItemsInserted(const KItemRangeList& itemRanges)
|
||||||
const int index = range.index + previouslyInsertedCount;
|
const int index = range.index + previouslyInsertedCount;
|
||||||
const int count = range.count;
|
const int count = range.count;
|
||||||
if (index < 0 || count <= 0) {
|
if (index < 0 || count <= 0) {
|
||||||
kWarning() << "Invalid item range (index:" << index << ", count:" << count << ")";
|
qCWarning(DolphinDebug) << "Invalid item range (index:" << index << ", count:" << count << ")";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
previouslyInsertedCount += count;
|
previouslyInsertedCount += count;
|
||||||
|
@ -1115,7 +1114,7 @@ void KItemListView::slotItemsRemoved(const KItemRangeList& itemRanges)
|
||||||
const int index = range.index;
|
const int index = range.index;
|
||||||
const int count = range.count;
|
const int count = range.count;
|
||||||
if (index < 0 || count <= 0) {
|
if (index < 0 || count <= 0) {
|
||||||
kWarning() << "Invalid item range (index:" << index << ", count:" << count << ")";
|
qCWarning(DolphinDebug) << "Invalid item range (index:" << index << ", count:" << count << ")";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1268,8 +1267,12 @@ void KItemListView::slotItemsChanged(const KItemRangeList& itemRanges,
|
||||||
updateVisibleGroupHeaders();
|
updateVisibleGroupHeaders();
|
||||||
doLayout(NoAnimation);
|
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()
|
void KItemListView::slotGroupsChanged()
|
||||||
|
@ -1345,7 +1348,10 @@ void KItemListView::slotCurrentChanged(int current, int previous)
|
||||||
currentWidget->setCurrent(true);
|
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)
|
void KItemListView::slotSelectionChanged(const KItemSet& current, const KItemSet& previous)
|
||||||
|
@ -1412,12 +1418,12 @@ void KItemListView::slotRubberBandPosChanged()
|
||||||
void KItemListView::slotRubberBandActivationChanged(bool active)
|
void KItemListView::slotRubberBandActivationChanged(bool active)
|
||||||
{
|
{
|
||||||
if (active) {
|
if (active) {
|
||||||
connect(m_rubberBand, SIGNAL(startPositionChanged(QPointF,QPointF)), this, SLOT(slotRubberBandPosChanged()));
|
connect(m_rubberBand, &KItemListRubberBand::startPositionChanged, this, &KItemListView::slotRubberBandPosChanged);
|
||||||
connect(m_rubberBand, SIGNAL(endPositionChanged(QPointF,QPointF)), this, SLOT(slotRubberBandPosChanged()));
|
connect(m_rubberBand, &KItemListRubberBand::endPositionChanged, this, &KItemListView::slotRubberBandPosChanged);
|
||||||
m_skipAutoScrollForRubberBand = true;
|
m_skipAutoScrollForRubberBand = true;
|
||||||
} else {
|
} else {
|
||||||
disconnect(m_rubberBand, SIGNAL(startPositionChanged(QPointF,QPointF)), this, SLOT(slotRubberBandPosChanged()));
|
disconnect(m_rubberBand, &KItemListRubberBand::startPositionChanged, this, &KItemListView::slotRubberBandPosChanged);
|
||||||
disconnect(m_rubberBand, SIGNAL(endPositionChanged(QPointF,QPointF)), this, SLOT(slotRubberBandPosChanged()));
|
disconnect(m_rubberBand, &KItemListRubberBand::endPositionChanged, this, &KItemListView::slotRubberBandPosChanged);
|
||||||
m_skipAutoScrollForRubberBand = false;
|
m_skipAutoScrollForRubberBand = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1544,16 +1550,16 @@ void KItemListView::setController(KItemListController* controller)
|
||||||
KItemListController* previous = m_controller;
|
KItemListController* previous = m_controller;
|
||||||
if (previous) {
|
if (previous) {
|
||||||
KItemListSelectionManager* selectionManager = previous->selectionManager();
|
KItemListSelectionManager* selectionManager = previous->selectionManager();
|
||||||
disconnect(selectionManager, SIGNAL(currentChanged(int,int)), this, SLOT(slotCurrentChanged(int,int)));
|
disconnect(selectionManager, &KItemListSelectionManager::currentChanged, this, &KItemListView::slotCurrentChanged);
|
||||||
disconnect(selectionManager, SIGNAL(selectionChanged(KItemSet,KItemSet)), this, SLOT(slotSelectionChanged(KItemSet,KItemSet)));
|
disconnect(selectionManager, &KItemListSelectionManager::selectionChanged, this, &KItemListView::slotSelectionChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_controller = controller;
|
m_controller = controller;
|
||||||
|
|
||||||
if (controller) {
|
if (controller) {
|
||||||
KItemListSelectionManager* selectionManager = controller->selectionManager();
|
KItemListSelectionManager* selectionManager = controller->selectionManager();
|
||||||
connect(selectionManager, SIGNAL(currentChanged(int,int)), this, SLOT(slotCurrentChanged(int,int)));
|
connect(selectionManager, &KItemListSelectionManager::currentChanged, this, &KItemListView::slotCurrentChanged);
|
||||||
connect(selectionManager, SIGNAL(selectionChanged(KItemSet,KItemSet)), this, SLOT(slotSelectionChanged(KItemSet,KItemSet)));
|
connect(selectionManager, &KItemListSelectionManager::selectionChanged, this, &KItemListView::slotSelectionChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
onControllerChanged(controller, previous);
|
onControllerChanged(controller, previous);
|
||||||
|
@ -1569,22 +1575,22 @@ void KItemListView::setModel(KItemModelBase* model)
|
||||||
KItemModelBase* previous = m_model;
|
KItemModelBase* previous = m_model;
|
||||||
|
|
||||||
if (m_model) {
|
if (m_model) {
|
||||||
disconnect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
|
disconnect(m_model, &KItemModelBase::itemsChanged,
|
||||||
this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
|
this, &KItemListView::slotItemsChanged);
|
||||||
disconnect(m_model, SIGNAL(itemsInserted(KItemRangeList)),
|
disconnect(m_model, &KItemModelBase::itemsInserted,
|
||||||
this, SLOT(slotItemsInserted(KItemRangeList)));
|
this, &KItemListView::slotItemsInserted);
|
||||||
disconnect(m_model, SIGNAL(itemsRemoved(KItemRangeList)),
|
disconnect(m_model, &KItemModelBase::itemsRemoved,
|
||||||
this, SLOT(slotItemsRemoved(KItemRangeList)));
|
this, &KItemListView::slotItemsRemoved);
|
||||||
disconnect(m_model, SIGNAL(itemsMoved(KItemRange,QList<int>)),
|
disconnect(m_model, &KItemModelBase::itemsMoved,
|
||||||
this, SLOT(slotItemsMoved(KItemRange,QList<int>)));
|
this, &KItemListView::slotItemsMoved);
|
||||||
disconnect(m_model, SIGNAL(groupsChanged()),
|
disconnect(m_model, &KItemModelBase::groupsChanged,
|
||||||
this, SLOT(slotGroupsChanged()));
|
this, &KItemListView::slotGroupsChanged);
|
||||||
disconnect(m_model, SIGNAL(groupedSortingChanged(bool)),
|
disconnect(m_model, &KItemModelBase::groupedSortingChanged,
|
||||||
this, SLOT(slotGroupedSortingChanged(bool)));
|
this, &KItemListView::slotGroupedSortingChanged);
|
||||||
disconnect(m_model, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder)),
|
disconnect(m_model, &KItemModelBase::sortOrderChanged,
|
||||||
this, SLOT(slotSortOrderChanged(Qt::SortOrder,Qt::SortOrder)));
|
this, &KItemListView::slotSortOrderChanged);
|
||||||
disconnect(m_model, SIGNAL(sortRoleChanged(QByteArray,QByteArray)),
|
disconnect(m_model, &KItemModelBase::sortRoleChanged,
|
||||||
this, SLOT(slotSortRoleChanged(QByteArray,QByteArray)));
|
this, &KItemListView::slotSortRoleChanged);
|
||||||
|
|
||||||
m_sizeHintResolver->itemsRemoved(KItemRangeList() << KItemRange(0, m_model->count()));
|
m_sizeHintResolver->itemsRemoved(KItemRangeList() << KItemRange(0, m_model->count()));
|
||||||
}
|
}
|
||||||
|
@ -1594,22 +1600,22 @@ void KItemListView::setModel(KItemModelBase* model)
|
||||||
m_grouped = model->groupedSorting();
|
m_grouped = model->groupedSorting();
|
||||||
|
|
||||||
if (m_model) {
|
if (m_model) {
|
||||||
connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
|
connect(m_model, &KItemModelBase::itemsChanged,
|
||||||
this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
|
this, &KItemListView::slotItemsChanged);
|
||||||
connect(m_model, SIGNAL(itemsInserted(KItemRangeList)),
|
connect(m_model, &KItemModelBase::itemsInserted,
|
||||||
this, SLOT(slotItemsInserted(KItemRangeList)));
|
this, &KItemListView::slotItemsInserted);
|
||||||
connect(m_model, SIGNAL(itemsRemoved(KItemRangeList)),
|
connect(m_model, &KItemModelBase::itemsRemoved,
|
||||||
this, SLOT(slotItemsRemoved(KItemRangeList)));
|
this, &KItemListView::slotItemsRemoved);
|
||||||
connect(m_model, SIGNAL(itemsMoved(KItemRange,QList<int>)),
|
connect(m_model, &KItemModelBase::itemsMoved,
|
||||||
this, SLOT(slotItemsMoved(KItemRange,QList<int>)));
|
this, &KItemListView::slotItemsMoved);
|
||||||
connect(m_model, SIGNAL(groupsChanged()),
|
connect(m_model, &KItemModelBase::groupsChanged,
|
||||||
this, SLOT(slotGroupsChanged()));
|
this, &KItemListView::slotGroupsChanged);
|
||||||
connect(m_model, SIGNAL(groupedSortingChanged(bool)),
|
connect(m_model, &KItemModelBase::groupedSortingChanged,
|
||||||
this, SLOT(slotGroupedSortingChanged(bool)));
|
this, &KItemListView::slotGroupedSortingChanged);
|
||||||
connect(m_model, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder)),
|
connect(m_model, &KItemModelBase::sortOrderChanged,
|
||||||
this, SLOT(slotSortOrderChanged(Qt::SortOrder,Qt::SortOrder)));
|
this, &KItemListView::slotSortOrderChanged);
|
||||||
connect(m_model, SIGNAL(sortRoleChanged(QByteArray,QByteArray)),
|
connect(m_model, &KItemModelBase::sortRoleChanged,
|
||||||
this, SLOT(slotSortRoleChanged(QByteArray,QByteArray)));
|
this, &KItemListView::slotSortRoleChanged);
|
||||||
|
|
||||||
const int itemCount = m_model->count();
|
const int itemCount = m_model->count();
|
||||||
if (itemCount > 0) {
|
if (itemCount > 0) {
|
||||||
|
@ -2023,7 +2029,7 @@ void KItemListView::updateGroupHeaderForWidget(KItemListWidget* widget)
|
||||||
groupHeader = groupHeaderCreator()->create(this);
|
groupHeader = groupHeaderCreator()->create(this);
|
||||||
groupHeader->setParentItem(widget);
|
groupHeader->setParentItem(widget);
|
||||||
m_visibleGroups.insert(widget, groupHeader);
|
m_visibleGroups.insert(widget, groupHeader);
|
||||||
connect(widget, SIGNAL(geometryChanged()), this, SLOT(slotGeometryOfGroupHeaderParentChanged()));
|
connect(widget, &KItemListWidget::geometryChanged, this, &KItemListView::slotGeometryOfGroupHeaderParentChanged);
|
||||||
}
|
}
|
||||||
Q_ASSERT(groupHeader->parentItem() == widget);
|
Q_ASSERT(groupHeader->parentItem() == widget);
|
||||||
|
|
||||||
|
@ -2070,7 +2076,7 @@ void KItemListView::recycleGroupHeaderForWidget(KItemListWidget* widget)
|
||||||
header->setParentItem(0);
|
header->setParentItem(0);
|
||||||
groupHeaderCreator()->recycle(header);
|
groupHeaderCreator()->recycle(header);
|
||||||
m_visibleGroups.remove(widget);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
widget->disconnect(SIGNAL(roleEditingCanceled(int,QByteArray,QVariant)), this);
|
disconnect(widget, &KItemListWidget::roleEditingCanceled, this, nullptr);
|
||||||
widget->disconnect(SIGNAL(roleEditingFinished(int,QByteArray,QVariant)), this);
|
disconnect(widget, &KItemListWidget::roleEditingFinished, this, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
int KItemListView::calculateAutoScrollingIncrement(int pos, int range, int oldInc)
|
int KItemListView::calculateAutoScrollingIncrement(int pos, int range, int oldInc)
|
||||||
|
@ -2719,4 +2725,3 @@ void KItemListGroupHeaderCreatorBase::recycle(KItemListGroupHeader* header)
|
||||||
pushRecycleableWidget(header);
|
pushRecycleableWidget(header);
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "kitemlistview.moc"
|
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#ifndef KITEMLISTVIEW_H
|
#ifndef KITEMLISTVIEW_H
|
||||||
#define KITEMLISTVIEW_H
|
#define KITEMLISTVIEW_H
|
||||||
|
|
||||||
#include <libdolphin_export.h>
|
#include "dolphin_export.h"
|
||||||
|
|
||||||
#include <kitemviews/kstandarditemlistgroupheader.h>
|
#include <kitemviews/kstandarditemlistgroupheader.h>
|
||||||
#include <kitemviews/kitemliststyleoption.h>
|
#include <kitemviews/kitemliststyleoption.h>
|
||||||
|
@ -44,7 +44,6 @@ class KItemListViewLayouter;
|
||||||
class KItemListWidget;
|
class KItemListWidget;
|
||||||
class KItemListWidgetInformant;
|
class KItemListWidgetInformant;
|
||||||
class KItemListWidgetCreatorBase;
|
class KItemListWidgetCreatorBase;
|
||||||
class KItemListViewCreatorBase;
|
|
||||||
class QTimer;
|
class QTimer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -60,7 +59,7 @@ class QTimer;
|
||||||
* @see KItemListWidget
|
* @see KItemListWidget
|
||||||
* @see KItemModelBase
|
* @see KItemModelBase
|
||||||
*/
|
*/
|
||||||
class LIBDOLPHINPRIVATE_EXPORT KItemListView : public QGraphicsWidget
|
class DOLPHIN_EXPORT KItemListView : public QGraphicsWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -161,8 +160,7 @@ public:
|
||||||
|
|
||||||
const KItemListStyleOption& styleOption() const;
|
const KItemListStyleOption& styleOption() const;
|
||||||
|
|
||||||
/** @reimp */
|
virtual void setGeometry(const QRectF& rect) Q_DECL_OVERRIDE;
|
||||||
virtual void setGeometry(const QRectF& rect);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The page step which should be used by the vertical scroll bar.
|
* @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);
|
void editRole(int index, const QByteArray& role);
|
||||||
|
|
||||||
/**
|
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0) Q_DECL_OVERRIDE;
|
||||||
* @reimp
|
|
||||||
*/
|
|
||||||
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void scrollOrientationChanged(Qt::Orientation current, Qt::Orientation previous);
|
void scrollOrientationChanged(Qt::Orientation current, Qt::Orientation previous);
|
||||||
|
@ -323,7 +318,7 @@ signals:
|
||||||
void roleEditingFinished(int index, const QByteArray& role, const QVariant& value);
|
void roleEditingFinished(int index, const QByteArray& role, const QVariant& value);
|
||||||
|
|
||||||
protected:
|
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 setItemSize(const QSizeF& size);
|
||||||
void setStyleOption(const KItemListStyleOption& option);
|
void setStyleOption(const KItemListStyleOption& option);
|
||||||
|
|
||||||
|
@ -380,13 +375,13 @@ protected:
|
||||||
virtual void onTransactionBegin();
|
virtual void onTransactionBegin();
|
||||||
virtual void onTransactionEnd();
|
virtual void onTransactionEnd();
|
||||||
|
|
||||||
virtual bool event(QEvent* event);
|
virtual bool event(QEvent* event) Q_DECL_OVERRIDE;
|
||||||
virtual void mousePressEvent(QGraphicsSceneMouseEvent* event);
|
virtual void mousePressEvent(QGraphicsSceneMouseEvent* event) Q_DECL_OVERRIDE;
|
||||||
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
|
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent* event) Q_DECL_OVERRIDE;
|
||||||
virtual void dragEnterEvent(QGraphicsSceneDragDropEvent* event);
|
virtual void dragEnterEvent(QGraphicsSceneDragDropEvent* event) Q_DECL_OVERRIDE;
|
||||||
virtual void dragMoveEvent(QGraphicsSceneDragDropEvent* event);
|
virtual void dragMoveEvent(QGraphicsSceneDragDropEvent* event) Q_DECL_OVERRIDE;
|
||||||
virtual void dragLeaveEvent(QGraphicsSceneDragDropEvent* event);
|
virtual void dragLeaveEvent(QGraphicsSceneDragDropEvent* event) Q_DECL_OVERRIDE;
|
||||||
virtual void dropEvent(QGraphicsSceneDragDropEvent* event);
|
virtual void dropEvent(QGraphicsSceneDragDropEvent* event) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
QList<KItemListWidget*> visibleItemListWidgets() const;
|
QList<KItemListWidget*> visibleItemListWidgets() const;
|
||||||
|
|
||||||
|
@ -774,7 +769,7 @@ private:
|
||||||
* KItemListWidgetCreatorBase and KItemListGroupHeaderCreatorBase.
|
* KItemListWidgetCreatorBase and KItemListGroupHeaderCreatorBase.
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
class LIBDOLPHINPRIVATE_EXPORT KItemListCreatorBase
|
class DOLPHIN_EXPORT KItemListCreatorBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~KItemListCreatorBase();
|
virtual ~KItemListCreatorBase();
|
||||||
|
@ -798,7 +793,7 @@ private:
|
||||||
* expensive instantiations and deletions of KItemListWidgets by recycling existing widget
|
* expensive instantiations and deletions of KItemListWidgets by recycling existing widget
|
||||||
* instances.
|
* instances.
|
||||||
*/
|
*/
|
||||||
class LIBDOLPHINPRIVATE_EXPORT KItemListWidgetCreatorBase : public KItemListCreatorBase
|
class DOLPHIN_EXPORT KItemListWidgetCreatorBase : public KItemListCreatorBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~KItemListWidgetCreatorBase();
|
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
|
* The intention of the group-header creator is to prevent repetitive and expensive instantiations and
|
||||||
* deletions of KItemListGroupHeaders by recycling existing header instances.
|
* deletions of KItemListGroupHeaders by recycling existing header instances.
|
||||||
*/
|
*/
|
||||||
class LIBDOLPHINPRIVATE_EXPORT KItemListGroupHeaderCreatorBase : public KItemListCreatorBase
|
class DOLPHIN_EXPORT KItemListGroupHeaderCreatorBase : public KItemListCreatorBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~KItemListGroupHeaderCreatorBase();
|
virtual ~KItemListGroupHeaderCreatorBase();
|
||||||
|
|
|
@ -27,11 +27,10 @@
|
||||||
#include "kitemlistview.h"
|
#include "kitemlistview.h"
|
||||||
#include "private/kitemlistviewlayouter.h"
|
#include "private/kitemlistviewlayouter.h"
|
||||||
|
|
||||||
#include <QtGui/qaccessible2.h>
|
#include <qaccessible.h>
|
||||||
#include <qgraphicsscene.h>
|
#include <qgraphicsscene.h>
|
||||||
#include <qgraphicsview.h>
|
#include <qgraphicsview.h>
|
||||||
|
|
||||||
#include <KDebug>
|
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
|
|
||||||
KItemListView* KItemListViewAccessible::view() const
|
KItemListView* KItemListViewAccessible::view() const
|
||||||
|
@ -40,35 +39,52 @@ KItemListView* KItemListViewAccessible::view() const
|
||||||
}
|
}
|
||||||
|
|
||||||
KItemListViewAccessible::KItemListViewAccessible(KItemListView* view_) :
|
KItemListViewAccessible::KItemListViewAccessible(KItemListView* view_) :
|
||||||
QAccessibleObjectEx(view_)
|
QAccessibleObject(view_)
|
||||||
{
|
{
|
||||||
Q_ASSERT(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()
|
void KItemListViewAccessible::modelReset()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QAccessible::Role KItemListViewAccessible::cellRole() const
|
QAccessibleInterface* KItemListViewAccessible::cell(int index) const
|
||||||
{
|
|
||||||
return QAccessible::Cell;
|
|
||||||
}
|
|
||||||
|
|
||||||
QAccessibleTable2CellInterface* KItemListViewAccessible::cell(int index) const
|
|
||||||
{
|
{
|
||||||
if (index < 0 || index >= view()->model()->count()) {
|
if (index < 0 || index >= view()->model()->count()) {
|
||||||
return 0;
|
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&)
|
QAccessibleInterface* KItemListViewAccessible::cellAt(int row, int column) const
|
||||||
{
|
|
||||||
return QVariant();
|
|
||||||
}
|
|
||||||
|
|
||||||
QAccessibleTable2CellInterface* KItemListViewAccessible::cellAt(int row, int column) const
|
|
||||||
{
|
{
|
||||||
return cell(columnCount() * row + column);
|
return cell(columnCount() * row + column);
|
||||||
}
|
}
|
||||||
|
@ -127,9 +143,9 @@ QString KItemListViewAccessible::rowDescription(int) const
|
||||||
return QString();
|
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()) {
|
Q_FOREACH (int index, view()->controller()->selectionManager()->selectedItems()) {
|
||||||
cells.append(cell(index));
|
cells.append(cell(index));
|
||||||
}
|
}
|
||||||
|
@ -181,42 +197,31 @@ bool KItemListViewAccessible::unselectColumn(int)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QAccessible2::TableModelChange KItemListViewAccessible::modelChange() const
|
void KItemListViewAccessible::modelChange(QAccessibleTableModelChangeEvent* /*event*/)
|
||||||
{
|
{}
|
||||||
QAccessible2::TableModelChange change;
|
|
||||||
change.lastRow = rowCount();
|
|
||||||
change.lastColumn = columnCount();
|
|
||||||
return change;
|
|
||||||
}
|
|
||||||
|
|
||||||
QAccessible::Role KItemListViewAccessible::role(int child) const
|
QAccessible::Role KItemListViewAccessible::role() const
|
||||||
{
|
{
|
||||||
Q_ASSERT(child >= 0);
|
|
||||||
|
|
||||||
if (child > 0) {
|
|
||||||
return QAccessible::Cell;
|
|
||||||
} else {
|
|
||||||
return QAccessible::Table;
|
return QAccessible::Table;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QAccessible::State KItemListViewAccessible::state(int child) const
|
QAccessible::State KItemListViewAccessible::state() const
|
||||||
{
|
{
|
||||||
if (child) {
|
QAccessible::State s;
|
||||||
QAccessibleInterface* interface = 0;
|
return s;
|
||||||
navigate(Child, child, &interface);
|
|
||||||
if (interface) {
|
|
||||||
return interface->state(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return QAccessible::Normal | QAccessible::HasInvokeExtension;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int KItemListViewAccessible::childAt(int x, int y) const
|
QAccessibleInterface* KItemListViewAccessible::childAt(int x, int y) const
|
||||||
{
|
{
|
||||||
const QPointF point = QPointF(x,y);
|
const QPointF point = QPointF(x, y);
|
||||||
return view()->itemAt(view()->mapFromScene(point));
|
int itemIndex = view()->itemAt(view()->mapFromScene(point));
|
||||||
|
return child(itemIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
QAccessibleInterface* KItemListViewAccessible::parent() const
|
||||||
|
{
|
||||||
|
// FIXME: return KItemListContainerAccessible here
|
||||||
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
int KItemListViewAccessible::childCount() const
|
int KItemListViewAccessible::childCount() const
|
||||||
|
@ -227,18 +232,16 @@ int KItemListViewAccessible::childCount() const
|
||||||
int KItemListViewAccessible::indexOfChild(const QAccessibleInterface* interface) const
|
int KItemListViewAccessible::indexOfChild(const QAccessibleInterface* interface) const
|
||||||
{
|
{
|
||||||
const KItemListAccessibleCell* widget = static_cast<const KItemListAccessibleCell*>(interface);
|
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();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect KItemListViewAccessible::rect(int child) const
|
QRect KItemListViewAccessible::rect() const
|
||||||
{
|
{
|
||||||
Q_UNUSED(child)
|
|
||||||
if (!view()->isVisible()) {
|
if (!view()->isVisible()) {
|
||||||
return QRect();
|
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;
|
if (index >= 0 && index < childCount()) {
|
||||||
|
return cell(index);
|
||||||
switch (relation) {
|
|
||||||
case QAccessible::Child:
|
|
||||||
Q_ASSERT(index > 0);
|
|
||||||
*interface = cell(index - 1);
|
|
||||||
if (*interface) {
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
break;
|
return Q_NULLPTR;
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
// Table Cell
|
||||||
|
|
||||||
KItemListAccessibleCell::KItemListAccessibleCell(KItemListView* view, int index) :
|
KItemListAccessibleCell::KItemListAccessibleCell(KItemListView* view, int index) :
|
||||||
|
@ -306,6 +273,14 @@ KItemListAccessibleCell::KItemListAccessibleCell(KItemListView* view, int index)
|
||||||
Q_ASSERT(index >= 0 && index < view->model()->count());
|
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
|
int KItemListAccessibleCell::columnExtent() const
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -341,52 +316,39 @@ bool KItemListAccessibleCell::isSelected() const
|
||||||
return m_view->controller()->selectionManager()->isSelected(m_index);
|
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;
|
return QAccessible::queryAccessibleInterface(m_view);
|
||||||
*row = layouter->itemRow(m_index);
|
|
||||||
*column = layouter->itemColumn(m_index);
|
|
||||||
*rowExtents = 1;
|
|
||||||
*columnExtents = 1;
|
|
||||||
*selected = isSelected();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
return QAccessible::Cell;
|
||||||
}
|
}
|
||||||
|
|
||||||
QAccessible::State KItemListAccessibleCell::state(int child) const
|
QAccessible::State KItemListAccessibleCell::state() const
|
||||||
{
|
{
|
||||||
Q_ASSERT(child == 0);
|
QAccessible::State state;
|
||||||
QAccessible::State state = Normal;
|
|
||||||
|
|
||||||
|
state.selectable = true;
|
||||||
if (isSelected()) {
|
if (isSelected()) {
|
||||||
state |= Selected;
|
state.selected = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
state.focusable = true;
|
||||||
if (m_view->controller()->selectionManager()->currentItem() == m_index) {
|
if (m_view->controller()->selectionManager()->currentItem() == m_index) {
|
||||||
state |= Focused;
|
state.focused = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
state |= Selectable;
|
|
||||||
state |= Focusable;
|
|
||||||
|
|
||||||
if (m_view->controller()->selectionBehavior() == KItemListController::MultiSelection) {
|
if (m_view->controller()->selectionBehavior() == KItemListController::MultiSelection) {
|
||||||
state |= MultiSelectable;
|
state.multiSelectable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_view->model()->isExpandable(m_index)) {
|
if (m_view->model()->isExpandable(m_index)) {
|
||||||
if (m_view->model()->isExpanded(m_index)) {
|
if (m_view->model()->isExpanded(m_index)) {
|
||||||
state |= Expanded;
|
state.expanded = true;
|
||||||
} else {
|
} else {
|
||||||
state |= Collapsed;
|
state.collapsed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -398,7 +360,7 @@ bool KItemListAccessibleCell::isExpandable() const
|
||||||
return m_view->model()->isExpandable(m_index);
|
return m_view->model()->isExpandable(m_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect KItemListAccessibleCell::rect(int) const
|
QRect KItemListAccessibleCell::rect() const
|
||||||
{
|
{
|
||||||
QRect rect = m_view->itemRect(m_index).toRect();
|
QRect rect = m_view->itemRect(m_index).toRect();
|
||||||
|
|
||||||
|
@ -411,13 +373,9 @@ QRect KItemListAccessibleCell::rect(int) const
|
||||||
return rect;
|
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) {
|
switch (t) {
|
||||||
case QAccessible::Value:
|
|
||||||
case QAccessible::Name: {
|
case QAccessible::Name: {
|
||||||
const QHash<QByteArray, QVariant> data = m_view->model()->data(m_index);
|
const QHash<QByteArray, QVariant> data = m_view->model()->data(m_index);
|
||||||
return data["text"].toString();
|
return data["text"].toString();
|
||||||
|
@ -430,9 +388,13 @@ QString KItemListAccessibleCell::text(QAccessible::Text t, int child) const
|
||||||
return QString();
|
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
|
bool KItemListAccessibleCell::isValid() const
|
||||||
|
@ -440,9 +402,9 @@ bool KItemListAccessibleCell::isValid() const
|
||||||
return m_view && (m_index >= 0) && (m_index < m_view->model()->count());
|
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
|
int KItemListAccessibleCell::childCount() const
|
||||||
|
@ -456,43 +418,11 @@ int KItemListAccessibleCell::indexOfChild(const QAccessibleInterface* child) con
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int KItemListAccessibleCell::navigate(RelationFlag relation, int index, QAccessibleInterface** interface) const
|
QAccessibleInterface* KItemListAccessibleCell::parent() const
|
||||||
{
|
{
|
||||||
if (relation == Ancestor && index == 1) {
|
return QAccessible::queryAccessibleInterface(m_view);
|
||||||
*interface = new KItemListViewAccessible(m_view);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
*interface = 0;
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
int KItemListAccessibleCell::index() const
|
||||||
{
|
{
|
||||||
return m_index;
|
return m_index;
|
||||||
|
@ -505,7 +435,7 @@ QObject* KItemListAccessibleCell::object() const
|
||||||
|
|
||||||
// Container Interface
|
// Container Interface
|
||||||
KItemListContainerAccessible::KItemListContainerAccessible(KItemListContainer* container) :
|
KItemListContainerAccessible::KItemListContainerAccessible(KItemListContainer* container) :
|
||||||
QAccessibleWidgetEx(container)
|
QAccessibleWidget(container)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -521,20 +451,17 @@ int KItemListContainerAccessible::childCount() const
|
||||||
int KItemListContainerAccessible::indexOfChild(const QAccessibleInterface* child) const
|
int KItemListContainerAccessible::indexOfChild(const QAccessibleInterface* child) const
|
||||||
{
|
{
|
||||||
if (child->object() == container()->controller()->view()) {
|
if (child->object() == container()->controller()->view()) {
|
||||||
return 1;
|
return 0;
|
||||||
} else {
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int KItemListContainerAccessible::navigate(QAccessible::RelationFlag relation, int index, QAccessibleInterface** target) const
|
QAccessibleInterface* KItemListContainerAccessible::child(int index) const
|
||||||
{
|
{
|
||||||
if (relation == QAccessible::Child) {
|
if (index == 0) {
|
||||||
*target = new KItemListViewAccessible(container()->controller()->view());
|
return QAccessible::queryAccessibleInterface(container()->controller()->view());
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
return QAccessibleWidgetEx::navigate(relation, index, target);
|
|
||||||
}
|
}
|
||||||
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
const KItemListContainer* KItemListContainerAccessible::container() const
|
const KItemListContainer* KItemListContainerAccessible::container() const
|
||||||
|
|
|
@ -22,118 +22,104 @@
|
||||||
|
|
||||||
#ifndef QT_NO_ACCESSIBILITY
|
#ifndef QT_NO_ACCESSIBILITY
|
||||||
|
|
||||||
|
#include "dolphin_export.h"
|
||||||
|
|
||||||
#include <QtCore/qpointer.h>
|
#include <QtCore/qpointer.h>
|
||||||
#include <QtGui/qaccessible.h>
|
#include <qaccessible.h>
|
||||||
#include <QtGui/qaccessible2.h>
|
#include <qaccessibleobject.h>
|
||||||
#include <QtGui/qaccessiblewidget.h>
|
#include <QtWidgets/qaccessiblewidget.h>
|
||||||
#include <QtGui/qaccessibleobject.h>
|
|
||||||
|
|
||||||
class KItemListView;
|
class KItemListView;
|
||||||
class KItemListContainer;
|
class KItemListContainer;
|
||||||
|
|
||||||
class KItemListViewAccessible: public QAccessibleTable2Interface, public QAccessibleObjectEx
|
class DOLPHIN_EXPORT KItemListViewAccessible: public QAccessibleObject, public QAccessibleTableInterface
|
||||||
{
|
{
|
||||||
Q_ACCESSIBLE_OBJECT
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit KItemListViewAccessible(KItemListView* view);
|
explicit KItemListViewAccessible(KItemListView* view);
|
||||||
|
~KItemListViewAccessible();
|
||||||
|
|
||||||
Role role(int child) const;
|
void* interface_cast(QAccessible::InterfaceType type) Q_DECL_OVERRIDE;
|
||||||
State state(int child) const;
|
|
||||||
QString text(Text t, int child) const;
|
|
||||||
QRect rect(int child) const;
|
|
||||||
|
|
||||||
int childAt(int x, int y) const;
|
QAccessible::Role role() const Q_DECL_OVERRIDE;
|
||||||
int childCount() const;
|
QAccessible::State state() const Q_DECL_OVERRIDE;
|
||||||
int indexOfChild(const QAccessibleInterface*) const;
|
QString text(QAccessible::Text t) const Q_DECL_OVERRIDE;
|
||||||
|
QRect rect() const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
int navigate(RelationFlag relation, int index, QAccessibleInterface** interface) const;
|
QAccessibleInterface* child(int index) const Q_DECL_OVERRIDE;
|
||||||
Relation relationTo(int child, const QAccessibleInterface* other, int otherChild) const;
|
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
|
// Table interface
|
||||||
int userActionCount(int child) const;
|
virtual QAccessibleInterface* cellAt(int row, int column) const Q_DECL_OVERRIDE;
|
||||||
QString actionText(int action, Text t, int child) const;
|
virtual QAccessibleInterface* caption() const Q_DECL_OVERRIDE;
|
||||||
bool doAction(int action, int child, const QVariantList& params);
|
virtual QAccessibleInterface* summary() const Q_DECL_OVERRIDE;
|
||||||
#endif
|
virtual QString columnDescription(int column) const Q_DECL_OVERRIDE;
|
||||||
QVariant invokeMethodEx(Method, int, const QVariantList&);
|
virtual QString rowDescription(int row) const Q_DECL_OVERRIDE;
|
||||||
|
virtual int columnCount() const Q_DECL_OVERRIDE;
|
||||||
// Table2 interface
|
virtual int rowCount() const Q_DECL_OVERRIDE;
|
||||||
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) {}
|
|
||||||
|
|
||||||
// Selection
|
// Selection
|
||||||
virtual int selectedCellCount() const;
|
virtual int selectedCellCount() const Q_DECL_OVERRIDE;
|
||||||
virtual int selectedColumnCount() const;
|
virtual int selectedColumnCount() const Q_DECL_OVERRIDE;
|
||||||
virtual int selectedRowCount() const;
|
virtual int selectedRowCount() const Q_DECL_OVERRIDE;
|
||||||
virtual QList<QAccessibleTable2CellInterface*> selectedCells() const;
|
virtual QList<QAccessibleInterface*> selectedCells() const Q_DECL_OVERRIDE;
|
||||||
virtual QList<int> selectedColumns() const;
|
virtual QList<int> selectedColumns() const Q_DECL_OVERRIDE;
|
||||||
virtual QList<int> selectedRows() const;
|
virtual QList<int> selectedRows() const Q_DECL_OVERRIDE;
|
||||||
virtual bool isColumnSelected(int column) const;
|
virtual bool isColumnSelected(int column) const Q_DECL_OVERRIDE;
|
||||||
virtual bool isRowSelected(int row) const;
|
virtual bool isRowSelected(int row) const Q_DECL_OVERRIDE;
|
||||||
virtual bool selectRow(int row);
|
virtual bool selectRow(int row) Q_DECL_OVERRIDE;
|
||||||
virtual bool selectColumn(int column);
|
virtual bool selectColumn(int column) Q_DECL_OVERRIDE;
|
||||||
virtual bool unselectRow(int row);
|
virtual bool unselectRow(int row) Q_DECL_OVERRIDE;
|
||||||
virtual bool unselectColumn(int column);
|
virtual bool unselectColumn(int column) Q_DECL_OVERRIDE;
|
||||||
|
virtual void modelChange(QAccessibleTableModelChangeEvent*) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
KItemListView* view() const;
|
KItemListView* view() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void modelReset();
|
virtual void modelReset();
|
||||||
/**
|
/**
|
||||||
* Create an QAccessibleTable2CellInterface representing the table
|
* Create an QAccessibleTableCellInterface representing the table
|
||||||
* cell at the @index. Index is 0-based.
|
* cell at the @index. Index is 0-based.
|
||||||
*/
|
*/
|
||||||
inline QAccessibleTable2CellInterface* cell(int index) const;
|
inline QAccessibleInterface* cell(int index) const;
|
||||||
inline QAccessible::Role cellRole() const;
|
|
||||||
|
private:
|
||||||
|
mutable QVector<QAccessibleInterface*> m_cells;
|
||||||
};
|
};
|
||||||
|
|
||||||
class KItemListAccessibleCell: public QAccessibleTable2CellInterface
|
class DOLPHIN_EXPORT KItemListAccessibleCell: public QAccessibleInterface, public QAccessibleTableCellInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
KItemListAccessibleCell(KItemListView* view, int m_index);
|
KItemListAccessibleCell(KItemListView* view, int m_index);
|
||||||
|
|
||||||
QObject* object() const;
|
void* interface_cast(QAccessible::InterfaceType type) Q_DECL_OVERRIDE;
|
||||||
Role role(int) const;
|
QObject* object() const Q_DECL_OVERRIDE;
|
||||||
State state(int) const;
|
bool isValid() const Q_DECL_OVERRIDE;
|
||||||
QRect rect(int) const;
|
QAccessible::Role role() const Q_DECL_OVERRIDE;
|
||||||
bool isValid() const;
|
QAccessible::State state() const Q_DECL_OVERRIDE;
|
||||||
int childAt(int, int) const;
|
QRect rect() const Q_DECL_OVERRIDE;
|
||||||
int childCount() const;
|
QString text(QAccessible::Text t) const Q_DECL_OVERRIDE;
|
||||||
int indexOfChild(const QAccessibleInterface*) const;
|
void setText(QAccessible::Text t, const QString& text) Q_DECL_OVERRIDE;
|
||||||
QString text(Text t, int child) const;
|
|
||||||
void setText(Text t, int child, const QString& text);
|
QAccessibleInterface* child(int index) const Q_DECL_OVERRIDE;
|
||||||
int navigate(RelationFlag relation, int m_index, QAccessibleInterface** interface) const;
|
int childCount() const Q_DECL_OVERRIDE;
|
||||||
Relation relationTo(int child, const QAccessibleInterface* other, int otherChild) const;
|
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;
|
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
|
// Cell Interface
|
||||||
virtual int columnExtent() const;
|
virtual int columnExtent() const Q_DECL_OVERRIDE;
|
||||||
virtual QList<QAccessibleInterface*> columnHeaderCells() const;
|
virtual QList<QAccessibleInterface*> columnHeaderCells() const Q_DECL_OVERRIDE;
|
||||||
virtual int columnIndex() const;
|
virtual int columnIndex() const Q_DECL_OVERRIDE;
|
||||||
virtual int rowExtent() const;
|
virtual int rowExtent() const Q_DECL_OVERRIDE;
|
||||||
virtual QList<QAccessibleInterface*> rowHeaderCells() const;
|
virtual QList<QAccessibleInterface*> rowHeaderCells() const Q_DECL_OVERRIDE;
|
||||||
virtual int rowIndex() const;
|
virtual int rowIndex() const Q_DECL_OVERRIDE;
|
||||||
virtual bool isSelected() const;
|
virtual bool isSelected() const Q_DECL_OVERRIDE;
|
||||||
virtual void rowColumnExtents(int* row, int* column, int* rowExtents, int* columnExtents, bool* selected) const;
|
virtual QAccessibleInterface* table() const Q_DECL_OVERRIDE;
|
||||||
virtual QAccessibleTable2Interface* table() const;
|
|
||||||
|
|
||||||
inline int index() const;
|
inline int index() const;
|
||||||
|
|
||||||
|
@ -142,17 +128,15 @@ private:
|
||||||
int m_index;
|
int m_index;
|
||||||
};
|
};
|
||||||
|
|
||||||
class KItemListContainerAccessible : public QAccessibleWidgetEx
|
class DOLPHIN_EXPORT KItemListContainerAccessible : public QAccessibleWidget
|
||||||
{
|
{
|
||||||
Q_ACCESSIBLE_OBJECT
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit KItemListContainerAccessible(KItemListContainer* container);
|
explicit KItemListContainerAccessible(KItemListContainer* container);
|
||||||
virtual ~KItemListContainerAccessible();
|
virtual ~KItemListContainerAccessible();
|
||||||
|
|
||||||
int childCount() const;
|
QAccessibleInterface* child(int index) const Q_DECL_OVERRIDE;
|
||||||
int indexOfChild(const QAccessibleInterface* child) const;
|
int childCount() const Q_DECL_OVERRIDE;
|
||||||
int navigate(RelationFlag relation, int entry, QAccessibleInterface** target) const;
|
int indexOfChild(const QAccessibleInterface* child) const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const KItemListContainer* container() const;
|
const KItemListContainer* container() const;
|
||||||
|
|
|
@ -27,9 +27,7 @@
|
||||||
|
|
||||||
#include "private/kitemlistselectiontoggle.h"
|
#include "private/kitemlistselectiontoggle.h"
|
||||||
|
|
||||||
#include <KDebug>
|
|
||||||
|
|
||||||
#include <KGlobalSettings>
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QPropertyAnimation>
|
#include <QPropertyAnimation>
|
||||||
|
@ -250,9 +248,9 @@ void KItemListWidget::setHovered(bool hovered)
|
||||||
|
|
||||||
if (!m_hoverAnimation) {
|
if (!m_hoverAnimation) {
|
||||||
m_hoverAnimation = new QPropertyAnimation(this, "hoverOpacity", this);
|
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);
|
m_hoverAnimation->setDuration(duration);
|
||||||
connect(m_hoverAnimation, SIGNAL(finished()), this, SLOT(slotHoverAnimationFinished()));
|
connect(m_hoverAnimation, &QPropertyAnimation::finished, this, &KItemListWidget::slotHoverAnimationFinished);
|
||||||
}
|
}
|
||||||
m_hoverAnimation->stop();
|
m_hoverAnimation->stop();
|
||||||
|
|
||||||
|
@ -526,4 +524,3 @@ void KItemListWidget::drawItemStyleOption(QPainter* painter, QWidget* widget, QS
|
||||||
widget->style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &viewItemOption, painter, widget);
|
widget->style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &viewItemOption, painter, widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "kitemlistwidget.moc"
|
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#ifndef KITEMLISTWIDGET_H
|
#ifndef KITEMLISTWIDGET_H
|
||||||
#define KITEMLISTWIDGET_H
|
#define KITEMLISTWIDGET_H
|
||||||
|
|
||||||
#include <libdolphin_export.h>
|
#include "dolphin_export.h"
|
||||||
|
|
||||||
#include <kitemviews/kitemliststyleoption.h>
|
#include <kitemviews/kitemliststyleoption.h>
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ class QPropertyAnimation;
|
||||||
* size for the invisible items must be accessible. KItemListWidgetInformant
|
* size for the invisible items must be accessible. KItemListWidgetInformant
|
||||||
* provides this information.
|
* provides this information.
|
||||||
*/
|
*/
|
||||||
class LIBDOLPHINPRIVATE_EXPORT KItemListWidgetInformant
|
class DOLPHIN_EXPORT KItemListWidgetInformant
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
KItemListWidgetInformant();
|
KItemListWidgetInformant();
|
||||||
|
@ -63,7 +63,7 @@ public:
|
||||||
* All properties are set by KItemListView, for each property there is a corresponding
|
* All properties are set by KItemListView, for each property there is a corresponding
|
||||||
* virtual protected method that allows to react on property changes.
|
* virtual protected method that allows to react on property changes.
|
||||||
*/
|
*/
|
||||||
class LIBDOLPHINPRIVATE_EXPORT KItemListWidget : public QGraphicsWidget
|
class DOLPHIN_EXPORT KItemListWidget : public QGraphicsWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ public:
|
||||||
* to show the data of the custom model provided by KItemListWidget::data().
|
* to show the data of the custom model provided by KItemListWidget::data().
|
||||||
* @reimp
|
* @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);
|
void setVisibleRoles(const QList<QByteArray>& roles);
|
||||||
QList<QByteArray> visibleRoles() const;
|
QList<QByteArray> visibleRoles() const;
|
||||||
|
@ -203,7 +203,7 @@ protected:
|
||||||
virtual void alternateBackgroundChanged(bool enabled);
|
virtual void alternateBackgroundChanged(bool enabled);
|
||||||
virtual void siblingsInformationChanged(const QBitArray& current, const QBitArray& previous);
|
virtual void siblingsInformationChanged(const QBitArray& current, const QBitArray& previous);
|
||||||
virtual void editedRoleChanged(const QByteArray& current, const QByteArray& 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
|
* @return The current opacity of the hover-animation. When implementing a custom painting-code for a hover-state
|
||||||
|
|
|
@ -159,4 +159,3 @@ void KItemModelBase::onSortOrderChanged(Qt::SortOrder current, Qt::SortOrder pre
|
||||||
Q_UNUSED(previous);
|
Q_UNUSED(previous);
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "kitemmodelbase.moc"
|
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#ifndef KITEMMODELBASE_H
|
#ifndef KITEMMODELBASE_H
|
||||||
#define KITEMMODELBASE_H
|
#define KITEMMODELBASE_H
|
||||||
|
|
||||||
#include <libdolphin_export.h>
|
#include "dolphin_export.h"
|
||||||
|
|
||||||
#include <kitemviews/kitemrange.h>
|
#include <kitemviews/kitemrange.h>
|
||||||
#include <kitemviews/kitemset.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
|
* Also optionally it is possible to provide a tree of items by implementing the methods
|
||||||
* setExpanded(), isExpanded(), isExpandable() and expandedParentsCount().
|
* setExpanded(), isExpanded(), isExpandable() and expandedParentsCount().
|
||||||
*/
|
*/
|
||||||
class LIBDOLPHINPRIVATE_EXPORT KItemModelBase : public QObject
|
class DOLPHIN_EXPORT KItemModelBase : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,8 @@
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include "kstandarditem.h"
|
#include "kstandarditem.h"
|
||||||
|
#include <QSet>
|
||||||
#include <KDebug>
|
#include <QByteArray>
|
||||||
#include "kstandarditemmodel.h"
|
#include "kstandarditemmodel.h"
|
||||||
|
|
||||||
KStandardItem::KStandardItem(KStandardItem* parent) :
|
KStandardItem::KStandardItem(KStandardItem* parent) :
|
||||||
|
|
|
@ -20,11 +20,10 @@
|
||||||
#ifndef KSTANDARDITEM_H
|
#ifndef KSTANDARDITEM_H
|
||||||
#define KSTANDARDITEM_H
|
#define KSTANDARDITEM_H
|
||||||
|
|
||||||
#include <libdolphin_export.h>
|
#include "dolphin_export.h"
|
||||||
|
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QIcon>
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
|
@ -37,7 +36,7 @@ class KStandardItemModel;
|
||||||
* used roles. It is possible to assign values for custom
|
* used roles. It is possible to assign values for custom
|
||||||
* roles by using setDataValue().
|
* roles by using setDataValue().
|
||||||
*/
|
*/
|
||||||
class LIBDOLPHINPRIVATE_EXPORT KStandardItem
|
class DOLPHIN_EXPORT KStandardItem
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
#include "kstandarditemlistgroupheader.h"
|
#include "kstandarditemlistgroupheader.h"
|
||||||
|
|
||||||
#include <kratingpainter.h>
|
#include <KRatingPainter>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
KStandardItemListGroupHeader::KStandardItemListGroupHeader(QGraphicsWidget* parent) :
|
KStandardItemListGroupHeader::KStandardItemListGroupHeader(QGraphicsWidget* parent) :
|
||||||
|
@ -122,4 +122,3 @@ void KStandardItemListGroupHeader::updateCache()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "kstandarditemlistgroupheader.moc"
|
|
||||||
|
|
|
@ -20,14 +20,14 @@
|
||||||
#ifndef KSTANDARDITEMLISTGROUPHEADER_H
|
#ifndef KSTANDARDITEMLISTGROUPHEADER_H
|
||||||
#define KSTANDARDITEMLISTGROUPHEADER_H
|
#define KSTANDARDITEMLISTGROUPHEADER_H
|
||||||
|
|
||||||
#include <libdolphin_export.h>
|
#include "dolphin_export.h"
|
||||||
|
|
||||||
#include <kitemviews/kitemlistgroupheader.h>
|
#include <kitemviews/kitemlistgroupheader.h>
|
||||||
|
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <QStaticText>
|
#include <QStaticText>
|
||||||
|
|
||||||
class LIBDOLPHINPRIVATE_EXPORT KStandardItemListGroupHeader : public KItemListGroupHeader
|
class DOLPHIN_EXPORT KStandardItemListGroupHeader : public KItemListGroupHeader
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -35,14 +35,14 @@ public:
|
||||||
KStandardItemListGroupHeader(QGraphicsWidget* parent = 0);
|
KStandardItemListGroupHeader(QGraphicsWidget* parent = 0);
|
||||||
virtual ~KStandardItemListGroupHeader();
|
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:
|
protected:
|
||||||
virtual void paintRole(QPainter* painter, const QRectF& roleBounds, const QColor& color);
|
virtual void paintRole(QPainter* painter, const QRectF& roleBounds, const QColor& color) Q_DECL_OVERRIDE;
|
||||||
virtual void paintSeparator(QPainter* painter, const QColor& color);
|
virtual void paintSeparator(QPainter* painter, const QColor& color) Q_DECL_OVERRIDE;
|
||||||
virtual void roleChanged(const QByteArray ¤t, const QByteArray &previous);
|
virtual void roleChanged(const QByteArray ¤t, const QByteArray &previous) Q_DECL_OVERRIDE;
|
||||||
virtual void dataChanged(const QVariant& current, const QVariant& previous);
|
virtual void dataChanged(const QVariant& current, const QVariant& previous) Q_DECL_OVERRIDE;
|
||||||
virtual void resizeEvent(QGraphicsSceneResizeEvent* event);
|
virtual void resizeEvent(QGraphicsSceneResizeEvent* event) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateCache();
|
void updateCache();
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
#include "kstandarditemlistview.h"
|
#include "kstandarditemlistview.h"
|
||||||
|
|
||||||
#include <KDebug>
|
|
||||||
#include <KIconLoader>
|
#include <KIconLoader>
|
||||||
#include "kstandarditemlistwidget.h"
|
#include "kstandarditemlistwidget.h"
|
||||||
#include "kstandarditemlistgroupheader.h"
|
#include "kstandarditemlistgroupheader.h"
|
||||||
|
@ -30,7 +29,7 @@ KStandardItemListView::KStandardItemListView(QGraphicsWidget* parent) :
|
||||||
{
|
{
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
setScrollOrientation(Qt::Vertical);
|
setScrollOrientation(Qt::Vertical);
|
||||||
setVisibleRoles(QList<QByteArray>() << "text");
|
setVisibleRoles({"text"});
|
||||||
}
|
}
|
||||||
|
|
||||||
KStandardItemListView::~KStandardItemListView()
|
KStandardItemListView::~KStandardItemListView()
|
||||||
|
@ -179,4 +178,3 @@ void KStandardItemListView::updateLayoutOfVisibleItems()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "kstandarditemlistview.moc"
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#ifndef KSTANDARDITEMLISTVIEW_H
|
#ifndef KSTANDARDITEMLISTVIEW_H
|
||||||
#define KSTANDARDITEMLISTVIEW_H
|
#define KSTANDARDITEMLISTVIEW_H
|
||||||
|
|
||||||
#include <libdolphin_export.h>
|
#include "dolphin_export.h"
|
||||||
|
|
||||||
#include <kitemviews/kitemlistview.h>
|
#include <kitemviews/kitemlistview.h>
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@
|
||||||
* KItemListContainer* container = new KItemListContainer(controller, parentWidget);
|
* KItemListContainer* container = new KItemListContainer(controller, parentWidget);
|
||||||
* </code>
|
* </code>
|
||||||
*/
|
*/
|
||||||
class LIBDOLPHINPRIVATE_EXPORT KStandardItemListView : public KItemListView
|
class DOLPHIN_EXPORT KStandardItemListView : public KItemListView
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -59,15 +59,15 @@ public:
|
||||||
ItemLayout itemLayout() const;
|
ItemLayout itemLayout() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual KItemListWidgetCreatorBase* defaultWidgetCreator() const;
|
virtual KItemListWidgetCreatorBase* defaultWidgetCreator() const Q_DECL_OVERRIDE;
|
||||||
virtual KItemListGroupHeaderCreatorBase* defaultGroupHeaderCreator() const;
|
virtual KItemListGroupHeaderCreatorBase* defaultGroupHeaderCreator() const Q_DECL_OVERRIDE;
|
||||||
virtual void initializeItemListWidget(KItemListWidget* item);
|
virtual void initializeItemListWidget(KItemListWidget* item) Q_DECL_OVERRIDE;
|
||||||
virtual bool itemSizeHintUpdateRequired(const QSet<QByteArray>& changedRoles) const;
|
virtual bool itemSizeHintUpdateRequired(const QSet<QByteArray>& changedRoles) const Q_DECL_OVERRIDE;
|
||||||
virtual bool itemLayoutSupportsItemExpanding(ItemLayout layout) const;
|
virtual bool itemLayoutSupportsItemExpanding(ItemLayout layout) const;
|
||||||
virtual void onItemLayoutChanged(ItemLayout current, ItemLayout previous);
|
virtual void onItemLayoutChanged(ItemLayout current, ItemLayout previous);
|
||||||
virtual void onScrollOrientationChanged(Qt::Orientation current, Qt::Orientation previous);
|
virtual void onScrollOrientationChanged(Qt::Orientation current, Qt::Orientation previous) Q_DECL_OVERRIDE;
|
||||||
virtual void onSupportsItemExpandingChanged(bool supportsExpanding);
|
virtual void onSupportsItemExpandingChanged(bool supportsExpanding) Q_DECL_OVERRIDE;
|
||||||
virtual void polishEvent();
|
virtual void polishEvent() Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void applyDefaultStyleOption(int iconSize, int padding, int horizontalMargin, int verticalMargin);
|
void applyDefaultStyleOption(int iconSize, int padding, int horizontalMargin, int verticalMargin);
|
||||||
|
|
|
@ -22,19 +22,16 @@
|
||||||
#include "kfileitemlistview.h"
|
#include "kfileitemlistview.h"
|
||||||
#include "kfileitemmodel.h"
|
#include "kfileitemmodel.h"
|
||||||
|
|
||||||
#include <KIcon>
|
#include <QIcon>
|
||||||
#include <KIconEffect>
|
#include <KIconEffect>
|
||||||
#include <KIconLoader>
|
#include <KIconLoader>
|
||||||
#include <KLocale>
|
#include <KRatingPainter>
|
||||||
#include <kratingpainter.h>
|
|
||||||
#include <KStringHandler>
|
#include <KStringHandler>
|
||||||
#include <KDebug>
|
|
||||||
|
|
||||||
#include "private/kfileitemclipboard.h"
|
#include "private/kfileitemclipboard.h"
|
||||||
#include "private/kitemlistroleeditor.h"
|
#include "private/kitemlistroleeditor.h"
|
||||||
#include "private/kpixmapmodifier.h"
|
#include "private/kpixmapmodifier.h"
|
||||||
|
|
||||||
#include <QFontMetricsF>
|
|
||||||
#include <QGraphicsScene>
|
#include <QGraphicsScene>
|
||||||
#include <QGraphicsSceneResizeEvent>
|
#include <QGraphicsSceneResizeEvent>
|
||||||
#include <QGraphicsView>
|
#include <QGraphicsView>
|
||||||
|
@ -120,6 +117,8 @@ QString KStandardItemListWidgetInformant::itemText(int index, const KItemListVie
|
||||||
|
|
||||||
bool KStandardItemListWidgetInformant::itemIsLink(int index, const KItemListView* view) const
|
bool KStandardItemListWidgetInformant::itemIsLink(int index, const KItemListView* view) const
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(index);
|
||||||
|
Q_UNUSED(view);
|
||||||
return false;
|
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
|
// 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.
|
// been changed). Therefore, the "is cut" state must be updated.
|
||||||
KFileItemClipboard* clipboard = KFileItemClipboard::instance();
|
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);
|
m_isCut = clipboard->isCut(itemUrl);
|
||||||
|
|
||||||
// The icon-state might depend from other roles and hence is
|
// 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) {
|
if (m_roleEditor) {
|
||||||
emit roleEditingCanceled(index(), current, data().value(current));
|
emit roleEditingCanceled(index(), current, data().value(current));
|
||||||
|
|
||||||
disconnect(m_roleEditor, SIGNAL(roleEditingCanceled(QByteArray,QVariant)),
|
disconnect(m_roleEditor, &KItemListRoleEditor::roleEditingCanceled,
|
||||||
this, SLOT(slotRoleEditingCanceled(QByteArray,QVariant)));
|
this, &KStandardItemListWidget::slotRoleEditingCanceled);
|
||||||
disconnect(m_roleEditor, SIGNAL(roleEditingFinished(QByteArray,QVariant)),
|
disconnect(m_roleEditor, &KItemListRoleEditor::roleEditingFinished,
|
||||||
this, SLOT(slotRoleEditingFinished(QByteArray,QVariant)));
|
this, &KStandardItemListWidget::slotRoleEditingFinished);
|
||||||
|
|
||||||
if (m_oldRoleEditor) {
|
if (m_oldRoleEditor) {
|
||||||
m_oldRoleEditor->deleteLater();
|
m_oldRoleEditor->deleteLater();
|
||||||
|
@ -796,10 +795,10 @@ void KStandardItemListWidget::editedRoleChanged(const QByteArray& current, const
|
||||||
m_roleEditor->setTextCursor(cursor);
|
m_roleEditor->setTextCursor(cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(m_roleEditor, SIGNAL(roleEditingCanceled(QByteArray,QVariant)),
|
connect(m_roleEditor, &KItemListRoleEditor::roleEditingCanceled,
|
||||||
this, SLOT(slotRoleEditingCanceled(QByteArray,QVariant)));
|
this, &KStandardItemListWidget::slotRoleEditingCanceled);
|
||||||
connect(m_roleEditor, SIGNAL(roleEditingFinished(QByteArray,QVariant)),
|
connect(m_roleEditor, &KItemListRoleEditor::roleEditingFinished,
|
||||||
this, SLOT(slotRoleEditingFinished(QByteArray,QVariant)));
|
this, &KStandardItemListWidget::slotRoleEditingFinished);
|
||||||
|
|
||||||
// Adjust the geometry of the editor
|
// Adjust the geometry of the editor
|
||||||
QRectF rect = roleEditingRect(current);
|
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
|
// Listen to changes of the clipboard to mark the item as cut/uncut
|
||||||
KFileItemClipboard* clipboard = KFileItemClipboard::instance();
|
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);
|
m_isCut = clipboard->isCut(itemUrl);
|
||||||
|
|
||||||
connect(clipboard, SIGNAL(cutItemsChanged()),
|
connect(clipboard, &KFileItemClipboard::cutItemsChanged,
|
||||||
this, SLOT(slotCutItemsChanged()));
|
this, &KStandardItemListWidget::slotCutItemsChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KStandardItemListWidget::hideEvent(QHideEvent* event)
|
void KStandardItemListWidget::hideEvent(QHideEvent* event)
|
||||||
{
|
{
|
||||||
disconnect(KFileItemClipboard::instance(), SIGNAL(cutItemsChanged()),
|
disconnect(KFileItemClipboard::instance(), &KFileItemClipboard::cutItemsChanged,
|
||||||
this, SLOT(slotCutItemsChanged()));
|
this, &KStandardItemListWidget::slotCutItemsChanged);
|
||||||
|
|
||||||
KItemListWidget::hideEvent(event);
|
KItemListWidget::hideEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KStandardItemListWidget::slotCutItemsChanged()
|
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);
|
const bool isCut = KFileItemClipboard::instance()->isCut(itemUrl);
|
||||||
if (m_isCut != isCut) {
|
if (m_isCut != isCut) {
|
||||||
m_isCut = isCut;
|
m_isCut = isCut;
|
||||||
|
@ -1415,10 +1414,10 @@ QRectF KStandardItemListWidget::roleEditingRect(const QByteArray& role) const
|
||||||
|
|
||||||
void KStandardItemListWidget::closeRoleEditor()
|
void KStandardItemListWidget::closeRoleEditor()
|
||||||
{
|
{
|
||||||
disconnect(m_roleEditor, SIGNAL(roleEditingCanceled(QByteArray,QVariant)),
|
disconnect(m_roleEditor, &KItemListRoleEditor::roleEditingCanceled,
|
||||||
this, SLOT(slotRoleEditingCanceled(QByteArray,QVariant)));
|
this, &KStandardItemListWidget::slotRoleEditingCanceled);
|
||||||
disconnect(m_roleEditor, SIGNAL(roleEditingFinished(QByteArray,QVariant)),
|
disconnect(m_roleEditor, &KItemListRoleEditor::roleEditingFinished,
|
||||||
this, SLOT(slotRoleEditingFinished(QByteArray,QVariant)));
|
this, &KStandardItemListWidget::slotRoleEditingFinished);
|
||||||
|
|
||||||
if (m_roleEditor->hasFocus()) {
|
if (m_roleEditor->hasFocus()) {
|
||||||
// If the editing was not ended by a FocusOut event, we have
|
// 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;
|
QPixmap pixmap;
|
||||||
|
|
||||||
if (!QPixmapCache::find(key, pixmap)) {
|
if (!QPixmapCache::find(key, pixmap)) {
|
||||||
const KIcon icon(name);
|
const QIcon icon = QIcon::fromTheme(name);
|
||||||
|
|
||||||
int requestedSize;
|
int requestedSize;
|
||||||
if (size <= KIconLoader::SizeSmall) {
|
if (size <= KIconLoader::SizeSmall) {
|
||||||
|
@ -1497,4 +1496,3 @@ qreal KStandardItemListWidget::columnPadding(const KItemListStyleOption& option)
|
||||||
return option.padding * 6;
|
return option.padding * 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "kstandarditemlistwidget.moc"
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#ifndef KSTANDARDITEMLISTWIDGET_H
|
#ifndef KSTANDARDITEMLISTWIDGET_H
|
||||||
#define KSTANDARDITEMLISTWIDGET_H
|
#define KSTANDARDITEMLISTWIDGET_H
|
||||||
|
|
||||||
#include <libdolphin_export.h>
|
#include "dolphin_export.h"
|
||||||
|
|
||||||
#include <kitemviews/kitemlistwidget.h>
|
#include <kitemviews/kitemlistwidget.h>
|
||||||
|
|
||||||
|
@ -32,17 +32,17 @@ class KItemListRoleEditor;
|
||||||
class KItemListStyleOption;
|
class KItemListStyleOption;
|
||||||
class KItemListView;
|
class KItemListView;
|
||||||
|
|
||||||
class LIBDOLPHINPRIVATE_EXPORT KStandardItemListWidgetInformant : public KItemListWidgetInformant
|
class DOLPHIN_EXPORT KStandardItemListWidgetInformant : public KItemListWidgetInformant
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
KStandardItemListWidgetInformant();
|
KStandardItemListWidgetInformant();
|
||||||
virtual ~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,
|
virtual qreal preferredRoleColumnWidth(const QByteArray& role,
|
||||||
int index,
|
int index,
|
||||||
const KItemListView* view) const;
|
const KItemListView* view) const Q_DECL_OVERRIDE;
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* @return The value of the "text" role. The default implementation returns
|
* @return The value of the "text" role. The default implementation returns
|
||||||
|
@ -83,7 +83,7 @@ protected:
|
||||||
/**
|
/**
|
||||||
* @brief Itemlist widget implementation for KStandardItemView and KStandardItemModel.
|
* @brief Itemlist widget implementation for KStandardItemView and KStandardItemModel.
|
||||||
*/
|
*/
|
||||||
class LIBDOLPHINPRIVATE_EXPORT KStandardItemListWidget : public KItemListWidget
|
class DOLPHIN_EXPORT KStandardItemListWidget : public KItemListWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -106,13 +106,13 @@ public:
|
||||||
|
|
||||||
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
|
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
|
||||||
|
|
||||||
virtual QRectF iconRect() const;
|
virtual QRectF iconRect() const Q_DECL_OVERRIDE;
|
||||||
virtual QRectF textRect() const;
|
virtual QRectF textRect() const Q_DECL_OVERRIDE;
|
||||||
virtual QRectF textFocusRect() const;
|
virtual QRectF textFocusRect() const Q_DECL_OVERRIDE;
|
||||||
virtual QRectF selectionRect() const;
|
virtual QRectF selectionRect() const Q_DECL_OVERRIDE;
|
||||||
virtual QRectF expansionToggleRect() const;
|
virtual QRectF expansionToggleRect() const Q_DECL_OVERRIDE;
|
||||||
virtual QRectF selectionToggleRect() const;
|
virtual QRectF selectionToggleRect() const Q_DECL_OVERRIDE;
|
||||||
virtual QPixmap createDragPixmap(const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
|
virtual QPixmap createDragPixmap(const QStyleOptionGraphicsItem* option, QWidget* widget = 0) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
static KItemListWidgetInformant* createInformant();
|
static KItemListWidgetInformant* createInformant();
|
||||||
|
|
||||||
|
@ -172,17 +172,17 @@ protected:
|
||||||
*/
|
*/
|
||||||
virtual int selectionLength(const QString& text) const;
|
virtual int selectionLength(const QString& text) const;
|
||||||
|
|
||||||
virtual void dataChanged(const QHash<QByteArray, QVariant>& current, const QSet<QByteArray>& roles = QSet<QByteArray>());
|
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);
|
virtual void visibleRolesChanged(const QList<QByteArray>& current, const QList<QByteArray>& previous) Q_DECL_OVERRIDE;
|
||||||
virtual void columnWidthChanged(const QByteArray& role, qreal current, qreal previous);
|
virtual void columnWidthChanged(const QByteArray& role, qreal current, qreal previous) Q_DECL_OVERRIDE;
|
||||||
virtual void styleOptionChanged(const KItemListStyleOption& current, const KItemListStyleOption& previous);
|
virtual void styleOptionChanged(const KItemListStyleOption& current, const KItemListStyleOption& previous) Q_DECL_OVERRIDE;
|
||||||
virtual void hoveredChanged(bool hovered);
|
virtual void hoveredChanged(bool hovered) Q_DECL_OVERRIDE;
|
||||||
virtual void selectedChanged(bool selected);
|
virtual void selectedChanged(bool selected) Q_DECL_OVERRIDE;
|
||||||
virtual void siblingsInformationChanged(const QBitArray& current, const QBitArray& previous);
|
virtual void siblingsInformationChanged(const QBitArray& current, const QBitArray& previous) Q_DECL_OVERRIDE;
|
||||||
virtual void editedRoleChanged(const QByteArray& current, const QByteArray& previous);
|
virtual void editedRoleChanged(const QByteArray& current, const QByteArray& previous) Q_DECL_OVERRIDE;
|
||||||
virtual void resizeEvent(QGraphicsSceneResizeEvent* event);
|
virtual void resizeEvent(QGraphicsSceneResizeEvent* event) Q_DECL_OVERRIDE;
|
||||||
virtual void showEvent(QShowEvent* event);
|
virtual void showEvent(QShowEvent* event) Q_DECL_OVERRIDE;
|
||||||
virtual void hideEvent(QHideEvent* event);
|
virtual void hideEvent(QHideEvent* event) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void slotCutItemsChanged();
|
void slotCutItemsChanged();
|
||||||
|
@ -274,5 +274,3 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,9 +19,9 @@
|
||||||
|
|
||||||
#include "kstandarditemmodel.h"
|
#include "kstandarditemmodel.h"
|
||||||
|
|
||||||
#include <KDebug>
|
|
||||||
#include "kstandarditem.h"
|
#include "kstandarditem.h"
|
||||||
|
#include <QSet>
|
||||||
|
#include <QByteArray>
|
||||||
KStandardItemModel::KStandardItemModel(QObject* parent) :
|
KStandardItemModel::KStandardItemModel(QObject* parent) :
|
||||||
KItemModelBase(parent),
|
KItemModelBase(parent),
|
||||||
m_items(),
|
m_items(),
|
||||||
|
@ -237,5 +237,3 @@ void KStandardItemModel::onItemRemoved(int index, KStandardItem* removedItem)
|
||||||
Q_UNUSED(removedItem);
|
Q_UNUSED(removedItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#include "kstandarditemmodel.moc"
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#ifndef KSTANDARDITEMMODEL_H
|
#ifndef KSTANDARDITEMMODEL_H
|
||||||
#define KSTANDARDITEMMODEL_H
|
#define KSTANDARDITEMMODEL_H
|
||||||
|
|
||||||
#include <libdolphin_export.h>
|
#include "dolphin_export.h"
|
||||||
#include <kitemviews/kitemmodelbase.h>
|
#include <kitemviews/kitemmodelbase.h>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
@ -35,7 +35,7 @@ class KStandardItem;
|
||||||
*
|
*
|
||||||
* @see KStandardItem
|
* @see KStandardItem
|
||||||
*/
|
*/
|
||||||
class LIBDOLPHINPRIVATE_EXPORT KStandardItemModel : public KItemModelBase
|
class DOLPHIN_EXPORT KStandardItemModel : public KItemModelBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -69,14 +69,14 @@ public:
|
||||||
*/
|
*/
|
||||||
void appendItem(KStandardItem* item);
|
void appendItem(KStandardItem* item);
|
||||||
|
|
||||||
virtual int count() const;
|
virtual int count() const Q_DECL_OVERRIDE;
|
||||||
virtual QHash<QByteArray, QVariant> data(int index) const;
|
virtual QHash<QByteArray, QVariant> data(int index) const Q_DECL_OVERRIDE;
|
||||||
virtual bool setData(int index, const QHash<QByteArray, QVariant>& values);
|
virtual bool setData(int index, const QHash<QByteArray, QVariant>& values) Q_DECL_OVERRIDE;
|
||||||
virtual QMimeData* createMimeData(const KItemSet& indexes) const;
|
virtual QMimeData* createMimeData(const KItemSet& indexes) const Q_DECL_OVERRIDE;
|
||||||
virtual int indexForKeyboardSearch(const QString& text, int startFromIndex = 0) const;
|
virtual int indexForKeyboardSearch(const QString& text, int startFromIndex = 0) const Q_DECL_OVERRIDE;
|
||||||
virtual bool supportsDropping(int index) const;
|
virtual bool supportsDropping(int index) const Q_DECL_OVERRIDE;
|
||||||
virtual QString roleDescription(const QByteArray& role) const;
|
virtual QString roleDescription(const QByteArray& role) const Q_DECL_OVERRIDE;
|
||||||
virtual QList<QPair<int, QVariant> > groups() const;
|
virtual QList<QPair<int, QVariant> > groups() const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
virtual void clear();
|
virtual void clear();
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -20,12 +20,12 @@
|
||||||
|
|
||||||
#include "kbaloorolesprovider.h"
|
#include "kbaloorolesprovider.h"
|
||||||
|
|
||||||
#include <KDebug>
|
#include <QDebug>
|
||||||
#include <KGlobal>
|
#include <KLocalizedString>
|
||||||
#include <KLocale>
|
|
||||||
|
|
||||||
#include <baloo/file.h>
|
#include <Baloo/File>
|
||||||
#include <kfilemetadata/propertyinfo.h>
|
#include <KFileMetaData/PropertyInfo>
|
||||||
|
#include <KFileMetaData/UserMetaData>
|
||||||
|
|
||||||
#include <QTime>
|
#include <QTime>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
@ -34,7 +34,7 @@ struct KBalooRolesProviderSingleton
|
||||||
{
|
{
|
||||||
KBalooRolesProvider instance;
|
KBalooRolesProvider instance;
|
||||||
};
|
};
|
||||||
K_GLOBAL_STATIC(KBalooRolesProviderSingleton, s_balooRolesProvider)
|
Q_GLOBAL_STATIC(KBalooRolesProviderSingleton, s_balooRolesProvider)
|
||||||
|
|
||||||
|
|
||||||
KBalooRolesProvider& KBalooRolesProvider::instance()
|
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")) {
|
if (roles.contains("tags")) {
|
||||||
values.insert("tags", tagsFromValues(file.tags()));
|
values.insert("tags", tagsFromValues(md.tags()));
|
||||||
}
|
}
|
||||||
if (roles.contains("rating")) {
|
if (roles.contains("rating")) {
|
||||||
values.insert("rating", QString::number(file.rating()));
|
values.insert("rating", QString::number(md.rating()));
|
||||||
}
|
}
|
||||||
if (roles.contains("comment")) {
|
if (roles.contains("comment")) {
|
||||||
values.insert("comment", file.userComment());
|
values.insert("comment", md.userComment());
|
||||||
}
|
}
|
||||||
|
|
||||||
return values;
|
return values;
|
||||||
|
|
|
@ -21,12 +21,11 @@
|
||||||
#ifndef KBALOO_ROLESPROVIDER_H
|
#ifndef KBALOO_ROLESPROVIDER_H
|
||||||
#define KBALOO_ROLESPROVIDER_H
|
#define KBALOO_ROLESPROVIDER_H
|
||||||
|
|
||||||
#include <libdolphin_export.h>
|
#include "dolphin_export.h"
|
||||||
|
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QUrl>
|
#include <QVariant>
|
||||||
|
|
||||||
namespace Baloo {
|
namespace Baloo {
|
||||||
class File;
|
class File;
|
||||||
}
|
}
|
||||||
|
@ -37,7 +36,7 @@ namespace Baloo {
|
||||||
* Is a helper class for KFileItemModelRolesUpdater to retrieve roles that
|
* Is a helper class for KFileItemModelRolesUpdater to retrieve roles that
|
||||||
* are only accessible with Baloo.
|
* are only accessible with Baloo.
|
||||||
*/
|
*/
|
||||||
class LIBDOLPHINPRIVATE_EXPORT KBalooRolesProvider
|
class DOLPHIN_EXPORT KBalooRolesProvider
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static KBalooRolesProvider& instance();
|
static KBalooRolesProvider& instance();
|
||||||
|
|
|
@ -35,8 +35,8 @@ KDirectoryContentsCounter::KDirectoryContentsCounter(KFileItemModel* model, QObj
|
||||||
m_dirWatcher(0),
|
m_dirWatcher(0),
|
||||||
m_watchedDirs()
|
m_watchedDirs()
|
||||||
{
|
{
|
||||||
connect(m_model, SIGNAL(itemsRemoved(KItemRangeList)),
|
connect(m_model, &KFileItemModel::itemsRemoved,
|
||||||
this, SLOT(slotItemsRemoved()));
|
this, &KDirectoryContentsCounter::slotItemsRemoved);
|
||||||
|
|
||||||
if (!m_workerThread) {
|
if (!m_workerThread) {
|
||||||
m_workerThread = new QThread();
|
m_workerThread = new QThread();
|
||||||
|
@ -47,13 +47,13 @@ KDirectoryContentsCounter::KDirectoryContentsCounter(KFileItemModel* model, QObj
|
||||||
m_worker->moveToThread(m_workerThread);
|
m_worker->moveToThread(m_workerThread);
|
||||||
++m_workersCount;
|
++m_workersCount;
|
||||||
|
|
||||||
connect(this, SIGNAL(requestDirectoryContentsCount(QString,KDirectoryContentsCounterWorker::Options)),
|
connect(this, &KDirectoryContentsCounter::requestDirectoryContentsCount,
|
||||||
m_worker, SLOT(countDirectoryContents(QString,KDirectoryContentsCounterWorker::Options)));
|
m_worker, &KDirectoryContentsCounterWorker::countDirectoryContents);
|
||||||
connect(m_worker, SIGNAL(result(QString,int)),
|
connect(m_worker, &KDirectoryContentsCounterWorker::result,
|
||||||
this, SLOT(slotResult(QString,int)));
|
this, &KDirectoryContentsCounter::slotResult);
|
||||||
|
|
||||||
m_dirWatcher = new KDirWatch(this);
|
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()
|
KDirectoryContentsCounter::~KDirectoryContentsCounter()
|
||||||
|
@ -122,7 +122,7 @@ void KDirectoryContentsCounter::slotResult(const QString& path, int count)
|
||||||
|
|
||||||
void KDirectoryContentsCounter::slotDirWatchDirty(const QString& path)
|
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 (index >= 0) {
|
||||||
if (!m_model->fileItem(index).isDir()) {
|
if (!m_model->fileItem(index).isDir()) {
|
||||||
// If INotify is used, KDirWatch issues the dirty() signal
|
// If INotify is used, KDirWatch issues the dirty() signal
|
||||||
|
@ -151,7 +151,7 @@ void KDirectoryContentsCounter::slotItemsRemoved()
|
||||||
QMutableSetIterator<QString> it(m_watchedDirs);
|
QMutableSetIterator<QString> it(m_watchedDirs);
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
const QString& path = it.next();
|
const QString& path = it.next();
|
||||||
if (m_model->index(KUrl(path)) < 0) {
|
if (m_model->index(QUrl::fromLocalFile(path)) < 0) {
|
||||||
m_dirWatcher->removeDir(path);
|
m_dirWatcher->removeDir(path);
|
||||||
it.remove();
|
it.remove();
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
#ifndef KDIRECTORYCONTENTENTSCOUNTERWORKER_H
|
#ifndef KDIRECTORYCONTENTENTSCOUNTERWORKER_H
|
||||||
#define KDIRECTORYCONTENTENTSCOUNTERWORKER_H
|
#define KDIRECTORYCONTENTENTSCOUNTERWORKER_H
|
||||||
|
|
||||||
#include <QFlags>
|
|
||||||
#include <QMetaType>
|
#include <QMetaType>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
|
|
|
@ -19,17 +19,17 @@
|
||||||
|
|
||||||
#include "kfileitemclipboard.h"
|
#include "kfileitemclipboard.h"
|
||||||
|
|
||||||
#include <KGlobal>
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
|
#include <KUrlMimeData>
|
||||||
|
|
||||||
class KFileItemClipboardSingleton
|
class KFileItemClipboardSingleton
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
KFileItemClipboard instance;
|
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;
|
return &s_KFileItemClipboard->instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KFileItemClipboard::isCut(const KUrl& url) const
|
bool KFileItemClipboard::isCut(const QUrl& url) const
|
||||||
{
|
{
|
||||||
return m_cutItems.contains(url);
|
return m_cutItems.contains(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<KUrl> KFileItemClipboard::cutItems() const
|
QList<QUrl> KFileItemClipboard::cutItems() const
|
||||||
{
|
{
|
||||||
return m_cutItems.toList();
|
return m_cutItems.toList();
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ void KFileItemClipboard::updateCutItems()
|
||||||
const QByteArray data = mimeData->data("application/x-kde-cutselection");
|
const QByteArray data = mimeData->data("application/x-kde-cutselection");
|
||||||
const bool isCutSelection = (!data.isEmpty() && data.at(0) == QLatin1Char('1'));
|
const bool isCutSelection = (!data.isEmpty() && data.at(0) == QLatin1Char('1'));
|
||||||
if (isCutSelection) {
|
if (isCutSelection) {
|
||||||
m_cutItems = KUrl::List::fromMimeData(mimeData).toSet();
|
m_cutItems = KUrlMimeData::urlsFromMimeData(mimeData).toSet();
|
||||||
} else {
|
} else {
|
||||||
m_cutItems.clear();
|
m_cutItems.clear();
|
||||||
}
|
}
|
||||||
|
@ -79,8 +79,6 @@ KFileItemClipboard::KFileItemClipboard() :
|
||||||
{
|
{
|
||||||
updateCutItems();
|
updateCutItems();
|
||||||
|
|
||||||
connect(QApplication::clipboard(), SIGNAL(dataChanged()),
|
connect(QApplication::clipboard(), &QClipboard::dataChanged,
|
||||||
this, SLOT(updateCutItems()));
|
this, &KFileItemClipboard::updateCutItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "kfileitemclipboard.moc"
|
|
||||||
|
|
|
@ -20,27 +20,27 @@
|
||||||
#ifndef KFILEITEMCLIPBOARD_H
|
#ifndef KFILEITEMCLIPBOARD_H
|
||||||
#define KFILEITEMCLIPBOARD_H
|
#define KFILEITEMCLIPBOARD_H
|
||||||
|
|
||||||
#include <KUrl>
|
#include <QUrl>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include "libdolphin_export.h"
|
#include "dolphin_export.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Wrapper for QClipboard to provide fast access for checking
|
* @brief Wrapper for QClipboard to provide fast access for checking
|
||||||
* whether a KFileItem has been clipped.
|
* whether a KFileItem has been clipped.
|
||||||
*/
|
*/
|
||||||
class LIBDOLPHINPRIVATE_EXPORT KFileItemClipboard : public QObject
|
class DOLPHIN_EXPORT KFileItemClipboard : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static KFileItemClipboard* instance();
|
static KFileItemClipboard* instance();
|
||||||
|
|
||||||
bool isCut(const KUrl& url) const;
|
bool isCut(const QUrl& url) const;
|
||||||
|
|
||||||
QList<KUrl> cutItems() const;
|
QList<QUrl> cutItems() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void cutItemsChanged();
|
void cutItemsChanged();
|
||||||
|
@ -54,7 +54,7 @@ private slots:
|
||||||
private:
|
private:
|
||||||
KFileItemClipboard();
|
KFileItemClipboard();
|
||||||
|
|
||||||
QSet<KUrl> m_cutItems;
|
QSet<QUrl> m_cutItems;
|
||||||
|
|
||||||
friend class KFileItemClipboardSingleton;
|
friend class KFileItemClipboardSingleton;
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,8 +18,8 @@
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include "kfileitemmodeldirlister.h"
|
#include "kfileitemmodeldirlister.h"
|
||||||
#include <KLocale>
|
#include <KLocalizedString>
|
||||||
#include <KIO/JobClasses>
|
#include <KIO/Job>
|
||||||
|
|
||||||
KFileItemModelDirLister::KFileItemModelDirLister(QObject* parent) :
|
KFileItemModelDirLister::KFileItemModelDirLister(QObject* parent) :
|
||||||
KDirLister(parent)
|
KDirLister(parent)
|
||||||
|
@ -45,4 +45,3 @@ void KFileItemModelDirLister::handleError(KIO::Job* job)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "kfileitemmodeldirlister.moc"
|
|
||||||
|
|