┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEmmanuel Pescosta <[email protected]>2015-02-27 11:30:27 +0100
committerEmmanuel Pescosta <[email protected]>2015-02-27 11:30:27 +0100
commit9aee5d22513f0367febab54b38b3a7dc58d120bb (patch)
tree99cf391070ac5d4650a3f1b309c3ec2e814f1ac6 /src
parentf025aeb63aa2a38e91c43d99ba9955793d3adf1e (diff)
parentb701b7e4edefb628d6f8b14146b2e299bd0ce5fc (diff)
Merge branch 'frameworks'
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt228
-rw-r--r--src/config-dolphin.h.cmake4
-rw-r--r--src/dolphin.appdata.xml2
-rw-r--r--src/dolphinapplication.cpp106
-rw-r--r--src/dolphincontextmenu.cpp128
-rw-r--r--src/dolphincontextmenu.h25
-rw-r--r--src/dolphindebug.cpp (renamed from src/search/filenamesearchprotocol.h)44
-rw-r--r--src/dolphindebug.h (renamed from src/dolphinapplication.h)29
-rw-r--r--src/dolphindockwidget.cpp1
-rw-r--r--src/dolphinmainwindow.cpp602
-rw-r--r--src/dolphinmainwindow.h75
-rw-r--r--src/dolphinnewfilemenu.cpp1
-rw-r--r--src/dolphinnewfilemenu.h6
-rw-r--r--src/dolphinpart.cpp213
-rw-r--r--src/dolphinpart.h27
-rw-r--r--src/dolphinpart.rc2
-rw-r--r--src/dolphinpart_ext.cpp5
-rw-r--r--src/dolphinpart_ext.h23
-rw-r--r--src/dolphinrecenttabsmenu.cpp16
-rw-r--r--src/dolphinrecenttabsmenu.h7
-rw-r--r--src/dolphinremoveaction.cpp4
-rw-r--r--src/dolphinremoveaction.h4
-rw-r--r--src/dolphintabbar.cpp23
-rw-r--r--src/dolphintabbar.h14
-rw-r--r--src/dolphintabpage.cpp47
-rw-r--r--src/dolphintabpage.h14
-rw-r--r--src/dolphintabwidget.cpp50
-rw-r--r--src/dolphintabwidget.h24
-rw-r--r--src/dolphinviewcontainer.cpp245
-rw-r--r--src/dolphinviewcontainer.h52
-rw-r--r--src/filterbar/filterbar.cpp30
-rw-r--r--src/filterbar/filterbar.h8
-rw-r--r--src/kitemviews/kfileitemlistview.cpp19
-rw-r--r--src/kitemviews/kfileitemlistview.h37
-rw-r--r--src/kitemviews/kfileitemlistwidget.cpp16
-rw-r--r--src/kitemviews/kfileitemlistwidget.h22
-rw-r--r--src/kitemviews/kfileitemmodel.cpp284
-rw-r--r--src/kitemviews/kfileitemmodel.h84
-rw-r--r--src/kitemviews/kfileitemmodelrolesupdater.cpp159
-rw-r--r--src/kitemviews/kfileitemmodelrolesupdater.h12
-rw-r--r--src/kitemviews/kitemlistcontainer.cpp57
-rw-r--r--src/kitemviews/kitemlistcontainer.h16
-rw-r--r--src/kitemviews/kitemlistcontroller.cpp35
-rw-r--r--src/kitemviews/kitemlistcontroller.h10
-rw-r--r--src/kitemviews/kitemlistgroupheader.cpp2
-rw-r--r--src/kitemviews/kitemlistgroupheader.h9
-rw-r--r--src/kitemviews/kitemlistheader.cpp5
-rw-r--r--src/kitemviews/kitemlistheader.h4
-rw-r--r--src/kitemviews/kitemlistselectionmanager.cpp3
-rw-r--r--src/kitemviews/kitemlistselectionmanager.h4
-rw-r--r--src/kitemviews/kitemliststyleoption.cpp1
-rw-r--r--src/kitemviews/kitemliststyleoption.h4
-rw-r--r--src/kitemviews/kitemlistview.cpp167
-rw-r--r--src/kitemviews/kitemlistview.h35
-rw-r--r--src/kitemviews/kitemlistviewaccessible.cpp259
-rw-r--r--src/kitemviews/kitemlistviewaccessible.h158
-rw-r--r--src/kitemviews/kitemlistwidget.cpp7
-rw-r--r--src/kitemviews/kitemlistwidget.h10
-rw-r--r--src/kitemviews/kitemmodelbase.cpp1
-rw-r--r--src/kitemviews/kitemmodelbase.h4
-rw-r--r--src/kitemviews/kstandarditem.cpp4
-rw-r--r--src/kitemviews/kstandarditem.h5
-rw-r--r--src/kitemviews/kstandarditemlistgroupheader.cpp3
-rw-r--r--src/kitemviews/kstandarditemlistgroupheader.h16
-rw-r--r--src/kitemviews/kstandarditemlistview.cpp4
-rw-r--r--src/kitemviews/kstandarditemlistview.h18
-rw-r--r--src/kitemviews/kstandarditemlistwidget.cpp50
-rw-r--r--src/kitemviews/kstandarditemlistwidget.h48
-rw-r--r--src/kitemviews/kstandarditemmodel.cpp6
-rw-r--r--src/kitemviews/kstandarditemmodel.h20
-rw-r--r--src/kitemviews/private/kbaloorolesprovider.cpp19
-rw-r--r--src/kitemviews/private/kbaloorolesprovider.h7
-rw-r--r--src/kitemviews/private/kdirectorycontentscounter.cpp20
-rw-r--r--src/kitemviews/private/kdirectorycontentscounterworker.h1
-rw-r--r--src/kitemviews/private/kfileitemclipboard.cpp16
-rw-r--r--src/kitemviews/private/kfileitemclipboard.h12
-rw-r--r--src/kitemviews/private/kfileitemmodeldirlister.cpp5
-rw-r--r--src/kitemviews/private/kfileitemmodeldirlister.h7
-rw-r--r--src/kitemviews/private/kfileitemmodelfilter.h4
-rw-r--r--src/kitemviews/private/kfileitemmodelsortalgorithm.h2
-rw-r--r--src/kitemviews/private/kitemlistheaderwidget.cpp20
-rw-r--r--src/kitemviews/private/kitemlistheaderwidget.h4
-rw-r--r--src/kitemviews/private/kitemlistkeyboardsearchmanager.cpp2
-rw-r--r--src/kitemviews/private/kitemlistkeyboardsearchmanager.h4
-rw-r--r--src/kitemviews/private/kitemlistroleeditor.cpp6
-rw-r--r--src/kitemviews/private/kitemlistroleeditor.h4
-rw-r--r--src/kitemviews/private/kitemlistrubberband.cpp1
-rw-r--r--src/kitemviews/private/kitemlistrubberband.h4
-rw-r--r--src/kitemviews/private/kitemlistselectiontoggle.cpp3
-rw-r--r--src/kitemviews/private/kitemlistselectiontoggle.h5
-rw-r--r--src/kitemviews/private/kitemlistsizehintresolver.h4
-rw-r--r--src/kitemviews/private/kitemlistsmoothscroller.cpp11
-rw-r--r--src/kitemviews/private/kitemlistsmoothscroller.h4
-rw-r--r--src/kitemviews/private/kitemlistviewanimation.cpp18
-rw-r--r--src/kitemviews/private/kitemlistviewanimation.h6
-rw-r--r--src/kitemviews/private/kitemlistviewlayouter.cpp5
-rw-r--r--src/kitemviews/private/kitemlistviewlayouter.h4
-rw-r--r--src/kitemviews/private/kpixmapmodifier.cpp1
-rw-r--r--src/kitemviews/private/kpixmapmodifier.h4
-rw-r--r--src/libdolphin_export.h38
-rw-r--r--src/main.cpp191
-rwxr-xr-xsrc/org.kde.dolphin.desktop (renamed from src/dolphin.desktop)3
-rw-r--r--src/panels/folders/foldersitemlistwidget.cpp1
-rw-r--r--src/panels/folders/foldersitemlistwidget.h2
-rw-r--r--src/panels/folders/folderspanel.cpp55
-rw-r--r--src/panels/folders/folderspanel.h16
-rw-r--r--src/panels/folders/treeviewcontextmenu.cpp93
-rw-r--r--src/panels/folders/treeviewcontextmenu.h1
-rw-r--r--src/panels/information/filemetadataconfigurationdialog.cpp44
-rw-r--r--src/panels/information/filemetadataconfigurationdialog.h7
-rw-r--r--src/panels/information/informationpanel.cpp63
-rw-r--r--src/panels/information/informationpanel.h20
-rw-r--r--src/panels/information/informationpanelcontent.cpp74
-rw-r--r--src/panels/information/informationpanelcontent.h11
-rw-r--r--src/panels/information/phononwidget.cpp32
-rw-r--r--src/panels/information/phononwidget.h13
-rw-r--r--src/panels/information/pixmapviewer.cpp7
-rw-r--r--src/panels/information/pixmapviewer.h4
-rw-r--r--src/panels/panel.cpp11
-rw-r--r--src/panels/panel.h12
-rw-r--r--src/panels/places/placesitem.cpp43
-rw-r--r--src/panels/places/placesitem.h12
-rw-r--r--src/panels/places/placesitemeditdialog.cpp61
-rw-r--r--src/panels/places/placesitemeditdialog.h20
-rw-r--r--src/panels/places/placesitemlistgroupheader.cpp1
-rw-r--r--src/panels/places/placesitemlistgroupheader.h2
-rw-r--r--src/panels/places/placesitemlistwidget.cpp3
-rw-r--r--src/panels/places/placesitemlistwidget.h4
-rw-r--r--src/panels/places/placesitemmodel.cpp193
-rw-r--r--src/panels/places/placesitemmodel.h34
-rw-r--r--src/panels/places/placesitemsignalhandler.cpp1
-rw-r--r--src/panels/places/placesitemsignalhandler.h2
-rw-r--r--src/panels/places/placespanel.cpp139
-rw-r--r--src/panels/places/placespanel.h18
-rw-r--r--src/panels/places/placesview.cpp3
-rw-r--r--src/panels/terminal/terminalpanel.cpp26
-rw-r--r--src/panels/terminal/terminalpanel.h16
-rw-r--r--src/search/dolphinfacetswidget.cpp5
-rw-r--r--src/search/dolphinfacetswidget.h3
-rw-r--r--src/search/dolphinsearchbox.cpp107
-rw-r--r--src/search/dolphinsearchbox.h34
-rw-r--r--src/search/filenamesearch.protocol17
-rw-r--r--src/search/filenamesearchprotocol.cpp191
-rw-r--r--src/settings/additionalinfodialog.cpp50
-rw-r--r--src/settings/additionalinfodialog.h9
-rw-r--r--src/settings/applyviewpropsjob.cpp12
-rw-r--r--src/settings/applyviewpropsjob.h9
-rw-r--r--src/settings/dolphin_compactmodesettings.kcfg6
-rw-r--r--src/settings/dolphin_detailsmodesettings.kcfg6
-rw-r--r--src/settings/dolphin_generalsettings.kcfg16
-rw-r--r--src/settings/dolphin_iconsmodesettings.kcfg6
-rw-r--r--src/settings/dolphinsettingsdialog.cpp77
-rw-r--r--src/settings/dolphinsettingsdialog.h10
-rw-r--r--src/settings/general/behaviorsettingspage.cpp33
-rw-r--r--src/settings/general/behaviorsettingspage.h11
-rw-r--r--src/settings/general/configurepreviewplugindialog.cpp85
-rw-r--r--src/settings/general/configurepreviewplugindialog.h21
-rw-r--r--src/settings/general/confirmationssettingspage.cpp32
-rw-r--r--src/settings/general/confirmationssettingspage.h5
-rw-r--r--src/settings/general/generalsettingspage.cpp20
-rw-r--r--src/settings/general/generalsettingspage.h8
-rw-r--r--src/settings/general/previewssettingspage.cpp37
-rw-r--r--src/settings/general/previewssettingspage.h10
-rw-r--r--src/settings/general/statusbarsettingspage.cpp11
-rw-r--r--src/settings/general/statusbarsettingspage.h4
-rw-r--r--src/settings/kcm/kcmdolphingeneral.cpp18
-rw-r--r--src/settings/kcm/kcmdolphingeneral.desktop2
-rw-r--r--src/settings/kcm/kcmdolphingeneral.h4
-rw-r--r--src/settings/kcm/kcmdolphinnavigation.cpp10
-rw-r--r--src/settings/kcm/kcmdolphinnavigation.desktop2
-rw-r--r--src/settings/kcm/kcmdolphinnavigation.h4
-rw-r--r--src/settings/kcm/kcmdolphinservices.cpp10
-rw-r--r--src/settings/kcm/kcmdolphinservices.desktop2
-rw-r--r--src/settings/kcm/kcmdolphinservices.h4
-rw-r--r--src/settings/kcm/kcmdolphinviewmodes.cpp27
-rw-r--r--src/settings/kcm/kcmdolphinviewmodes.desktop2
-rw-r--r--src/settings/kcm/kcmdolphinviewmodes.h4
-rw-r--r--src/settings/navigation/navigationsettingspage.cpp53
-rw-r--r--src/settings/navigation/navigationsettingspage.h7
-rw-r--r--src/settings/serviceitemdelegate.cpp23
-rw-r--r--src/settings/serviceitemdelegate.h8
-rw-r--r--src/settings/servicemodel.cpp1
-rw-r--r--src/settings/servicemodel.h8
-rw-r--r--src/settings/services/servicessettingspage.cpp29
-rw-r--r--src/settings/services/servicessettingspage.h9
-rw-r--r--src/settings/settingspagebase.cpp1
-rw-r--r--src/settings/startup/startupsettingspage.cpp97
-rw-r--r--src/settings/startup/startupsettingspage.h14
-rw-r--r--src/settings/trash/trashsettingspage.cpp16
-rw-r--r--src/settings/trash/trashsettingspage.h4
-rw-r--r--src/settings/viewmodes/dolphinfontrequester.cpp26
-rw-r--r--src/settings/viewmodes/viewmodesettings.cpp14
-rw-r--r--src/settings/viewmodes/viewmodesettings.h2
-rw-r--r--src/settings/viewmodes/viewsettingspage.cpp22
-rw-r--r--src/settings/viewmodes/viewsettingspage.h4
-rw-r--r--src/settings/viewmodes/viewsettingstab.cpp28
-rw-r--r--src/settings/viewpropertiesdialog.cpp146
-rw-r--r--src/settings/viewpropertiesdialog.h13
-rw-r--r--src/settings/viewpropsprogressinfo.cpp83
-rw-r--r--src/settings/viewpropsprogressinfo.h16
-rw-r--r--src/statusbar/dolphinstatusbar.cpp33
-rw-r--r--src/statusbar/dolphinstatusbar.h10
-rw-r--r--src/statusbar/mountpointobserver.cpp29
-rw-r--r--src/statusbar/mountpointobserver.h28
-rw-r--r--src/statusbar/mountpointobservercache.cpp44
-rw-r--r--src/statusbar/mountpointobservercache.h8
-rw-r--r--src/statusbar/spaceinfoobserver.cpp72
-rw-r--r--src/statusbar/spaceinfoobserver.h16
-rw-r--r--src/statusbar/spaceinfotoolsmenu.cpp103
-rw-r--r--src/statusbar/spaceinfotoolsmenu.h41
-rw-r--r--src/statusbar/statusbarspaceinfo.cpp21
-rw-r--r--src/statusbar/statusbarspaceinfo.h19
-rw-r--r--src/tests/CMakeLists.txt113
-rw-r--r--src/tests/dolphinsearchboxtest.cpp7
-rw-r--r--src/tests/kfileitemlistviewtest.cpp32
-rw-r--r--src/tests/kfileitemmodelbenchmark.cpp34
-rw-r--r--src/tests/kfileitemmodeltest.cpp605
-rw-r--r--src/tests/kitemlistcontrollertest.cpp132
-rw-r--r--src/tests/kitemlistkeyboardsearchmanagertest.cpp19
-rw-r--r--src/tests/kitemlistselectionmanagertest.cpp33
-rw-r--r--src/tests/kitemrangetest.cpp43
-rw-r--r--src/tests/kitemsettest.cpp5
-rw-r--r--src/tests/kstandarditemmodeltest.cpp10
-rw-r--r--src/tests/testdir.cpp19
-rw-r--r--src/tests/testdir.h12
-rw-r--r--src/tests/viewpropertiestest.cpp20
-rw-r--r--src/views/dolphinfileitemlistwidget.cpp36
-rw-r--r--src/views/dolphinfileitemlistwidget.h10
-rw-r--r--src/views/dolphinitemlistview.cpp10
-rw-r--r--src/views/dolphinitemlistview.h16
-rw-r--r--src/views/dolphinnewfilemenuobserver.cpp28
-rw-r--r--src/views/dolphinnewfilemenuobserver.h7
-rw-r--r--src/views/dolphinremoteencoding.cpp41
-rw-r--r--src/views/dolphinremoteencoding.h8
-rw-r--r--src/views/dolphinview.cpp373
-rw-r--r--src/views/dolphinview.h89
-rw-r--r--src/views/dolphinviewactionhandler.cpp162
-rw-r--r--src/views/dolphinviewactionhandler.h8
-rw-r--r--src/views/draganddrophelper.cpp40
-rw-r--r--src/views/draganddrophelper.h27
-rw-r--r--src/views/renamedialog.cpp119
-rw-r--r--src/views/renamedialog.h24
-rw-r--r--src/views/tooltips/filemetadatatooltip.cpp22
-rw-r--r--src/views/tooltips/filemetadatatooltip.h4
-rw-r--r--src/views/tooltips/tooltipmanager.cpp26
-rw-r--r--src/views/tooltips/tooltipmanager.h4
-rw-r--r--src/views/versioncontrol/kversioncontrolplugin.cpp29
-rw-r--r--src/views/versioncontrol/kversioncontrolplugin.h223
-rw-r--r--src/views/versioncontrol/updateitemstatesthread.cpp19
-rw-r--r--src/views/versioncontrol/updateitemstatesthread.h8
-rw-r--r--src/views/versioncontrol/versioncontrolobserver.cpp112
-rw-r--r--src/views/versioncontrol/versioncontrolobserver.h18
-rw-r--r--src/views/viewmodecontroller.cpp7
-rw-r--r--src/views/viewmodecontroller.h16
-rw-r--r--src/views/viewproperties.cpp53
-rw-r--r--src/views/viewproperties.h21
256 files changed, 4805 insertions, 4947 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 6f256a2f4..9ea45e34b 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,39 +1,62 @@
-macro_optional_find_package(Baloo)
-set_package_properties(Baloo PROPERTIES DESCRIPTION "Baloo Core libraries"
- URL "http://www.kde.org"
- TYPE OPTIONAL
- PURPOSE "For adding desktop-wide search and tagging support to dolphin"
- )
-macro_optional_find_package(BalooWidgets)
-set_package_properties(BalooWidgets PROPERTIES DESCRIPTION "Baloos Widgets"
- URL "http://www.kde.org"
- TYPE OPTIONAL
- )
+configure_file(config-baloo.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-baloo.h)
-macro_optional_find_package(KFileMetaData)
-set_package_properties(KFileMetaData PROPERTIES
- URL "https://projects.kde.org/kfilemetadata"
- TYPE OPTIONAL
- PURPOSE "For accessing file metadata labels"
- )
+configure_file(config-dolphin.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-dolphin.h)
-if (Baloo_FOUND AND BalooWidgets_FOUND AND KFileMetaData_FOUND)
- set(HAVE_BALOO TRUE)
+add_definitions(
+ -DTRANSLATION_DOMAIN=\"dolphin\"
+ -DQT_USE_FAST_CONCATENATION
+ -DQT_USE_FAST_OPERATOR_PLUS
+)
+remove_definitions(
+ -DQT_NO_CAST_FROM_BYTEARRAY
+ -DQT_NO_URL_CAST_FROM_STRING
+ -DQT_NO_SIGNALS_SLOTS_KEYWORDS
+ -DQT_NO_CAST_FROM_ASCII
+ -DQT_NO_CAST_TO_ASCII
+)
+
+if(X11_Xrender_FOUND)
+ set(HAVE_XRENDER TRUE)
endif()
-configure_file(config-baloo.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-baloo.h )
+configure_file(config-X11.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-X11.h)
-macro_bool_to_01(X11_Xrender_FOUND HAVE_XRENDER)
-configure_file(config-X11.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-X11.h )
+##########################################
-include_directories( ${KACTIVITIES_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR} )
+set(dolphinvcs_LIB_SRCS
+ views/versioncontrol/kversioncontrolplugin.cpp
+)
-if(HAVE_BALOO)
- include_directories(${BALOO_INCLUDE_DIR} ${BALOO_WIDGETS_INCLUDE_DIR} ${KFILEMETADATA_INCLUDE_DIR})
-endif()
+add_library(dolphinvcs ${dolphinvcs_LIB_SRCS})
+
+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})
-add_subdirectory(tests)
+install(FILES views/versioncontrol/fileviewversioncontrolplugin.desktop DESTINATION ${KDE_INSTALL_KSERVICETYPES5DIR})
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/dolphin_export.h DESTINATION ${KDE_INSTALL_INCLUDEDIR} COMPONENT Devel)
+install(FILES ${dolphinvcs_LIB_HEADERS} DESTINATION "${KDE_INSTALL_INCLUDEDIR}/Dolphin" COMPONENT Devel)
########### next target ###############
@@ -95,6 +118,7 @@ set(dolphinprivate_LIB_SRCS
views/zoomlevelinfo.cpp
dolphinremoveaction.cpp
dolphinnewfilemenu.cpp
+ dolphindebug.cpp
)
if(HAVE_BALOO)
@@ -104,7 +128,7 @@ if(HAVE_BALOO)
)
endif()
-kde4_add_kcfg_files(dolphinprivate_LIB_SRCS
+kconfig_add_kcfg_files(dolphinprivate_LIB_SRCS GENERATE_MOC
settings/dolphin_compactmodesettings.kcfgc
settings/dolphin_directoryviewpropertysettings.kcfgc
settings/dolphin_detailsmodesettings.kcfgc
@@ -113,21 +137,35 @@ kde4_add_kcfg_files(dolphinprivate_LIB_SRCS
settings/dolphin_versioncontrolsettings.kcfgc
)
-kde4_add_library(dolphinprivate SHARED ${dolphinprivate_LIB_SRCS})
+add_library(dolphinprivate ${dolphinprivate_LIB_SRCS})
target_link_libraries(
- dolphinprivate
- ${KDE4_KFILE_LIBS}
- konq
- ${KDE4_KNEWSTUFF3_LIBS}
+ dolphinprivate PUBLIC
+ dolphinvcs
+ Qt5::Gui
+ KF5::I18n
+ KF5::IconThemes
+ KF5::KIOCore
+ KF5::KIOWidgets
+ KF5::KIOFileWidgets
+ KF5::Completion
+ KF5::TextEditor
+ KF5::WindowSystem
+ KF5::ConfigCore
+ KF5::NewStuff
)
if(HAVE_BALOO)
target_link_libraries(
- dolphinprivate
- ${BALOO_LIBRARIES}
- ${BALOO_WIDGETS_LIBRARY}
- ${KFILEMETADATA_LIBRARY}
+ dolphinprivate PUBLIC
+ KF5::FileMetaData
+ KF5::Baloo
+ KF5::BalooWidgets
+ )
+else()
+ target_link_libraries(
+ dolphinprivate PUBLIC
+ KF5::KDELibs4Support # for KFileMetaDataWidget
)
endif()
@@ -135,38 +173,35 @@ if(X11_Xrender_FOUND)
target_link_libraries(dolphinprivate ${X11_Xrender_LIB})
endif(X11_Xrender_FOUND)
-target_link_libraries(dolphinprivate ${KDE4_PLASMA_LIBS})
+set_target_properties(dolphinprivate PROPERTIES
+ VERSION ${DOLPHINPRIVATE_VERSION_STRING}
+ SOVERSION ${DOLPHINPRIVATE_SOVERSION}
+)
-set_target_properties(dolphinprivate PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION} )
-install(TARGETS dolphinprivate ${INSTALL_TARGETS_DEFAULT_ARGS})
+install(TARGETS dolphinprivate ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
##########################################
set(dolphinpart_SRCS
dolphinpart.cpp
+ dolphinpart_ext.cpp
+ dolphindebug.cpp
)
-# Add dolphinpart_ext.cpp conditionally, only with KDE > 4.9.1.
-if (${KDE_VERSION} VERSION_GREATER "4.9.1")
-set(dolphinpart_SRCS
- ${dolphinpart_SRCS}
- dolphinpart_ext.cpp)
-endif (${KDE_VERSION} VERSION_GREATER "4.9.1")
+add_library(dolphinpart MODULE ${dolphinpart_SRCS})
-kde4_add_plugin(dolphinpart ${dolphinpart_SRCS})
-
-target_link_libraries(dolphinpart dolphinprivate konq ${KDE4_KPARTS_LIBS} ${KDE4_KFILE_LIBS})
+target_link_libraries(dolphinpart
+ dolphinprivate
+)
install(TARGETS dolphinpart DESTINATION ${PLUGIN_INSTALL_DIR})
-install(FILES dolphinpart.rc DESTINATION ${DATA_INSTALL_DIR}/dolphinpart)
-install(FILES dolphinpart.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
-install(FILES views/versioncontrol/fileviewversioncontrolplugin.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR})
+install(FILES dolphinpart.rc DESTINATION ${CMAKE_INSTALL_KXMLGUI5DIR}/dolphinpart)
+install(FILES dolphinpart.desktop DESTINATION ${SERVICES_INSTALL_DIR})
##########################################
set(dolphin_SRCS
- dolphinapplication.cpp
dolphindockwidget.cpp
dolphinmainwindow.cpp
dolphinviewcontainer.cpp
@@ -217,12 +252,14 @@ set(dolphin_SRCS
statusbar/dolphinstatusbar.cpp
statusbar/mountpointobserver.cpp
statusbar/mountpointobservercache.cpp
+ statusbar/spaceinfotoolsmenu.cpp
statusbar/spaceinfoobserver.cpp
statusbar/statusbarspaceinfo.cpp
views/zoomlevelinfo.cpp
+ dolphindebug.cpp
)
-kde4_add_kcfg_files(dolphin_SRCS
+kconfig_add_kcfg_files(dolphin_SRCS GENERATE_MOC
panels/folders/dolphin_folderspanelsettings.kcfgc
panels/information/dolphin_informationpanelsettings.kcfgc
panels/places/dolphin_placespanelsettings.kcfgc
@@ -236,40 +273,36 @@ kde4_add_kcfg_files(dolphin_SRCS
if(NOT WIN32)
set(dolphin_SRCS ${dolphin_SRCS} panels/terminal/terminalpanel.cpp)
-endif(NOT WIN32)
+endif()
-kde4_add_app_icon(dolphin_SRCS "${KDE4_ICON_INSTALL_DIR}/oxygen/*/apps/system-file-manager.png")
+# TODO Does anything replace kde4_add_app_icon ?
+#kde4_add_app_icon(dolphin_SRCS "${KDE4_ICON_INSTALL_DIR}/oxygen/*/apps/system-file-manager.png")
-kde4_add_kdeinit_executable(dolphin ${dolphin_SRCS})
+kf5_add_kdeinit_executable(dolphin ${dolphin_SRCS})
+
+target_include_directories(kdeinit_dolphin PRIVATE ${PHONON_INCLUDES})
target_link_libraries(kdeinit_dolphin
- ${KDE4_KDEPRINT_LIBS}
- ${KDE4_KFILE_LIBS}
- ${KDE4_KPARTS_LIBS}
- ${KDE4_KCMUTILS_LIBRARY}
- konq
dolphinprivate
- knewstuff3
- ${KDE4_SOLID_LIBS}
- ${KDE4_PHONON_LIBS}
+ KF5::Parts
+ KF5::KCMUtils
+ KF5::Solid
+ KF5::CoreAddons
+ KF5::DBusAddons
+ KF5::Bookmarks
+ KF5::Notifications
+ Phonon::phonon4qt5
)
-if(HAVE_BALOO)
- target_link_libraries(kdeinit_dolphin
- ${BALOO_LIBRARIES}
- ${BALOO_WIDGETS_LIBRARY}
- )
-endif()
-
-if (KActivities_FOUND)
+if (KF5Activities_FOUND)
target_link_libraries(
kdeinit_dolphin
- ${KACTIVITIES_LIBRARY}
+ KF5::Activities
)
-endif (KActivities_FOUND)
+endif()
-install(TARGETS kdeinit_dolphin ${INSTALL_TARGETS_DEFAULT_ARGS})
-install(TARGETS dolphin ${INSTALL_TARGETS_DEFAULT_ARGS})
+install(TARGETS kdeinit_dolphin ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
+install(TARGETS dolphin ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
##########################################
@@ -302,7 +335,7 @@ set(kcm_dolphingeneral_PART_SRCS
settings/serviceitemdelegate.cpp
settings/servicemodel.cpp)
-kde4_add_kcfg_files(kcm_dolphinviewmodes_PART_SRCS
+kconfig_add_kcfg_files(kcm_dolphinviewmodes_PART_SRCS
settings/dolphin_compactmodesettings.kcfgc
settings/dolphin_directoryviewpropertysettings.kcfgc
settings/dolphin_detailsmodesettings.kcfgc
@@ -311,42 +344,34 @@ kde4_add_kcfg_files(kcm_dolphinviewmodes_PART_SRCS
settings/dolphin_versioncontrolsettings.kcfgc
)
-kde4_add_kcfg_files(kcm_dolphinnavigation_PART_SRCS
+kconfig_add_kcfg_files(kcm_dolphinnavigation_PART_SRCS
settings/dolphin_generalsettings.kcfgc)
-kde4_add_kcfg_files(kcm_dolphinservices_PART_SRCS
+kconfig_add_kcfg_files(kcm_dolphinservices_PART_SRCS
settings/dolphin_generalsettings.kcfgc
settings/dolphin_versioncontrolsettings.kcfgc)
-kde4_add_kcfg_files(kcm_dolphingeneral_PART_SRCS
+kconfig_add_kcfg_files(kcm_dolphingeneral_PART_SRCS
settings/dolphin_generalsettings.kcfgc)
-kde4_add_plugin(kcm_dolphinviewmodes ${kcm_dolphinviewmodes_PART_SRCS})
-kde4_add_plugin(kcm_dolphinnavigation ${kcm_dolphinnavigation_PART_SRCS})
-kde4_add_plugin(kcm_dolphinservices ${kcm_dolphinservices_PART_SRCS})
-kde4_add_plugin(kcm_dolphingeneral ${kcm_dolphingeneral_PART_SRCS})
+add_library(kcm_dolphinviewmodes MODULE ${kcm_dolphinviewmodes_PART_SRCS})
+add_library(kcm_dolphinnavigation MODULE ${kcm_dolphinnavigation_PART_SRCS})
+add_library(kcm_dolphinservices MODULE ${kcm_dolphinservices_PART_SRCS})
+add_library(kcm_dolphingeneral MODULE ${kcm_dolphingeneral_PART_SRCS})
-target_link_libraries(kcm_dolphinviewmodes ${KDE4_KDEUI_LIBS} ${KDE4_KFILE_LIBS} dolphinprivate)
-target_link_libraries(kcm_dolphinnavigation ${KDE4_KDEUI_LIBS} ${KDE4_KFILE_LIBS} dolphinprivate)
-target_link_libraries(kcm_dolphinservices ${KDE4_KDEUI_LIBS} ${KDE4_KFILE_LIBS} ${KDE4_KIO_LIBS} ${KDE4_KNEWSTUFF3_LIBRARY} dolphinprivate)
-target_link_libraries(kcm_dolphingeneral ${KDE4_KDEUI_LIBS} ${KDE4_KFILE_LIBS} ${KDE4_KIO_LIBS} dolphinprivate)
+target_link_libraries(kcm_dolphinviewmodes dolphinprivate)
+target_link_libraries(kcm_dolphinnavigation dolphinprivate)
+target_link_libraries(kcm_dolphinservices dolphinprivate)
+target_link_libraries(kcm_dolphingeneral dolphinprivate)
install(TARGETS kcm_dolphinviewmodes DESTINATION ${PLUGIN_INSTALL_DIR} )
install(TARGETS kcm_dolphinnavigation DESTINATION ${PLUGIN_INSTALL_DIR} )
install(TARGETS kcm_dolphinservices DESTINATION ${PLUGIN_INSTALL_DIR} )
install(TARGETS kcm_dolphingeneral DESTINATION ${PLUGIN_INSTALL_DIR} )
-#########################################
-
-set(kio_search_PART_SRCS
- search/filenamesearchprotocol.cpp)
-kde4_add_plugin(kio_filenamesearch ${kio_search_PART_SRCS})
-target_link_libraries(kio_filenamesearch ${KDE4_KIO_LIBS})
-install(TARGETS kio_filenamesearch DESTINATION ${PLUGIN_INSTALL_DIR})
-
########### install files ###############
-install( PROGRAMS dolphin.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} )
+install( PROGRAMS org.kde.dolphin.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} )
install( FILES settings/dolphin_directoryviewpropertysettings.kcfg
settings/dolphin_generalsettings.kcfg
settings/dolphin_compactmodesettings.kcfg
@@ -354,9 +379,8 @@ install( FILES settings/dolphin_directoryviewpropertysettings.kcfg
settings/dolphin_detailsmodesettings.kcfg
settings/dolphin_versioncontrolsettings.kcfg
DESTINATION ${KCFG_INSTALL_DIR} )
-install( FILES dolphinui.rc DESTINATION ${DATA_INSTALL_DIR}/dolphin )
+install( FILES dolphinui.rc DESTINATION ${CMAKE_INSTALL_KXMLGUI5DIR}/dolphin )
install( FILES dolphin.appdata.xml DESTINATION ${SHARE_INSTALL_PREFIX}/appdata )
-install( FILES search/filenamesearch.protocol DESTINATION ${SERVICES_INSTALL_DIR} )
install( FILES settings/kcm/kcmdolphinviewmodes.desktop DESTINATION
${SERVICES_INSTALL_DIR} )
install( FILES settings/kcm/kcmdolphinnavigation.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
@@ -366,3 +390,7 @@ install( FILES settings/services/servicemenu.knsrc DESTINATION ${CONFIG_INSTALL_
install( PROGRAMS settings/services/servicemenuinstallation DESTINATION ${BIN_INSTALL_DIR} )
install( PROGRAMS settings/services/servicemenudeinstallation DESTINATION ${BIN_INSTALL_DIR} )
+if(BUILD_TESTING)
+ find_package(Qt5Test ${QT_MIN_VERSION} CONFIG REQUIRED)
+ add_subdirectory(tests)
+endif()
diff --git a/src/config-dolphin.h.cmake b/src/config-dolphin.h.cmake
new file mode 100644
index 000000000..45e7208e1
--- /dev/null
+++ b/src/config-dolphin.h.cmake
@@ -0,0 +1,4 @@
+
+/* Define to 1 if you have the KActivities library. */
+#cmakedefine KF5Activities_FOUND 1
+
diff --git a/src/dolphin.appdata.xml b/src/dolphin.appdata.xml
index 1d894a585..1f6ce01b0 100644
--- a/src/dolphin.appdata.xml
+++ b/src/dolphin.appdata.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<component type="desktop">
- <id>dolphin.desktop</id>
+ <id>org.kde.dolphin.desktop</id>
<metadata_license>CC0-1.0</metadata_license>
<project_license>GPL-2.0+</project_license>
<name>Dolphin</name>
diff --git a/src/dolphinapplication.cpp b/src/dolphinapplication.cpp
deleted file mode 100644
index a4b105b90..000000000
--- a/src/dolphinapplication.cpp
+++ /dev/null
@@ -1,106 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2006-2011 by Peter Penz <[email protected]> *
- * Copyright (C) 2006 by Holger 'zecke' Freyther <[email protected]> *
- * *
- * 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"
diff --git a/src/dolphincontextmenu.cpp b/src/dolphincontextmenu.cpp
index e692c8fa9..27ad19924 100644
--- a/src/dolphincontextmenu.cpp
+++ b/src/dolphincontextmenu.cpp
@@ -27,34 +27,30 @@
#include "dolphinremoveaction.h"
#include <KActionCollection>
-#include <KDesktopFile>
-#include <kfileitemactionplugin.h>
-#include <kabstractfileitemactionplugin.h>
+#include <KAbstractFileItemActionPlugin>
#include <KFileItemActions>
#include <KFileItemListProperties>
-#include <KGlobal>
-#include <KIconLoader>
-#include <KIO/NetAccess>
-#include <KMenu>
-#include <KMenuBar>
-#include <KMessageBox>
+#include <KIO/RestoreJob>
+#include <KIO/EmptyTrashJob>
+#include <KIO/JobUiDelegate>
+#include <KIO/Paste>
+#include <KJobWidgets>
#include <KMimeTypeTrader>
#include <KNewFileMenu>
-#include <konqmimedata.h>
-#include <konq_operations.h>
#include <KService>
-#include <KLocale>
-#include <KPropertiesDialog>
+#include <KLocalizedString>
#include <KStandardAction>
-#include <KStandardDirs>
#include <KToolBar>
+#include <QApplication>
+#include <QClipboard>
+#include <QKeyEvent>
+#include <QMenuBar>
+#include <QMenu>
+
#include <panels/places/placesitem.h>
#include <panels/places/placesitemmodel.h>
-#include <QApplication>
-#include <QClipboard>
-#include <QDir>
#include "views/dolphinview.h"
#include "views/viewmodecontroller.h"
@@ -62,8 +58,8 @@
DolphinContextMenu::DolphinContextMenu(DolphinMainWindow* parent,
const QPoint& pos,
const KFileItem& fileInfo,
- const KUrl& baseUrl) :
- KMenu(parent),
+ const QUrl& baseUrl) :
+ QMenu(parent),
m_pos(pos),
m_mainWindow(parent),
m_fileInfo(fileInfo),
@@ -97,7 +93,7 @@ void DolphinContextMenu::setCustomActions(const QList<QAction*>& actions)
DolphinContextMenu::Command DolphinContextMenu::open()
{
// get the context information
- if (m_baseUrl.protocol() == QLatin1String("trash")) {
+ if (m_baseUrl.scheme() == QLatin1String("trash")) {
m_context |= TrashContext;
}
@@ -128,7 +124,7 @@ void DolphinContextMenu::keyPressEvent(QKeyEvent *ev)
if (m_removeAction && ev->key() == Qt::Key_Shift) {
m_removeAction->update();
}
- KMenu::keyPressEvent(ev);
+ QMenu::keyPressEvent(ev);
}
void DolphinContextMenu::keyReleaseEvent(QKeyEvent *ev)
@@ -136,14 +132,14 @@ void DolphinContextMenu::keyReleaseEvent(QKeyEvent *ev)
if (m_removeAction && ev->key() == Qt::Key_Shift) {
m_removeAction->update();
}
- KMenu::keyReleaseEvent(ev);
+ QMenu::keyReleaseEvent(ev);
}
void DolphinContextMenu::openTrashContextMenu()
{
Q_ASSERT(m_context & TrashContext);
- QAction* emptyTrashAction = new QAction(KIcon("trash-empty"), i18nc("@action:inmenu", "Empty Trash"), this);
+ QAction* emptyTrashAction = new QAction(QIcon::fromTheme("trash-empty"), i18nc("@action:inmenu", "Empty Trash"), this);
KConfig trashConfig("trashrc", KConfig::SimpleConfig);
emptyTrashAction->setEnabled(!trashConfig.group("Status").readEntry("Empty", true));
addAction(emptyTrashAction);
@@ -156,7 +152,13 @@ void DolphinContextMenu::openTrashContextMenu()
addShowMenuBarAction();
if (exec(m_pos) == emptyTrashAction) {
- KonqOperations::emptyTrash(m_mainWindow);
+ KIO::JobUiDelegate uiDelegate;
+ uiDelegate.setWindow(m_mainWindow);
+ if (uiDelegate.askDeleteConfirmation(QList<QUrl>(), KIO::JobUiDelegate::EmptyTrash, KIO::JobUiDelegate::DefaultConfirmation)) {
+ KIO::Job* job = KIO::emptyTrash();
+ KJobWidgets::setWindow(job, m_mainWindow);
+ job->ui()->setAutoErrorHandlingEnabled(true);
+ }
}
}
@@ -175,12 +177,14 @@ void DolphinContextMenu::openTrashItemContextMenu()
addAction(propertiesAction);
if (exec(m_pos) == restoreAction) {
- KUrl::List selectedUrls;
+ QList<QUrl> selectedUrls;
foreach (const KFileItem &item, m_selectedItems) {
selectedUrls.append(item.url());
}
- KonqOperations::restoreTrashedItems(selectedUrls, m_mainWindow);
+ KIO::RestoreJob *job = KIO::restoreFromTrash(selectedUrls);
+ KJobWidgets::setWindow(job, m_mainWindow);
+ job->uiDelegate()->setAutoErrorHandlingEnabled(true);
}
}
@@ -188,6 +192,7 @@ void DolphinContextMenu::openItemContextMenu()
{
Q_ASSERT(!m_fileInfo.isNull());
+ QAction* openParentAction = 0;
QAction* openParentInNewWindowAction = 0;
QAction* openParentInNewTabAction = 0;
QAction* addToPlacesAction = 0;
@@ -202,12 +207,12 @@ void DolphinContextMenu::openItemContextMenu()
newFileMenu->checkUpToDate();
newFileMenu->setPopupFiles(m_fileInfo.url());
newFileMenu->setEnabled(selectedItemsProps.supportsWriting());
- connect(newFileMenu, SIGNAL(fileCreated(KUrl)), newFileMenu, SLOT(deleteLater()));
- connect(newFileMenu, SIGNAL(directoryCreated(KUrl)), newFileMenu, SLOT(deleteLater()));
+ connect(newFileMenu, &DolphinNewFileMenu::fileCreated, newFileMenu, &DolphinNewFileMenu::deleteLater);
+ connect(newFileMenu, &DolphinNewFileMenu::directoryCreated, newFileMenu, &DolphinNewFileMenu::deleteLater);
- KMenu* menu = newFileMenu->menu();
+ QMenu* menu = newFileMenu->menu();
menu->setTitle(i18nc("@title:menu Create new folder, file, link, etc.", "Create New"));
- menu->setIcon(KIcon("document-new"));
+ menu->setIcon(QIcon::fromTheme("document-new"));
addMenu(menu);
addSeparator();
@@ -217,20 +222,26 @@ void DolphinContextMenu::openItemContextMenu()
// insert 'Add to Places' entry
if (!placeExists(m_fileInfo.url())) {
- addToPlacesAction = addAction(KIcon("bookmark-new"),
+ addToPlacesAction = addAction(QIcon::fromTheme("bookmark-new"),
i18nc("@action:inmenu Add selected folder to places",
"Add to Places"));
}
addSeparator();
- } else if (m_baseUrl.protocol().contains("search")) {
- openParentInNewWindowAction = new QAction(KIcon("window-new"),
+ } else if (m_baseUrl.scheme().contains("search") || m_baseUrl.scheme().contains("timeline")) {
+ openParentAction = new QAction(QIcon::fromTheme("document-open-folder"),
+ i18nc("@action:inmenu",
+ "Open Path"),
+ this);
+ addAction(openParentAction);
+
+ openParentInNewWindowAction = new QAction(QIcon::fromTheme("window-new"),
i18nc("@action:inmenu",
"Open Path in New Window"),
this);
addAction(openParentInNewWindowAction);
- openParentInNewTabAction = new QAction(KIcon("tab-new"),
+ openParentInNewTabAction = new QAction(QIcon::fromTheme("tab-new"),
i18nc("@action:inmenu",
"Open Path in New Tab"),
this);
@@ -247,7 +258,7 @@ void DolphinContextMenu::openItemContextMenu()
} else {
bool selectionHasOnlyDirs = true;
foreach (const KFileItem& item, m_selectedItems) {
- const KUrl& url = DolphinView::openItemAsFolderUrl(item);
+ const QUrl& url = DolphinView::openItemAsFolderUrl(item);
if (url.isEmpty()) {
selectionHasOnlyDirs = false;
break;
@@ -275,8 +286,9 @@ void DolphinContextMenu::openItemContextMenu()
// insert 'Copy To' and 'Move To' sub menus
if (GeneralSettings::showCopyMoveMenu()) {
- m_copyToMenu.setItems(m_selectedItems);
+ m_copyToMenu.setUrls(m_selectedItems.urlList());
m_copyToMenu.setReadOnly(!selectedItemsProps.supportsWriting());
+ m_copyToMenu.setAutoErrorHandlingEnabled(true);
m_copyToMenu.addActionsTo(this);
}
@@ -287,13 +299,15 @@ void DolphinContextMenu::openItemContextMenu()
QAction* activatedAction = exec(m_pos);
if (activatedAction) {
if (activatedAction == addToPlacesAction) {
- const KUrl selectedUrl(m_fileInfo.url());
+ const QUrl selectedUrl(m_fileInfo.url());
if (selectedUrl.isValid()) {
PlacesItemModel model;
const QString text = selectedUrl.fileName();
PlacesItem* item = model.createPlacesItem(text, selectedUrl);
model.appendItemToGroup(item);
}
+ } else if (activatedAction == openParentAction) {
+ m_command = OpenParentFolder;
} else if (activatedAction == openParentInNewWindowAction) {
m_command = OpenParentFolderInNewWindow;
} else if (activatedAction == openParentInNewTabAction) {
@@ -321,7 +335,7 @@ void DolphinContextMenu::openViewportContextMenu()
// Insert 'Add to Places' entry if exactly one item is selected
QAction* addToPlacesAction = 0;
if (!placeExists(m_mainWindow->activeViewContainer()->url())) {
- addToPlacesAction = addAction(KIcon("bookmark-new"),
+ addToPlacesAction = addAction(QIcon::fromTheme("bookmark-new"),
i18nc("@action:inmenu Add current folder to places", "Add to Places"));
}
@@ -377,7 +391,7 @@ void DolphinContextMenu::insertDefaultItemActions(const KFileItemListProperties&
// Insert 'Move to Trash' and/or 'Delete'
if (properties.supportsDeleting()) {
- const bool showDeleteAction = (KGlobal::config()->group("KDE").readEntry("ShowDeleteCommand", false) ||
+ const bool showDeleteAction = (KSharedConfig::openConfig()->group("KDE").readEntry("ShowDeleteCommand", false) ||
!properties.isLocal());
const bool showMoveToTrashAction = (properties.isLocal() &&
properties.supportsMoving());
@@ -409,14 +423,14 @@ void DolphinContextMenu::addShowMenuBarAction()
}
}
-bool DolphinContextMenu::placeExists(const KUrl& url) const
+bool DolphinContextMenu::placeExists(const QUrl& url) const
{
PlacesItemModel model;
const int count = model.count();
for (int i = 0; i < count; ++i) {
- const KUrl placeUrl = model.placesItem(i)->url();
- if (placeUrl.equals(url, KUrl::CompareWithoutTrailingSlash)) {
+ const QUrl placeUrl = model.placesItem(i)->url();
+ if (placeUrl.matches(url, QUrl::StripTrailingSlash)) {
return true;
}
}
@@ -429,10 +443,12 @@ QAction* DolphinContextMenu::createPasteAction()
QAction* action = 0;
const bool isDir = !m_fileInfo.isNull() && m_fileInfo.isDir();
if (isDir && (m_selectedItems.count() == 1)) {
- const QPair<bool, QString> pasteInfo = KonqOperations::pasteInfo(m_fileInfo.url());
- action = new QAction(KIcon("edit-paste"), i18nc("@action:inmenu", "Paste Into Folder"), this);
- action->setEnabled(pasteInfo.first);
- connect(action, SIGNAL(triggered()), m_mainWindow, SLOT(pasteIntoFolder()));
+ const QMimeData *mimeData = QApplication::clipboard()->mimeData();
+ bool canPaste;
+ const QString text = KIO::pasteActionText(mimeData, &canPaste, m_fileInfo);
+ action = new QAction(QIcon::fromTheme("edit-paste"), text, this);
+ action->setEnabled(canPaste);
+ connect(action, &QAction::triggered, m_mainWindow, &DolphinMainWindow::pasteIntoFolder);
} else {
action = m_mainWindow->actionCollection()->action(KStandardAction::name(KStandardAction::Paste));
}
@@ -451,7 +467,7 @@ KFileItemListProperties& DolphinContextMenu::selectedItemsProperties() const
KFileItem DolphinContextMenu::baseFileItem()
{
if (!m_baseFileItem) {
- m_baseFileItem = new KFileItem(KFileItem::Unknown, KFileItem::Unknown, m_baseUrl);
+ m_baseFileItem = new KFileItem(m_baseUrl);
}
return *m_baseFileItem;
}
@@ -489,19 +505,12 @@ void DolphinContextMenu::addFileItemPluginActions()
const KConfig config("kservicemenurc", KConfig::NoGlobals);
const KConfigGroup showGroup = config.group("Show");
- foreach (const KSharedPtr<KService>& service, pluginServices) {
+ foreach (const KService::Ptr& service, pluginServices) {
if (!showGroup.readEntry(service->desktopEntryName(), true)) {
// The plugin has been disabled
continue;
}
- // Old API (kdelibs-4.6.0 only)
- KFileItemActionPlugin* plugin = service->createInstance<KFileItemActionPlugin>();
- if (plugin) {
- plugin->setParent(this);
- addActions(plugin->actions(props, m_mainWindow));
- }
- // New API (kdelibs >= 4.6.1)
KAbstractFileItemActionPlugin* abstractPlugin = service->createInstance<KAbstractFileItemActionPlugin>();
if (abstractPlugin) {
abstractPlugin->setParent(this);
@@ -515,18 +524,13 @@ void DolphinContextMenu::addVersionControlPluginActions()
const DolphinView* view = m_mainWindow->activeViewContainer()->view();
const QList<QAction*> versionControlActions = view->versionControlActions(m_selectedItems);
if (!versionControlActions.isEmpty()) {
- foreach (QAction* action, versionControlActions) {
- addAction(action);
- }
+ addActions(versionControlActions);
addSeparator();
}
}
void DolphinContextMenu::addCustomActions()
{
- foreach (QAction* action, m_customActions) {
- addAction(action);
- }
+ addActions(m_customActions);
}
-#include "dolphincontextmenu.moc"
diff --git a/src/dolphincontextmenu.h b/src/dolphincontextmenu.h
index 180f91787..419d3f9bd 100644
--- a/src/dolphincontextmenu.h
+++ b/src/dolphincontextmenu.h
@@ -21,16 +21,12 @@
#define DOLPHINCONTEXTMENU_H
#include <KFileItem>
-#include <KService>
-#include <KUrl>
-#include <konq_copytomenu.h>
-#include <KMenu>
+#include <QUrl>
+#include <KFileCopyToMenu>
+#include <QMenu>
-#include <QObject>
-#include <QVector>
-#include <QScopedPointer>
class QAction;
class DolphinMainWindow;
@@ -50,7 +46,7 @@ class DolphinRemoveAction;
* - 'Actions': Contains all actions which can be applied to the
* given item.
*/
-class DolphinContextMenu : public KMenu
+class DolphinContextMenu : public QMenu
{
Q_OBJECT
@@ -58,6 +54,7 @@ public:
enum Command
{
None,
+ OpenParentFolder,
OpenParentFolderInNewWindow,
OpenParentFolderInNewTab
};
@@ -75,7 +72,7 @@ public:
DolphinContextMenu(DolphinMainWindow* parent,
const QPoint& pos,
const KFileItem& fileInfo,
- const KUrl& baseUrl);
+ const QUrl& baseUrl);
virtual ~DolphinContextMenu();
@@ -92,8 +89,8 @@ public:
Command open();
protected:
- virtual void keyPressEvent(QKeyEvent *ev);
- virtual void keyReleaseEvent(QKeyEvent *ev);
+ virtual void keyPressEvent(QKeyEvent *ev) Q_DECL_OVERRIDE;
+ virtual void keyReleaseEvent(QKeyEvent *ev) Q_DECL_OVERRIDE;
private:
void openTrashContextMenu();
@@ -109,7 +106,7 @@ private:
*/
void addShowMenuBarAction();
- bool placeExists(const KUrl& url) const;
+ bool placeExists(const QUrl& url) const;
QAction* createPasteAction();
@@ -165,14 +162,14 @@ private:
KFileItem m_fileInfo;
- KUrl m_baseUrl;
+ QUrl m_baseUrl;
KFileItem* m_baseFileItem; /// File item for m_baseUrl
KFileItemList m_selectedItems;
mutable KFileItemListProperties* m_selectedItemsProperties;
int m_context;
- KonqCopyToMenu m_copyToMenu;
+ KFileCopyToMenu m_copyToMenu;
QList<QAction*> m_customActions;
Command m_command;
diff --git a/src/search/filenamesearchprotocol.h b/src/dolphindebug.cpp
index 4a854d729..17f108427 100644
--- a/src/search/filenamesearchprotocol.h
+++ b/src/dolphindebug.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2010 by Peter Penz <[email protected]> *
+ * Copyright (C) 2015 by Emmanuel Pescosta <[email protected]> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@@ -17,44 +17,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
-#ifndef FILENAMESEARCHPROTOCOL_H
-#define FILENAMESEARCHPROTOCOL_H
+#include "dolphindebug.h"
-#include <kio/slavebase.h>
-
-class KFileItem;
-class KUrl;
-class QRegExp;
-
-/**
- * @brief Lists files where the filename matches do a given query.
- *
- * The query is defined as part of the "search" query item of the URL.
- * The directory where the searching is started is defined in the "url" query
- * item. If the query item "checkContent" is set to "yes", all files with
- * a text MIME type will be checked for the content.
- */
-class FileNameSearchProtocol : public KIO::SlaveBase {
-public:
- FileNameSearchProtocol(const QByteArray& pool, const QByteArray& app);
- virtual ~FileNameSearchProtocol();
-
- virtual void listDir(const KUrl& url);
-
-private:
- void searchDirectory(const KUrl& directory);
-
- /**
- * @return True, if the pattern m_searchPattern is part of
- * the file \a fileName.
- */
- bool contentContainsPattern(const KUrl& fileName) const;
-
- void cleanup();
-
- bool m_checkContent;
- QRegExp* m_regExp;
- QSet<QString> m_iteratedDirs;
-};
-
-#endif
+Q_LOGGING_CATEGORY(DolphinDebug, "org.kde.dolphin")
diff --git a/src/dolphinapplication.h b/src/dolphindebug.h
index 69d07c36e..9b4554b49 100644
--- a/src/dolphinapplication.h
+++ b/src/dolphindebug.h
@@ -1,6 +1,5 @@
/***************************************************************************
- * Copyright (C) 2006-2011 by Peter Penz <[email protected]> *
- * Copyright (C) 2006 by Holger 'zecke' Freyther <[email protected]> *
+ * Copyright (C) 2015 by Emmanuel Pescosta <[email protected]> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@@ -18,27 +17,11 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
-#ifndef DOLPHIN_APPLICATION_H
-#define DOLPHIN_APPLICATION_H
+#ifndef DOLPHIN_DEBUG_H
+#define DOLPHIN_DEBUG_H
-#include <KApplication>
+#include <QLoggingCategory>
-class DolphinMainWindow;
+Q_DECLARE_LOGGING_CATEGORY(DolphinDebug)
-class DolphinApplication : public KApplication
-{
- Q_OBJECT
-
-public:
- DolphinApplication();
- virtual ~DolphinApplication();
-
- static DolphinApplication* app();
-
- void restoreSession();
-
-private:
- DolphinMainWindow* m_mainWindow;
-};
-
-#endif
+#endif // DOLPHIN_DEBUG_H
diff --git a/src/dolphindockwidget.cpp b/src/dolphindockwidget.cpp
index 6495c8da9..1e83ef841 100644
--- a/src/dolphindockwidget.cpp
+++ b/src/dolphindockwidget.cpp
@@ -91,4 +91,3 @@ bool DolphinDockWidget::isLocked() const
return m_locked;
}
-#include "dolphindockwidget.moc"
diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp
index 95b08af96..1eda03e3c 100644
--- a/src/dolphinmainwindow.cpp
+++ b/src/dolphinmainwindow.cpp
@@ -21,7 +21,6 @@
#include "dolphinmainwindow.h"
-#include "dolphinapplication.h"
#include "dolphindockwidget.h"
#include "dolphincontextmenu.h"
#include "dolphinnewfilemenu.h"
@@ -46,47 +45,38 @@
#include "dolphin_generalsettings.h"
-#include <KAcceleratorManager>
-#include <KAction>
#include <KActionCollection>
#include <KActionMenu>
#include <KConfig>
-#include <KDesktopFile>
#include <kdeversion.h>
#include <kdualaction.h>
-#include <KFileDialog>
-#include <KGlobal>
-#include <KLineEdit>
+#include <KJobWidgets>
+#include <QLineEdit>
#include <KToolBar>
-#include <KIcon>
-#include <KIconLoader>
-#include <KIO/NetAccess>
#include <KIO/JobUiDelegate>
-#include <KInputDialog>
-#include <KLocale>
+#include <KLocalizedString>
#include <KProtocolManager>
-#include <KMenu>
-#include <KMenuBar>
+#include <QMenu>
#include <KMessageBox>
#include <KFileItemListProperties>
-#include <konqmimedata.h>
-#include <KProtocolInfo>
#include <KRun>
#include <KShell>
-#include <KStandardDirs>
-#include <kstatusbar.h>
#include <KStandardAction>
#include <KToggleAction>
#include <KUrlNavigator>
-#include <KUrl>
-#include <KUrlComboBox>
#include <KToolInvocation>
+#include <KUrlComboBox>
-#include <QDesktopWidget>
-#include <QDBusMessage>
-#include <QKeyEvent>
+#include <QApplication>
+#include <QMenuBar>
#include <QClipboard>
#include <QToolButton>
+#include <QTimer>
+#include <QStandardPaths>
+#include <QPushButton>
+#include <QCloseEvent>
+#include <QShowEvent>
+#include <QDialog>
namespace {
// Used for GeneralSettings::version() to determine whether
@@ -108,20 +98,20 @@ DolphinMainWindow::DolphinMainWindow() :
{
setObjectName("Dolphin#");
- connect(&DolphinNewFileMenuObserver::instance(), SIGNAL(errorMessage(QString)),
- this, SLOT(showErrorMessage(QString)));
+ connect(&DolphinNewFileMenuObserver::instance(), &DolphinNewFileMenuObserver::errorMessage,
+ this, &DolphinMainWindow::showErrorMessage);
KIO::FileUndoManager* undoManager = KIO::FileUndoManager::self();
undoManager->setUiInterface(new UndoUiInterface());
- connect(undoManager, SIGNAL(undoAvailable(bool)),
- this, SLOT(slotUndoAvailable(bool)));
- connect(undoManager, SIGNAL(undoTextChanged(QString)),
- this, SLOT(slotUndoTextChanged(QString)));
- connect(undoManager, SIGNAL(jobRecordingStarted(CommandType)),
- this, SLOT(clearStatusBar()));
- connect(undoManager, SIGNAL(jobRecordingFinished(CommandType)),
- this, SLOT(showCommand(CommandType)));
+ connect(undoManager, static_cast<void(KIO::FileUndoManager::*)(bool)>(&KIO::FileUndoManager::undoAvailable),
+ this, &DolphinMainWindow::slotUndoAvailable);
+ connect(undoManager, &KIO::FileUndoManager::undoTextChanged,
+ this, &DolphinMainWindow::slotUndoTextChanged);
+ connect(undoManager, &KIO::FileUndoManager::jobRecordingStarted,
+ this, &DolphinMainWindow::clearStatusBar);
+ connect(undoManager, &KIO::FileUndoManager::jobRecordingFinished,
+ this, &DolphinMainWindow::showCommand);
GeneralSettings* generalSettings = GeneralSettings::self();
const bool firstRun = (generalSettings->version() < 200);
@@ -136,19 +126,19 @@ DolphinMainWindow::DolphinMainWindow() :
this, SLOT(activeViewChanged(DolphinViewContainer*)));
connect(m_tabWidget, SIGNAL(tabCountChanged(int)),
this, SLOT(tabCountChanged(int)));
- connect(m_tabWidget, SIGNAL(currentUrlChanged(KUrl)),
- this, SLOT(setUrlAsCaption(KUrl)));
+ connect(m_tabWidget, SIGNAL(currentUrlChanged(QUrl)),
+ this, SLOT(setUrlAsCaption(QUrl)));
setCentralWidget(m_tabWidget);
setupActions();
m_actionHandler = new DolphinViewActionHandler(actionCollection(), this);
- connect(m_actionHandler, SIGNAL(actionBeingHandled()), SLOT(clearStatusBar()));
- connect(m_actionHandler, SIGNAL(createDirectory()), SLOT(createDirectory()));
+ connect(m_actionHandler, &DolphinViewActionHandler::actionBeingHandled, this, &DolphinMainWindow::clearStatusBar);
+ connect(m_actionHandler, &DolphinViewActionHandler::createDirectory, this, &DolphinMainWindow::createDirectory);
m_remoteEncoding = new DolphinRemoteEncoding(this, m_actionHandler);
- connect(this, SIGNAL(urlChanged(KUrl)),
- m_remoteEncoding, SLOT(slotAboutToOpenUrl()));
+ connect(this, &DolphinMainWindow::urlChanged,
+ m_remoteEncoding, &DolphinRemoteEncoding::slotAboutToOpenUrl);
setupDockWidgets();
@@ -156,8 +146,8 @@ DolphinMainWindow::DolphinMainWindow() :
stateChanged("new_file");
QClipboard* clipboard = QApplication::clipboard();
- connect(clipboard, SIGNAL(dataChanged()),
- this, SLOT(updatePasteAction()));
+ connect(clipboard, &QClipboard::dataChanged,
+ this, &DolphinMainWindow::updatePasteAction);
QAction* showFilterBarAction = actionCollection()->action("show_filter_bar");
showFilterBarAction->setChecked(generalSettings->filterBar());
@@ -180,12 +170,12 @@ DolphinMainWindow::~DolphinMainWindow()
{
}
-void DolphinMainWindow::openDirectories(const QList<KUrl>& dirs)
+void DolphinMainWindow::openDirectories(const QList<QUrl>& dirs)
{
m_tabWidget->openDirectories(dirs);
}
-void DolphinMainWindow::openFiles(const QList<KUrl>& files)
+void DolphinMainWindow::openFiles(const QList<QUrl>& files)
{
m_tabWidget->openFiles(files);
}
@@ -224,7 +214,7 @@ void DolphinMainWindow::pasteIntoFolder()
m_activeViewContainer->view()->pasteIntoFolder();
}
-void DolphinMainWindow::changeUrl(const KUrl& url)
+void DolphinMainWindow::changeUrl(const QUrl &url)
{
if (!KProtocolManager::supportsListing(url)) {
// The URL navigator only checks for validity, not
@@ -242,7 +232,7 @@ void DolphinMainWindow::changeUrl(const KUrl& url)
emit urlChanged(url);
}
-void DolphinMainWindow::slotTerminalDirectoryChanged(const KUrl& url)
+void DolphinMainWindow::slotTerminalDirectoryChanged(const QUrl& url)
{
m_activeViewContainer->setAutoGrabFocus(false);
changeUrl(url);
@@ -272,11 +262,6 @@ void DolphinMainWindow::slotSelectionChanged(const KFileItemList& selection)
emit selectionChanged(selection);
}
-void DolphinMainWindow::slotRequestItemInfo(const KFileItem& item)
-{
- emit requestItemInfo(item);
-}
-
void DolphinMainWindow::updateHistory()
{
const KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
@@ -303,7 +288,7 @@ void DolphinMainWindow::updateFilterBarAction(bool show)
void DolphinMainWindow::openNewMainWindow()
{
- KRun::run("dolphin %u", KUrl::List(), this);
+ KRun::run("dolphin %u", QList<QUrl>(), this);
}
void DolphinMainWindow::openNewActivatedTab()
@@ -311,14 +296,14 @@ void DolphinMainWindow::openNewActivatedTab()
m_tabWidget->openNewActivatedTab();
}
-void DolphinMainWindow::openNewTab(const KUrl& primaryUrl, const KUrl& secondaryUrl)
+void DolphinMainWindow::openNewTab(const QUrl& url)
{
- m_tabWidget->openNewTab(primaryUrl, secondaryUrl);
+ m_tabWidget->openNewTab(url);
}
-void DolphinMainWindow::openNewActivatedTab(const KUrl& primaryUrl, const KUrl& secondaryUrl)
+void DolphinMainWindow::openNewActivatedTab(const QUrl& url)
{
- m_tabWidget->openNewActivatedTab(primaryUrl, secondaryUrl);
+ m_tabWidget->openNewActivatedTab(url);
}
void DolphinMainWindow::openInNewTab()
@@ -328,7 +313,7 @@ void DolphinMainWindow::openInNewTab()
openNewTab(m_activeViewContainer->url());
} else {
foreach (const KFileItem& item, list) {
- const KUrl& url = DolphinView::openItemAsFolderUrl(item);
+ const QUrl& url = DolphinView::openItemAsFolderUrl(item);
if (!url.isEmpty()) {
openNewTab(url);
}
@@ -338,7 +323,7 @@ void DolphinMainWindow::openInNewTab()
void DolphinMainWindow::openInNewWindow()
{
- KUrl newWindowUrl;
+ QUrl newWindowUrl;
const KFileItemList list = m_activeViewContainer->view()->selectedItems();
if (list.isEmpty()) {
@@ -349,7 +334,7 @@ void DolphinMainWindow::openInNewWindow()
}
if (!newWindowUrl.isEmpty()) {
- KRun::run("dolphin %u", KUrl::List() << newWindowUrl, this);
+ KRun::run("dolphin %u", {newWindowUrl}, this);
}
}
@@ -367,29 +352,29 @@ void DolphinMainWindow::closeEvent(QCloseEvent* event)
// Find out if Dolphin is closed directly by the user or
// by the session manager because the session is closed
bool closedByUser = true;
- DolphinApplication *application = qobject_cast<DolphinApplication*>(qApp);
- if (application && application->sessionSaving()) {
+ if (qApp->isSessionRestored()) {
closedByUser = false;
}
if (m_tabWidget->count() > 1 && GeneralSettings::confirmClosingMultipleTabs() && closedByUser) {
// Ask the user if he really wants to quit and close all tabs.
// Open a confirmation dialog with 3 buttons:
- // KDialog::Yes -> Quit
- // KDialog::No -> Close only the current tab
- // KDialog::Cancel -> do nothing
- KDialog *dialog = new KDialog(this, Qt::Dialog);
- dialog->setCaption(i18nc("@title:window", "Confirmation"));
- dialog->setButtons(KDialog::Yes | KDialog::No | KDialog::Cancel);
+ // QDialogButtonBox::Yes -> Quit
+ // QDialogButtonBox::No -> Close only the current tab
+ // QDialogButtonBox::Cancel -> do nothing
+ QDialog *dialog = new QDialog(this, Qt::Dialog);
+ dialog->setWindowTitle(i18nc("@title:window", "Confirmation"));
dialog->setModal(true);
- dialog->setButtonGuiItem(KDialog::Yes, KStandardGuiItem::quit());
- dialog->setButtonGuiItem(KDialog::No, KGuiItem(i18n("C&lose Current Tab"), KIcon("tab-close")));
- dialog->setButtonGuiItem(KDialog::Cancel, KStandardGuiItem::cancel());
- dialog->setDefaultButton(KDialog::Yes);
+ QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Yes | QDialogButtonBox::No | QDialogButtonBox::Cancel);
+ KGuiItem::assign(buttons->button(QDialogButtonBox::Yes), KStandardGuiItem::quit());
+ KGuiItem::assign(buttons->button(QDialogButtonBox::No), KGuiItem(i18n("C&lose Current Tab"), QIcon::fromTheme("tab-close")));
+ KGuiItem::assign(buttons->button(QDialogButtonBox::Cancel), KStandardGuiItem::cancel());
+ buttons->button(QDialogButtonBox::Yes)->setDefault(true);
bool doNotAskAgainCheckboxResult = false;
const int result = KMessageBox::createKMessageBox(dialog,
+ buttons,
QMessageBox::Warning,
i18n("You have multiple tabs open in this window, are you sure you want to quit?"),
QStringList(),
@@ -402,10 +387,10 @@ void DolphinMainWindow::closeEvent(QCloseEvent* event)
}
switch (result) {
- case KDialog::Yes:
+ case QDialogButtonBox::Yes:
// Quit
break;
- case KDialog::No:
+ case QDialogButtonBox::No:
// Close only the current tab
m_tabWidget->closeTab();
default:
@@ -415,7 +400,7 @@ void DolphinMainWindow::closeEvent(QCloseEvent* event)
}
GeneralSettings::setVersion(CurrentDolphinVersion);
- GeneralSettings::self()->writeConfig();
+ GeneralSettings::self()->save();
KXmlGuiWindow::closeEvent(event);
}
@@ -505,6 +490,11 @@ void DolphinMainWindow::updatePasteAction()
pasteAction->setText(pasteInfo.second);
}
+void DolphinMainWindow::slotDirectoryLoadingCompleted()
+{
+ updatePasteAction();
+}
+
void DolphinMainWindow::selectAll()
{
clearStatusBar();
@@ -626,7 +616,7 @@ void DolphinMainWindow::goHome()
void DolphinMainWindow::goBack(Qt::MouseButtons buttons)
{
// The default case (left button pressed) is handled in goBack().
- if (buttons == Qt::MidButton) {
+ if (buttons == Qt::MiddleButton) {
KUrlNavigator* urlNavigator = activeViewContainer()->urlNavigator();
const int index = urlNavigator->historyIndex() + 1;
openNewTab(urlNavigator->locationUrl(index));
@@ -636,7 +626,7 @@ void DolphinMainWindow::goBack(Qt::MouseButtons buttons)
void DolphinMainWindow::goForward(Qt::MouseButtons buttons)
{
// The default case (left button pressed) is handled in goForward().
- if (buttons == Qt::MidButton) {
+ if (buttons == Qt::MiddleButton) {
KUrlNavigator* urlNavigator = activeViewContainer()->urlNavigator();
const int index = urlNavigator->historyIndex() - 1;
openNewTab(urlNavigator->locationUrl(index));
@@ -646,15 +636,15 @@ void DolphinMainWindow::goForward(Qt::MouseButtons buttons)
void DolphinMainWindow::goUp(Qt::MouseButtons buttons)
{
// The default case (left button pressed) is handled in goUp().
- if (buttons == Qt::MidButton) {
- openNewTab(activeViewContainer()->url().upUrl());
+ if (buttons == Qt::MiddleButton) {
+ openNewTab(KIO::upUrl(activeViewContainer()->url()));
}
}
void DolphinMainWindow::goHome(Qt::MouseButtons buttons)
{
// The default case (left button pressed) is handled in goHome().
- if (buttons == Qt::MidButton) {
+ if (buttons == Qt::MiddleButton) {
openNewTab(GeneralSettings::self()->homeUrl());
}
}
@@ -668,13 +658,13 @@ void DolphinMainWindow::compareFiles()
return;
}
- KUrl urlA = items.at(0).url();
- KUrl urlB = items.at(1).url();
+ QUrl urlA = items.at(0).url();
+ QUrl urlB = items.at(1).url();
QString command("kompare -c \"");
- command.append(urlA.pathOrUrl());
+ command.append(urlA.toDisplayString(QUrl::PreferLocalFile));
command.append("\" \"");
- command.append(urlB.pathOrUrl());
+ command.append(urlB.toDisplayString(QUrl::PreferLocalFile));
command.append('\"');
KRun::runCommand(command, "Kompare", "kompare", this);
}
@@ -696,7 +686,10 @@ void DolphinMainWindow::openTerminal()
// 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.
- KUrl url = KIO::NetAccess::mostLocalUrl(m_activeViewContainer->url(), this);
+ KIO::StatJob* statJob = KIO::mostLocalUrl(m_activeViewContainer->url());
+ KJobWidgets::setWindow(statJob, this);
+ statJob->exec();
+ QUrl url = statJob->mostLocalUrl();
//If the URL is local after the above conversion, set the directory.
if (url.isLocalFile()) {
@@ -712,9 +705,9 @@ void DolphinMainWindow::editSettings()
DolphinViewContainer* container = activeViewContainer();
container->view()->writeSettings();
- const KUrl url = container->url();
+ const QUrl url = container->url();
DolphinSettingsDialog* settingsDialog = new DolphinSettingsDialog(url, this);
- connect(settingsDialog, SIGNAL(settingsChanged()), this, SLOT(refreshViews()));
+ connect(settingsDialog, &DolphinSettingsDialog::settingsChanged, this, &DolphinMainWindow::refreshViews);
settingsDialog->setAttribute(Qt::WA_DeleteOnClose);
settingsDialog->show();
m_settingsDialog = settingsDialog;
@@ -723,7 +716,7 @@ void DolphinMainWindow::editSettings()
}
}
-void DolphinMainWindow::handleUrl(const KUrl& url)
+void DolphinMainWindow::handleUrl(const QUrl& url)
{
delete m_lastHandleUrlStatJob;
m_lastHandleUrlStatJob = 0;
@@ -734,10 +727,10 @@ void DolphinMainWindow::handleUrl(const KUrl& url)
// stat the URL to see if it is a dir or not
m_lastHandleUrlStatJob = KIO::stat(url, KIO::HideProgressInfo);
if (m_lastHandleUrlStatJob->ui()) {
- m_lastHandleUrlStatJob->ui()->setWindow(this);
+ KJobWidgets::setWindow(m_lastHandleUrlStatJob, this);
}
- connect(m_lastHandleUrlStatJob, SIGNAL(result(KJob*)),
- this, SLOT(slotHandleUrlStatFinished(KJob*)));
+ connect(m_lastHandleUrlStatJob, &KIO::Job::result,
+ this, &DolphinMainWindow::slotHandleUrlStatFinished);
} else {
new KRun(url, this); // Automatically deletes itself after being finished
@@ -748,7 +741,7 @@ void DolphinMainWindow::slotHandleUrlStatFinished(KJob* job)
{
m_lastHandleUrlStatJob = 0;
const KIO::UDSEntry entry = static_cast<KIO::StatJob*>(job)->statResult();
- const KUrl url = static_cast<KIO::StatJob*>(job)->url();
+ const QUrl url = static_cast<KIO::StatJob*>(job)->url();
if (entry.isDir()) {
activeViewContainer()->setUrl(url);
} else {
@@ -763,21 +756,26 @@ void DolphinMainWindow::slotWriteStateChanged(bool isFolderWritable)
void DolphinMainWindow::openContextMenu(const QPoint& pos,
const KFileItem& item,
- const KUrl& url,
+ const QUrl& url,
const QList<QAction*>& customActions)
{
- QWeakPointer<DolphinContextMenu> contextMenu = new DolphinContextMenu(this, pos, item, url);
+ QPointer<DolphinContextMenu> contextMenu = new DolphinContextMenu(this, pos, item, url);
contextMenu.data()->setCustomActions(customActions);
const DolphinContextMenu::Command command = contextMenu.data()->open();
switch (command) {
+ case DolphinContextMenu::OpenParentFolder:
+ changeUrl(KIO::upUrl(item.url()));
+ break;
+
case DolphinContextMenu::OpenParentFolderInNewWindow: {
- KRun::run("dolphin %u", KUrl::List() << item.url().upUrl(), this);
+
+ KRun::run("dolphin %u", {KIO::upUrl(item.url())}, this);
break;
}
case DolphinContextMenu::OpenParentFolderInNewTab:
- openNewTab(item.url().upUrl());
+ openNewTab(KIO::upUrl(item.url()));
break;
case DolphinContextMenu::None:
@@ -785,15 +783,18 @@ void DolphinMainWindow::openContextMenu(const QPoint& pos,
break;
}
- delete contextMenu.data();
+ // Delete the menu, unless it has been deleted in its own nested event loop already.
+ if (contextMenu) {
+ contextMenu->deleteLater();
+ }
}
void DolphinMainWindow::updateControlMenu()
{
- KMenu* menu = qobject_cast<KMenu*>(sender());
+ QMenu* menu = qobject_cast<QMenu*>(sender());
Q_ASSERT(menu);
- // All actions get cleared by KMenu::clear(). The sub-menus are deleted
+ // All actions get cleared by QMenu::clear(). The sub-menus are deleted
// by connecting to the aboutToHide() signal from the parent-menu.
menu->clear();
@@ -835,7 +836,7 @@ void DolphinMainWindow::updateControlMenu()
}
addActionToMenu(ac->action("panels"), menu);
- KMenu* locationBarMenu = new KMenu(i18nc("@action:inmenu", "Location Bar"), menu);
+ QMenu* locationBarMenu = new QMenu(i18nc("@action:inmenu", "Location Bar"), menu);
locationBarMenu->addAction(ac->action("editable_location"));
locationBarMenu->addAction(ac->action("replace_location"));
menu->addMenu(locationBarMenu);
@@ -843,8 +844,8 @@ void DolphinMainWindow::updateControlMenu()
menu->addSeparator();
// Add "Go" menu
- KMenu* goMenu = new KMenu(i18nc("@action:inmenu", "Go"), menu);
- connect(menu, SIGNAL(aboutToHide()), goMenu, SLOT(deleteLater()));
+ QMenu* goMenu = new QMenu(i18nc("@action:inmenu", "Go"), menu);
+ connect(menu, &QMenu::aboutToHide, goMenu, &QMenu::deleteLater);
goMenu->addAction(ac->action(KStandardAction::name(KStandardAction::Back)));
goMenu->addAction(ac->action(KStandardAction::name(KStandardAction::Forward)));
goMenu->addAction(ac->action(KStandardAction::name(KStandardAction::Up)));
@@ -853,8 +854,8 @@ void DolphinMainWindow::updateControlMenu()
menu->addMenu(goMenu);
// Add "Tool" menu
- KMenu* toolsMenu = new KMenu(i18nc("@action:inmenu", "Tools"), menu);
- connect(menu, SIGNAL(aboutToHide()), toolsMenu, SLOT(deleteLater()));
+ QMenu* toolsMenu = new QMenu(i18nc("@action:inmenu", "Tools"), menu);
+ connect(menu, &QMenu::aboutToHide, toolsMenu, &QMenu::deleteLater);
toolsMenu->addAction(ac->action("show_filter_bar"));
toolsMenu->addAction(ac->action("compare_files"));
toolsMenu->addAction(ac->action("open_terminal"));
@@ -867,8 +868,8 @@ void DolphinMainWindow::updateControlMenu()
addActionToMenu(ac->action(KStandardAction::name(KStandardAction::Preferences)), menu);
// Add "Help" menu
- KMenu* helpMenu = new KMenu(i18nc("@action:inmenu", "Help"), menu);
- connect(menu, SIGNAL(aboutToHide()), helpMenu, SLOT(deleteLater()));
+ QMenu* helpMenu = new QMenu(i18nc("@action:inmenu", "Help"), menu);
+ connect(menu, &QMenu::aboutToHide, helpMenu, &QMenu::deleteLater);
helpMenu->addAction(ac->action(KStandardAction::name(KStandardAction::HelpContents)));
helpMenu->addAction(ac->action(KStandardAction::name(KStandardAction::WhatsThis)));
helpMenu->addSeparator();
@@ -897,12 +898,7 @@ void DolphinMainWindow::slotControlButtonDeleted()
m_updateToolBarTimer->start();
}
-void DolphinMainWindow::slotPanelErrorMessage(const QString& error)
-{
- activeViewContainer()->showMessage(error, DolphinViewContainer::Error);
-}
-
-void DolphinMainWindow::slotPlaceActivated(const KUrl& url)
+void DolphinMainWindow::slotPlaceActivated(const QUrl& url)
{
DolphinViewContainer* view = activeViewContainer();
@@ -945,7 +941,7 @@ void DolphinMainWindow::activeViewChanged(DolphinViewContainer* viewContainer)
updateViewActions();
updateGoActions();
- const KUrl url = viewContainer->url();
+ const QUrl url = viewContainer->url();
emit urlChanged(url);
}
@@ -957,51 +953,55 @@ void DolphinMainWindow::tabCountChanged(int count)
actionCollection()->action("activate_prev_tab")->setEnabled(enableTabActions);
}
-void DolphinMainWindow::setUrlAsCaption(const KUrl& url)
+void DolphinMainWindow::setUrlAsCaption(const QUrl& url)
{
QString caption;
if (!url.isLocalFile()) {
- caption.append(url.protocol() + " - ");
- if (url.hasHost()) {
+ caption.append(url.scheme() + " - ");
+ if (!url.host().isEmpty()) {
caption.append(url.host() + " - ");
}
}
- const QString fileName = url.fileName().isEmpty() ? "/" : url.fileName();
+ QString fileName = url.adjusted(QUrl::StripTrailingSlash).fileName();
+ if (fileName.isEmpty()) {
+ fileName = '/';
+ }
+
caption.append(fileName);
- setCaption(caption);
+ setWindowTitle(caption);
}
void DolphinMainWindow::setupActions()
{
// setup 'File' menu
m_newFileMenu = new DolphinNewFileMenu(actionCollection(), this);
- KMenu* menu = m_newFileMenu->menu();
+ QMenu* menu = m_newFileMenu->menu();
menu->setTitle(i18nc("@title:menu Create new folder, file, link, etc.", "Create New"));
- menu->setIcon(KIcon("document-new"));
+ menu->setIcon(QIcon::fromTheme("document-new"));
m_newFileMenu->setDelayed(false);
- connect(menu, SIGNAL(aboutToShow()),
- this, SLOT(updateNewMenu()));
+ connect(menu, &QMenu::aboutToShow,
+ this, &DolphinMainWindow::updateNewMenu);
- KAction* newWindow = actionCollection()->addAction("new_window");
- newWindow->setIcon(KIcon("window-new"));
+ QAction* newWindow = actionCollection()->addAction("new_window");
+ newWindow->setIcon(QIcon::fromTheme("window-new"));
newWindow->setText(i18nc("@action:inmenu File", "New &Window"));
- newWindow->setShortcut(Qt::CTRL | Qt::Key_N);
- connect(newWindow, SIGNAL(triggered()), this, SLOT(openNewMainWindow()));
+ actionCollection()->setDefaultShortcut(newWindow, Qt::CTRL | Qt::Key_N);
+ connect(newWindow, &QAction::triggered, this, &DolphinMainWindow::openNewMainWindow);
- KAction* newTab = actionCollection()->addAction("new_tab");
- newTab->setIcon(KIcon("tab-new"));
+ QAction* newTab = actionCollection()->addAction("new_tab");
+ newTab->setIcon(QIcon::fromTheme("tab-new"));
newTab->setText(i18nc("@action:inmenu File", "New Tab"));
- newTab->setShortcut(KShortcut(Qt::CTRL | Qt::Key_T, Qt::CTRL | Qt::SHIFT | Qt::Key_N));
- connect(newTab, SIGNAL(triggered()), this, SLOT(openNewActivatedTab()));
+ actionCollection()->setDefaultShortcuts(newTab, {Qt::CTRL | Qt::Key_T, Qt::CTRL | Qt::SHIFT | Qt::Key_N});
+ connect(newTab, &QAction::triggered, this, static_cast<void(DolphinMainWindow::*)()>(&DolphinMainWindow::openNewActivatedTab));
- KAction* closeTab = actionCollection()->addAction("close_tab");
- closeTab->setIcon(KIcon("tab-close"));
+ QAction* closeTab = actionCollection()->addAction("close_tab");
+ closeTab->setIcon(QIcon::fromTheme("tab-close"));
closeTab->setText(i18nc("@action:inmenu File", "Close Tab"));
- closeTab->setShortcut(Qt::CTRL | Qt::Key_W);
+ actionCollection()->setDefaultShortcut(closeTab, Qt::CTRL | Qt::Key_W);
closeTab->setEnabled(false);
- connect(closeTab, SIGNAL(triggered()), m_tabWidget, SLOT(closeTab()));
+ connect(closeTab, &QAction::triggered, m_tabWidget, static_cast<void(DolphinTabWidget::*)()>(&DolphinTabWidget::closeTab));
KStandardAction::quit(this, SLOT(quit()), actionCollection());
@@ -1012,12 +1012,12 @@ void DolphinMainWindow::setupActions()
// need to remove shift+del from cut action, else the shortcut for deletejob
// doesn't work
- KAction* cut = KStandardAction::cut(this, SLOT(cut()), actionCollection());
- KShortcut cutShortcut = cut->shortcut();
- cutShortcut.remove(Qt::SHIFT | Qt::Key_Delete, KShortcut::KeepEmpty);
- cut->setShortcut(cutShortcut);
+ QAction* cut = KStandardAction::cut(this, SLOT(cut()), actionCollection());
+ auto cutShortcuts = cut->shortcuts();
+ cutShortcuts.removeAll(QKeySequence(Qt::SHIFT | Qt::Key_Delete));
+ actionCollection()->setDefaultShortcuts(cut, cutShortcuts);
KStandardAction::copy(this, SLOT(copy()), actionCollection());
- KAction* paste = KStandardAction::paste(this, SLOT(paste()), actionCollection());
+ QAction* paste = KStandardAction::paste(this, SLOT(paste()), actionCollection());
// The text of the paste-action is modified dynamically by Dolphin
// (e. g. to "Paste One Folder"). To prevent that the size of the toolbar changes
// due to the long text, the text "Paste" is used:
@@ -1025,140 +1025,135 @@ void DolphinMainWindow::setupActions()
KStandardAction::find(this, SLOT(find()), actionCollection());
- KAction* selectAll = actionCollection()->addAction("select_all");
+ QAction* selectAll = actionCollection()->addAction("select_all");
selectAll->setText(i18nc("@action:inmenu Edit", "Select All"));
- selectAll->setShortcut(Qt::CTRL | Qt::Key_A);
- connect(selectAll, SIGNAL(triggered()), this, SLOT(selectAll()));
+ actionCollection()->setDefaultShortcut(selectAll, Qt::CTRL | Qt::Key_A);
+ connect(selectAll, &QAction::triggered, this, &DolphinMainWindow::selectAll);
- KAction* invertSelection = actionCollection()->addAction("invert_selection");
+ QAction* invertSelection = actionCollection()->addAction("invert_selection");
invertSelection->setText(i18nc("@action:inmenu Edit", "Invert Selection"));
- invertSelection->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_A);
- connect(invertSelection, SIGNAL(triggered()), this, SLOT(invertSelection()));
+ actionCollection()->setDefaultShortcut(invertSelection, Qt::CTRL | Qt::SHIFT | Qt::Key_A);
+ connect(invertSelection, &QAction::triggered, this, &DolphinMainWindow::invertSelection);
// setup 'View' menu
// (note that most of it is set up in DolphinViewActionHandler)
- KAction* split = actionCollection()->addAction("split_view");
- split->setShortcut(Qt::Key_F3);
- connect(split, SIGNAL(triggered()), this, SLOT(toggleSplitView()));
+ QAction* split = actionCollection()->addAction("split_view");
+ actionCollection()->setDefaultShortcut(split, Qt::Key_F3);
+ connect(split, &QAction::triggered, this, &DolphinMainWindow::toggleSplitView);
- KAction* reload = actionCollection()->addAction("reload");
+ QAction* reload = actionCollection()->addAction("reload");
reload->setText(i18nc("@action:inmenu View", "Reload"));
- reload->setShortcut(Qt::Key_F5);
- reload->setIcon(KIcon("view-refresh"));
- connect(reload, SIGNAL(triggered()), this, SLOT(reloadView()));
+ actionCollection()->setDefaultShortcut(reload, Qt::Key_F5);
+ reload->setIcon(QIcon::fromTheme("view-refresh"));
+ connect(reload, &QAction::triggered, this, &DolphinMainWindow::reloadView);
- KAction* stop = actionCollection()->addAction("stop");
+ QAction* stop = actionCollection()->addAction("stop");
stop->setText(i18nc("@action:inmenu View", "Stop"));
stop->setToolTip(i18nc("@info", "Stop loading"));
- stop->setIcon(KIcon("process-stop"));
- connect(stop, SIGNAL(triggered()), this, SLOT(stopLoading()));
+ stop->setIcon(QIcon::fromTheme("process-stop"));
+ connect(stop, &QAction::triggered, this, &DolphinMainWindow::stopLoading);
KToggleAction* editableLocation = actionCollection()->add<KToggleAction>("editable_location");
editableLocation->setText(i18nc("@action:inmenu Navigation Bar", "Editable Location"));
- editableLocation->setShortcut(Qt::Key_F6);
- connect(editableLocation, SIGNAL(triggered()), this, SLOT(toggleEditLocation()));
+ actionCollection()->setDefaultShortcut(editableLocation, Qt::Key_F6);
+ connect(editableLocation, &KToggleAction::triggered, this, &DolphinMainWindow::toggleEditLocation);
- KAction* replaceLocation = actionCollection()->addAction("replace_location");
+ QAction* replaceLocation = actionCollection()->addAction("replace_location");
replaceLocation->setText(i18nc("@action:inmenu Navigation Bar", "Replace Location"));
- replaceLocation->setShortcut(Qt::CTRL | Qt::Key_L);
- connect(replaceLocation, SIGNAL(triggered()), this, SLOT(replaceLocation()));
+ actionCollection()->setDefaultShortcut(replaceLocation, Qt::CTRL | Qt::Key_L);
+ connect(replaceLocation, &QAction::triggered, this, &DolphinMainWindow::replaceLocation);
// setup 'Go' menu
- KAction* backAction = KStandardAction::back(this, SLOT(goBack()), actionCollection());
- connect(backAction, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)), this, SLOT(goBack(Qt::MouseButtons)));
- KShortcut backShortcut = backAction->shortcut();
- backShortcut.setAlternate(Qt::Key_Backspace);
- backAction->setShortcut(backShortcut);
+ QAction* backAction = KStandardAction::back(this, SLOT(goBack()), actionCollection());
+ auto backShortcuts = backAction->shortcuts();
+ backShortcuts.append(QKeySequence(Qt::Key_Backspace));
+ actionCollection()->setDefaultShortcuts(backAction, backShortcuts);
DolphinRecentTabsMenu* recentTabsMenu = new DolphinRecentTabsMenu(this);
actionCollection()->addAction("closed_tabs", recentTabsMenu);
- connect(m_tabWidget, SIGNAL(rememberClosedTab(KUrl,QByteArray)),
- recentTabsMenu, SLOT(rememberClosedTab(KUrl,QByteArray)));
+ connect(m_tabWidget, SIGNAL(rememberClosedTab(QUrl,QByteArray)),
+ recentTabsMenu, SLOT(rememberClosedTab(QUrl,QByteArray)));
connect(recentTabsMenu, SIGNAL(restoreClosedTab(QByteArray)),
m_tabWidget, SLOT(restoreClosedTab(QByteArray)));
connect(recentTabsMenu, SIGNAL(closedTabsCountChanged(uint)),
this, SLOT(closedTabsCountChanged(uint)));
- KAction* undoCloseTab = actionCollection()->addAction("undo_close_tab");
+ QAction* undoCloseTab = actionCollection()->addAction("undo_close_tab");
undoCloseTab->setText(i18nc("@action:inmenu File", "Undo close tab"));
- undoCloseTab->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_T);
- undoCloseTab->setIcon(KIcon("edit-undo"));
+ actionCollection()->setDefaultShortcut(undoCloseTab, Qt::CTRL | Qt::SHIFT | Qt::Key_T);
+ undoCloseTab->setIcon(QIcon::fromTheme("edit-undo"));
undoCloseTab->setEnabled(false);
connect(undoCloseTab, SIGNAL(triggered()), recentTabsMenu, SLOT(undoCloseTab()));
- KAction* forwardAction = KStandardAction::forward(this, SLOT(goForward()), actionCollection());
- connect(forwardAction, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)), this, SLOT(goForward(Qt::MouseButtons)));
-
- KAction* upAction = KStandardAction::up(this, SLOT(goUp()), actionCollection());
- connect(upAction, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)), this, SLOT(goUp(Qt::MouseButtons)));
+ auto undoAction = actionCollection()->action(KStandardAction::name(KStandardAction::Undo));
+ undoAction->setEnabled(false); // undo should be disabled by default
- KAction* homeAction = KStandardAction::home(this, SLOT(goHome()), actionCollection());
- connect(homeAction, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)), this, SLOT(goHome(Qt::MouseButtons)));
+ KStandardAction::forward(this, SLOT(goForward()), actionCollection());
+ KStandardAction::up(this, SLOT(goUp()), actionCollection());
+ KStandardAction::home(this, SLOT(goHome()), actionCollection());
// setup 'Tools' menu
- KAction* showFilterBar = actionCollection()->addAction("show_filter_bar");
+ QAction* showFilterBar = actionCollection()->addAction("show_filter_bar");
showFilterBar->setText(i18nc("@action:inmenu Tools", "Show Filter Bar"));
- showFilterBar->setIcon(KIcon("view-filter"));
- showFilterBar->setShortcut(Qt::CTRL | Qt::Key_I);
- connect(showFilterBar, SIGNAL(triggered()), this, SLOT(showFilterBar()));
+ showFilterBar->setIcon(QIcon::fromTheme("view-filter"));
+ actionCollection()->setDefaultShortcut(showFilterBar, Qt::CTRL | Qt::Key_I);
+ connect(showFilterBar, &QAction::triggered, this, &DolphinMainWindow::showFilterBar);
- KAction* compareFiles = actionCollection()->addAction("compare_files");
+ QAction* compareFiles = actionCollection()->addAction("compare_files");
compareFiles->setText(i18nc("@action:inmenu Tools", "Compare Files"));
- compareFiles->setIcon(KIcon("kompare"));
+ compareFiles->setIcon(QIcon::fromTheme("kompare"));
compareFiles->setEnabled(false);
- connect(compareFiles, SIGNAL(triggered()), this, SLOT(compareFiles()));
+ connect(compareFiles, &QAction::triggered, this, &DolphinMainWindow::compareFiles);
- KAction* openTerminal = actionCollection()->addAction("open_terminal");
+ QAction* openTerminal = actionCollection()->addAction("open_terminal");
openTerminal->setText(i18nc("@action:inmenu Tools", "Open Terminal"));
- openTerminal->setIcon(KIcon("utilities-terminal"));
- openTerminal->setShortcut(Qt::SHIFT | Qt::Key_F4);
- connect(openTerminal, SIGNAL(triggered()), this, SLOT(openTerminal()));
+ openTerminal->setIcon(QIcon::fromTheme("utilities-terminal"));
+ actionCollection()->setDefaultShortcut(openTerminal, Qt::SHIFT | Qt::Key_F4);
+ connect(openTerminal, &QAction::triggered, this, &DolphinMainWindow::openTerminal);
// setup 'Settings' menu
KToggleAction* showMenuBar = KStandardAction::showMenubar(0, 0, actionCollection());
- connect(showMenuBar, SIGNAL(triggered(bool)), // Fixes #286822
- this, SLOT(toggleShowMenuBar()), Qt::QueuedConnection);
+ connect(showMenuBar, &KToggleAction::triggered, // Fixes #286822
+ this, &DolphinMainWindow::toggleShowMenuBar, Qt::QueuedConnection);
KStandardAction::preferences(this, SLOT(editSettings()), actionCollection());
// not in menu actions
- QList<QKeySequence> nextTabKeys;
- nextTabKeys.append(KStandardShortcut::tabNext().primary());
+ QList<QKeySequence> nextTabKeys = KStandardShortcut::tabNext();
nextTabKeys.append(QKeySequence(Qt::CTRL | Qt::Key_Tab));
- QList<QKeySequence> prevTabKeys;
- prevTabKeys.append(KStandardShortcut::tabPrev().primary());
+ QList<QKeySequence> prevTabKeys = KStandardShortcut::tabPrev();
prevTabKeys.append(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_Tab));
- KAction* activateNextTab = actionCollection()->addAction("activate_next_tab");
+ QAction* activateNextTab = actionCollection()->addAction("activate_next_tab");
activateNextTab->setIconText(i18nc("@action:inmenu", "Next Tab"));
activateNextTab->setText(i18nc("@action:inmenu", "Activate Next Tab"));
activateNextTab->setEnabled(false);
- connect(activateNextTab, SIGNAL(triggered()), m_tabWidget, SLOT(activateNextTab()));
- activateNextTab->setShortcuts(QApplication::isRightToLeft() ? prevTabKeys : nextTabKeys);
+ connect(activateNextTab, &QAction::triggered, m_tabWidget, &DolphinTabWidget::activateNextTab);
+ actionCollection()->setDefaultShortcuts(activateNextTab, QApplication::isRightToLeft() ? prevTabKeys : nextTabKeys);
- KAction* activatePrevTab = actionCollection()->addAction("activate_prev_tab");
+ QAction* activatePrevTab = actionCollection()->addAction("activate_prev_tab");
activatePrevTab->setIconText(i18nc("@action:inmenu", "Previous Tab"));
activatePrevTab->setText(i18nc("@action:inmenu", "Activate Previous Tab"));
activatePrevTab->setEnabled(false);
- connect(activatePrevTab, SIGNAL(triggered()), m_tabWidget, SLOT(activatePrevTab()));
- activatePrevTab->setShortcuts(QApplication::isRightToLeft() ? nextTabKeys : prevTabKeys);
+ connect(activatePrevTab, &QAction::triggered, m_tabWidget, &DolphinTabWidget::activatePrevTab);
+ actionCollection()->setDefaultShortcuts(activatePrevTab, QApplication::isRightToLeft() ? nextTabKeys : prevTabKeys);
// for context menu
- KAction* openInNewTab = actionCollection()->addAction("open_in_new_tab");
+ QAction* openInNewTab = actionCollection()->addAction("open_in_new_tab");
openInNewTab->setText(i18nc("@action:inmenu", "Open in New Tab"));
- openInNewTab->setIcon(KIcon("tab-new"));
- connect(openInNewTab, SIGNAL(triggered()), this, SLOT(openInNewTab()));
+ openInNewTab->setIcon(QIcon::fromTheme("tab-new"));
+ connect(openInNewTab, &QAction::triggered, this, &DolphinMainWindow::openInNewTab);
- KAction* openInNewTabs = actionCollection()->addAction("open_in_new_tabs");
+ QAction* openInNewTabs = actionCollection()->addAction("open_in_new_tabs");
openInNewTabs->setText(i18nc("@action:inmenu", "Open in New Tabs"));
- openInNewTabs->setIcon(KIcon("tab-new"));
- connect(openInNewTabs, SIGNAL(triggered()), this, SLOT(openInNewTab()));
+ openInNewTabs->setIcon(QIcon::fromTheme("tab-new"));
+ connect(openInNewTabs, &QAction::triggered, this, &DolphinMainWindow::openInNewTab);
- KAction* openInNewWindow = actionCollection()->addAction("open_in_new_window");
+ QAction* openInNewWindow = actionCollection()->addAction("open_in_new_window");
openInNewWindow->setText(i18nc("@action:inmenu", "Open in New Window"));
- openInNewWindow->setIcon(KIcon("window-new"));
- connect(openInNewWindow, SIGNAL(triggered()), this, SLOT(openInNewWindow()));
+ openInNewWindow->setIcon(QIcon::fromTheme("window-new"));
+ connect(openInNewWindow, &QAction::triggered, this, &DolphinMainWindow::openInNewWindow);
}
void DolphinMainWindow::setupDockWidgets()
@@ -1167,32 +1162,32 @@ void DolphinMainWindow::setupDockWidgets()
KDualAction* lockLayoutAction = actionCollection()->add<KDualAction>("lock_panels");
lockLayoutAction->setActiveText(i18nc("@action:inmenu Panels", "Unlock Panels"));
- lockLayoutAction->setActiveIcon(KIcon("object-unlocked"));
+ lockLayoutAction->setActiveIcon(QIcon::fromTheme("object-unlocked"));
lockLayoutAction->setInactiveText(i18nc("@action:inmenu Panels", "Lock Panels"));
- lockLayoutAction->setInactiveIcon(KIcon("object-locked"));
+ lockLayoutAction->setInactiveIcon(QIcon::fromTheme("object-locked"));
lockLayoutAction->setActive(lock);
- connect(lockLayoutAction, SIGNAL(triggered()), this, SLOT(togglePanelLockState()));
+ connect(lockLayoutAction, &KDualAction::triggered, this, &DolphinMainWindow::togglePanelLockState);
// Setup "Information"
DolphinDockWidget* infoDock = new DolphinDockWidget(i18nc("@title:window", "Information"));
infoDock->setLocked(lock);
infoDock->setObjectName("infoDock");
infoDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
- Panel* infoPanel = new InformationPanel(infoDock);
- infoPanel->setCustomContextMenuActions(QList<QAction*>() << lockLayoutAction);
- connect(infoPanel, SIGNAL(urlActivated(KUrl)), this, SLOT(handleUrl(KUrl)));
+ InformationPanel* infoPanel = new InformationPanel(infoDock);
+ infoPanel->setCustomContextMenuActions({lockLayoutAction});
+ connect(infoPanel, &InformationPanel::urlActivated, this, &DolphinMainWindow::handleUrl);
infoDock->setWidget(infoPanel);
QAction* infoAction = infoDock->toggleViewAction();
- createPanelAction(KIcon("dialog-information"), Qt::Key_F11, infoAction, "show_information_panel");
+ createPanelAction(QIcon::fromTheme("dialog-information"), Qt::Key_F11, infoAction, "show_information_panel");
addDockWidget(Qt::RightDockWidgetArea, infoDock);
- connect(this, SIGNAL(urlChanged(KUrl)),
- infoPanel, SLOT(setUrl(KUrl)));
- connect(this, SIGNAL(selectionChanged(KFileItemList)),
- infoPanel, SLOT(setSelection(KFileItemList)));
- connect(this, SIGNAL(requestItemInfo(KFileItem)),
- infoPanel, SLOT(requestDelayedItemInfo(KFileItem)));
+ connect(this, &DolphinMainWindow::urlChanged,
+ infoPanel, &InformationPanel::setUrl);
+ connect(this, &DolphinMainWindow::selectionChanged,
+ infoPanel, &InformationPanel::setSelection);
+ connect(this, &DolphinMainWindow::requestItemInfo,
+ infoPanel, &InformationPanel::requestDelayedItemInfo);
// Setup "Folders"
DolphinDockWidget* foldersDock = new DolphinDockWidget(i18nc("@title:window", "Folders"));
@@ -1200,21 +1195,21 @@ void DolphinMainWindow::setupDockWidgets()
foldersDock->setObjectName("foldersDock");
foldersDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
FoldersPanel* foldersPanel = new FoldersPanel(foldersDock);
- foldersPanel->setCustomContextMenuActions(QList<QAction*>() << lockLayoutAction);
+ foldersPanel->setCustomContextMenuActions({lockLayoutAction});
foldersDock->setWidget(foldersPanel);
QAction* foldersAction = foldersDock->toggleViewAction();
- createPanelAction(KIcon("folder"), Qt::Key_F7, foldersAction, "show_folders_panel");
+ createPanelAction(QIcon::fromTheme("folder"), Qt::Key_F7, foldersAction, "show_folders_panel");
addDockWidget(Qt::LeftDockWidgetArea, foldersDock);
- connect(this, SIGNAL(urlChanged(KUrl)),
- foldersPanel, SLOT(setUrl(KUrl)));
- connect(foldersPanel, SIGNAL(folderActivated(KUrl)),
- this, SLOT(changeUrl(KUrl)));
- connect(foldersPanel, SIGNAL(folderMiddleClicked(KUrl)),
- this, SLOT(openNewTab(KUrl)));
- connect(foldersPanel, SIGNAL(errorMessage(QString)),
- this, SLOT(slotPanelErrorMessage(QString)));
+ connect(this, &DolphinMainWindow::urlChanged,
+ foldersPanel, &FoldersPanel::setUrl);
+ connect(foldersPanel, &FoldersPanel::folderActivated,
+ this, &DolphinMainWindow::changeUrl);
+ connect(foldersPanel, &FoldersPanel::folderMiddleClicked,
+ this, &DolphinMainWindow::openNewTab);
+ connect(foldersPanel, &FoldersPanel::errorMessage,
+ this, &DolphinMainWindow::showErrorMessage);
// Setup "Terminal"
#ifndef Q_OS_WIN
@@ -1222,21 +1217,21 @@ void DolphinMainWindow::setupDockWidgets()
terminalDock->setLocked(lock);
terminalDock->setObjectName("terminalDock");
terminalDock->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
- Panel* terminalPanel = new TerminalPanel(terminalDock);
- terminalPanel->setCustomContextMenuActions(QList<QAction*>() << lockLayoutAction);
+ TerminalPanel* terminalPanel = new TerminalPanel(terminalDock);
+ terminalPanel->setCustomContextMenuActions({lockLayoutAction});
terminalDock->setWidget(terminalPanel);
- connect(terminalPanel, SIGNAL(hideTerminalPanel()), terminalDock, SLOT(hide()));
- connect(terminalPanel, SIGNAL(changeUrl(KUrl)), this, SLOT(slotTerminalDirectoryChanged(KUrl)));
- connect(terminalDock, SIGNAL(visibilityChanged(bool)),
- terminalPanel, SLOT(dockVisibilityChanged()));
+ connect(terminalPanel, &TerminalPanel::hideTerminalPanel, terminalDock, &DolphinDockWidget::hide);
+ connect(terminalPanel, &TerminalPanel::changeUrl, this, &DolphinMainWindow::slotTerminalDirectoryChanged);
+ connect(terminalDock, &DolphinDockWidget::visibilityChanged,
+ terminalPanel, &TerminalPanel::dockVisibilityChanged);
QAction* terminalAction = terminalDock->toggleViewAction();
- createPanelAction(KIcon("utilities-terminal"), Qt::Key_F4, terminalAction, "show_terminal_panel");
+ createPanelAction(QIcon::fromTheme("utilities-terminal"), Qt::Key_F4, terminalAction, "show_terminal_panel");
addDockWidget(Qt::BottomDockWidgetArea, terminalDock);
- connect(this, SIGNAL(urlChanged(KUrl)),
- terminalPanel, SLOT(setUrl(KUrl)));
+ connect(this, &DolphinMainWindow::urlChanged,
+ terminalPanel, &TerminalPanel::setUrl);
#endif
if (GeneralSettings::version() < 200) {
@@ -1254,25 +1249,25 @@ void DolphinMainWindow::setupDockWidgets()
placesDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
PlacesPanel* placesPanel = new PlacesPanel(placesDock);
- placesPanel->setCustomContextMenuActions(QList<QAction*>() << lockLayoutAction);
+ placesPanel->setCustomContextMenuActions({lockLayoutAction});
placesDock->setWidget(placesPanel);
QAction* placesAction = placesDock->toggleViewAction();
- createPanelAction(KIcon("bookmarks"), Qt::Key_F9, placesAction, "show_places_panel");
+ createPanelAction(QIcon::fromTheme("bookmarks"), Qt::Key_F9, placesAction, "show_places_panel");
addDockWidget(Qt::LeftDockWidgetArea, placesDock);
- connect(placesPanel, SIGNAL(placeActivated(KUrl)),
- this, SLOT(slotPlaceActivated(KUrl)));
- connect(placesPanel, SIGNAL(placeMiddleClicked(KUrl)),
- this, SLOT(openNewTab(KUrl)));
- connect(placesPanel, SIGNAL(errorMessage(QString)),
- this, SLOT(slotPanelErrorMessage(QString)));
- connect(this, SIGNAL(urlChanged(KUrl)),
- placesPanel, SLOT(setUrl(KUrl)));
- connect(placesDock, SIGNAL(visibilityChanged(bool)),
- m_tabWidget, SLOT(slotPlacesPanelVisibilityChanged(bool)));
- connect(this, SIGNAL(settingsChanged()),
- placesPanel, SLOT(readSettings()));
+ connect(placesPanel, &PlacesPanel::placeActivated,
+ this, &DolphinMainWindow::slotPlaceActivated);
+ connect(placesPanel, SIGNAL(placeMiddleClicked(QUrl)),
+ this, SLOT(openNewTab(QUrl)));
+ connect(placesPanel, &PlacesPanel::errorMessage,
+ this, &DolphinMainWindow::showErrorMessage);
+ connect(this, &DolphinMainWindow::urlChanged,
+ placesPanel, &PlacesPanel::setUrl);
+ connect(placesDock, &DolphinDockWidget::visibilityChanged,
+ m_tabWidget, &DolphinTabWidget::slotPlacesPanelVisibilityChanged);
+ connect(this, &DolphinMainWindow::settingsChanged,
+ placesPanel, &PlacesPanel::readSettings);
m_tabWidget->slotPlacesPanelVisibilityChanged(placesPanel->isVisible());
@@ -1334,8 +1329,8 @@ void DolphinMainWindow::updateViewActions()
void DolphinMainWindow::updateGoActions()
{
QAction* goUpAction = actionCollection()->action(KStandardAction::name(KStandardAction::Up));
- const KUrl currentUrl = m_activeViewContainer->url();
- goUpAction->setEnabled(currentUrl.upUrl() != currentUrl);
+ const QUrl currentUrl = m_activeViewContainer->url();
+ goUpAction->setEnabled(KIO::upUrl(currentUrl) != currentUrl);
}
void DolphinMainWindow::createControlButton()
@@ -1346,29 +1341,29 @@ void DolphinMainWindow::createControlButton()
Q_ASSERT(!m_controlButton);
m_controlButton = new QToolButton(this);
- m_controlButton->setIcon(KIcon("applications-system"));
+ m_controlButton->setIcon(QIcon::fromTheme("applications-system"));
m_controlButton->setText(i18nc("@action", "Control"));
m_controlButton->setPopupMode(QToolButton::InstantPopup);
m_controlButton->setToolButtonStyle(toolBar()->toolButtonStyle());
- KMenu* controlMenu = new KMenu(m_controlButton);
- connect(controlMenu, SIGNAL(aboutToShow()), this, SLOT(updateControlMenu()));
+ QMenu* controlMenu = new QMenu(m_controlButton);
+ connect(controlMenu, &QMenu::aboutToShow, this, &DolphinMainWindow::updateControlMenu);
m_controlButton->setMenu(controlMenu);
toolBar()->addWidget(m_controlButton);
- connect(toolBar(), SIGNAL(iconSizeChanged(QSize)),
- m_controlButton, SLOT(setIconSize(QSize)));
- connect(toolBar(), SIGNAL(toolButtonStyleChanged(Qt::ToolButtonStyle)),
- m_controlButton, SLOT(setToolButtonStyle(Qt::ToolButtonStyle)));
+ connect(toolBar(), &KToolBar::iconSizeChanged,
+ m_controlButton, &QToolButton::setIconSize);
+ connect(toolBar(), &KToolBar::toolButtonStyleChanged,
+ m_controlButton, &QToolButton::setToolButtonStyle);
// The added widgets are owned by the toolbar and may get deleted when e.g. the toolbar
// gets edited. In this case we must add them again. The adding is done asynchronously by
// m_updateToolBarTimer.
- connect(m_controlButton, SIGNAL(destroyed()), this, SLOT(slotControlButtonDeleted()));
+ connect(m_controlButton, &QToolButton::destroyed, this, &DolphinMainWindow::slotControlButtonDeleted);
m_updateToolBarTimer = new QTimer(this);
m_updateToolBarTimer->setInterval(500);
- connect(m_updateToolBarTimer, SIGNAL(timeout()), this, SLOT(updateToolBar()));
+ connect(m_updateToolBarTimer, &QTimer::timeout, this, &DolphinMainWindow::updateToolBar);
}
void DolphinMainWindow::deleteControlButton()
@@ -1380,7 +1375,7 @@ void DolphinMainWindow::deleteControlButton()
m_updateToolBarTimer = 0;
}
-bool DolphinMainWindow::addActionToMenu(QAction* action, KMenu* menu)
+bool DolphinMainWindow::addActionToMenu(QAction* action, QMenu* menu)
{
Q_ASSERT(action);
Q_ASSERT(menu);
@@ -1418,38 +1413,40 @@ void DolphinMainWindow::clearStatusBar()
void DolphinMainWindow::connectViewSignals(DolphinViewContainer* container)
{
- connect(container, SIGNAL(showFilterBarChanged(bool)),
- this, SLOT(updateFilterBarAction(bool)));
- connect(container, SIGNAL(writeStateChanged(bool)),
- this, SLOT(slotWriteStateChanged(bool)));
+ connect(container, &DolphinViewContainer::showFilterBarChanged,
+ this, &DolphinMainWindow::updateFilterBarAction);
+ connect(container, &DolphinViewContainer::writeStateChanged,
+ this, &DolphinMainWindow::slotWriteStateChanged);
const DolphinView* view = container->view();
- connect(view, SIGNAL(selectionChanged(KFileItemList)),
- this, SLOT(slotSelectionChanged(KFileItemList)));
- connect(view, SIGNAL(requestItemInfo(KFileItem)),
- this, SLOT(slotRequestItemInfo(KFileItem)));
- connect(view, SIGNAL(tabRequested(KUrl)),
- this, SLOT(openNewTab(KUrl)));
- connect(view, SIGNAL(requestContextMenu(QPoint,KFileItem,KUrl,QList<QAction*>)),
- this, SLOT(openContextMenu(QPoint,KFileItem,KUrl,QList<QAction*>)));
- connect(view, SIGNAL(directoryLoadingStarted()),
- this, SLOT(enableStopAction()));
- connect(view, SIGNAL(directoryLoadingCompleted()),
- this, SLOT(disableStopAction()));
- connect(view, SIGNAL(goBackRequested()),
- this, SLOT(goBack()));
- connect(view, SIGNAL(goForwardRequested()),
- this, SLOT(goForward()));
+ connect(view, &DolphinView::selectionChanged,
+ this, &DolphinMainWindow::slotSelectionChanged);
+ connect(view, &DolphinView::requestItemInfo,
+ this, &DolphinMainWindow::requestItemInfo);
+ connect(view, &DolphinView::tabRequested,
+ this, &DolphinMainWindow::openNewTab);
+ connect(view, &DolphinView::requestContextMenu,
+ this, &DolphinMainWindow::openContextMenu);
+ connect(view, &DolphinView::directoryLoadingStarted,
+ this, &DolphinMainWindow::enableStopAction);
+ connect(view, &DolphinView::directoryLoadingCompleted,
+ this, &DolphinMainWindow::disableStopAction);
+ connect(view, &DolphinView::directoryLoadingCompleted,
+ this, &DolphinMainWindow::slotDirectoryLoadingCompleted);
+ connect(view, &DolphinView::goBackRequested,
+ this, static_cast<void(DolphinMainWindow::*)()>(&DolphinMainWindow::goBack));
+ connect(view, &DolphinView::goForwardRequested,
+ this, static_cast<void(DolphinMainWindow::*)()>(&DolphinMainWindow::goForward));
const KUrlNavigator* navigator = container->urlNavigator();
- connect(navigator, SIGNAL(urlChanged(KUrl)),
- this, SLOT(changeUrl(KUrl)));
- connect(navigator, SIGNAL(historyChanged()),
- this, SLOT(updateHistory()));
- connect(navigator, SIGNAL(editableStateChanged(bool)),
- this, SLOT(slotEditableStateChanged(bool)));
- connect(navigator, SIGNAL(tabRequested(KUrl)),
- this, SLOT(openNewTab(KUrl)));
+ connect(navigator, &KUrlNavigator::urlChanged,
+ this, &DolphinMainWindow::changeUrl);
+ connect(navigator, &KUrlNavigator::historyChanged,
+ this, &DolphinMainWindow::updateHistory);
+ connect(navigator, &KUrlNavigator::editableStateChanged,
+ this, &DolphinMainWindow::slotEditableStateChanged);
+ connect(navigator, &KUrlNavigator::tabRequested,
+ this, &DolphinMainWindow::openNewTab);
}
void DolphinMainWindow::updateSplitAction()
@@ -1460,16 +1457,16 @@ void DolphinMainWindow::updateSplitAction()
if (tabPage->primaryViewActive()) {
splitAction->setText(i18nc("@action:intoolbar Close left view", "Close"));
splitAction->setToolTip(i18nc("@info", "Close left view"));
- splitAction->setIcon(KIcon("view-left-close"));
+ splitAction->setIcon(QIcon::fromTheme("view-left-close"));
} else {
splitAction->setText(i18nc("@action:intoolbar Close right view", "Close"));
splitAction->setToolTip(i18nc("@info", "Close right view"));
- splitAction->setIcon(KIcon("view-right-close"));
+ splitAction->setIcon(QIcon::fromTheme("view-right-close"));
}
} else {
splitAction->setText(i18nc("@action:intoolbar Split view", "Split"));
splitAction->setToolTip(i18nc("@info", "Split view"));
- splitAction->setIcon(KIcon("view-right-new"));
+ splitAction->setIcon(QIcon::fromTheme("view-right-new"));
}
}
@@ -1480,26 +1477,26 @@ bool DolphinMainWindow::isKompareInstalled() const
if (!initialized) {
// TODO: maybe replace this approach later by using a menu
// plugin like kdiff3plugin.cpp
- installed = !KGlobal::dirs()->findExe("kompare").isEmpty();
+ installed = !QStandardPaths::findExecutable(QStringLiteral("kompare")).isEmpty();
initialized = true;
}
return installed;
}
-void DolphinMainWindow::createPanelAction(const KIcon& icon,
+void DolphinMainWindow::createPanelAction(const QIcon& icon,
const QKeySequence& shortcut,
QAction* dockAction,
const QString& actionName)
{
- KAction* panelAction = actionCollection()->addAction(actionName);
+ QAction* panelAction = actionCollection()->addAction(actionName);
panelAction->setCheckable(true);
panelAction->setChecked(dockAction->isChecked());
panelAction->setText(dockAction->text());
panelAction->setIcon(icon);
- panelAction->setShortcut(shortcut);
+ actionCollection()->setDefaultShortcut(panelAction, shortcut);
- connect(panelAction, SIGNAL(triggered()), dockAction, SLOT(trigger()));
- connect(dockAction, SIGNAL(toggled(bool)), panelAction, SLOT(setChecked(bool)));
+ connect(panelAction, &QAction::triggered, dockAction, &QAction::trigger);
+ connect(dockAction, &QAction::toggled, panelAction, &QAction::setChecked);
}
DolphinMainWindow::UndoUiInterface::UndoUiInterface() :
@@ -1522,4 +1519,3 @@ void DolphinMainWindow::UndoUiInterface::jobError(KIO::Job* job)
}
}
-#include "dolphinmainwindow.moc"
diff --git a/src/dolphinmainwindow.h b/src/dolphinmainwindow.h
index 9d4c003af..5066657ef 100644
--- a/src/dolphinmainwindow.h
+++ b/src/dolphinmainwindow.h
@@ -24,30 +24,28 @@
#include <config-baloo.h>
-#include <KFileItemDelegate>
#include <kio/fileundomanager.h>
#include <ksortablelist.h>
#include <kxmlguiwindow.h>
-#include <KIcon>
+#include <QIcon>
+#include <QUrl>
#include <QList>
-#include <QWeakPointer>
+#include <QPointer>
typedef KIO::FileUndoManager::CommandType CommandType;
class DolphinViewActionHandler;
-class DolphinApplication;
class DolphinSettingsDialog;
class DolphinViewContainer;
class DolphinRemoteEncoding;
class DolphinTabWidget;
-class KAction;
class KFileItem;
class KFileItemList;
class KJob;
class KNewFileMenu;
-class KUrl;
class QToolButton;
+class QIcon;
/**
* @short Main window for Dolphin.
@@ -59,7 +57,6 @@ class DolphinMainWindow: public KXmlGuiWindow
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.kde.dolphin.MainWindow")
Q_PROPERTY(int id READ getId SCRIPTABLE true)
- friend class DolphinApplication;
public:
DolphinMainWindow();
@@ -77,14 +74,14 @@ public:
* Opens each directory in \p dirs in a separate tab. If the "split view"
* option is enabled, 2 directories are collected within one tab.
*/
- void openDirectories(const QList<KUrl>& dirs);
+ void openDirectories(const QList<QUrl> &dirs);
/**
* Opens the directory which contains the files \p files
* and selects all files (implements the --select option
* of Dolphin).
*/
- void openFiles(const QList<KUrl>& files);
+ void openFiles(const QList<QUrl>& files);
/**
* Returns the 'Create New...' sub menu which also can be shared
@@ -110,18 +107,23 @@ public slots:
* Inform all affected dolphin components (panels, views) of an URL
* change.
*/
- void changeUrl(const KUrl& url);
+ void changeUrl(const QUrl& url);
/**
* The current directory of the Terminal Panel has changed, probably because
* the user entered a 'cd' command. This slot calls changeUrl(url) and makes
* sure that the panel keeps the keyboard focus.
*/
- void slotTerminalDirectoryChanged(const KUrl& url);
+ void slotTerminalDirectoryChanged(const QUrl& url);
/** Stores all settings and quits Dolphin. */
void quit();
+ /**
+ * Opens a new tab showing the URL \a url and activates the tab.
+ */
+ void openNewActivatedTab(const QUrl& url);
+
signals:
/**
* Is sent if the selection of the currently active view has
@@ -133,7 +135,7 @@ signals:
* Is sent if the url of the currently active view has
* been changed.
*/
- void urlChanged(const KUrl& url);
+ void urlChanged(const QUrl& url);
/**
* Is emitted if information of an item is requested to be shown e. g. in the panel.
@@ -148,16 +150,16 @@ signals:
protected:
/** @see QWidget::showEvent() */
- virtual void showEvent(QShowEvent* event);
+ virtual void showEvent(QShowEvent* event) Q_DECL_OVERRIDE;
/** @see QMainWindow::closeEvent() */
- virtual void closeEvent(QCloseEvent* event);
+ virtual void closeEvent(QCloseEvent* event) Q_DECL_OVERRIDE;
/** @see KMainWindow::saveProperties() */
- virtual void saveProperties(KConfigGroup& group);
+ virtual void saveProperties(KConfigGroup& group) Q_DECL_OVERRIDE;
/** @see KMainWindow::readProperties() */
- virtual void readProperties(const KConfigGroup& group);
+ virtual void readProperties(const KConfigGroup& group) Q_DECL_OVERRIDE;
private slots:
/**
@@ -313,9 +315,6 @@ private slots:
*/
void slotSelectionChanged(const KFileItemList& selection);
- /** Emits the signal requestItemInfo(). */
- void slotRequestItemInfo(const KFileItem&);
-
/**
* Updates the state of the 'Back' and 'Forward' menu
* actions corresponding to the current history.
@@ -335,16 +334,9 @@ private slots:
void openNewActivatedTab();
/**
- * Opens a new tab in the background showing the URL \a primaryUrl and the
- * optional URL \a secondaryUrl.
- */
- void openNewTab(const KUrl& primaryUrl, const KUrl& secondaryUrl = KUrl());
-
- /**
- * Opens a new tab showing the URL \a primaryUrl and the optional URL
- * \a secondaryUrl and activates the tab.
+ * Opens a new tab in the background showing the URL \a url.
*/
- void openNewActivatedTab(const KUrl& primaryUrl, const KUrl& secondaryUrl = KUrl());
+ void openNewTab(const QUrl& url);
/**
* Opens the selected folder in a new tab.
@@ -366,7 +358,7 @@ private slots:
* If the URL can be listed, open it in the current view, otherwise
* run it through KRun.
*/
- void handleUrl(const KUrl& url);
+ void handleUrl(const QUrl& url);
/**
* handleUrl() can trigger a stat job to see if the url can actually
@@ -391,7 +383,7 @@ private slots:
*/
void openContextMenu(const QPoint& pos,
const KFileItem& item,
- const KUrl& url,
+ const QUrl& url,
const QList<QAction*>& customActions);
void updateControlMenu();
@@ -399,17 +391,11 @@ private slots:
void slotControlButtonDeleted();
/**
- * Is called if a panel emits an error-message and shows
- * the error-message in the active view-container.
- */
- void slotPanelErrorMessage(const QString& error);
-
- /**
* Is called if the user clicked an item in the Places Panel.
* Reloads the view if \a url is the current URL already, and changes the
* current URL otherwise.
*/
- void slotPlaceActivated(const KUrl& url);
+ void slotPlaceActivated(const QUrl& url);
/**
* Is called if the another view has been activated by changing the current
@@ -433,7 +419,12 @@ private slots:
* Sets the window caption to url.fileName() if this is non-empty,
* "/" if the URL is "file:///", and url.protocol() otherwise.
*/
- void setUrlAsCaption(const KUrl& url);
+ void setUrlAsCaption(const QUrl& url);
+
+ /**
+ * Is called when the view has finished loading the directory.
+ */
+ void slotDirectoryLoadingCompleted();
private:
void setupActions();
@@ -450,7 +441,7 @@ private:
* case if it has not added already to the toolbar.
* @return True if the action has been added to the menu.
*/
- bool addActionToMenu(QAction* action, KMenu* menu);
+ bool addActionToMenu(QAction* action, QMenu* menu);
/**
* Connects the signals from the created DolphinView with
@@ -476,7 +467,7 @@ private:
* as the action for toggling the dock visibility is done by Qt which
* is no KAction instance.
*/
- void createPanelAction(const KIcon& icon,
+ void createPanelAction(const QIcon &icon,
const QKeySequence& shortcut,
QAction* dockAction,
const QString& actionName);
@@ -492,7 +483,7 @@ private:
public:
UndoUiInterface();
virtual ~UndoUiInterface();
- virtual void jobError(KIO::Job* job);
+ virtual void jobError(KIO::Job* job) Q_DECL_OVERRIDE;
};
KNewFileMenu* m_newFileMenu;
@@ -502,7 +493,7 @@ private:
DolphinViewActionHandler* m_actionHandler;
DolphinRemoteEncoding* m_remoteEncoding;
- QWeakPointer<DolphinSettingsDialog> m_settingsDialog;
+ QPointer<DolphinSettingsDialog> m_settingsDialog;
// Members for the toolbar menu that is shown when the menubar is hidden:
QToolButton* m_controlButton;
diff --git a/src/dolphinnewfilemenu.cpp b/src/dolphinnewfilemenu.cpp
index da57ca946..87f0932d8 100644
--- a/src/dolphinnewfilemenu.cpp
+++ b/src/dolphinnewfilemenu.cpp
@@ -45,4 +45,3 @@ void DolphinNewFileMenu::slotResult(KJob* job)
}
}
-#include "dolphinnewfilemenu.moc"
diff --git a/src/dolphinnewfilemenu.h b/src/dolphinnewfilemenu.h
index e211dfd88..9f1cb5599 100644
--- a/src/dolphinnewfilemenu.h
+++ b/src/dolphinnewfilemenu.h
@@ -23,7 +23,7 @@
#include <KNewFileMenu>
-#include "libdolphin_export.h"
+#include "dolphin_export.h"
class KJob;
@@ -35,7 +35,7 @@ class KJob;
* All errors are shown in the status bar of Dolphin
* instead as modal error dialog with an OK button.
*/
-class LIBDOLPHINPRIVATE_EXPORT DolphinNewFileMenu : public KNewFileMenu
+class DOLPHIN_EXPORT DolphinNewFileMenu : public KNewFileMenu
{
Q_OBJECT
@@ -48,7 +48,7 @@ signals:
protected slots:
/** @see KNewFileMenu::slotResult() */
- virtual void slotResult(KJob* job);
+ virtual void slotResult(KJob* job) Q_DECL_OVERRIDE;
};
#endif
diff --git a/src/dolphinpart.cpp b/src/dolphinpart.cpp
index 908173193..ea0ffd92c 100644
--- a/src/dolphinpart.cpp
+++ b/src/dolphinpart.cpp
@@ -21,31 +21,25 @@
#include "dolphinremoveaction.h"
#include <KFileItemListProperties>
-#include <konq_operations.h>
#include <KAboutData>
#include <KActionCollection>
-#include <KConfigGroup>
-#include <KDebug>
-#include <KGlobalSettings>
+#include "dolphindebug.h"
#include <KIconLoader>
-#include <KLocale>
+#include <KLocalizedString>
#include <KMessageBox>
#include <KPluginFactory>
#include <KRun>
-#include <KToggleAction>
-#include <KIO/NetAccess>
#include <KToolInvocation>
#include <kauthorized.h>
-#include <KMenu>
-#include <KInputDialog>
-#include <KProtocolInfo>
+#include <QMenu>
#include <kdeversion.h>
+#include <KSharedConfig>
+#include <KConfigGroup>
+#include <KMimeTypeEditor>
+#include <KJobWidgets>
-#if KDE_IS_VERSION(4, 9, 2)
#include "dolphinpart_ext.h"
-#endif
-
#include "dolphinnewfilemenu.h"
#include "views/dolphinview.h"
#include "views/dolphinviewactionhandler.h"
@@ -54,14 +48,16 @@
#include "kitemviews/kfileitemmodel.h"
#include "kitemviews/private/kfileitemmodeldirlister.h"
+#include <QStandardPaths>
#include <QActionGroup>
+#include <QTextDocument>
#include <QApplication>
#include <QClipboard>
#include <QDir>
-#include <QTextDocument>
+#include <QKeyEvent>
+#include <QInputDialog>
K_PLUGIN_FACTORY(DolphinPartFactory, registerPlugin<DolphinPart>();)
-K_EXPORT_PLUGIN(DolphinPartFactory("dolphinpart", "dolphin"))
DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantList& args)
: KParts::ReadOnlyPart(parent)
@@ -69,83 +65,81 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantL
,m_removeAction(0)
{
Q_UNUSED(args)
- setComponentData(DolphinPartFactory::componentData(), false);
+ setComponentData(*createAboutData(), false);
m_extension = new DolphinPartBrowserExtension(this);
// make sure that other apps using this part find Dolphin's view-file-columns icons
KIconLoader::global()->addAppDir("dolphin");
- m_view = new DolphinView(KUrl(), parentWidget);
+ m_view = new DolphinView(QUrl(), parentWidget);
m_view->setTabsForFilesEnabled(true);
setWidget(m_view);
- connect(&DolphinNewFileMenuObserver::instance(), SIGNAL(errorMessage(QString)),
- this, SLOT(slotErrorMessage(QString)));
+ connect(&DolphinNewFileMenuObserver::instance(), &DolphinNewFileMenuObserver::errorMessage,
+ this, &DolphinPart::slotErrorMessage);
- connect(m_view, SIGNAL(directoryLoadingCompleted()), this, SIGNAL(completed()));
- connect(m_view, SIGNAL(directoryLoadingProgress(int)), this, SLOT(updateProgress(int)));
- connect(m_view, SIGNAL(errorMessage(QString)), this, SLOT(slotErrorMessage(QString)));
+ connect(m_view, &DolphinView::directoryLoadingCompleted, this, static_cast<void(DolphinPart::*)()>(&DolphinPart::completed));
+ connect(m_view, &DolphinView::directoryLoadingProgress, this, &DolphinPart::updateProgress);
+ connect(m_view, &DolphinView::errorMessage, this, &DolphinPart::slotErrorMessage);
setXMLFile("dolphinpart.rc");
- connect(m_view, SIGNAL(infoMessage(QString)),
- this, SLOT(slotMessage(QString)));
- connect(m_view, SIGNAL(operationCompletedMessage(QString)),
- this, SLOT(slotMessage(QString)));
- connect(m_view, SIGNAL(errorMessage(QString)),
- this, SLOT(slotErrorMessage(QString)));
- connect(m_view, SIGNAL(itemActivated(KFileItem)),
- this, SLOT(slotItemActivated(KFileItem)));
- connect(m_view, SIGNAL(itemsActivated(KFileItemList)),
- this, SLOT(slotItemsActivated(KFileItemList)));
- connect(m_view, SIGNAL(tabRequested(KUrl)),
- this, SLOT(createNewWindow(KUrl)));
- connect(m_view, SIGNAL(requestContextMenu(QPoint,KFileItem,KUrl,QList<QAction*>)),
- this, SLOT(slotOpenContextMenu(QPoint,KFileItem,KUrl,QList<QAction*>)));
- connect(m_view, SIGNAL(selectionChanged(KFileItemList)),
- m_extension, SIGNAL(selectionInfo(KFileItemList)));
- connect(m_view, SIGNAL(selectionChanged(KFileItemList)),
- this, SLOT(slotSelectionChanged(KFileItemList)));
- connect(m_view, SIGNAL(requestItemInfo(KFileItem)),
- this, SLOT(slotRequestItemInfo(KFileItem)));
- connect(m_view, SIGNAL(modeChanged(DolphinView::Mode,DolphinView::Mode)),
- this, SIGNAL(viewModeChanged())); // relay signal
- connect(m_view, SIGNAL(redirection(KUrl,KUrl)),
- this, SLOT(slotDirectoryRedirection(KUrl,KUrl)));
+ connect(m_view, &DolphinView::infoMessage,
+ this, &DolphinPart::slotMessage);
+ connect(m_view, &DolphinView::operationCompletedMessage,
+ this, &DolphinPart::slotMessage);
+ connect(m_view, &DolphinView::errorMessage,
+ this, &DolphinPart::slotErrorMessage);
+ connect(m_view, &DolphinView::itemActivated,
+ this, &DolphinPart::slotItemActivated);
+ connect(m_view, &DolphinView::itemsActivated,
+ this, &DolphinPart::slotItemsActivated);
+ connect(m_view, &DolphinView::tabRequested,
+ this, &DolphinPart::createNewWindow);
+ connect(m_view, &DolphinView::requestContextMenu,
+ this, &DolphinPart::slotOpenContextMenu);
+ connect(m_view, &DolphinView::selectionChanged,
+ m_extension, static_cast<void(DolphinPartBrowserExtension::*)(const KFileItemList&)>(&DolphinPartBrowserExtension::selectionInfo));
+ connect(m_view, &DolphinView::selectionChanged,
+ this, &DolphinPart::slotSelectionChanged);
+ connect(m_view, &DolphinView::requestItemInfo,
+ this, &DolphinPart::slotRequestItemInfo);
+ connect(m_view, &DolphinView::modeChanged,
+ this, &DolphinPart::viewModeChanged); // relay signal
+ connect(m_view, &DolphinView::redirection,
+ this, &DolphinPart::slotDirectoryRedirection);
// Watch for changes that should result in updates to the
// status bar text.
- connect(m_view, SIGNAL(itemCountChanged()), this, SLOT(updateStatusBar()));
- connect(m_view, SIGNAL(selectionChanged(KFileItemList)), this, SLOT(updateStatusBar()));
+ connect(m_view, &DolphinView::itemCountChanged, this, &DolphinPart::updateStatusBar);
+ connect(m_view, &DolphinView::selectionChanged, this, &DolphinPart::updateStatusBar);
m_actionHandler = new DolphinViewActionHandler(actionCollection(), this);
m_actionHandler->setCurrentView(m_view);
- connect(m_actionHandler, SIGNAL(createDirectory()), SLOT(createDirectory()));
+ connect(m_actionHandler, &DolphinViewActionHandler::createDirectory, this, &DolphinPart::createDirectory);
m_remoteEncoding = new DolphinRemoteEncoding(this, m_actionHandler);
- connect(this, SIGNAL(aboutToOpenURL()),
- m_remoteEncoding, SLOT(slotAboutToOpenUrl()));
+ connect(this, &DolphinPart::aboutToOpenURL,
+ m_remoteEncoding, &DolphinRemoteEncoding::slotAboutToOpenUrl);
QClipboard* clipboard = QApplication::clipboard();
- connect(clipboard, SIGNAL(dataChanged()),
- this, SLOT(updatePasteAction()));
+ connect(clipboard, &QClipboard::dataChanged,
+ this, &DolphinPart::updatePasteAction);
// Create file info and listing filter extensions.
// NOTE: Listing filter needs to be instantiated after the creation of the view.
new DolphinPartFileInfoExtension(this);
-#if KDE_IS_VERSION(4, 9, 2)
new DolphinPartListingFilterExtension(this);
KDirLister* lister = m_view->m_model->m_dirLister;
if (lister) {
DolphinPartListingNotificationExtension* notifyExt = new DolphinPartListingNotificationExtension(this);
- connect(lister, SIGNAL(newItems(KFileItemList)), notifyExt, SLOT(slotNewItems(KFileItemList)));
- connect(lister, SIGNAL(itemsDeleted(KFileItemList)), notifyExt, SLOT(slotItemsDeleted(KFileItemList)));
+ connect(lister, &KDirLister::newItems, notifyExt, &DolphinPartListingNotificationExtension::slotNewItems);
+ connect(lister, &KDirLister::itemsDeleted, notifyExt, &DolphinPartListingNotificationExtension::slotItemsDeleted);
} else {
- kWarning() << "NULL KDirLister object! KParts::ListingNotificationExtension will NOT be supported";
+ qCWarning(DolphinDebug) << "NULL KDirLister object! KParts::ListingNotificationExtension will NOT be supported";
}
-#endif
createActions();
m_actionHandler->updateViewActions();
@@ -171,70 +165,70 @@ void DolphinPart::createActions()
m_newFileMenu = new DolphinNewFileMenu(actionCollection(), this);
m_newFileMenu->setParentWidget(widget());
- connect(m_newFileMenu->menu(), SIGNAL(aboutToShow()),
- this, SLOT(updateNewMenu()));
+ connect(m_newFileMenu->menu(), &QMenu::aboutToShow,
+ this, &DolphinPart::updateNewMenu);
- KAction *editMimeTypeAction = actionCollection()->addAction( "editMimeType" );
+ QAction *editMimeTypeAction = actionCollection()->addAction( "editMimeType" );
editMimeTypeAction->setText( i18nc("@action:inmenu Edit", "&Edit File Type..." ) );
- connect(editMimeTypeAction, SIGNAL(triggered()), SLOT(slotEditMimeType()));
+ connect(editMimeTypeAction, &QAction::triggered, this, &DolphinPart::slotEditMimeType);
- KAction* selectItemsMatching = actionCollection()->addAction("select_items_matching");
+ QAction* selectItemsMatching = actionCollection()->addAction("select_items_matching");
selectItemsMatching->setText(i18nc("@action:inmenu Edit", "Select Items Matching..."));
- selectItemsMatching->setShortcut(Qt::CTRL | Qt::Key_S);
- connect(selectItemsMatching, SIGNAL(triggered()), this, SLOT(slotSelectItemsMatchingPattern()));
+ actionCollection()->setDefaultShortcut(selectItemsMatching, Qt::CTRL | Qt::Key_S);
+ connect(selectItemsMatching, &QAction::triggered, this, &DolphinPart::slotSelectItemsMatchingPattern);
- KAction* unselectItemsMatching = actionCollection()->addAction("unselect_items_matching");
+ QAction* unselectItemsMatching = actionCollection()->addAction("unselect_items_matching");
unselectItemsMatching->setText(i18nc("@action:inmenu Edit", "Unselect Items Matching..."));
- connect(unselectItemsMatching, SIGNAL(triggered()), this, SLOT(slotUnselectItemsMatchingPattern()));
+ connect(unselectItemsMatching, &QAction::triggered, this, &DolphinPart::slotUnselectItemsMatchingPattern);
actionCollection()->addAction(KStandardAction::SelectAll, "select_all", m_view, SLOT(selectAll()));
- KAction* unselectAll = actionCollection()->addAction("unselect_all");
+ QAction* unselectAll = actionCollection()->addAction("unselect_all");
unselectAll->setText(i18nc("@action:inmenu Edit", "Unselect All"));
- connect(unselectAll, SIGNAL(triggered()), m_view, SLOT(clearSelection()));
+ connect(unselectAll, &QAction::triggered, m_view, &DolphinView::clearSelection);
- KAction* invertSelection = actionCollection()->addAction("invert_selection");
+ QAction* invertSelection = actionCollection()->addAction("invert_selection");
invertSelection->setText(i18nc("@action:inmenu Edit", "Invert Selection"));
- invertSelection->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_A);
- connect(invertSelection, SIGNAL(triggered()), m_view, SLOT(invertSelection()));
+ actionCollection()->setDefaultShortcut(invertSelection, Qt::CTRL | Qt::SHIFT | Qt::Key_A);
+ connect(invertSelection, &QAction::triggered, m_view, &DolphinView::invertSelection);
// View menu: all done by DolphinViewActionHandler
// Go menu
QActionGroup* goActionGroup = new QActionGroup(this);
- connect(goActionGroup, SIGNAL(triggered(QAction*)),
- this, SLOT(slotGoTriggered(QAction*)));
+ connect(goActionGroup, &QActionGroup::triggered,
+ this, &DolphinPart::slotGoTriggered);
createGoAction("go_applications", "start-here-kde",
- i18nc("@action:inmenu Go", "App&lications"), QString("programs:/"),
+ i18nc("@action:inmenu Go", "App&lications"), QStringLiteral("programs:/"),
goActionGroup);
createGoAction("go_network_folders", "folder-remote",
- i18nc("@action:inmenu Go", "&Network Folders"), QString("remote:/"),
+ i18nc("@action:inmenu Go", "&Network Folders"), QStringLiteral("remote:/"),
goActionGroup);
createGoAction("go_settings", "preferences-system",
- i18nc("@action:inmenu Go", "Sett&ings"), QString("settings:/"),
+ i18nc("@action:inmenu Go", "Sett&ings"), QStringLiteral("settings:/"),
goActionGroup);
createGoAction("go_trash", "user-trash",
- i18nc("@action:inmenu Go", "Trash"), QString("trash:/"),
+ i18nc("@action:inmenu Go", "Trash"), QStringLiteral("trash:/"),
goActionGroup);
createGoAction("go_autostart", "",
- i18nc("@action:inmenu Go", "Autostart"), KGlobalSettings::autostartPath(),
+ i18nc("@action:inmenu Go", "Autostart"), QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + "/autostart",
goActionGroup);
// Tools menu
m_findFileAction = actionCollection()->addAction("find_file");
m_findFileAction->setText(i18nc("@action:inmenu Tools", "Find File..."));
- m_findFileAction->setShortcut(Qt::CTRL | Qt::Key_F);
- m_findFileAction->setIcon(KIcon("edit-find"));
- connect(m_findFileAction, SIGNAL(triggered()), this, SLOT(slotFindFile()));
+ actionCollection()->setDefaultShortcut(m_findFileAction, Qt::CTRL | Qt::Key_F);
+ m_findFileAction->setIcon(QIcon::fromTheme("edit-find"));
+ connect(m_findFileAction, &QAction::triggered, this, &DolphinPart::slotFindFile);
if (KAuthorized::authorizeKAction("shell_access")) {
m_openTerminalAction = actionCollection()->addAction("open_terminal");
- m_openTerminalAction->setIcon(KIcon("utilities-terminal"));
+ m_openTerminalAction->setIcon(QIcon::fromTheme("utilities-terminal"));
m_openTerminalAction->setText(i18nc("@action:inmenu Tools", "Open &Terminal"));
- connect(m_openTerminalAction, SIGNAL(triggered()), SLOT(slotOpenTerminal()));
- m_openTerminalAction->setShortcut(Qt::Key_F4);
+ connect(m_openTerminalAction, &QAction::triggered, this, &DolphinPart::slotOpenTerminal);
+ actionCollection()->setDefaultShortcut(m_openTerminalAction, Qt::Key_F4);
}
}
@@ -242,8 +236,8 @@ void DolphinPart::createGoAction(const char* name, const char* iconName,
const QString& text, const QString& url,
QActionGroup* actionGroup)
{
- KAction* action = actionCollection()->addAction(name);
- action->setIcon(KIcon(iconName));
+ QAction* action = actionCollection()->addAction(name);
+ action->setIcon(QIcon::fromTheme(iconName));
action->setText(text);
action->setData(url);
action->setActionGroup(actionGroup);
@@ -252,7 +246,7 @@ void DolphinPart::createGoAction(const char* name, const char* iconName,
void DolphinPart::slotGoTriggered(QAction* action)
{
const QString url = action->data().toString();
- emit m_extension->openUrlRequest(KUrl(url));
+ emit m_extension->openUrlRequest(QUrl(url));
}
void DolphinPart::slotSelectionChanged(const KFileItemList& selection)
@@ -301,10 +295,10 @@ void DolphinPart::updatePasteAction()
KAboutData* DolphinPart::createAboutData()
{
- return new KAboutData("dolphinpart", "dolphin", ki18nc("@title", "Dolphin Part"), "0.1");
+ return new KAboutData("dolphinpart", i18nc("@title", "Dolphin Part"), "0.1");
}
-bool DolphinPart::openUrl(const KUrl& url)
+bool DolphinPart::openUrl(const QUrl &url)
{
bool reload = arguments().reload();
// A bit of a workaround so that changing the namefilter works: force reload.
@@ -315,11 +309,11 @@ bool DolphinPart::openUrl(const KUrl& url)
return true;
}
setUrl(url); // remember it at the KParts level
- KUrl visibleUrl(url);
+ QUrl visibleUrl(url);
if (!m_nameFilter.isEmpty()) {
- visibleUrl.addPath(m_nameFilter);
+ visibleUrl.setPath(visibleUrl.path() + '/' + m_nameFilter);
}
- QString prettyUrl = visibleUrl.pathOrUrl();
+ QString prettyUrl = visibleUrl.toDisplayString(QUrl::PreferLocalFile);
emit setWindowCaption(prettyUrl);
emit m_extension->setLocationBarUrl(prettyUrl);
emit started(0); // get the wheel to spin
@@ -346,7 +340,7 @@ void DolphinPart::slotMessage(const QString& msg)
void DolphinPart::slotErrorMessage(const QString& msg)
{
- kDebug() << msg;
+ qCDebug(DolphinDebug) << msg;
emit canceled(msg);
//KMessageBox::error(m_view, msg);
}
@@ -385,7 +379,7 @@ void DolphinPart::slotItemsActivated(const KFileItemList& items)
}
}
-void DolphinPart::createNewWindow(const KUrl& url)
+void DolphinPart::createNewWindow(const QUrl& url)
{
// TODO: Check issue N176832 for the missing QAIV signal; task 177399 - maybe this code
// should be moved into DolphinPart::slotItemActivated()
@@ -394,7 +388,7 @@ void DolphinPart::createNewWindow(const KUrl& url)
void DolphinPart::slotOpenContextMenu(const QPoint& pos,
const KFileItem& _item,
- const KUrl&,
+ const QUrl &,
const QList<QAction*>& customActions)
{
KParts::BrowserExtension::PopupFlags popupFlags = KParts::BrowserExtension::DefaultPopupItems
@@ -407,7 +401,7 @@ void DolphinPart::slotOpenContextMenu(const QPoint& pos,
popupFlags |= KParts::BrowserExtension::ShowNavigationItems | KParts::BrowserExtension::ShowUp;
item = m_view->rootItem();
if (item.isNull())
- item = KFileItem( S_IFDIR, (mode_t)-1, url() );
+ item = KFileItem(url());
else
item.setUrl(url()); // ensure we use the view url, not the canonical path (#213799)
}
@@ -432,7 +426,7 @@ void DolphinPart::slotOpenContextMenu(const QPoint& pos,
const bool supportsMoving = capabilities.supportsMoving();
if (capabilities.supportsDeleting()) {
- const bool showDeleteAction = (KGlobal::config()->group("KDE").readEntry("ShowDeleteCommand", false) ||
+ const bool showDeleteAction = (KSharedConfig::openConfig()->group("KDE").readEntry("ShowDeleteCommand", false) ||
!item.isLocalFile());
const bool showMoveToTrashAction = capabilities.isLocal() && supportsMoving;
@@ -475,12 +469,12 @@ void DolphinPart::slotOpenContextMenu(const QPoint& pos,
actionGroups);
}
-void DolphinPart::slotDirectoryRedirection(const KUrl& oldUrl, const KUrl& newUrl)
+void DolphinPart::slotDirectoryRedirection(const QUrl &oldUrl, const QUrl &newUrl)
{
- //kDebug() << oldUrl << newUrl << "currentUrl=" << url();
- if (oldUrl.equals(url(), KUrl::CompareWithoutTrailingSlash /* #207572 */)) {
+ qCDebug(DolphinDebug) << oldUrl << newUrl << "currentUrl=" << url();
+ if (oldUrl.matches(url(), QUrl::StripTrailingSlash /* #207572 */)) {
KParts::ReadOnlyPart::setUrl(newUrl);
- const QString prettyUrl = newUrl.pathOrUrl();
+ const QString prettyUrl = newUrl.toDisplayString(QUrl::PreferLocalFile);
emit m_extension->setLocationBarUrl(prettyUrl);
}
}
@@ -490,7 +484,7 @@ void DolphinPart::slotEditMimeType()
{
const KFileItemList items = m_view->selectedItems();
if (!items.isEmpty()) {
- KonqOperations::editMimeType(items.first().mimetype(), m_view);
+ KMimeTypeEditor::editMimeType(items.first().mimetype(), m_view);
}
}
@@ -511,7 +505,7 @@ void DolphinPart::slotUnselectItemsMatchingPattern()
void DolphinPart::openSelectionDialog(const QString& title, const QString& text, bool selectItems)
{
bool okClicked;
- QString pattern = KInputDialog::getText(title, text, "*", &okClicked, m_view);
+ const QString pattern = QInputDialog::getText(m_view, title, text, QLineEdit::Normal, "*", &okClicked);
if (okClicked && !pattern.isEmpty()) {
QRegExp patternRegExp(pattern, Qt::CaseSensitive, QRegExp::Wildcard);
@@ -543,11 +537,14 @@ void DolphinPart::slotOpenTerminal()
{
QString dir(QDir::homePath());
- KUrl u(url());
+ QUrl u(url());
// If the given directory is not local, it can still be the URL of an
// ioslave using UDS_LOCAL_PATH which to be converted first.
- u = KIO::NetAccess::mostLocalUrl(u, widget());
+ KIO::StatJob* statJob = KIO::mostLocalUrl(u);
+ KJobWidgets::setWindow(statJob, widget());
+ statJob->exec();
+ u = statJob->mostLocalUrl();
//If the URL is local after the above conversion, set the directory.
if (u.isLocalFile()) {
@@ -559,7 +556,7 @@ void DolphinPart::slotOpenTerminal()
void DolphinPart::slotFindFile()
{
- KRun::run("kfind", url(), widget());
+ KRun::run("kfind", {url()}, widget());
}
void DolphinPart::updateNewMenu()
@@ -589,7 +586,7 @@ void DolphinPart::createDirectory()
m_newFileMenu->createDirectory();
}
-void DolphinPart::setFilesToSelect(const KUrl::List& files)
+void DolphinPart::setFilesToSelect(const QList<QUrl>& files)
{
if (files.isEmpty()) {
return;
diff --git a/src/dolphinpart.h b/src/dolphinpart.h
index 7146b46af..9f0ed5570 100644
--- a/src/dolphinpart.h
+++ b/src/dolphinpart.h
@@ -20,20 +20,17 @@
#ifndef DOLPHINPART_H
#define DOLPHINPART_H
-#include <kparts/part.h>
+#include <KParts/ReadOnlyPart>
+#include <QUrl>
-#include <QItemSelectionModel>
class DolphinNewFileMenu;
class DolphinViewActionHandler;
class QActionGroup;
-class KAction;
class KFileItemList;
class KFileItem;
class DolphinPartBrowserExtension;
-class DolphinSortFilterProxyModel;
class DolphinRemoteEncoding;
-class DolphinModel;
class KDirLister;
class DolphinView;
class KAboutData;
@@ -53,7 +50,7 @@ class DolphinPart : public KParts::ReadOnlyPart
Q_PROPERTY( QString nameFilter READ nameFilter WRITE setNameFilter )
// Used by konqueror to implement the --select command-line option
- Q_PROPERTY( KUrl::List filesToSelect READ filesToSelect WRITE setFilesToSelect )
+ Q_PROPERTY( QList<QUrl> filesToSelect READ filesToSelect WRITE setFilesToSelect )
public:
explicit DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantList& args);
@@ -65,7 +62,7 @@ public:
* Standard KParts::ReadOnlyPart openUrl method.
* Called by Konqueror to view a directory in DolphinPart.
*/
- virtual bool openUrl(const KUrl& url);
+ virtual bool openUrl(const QUrl& url) Q_DECL_OVERRIDE;
/// see the supportsUndo property
bool supportsUndo() const { return true; }
@@ -134,7 +131,7 @@ private Q_SLOTS:
/**
* Creates a new window showing the content of \a url.
*/
- void createNewWindow(const KUrl& url);
+ void createNewWindow(const QUrl &url);
/**
* Opens the context menu on the current mouse position.
* @pos Position in screen coordinates.
@@ -146,7 +143,7 @@ private Q_SLOTS:
*/
void slotOpenContextMenu(const QPoint& pos,
const KFileItem& item,
- const KUrl& url,
+ const QUrl& url,
const QList<QAction*>& customActions);
/**
@@ -155,7 +152,7 @@ private Q_SLOTS:
* Testcase 1: fish://localhost
* Testcase 2: showing a directory that is being renamed by another window (#180156)
*/
- void slotDirectoryRedirection(const KUrl& oldUrl, const KUrl& newUrl);
+ void slotDirectoryRedirection(const QUrl& oldUrl, const QUrl& newUrl);
/**
* Updates the state of the 'Edit' menu actions and emits
@@ -223,10 +220,10 @@ private Q_SLOTS:
/**
* Called by konqueror --select
*/
- void setFilesToSelect(const KUrl::List& files);
- KUrl::List filesToSelect() const { return KUrl::List(); } // silence moc
+ void setFilesToSelect(const QList<QUrl> &files);
+ QList<QUrl> filesToSelect() const { return QList<QUrl>(); } // silence moc
- virtual bool eventFilter(QObject*, QEvent*);
+ virtual bool eventFilter(QObject*, QEvent*) Q_DECL_OVERRIDE;
private:
void createActions();
@@ -243,8 +240,8 @@ private:
DolphinRemoteEncoding* m_remoteEncoding;
DolphinPartBrowserExtension* m_extension;
DolphinNewFileMenu* m_newFileMenu;
- KAction* m_findFileAction;
- KAction* m_openTerminalAction;
+ QAction* m_findFileAction;
+ QAction* m_openTerminalAction;
QString m_nameFilter;
DolphinRemoveAction* m_removeAction;
Q_DISABLE_COPY(DolphinPart)
diff --git a/src/dolphinpart.rc b/src/dolphinpart.rc
index 893d6c831..725320b28 100644
--- a/src/dolphinpart.rc
+++ b/src/dolphinpart.rc
@@ -1,5 +1,5 @@
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
-<kpartgui name="dolphinpart" version="10" >
+<kpartgui name="dolphinpart" version="11" translationDomain="dolphin">
<MenuBar>
<Menu name="edit"><text>&amp;Edit</text>
<Action name="new_menu"/>
diff --git a/src/dolphinpart_ext.cpp b/src/dolphinpart_ext.cpp
index fb7a4d2ea..a9cefb061 100644
--- a/src/dolphinpart_ext.cpp
+++ b/src/dolphinpart_ext.cpp
@@ -24,7 +24,7 @@
#include <QVariant>
-#include <KFileItemList>
+#include <KFileItem>
DolphinPartBrowserExtension::DolphinPartBrowserExtension(DolphinPart* part)
@@ -61,7 +61,7 @@ void DolphinPartBrowserExtension::paste()
m_part->view()->paste();
}
-void DolphinPartBrowserExtension::pasteTo(const KUrl&)
+void DolphinPartBrowserExtension::pasteTo(const QUrl&)
{
m_part->view()->pasteIntoFolder();
}
@@ -190,4 +190,3 @@ void DolphinPartListingNotificationExtension::slotItemsDeleted(const KFileItemLi
emit listingEvent(KParts::ListingNotificationExtension::ItemsDeleted, items);
}
-#include "dolphinpart_ext.moc"
diff --git a/src/dolphinpart_ext.h b/src/dolphinpart_ext.h
index c05962cd9..6adf64972 100644
--- a/src/dolphinpart_ext.h
+++ b/src/dolphinpart_ext.h
@@ -23,6 +23,7 @@
#include <kparts/browserextension.h>
#include <kparts/fileinfoextension.h>
#include <kparts/listingextension.h>
+#include <QUrl>
class DolphinPart;
@@ -31,14 +32,14 @@ class DolphinPartBrowserExtension : public KParts::BrowserExtension
Q_OBJECT
public:
DolphinPartBrowserExtension( DolphinPart* part );
- virtual void restoreState(QDataStream &stream);
- virtual void saveState(QDataStream &stream);
+ virtual void restoreState(QDataStream &stream) Q_DECL_OVERRIDE;
+ virtual void saveState(QDataStream &stream) Q_DECL_OVERRIDE;
public Q_SLOTS:
void cut();
void copy();
void paste();
- void pasteTo(const KUrl&);
+ void pasteTo(const QUrl &);
void reparseConfiguration();
private:
@@ -52,10 +53,10 @@ class DolphinPartFileInfoExtension : public KParts::FileInfoExtension
public:
DolphinPartFileInfoExtension(DolphinPart* part);
- virtual QueryModes supportedQueryModes() const;
- virtual bool hasSelection() const;
+ virtual QueryModes supportedQueryModes() const Q_DECL_OVERRIDE;
+ virtual bool hasSelection() const Q_DECL_OVERRIDE;
- virtual KFileItemList queryFor(QueryMode mode) const;
+ virtual KFileItemList queryFor(QueryMode mode) const Q_DECL_OVERRIDE;
private:
DolphinPart* m_part;
@@ -67,10 +68,10 @@ class DolphinPartListingFilterExtension : public KParts::ListingFilterExtension
public:
DolphinPartListingFilterExtension(DolphinPart* part);
- virtual FilterModes supportedFilterModes() const;
- virtual bool supportsMultipleFilters(FilterMode mode) const;
- virtual QVariant filter(FilterMode mode) const;
- virtual void setFilter(FilterMode mode, const QVariant& filter);
+ virtual FilterModes supportedFilterModes() const Q_DECL_OVERRIDE;
+ virtual bool supportsMultipleFilters(FilterMode mode) const Q_DECL_OVERRIDE;
+ virtual QVariant filter(FilterMode mode) const Q_DECL_OVERRIDE;
+ virtual void setFilter(FilterMode mode, const QVariant& filter) Q_DECL_OVERRIDE;
private:
DolphinPart* m_part;
@@ -82,7 +83,7 @@ class DolphinPartListingNotificationExtension : public KParts::ListingNotificati
public:
DolphinPartListingNotificationExtension(DolphinPart* part);
- virtual NotificationEventTypes supportedNotificationEventTypes() const;
+ virtual NotificationEventTypes supportedNotificationEventTypes() const Q_DECL_OVERRIDE;
public Q_SLOTS:
void slotNewItems(const KFileItemList&);
diff --git a/src/dolphinrecenttabsmenu.cpp b/src/dolphinrecenttabsmenu.cpp
index fa3eaf166..1087a38e4 100644
--- a/src/dolphinrecenttabsmenu.cpp
+++ b/src/dolphinrecenttabsmenu.cpp
@@ -21,17 +21,17 @@
#include <KLocalizedString>
#include <KAcceleratorManager>
-#include <KMimeType>
-#include <KMenu>
+#include <kio/global.h>
+#include <QMenu>
DolphinRecentTabsMenu::DolphinRecentTabsMenu(QObject* parent) :
- KActionMenu(KIcon("edit-undo"), i18n("Recently Closed Tabs"), parent)
+ KActionMenu(QIcon::fromTheme("edit-undo"), i18n("Recently Closed Tabs"), parent)
{
setDelayed(false);
setEnabled(false);
m_clearListAction = new QAction(i18n("Empty Recently Closed Tabs"), this);
- m_clearListAction->setIcon(KIcon("edit-clear-list"));
+ m_clearListAction->setIcon(QIcon::fromTheme("edit-clear-list"));
addAction(m_clearListAction);
addSeparator();
@@ -40,13 +40,13 @@ DolphinRecentTabsMenu::DolphinRecentTabsMenu(QObject* parent) :
this, SLOT(handleAction(QAction*)));
}
-void DolphinRecentTabsMenu::rememberClosedTab(const KUrl& url, const QByteArray& state)
+void DolphinRecentTabsMenu::rememberClosedTab(const QUrl& url, const QByteArray& state)
{
QAction* action = new QAction(menu());
action->setText(url.path());
action->setData(state);
- const QString iconName = KMimeType::iconNameForUrl(url);
- action->setIcon(KIcon(iconName));
+ const QString iconName = KIO::iconNameForUrl(url);
+ action->setIcon(QIcon::fromTheme(iconName));
// Add the closed tab menu entry after the separator and
// "Empty Recently Closed Tabs" entry
@@ -94,4 +94,4 @@ void DolphinRecentTabsMenu::handleAction(QAction* action)
if (menu()->actions().count() <= 2) {
setEnabled(false);
}
-} \ No newline at end of file
+}
diff --git a/src/dolphinrecenttabsmenu.h b/src/dolphinrecenttabsmenu.h
index 910e564a1..fe92a516d 100644
--- a/src/dolphinrecenttabsmenu.h
+++ b/src/dolphinrecenttabsmenu.h
@@ -21,9 +21,8 @@
#define DOLPHIN_RECENT_TABS_MENU_H
#include <KActionMenu>
-#include <KUrl>
+#include <QUrl>
-class DolphinTabPage;
class QAction;
class DolphinRecentTabsMenu : public KActionMenu
@@ -34,7 +33,7 @@ public:
explicit DolphinRecentTabsMenu(QObject* parent);
public slots:
- void rememberClosedTab(const KUrl& url, const QByteArray& state);
+ void rememberClosedTab(const QUrl& url, const QByteArray& state);
void undoCloseTab();
signals:
@@ -48,4 +47,4 @@ private:
QAction* m_clearListAction;
};
-#endif \ No newline at end of file
+#endif
diff --git a/src/dolphinremoveaction.cpp b/src/dolphinremoveaction.cpp
index 7d7c2f043..7ea4e4f79 100644
--- a/src/dolphinremoveaction.cpp
+++ b/src/dolphinremoveaction.cpp
@@ -29,7 +29,7 @@ DolphinRemoveAction::DolphinRemoveAction(QObject* parent, KActionCollection* col
m_collection(collection)
{
update();
- connect(this, SIGNAL(triggered()), this, SLOT(slotRemoveActionTriggered()));
+ connect(this, &DolphinRemoveAction::triggered, this, &DolphinRemoveAction::slotRemoveActionTriggered);
}
void DolphinRemoveAction::slotRemoveActionTriggered()
@@ -55,7 +55,7 @@ void DolphinRemoveAction::update()
if (m_action) {
setIcon(m_action->icon());
- setShortcuts(m_action->shortcuts());
+ m_collection->setDefaultShortcuts(this, m_action->shortcuts());
setEnabled(m_action->isEnabled());
}
}
diff --git a/src/dolphinremoveaction.h b/src/dolphinremoveaction.h
index 1a123ace5..85f404318 100644
--- a/src/dolphinremoveaction.h
+++ b/src/dolphinremoveaction.h
@@ -20,7 +20,7 @@
#ifndef DOLPHINREMOVEACTION_H
#define DOLPHINREMOVEACTION_H
-#include "libdolphin_export.h"
+#include "dolphin_export.h"
#include <QAction>
#include <QPointer>
@@ -34,7 +34,7 @@
* This class expects the presence of both the "move_to_trash" and "delete"
* actions in @ref collection.
*/
-class LIBDOLPHINPRIVATE_EXPORT DolphinRemoveAction : public QAction
+class DOLPHIN_EXPORT DolphinRemoveAction : public QAction
{
Q_OBJECT
public:
diff --git a/src/dolphintabbar.cpp b/src/dolphintabbar.cpp
index 78bd5edcb..dbd324db5 100644
--- a/src/dolphintabbar.cpp
+++ b/src/dolphintabbar.cpp
@@ -22,9 +22,10 @@
#include <QTimer>
#include <QDragEnterEvent>
#include <KLocalizedString>
-#include <KMenu>
-#include <KIcon>
-#include <KUrl>
+#include <QMenu>
+#include <QIcon>
+#include <QUrl>
+#include <QMimeData>
DolphinTabBar::DolphinTabBar(QWidget* parent) :
QTabBar(parent),
@@ -47,7 +48,7 @@ void DolphinTabBar::dragEnterEvent(QDragEnterEvent* event)
const QMimeData* mimeData = event->mimeData();
const int index = tabAt(event->pos());
- if (KUrl::List::canDecode(mimeData)) {
+ if (mimeData->hasUrls()) {
event->acceptProposedAction();
updateAutoActivationTimer(index);
}
@@ -67,7 +68,7 @@ void DolphinTabBar::dragMoveEvent(QDragMoveEvent* event)
const QMimeData* mimeData = event->mimeData();
const int index = tabAt(event->pos());
- if (KUrl::List::canDecode(mimeData)) {
+ if (mimeData->hasUrls()) {
updateAutoActivationTimer(index);
}
@@ -82,7 +83,7 @@ void DolphinTabBar::dropEvent(QDropEvent* event)
const QMimeData* mimeData = event->mimeData();
const int index = tabAt(event->pos());
- if (index >= 0 && KUrl::List::canDecode(mimeData)) {
+ if (index >= 0 && mimeData->hasUrls()) {
emit tabDropEvent(index, event);
}
@@ -122,12 +123,12 @@ void DolphinTabBar::contextMenuEvent(QContextMenuEvent* event)
if (index >= 0) {
// Tab context menu
- KMenu menu(this);
+ QMenu menu(this);
- QAction* newTabAction = menu.addAction(KIcon("tab-new"), i18nc("@action:inmenu", "New Tab"));
- QAction* detachTabAction = menu.addAction(KIcon("tab-detach"), i18nc("@action:inmenu", "Detach Tab"));
- QAction* closeOtherTabsAction = menu.addAction(KIcon("tab-close-other"), i18nc("@action:inmenu", "Close Other Tabs"));
- QAction* closeTabAction = menu.addAction(KIcon("tab-close"), i18nc("@action:inmenu", "Close Tab"));
+ QAction* newTabAction = menu.addAction(QIcon::fromTheme("tab-new"), i18nc("@action:inmenu", "New Tab"));
+ QAction* detachTabAction = menu.addAction(QIcon::fromTheme("tab-detach"), i18nc("@action:inmenu", "Detach Tab"));
+ QAction* closeOtherTabsAction = menu.addAction(QIcon::fromTheme("tab-close-other"), i18nc("@action:inmenu", "Close Other Tabs"));
+ QAction* closeTabAction = menu.addAction(QIcon::fromTheme("tab-close"), i18nc("@action:inmenu", "Close Tab"));
QAction* selectedAction = menu.exec(event->globalPos());
if (selectedAction == newTabAction) {
diff --git a/src/dolphintabbar.h b/src/dolphintabbar.h
index d2b2e9e57..6daa9a1ad 100644
--- a/src/dolphintabbar.h
+++ b/src/dolphintabbar.h
@@ -35,17 +35,17 @@ signals:
void tabDetachRequested(int index);
protected:
- virtual void dragEnterEvent(QDragEnterEvent* event);
- virtual void dragLeaveEvent(QDragLeaveEvent* event);
- virtual void dragMoveEvent(QDragMoveEvent* event);
- virtual void dropEvent(QDropEvent* event);
- virtual void mousePressEvent(QMouseEvent* event);
- virtual void mouseDoubleClickEvent(QMouseEvent* event);
+ virtual void dragEnterEvent(QDragEnterEvent* event) Q_DECL_OVERRIDE;
+ virtual void dragLeaveEvent(QDragLeaveEvent* event) Q_DECL_OVERRIDE;
+ virtual void dragMoveEvent(QDragMoveEvent* event) Q_DECL_OVERRIDE;
+ virtual void dropEvent(QDropEvent* event) Q_DECL_OVERRIDE;
+ virtual void mousePressEvent(QMouseEvent* event) Q_DECL_OVERRIDE;
+ virtual void mouseDoubleClickEvent(QMouseEvent* event) Q_DECL_OVERRIDE;
/**
* Opens a context menu for the tab on the \a event position.
*/
- virtual void contextMenuEvent(QContextMenuEvent* event);
+ virtual void contextMenuEvent(QContextMenuEvent* event) Q_DECL_OVERRIDE;
private slots:
void slotAutoActivationTimeout();
diff --git a/src/dolphintabpage.cpp b/src/dolphintabpage.cpp
index f7000ea66..6d55ebeb2 100644
--- a/src/dolphintabpage.cpp
+++ b/src/dolphintabpage.cpp
@@ -23,8 +23,9 @@
#include "dolphin_generalsettings.h"
#include <QSplitter>
+#include <QVBoxLayout>
-DolphinTabPage::DolphinTabPage(const KUrl& primaryUrl, const KUrl& secondaryUrl, QWidget* parent) :
+DolphinTabPage::DolphinTabPage(const QUrl &primaryUrl, const QUrl &secondaryUrl, QWidget* parent) :
QWidget(parent),
m_primaryViewActive(true),
m_splitViewEnabled(false)
@@ -39,10 +40,10 @@ DolphinTabPage::DolphinTabPage(const KUrl& primaryUrl, const KUrl& secondaryUrl,
// Create a new primary view
m_primaryViewContainer = createViewContainer(primaryUrl);
- connect(m_primaryViewContainer->view(), SIGNAL(urlChanged(KUrl)),
- this, SIGNAL(activeViewUrlChanged(KUrl)));
- connect(m_primaryViewContainer->view(), SIGNAL(redirection(KUrl,KUrl)),
- this, SLOT(slotViewUrlRedirection(KUrl,KUrl)));
+ connect(m_primaryViewContainer->view(), SIGNAL(urlChanged(QUrl)),
+ this, SIGNAL(activeViewUrlChanged(QUrl)));
+ connect(m_primaryViewContainer->view(), SIGNAL(redirection(QUrl,QUrl)),
+ this, SLOT(slotViewUrlRedirection(QUrl,QUrl)));
m_splitter->addWidget(m_primaryViewContainer);
m_primaryViewContainer->show();
@@ -51,7 +52,7 @@ DolphinTabPage::DolphinTabPage(const KUrl& primaryUrl, const KUrl& secondaryUrl,
// Provide a secondary view, if the given secondary url is valid or if the
// startup settings are set this way (use the url of the primary view).
m_splitViewEnabled = true;
- const KUrl& url = secondaryUrl.isValid() ? secondaryUrl : primaryUrl;
+ const QUrl& url = secondaryUrl.isValid() ? secondaryUrl : primaryUrl;
m_secondaryViewContainer = createViewContainer(url);
m_splitter->addWidget(m_secondaryViewContainer);
m_secondaryViewContainer->show();
@@ -76,7 +77,7 @@ void DolphinTabPage::setSplitViewEnabled(bool enabled)
m_splitViewEnabled = enabled;
if (enabled) {
- const KUrl& url = m_primaryViewContainer->url();
+ const QUrl& url = m_primaryViewContainer->url();
m_secondaryViewContainer = createViewContainer(url);
const bool placesSelectorVisible = m_primaryViewContainer->urlNavigator()->isPlacesSelectorVisible();
@@ -134,7 +135,7 @@ int DolphinTabPage::selectedItemsCount() const
return selectedItemsCount;
}
-void DolphinTabPage::markUrlsAsSelected(const QList<KUrl>& urls)
+void DolphinTabPage::markUrlsAsSelected(const QList<QUrl>& urls)
{
m_primaryViewContainer->view()->markUrlsAsSelected(urls);
if (m_splitViewEnabled) {
@@ -142,7 +143,7 @@ void DolphinTabPage::markUrlsAsSelected(const QList<KUrl>& urls)
}
}
-void DolphinTabPage::markUrlAsCurrent(const KUrl& url)
+void DolphinTabPage::markUrlAsCurrent(const QUrl& url)
{
m_primaryViewContainer->view()->markUrlAsCurrent(url);
if (m_splitViewEnabled) {
@@ -212,7 +213,7 @@ void DolphinTabPage::restoreState(const QByteArray& state)
stream >> isSplitViewEnabled;
setSplitViewEnabled(isSplitViewEnabled);
- KUrl primaryUrl;
+ QUrl primaryUrl;
stream >> primaryUrl;
m_primaryViewContainer->setUrl(primaryUrl);
bool primaryUrlEditable;
@@ -221,7 +222,7 @@ void DolphinTabPage::restoreState(const QByteArray& state)
m_primaryViewContainer->view()->restoreState(stream);
if (isSplitViewEnabled) {
- KUrl secondaryUrl;
+ QUrl secondaryUrl;
stream >> secondaryUrl;
m_secondaryViewContainer->setUrl(secondaryUrl);
bool secondaryUrlEditable;
@@ -256,7 +257,7 @@ void DolphinTabPage::restoreStateV1(const QByteArray& state)
stream >> isSplitViewEnabled;
setSplitViewEnabled(isSplitViewEnabled);
- KUrl primaryUrl;
+ QUrl primaryUrl;
stream >> primaryUrl;
m_primaryViewContainer->setUrl(primaryUrl);
bool primaryUrlEditable;
@@ -264,7 +265,7 @@ void DolphinTabPage::restoreStateV1(const QByteArray& state)
m_primaryViewContainer->urlNavigator()->setUrlEditable(primaryUrlEditable);
if (isSplitViewEnabled) {
- KUrl secondaryUrl;
+ QUrl secondaryUrl;
stream >> secondaryUrl;
m_secondaryViewContainer->setUrl(secondaryUrl);
bool secondaryUrlEditable;
@@ -301,28 +302,28 @@ void DolphinTabPage::slotViewActivated()
const DolphinView* newActiveView = activeViewContainer()->view();
if (newActiveView != oldActiveView) {
- disconnect(oldActiveView, SIGNAL(urlChanged(KUrl)),
- this, SIGNAL(activeViewUrlChanged(KUrl)));
- disconnect(oldActiveView, SIGNAL(redirection(KUrl,KUrl)),
- this, SLOT(slotViewUrlRedirection(KUrl,KUrl)));
- connect(newActiveView, SIGNAL(urlChanged(KUrl)),
- this, SIGNAL(activeViewUrlChanged(KUrl)));
- connect(newActiveView, SIGNAL(redirection(KUrl,KUrl)),
- this, SLOT(slotViewUrlRedirection(KUrl,KUrl)));
+ disconnect(oldActiveView, SIGNAL(urlChanged(QUrl)),
+ this, SIGNAL(activeViewUrlChanged(QUrl)));
+ disconnect(oldActiveView, SIGNAL(redirection(QUrl,QUrl)),
+ this, SLOT(slotViewUrlRedirection(QUrl,QUrl)));
+ connect(newActiveView, SIGNAL(urlChanged(QUrl)),
+ this, SIGNAL(activeViewUrlChanged(QUrl)));
+ connect(newActiveView, SIGNAL(redirection(QUrl,QUrl)),
+ this, SLOT(slotViewUrlRedirection(QUrl,QUrl)));
}
emit activeViewUrlChanged(activeViewContainer()->url());
emit activeViewChanged(activeViewContainer());
}
-void DolphinTabPage::slotViewUrlRedirection(const KUrl& oldUrl, const KUrl& newUrl)
+void DolphinTabPage::slotViewUrlRedirection(const QUrl& oldUrl, const QUrl& newUrl)
{
Q_UNUSED(oldUrl);
emit activeViewUrlChanged(newUrl);
}
-DolphinViewContainer* DolphinTabPage::createViewContainer(const KUrl& url) const
+DolphinViewContainer* DolphinTabPage::createViewContainer(const QUrl& url) const
{
DolphinViewContainer* container = new DolphinViewContainer(url, m_splitter);
container->setActive(false);
diff --git a/src/dolphintabpage.h b/src/dolphintabpage.h
index 2a406f4a9..b46daf350 100644
--- a/src/dolphintabpage.h
+++ b/src/dolphintabpage.h
@@ -22,7 +22,7 @@
#include <QWidget>
#include <QPointer>
-#include <KUrl>
+#include <QUrl>
class QSplitter;
class DolphinViewContainer;
@@ -33,7 +33,7 @@ class DolphinTabPage : public QWidget
Q_OBJECT
public:
- explicit DolphinTabPage(const KUrl& primaryUrl, const KUrl& secondaryUrl = KUrl(), QWidget* parent = 0);
+ explicit DolphinTabPage(const QUrl& primaryUrl, const QUrl& secondaryUrl = QUrl(), QWidget* parent = 0);
/**
* @return True if primary view is the active view in this tab.
@@ -85,13 +85,13 @@ public:
* gets selected if no loading of a directory has been triggered
* by DolphinView::setUrl() or DolphinView::reload().
*/
- void markUrlsAsSelected(const QList<KUrl>& urls);
+ void markUrlsAsSelected(const QList<QUrl> &urls);
/**
* Marks the item indicated by \p url to be scrolled to and as the
* current item after directory DolphinView::url() has been loaded.
*/
- void markUrlAsCurrent(const KUrl& url);
+ void markUrlAsCurrent(const QUrl& url);
/**
* Sets the places selector visible, if \a visible is true.
@@ -131,7 +131,7 @@ public:
signals:
void activeViewChanged(DolphinViewContainer* viewContainer);
- void activeViewUrlChanged(const KUrl& url);
+ void activeViewUrlChanged(const QUrl& url);
private slots:
/**
@@ -147,13 +147,13 @@ private slots:
*
* It emits the activeViewUrlChanged signal with the url \a newUrl.
*/
- void slotViewUrlRedirection(const KUrl& oldUrl, const KUrl& newUrl);
+ void slotViewUrlRedirection(const QUrl& oldUrl, const QUrl& newUrl);
private:
/**
* Creates a new view container and does the default initialization.
*/
- DolphinViewContainer* createViewContainer(const KUrl& url) const;
+ DolphinViewContainer* createViewContainer(const QUrl& url) const;
private:
QSplitter* m_splitter;
diff --git a/src/dolphintabwidget.cpp b/src/dolphintabwidget.cpp
index c6607e529..5b26359e6 100644
--- a/src/dolphintabwidget.cpp
+++ b/src/dolphintabwidget.cpp
@@ -23,11 +23,10 @@
#include "dolphintabpage.h"
#include "dolphinviewcontainer.h"
#include "dolphin_generalsettings.h"
-#include "views/draganddrophelper.h"
#include <QApplication>
#include <KConfigGroup>
-#include <KIcon>
+#include <kio/global.h>
#include <KRun>
DolphinTabWidget::DolphinTabWidget(QWidget* parent) :
@@ -130,13 +129,13 @@ void DolphinTabWidget::openNewActivatedTab()
}
}
-void DolphinTabWidget::openNewActivatedTab(const KUrl& primaryUrl, const KUrl& secondaryUrl)
+void DolphinTabWidget::openNewActivatedTab(const QUrl& primaryUrl, const QUrl& secondaryUrl)
{
openNewTab(primaryUrl, secondaryUrl);
setCurrentIndex(count() - 1);
}
-void DolphinTabWidget::openNewTab(const KUrl& primaryUrl, const KUrl& secondaryUrl)
+void DolphinTabWidget::openNewTab(const QUrl& primaryUrl, const QUrl& secondaryUrl)
{
QWidget* focusWidget = QApplication::focusWidget();
@@ -144,9 +143,9 @@ void DolphinTabWidget::openNewTab(const KUrl& primaryUrl, const KUrl& secondaryU
tabPage->setPlacesSelectorVisible(m_placesSelectorVisible);
connect(tabPage, SIGNAL(activeViewChanged(DolphinViewContainer*)),
this, SIGNAL(activeViewChanged(DolphinViewContainer*)));
- connect(tabPage, SIGNAL(activeViewUrlChanged(KUrl)),
- this, SLOT(tabUrlChanged(KUrl)));
- addTab(tabPage, KIcon(KMimeType::iconNameForUrl(primaryUrl)), tabName(primaryUrl));
+ connect(tabPage, SIGNAL(activeViewUrlChanged(QUrl)),
+ this, SLOT(tabUrlChanged(QUrl)));
+ addTab(tabPage, QIcon::fromTheme(KIO::iconNameForUrl(primaryUrl)), tabName(primaryUrl));
if (focusWidget) {
// The DolphinViewContainer grabbed the keyboard focus. As the tab is opened
@@ -155,17 +154,17 @@ void DolphinTabWidget::openNewTab(const KUrl& primaryUrl, const KUrl& secondaryU
}
}
-void DolphinTabWidget::openDirectories(const QList<KUrl>& dirs)
+void DolphinTabWidget::openDirectories(const QList<QUrl>& dirs)
{
const bool hasSplitView = GeneralSettings::splitView();
// Open each directory inside a new tab. If the "split view" option has been enabled,
// always show two directories within one tab.
- QList<KUrl>::const_iterator it = dirs.constBegin();
+ QList<QUrl>::const_iterator it = dirs.constBegin();
while (it != dirs.constEnd()) {
- const KUrl& primaryUrl = *(it++);
+ const QUrl& primaryUrl = *(it++);
if (hasSplitView && (it != dirs.constEnd())) {
- const KUrl& secondaryUrl = *(it++);
+ const QUrl& secondaryUrl = *(it++);
openNewTab(primaryUrl, secondaryUrl);
} else {
openNewTab(primaryUrl);
@@ -173,7 +172,7 @@ void DolphinTabWidget::openDirectories(const QList<KUrl>& dirs)
}
}
-void DolphinTabWidget::openFiles(const QList<KUrl>& files)
+void DolphinTabWidget::openFiles(const QList<QUrl>& files)
{
if (files.isEmpty()) {
return;
@@ -182,9 +181,9 @@ void DolphinTabWidget::openFiles(const QList<KUrl>& files)
// Get all distinct directories from 'files' and open a tab
// for each directory. If the "split view" option is enabled, two
// directories are shown inside one tab (see openDirectories()).
- QList<KUrl> dirs;
- foreach (const KUrl& url, files) {
- const KUrl dir(url.directory());
+ QList<QUrl> dirs;
+ foreach (const QUrl& url, files) {
+ const QUrl dir(url.adjusted(QUrl::RemoveFilename));
if (!dirs.contains(dir)) {
dirs.append(dir);
}
@@ -286,22 +285,17 @@ void DolphinTabWidget::openNewActivatedTab(int index)
void DolphinTabWidget::tabDropEvent(int index, QDropEvent* event)
{
if (index >= 0) {
- const DolphinView* view = tabPageAt(index)->activeViewContainer()->view();
-
- QString error;
- DragAndDropHelper::dropUrls(view->rootItem(), view->url(), event, error);
- if (!error.isEmpty()) {
- currentTabPage()->activeViewContainer()->showMessage(error, DolphinViewContainer::Error);
- }
+ DolphinView* view = tabPageAt(index)->activeViewContainer()->view();
+ view->dropUrls(view->url(), event);
}
}
-void DolphinTabWidget::tabUrlChanged(const KUrl& url)
+void DolphinTabWidget::tabUrlChanged(const QUrl& url)
{
const int index = indexOf(qobject_cast<QWidget*>(sender()));
if (index >= 0) {
tabBar()->setTabText(index, tabName(url));
- tabBar()->setTabIcon(index, KIcon(KMimeType::iconNameForUrl(url)));
+ tabBar()->setTabIcon(index, QIcon::fromTheme(KIO::iconNameForUrl(url)));
// Emit the currentUrlChanged signal if the url of the current tab has been changed.
if (index == currentIndex()) {
@@ -342,15 +336,15 @@ void DolphinTabWidget::tabRemoved(int index)
emit tabCountChanged(count());
}
-QString DolphinTabWidget::tabName(const KUrl& url) const
+QString DolphinTabWidget::tabName(const QUrl& url) const
{
QString name;
- if (url.equals(KUrl("file:///"))) {
+ if (url == QUrl("file:///")) {
name = '/';
} else {
- name = url.fileName();
+ name = url.adjusted(QUrl::StripTrailingSlash).fileName();
if (name.isEmpty()) {
- name = url.protocol();
+ name = url.scheme();
} else {
// Make sure that a '&' inside the directory name is displayed correctly
// and not misinterpreted as a keyboard shortcut in QTabBar::setTabText()
diff --git a/src/dolphintabwidget.h b/src/dolphintabwidget.h
index 98bcd985a..a84b7facb 100644
--- a/src/dolphintabwidget.h
+++ b/src/dolphintabwidget.h
@@ -21,7 +21,7 @@
#define DOLPHIN_TAB_WIDGET_H
#include <QTabWidget>
-#include <KUrl>
+#include <QUrl>
class DolphinViewContainer;
class DolphinTabPage;
@@ -70,13 +70,13 @@ signals:
/**
* Is emitted when a tab has been closed.
*/
- void rememberClosedTab(const KUrl& url, const QByteArray& state);
+ void rememberClosedTab(const QUrl& url, const QByteArray& state);
/**
* Is emitted when the url of the current tab has been changed. This signal
* is also emitted when the active view has been changed.
*/
- void currentUrlChanged(const KUrl& url);
+ void currentUrlChanged(const QUrl& url);
public slots:
/**
@@ -89,26 +89,26 @@ public slots:
* Opens a new tab showing the URL \a primaryUrl and the optional URL
* \a secondaryUrl and activates the tab.
*/
- void openNewActivatedTab(const KUrl& primaryUrl, const KUrl& secondaryUrl = KUrl());
+ void openNewActivatedTab(const QUrl& primaryUrl, const QUrl& secondaryUrl = QUrl());
/**
* Opens a new tab in the background showing the URL \a primaryUrl and the
* optional URL \a secondaryUrl.
*/
- void openNewTab(const KUrl& primaryUrl, const KUrl& secondaryUrl = KUrl());
+ void openNewTab(const QUrl &primaryUrl, const QUrl &secondaryUrl = QUrl());
/**
* Opens each directory in \p dirs in a separate tab. If the "split view"
* option is enabled, 2 directories are collected within one tab.
*/
- void openDirectories(const QList<KUrl>& dirs);
+ void openDirectories(const QList<QUrl>& dirs);
/**
* Opens the directory which contains the files \p files
* and selects all files (implements the --select option
* of Dolphin).
*/
- void openFiles(const QList<KUrl>& files);
+ void openFiles(const QList<QUrl> &files);
/**
* Closes the currently active tab.
@@ -168,23 +168,23 @@ private slots:
* The active view url of a tab has been changed so update the text and the
* icon of the corresponding tab.
*/
- void tabUrlChanged(const KUrl& url);
+ void tabUrlChanged(const QUrl& url);
void currentTabChanged(int index);
protected:
- virtual void tabInserted(int index);
- virtual void tabRemoved(int index);
+ virtual void tabInserted(int index) Q_DECL_OVERRIDE;
+ virtual void tabRemoved(int index) Q_DECL_OVERRIDE;
private:
/**
* Returns the name of the tab for the URL \a url.
*/
- QString tabName(const KUrl& url) const;
+ QString tabName(const QUrl& url) const;
private:
/** Caches the (negated) places panel visibility */
bool m_placesSelectorVisible;
};
-#endif \ No newline at end of file
+#endif
diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp
index a11ba4202..8fea3ba9d 100644
--- a/src/dolphinviewcontainer.cpp
+++ b/src/dolphinviewcontainer.cpp
@@ -20,44 +20,33 @@
#include "dolphinviewcontainer.h"
#include <KProtocolManager>
-#include <QApplication>
-#include <QKeyEvent>
-#include <QItemSelection>
-#include <QBoxLayout>
+#include <QDropEvent>
#include <QTimer>
-#include <QScrollBar>
+#include <QMimeData>
+#include <QVBoxLayout>
-#include <KDesktopFile>
-#include <KFileItemDelegate>
#include <KFileItemActions>
#include <KFilePlacesModel>
-#include <KLocale>
-#include <KIconEffect>
-#include <KIO/NetAccess>
+#include <KLocalizedString>
#include <KIO/PreviewJob>
#include <KMessageWidget>
-#include <KNewFileMenu>
-#include <konqmimedata.h>
-#include <konq_operations.h>
#include <KShell>
-#include <KUrl>
+#include <QUrl>
#include <KUrlComboBox>
#include <KUrlNavigator>
#include <KRun>
#ifdef KActivities_FOUND
-#include <KActivities/ResourceInstance>
#endif
#include "dolphin_generalsettings.h"
#include "filterbar/filterbar.h"
#include "search/dolphinsearchbox.h"
#include "statusbar/dolphinstatusbar.h"
-#include "views/draganddrophelper.h"
#include "views/viewmodecontroller.h"
#include "views/viewproperties.h"
-DolphinViewContainer::DolphinViewContainer(const KUrl& url, QWidget* parent) :
+DolphinViewContainer::DolphinViewContainer(const QUrl& url, QWidget* parent) :
QWidget(parent),
m_topLayout(0),
m_urlNavigator(0),
@@ -68,9 +57,7 @@ DolphinViewContainer::DolphinViewContainer(const KUrl& url, QWidget* parent) :
m_statusBar(0),
m_statusBarTimer(0),
m_statusBarTimestamp(),
- m_autoGrabFocus(true),
- m_dropDestination(),
- m_dropEvent(0)
+ m_autoGrabFocus(true)
#ifdef KActivities_FOUND
, m_activityResourceInstance(0)
#endif
@@ -82,92 +69,117 @@ DolphinViewContainer::DolphinViewContainer(const KUrl& url, QWidget* parent) :
m_topLayout->setMargin(0);
m_urlNavigator = new KUrlNavigator(new KFilePlacesModel(this), url, this);
- connect(m_urlNavigator, SIGNAL(urlsDropped(KUrl,QDropEvent*)),
- this, SLOT(dropUrls(KUrl,QDropEvent*)));
- connect(m_urlNavigator, SIGNAL(activated()),
- this, SLOT(activate()));
- connect(m_urlNavigator->editor(), SIGNAL(completionModeChanged(KGlobalSettings::Completion)),
- this, SLOT(saveUrlCompletionMode(KGlobalSettings::Completion)));
+ connect(m_urlNavigator, &KUrlNavigator::activated,
+ this, &DolphinViewContainer::activate);
+ connect(m_urlNavigator->editor(), &KUrlComboBox::completionModeChanged,
+ this, &DolphinViewContainer::saveUrlCompletionMode);
const GeneralSettings* settings = GeneralSettings::self();
m_urlNavigator->setUrlEditable(settings->editableUrl());
m_urlNavigator->setShowFullPath(settings->showFullPath());
- m_urlNavigator->setHomeUrl(KUrl(settings->homeUrl()));
+ m_urlNavigator->setHomeUrl(QUrl::fromLocalFile(settings->homeUrl()));
KUrlComboBox* editor = m_urlNavigator->editor();
- editor->setCompletionMode(KGlobalSettings::Completion(settings->urlCompletionMode()));
+ editor->setCompletionMode(KCompletion::CompletionMode(settings->urlCompletionMode()));
m_searchBox = new DolphinSearchBox(this);
m_searchBox->hide();
- connect(m_searchBox, SIGNAL(activated()), this, SLOT(activate()));
- connect(m_searchBox, SIGNAL(closeRequest()), this, SLOT(closeSearchBox()));
- connect(m_searchBox, SIGNAL(searchRequest()), this, SLOT(startSearching()));
- connect(m_searchBox, SIGNAL(returnPressed(QString)), this, SLOT(requestFocus()));
+ connect(m_searchBox, &DolphinSearchBox::activated, this, &DolphinViewContainer::activate);
+ connect(m_searchBox, &DolphinSearchBox::closeRequest, this, &DolphinViewContainer::closeSearchBox);
+ connect(m_searchBox, &DolphinSearchBox::searchRequest, this, &DolphinViewContainer::startSearching);
+ connect(m_searchBox, &DolphinSearchBox::returnPressed, this, &DolphinViewContainer::requestFocus);
m_messageWidget = new KMessageWidget(this);
m_messageWidget->setCloseButtonVisible(true);
m_messageWidget->hide();
m_view = new DolphinView(url, this);
- connect(m_view, SIGNAL(urlChanged(KUrl)), m_urlNavigator, SLOT(setUrl(KUrl)));
- connect(m_view, SIGNAL(urlChanged(KUrl)), m_messageWidget, SLOT(hide()));
- connect(m_view, SIGNAL(directoryLoadingCompleted()), m_messageWidget, SLOT(hide()));
- connect(m_view, SIGNAL(writeStateChanged(bool)), this, SIGNAL(writeStateChanged(bool)));
- connect(m_view, SIGNAL(requestItemInfo(KFileItem)), this, SLOT(showItemInfo(KFileItem)));
- connect(m_view, SIGNAL(itemActivated(KFileItem)), this, SLOT(slotItemActivated(KFileItem)));
- connect(m_view, SIGNAL(itemsActivated(KFileItemList)), this, SLOT(slotItemsActivated(KFileItemList)));
- connect(m_view, SIGNAL(redirection(KUrl,KUrl)), this, SLOT(redirect(KUrl,KUrl)));
- connect(m_view, SIGNAL(directoryLoadingStarted()), this, SLOT(slotDirectoryLoadingStarted()));
- connect(m_view, SIGNAL(directoryLoadingCompleted()), this, SLOT(slotDirectoryLoadingCompleted()));
- connect(m_view, SIGNAL(directoryLoadingCanceled()), this, SLOT(slotDirectoryLoadingCanceled()));
- connect(m_view, SIGNAL(itemCountChanged()), this, SLOT(delayedStatusBarUpdate()));
- connect(m_view, SIGNAL(directoryLoadingProgress(int)), this, SLOT(updateDirectoryLoadingProgress(int)));
- connect(m_view, SIGNAL(directorySortingProgress(int)), this, SLOT(updateDirectorySortingProgress(int)));
- connect(m_view, SIGNAL(selectionChanged(KFileItemList)), this, SLOT(delayedStatusBarUpdate()));
- connect(m_view, SIGNAL(urlAboutToBeChanged(KUrl)), this, SLOT(slotViewUrlAboutToBeChanged(KUrl)));
- connect(m_view, SIGNAL(errorMessage(QString)), this, SLOT(showErrorMessage(QString)));
- connect(m_view, SIGNAL(urlIsFileError(KUrl)), this, SLOT(slotUrlIsFileError(KUrl)));
- connect(m_view, SIGNAL(activated()), this, SLOT(activate()));
+ connect(m_view, &DolphinView::urlChanged,
+ m_urlNavigator, &KUrlNavigator::setUrl);
+ connect(m_view, &DolphinView::urlChanged,
+ m_messageWidget, &KMessageWidget::hide);
+ connect(m_view, &DolphinView::directoryLoadingCompleted,
+ m_messageWidget, &KMessageWidget::hide);
+ connect(m_view, &DolphinView::writeStateChanged,
+ this, &DolphinViewContainer::writeStateChanged);
+ connect(m_view, &DolphinView::requestItemInfo,
+ this, &DolphinViewContainer::showItemInfo);
+ connect(m_view, &DolphinView::itemActivated,
+ this, &DolphinViewContainer::slotItemActivated);
+ connect(m_view, &DolphinView::itemsActivated,
+ this, &DolphinViewContainer::slotItemsActivated);
+ connect(m_view, &DolphinView::redirection,
+ this, &DolphinViewContainer::redirect);
+ connect(m_view, &DolphinView::directoryLoadingStarted,
+ this, &DolphinViewContainer::slotDirectoryLoadingStarted);
+ connect(m_view, &DolphinView::directoryLoadingCompleted,
+ this, &DolphinViewContainer::slotDirectoryLoadingCompleted);
+ connect(m_view, &DolphinView::directoryLoadingCanceled,
+ this, &DolphinViewContainer::slotDirectoryLoadingCanceled);
+ connect(m_view, &DolphinView::itemCountChanged,
+ this, &DolphinViewContainer::delayedStatusBarUpdate);
+ connect(m_view, &DolphinView::directoryLoadingProgress,
+ this, &DolphinViewContainer::updateDirectoryLoadingProgress);
+ connect(m_view, &DolphinView::directorySortingProgress,
+ this, &DolphinViewContainer::updateDirectorySortingProgress);
+ connect(m_view, &DolphinView::selectionChanged,
+ this, &DolphinViewContainer::delayedStatusBarUpdate);
+ connect(m_view, &DolphinView::urlAboutToBeChanged,
+ this, &DolphinViewContainer::slotViewUrlAboutToBeChanged);
+ connect(m_view, &DolphinView::errorMessage,
+ this, &DolphinViewContainer::showErrorMessage);
+ connect(m_view, &DolphinView::urlIsFileError,
+ this, &DolphinViewContainer::slotUrlIsFileError);
+ connect(m_view, &DolphinView::activated,
+ this, &DolphinViewContainer::activate);
- connect(m_urlNavigator, SIGNAL(urlAboutToBeChanged(KUrl)),
- this, SLOT(slotUrlNavigatorLocationAboutToBeChanged(KUrl)));
- connect(m_urlNavigator, SIGNAL(urlChanged(KUrl)),
- this, SLOT(slotUrlNavigatorLocationChanged(KUrl)));
- connect(m_urlNavigator, SIGNAL(historyChanged()),
- this, SLOT(slotHistoryChanged()));
- connect(m_urlNavigator, SIGNAL(returnPressed()),
- this, SLOT(slotReturnPressed()));
+ connect(m_urlNavigator, &KUrlNavigator::urlAboutToBeChanged,
+ this, &DolphinViewContainer::slotUrlNavigatorLocationAboutToBeChanged);
+ connect(m_urlNavigator, &KUrlNavigator::urlChanged,
+ this, &DolphinViewContainer::slotUrlNavigatorLocationChanged);
+ connect(m_urlNavigator, &KUrlNavigator::historyChanged,
+ this, &DolphinViewContainer::slotHistoryChanged);
+ connect(m_urlNavigator, &KUrlNavigator::returnPressed,
+ this, &DolphinViewContainer::slotReturnPressed);
+ connect(m_urlNavigator, &KUrlNavigator::urlsDropped,
+ m_view, &DolphinView::dropUrls);
// Initialize status bar
m_statusBar = new DolphinStatusBar(this);
m_statusBar->setUrl(m_view->url());
m_statusBar->setZoomLevel(m_view->zoomLevel());
- connect(m_view, SIGNAL(urlChanged(KUrl)), m_statusBar, SLOT(setUrl(KUrl)));
- connect(m_view, SIGNAL(zoomLevelChanged(int,int)), m_statusBar, SLOT(setZoomLevel(int)));
- connect(m_view, SIGNAL(infoMessage(QString)), m_statusBar, SLOT(setText(QString)));
- connect(m_view, SIGNAL(operationCompletedMessage(QString)), m_statusBar, SLOT(setText(QString)));
- connect(m_statusBar, SIGNAL(stopPressed()), this, SLOT(stopDirectoryLoading()));
- connect(m_statusBar, SIGNAL(zoomLevelChanged(int)), this, SLOT(slotStatusBarZoomLevelChanged(int)));
+ connect(m_view, &DolphinView::urlChanged,
+ m_statusBar, &DolphinStatusBar::setUrl);
+ connect(m_view, &DolphinView::zoomLevelChanged,
+ m_statusBar, &DolphinStatusBar::setZoomLevel);
+ connect(m_view, &DolphinView::infoMessage,
+ m_statusBar, &DolphinStatusBar::setText);
+ connect(m_view, &DolphinView::operationCompletedMessage,
+ m_statusBar, &DolphinStatusBar::setText);
+ connect(m_statusBar, &DolphinStatusBar::stopPressed,
+ this, &DolphinViewContainer::stopDirectoryLoading);
+ connect(m_statusBar, &DolphinStatusBar::zoomLevelChanged,
+ this, &DolphinViewContainer::slotStatusBarZoomLevelChanged);
m_statusBarTimer = new QTimer(this);
m_statusBarTimer->setSingleShot(true);
m_statusBarTimer->setInterval(300);
- connect(m_statusBarTimer, SIGNAL(timeout()), this, SLOT(updateStatusBar()));
+ connect(m_statusBarTimer, &QTimer::timeout, this, &DolphinViewContainer::updateStatusBar);
KIO::FileUndoManager* undoManager = KIO::FileUndoManager::self();
- connect(undoManager, SIGNAL(jobRecordingFinished(CommandType)),
- this, SLOT(delayedStatusBarUpdate()));
+ connect(undoManager, &KIO::FileUndoManager::jobRecordingFinished,
+ this, &DolphinViewContainer::delayedStatusBarUpdate);
// Initialize filter bar
m_filterBar = new FilterBar(this);
m_filterBar->setVisible(settings->filterBar());
- connect(m_filterBar, SIGNAL(filterChanged(QString)),
- this, SLOT(setNameFilter(QString)));
- connect(m_filterBar, SIGNAL(closeRequest()),
- this, SLOT(closeFilterBar()));
- connect(m_filterBar, SIGNAL(focusViewRequest()),
- this, SLOT(requestFocus()));
- connect(m_view, SIGNAL(urlChanged(KUrl)),
- m_filterBar, SLOT(slotUrlChanged()));
+ connect(m_filterBar, &FilterBar::filterChanged,
+ this, &DolphinViewContainer::setNameFilter);
+ connect(m_filterBar, &FilterBar::closeRequest,
+ this, &DolphinViewContainer::closeFilterBar);
+ connect(m_filterBar, &FilterBar::focusViewRequest,
+ this, &DolphinViewContainer::requestFocus);
+ connect(m_view, &DolphinView::urlChanged,
+ m_filterBar, &FilterBar::slotUrlChanged);
m_topLayout->addWidget(m_urlNavigator);
m_topLayout->addWidget(m_searchBox);
@@ -191,7 +203,7 @@ DolphinViewContainer::~DolphinViewContainer()
{
}
-KUrl DolphinViewContainer::url() const
+QUrl DolphinViewContainer::url() const
{
return m_view->url();
}
@@ -292,7 +304,7 @@ void DolphinViewContainer::readSettings()
// settings of the URL navigator and the filterbar.
m_urlNavigator->setUrlEditable(GeneralSettings::editableUrl());
m_urlNavigator->setShowFullPath(GeneralSettings::showFullPath());
- m_urlNavigator->setHomeUrl(KUrl(GeneralSettings::homeUrl()));
+ m_urlNavigator->setHomeUrl(QUrl::fromLocalFile(GeneralSettings::homeUrl()));
setFilterBarVisible(GeneralSettings::filterBar());
}
@@ -319,16 +331,16 @@ void DolphinViewContainer::setSearchModeEnabled(bool enabled)
m_urlNavigator->setVisible(!enabled);
if (enabled) {
- const KUrl& locationUrl = m_urlNavigator->locationUrl();
+ const QUrl& locationUrl = m_urlNavigator->locationUrl();
m_searchBox->fromSearchUrl(locationUrl);
} else {
m_view->setViewPropertiesContext(QString());
// Restore the URL for the URL navigator. If Dolphin has been
// started with a search-URL, the home URL is used as fallback.
- KUrl url = m_searchBox->searchPath();
+ QUrl url = m_searchBox->searchPath();
if (url.isEmpty() || !url.isValid() || isSearchUrl(url)) {
- url = GeneralSettings::self()->homeUrl();
+ url = QUrl::fromLocalFile(GeneralSettings::self()->homeUrl());
}
m_urlNavigator->setLocationUrl(url);
}
@@ -355,7 +367,7 @@ QString DolphinViewContainer::placesText() const
return text;
}
-void DolphinViewContainer::setUrl(const KUrl& newUrl)
+void DolphinViewContainer::setUrl(const QUrl& newUrl)
{
if (newUrl != m_urlNavigator->locationUrl()) {
m_urlNavigator->setLocationUrl(newUrl);
@@ -460,14 +472,14 @@ void DolphinViewContainer::slotDirectoryLoadingCanceled()
m_statusBar->setText(QString());
}
-void DolphinViewContainer::slotUrlIsFileError(const KUrl& url)
+void DolphinViewContainer::slotUrlIsFileError(const QUrl& url)
{
- const KFileItem item(KFileItem::Unknown, KFileItem::Unknown, url);
+ const KFileItem item(url);
// Find out if the file can be opened in the view (for example, this is the
// case if the file is an archive). The mime type must be known for that.
item.determineMimeType();
- const KUrl& folderUrl = DolphinView::openItemAsFolderUrl(item, true);
+ const QUrl& folderUrl = DolphinView::openItemAsFolderUrl(item, true);
if (!folderUrl.isEmpty()) {
m_view->setUrl(folderUrl);
} else {
@@ -482,13 +494,14 @@ void DolphinViewContainer::slotItemActivated(const KFileItem& item)
// results in an active view.
m_view->setActive(true);
- const KUrl& url = DolphinView::openItemAsFolderUrl(item, GeneralSettings::browseThroughArchives());
+ const QUrl& url = DolphinView::openItemAsFolderUrl(item, GeneralSettings::browseThroughArchives());
if (!url.isEmpty()) {
m_view->setUrl(url);
return;
}
- item.run();
+ KRun *run = new KRun(item.targetUrl(), this);
+ run->setShowScriptExecutionPrompt(true);
}
void DolphinViewContainer::slotItemsActivated(const KFileItemList& items)
@@ -526,7 +539,7 @@ void DolphinViewContainer::activate()
setActive(true);
}
-void DolphinViewContainer::slotViewUrlAboutToBeChanged(const KUrl& url)
+void DolphinViewContainer::slotViewUrlAboutToBeChanged(const QUrl& url)
{
// URL changes of the view can happen in two ways:
// 1. The URL navigator gets changed and will trigger the view to update its URL
@@ -538,7 +551,7 @@ void DolphinViewContainer::slotViewUrlAboutToBeChanged(const KUrl& url)
}
}
-void DolphinViewContainer::slotUrlNavigatorLocationAboutToBeChanged(const KUrl& url)
+void DolphinViewContainer::slotUrlNavigatorLocationAboutToBeChanged(const QUrl& url)
{
// URL changes of the view can happen in two ways:
// 1. The URL navigator gets changed and will trigger the view to update its URL
@@ -550,7 +563,7 @@ void DolphinViewContainer::slotUrlNavigatorLocationAboutToBeChanged(const KUrl&
}
}
-void DolphinViewContainer::slotUrlNavigatorLocationChanged(const KUrl& url)
+void DolphinViewContainer::slotUrlNavigatorLocationChanged(const QUrl& url)
{
slotReturnPressed();
@@ -566,7 +579,7 @@ void DolphinViewContainer::slotUrlNavigatorLocationChanged(const KUrl& url)
}
} else if (KProtocolManager::isSourceProtocol(url)) {
QString app = "konqueror";
- if (url.protocol().startsWith(QLatin1String("http"))) {
+ if (url.scheme().startsWith(QLatin1String("http"))) {
showMessage(i18nc("@info:status", // krazy:exclude=qmethods
"Dolphin does not support web pages, the web browser has been launched"),
Information);
@@ -586,7 +599,7 @@ void DolphinViewContainer::slotUrlNavigatorLocationChanged(const KUrl& url)
Information);
}
- const QString secureUrl = KShell::quoteArg(url.pathOrUrl());
+ const QString secureUrl = KShell::quoteArg(url.toDisplayString(QUrl::PreferLocalFile));
const QString command = app + ' ' + secureUrl;
KRun::runCommand(command, app, app, this);
} else {
@@ -594,42 +607,7 @@ void DolphinViewContainer::slotUrlNavigatorLocationChanged(const KUrl& url)
}
}
-void DolphinViewContainer::dropUrls(const KUrl& destination, QDropEvent* event)
-{
- m_dropDestination = destination;
-
- const QMimeData* mimeData = event->mimeData();
- QMimeData* mimeDataCopy = new QMimeData;
- foreach (const QString& format, mimeData->formats()) {
- mimeDataCopy->setData(format, mimeData->data(format));
- }
-
- m_dropEvent.reset(new QDropEvent(event->pos(),
- event->possibleActions(),
- mimeDataCopy,
- event->mouseButtons(),
- event->keyboardModifiers()));
-
- QTimer::singleShot(0, this, SLOT(dropUrlsDelayed()));
-}
-
-void DolphinViewContainer::dropUrlsDelayed()
-{
- if (m_dropEvent.isNull()) {
- return;
- }
-
- QString error;
- DragAndDropHelper::dropUrls(KFileItem(), m_dropDestination, m_dropEvent.data(), error);
- if (!error.isEmpty()) {
- showMessage(error, Error);
- }
-
- delete m_dropEvent->mimeData();
- m_dropEvent.reset();
-}
-
-void DolphinViewContainer::redirect(const KUrl& oldUrl, const KUrl& newUrl)
+void DolphinViewContainer::redirect(const QUrl& oldUrl, const QUrl& newUrl)
{
Q_UNUSED(oldUrl);
const bool block = m_urlNavigator->signalsBlocked();
@@ -650,7 +628,7 @@ void DolphinViewContainer::requestFocus()
m_view->setFocus();
}
-void DolphinViewContainer::saveUrlCompletionMode(KGlobalSettings::Completion completion)
+void DolphinViewContainer::saveUrlCompletionMode(KCompletion::CompletionMode completion)
{
GeneralSettings::setUrlCompletionMode(completion);
}
@@ -673,7 +651,7 @@ void DolphinViewContainer::slotReturnPressed()
void DolphinViewContainer::startSearching()
{
- const KUrl url = m_searchBox->urlForSearching();
+ const QUrl url = m_searchBox->urlForSearching();
if (url.isValid() && !url.isEmpty()) {
m_view->setViewPropertiesContext("search");
m_urlNavigator->setLocationUrl(url);
@@ -701,10 +679,9 @@ void DolphinViewContainer::showErrorMessage(const QString& msg)
showMessage(msg, Error);
}
-bool DolphinViewContainer::isSearchUrl(const KUrl& url) const
+bool DolphinViewContainer::isSearchUrl(const QUrl& url) const
{
- const QString protocol = url.protocol();
- return protocol.contains("search");
+ return url.scheme().contains("search");
}
void DolphinViewContainer::saveViewState()
@@ -714,5 +691,3 @@ void DolphinViewContainer::saveViewState()
m_view->saveState(stream);
m_urlNavigator->saveLocationState(locationState);
}
-
-#include "dolphinviewcontainer.moc"
diff --git a/src/dolphinviewcontainer.h b/src/dolphinviewcontainer.h
index 31612f10a..62f91100e 100644
--- a/src/dolphinviewcontainer.h
+++ b/src/dolphinviewcontainer.h
@@ -21,8 +21,7 @@
#define DOLPHINVIEWCONTAINER_H
#include <KFileItem>
-#include <KFileItemDelegate>
-#include <KGlobalSettings>
+#include <KCompletion>
#include <KIO/Job>
#include <KUrlNavigator>
@@ -31,9 +30,9 @@
#include <QWidget>
#include <views/dolphinview.h>
-#include <config-apps.h>
+#include <config-dolphin.h>
-#ifdef KActivities_FOUND
+#ifdef KF5Activities_FOUND
namespace KActivities {
class ResourceInstance;
}
@@ -41,7 +40,7 @@ namespace KActivities {
class FilterBar;
class KMessageWidget;
-class KUrl;
+class QUrl;
class KUrlNavigator;
class DolphinSearchBox;
class DolphinStatusBar;
@@ -70,14 +69,14 @@ public:
Error
};
- DolphinViewContainer(const KUrl& url, QWidget* parent);
+ DolphinViewContainer(const QUrl& url, QWidget* parent);
virtual ~DolphinViewContainer();
/**
* Returns the current active URL, where all actions are applied.
* The URL navigator is synchronized with this URL.
*/
- KUrl url() const;
+ QUrl url() const;
/**
* If \a active is true, the view container will marked as active. The active
@@ -138,7 +137,7 @@ public slots:
* are emitted.
* @see DolphinViewContainer::urlNavigator()
*/
- void setUrl(const KUrl& url);
+ void setUrl(const QUrl& url);
/**
* Popups the filter bar above the status bar if \a visible is true.
@@ -205,7 +204,7 @@ private slots:
* Is called if the URL set by DolphinView::setUrl() represents
* a file and not a directory. Takes care to activate the file.
*/
- void slotUrlIsFileError(const KUrl& url);
+ void slotUrlIsFileError(const QUrl& url);
/**
* Handles clicking on an item. If the item is a directory, the
@@ -244,44 +243,26 @@ private slots:
* Is invoked if the signal urlAboutToBeChanged() from the DolphinView
* is emitted. Tries to save the view-state.
*/
- void slotViewUrlAboutToBeChanged(const KUrl& url);
+ void slotViewUrlAboutToBeChanged(const QUrl& url);
/**
* Is invoked if the signal urlAboutToBeChanged() from the URL navigator
* is emitted. Tries to save the view-state.
*/
- void slotUrlNavigatorLocationAboutToBeChanged(const KUrl& url);
+ void slotUrlNavigatorLocationAboutToBeChanged(const QUrl& url);
/**
* Restores the current view to show \a url and assures
* that the root URL of the view is respected.
*/
- void slotUrlNavigatorLocationChanged(const KUrl& url);
-
- /**
- * Is connected with the URL navigator and drops the URLs
- * above the destination \a destination.
- *
- * Creates a copy of \a event and invokes \a dropUrlsDelayed with a
- * queued connection.
- */
- void dropUrls(const KUrl& destination, QDropEvent* event);
-
- /**
- * Is invoked with a queued connection by \a dropUrls to prevent that the
- * drop actions are executed in the URL navigator menu's nested event loop,
- * which might cause a crash. Simply using a queued connection from the URL
- * navigator to \a dropUrls would not work because the \a event pointer
- * would be dangling then.
- */
- void dropUrlsDelayed();
+ void slotUrlNavigatorLocationChanged(const QUrl& url);
/**
* Is invoked when a redirection is done and changes the
* URL of the URL navigator to \a newUrl without triggering
* a reloading of the directory.
*/
- void redirect(const KUrl& oldUrl, const KUrl& newUrl);
+ void redirect(const QUrl& oldUrl, const QUrl& newUrl);
/** Requests the focus for the view \a m_view. */
void requestFocus();
@@ -290,7 +271,7 @@ private slots:
* Saves the currently used URL completion mode of
* the URL navigator.
*/
- void saveUrlCompletionMode(KGlobalSettings::Completion completion);
+ void saveUrlCompletionMode(KCompletion::CompletionMode completion);
void slotHistoryChanged();
@@ -319,7 +300,7 @@ private:
/**
* @return True if the URL protocol is a search URL (e. g. baloosearch:// or filenamesearch://).
*/
- bool isSearchUrl(const KUrl& url) const;
+ bool isSearchUrl(const QUrl& url) const;
/**
* Saves the state of the current view: contents position,
@@ -342,10 +323,7 @@ private:
QElapsedTimer m_statusBarTimestamp; // Time in ms since last update
bool m_autoGrabFocus;
- KUrl m_dropDestination;
- QScopedPointer<QDropEvent> m_dropEvent;
-
-#ifdef KActivities_FOUND
+#ifdef KF5Activities_FOUND
private:
KActivities::ResourceInstance * m_activityResourceInstance;
#endif
diff --git a/src/filterbar/filterbar.cpp b/src/filterbar/filterbar.cpp
index 6de6fbe5c..82d5f549e 100644
--- a/src/filterbar/filterbar.cpp
+++ b/src/filterbar/filterbar.cpp
@@ -20,15 +20,14 @@
***************************************************************************/
#include "filterbar.h"
-#include <QBoxLayout>
#include <QKeyEvent>
#include <QLabel>
#include <QToolButton>
+#include <QHBoxLayout>
-#include <KIcon>
-#include <KLocale>
-#include <KLineEdit>
-#include <KIconLoader>
+#include <QIcon>
+#include <KLocalizedString>
+#include <QLineEdit>
FilterBar::FilterBar(QWidget* parent) :
QWidget(parent)
@@ -36,27 +35,27 @@ FilterBar::FilterBar(QWidget* parent) :
// Create close button
QToolButton *closeButton = new QToolButton(this);
closeButton->setAutoRaise(true);
- closeButton->setIcon(KIcon("dialog-close"));
+ closeButton->setIcon(QIcon::fromTheme("dialog-close"));
closeButton->setToolTip(i18nc("@info:tooltip", "Hide Filter Bar"));
- connect(closeButton, SIGNAL(clicked()), this, SIGNAL(closeRequest()));
+ connect(closeButton, &QToolButton::clicked, this, &FilterBar::closeRequest);
// Create button to lock text when changing folders
m_lockButton = new QToolButton(this);
m_lockButton->setAutoRaise(true);
m_lockButton->setCheckable(true);
- m_lockButton->setIcon(KIcon("object-unlocked"));
+ m_lockButton->setIcon(QIcon::fromTheme("object-unlocked"));
m_lockButton->setToolTip(i18nc("@info:tooltip", "Keep Filter When Changing Folders"));
- connect(m_lockButton, SIGNAL(toggled(bool)), this, SLOT(slotToggleLockButton(bool)));
+ connect(m_lockButton, &QToolButton::toggled, this, &FilterBar::slotToggleLockButton);
// Create label
QLabel* filterLabel = new QLabel(i18nc("@label:textbox", "Filter:"), this);
// Create filter editor
- m_filterInput = new KLineEdit(this);
+ m_filterInput = new QLineEdit(this);
m_filterInput->setLayoutDirection(Qt::LeftToRight);
- m_filterInput->setClearButtonShown(true);
- connect(m_filterInput, SIGNAL(textChanged(QString)),
- this, SIGNAL(filterChanged(QString)));
+ m_filterInput->setClearButtonEnabled(true);
+ connect(m_filterInput, &QLineEdit::textChanged,
+ this, &FilterBar::filterChanged);
setFocusProxy(m_filterInput);
// Apply layout
@@ -103,9 +102,9 @@ void FilterBar::slotUrlChanged()
void FilterBar::slotToggleLockButton(bool checked)
{
if (checked) {
- m_lockButton->setIcon(KIcon("object-locked"));
+ m_lockButton->setIcon(QIcon::fromTheme("object-locked"));
} else {
- m_lockButton->setIcon(KIcon("object-unlocked"));
+ m_lockButton->setIcon(QIcon::fromTheme("object-unlocked"));
clear();
}
}
@@ -140,4 +139,3 @@ void FilterBar::keyReleaseEvent(QKeyEvent* event)
}
}
-#include "filterbar.moc"
diff --git a/src/filterbar/filterbar.h b/src/filterbar/filterbar.h
index 5d5463a28..a275d1ea4 100644
--- a/src/filterbar/filterbar.h
+++ b/src/filterbar/filterbar.h
@@ -24,7 +24,7 @@
#include <QWidget>
-class KLineEdit;
+class QLineEdit;
class QToolButton;
/**
@@ -74,11 +74,11 @@ signals:
void focusViewRequest();
protected:
- virtual void showEvent(QShowEvent* event);
- virtual void keyReleaseEvent(QKeyEvent* event);
+ virtual void showEvent(QShowEvent* event) Q_DECL_OVERRIDE;
+ virtual void keyReleaseEvent(QKeyEvent* event) Q_DECL_OVERRIDE;
private:
- KLineEdit* m_filterInput;
+ QLineEdit* m_filterInput;
QToolButton* m_lockButton;
};
diff --git a/src/kitemviews/kfileitemlistview.cpp b/src/kitemviews/kfileitemlistview.cpp
index fd01f2c4c..d249bef91 100644
--- a/src/kitemviews/kfileitemlistview.cpp
+++ b/src/kitemviews/kfileitemlistview.cpp
@@ -22,16 +22,12 @@
#include "kfileitemmodelrolesupdater.h"
#include "kfileitemlistwidget.h"
#include "kfileitemmodel.h"
-#include <KLocale>
-#include <KStringHandler>
#include "private/kpixmapmodifier.h"
-#include <KDebug>
-#include <KIcon>
-#include <KTextEdit>
+#include <QIcon>
+#include <KIconLoader>
#include <QPainter>
-#include <QTextLine>
#include <QTimer>
// #define KFILEITEMLISTVIEW_DEBUG
@@ -62,14 +58,14 @@ KFileItemListView::KFileItemListView(QGraphicsWidget* parent) :
m_updateVisibleIndexRangeTimer = new QTimer(this);
m_updateVisibleIndexRangeTimer->setSingleShot(true);
m_updateVisibleIndexRangeTimer->setInterval(ShortInterval);
- connect(m_updateVisibleIndexRangeTimer, SIGNAL(timeout()), this, SLOT(updateVisibleIndexRange()));
+ connect(m_updateVisibleIndexRangeTimer, &QTimer::timeout, this, &KFileItemListView::updateVisibleIndexRange);
m_updateIconSizeTimer = new QTimer(this);
m_updateIconSizeTimer->setSingleShot(true);
m_updateIconSizeTimer->setInterval(LongInterval);
- connect(m_updateIconSizeTimer, SIGNAL(timeout()), this, SLOT(updateIconSize()));
+ connect(m_updateIconSizeTimer, &QTimer::timeout, this, &KFileItemListView::updateIconSize);
- setVisibleRoles(QList<QByteArray>() << "text");
+ setVisibleRoles({"text"});
}
KFileItemListView::~KFileItemListView()
@@ -169,7 +165,7 @@ QPixmap KFileItemListView::createDragPixmap(const KItemSet& indexes) const
foreach (int index, indexes) {
QPixmap pixmap = model()->data(index).value("iconPixmap").value<QPixmap>();
if (pixmap.isNull()) {
- KIcon icon(model()->data(index).value("iconName").toString());
+ QIcon icon = QIcon::fromTheme(model()->data(index).value("iconName").toString());
pixmap = icon.pixmap(size, size);
} else {
KPixmapModifier::scale(pixmap, QSize(size, size));
@@ -208,7 +204,7 @@ void KFileItemListView::initializeItemListWidget(KItemListWidget* item)
const KFileItem fileItem = fileItemModel->fileItem(item->index());
data.insert("iconName", fileItem.iconName());
- item->setData(data, QSet<QByteArray>() << "iconName");
+ item->setData(data, {"iconName"});
}
}
@@ -421,4 +417,3 @@ QSize KFileItemListView::availableIconSize() const
return QSize(iconSize, iconSize);
}
-#include "kfileitemlistview.moc"
diff --git a/src/kitemviews/kfileitemlistview.h b/src/kitemviews/kfileitemlistview.h
index 2fd21edbf..84aa17d89 100644
--- a/src/kitemviews/kfileitemlistview.h
+++ b/src/kitemviews/kfileitemlistview.h
@@ -20,7 +20,7 @@
#ifndef KFILEITEMLISTVIEW_H
#define KFILEITEMLISTVIEW_H
-#include <libdolphin_export.h>
+#include "dolphin_export.h"
#include <kitemviews/kstandarditemlistview.h>
@@ -36,7 +36,7 @@ class QTimer;
* KItemListView::setWidgetCreator() and KItemListView::setGroupHeaderCreator()
* to apply customized generators.
*/
-class LIBDOLPHINPRIVATE_EXPORT KFileItemListView : public KStandardItemListView
+class DOLPHIN_EXPORT KFileItemListView : public KStandardItemListView
{
Q_OBJECT
@@ -72,28 +72,27 @@ public:
*/
QStringList enabledPlugins() const;
- /** @reimp */
- virtual QPixmap createDragPixmap(const KItemSet& indexes) const;
+ virtual QPixmap createDragPixmap(const KItemSet& indexes) const Q_DECL_OVERRIDE;
protected:
- virtual KItemListWidgetCreatorBase* defaultWidgetCreator() const;
- virtual void initializeItemListWidget(KItemListWidget* item);
+ virtual KItemListWidgetCreatorBase* defaultWidgetCreator() const Q_DECL_OVERRIDE;
+ virtual void initializeItemListWidget(KItemListWidget* item) Q_DECL_OVERRIDE;
virtual void onPreviewsShownChanged(bool shown);
- virtual void onItemLayoutChanged(ItemLayout current, ItemLayout previous);
- virtual void onModelChanged(KItemModelBase* current, KItemModelBase* previous);
- virtual void onScrollOrientationChanged(Qt::Orientation current, Qt::Orientation previous);
- virtual void onItemSizeChanged(const QSizeF& current, const QSizeF& previous);
- virtual void onScrollOffsetChanged(qreal current, qreal previous);
- virtual void onVisibleRolesChanged(const QList<QByteArray>& current, const QList<QByteArray>& previous);
- virtual void onStyleOptionChanged(const KItemListStyleOption& current, const KItemListStyleOption& previous);
- virtual void onSupportsItemExpandingChanged(bool supportsExpanding);
- virtual void onTransactionBegin();
- virtual void onTransactionEnd();
- virtual void resizeEvent(QGraphicsSceneResizeEvent* event);
+ virtual void onItemLayoutChanged(ItemLayout current, ItemLayout previous) Q_DECL_OVERRIDE;
+ virtual void onModelChanged(KItemModelBase* current, KItemModelBase* previous) Q_DECL_OVERRIDE;
+ virtual void onScrollOrientationChanged(Qt::Orientation current, Qt::Orientation previous) Q_DECL_OVERRIDE;
+ virtual void onItemSizeChanged(const QSizeF& current, const QSizeF& previous) Q_DECL_OVERRIDE;
+ virtual void onScrollOffsetChanged(qreal current, qreal previous) Q_DECL_OVERRIDE;
+ virtual void onVisibleRolesChanged(const QList<QByteArray>& current, const QList<QByteArray>& previous) Q_DECL_OVERRIDE;
+ virtual void onStyleOptionChanged(const KItemListStyleOption& current, const KItemListStyleOption& previous) Q_DECL_OVERRIDE;
+ virtual void onSupportsItemExpandingChanged(bool supportsExpanding) Q_DECL_OVERRIDE;
+ virtual void onTransactionBegin() Q_DECL_OVERRIDE;
+ virtual void onTransactionEnd() Q_DECL_OVERRIDE;
+ virtual void resizeEvent(QGraphicsSceneResizeEvent* event) Q_DECL_OVERRIDE;
protected slots:
- virtual void slotItemsRemoved(const KItemRangeList& itemRanges);
- virtual void slotSortRoleChanged(const QByteArray& current, const QByteArray& previous);
+ virtual void slotItemsRemoved(const KItemRangeList& itemRanges) Q_DECL_OVERRIDE;
+ virtual void slotSortRoleChanged(const QByteArray& current, const QByteArray& previous) Q_DECL_OVERRIDE;
private slots:
void triggerVisibleIndexRangeUpdate();
diff --git a/src/kitemviews/kfileitemlistwidget.cpp b/src/kitemviews/kfileitemlistwidget.cpp
index fe8c7e997..7e5b4bb13 100644
--- a/src/kitemviews/kfileitemlistwidget.cpp
+++ b/src/kitemviews/kfileitemlistwidget.cpp
@@ -21,12 +21,12 @@
#include "kfileitemmodel.h"
#include "kitemlistview.h"
-#include <kmimetype.h>
-#include <KDebug>
-#include <KGlobal>
-#include <KLocale>
+#include <KLocalizedString>
#include <KIO/MetaData>
#include <QDateTime>
+#include <KFormat>
+#include <QMimeDatabase>
+#include <QLocale>
KFileItemListWidgetInformant::KFileItemListWidgetInformant() :
KStandardItemListWidgetInformant()
@@ -78,11 +78,11 @@ QString KFileItemListWidgetInformant::roleText(const QByteArray& role,
}
} else {
const KIO::filesize_t size = roleValue.value<KIO::filesize_t>();
- text = KGlobal::locale()->formatByteSize(size);
+ text = KFormat().formatByteSize(size);
}
} else if (role == "date") {
const QDateTime dateTime = roleValue.toDateTime();
- text = KGlobal::locale()->formatDateTime(dateTime);
+ text = QLocale().toString(dateTime, QLocale::ShortFormat);
} else {
text = KStandardItemListWidgetInformant::roleText(role, values);
}
@@ -142,7 +142,8 @@ int KFileItemListWidget::selectionLength(const QString& text) const
return selectionLength;
}
- const QString extension = KMimeType::extractKnownExtension(text);
+ QMimeDatabase db;
+ const QString extension = db.suffixForFileName(text);
if (extension.isEmpty()) {
// For an unknown extension just exclude the extension after
// the last point. This does not work for multiple extensions like
@@ -161,4 +162,3 @@ int KFileItemListWidget::selectionLength(const QString& text) const
return selectionLength;
}
-#include "kfileitemlistwidget.moc"
diff --git a/src/kitemviews/kfileitemlistwidget.h b/src/kitemviews/kfileitemlistwidget.h
index 8e8958b16..07ca59b44 100644
--- a/src/kitemviews/kfileitemlistwidget.h
+++ b/src/kitemviews/kfileitemlistwidget.h
@@ -20,24 +20,24 @@
#ifndef KFILEITEMLISTWIDGET_H
#define KFILEITEMLISTWIDGET_H
-#include <libdolphin_export.h>
+#include "dolphin_export.h"
#include <kitemviews/kstandarditemlistwidget.h>
-class LIBDOLPHINPRIVATE_EXPORT KFileItemListWidgetInformant : public KStandardItemListWidgetInformant
+class DOLPHIN_EXPORT KFileItemListWidgetInformant : public KStandardItemListWidgetInformant
{
public:
KFileItemListWidgetInformant();
virtual ~KFileItemListWidgetInformant();
protected:
- virtual QString itemText(int index, const KItemListView* view) const;
- virtual bool itemIsLink(int index, const KItemListView* view) const;
- virtual QString roleText(const QByteArray& role, const QHash<QByteArray, QVariant>& values) const;
- virtual QFont customizedFontForLinks(const QFont& baseFont) const;
+ virtual QString itemText(int index, const KItemListView* view) const Q_DECL_OVERRIDE;
+ virtual bool itemIsLink(int index, const KItemListView* view) const Q_DECL_OVERRIDE;
+ virtual QString roleText(const QByteArray& role, const QHash<QByteArray, QVariant>& values) const Q_DECL_OVERRIDE;
+ virtual QFont customizedFontForLinks(const QFont& baseFont) const Q_DECL_OVERRIDE;
};
-class LIBDOLPHINPRIVATE_EXPORT KFileItemListWidget : public KStandardItemListWidget
+class DOLPHIN_EXPORT KFileItemListWidget : public KStandardItemListWidget
{
Q_OBJECT
@@ -48,14 +48,14 @@ public:
static KItemListWidgetInformant* createInformant();
protected:
- virtual bool isRoleRightAligned(const QByteArray& role) const;
- virtual bool isHidden() const;
- virtual QFont customizedFont(const QFont& baseFont) const;
+ virtual bool isRoleRightAligned(const QByteArray& role) const Q_DECL_OVERRIDE;
+ virtual bool isHidden() const Q_DECL_OVERRIDE;
+ virtual QFont customizedFont(const QFont& baseFont) const Q_DECL_OVERRIDE;
/**
* @return Selection length without MIME-type extension
*/
- virtual int selectionLength(const QString& text) const;
+ virtual int selectionLength(const QString& text) const Q_DECL_OVERRIDE;
};
#endif
diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp
index 72acf776a..eac3ddf8b 100644
--- a/src/kitemviews/kfileitemmodel.cpp
+++ b/src/kitemviews/kfileitemmodel.cpp
@@ -21,15 +21,14 @@
#include "kfileitemmodel.h"
-#include <KGlobalSettings>
-#include <KLocale>
-#include <KStringHandler>
-#include <KDebug>
+#include "dolphin_generalsettings.h"
+
+#include <KLocalizedString>
+#include "dolphindebug.h"
#include "private/kfileitemmodelsortalgorithm.h"
#include "private/kfileitemmodeldirlister.h"
-#include <QApplication>
#include <QMimeData>
#include <QTimer>
#include <QWidget>
@@ -42,12 +41,11 @@
KFileItemModel::KFileItemModel(QObject* parent) :
KItemModelBase("text", parent),
m_dirLister(0),
- m_naturalSorting(KGlobalSettings::naturalSorting()),
+ m_naturalSorting(GeneralSettings::naturalSorting()),
m_sortDirsFirst(true),
m_sortRole(NameRole),
m_sortingProgressPercent(-1),
m_roles(),
- m_caseSensitivity(Qt::CaseInsensitive),
m_itemData(),
m_items(),
m_filter(),
@@ -60,6 +58,9 @@ KFileItemModel::KFileItemModel(QObject* parent) :
m_expandedDirs(),
m_urlsToExpand()
{
+ m_collator.setCaseSensitivity(Qt::CaseInsensitive);
+ m_collator.setNumericMode(true);
+
m_dirLister = new KFileItemModelDirLister(this);
m_dirLister->setDelayedMimeTypes(true);
@@ -68,17 +69,17 @@ KFileItemModel::KFileItemModel(QObject* parent) :
m_dirLister->setMainWindow(parentWidget->window());
}
- connect(m_dirLister, SIGNAL(started(KUrl)), this, SIGNAL(directoryLoadingStarted()));
- connect(m_dirLister, SIGNAL(canceled()), this, SLOT(slotCanceled()));
- connect(m_dirLister, SIGNAL(completed(KUrl)), this, SLOT(slotCompleted()));
- connect(m_dirLister, SIGNAL(itemsAdded(KUrl,KFileItemList)), this, SLOT(slotItemsAdded(KUrl,KFileItemList)));
- connect(m_dirLister, SIGNAL(itemsDeleted(KFileItemList)), this, SLOT(slotItemsDeleted(KFileItemList)));
- connect(m_dirLister, SIGNAL(refreshItems(QList<QPair<KFileItem,KFileItem> >)), this, SLOT(slotRefreshItems(QList<QPair<KFileItem,KFileItem> >)));
- connect(m_dirLister, SIGNAL(clear()), this, SLOT(slotClear()));
- connect(m_dirLister, SIGNAL(infoMessage(QString)), this, SIGNAL(infoMessage(QString)));
- connect(m_dirLister, SIGNAL(errorMessage(QString)), this, SIGNAL(errorMessage(QString)));
- connect(m_dirLister, SIGNAL(redirection(KUrl,KUrl)), this, SIGNAL(directoryRedirection(KUrl,KUrl)));
- connect(m_dirLister, SIGNAL(urlIsFileError(KUrl)), this, SIGNAL(urlIsFileError(KUrl)));
+ connect(m_dirLister, &KFileItemModelDirLister::started, this, &KFileItemModel::directoryLoadingStarted);
+ connect(m_dirLister, static_cast<void(KFileItemModelDirLister::*)()>(&KFileItemModelDirLister::canceled), this, &KFileItemModel::slotCanceled);
+ connect(m_dirLister, static_cast<void(KFileItemModelDirLister::*)(const QUrl&)>(&KFileItemModelDirLister::completed), this, &KFileItemModel::slotCompleted);
+ connect(m_dirLister, &KFileItemModelDirLister::itemsAdded, this, &KFileItemModel::slotItemsAdded);
+ connect(m_dirLister, &KFileItemModelDirLister::itemsDeleted, this, &KFileItemModel::slotItemsDeleted);
+ connect(m_dirLister, &KFileItemModelDirLister::refreshItems, this, &KFileItemModel::slotRefreshItems);
+ connect(m_dirLister, static_cast<void(KFileItemModelDirLister::*)()>(&KFileItemModelDirLister::clear), this, &KFileItemModel::slotClear);
+ connect(m_dirLister, &KFileItemModelDirLister::infoMessage, this, &KFileItemModel::infoMessage);
+ connect(m_dirLister, &KFileItemModelDirLister::errorMessage, this, &KFileItemModel::errorMessage);
+ connect(m_dirLister, static_cast<void(KFileItemModelDirLister::*)(const QUrl&, const QUrl&)>(&KFileItemModelDirLister::redirection), this, &KFileItemModel::directoryRedirection);
+ connect(m_dirLister, &KFileItemModelDirLister::urlIsFileError, this, &KFileItemModel::urlIsFileError);
// Apply default roles that should be determined
resetRoles();
@@ -94,7 +95,7 @@ KFileItemModel::KFileItemModel(QObject* parent) :
m_maximumUpdateIntervalTimer = new QTimer(this);
m_maximumUpdateIntervalTimer->setInterval(2000);
m_maximumUpdateIntervalTimer->setSingleShot(true);
- connect(m_maximumUpdateIntervalTimer, SIGNAL(timeout()), this, SLOT(dispatchPendingItemsToInsert()));
+ connect(m_maximumUpdateIntervalTimer, &QTimer::timeout, this, &KFileItemModel::dispatchPendingItemsToInsert);
// When changing the value of an item which represents the sort-role a resorting must be
// triggered. Especially in combination with KFileItemModelRolesUpdater this might be done
@@ -103,9 +104,10 @@ KFileItemModel::KFileItemModel(QObject* parent) :
m_resortAllItemsTimer = new QTimer(this);
m_resortAllItemsTimer->setInterval(500);
m_resortAllItemsTimer->setSingleShot(true);
- connect(m_resortAllItemsTimer, SIGNAL(timeout()), this, SLOT(resortAllItems()));
+ connect(m_resortAllItemsTimer, &QTimer::timeout, this, &KFileItemModel::resortAllItems);
- connect(KGlobalSettings::self(), SIGNAL(naturalSortingChanged()), this, SLOT(slotNaturalSortingChanged()));
+ connect(GeneralSettings::self(), &GeneralSettings::naturalSortingChanged,
+ this, &KFileItemModel::slotNaturalSortingChanged);
}
KFileItemModel::~KFileItemModel()
@@ -115,15 +117,15 @@ KFileItemModel::~KFileItemModel()
qDeleteAll(m_pendingItemsToInsert);
}
-void KFileItemModel::loadDirectory(const KUrl& url)
+void KFileItemModel::loadDirectory(const QUrl &url)
{
m_dirLister->openUrl(url);
}
-void KFileItemModel::refreshDirectory(const KUrl& url)
+void KFileItemModel::refreshDirectory(const QUrl &url)
{
// Refresh all expanded directories first (Bug 295300)
- QHashIterator<KUrl, KUrl> expandedDirs(m_expandedDirs);
+ QHashIterator<QUrl, QUrl> expandedDirs(m_expandedDirs);
while (expandedDirs.hasNext()) {
expandedDirs.next();
m_dirLister->openUrl(expandedDirs.value(), KDirLister::Reload);
@@ -132,7 +134,7 @@ void KFileItemModel::refreshDirectory(const KUrl& url)
m_dirLister->openUrl(url, KDirLister::Reload);
}
-KUrl KFileItemModel::directory() const
+QUrl KFileItemModel::directory() const
{
return m_dirLister->url();
}
@@ -188,8 +190,9 @@ bool KFileItemModel::setData(int index, const QHash<QByteArray, QVariant>& value
m_itemData[index]->values = currentValues;
if (changedRoles.contains("text")) {
- KUrl url = m_itemData[index]->item.url();
- url.setFileName(currentValues["text"].toString());
+ QUrl url = m_itemData[index]->item.url();
+ url = url.adjusted(QUrl::RemoveFilename);
+ url.setPath(url.path() + currentValues["text"].toString());
m_itemData[index]->item.setUrl(url);
}
@@ -242,8 +245,8 @@ QMimeData* KFileItemModel::createMimeData(const KItemSet& indexes) const
// The following code has been taken from KDirModel::mimeData()
// (kdelibs/kio/kio/kdirmodel.cpp)
// Copyright (C) 2006 David Faure <[email protected]>
- KUrl::List urls;
- KUrl::List mostLocalUrls;
+ QList<QUrl> urls;
+ QList<QUrl> mostLocalUrls;
bool canUseMostLocalUrls = true;
const ItemData* lastAddedItem = 0;
@@ -275,9 +278,9 @@ QMimeData* KFileItemModel::createMimeData(const KItemSet& indexes) const
const bool different = canUseMostLocalUrls && mostLocalUrls != urls;
if (different) {
- urls.populateMimeData(mostLocalUrls, data);
+ data->setUrls(mostLocalUrls);
} else {
- urls.populateMimeData(data);
+ data->setUrls(urls);
}
return data;
@@ -336,7 +339,7 @@ QList<QPair<int, QVariant> > KFileItemModel::groups() const
}
#ifdef KFILEITEMMODEL_DEBUG
- kDebug() << "[TIME] Calculating groups for" << count() << "items:" << timer.elapsed();
+ qCDebug(DolphinDebug) << "[TIME] Calculating groups for" << count() << "items:" << timer.elapsed();
#endif
}
@@ -352,7 +355,7 @@ KFileItem KFileItemModel::fileItem(int index) const
return KFileItem();
}
-KFileItem KFileItemModel::fileItem(const KUrl& url) const
+KFileItem KFileItemModel::fileItem(const QUrl &url) const
{
const int indexForUrl = index(url);
if (indexForUrl >= 0) {
@@ -366,10 +369,9 @@ int KFileItemModel::index(const KFileItem& item) const
return index(item.url());
}
-int KFileItemModel::index(const KUrl& url) const
+int KFileItemModel::index(const QUrl& url) const
{
- KUrl urlToFind = url;
- urlToFind.adjustPath(KUrl::RemoveTrailingSlash);
+ const QUrl urlToFind = url.adjusted(QUrl::StripTrailingSlash);
const int itemCount = m_itemData.count();
int itemsInHash = m_items.count();
@@ -387,7 +389,7 @@ int KFileItemModel::index(const KUrl& url) const
const int blockSize = 1000;
const int currentBlockEnd = qMin(itemsInHash + blockSize, itemCount);
for (int i = itemsInHash; i < currentBlockEnd; ++i) {
- const KUrl nextUrl = m_itemData.at(i)->item.url();
+ const QUrl nextUrl = m_itemData.at(i)->item.url();
m_items.insert(nextUrl, i);
}
@@ -406,24 +408,24 @@ int KFileItemModel::index(const KUrl& url) const
if (m_items.count() != m_itemData.count() && printDebugInfo) {
printDebugInfo = false;
- kWarning() << "The model is in an inconsistent state.";
- kWarning() << "m_items.count() ==" << m_items.count();
- kWarning() << "m_itemData.count() ==" << m_itemData.count();
+ qCWarning(DolphinDebug) << "The model is in an inconsistent state.";
+ qCWarning(DolphinDebug) << "m_items.count() ==" << m_items.count();
+ qCWarning(DolphinDebug) << "m_itemData.count() ==" << m_itemData.count();
// Check if there are multiple items with the same URL.
- QMultiHash<KUrl, int> indexesForUrl;
+ QMultiHash<QUrl, int> indexesForUrl;
for (int i = 0; i < m_itemData.count(); ++i) {
indexesForUrl.insert(m_itemData.at(i)->item.url(), i);
}
- foreach (const KUrl& url, indexesForUrl.uniqueKeys()) {
+ foreach (const QUrl& url, indexesForUrl.uniqueKeys()) {
if (indexesForUrl.count(url) > 1) {
- kWarning() << "Multiple items found with the URL" << url;
+ qCWarning(DolphinDebug) << "Multiple items found with the URL" << url;
foreach (int index, indexesForUrl.values(url)) {
const ItemData* data = m_itemData.at(index);
- kWarning() << "index" << index << ":" << data->item;
+ qCWarning(DolphinDebug) << "index" << index << ":" << data->item;
if (data->parent) {
- kWarning() << "parent" << data->parent->item;
+ qCWarning(DolphinDebug) << "parent" << data->parent->item;
}
}
}
@@ -510,15 +512,15 @@ bool KFileItemModel::setExpanded(int index, bool expanded)
}
const KFileItem item = m_itemData.at(index)->item;
- const KUrl url = item.url();
- const KUrl targetUrl = item.targetUrl();
+ const QUrl url = item.url();
+ const QUrl targetUrl = item.targetUrl();
if (expanded) {
m_expandedDirs.insert(targetUrl, url);
m_dirLister->openUrl(url, KDirLister::Keep);
- const KUrl::List previouslyExpandedChildren = m_itemData.at(index)->values.value("previouslyExpandedChildren").value<KUrl::List>();
- foreach (const KUrl& url, previouslyExpandedChildren) {
- m_urlsToExpand.insert(url);
+ const QVariantList previouslyExpandedChildren = m_itemData.at(index)->values.value("previouslyExpandedChildren").value<QVariantList>();
+ foreach (const QVariant& var, previouslyExpandedChildren) {
+ m_urlsToExpand.insert(var.toUrl());
}
} else {
// Note that there might be (indirect) children of the folder which is to be collapsed in
@@ -540,14 +542,14 @@ bool KFileItemModel::setExpanded(int index, bool expanded)
const int itemCount = m_itemData.count();
const int firstChildIndex = index + 1;
- KUrl::List expandedChildren;
+ QVariantList expandedChildren;
int childIndex = firstChildIndex;
while (childIndex < itemCount && expandedParentsCount(childIndex) > parentLevel) {
ItemData* itemData = m_itemData.at(childIndex);
if (itemData->values.value("isExpanded").toBool()) {
- const KUrl targetUrl = itemData->item.targetUrl();
- const KUrl url = itemData->item.url();
+ const QUrl targetUrl = itemData->item.targetUrl();
+ const QUrl url = itemData->item.url();
m_expandedDirs.remove(targetUrl);
m_dirLister->stop(url); // TODO: try to unit-test this, see https://bugs.kde.org/show_bug.cgi?id=332102#c11
expandedChildren.append(targetUrl);
@@ -591,17 +593,17 @@ int KFileItemModel::expandedParentsCount(int index) const
return 0;
}
-QSet<KUrl> KFileItemModel::expandedDirectories() const
+QSet<QUrl> KFileItemModel::expandedDirectories() const
{
return m_expandedDirs.values().toSet();
}
-void KFileItemModel::restoreExpandedDirectories(const QSet<KUrl>& urls)
+void KFileItemModel::restoreExpandedDirectories(const QSet<QUrl> &urls)
{
m_urlsToExpand = urls;
}
-void KFileItemModel::expandParentDirectories(const KUrl& url)
+void KFileItemModel::expandParentDirectories(const QUrl &url)
{
const int pos = m_dirLister->url().path().length();
@@ -609,17 +611,17 @@ void KFileItemModel::expandParentDirectories(const KUrl& url)
// expanded is added to m_urlsToExpand. KDirLister
// does not care whether the parent-URL has already been
// expanded.
- KUrl urlToExpand = m_dirLister->url();
+ QUrl urlToExpand = m_dirLister->url();
const QStringList subDirs = url.path().mid(pos).split(QDir::separator());
for (int i = 0; i < subDirs.count() - 1; ++i) {
- urlToExpand.addPath(subDirs.at(i));
+ urlToExpand.setPath(urlToExpand.path() + '/' + subDirs.at(i));
m_urlsToExpand.insert(urlToExpand);
}
// KDirLister::open() must called at least once to trigger an initial
// loading. The pending URLs that must be restored are handled
// in slotCompleted().
- QSetIterator<KUrl> it2(m_urlsToExpand);
+ QSetIterator<QUrl> it2(m_urlsToExpand);
while (it2.hasNext()) {
const int idx = index(it2.next());
if (idx >= 0 && !isExpanded(idx)) {
@@ -793,14 +795,14 @@ void KFileItemModel::resortAllItems()
#ifdef KFILEITEMMODEL_DEBUG
QElapsedTimer timer;
timer.start();
- kDebug() << "===========================================================";
- kDebug() << "Resorting" << itemCount << "items";
+ qCDebug(DolphinDebug) << "===========================================================";
+ qCDebug(DolphinDebug) << "Resorting" << itemCount << "items";
#endif
// Remember the order of the current URLs so
// that it can be determined which indexes have
// been moved because of the resorting.
- QList<KUrl> oldUrls;
+ QList<QUrl> oldUrls;
oldUrls.reserve(itemCount);
foreach (const ItemData* itemData, m_itemData) {
oldUrls.append(itemData->item.url());
@@ -856,7 +858,7 @@ void KFileItemModel::resortAllItems()
}
#ifdef KFILEITEMMODEL_DEBUG
- kDebug() << "[TIME] Resorting of" << itemCount << "items:" << timer.elapsed();
+ qCDebug(DolphinDebug) << "[TIME] Resorting of" << itemCount << "items:" << timer.elapsed();
#endif
}
@@ -869,7 +871,7 @@ void KFileItemModel::slotCompleted()
// Note that the parent folder must be expanded before any of its subfolders become visible.
// Therefore, some URLs in m_restoredExpandedUrls might not be visible yet
// -> we expand the first visible URL we find in m_restoredExpandedUrls.
- foreach (const KUrl& url, m_urlsToExpand) {
+ foreach (const QUrl& url, m_urlsToExpand) {
const int indexForUrl = index(url);
if (indexForUrl >= 0) {
m_urlsToExpand.remove(url);
@@ -897,16 +899,15 @@ void KFileItemModel::slotCanceled()
emit directoryLoadingCanceled();
}
-void KFileItemModel::slotItemsAdded(const KUrl& directoryUrl, const KFileItemList& items)
+void KFileItemModel::slotItemsAdded(const QUrl &directoryUrl, const KFileItemList& items)
{
Q_ASSERT(!items.isEmpty());
- KUrl parentUrl;
+ QUrl parentUrl;
if (m_expandedDirs.contains(directoryUrl)) {
parentUrl = m_expandedDirs.value(directoryUrl);
} else {
- parentUrl = directoryUrl;
- parentUrl.adjustPath(KUrl::RemoveTrailingSlash);
+ parentUrl = directoryUrl.adjusted(QUrl::StripTrailingSlash);
}
if (m_requestRole[ExpandedParentsCountRole]) {
@@ -1012,7 +1013,7 @@ void KFileItemModel::slotRefreshItems(const QList<QPair<KFileItem, KFileItem> >&
{
Q_ASSERT(!items.isEmpty());
#ifdef KFILEITEMMODEL_DEBUG
- kDebug() << "Refreshing" << items.count() << "items";
+ qCDebug(DolphinDebug) << "Refreshing" << items.count() << "items";
#endif
// Get the indexes of all items that have been refreshed
@@ -1078,7 +1079,7 @@ void KFileItemModel::slotRefreshItems(const QList<QPair<KFileItem, KFileItem> >&
void KFileItemModel::slotClear()
{
#ifdef KFILEITEMMODEL_DEBUG
- kDebug() << "Clearing all items";
+ qCDebug(DolphinDebug) << "Clearing all items";
#endif
qDeleteAll(m_filteredItems.values());
@@ -1104,7 +1105,7 @@ void KFileItemModel::slotClear()
void KFileItemModel::slotNaturalSortingChanged()
{
- m_naturalSorting = KGlobalSettings::naturalSorting();
+ m_naturalSorting = GeneralSettings::naturalSorting();
resortAllItems();
}
@@ -1125,8 +1126,8 @@ void KFileItemModel::insertItems(QList<ItemData*>& newItems)
#ifdef KFILEITEMMODEL_DEBUG
QElapsedTimer timer;
timer.start();
- kDebug() << "===========================================================";
- kDebug() << "Inserting" << newItems.count() << "items";
+ qCDebug(DolphinDebug) << "===========================================================";
+ qCDebug(DolphinDebug) << "Inserting" << newItems.count() << "items";
#endif
m_groups.clear();
@@ -1143,7 +1144,7 @@ void KFileItemModel::insertItems(QList<ItemData*>& newItems)
sort(newItems.begin(), newItems.end());
#ifdef KFILEITEMMODEL_DEBUG
- kDebug() << "[TIME] Sorting:" << timer.elapsed();
+ qCDebug(DolphinDebug) << "[TIME] Sorting:" << timer.elapsed();
#endif
KItemRangeList itemRanges;
@@ -1172,7 +1173,7 @@ void KFileItemModel::insertItems(QList<ItemData*>& newItems)
while (sourceIndexNewItems >= 0) {
ItemData* newItem = newItems.at(sourceIndexNewItems);
- if (sourceIndexExistingItems >= 0 && lessThan(newItem, m_itemData.at(sourceIndexExistingItems))) {
+ if (sourceIndexExistingItems >= 0 && lessThan(newItem, m_itemData.at(sourceIndexExistingItems), m_collator)) {
// Move an existing item to its new position. If any new items
// are behind it, push the item range to itemRanges.
if (rangeCount > 0) {
@@ -1201,13 +1202,13 @@ void KFileItemModel::insertItems(QList<ItemData*>& newItems)
}
// The indexes in m_items are not correct anymore. Therefore, we clear m_items.
- // It will be re-populated with the updated indices if index(const KUrl&) is called.
+ // It will be re-populated with the updated indices if index(const QUrl&) is called.
m_items.clear();
emit itemsInserted(itemRanges);
#ifdef KFILEITEMMODEL_DEBUG
- kDebug() << "[TIME] Inserting of" << newItems.count() << "items:" << timer.elapsed();
+ qCDebug(DolphinDebug) << "[TIME] Inserting of" << newItems.count() << "items:" << timer.elapsed();
#endif
}
@@ -1254,13 +1255,13 @@ void KFileItemModel::removeItems(const KItemRangeList& itemRanges, RemoveItemsBe
m_itemData.erase(m_itemData.end() - removedItemsCount, m_itemData.end());
// The indexes in m_items are not correct anymore. Therefore, we clear m_items.
- // It will be re-populated with the updated indices if index(const KUrl&) is called.
+ // It will be re-populated with the updated indices if index(const QUrl&) is called.
m_items.clear();
emit itemsRemoved(itemRanges);
}
-QList<KFileItemModel::ItemData*> KFileItemModel::createItemDataList(const KUrl& parentUrl, const KFileItemList& items) const
+QList<KFileItemModel::ItemData*> KFileItemModel::createItemDataList(const QUrl& parentUrl, const KFileItemList& items) const
{
if (m_sortRole == TypeRole) {
// Try to resolve the MIME-types synchronously to prevent a reordering of
@@ -1388,14 +1389,14 @@ void KFileItemModel::emitItemsChangedAndTriggerResorting(const KItemRangeList& i
// (b) the successor of the last item is "lessThan" the last item, or
// (c) the internal order of the items in the range is incorrect.
if (first > 0
- && lessThan(m_itemData.at(first), m_itemData.at(first - 1))) {
+ && lessThan(m_itemData.at(first), m_itemData.at(first - 1), m_collator)) {
needsResorting = true;
} else if (last < count() - 1
- && lessThan(m_itemData.at(last + 1), m_itemData.at(last))) {
+ && lessThan(m_itemData.at(last + 1), m_itemData.at(last), m_collator)) {
needsResorting = true;
} else {
for (int index = first; index < last; ++index) {
- if (lessThan(m_itemData.at(index + 1), m_itemData.at(index))) {
+ if (lessThan(m_itemData.at(index + 1), m_itemData.at(index), m_collator)) {
needsResorting = true;
break;
}
@@ -1510,8 +1511,8 @@ QHash<QByteArray, QVariant> KFileItemModel::retrieveData(const KFileItem& item,
// Don't use KFileItem::timeString() as this is too expensive when
// having several thousands of items. Instead the formatting of the
// date-time will be done on-demand by the view when the date will be shown.
- const KDateTime dateTime = item.time(KFileItem::ModificationTime);
- data.insert(sharedValue("date"), dateTime.dateTime());
+ const QDateTime dateTime = item.time(KFileItem::ModificationTime);
+ data.insert(sharedValue("date"), dateTime);
}
if (m_requestRole[PermissionsRole]) {
@@ -1536,7 +1537,7 @@ QHash<QByteArray, QVariant> KFileItemModel::retrieveData(const KFileItem& item,
if (m_requestRole[PathRole]) {
QString path;
- if (item.url().protocol() == QLatin1String("trash")) {
+ if (item.url().scheme() == QLatin1String("trash")) {
path = item.entry().stringValue(KIO::UDSEntry::UDS_EXTRA);
} else {
// For performance reasons cache the home-path in a static QString
@@ -1582,7 +1583,7 @@ QHash<QByteArray, QVariant> KFileItemModel::retrieveData(const KFileItem& item,
return data;
}
-bool KFileItemModel::lessThan(const ItemData* a, const ItemData* b) const
+bool KFileItemModel::lessThan(const ItemData* a, const ItemData* b, const QCollator& collator) const
{
int result = 0;
@@ -1627,7 +1628,7 @@ bool KFileItemModel::lessThan(const ItemData* a, const ItemData* b) const
}
}
- result = sortRoleCompare(a, b);
+ result = sortRoleCompare(a, b, collator);
return (sortOrder() == Qt::AscendingOrder) ? result < 0 : result > 0;
}
@@ -1638,24 +1639,36 @@ bool KFileItemModel::lessThan(const ItemData* a, const ItemData* b) const
class KFileItemModelLessThan
{
public:
- KFileItemModelLessThan(const KFileItemModel* model) :
- m_model(model)
+ KFileItemModelLessThan(const KFileItemModel* model, const QCollator& collator) :
+ m_model(model),
+ m_collator(collator)
+ {
+ }
+
+ KFileItemModelLessThan(const KFileItemModelLessThan& other) :
+ m_model(other.m_model),
+ m_collator()
{
+ m_collator.setCaseSensitivity(other.m_collator.caseSensitivity());
+ m_collator.setIgnorePunctuation(other.m_collator.ignorePunctuation());
+ m_collator.setLocale(other.m_collator.locale());
+ m_collator.setNumericMode(other.m_collator.numericMode());
}
bool operator()(const KFileItemModel::ItemData* a, const KFileItemModel::ItemData* b) const
{
- return m_model->lessThan(a, b);
+ return m_model->lessThan(a, b, m_collator);
}
private:
const KFileItemModel* m_model;
+ QCollator m_collator;
};
void KFileItemModel::sort(QList<KFileItemModel::ItemData*>::iterator begin,
QList<KFileItemModel::ItemData*>::iterator end) const
{
- KFileItemModelLessThan lessThan(this);
+ KFileItemModelLessThan lessThan(this, m_collator);
if (m_sortRole == NameRole) {
// Sorting by name can be expensive, in particular if natural sorting is
@@ -1670,7 +1683,7 @@ void KFileItemModel::sort(QList<KFileItemModel::ItemData*>::iterator begin,
}
}
-int KFileItemModel::sortRoleCompare(const ItemData* a, const ItemData* b) const
+int KFileItemModel::sortRoleCompare(const ItemData* a, const ItemData* b, const QCollator& collator) const
{
const KFileItem& itemA = a->item;
const KFileItem& itemB = b->item;
@@ -1715,8 +1728,8 @@ int KFileItemModel::sortRoleCompare(const ItemData* a, const ItemData* b) const
}
case DateRole: {
- const KDateTime dateTimeA = itemA.time(KFileItem::ModificationTime);
- const KDateTime dateTimeB = itemB.time(KFileItem::ModificationTime);
+ const QDateTime dateTimeA = itemA.time(KFileItem::ModificationTime);
+ const QDateTime dateTimeB = itemB.time(KFileItem::ModificationTime);
if (dateTimeA < dateTimeB) {
result = -1;
} else if (dateTimeA > dateTimeB) {
@@ -1733,9 +1746,8 @@ int KFileItemModel::sortRoleCompare(const ItemData* a, const ItemData* b) const
case ImageSizeRole: {
// Alway use a natural comparing to interpret the numbers of a string like
// "1600 x 1200" for having a correct sorting.
- result = KStringHandler::naturalCompare(a->values.value("imageSize").toString(),
- b->values.value("imageSize").toString(),
- Qt::CaseSensitive);
+ result = collator.compare(a->values.value("imageSize").toString(),
+ b->values.value("imageSize").toString());
break;
}
@@ -1754,14 +1766,13 @@ int KFileItemModel::sortRoleCompare(const ItemData* a, const ItemData* b) const
}
// Fallback #1: Compare the text of the items
- result = stringCompare(itemA.text(), itemB.text());
+ result = stringCompare(itemA.text(), itemB.text(), collator);
if (result != 0) {
return result;
}
// Fallback #2: KFileItem::text() may not be unique in case UDS_DISPLAY_NAME is used
- result = stringCompare(itemA.name(m_caseSensitivity == Qt::CaseInsensitive),
- itemB.name(m_caseSensitivity == Qt::CaseInsensitive));
+ result = stringCompare(itemA.name(), itemB.name(), collator);
if (result != 0) {
return result;
}
@@ -1772,26 +1783,21 @@ int KFileItemModel::sortRoleCompare(const ItemData* a, const ItemData* b) const
return QString::compare(itemA.url().url(), itemB.url().url(), Qt::CaseSensitive);
}
-int KFileItemModel::stringCompare(const QString& a, const QString& b) const
+int KFileItemModel::stringCompare(const QString& a, const QString& b, const QCollator& collator) const
{
- // Taken from KDirSortFilterProxyModel (kdelibs/kfile/kdirsortfilterproxymodel.*)
- // Copyright (C) 2006 by Peter Penz <[email protected]>
- // Copyright (C) 2006 by Dominic Battre <[email protected]>
- // Copyright (C) 2006 by Martin Pool <[email protected]>
+ if (m_naturalSorting) {
+ return collator.compare(a, b);
+ }
- if (m_caseSensitivity == Qt::CaseInsensitive) {
- const int result = m_naturalSorting ? KStringHandler::naturalCompare(a, b, Qt::CaseInsensitive)
- : QString::compare(a, b, Qt::CaseInsensitive);
- if (result != 0) {
- // Only return the result, if the strings are not equal. If they are equal by a case insensitive
- // comparison, still a deterministic sort order is required. A case sensitive
- // comparison is done as fallback.
- return result;
- }
+ const int result = QString::compare(a, b, collator.caseSensitivity());
+ if (result != 0 || collator.caseSensitivity() == Qt::CaseSensitive) {
+ // Only return the result, if the strings are not equal. If they are equal by a case insensitive
+ // comparison, still a deterministic sort order is required. A case sensitive
+ // comparison is done as fallback.
+ return result;
}
- return m_naturalSorting ? KStringHandler::naturalCompare(a, b, Qt::CaseSensitive)
- : QString::compare(a, b, Qt::CaseSensitive);
+ return QString::compare(a, b, Qt::CaseSensitive);
}
bool KFileItemModel::useMaximumUpdateInterval() const
@@ -1799,11 +1805,6 @@ bool KFileItemModel::useMaximumUpdateInterval() const
return !m_dirLister->url().isLocalFile();
}
-static bool localeAwareLessThan(const QChar& c1, const QChar& c2)
-{
- return QString::localeAwareCompare(c1, c2) < 0;
-}
-
QList<QPair<int, QVariant> > KFileItemModel::nameRoleGroups() const
{
Q_ASSERT(!m_itemData.isEmpty());
@@ -1837,6 +1838,10 @@ QList<QPair<int, QVariant> > KFileItemModel::nameRoleGroups() const
}
}
+ auto localeAwareLessThan = [this](const QChar& c1, const QChar& c2) -> bool {
+ return m_collator.compare(c1, c2) < 0;
+ };
+
std::vector<QChar>::iterator it = std::lower_bound(lettersAtoZ.begin(), lettersAtoZ.end(), newFirstChar, localeAwareLessThan);
if (it != lettersAtoZ.end()) {
if (localeAwareLessThan(newFirstChar, *it) && it != lettersAtoZ.begin()) {
@@ -1908,7 +1913,7 @@ QList<QPair<int, QVariant> > KFileItemModel::dateRoleGroups() const
const int maxIndex = count() - 1;
QList<QPair<int, QVariant> > groups;
- const QDate currentDate = KDateTime::currentLocalDateTime().date();
+ const QDate currentDate = QDate::currentDate();
QDate previousModifiedDate;
QString groupValue;
@@ -1917,7 +1922,7 @@ QList<QPair<int, QVariant> > KFileItemModel::dateRoleGroups() const
continue;
}
- const KDateTime modifiedTime = m_itemData.at(i)->item.time(KFileItem::ModificationTime);
+ const QDateTime modifiedTime = m_itemData.at(i)->item.time(KFileItem::ModificationTime);
const QDate modifiedDate = modifiedTime.date();
if (modifiedDate == previousModifiedDate) {
// The current item is in the same group as the previous item
@@ -1934,7 +1939,7 @@ QList<QPair<int, QVariant> > KFileItemModel::dateRoleGroups() const
switch (daysDistance) {
case 0: newGroupValue = i18nc("@title:group Date", "Today"); break;
case 1: newGroupValue = i18nc("@title:group Date", "Yesterday"); break;
- default: newGroupValue = modifiedTime.toString(i18nc("@title:group The week day name: %A", "%A"));
+ default: newGroupValue = modifiedTime.toString(i18nc("@title:group The week day name: dddd", "dddd"));
}
break;
case 1:
@@ -1957,20 +1962,20 @@ QList<QPair<int, QVariant> > KFileItemModel::dateRoleGroups() const
const QDate lastMonthDate = currentDate.addMonths(-1);
if (lastMonthDate.year() == modifiedDate.year() && lastMonthDate.month() == modifiedDate.month()) {
if (daysDistance == 1) {
- newGroupValue = modifiedTime.toString(i18nc("@title:group Date: %B is full month name in current locale, and %Y is full year number", "Yesterday (%B, %Y)"));
+ newGroupValue = modifiedTime.toString(i18nc("@title:group Date: MMMM is full month name in current locale, and yyyy is full year number", "'Yesterday' (MMMM, yyyy)"));
} else if (daysDistance <= 7) {
- newGroupValue = modifiedTime.toString(i18nc("@title:group The week day name: %A, %B is full month name in current locale, and %Y is full year number", "%A (%B, %Y)"));
+ newGroupValue = modifiedTime.toString(i18nc("@title:group The week day name: dddd, MMMM is full month name in current locale, and yyyy is full year number", "dddd (MMMM, yyyy)"));
} else if (daysDistance <= 7 * 2) {
- newGroupValue = modifiedTime.toString(i18nc("@title:group Date: %B is full month name in current locale, and %Y is full year number", "One Week Ago (%B, %Y)"));
+ newGroupValue = modifiedTime.toString(i18nc("@title:group Date: MMMM is full month name in current locale, and yyyy is full year number", "'One Week Ago' (MMMM, yyyy)"));
} else if (daysDistance <= 7 * 3) {
- newGroupValue = modifiedTime.toString(i18nc("@title:group Date: %B is full month name in current locale, and %Y is full year number", "Two Weeks Ago (%B, %Y)"));
+ newGroupValue = modifiedTime.toString(i18nc("@title:group Date: MMMM is full month name in current locale, and yyyy is full year number", "'Two Weeks Ago' (MMMM, yyyy)"));
} else if (daysDistance <= 7 * 4) {
- newGroupValue = modifiedTime.toString(i18nc("@title:group Date: %B is full month name in current locale, and %Y is full year number", "Three Weeks Ago (%B, %Y)"));
+ newGroupValue = modifiedTime.toString(i18nc("@title:group Date: MMMM is full month name in current locale, and yyyy is full year number", "'Three Weeks Ago' (MMMM, yyyy)"));
} else {
- newGroupValue = modifiedTime.toString(i18nc("@title:group Date: %B is full month name in current locale, and %Y is full year number", "Earlier on %B, %Y"));
+ newGroupValue = modifiedTime.toString(i18nc("@title:group Date: MMMM is full month name in current locale, and yyyy is full year number", "'Earlier on' MMMM, yyyy"));
}
} else {
- newGroupValue = modifiedTime.toString(i18nc("@title:group The month and year: %B is full month name in current locale, and %Y is full year number", "%B, %Y"));
+ newGroupValue = modifiedTime.toString(i18nc("@title:group The month and year: MMMM is full month name in current locale, and yyyy is full year number", "MMMM, yyyy"));
}
}
@@ -2004,7 +2009,7 @@ QList<QPair<int, QVariant> > KFileItemModel::permissionRoleGroups() const
}
permissionsString = newPermissionsString;
- const QFileInfo info(itemData->item.url().pathOrUrl());
+ const QFileInfo info(itemData->item.url().toLocalFile());
// Set user string
QString user;
@@ -2199,7 +2204,7 @@ QByteArray KFileItemModel::sharedValue(const QByteArray& value)
bool KFileItemModel::isConsistent() const
{
// m_items may contain less items than m_itemData because m_items
- // is populated lazily, see KFileItemModel::index(const KUrl& url).
+ // is populated lazily, see KFileItemModel::index(const QUrl& url).
if (m_items.count() > m_itemData.count()) {
return false;
}
@@ -2208,19 +2213,19 @@ bool KFileItemModel::isConsistent() const
// Check if m_items and m_itemData are consistent.
const KFileItem item = fileItem(i);
if (item.isNull()) {
- qWarning() << "Item" << i << "is null";
+ qCWarning(DolphinDebug) << "Item" << i << "is null";
return false;
}
const int itemIndex = index(item);
if (itemIndex != i) {
- qWarning() << "Item" << i << "has a wrong index:" << itemIndex;
+ qCWarning(DolphinDebug) << "Item" << i << "has a wrong index:" << itemIndex;
return false;
}
// Check if the items are sorted correctly.
- if (i > 0 && !lessThan(m_itemData.at(i - 1), m_itemData.at(i))) {
- qWarning() << "The order of items" << i - 1 << "and" << i << "is wrong:"
+ if (i > 0 && !lessThan(m_itemData.at(i - 1), m_itemData.at(i), m_collator)) {
+ qCWarning(DolphinDebug) << "The order of items" << i - 1 << "and" << i << "is wrong:"
<< fileItem(i - 1) << fileItem(i);
return false;
}
@@ -2230,13 +2235,13 @@ bool KFileItemModel::isConsistent() const
const ItemData* parent = data->parent;
if (parent) {
if (expandedParentsCount(data) != expandedParentsCount(parent) + 1) {
- qWarning() << "expandedParentsCount is inconsistent for parent" << parent->item << "and child" << data->item;
+ qCWarning(DolphinDebug) << "expandedParentsCount is inconsistent for parent" << parent->item << "and child" << data->item;
return false;
}
const int parentIndex = index(parent->item);
if (parentIndex >= i) {
- qWarning() << "Index" << parentIndex << "of parent" << parent->item << "is not smaller than index" << i << "of child" << data->item;
+ qCWarning(DolphinDebug) << "Index" << parentIndex << "of parent" << parent->item << "is not smaller than index" << i << "of child" << data->item;
return false;
}
}
@@ -2245,4 +2250,3 @@ bool KFileItemModel::isConsistent() const
return true;
}
-#include "kfileitemmodel.moc"
diff --git a/src/kitemviews/kfileitemmodel.h b/src/kitemviews/kfileitemmodel.h
index 62a283d33..167f508cf 100644
--- a/src/kitemviews/kfileitemmodel.h
+++ b/src/kitemviews/kfileitemmodel.h
@@ -20,12 +20,13 @@
#ifndef KFILEITEMMODEL_H
#define KFILEITEMMODEL_H
-#include <libdolphin_export.h>
-#include <KFileItemList>
-#include <KUrl>
+#include "dolphin_export.h"
+#include <KFileItem>
+#include <QUrl>
#include <kitemviews/kitemmodelbase.h>
#include <kitemviews/private/kfileitemmodelfilter.h>
+#include <QCollator>
#include <QHash>
#include <QSet>
@@ -42,7 +43,7 @@ class QTimer;
* Recursive expansion of sub-directories is supported by
* KFileItemModel::setExpanded().
*/
-class LIBDOLPHINPRIVATE_EXPORT KFileItemModel : public KItemModelBase
+class DOLPHIN_EXPORT KFileItemModel : public KItemModelBase
{
Q_OBJECT
@@ -56,13 +57,13 @@ public:
* indicate the current state of the loading process. The items
* of the directory are added after the loading has been completed.
*/
- void loadDirectory(const KUrl& url);
+ void loadDirectory(const QUrl& url);
/**
* Throws away all currently loaded items and refreshes the directory
* by reloading all items again.
*/
- void refreshDirectory(const KUrl& url);
+ void refreshDirectory(const QUrl& url);
/**
* @return Parent directory of the items that are shown. In case
@@ -70,7 +71,7 @@ public:
* the root-parent of all items.
* @see rootItem()
*/
- KUrl directory() const;
+ QUrl directory() const;
/**
* Cancels the loading of a directory which has been started by either
@@ -78,9 +79,9 @@ public:
*/
void cancelDirectoryLoading();
- virtual int count() const;
- virtual QHash<QByteArray, QVariant> data(int index) const;
- virtual bool setData(int index, const QHash<QByteArray, QVariant>& values);
+ virtual int count() const Q_DECL_OVERRIDE;
+ virtual QHash<QByteArray, QVariant> data(int index) const Q_DECL_OVERRIDE;
+ virtual bool setData(int index, const QHash<QByteArray, QVariant>& values) Q_DECL_OVERRIDE;
/**
* Sets a separate sorting with directories first (true) or a mixed
@@ -99,20 +100,15 @@ public:
void setShowDirectoriesOnly(bool enabled);
bool showDirectoriesOnly() const;
- /** @reimp */
- virtual QMimeData* createMimeData(const KItemSet& indexes) const;
+ virtual QMimeData* createMimeData(const KItemSet& indexes) const Q_DECL_OVERRIDE;
- /** @reimp */
- virtual int indexForKeyboardSearch(const QString& text, int startFromIndex = 0) const;
+ virtual int indexForKeyboardSearch(const QString& text, int startFromIndex = 0) const Q_DECL_OVERRIDE;
- /** @reimp */
- virtual bool supportsDropping(int index) const;
+ virtual bool supportsDropping(int index) const Q_DECL_OVERRIDE;
- /** @reimp */
- virtual QString roleDescription(const QByteArray& role) const;
+ virtual QString roleDescription(const QByteArray& role) const Q_DECL_OVERRIDE;
- /** @reimp */
- virtual QList<QPair<int, QVariant> > groups() const;
+ virtual QList<QPair<int, QVariant> > groups() const Q_DECL_OVERRIDE;
/**
* @return The file-item for the index \a index. If the index is in a valid
@@ -126,7 +122,7 @@ public:
* URL is found KFileItem::isNull() will be true for the returned
* file-item. The runtime complexity of this call is O(1).
*/
- KFileItem fileItem(const KUrl& url) const;
+ KFileItem fileItem(const QUrl& url) const;
/**
* @return The index for the file-item \a item. -1 is returned if no file-item
@@ -139,7 +135,7 @@ public:
* @return The index for the URL \a url. -1 is returned if no file-item
* is found. The amortized runtime complexity of this call is O(1).
*/
- int index(const KUrl& url) const;
+ int index(const QUrl &url) const;
/**
* @return Root item of all items representing the item
@@ -158,24 +154,24 @@ public:
void setRoles(const QSet<QByteArray>& roles);
QSet<QByteArray> roles() const;
- virtual bool setExpanded(int index, bool expanded);
- virtual bool isExpanded(int index) const;
- virtual bool isExpandable(int index) const;
- virtual int expandedParentsCount(int index) const;
+ virtual bool setExpanded(int index, bool expanded) Q_DECL_OVERRIDE;
+ virtual bool isExpanded(int index) const Q_DECL_OVERRIDE;
+ virtual bool isExpandable(int index) const Q_DECL_OVERRIDE;
+ virtual int expandedParentsCount(int index) const Q_DECL_OVERRIDE;
- QSet<KUrl> expandedDirectories() const;
+ QSet<QUrl> expandedDirectories() const;
/**
* Marks the URLs in \a urls as sub-directories which were expanded previously.
* After calling loadDirectory() or refreshDirectory() the marked sub-directories
* will be expanded step-by-step.
*/
- void restoreExpandedDirectories(const QSet<KUrl>& urls);
+ void restoreExpandedDirectories(const QSet<QUrl>& urls);
/**
* Expands all parent-directories of the item \a url.
*/
- void expandParentDirectories(const KUrl& url);
+ void expandParentDirectories(const QUrl& url);
void setNameFilter(const QString& nameFilter);
QString nameFilter() const;
@@ -251,18 +247,18 @@ signals:
* Is emitted if a redirection from the current URL \a oldUrl
* to the new URL \a newUrl has been done.
*/
- void directoryRedirection(const KUrl& oldUrl, const KUrl& newUrl);
+ void directoryRedirection(const QUrl& oldUrl, const QUrl& newUrl);
/**
* Is emitted when the URL passed by KFileItemModel::setUrl() represents a file.
* In this case no signal errorMessage() will be emitted.
*/
- void urlIsFileError(const KUrl& url);
+ void urlIsFileError(const QUrl& url);
protected:
- virtual void onGroupedSortingChanged(bool current);
- virtual void onSortRoleChanged(const QByteArray& current, const QByteArray& previous);
- virtual void onSortOrderChanged(Qt::SortOrder current, Qt::SortOrder previous);
+ virtual void onGroupedSortingChanged(bool current) Q_DECL_OVERRIDE;
+ virtual void onSortRoleChanged(const QByteArray& current, const QByteArray& previous) Q_DECL_OVERRIDE;
+ virtual void onSortOrderChanged(Qt::SortOrder current, Qt::SortOrder previous) Q_DECL_OVERRIDE;
private slots:
/**
@@ -273,7 +269,7 @@ private slots:
void slotCompleted();
void slotCanceled();
- void slotItemsAdded(const KUrl& directoryUrl, const KFileItemList& items);
+ void slotItemsAdded(const QUrl& directoryUrl, const KFileItemList& items);
void slotItemsDeleted(const KFileItemList& items);
void slotRefreshItems(const QList<QPair<KFileItem, KFileItem> >& items);
void slotClear();
@@ -317,7 +313,7 @@ private:
* Note that the ItemData instances are created dynamically and
* must be deleted by the caller.
*/
- QList<ItemData*> createItemDataList(const KUrl& parentUrl, const KFileItemList& items) const;
+ QList<ItemData*> createItemDataList(const QUrl& parentUrl, const KFileItemList& items) const;
/**
* Prepares the items for sorting. Normally, the hash 'values' in ItemData is filled
@@ -366,7 +362,7 @@ private:
* @return True if the item-data \a a should be ordered before the item-data
* \b. The item-data may have different parent-items.
*/
- bool lessThan(const ItemData* a, const ItemData* b) const;
+ bool lessThan(const ItemData* a, const ItemData* b, const QCollator& collator) const;
/**
* Sorts the items between \a begin and \a end using the comparison
@@ -379,9 +375,9 @@ private:
* the passed item-data using m_sortRole as criteria. Both items must
* have the same parent item, otherwise the comparison will be wrong.
*/
- int sortRoleCompare(const ItemData* a, const ItemData* b) const;
+ int sortRoleCompare(const ItemData* a, const ItemData* b, const QCollator& collator) const;
- int stringCompare(const QString& a, const QString& b) const;
+ int stringCompare(const QString& a, const QString& b, const QCollator& collator) const;
bool useMaximumUpdateInterval() const;
@@ -460,21 +456,21 @@ private:
private:
KFileItemModelDirLister* m_dirLister;
+ QCollator m_collator;
bool m_naturalSorting;
bool m_sortDirsFirst;
RoleType m_sortRole;
int m_sortingProgressPercent; // Value of directorySortingProgress() signal
QSet<QByteArray> m_roles;
- Qt::CaseSensitivity m_caseSensitivity;
QList<ItemData*> m_itemData;
- // m_items is a cache for the method index(const KUrl&). If it contains N
+ // m_items is a cache for the method index(const QUrl&). If it contains N
// entries, it is guaranteed that these correspond to the first N items in
// the model, i.e., that (for every i between 0 and N - 1)
// m_items.value(fileItem(i).url()) == i
- mutable QHash<KUrl, int> m_items;
+ mutable QHash<QUrl, int> m_items;
KFileItemModelFilter m_filter;
QHash<KFileItem, ItemData*> m_filteredItems; // Items that got hidden by KFileItemModel::setNameFilter()
@@ -489,11 +485,11 @@ private:
mutable QList<QPair<int, QVariant> > m_groups;
// Stores the URLs (key: target url, value: url) of the expanded directories.
- QHash<KUrl, KUrl> m_expandedDirs;
+ QHash<QUrl, QUrl> m_expandedDirs;
// URLs that must be expanded. The expanding is initially triggered in setExpanded()
// and done step after step in slotCompleted().
- QSet<KUrl> m_urlsToExpand;
+ QSet<QUrl> m_urlsToExpand;
friend class KFileItemModelLessThan; // Accesses lessThan() method
friend class KFileItemModelRolesUpdater; // Accesses emitSortProgress() method
diff --git a/src/kitemviews/kfileitemmodelrolesupdater.cpp b/src/kitemviews/kfileitemmodelrolesupdater.cpp
index 0865d40e7..c18d65892 100644
--- a/src/kitemviews/kfileitemmodelrolesupdater.cpp
+++ b/src/kitemviews/kfileitemmodelrolesupdater.cpp
@@ -23,9 +23,10 @@
#include <KConfig>
#include <KConfigGroup>
-#include <KDebug>
+#include <KSharedConfig>
#include <KFileItem>
-#include <KGlobal>
+#include <KIconLoader>
+#include <KJobWidgets>
#include <KIO/JobUiDelegate>
#include <KIO/PreviewJob>
@@ -42,9 +43,8 @@
#ifdef HAVE_BALOO
#include "private/kbaloorolesprovider.h"
- #include <baloo/file.h>
- #include <baloo/filefetchjob.h>
- #include <baloo/filemonitor.h>
+ #include <Baloo/File>
+ #include <Baloo/FileMonitor>
#endif
// #define KFILEITEMMODELROLESUPDATER_DEBUG
@@ -95,29 +95,29 @@ KFileItemModelRolesUpdater::KFileItemModelRolesUpdater(KFileItemModel* model, QO
{
Q_ASSERT(model);
- const KConfigGroup globalConfig(KGlobal::config(), "PreviewSettings");
+ const KConfigGroup globalConfig(KSharedConfig::openConfig(), "PreviewSettings");
m_enabledPlugins = globalConfig.readEntry("Plugins", QStringList()
<< "directorythumbnail"
<< "imagethumbnail"
<< "jpegthumbnail");
- connect(m_model, SIGNAL(itemsInserted(KItemRangeList)),
- this, SLOT(slotItemsInserted(KItemRangeList)));
- connect(m_model, SIGNAL(itemsRemoved(KItemRangeList)),
- this, SLOT(slotItemsRemoved(KItemRangeList)));
- connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
- this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
- connect(m_model, SIGNAL(itemsMoved(KItemRange,QList<int>)),
- this, SLOT(slotItemsMoved(KItemRange,QList<int>)));
- connect(m_model, SIGNAL(sortRoleChanged(QByteArray,QByteArray)),
- this, SLOT(slotSortRoleChanged(QByteArray,QByteArray)));
+ connect(m_model, &KFileItemModel::itemsInserted,
+ this, &KFileItemModelRolesUpdater::slotItemsInserted);
+ connect(m_model, &KFileItemModel::itemsRemoved,
+ this, &KFileItemModelRolesUpdater::slotItemsRemoved);
+ connect(m_model, &KFileItemModel::itemsChanged,
+ this, &KFileItemModelRolesUpdater::slotItemsChanged);
+ connect(m_model, &KFileItemModel::itemsMoved,
+ this, &KFileItemModelRolesUpdater::slotItemsMoved);
+ connect(m_model, &KFileItemModel::sortRoleChanged,
+ this, &KFileItemModelRolesUpdater::slotSortRoleChanged);
// Use a timer to prevent that each call of slotItemsChanged() results in a synchronous
// resolving of the roles. Postpone the resolving until no update has been done for 1 second.
m_recentlyChangedItemsTimer = new QTimer(this);
m_recentlyChangedItemsTimer->setInterval(1000);
m_recentlyChangedItemsTimer->setSingleShot(true);
- connect(m_recentlyChangedItemsTimer, SIGNAL(timeout()), this, SLOT(resolveRecentlyChangedItems()));
+ connect(m_recentlyChangedItemsTimer, &QTimer::timeout, this, &KFileItemModelRolesUpdater::resolveRecentlyChangedItems);
m_resolvableRoles.insert("size");
m_resolvableRoles.insert("type");
@@ -127,8 +127,8 @@ KFileItemModelRolesUpdater::KFileItemModelRolesUpdater(KFileItemModel* model, QO
#endif
m_directoryContentsCounter = new KDirectoryContentsCounter(m_model, this);
- connect(m_directoryContentsCounter, SIGNAL(result(QString,int)),
- this, SLOT(slotDirectoryContentsCountReceived(QString,int)));
+ connect(m_directoryContentsCounter, &KDirectoryContentsCounter::result,
+ this, &KFileItemModelRolesUpdater::slotDirectoryContentsCountReceived);
}
KFileItemModelRolesUpdater::~KFileItemModelRolesUpdater()
@@ -280,8 +280,8 @@ void KFileItemModelRolesUpdater::setRoles(const QSet<QByteArray>& roles)
if (hasBalooRole && !m_balooFileMonitor) {
m_balooFileMonitor = new Baloo::FileMonitor(this);
- connect(m_balooFileMonitor, SIGNAL(fileMetaDataChanged(QString)),
- this, SLOT(applyChangedBalooRoles(QString)));
+ connect(m_balooFileMonitor, &Baloo::FileMonitor::fileMetaDataChanged,
+ this, &KFileItemModelRolesUpdater::applyChangedBalooRoles);
} else if (!hasBalooRole && m_balooFileMonitor) {
delete m_balooFileMonitor;
m_balooFileMonitor = 0;
@@ -543,11 +543,11 @@ void KFileItemModelRolesUpdater::slotGotPreview(const KFileItem& item, const QPi
data.insert("iconPixmap", scaledPixmap);
- disconnect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
- this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
+ disconnect(m_model, &KFileItemModel::itemsChanged,
+ this, &KFileItemModelRolesUpdater::slotItemsChanged);
m_model->setData(index, data);
- connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
- this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
+ connect(m_model, &KFileItemModel::itemsChanged,
+ this, &KFileItemModelRolesUpdater::slotItemsChanged);
m_finishedItems.insert(item);
}
@@ -565,11 +565,11 @@ void KFileItemModelRolesUpdater::slotPreviewFailed(const KFileItem& item)
QHash<QByteArray, QVariant> data;
data.insert("iconPixmap", QPixmap());
- disconnect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
- this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
+ disconnect(m_model, &KFileItemModel::itemsChanged,
+ this, &KFileItemModelRolesUpdater::slotItemsChanged);
m_model->setData(index, data);
- connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
- this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
+ connect(m_model, &KFileItemModel::itemsChanged,
+ this, &KFileItemModelRolesUpdater::slotItemsChanged);
applyResolvedRoles(index, ResolveAll);
m_finishedItems.insert(item);
@@ -625,11 +625,11 @@ void KFileItemModelRolesUpdater::resolveNextSortRole()
m_state = Idle;
// Prevent that we try to update the items twice.
- disconnect(m_model, SIGNAL(itemsMoved(KItemRange,QList<int>)),
- this, SLOT(slotItemsMoved(KItemRange,QList<int>)));
+ disconnect(m_model, &KFileItemModel::itemsMoved,
+ this, &KFileItemModelRolesUpdater::slotItemsMoved);
applySortProgressToModel();
- connect(m_model, SIGNAL(itemsMoved(KItemRange,QList<int>)),
- this, SLOT(slotItemsMoved(KItemRange,QList<int>)));
+ connect(m_model, &KFileItemModel::itemsMoved,
+ this, &KFileItemModelRolesUpdater::slotItemsMoved);
startUpdating();
}
}
@@ -665,15 +665,15 @@ void KFileItemModelRolesUpdater::resolveNextPendingRoles()
QHash<QByteArray, QVariant> data;
data.insert("iconPixmap", QPixmap());
- disconnect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
- this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
+ disconnect(m_model, &KFileItemModel::itemsChanged,
+ this, &KFileItemModelRolesUpdater::slotItemsChanged);
for (int index = 0; index <= m_model->count(); ++index) {
if (m_model->data(index).contains("iconPixmap")) {
m_model->setData(index, data);
}
}
- connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
- this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
+ connect(m_model, &KFileItemModel::itemsChanged,
+ this, &KFileItemModelRolesUpdater::slotItemsChanged);
}
m_clearPreviews = false;
@@ -703,21 +703,8 @@ void KFileItemModelRolesUpdater::applyChangedBalooRoles(const QString& itemUrl)
return;
}
- Baloo::FileFetchJob* job = new Baloo::FileFetchJob(item.localPath());
- connect(job, SIGNAL(finished(KJob*)), this, SLOT(applyChangedBalooRolesJobFinished(KJob*)));
- job->setProperty("item", QVariant::fromValue(item));
- job->start();
-#else
-#ifndef Q_CC_MSVC
- Q_UNUSED(itemUrl);
-#endif
-#endif
-}
-
-void KFileItemModelRolesUpdater::applyChangedBalooRolesJobFinished(KJob* kjob)
-{
-#ifdef HAVE_BALOO
- const KFileItem item = kjob->property("item").value<KFileItem>();
+ Baloo::File file(item.localPath());
+ file.load();
const KBalooRolesProvider& rolesProvider = KBalooRolesProvider::instance();
QHash<QByteArray, QVariant> data;
@@ -729,19 +716,22 @@ void KFileItemModelRolesUpdater::applyChangedBalooRolesJobFinished(KJob* kjob)
data.insert(role, QVariant());
}
- Baloo::FileFetchJob* job = static_cast<Baloo::FileFetchJob*>(kjob);
- QHashIterator<QByteArray, QVariant> it(rolesProvider.roleValues(job->file(), m_roles));
+ QHashIterator<QByteArray, QVariant> it(rolesProvider.roleValues(file, m_roles));
while (it.hasNext()) {
it.next();
data.insert(it.key(), it.value());
}
- disconnect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
- this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
+ disconnect(m_model, &KFileItemModel::itemsChanged,
+ this, &KFileItemModelRolesUpdater::slotItemsChanged);
const int index = m_model->index(item);
m_model->setData(index, data);
- connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
- this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
+ connect(m_model, &KFileItemModel::itemsChanged,
+ this, &KFileItemModelRolesUpdater::slotItemsChanged);
+#else
+#ifndef Q_CC_MSVC
+ Q_UNUSED(itemUrl);
+#endif
#endif
}
@@ -751,7 +741,7 @@ void KFileItemModelRolesUpdater::slotDirectoryContentsCountReceived(const QStrin
const bool getIsExpandableRole = m_roles.contains("isExpandable");
if (getSizeRole || getIsExpandableRole) {
- const int index = m_model->index(KUrl(path));
+ const int index = m_model->index(QUrl::fromLocalFile(path));
if (index >= 0) {
QHash<QByteArray, QVariant> data;
@@ -762,11 +752,11 @@ void KFileItemModelRolesUpdater::slotDirectoryContentsCountReceived(const QStrin
data.insert("isExpandable", count > 0);
}
- disconnect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
- this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
+ disconnect(m_model, &KFileItemModel::itemsChanged,
+ this, &KFileItemModelRolesUpdater::slotItemsChanged);
m_model->setData(index, data);
- connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
- this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
+ connect(m_model, &KFileItemModel::itemsChanged,
+ this, &KFileItemModelRolesUpdater::slotItemsChanged);
}
}
}
@@ -897,15 +887,15 @@ void KFileItemModelRolesUpdater::startPreviewJob()
job->setIgnoreMaximumSize(itemSubSet.first().isLocalFile());
if (job->ui()) {
- job->ui()->setWindow(qApp->activeWindow());
+ KJobWidgets::setWindow(job, qApp->activeWindow());
}
- connect(job, SIGNAL(gotPreview(KFileItem,QPixmap)),
- this, SLOT(slotGotPreview(KFileItem,QPixmap)));
- connect(job, SIGNAL(failed(KFileItem)),
- this, SLOT(slotPreviewFailed(KFileItem)));
- connect(job, SIGNAL(finished(KJob*)),
- this, SLOT(slotPreviewJobFinished()));
+ connect(job, &KIO::PreviewJob::gotPreview,
+ this, &KFileItemModelRolesUpdater::slotGotPreview);
+ connect(job, &KIO::PreviewJob::failed,
+ this, &KFileItemModelRolesUpdater::slotPreviewFailed);
+ connect(job, &KIO::PreviewJob::finished,
+ this, &KFileItemModelRolesUpdater::slotPreviewJobFinished);
m_previewJob = job;
}
@@ -998,11 +988,11 @@ void KFileItemModelRolesUpdater::applySortRole(int index)
data = rolesData(item);
}
- disconnect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
- this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
+ disconnect(m_model, &KFileItemModel::itemsChanged,
+ this, &KFileItemModelRolesUpdater::slotItemsChanged);
m_model->setData(index, data);
- connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
- this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
+ connect(m_model, &KFileItemModel::itemsChanged,
+ this, &KFileItemModelRolesUpdater::slotItemsChanged);
}
void KFileItemModelRolesUpdater::applySortProgressToModel()
@@ -1042,11 +1032,11 @@ bool KFileItemModelRolesUpdater::applyResolvedRoles(int index, ResolveHint hint)
data.insert("iconPixmap", QPixmap());
}
- disconnect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
- this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
+ disconnect(m_model, &KFileItemModel::itemsChanged,
+ this, &KFileItemModelRolesUpdater::slotItemsChanged);
m_model->setData(index, data);
- connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
- this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
+ connect(m_model, &KFileItemModel::itemsChanged,
+ this, &KFileItemModelRolesUpdater::slotItemsChanged);
return true;
}
@@ -1099,12 +1089,12 @@ void KFileItemModelRolesUpdater::updateAllPreviews()
void KFileItemModelRolesUpdater::killPreviewJob()
{
if (m_previewJob) {
- disconnect(m_previewJob, SIGNAL(gotPreview(KFileItem,QPixmap)),
- this, SLOT(slotGotPreview(KFileItem,QPixmap)));
- disconnect(m_previewJob, SIGNAL(failed(KFileItem)),
- this, SLOT(slotPreviewFailed(KFileItem)));
- disconnect(m_previewJob, SIGNAL(finished(KJob*)),
- this, SLOT(slotPreviewJobFinished()));
+ disconnect(m_previewJob, &KIO::PreviewJob::gotPreview,
+ this, &KFileItemModelRolesUpdater::slotGotPreview);
+ disconnect(m_previewJob, &KIO::PreviewJob::failed,
+ this, &KFileItemModelRolesUpdater::slotPreviewFailed);
+ disconnect(m_previewJob, &KIO::PreviewJob::finished,
+ this, &KFileItemModelRolesUpdater::slotPreviewJobFinished);
m_previewJob->kill();
m_previewJob = 0;
m_pendingPreviewItems.clear();
@@ -1168,4 +1158,3 @@ QList<int> KFileItemModelRolesUpdater::indexesToResolve() const
return result;
}
-#include "kfileitemmodelrolesupdater.moc"
diff --git a/src/kitemviews/kfileitemmodelrolesupdater.h b/src/kitemviews/kfileitemmodelrolesupdater.h
index a9e979ae1..216b0a501 100644
--- a/src/kitemviews/kfileitemmodelrolesupdater.h
+++ b/src/kitemviews/kfileitemmodelrolesupdater.h
@@ -25,7 +25,7 @@
#include <KFileItem>
#include <kitemviews/kitemmodelbase.h>
-#include <libdolphin_export.h>
+#include "dolphin_export.h"
#include <QObject>
#include <QSet>
@@ -34,10 +34,13 @@
class KDirectoryContentsCounter;
class KFileItemModel;
-class KJob;
class QPixmap;
class QTimer;
+namespace KIO {
+ class PreviewJob;
+}
+
#ifdef HAVE_BALOO
namespace Baloo
{
@@ -84,7 +87,7 @@ class QTimer;
* 3. Finally, the entire process is repeated for any items that might have
* changed in the mean time.
*/
-class LIBDOLPHINPRIVATE_EXPORT KFileItemModelRolesUpdater : public QObject
+class DOLPHIN_EXPORT KFileItemModelRolesUpdater : public QObject
{
Q_OBJECT
@@ -201,7 +204,6 @@ private slots:
void resolveRecentlyChangedItems();
void applyChangedBalooRoles(const QString& file);
- void applyChangedBalooRolesJobFinished(KJob* job);
void slotDirectoryContentsCountReceived(const QString& path, int count);
@@ -316,7 +318,7 @@ private:
// A new preview job will be started from them once the first one finishes.
KFileItemList m_pendingPreviewItems;
- KJob* m_previewJob;
+ KIO::PreviewJob* m_previewJob;
// When downloading or copying large files, the slot slotItemsChanged()
// will be called periodically within a quite short delay. To prevent
diff --git a/src/kitemviews/kitemlistcontainer.cpp b/src/kitemviews/kitemlistcontainer.cpp
index 8498286c9..f5c785a3e 100644
--- a/src/kitemviews/kitemlistcontainer.cpp
+++ b/src/kitemviews/kitemlistcontainer.cpp
@@ -31,12 +31,10 @@
#include <QApplication>
#include <QGraphicsScene>
#include <QGraphicsView>
-#include <QPropertyAnimation>
#include <QScrollBar>
#include <QStyle>
#include <QStyleOption>
-#include <KDebug>
/**
* Replaces the default viewport of KItemListContainer by a
@@ -89,10 +87,10 @@ KItemListContainer::KItemListContainer(KItemListController* controller, QWidget*
slotViewChanged(controller->view(), 0);
}
- connect(controller, SIGNAL(modelChanged(KItemModelBase*,KItemModelBase*)),
- this, SLOT(slotModelChanged(KItemModelBase*,KItemModelBase*)));
- connect(controller, SIGNAL(viewChanged(KItemListView*,KItemListView*)),
- this, SLOT(slotViewChanged(KItemListView*,KItemListView*)));
+ connect(controller, &KItemListController::modelChanged,
+ this, &KItemListContainer::slotModelChanged);
+ connect(controller, &KItemListController::viewChanged,
+ this, &KItemListContainer::slotViewChanged);
}
KItemListContainer::~KItemListContainer()
@@ -185,11 +183,15 @@ void KItemListContainer::wheelEvent(QWheelEvent* event)
KItemListSmoothScroller* smoothScroller = scrollHorizontally ?
m_horizontalSmoothScroller : m_verticalSmoothScroller;
- const int numDegrees = event->delta() / 8;
- const int numSteps = numDegrees / 15;
-
const QScrollBar* scrollBar = smoothScroller->scrollBar();
- smoothScroller->scrollTo(scrollBar->value() - numSteps * scrollBar->pageStep() / 4);
+ if (!event->pixelDelta().isNull()) {
+ const int numPixels = event->pixelDelta().y();
+ smoothScroller->scrollTo(scrollBar->value() - numPixels);
+ } else {
+ const int numDegrees = event->angleDelta().y() / 8;
+ const int numSteps = numDegrees / 15;
+ smoothScroller->scrollTo(scrollBar->value() - numSteps * scrollBar->pageStep() / 4);
+ }
event->accept();
}
@@ -211,23 +213,33 @@ void KItemListContainer::slotViewChanged(KItemListView* current, KItemListView*
QGraphicsScene* scene = static_cast<QGraphicsView*>(viewport())->scene();
if (previous) {
scene->removeItem(previous);
- disconnect(previous, SIGNAL(scrollOrientationChanged(Qt::Orientation,Qt::Orientation)), this, SLOT(slotScrollOrientationChanged(Qt::Orientation,Qt::Orientation)));
- disconnect(previous, SIGNAL(scrollOffsetChanged(qreal,qreal)), this, SLOT(updateScrollOffsetScrollBar()));
- disconnect(previous, SIGNAL(maximumScrollOffsetChanged(qreal,qreal)), this, SLOT(updateScrollOffsetScrollBar()));
- disconnect(previous, SIGNAL(itemOffsetChanged(qreal,qreal)), this, SLOT(updateItemOffsetScrollBar()));
- disconnect(previous, SIGNAL(maximumItemOffsetChanged(qreal,qreal)), this, SLOT(updateItemOffsetScrollBar()));
- disconnect(previous, SIGNAL(scrollTo(qreal)), this, SLOT(scrollTo(qreal)));
+ disconnect(previous, &KItemListView::scrollOrientationChanged,
+ this, &KItemListContainer::slotScrollOrientationChanged);
+ disconnect(previous, &KItemListView::scrollOffsetChanged,
+ this, &KItemListContainer::updateScrollOffsetScrollBar);
+ disconnect(previous, &KItemListView::maximumScrollOffsetChanged,
+ this, &KItemListContainer::updateScrollOffsetScrollBar);
+ disconnect(previous, &KItemListView::itemOffsetChanged,
+ this, &KItemListContainer::updateItemOffsetScrollBar);
+ disconnect(previous, &KItemListView::maximumItemOffsetChanged,
+ this, &KItemListContainer::updateItemOffsetScrollBar);
+ disconnect(previous, &KItemListView::scrollTo, this, &KItemListContainer::scrollTo);
m_horizontalSmoothScroller->setTargetObject(0);
m_verticalSmoothScroller->setTargetObject(0);
}
if (current) {
scene->addItem(current);
- connect(current, SIGNAL(scrollOrientationChanged(Qt::Orientation,Qt::Orientation)), this, SLOT(slotScrollOrientationChanged(Qt::Orientation,Qt::Orientation)));
- connect(current, SIGNAL(scrollOffsetChanged(qreal,qreal)), this, SLOT(updateScrollOffsetScrollBar()));
- connect(current, SIGNAL(maximumScrollOffsetChanged(qreal,qreal)), this, SLOT(updateScrollOffsetScrollBar()));
- connect(current, SIGNAL(itemOffsetChanged(qreal,qreal)), this, SLOT(updateItemOffsetScrollBar()));
- connect(current, SIGNAL(maximumItemOffsetChanged(qreal,qreal)), this, SLOT(updateItemOffsetScrollBar()));
- connect(current, SIGNAL(scrollTo(qreal)), this, SLOT(scrollTo(qreal)));
+ connect(current, &KItemListView::scrollOrientationChanged,
+ this, &KItemListContainer::slotScrollOrientationChanged);
+ connect(current, &KItemListView::scrollOffsetChanged,
+ this, &KItemListContainer::updateScrollOffsetScrollBar);
+ connect(current, &KItemListView::maximumScrollOffsetChanged,
+ this, &KItemListContainer::updateScrollOffsetScrollBar);
+ connect(current, &KItemListView::itemOffsetChanged,
+ this, &KItemListContainer::updateItemOffsetScrollBar);
+ connect(current, &KItemListView::maximumItemOffsetChanged,
+ this, &KItemListContainer::updateItemOffsetScrollBar);
+ connect(current, &KItemListView::scrollTo, this, &KItemListContainer::scrollTo);
m_horizontalSmoothScroller->setTargetObject(current);
m_verticalSmoothScroller->setTargetObject(current);
updateSmoothScrollers(current->scrollOrientation());
@@ -403,4 +415,3 @@ void KItemListContainer::updateScrollOffsetScrollBarPolicy()
}
}
-#include "kitemlistcontainer.moc"
diff --git a/src/kitemviews/kitemlistcontainer.h b/src/kitemviews/kitemlistcontainer.h
index 474a9ecc0..9fc3d4957 100644
--- a/src/kitemviews/kitemlistcontainer.h
+++ b/src/kitemviews/kitemlistcontainer.h
@@ -23,16 +23,14 @@
#ifndef KITEMLISTCONTAINER_H
#define KITEMLISTCONTAINER_H
-#include <libdolphin_export.h>
+#include "dolphin_export.h"
-#include <QAbstractAnimation>
#include <QAbstractScrollArea>
class KItemListController;
class KItemListSmoothScroller;
class KItemListView;
class KItemModelBase;
-class QPropertyAnimation;
/**
* @brief Provides a QWidget based scrolling view for a KItemListController.
@@ -41,7 +39,7 @@ class QPropertyAnimation;
*
* @see KItemListController
*/
-class LIBDOLPHINPRIVATE_EXPORT KItemListContainer : public QAbstractScrollArea
+class DOLPHIN_EXPORT KItemListContainer : public QAbstractScrollArea
{
Q_OBJECT
@@ -60,11 +58,11 @@ public:
bool enabledFrame() const;
protected:
- virtual void keyPressEvent(QKeyEvent* event);
- virtual void showEvent(QShowEvent* event);
- virtual void resizeEvent(QResizeEvent* event);
- virtual void scrollContentsBy(int dx, int dy);
- virtual void wheelEvent(QWheelEvent* event);
+ virtual void keyPressEvent(QKeyEvent* event) Q_DECL_OVERRIDE;
+ virtual void showEvent(QShowEvent* event) Q_DECL_OVERRIDE;
+ virtual void resizeEvent(QResizeEvent* event) Q_DECL_OVERRIDE;
+ virtual void scrollContentsBy(int dx, int dy) Q_DECL_OVERRIDE;
+ virtual void wheelEvent(QWheelEvent* event) Q_DECL_OVERRIDE;
private slots:
void slotScrollOrientationChanged(Qt::Orientation current, Qt::Orientation previous);
diff --git a/src/kitemviews/kitemlistcontroller.cpp b/src/kitemviews/kitemlistcontroller.cpp
index 8e2ef5ef3..a9ebf97af 100644
--- a/src/kitemviews/kitemlistcontroller.cpp
+++ b/src/kitemviews/kitemlistcontroller.cpp
@@ -23,8 +23,6 @@
#include "kitemlistcontroller.h"
-#include <KGlobalSettings>
-#include <KDebug>
#include "kitemlistview.h"
#include "kitemlistselectionmanager.h"
@@ -61,15 +59,15 @@ KItemListController::KItemListController(KItemModelBase* model, KItemListView* v
m_keyboardAnchorIndex(-1),
m_keyboardAnchorPos(0)
{
- connect(m_keyboardManager, SIGNAL(changeCurrentItem(QString,bool)),
- this, SLOT(slotChangeCurrentItem(QString,bool)));
- connect(m_selectionManager, SIGNAL(currentChanged(int,int)),
- m_keyboardManager, SLOT(slotCurrentChanged(int,int)));
+ connect(m_keyboardManager, &KItemListKeyboardSearchManager::changeCurrentItem,
+ this, &KItemListController::slotChangeCurrentItem);
+ connect(m_selectionManager, &KItemListSelectionManager::currentChanged,
+ m_keyboardManager, &KItemListKeyboardSearchManager::slotCurrentChanged);
m_autoActivationTimer = new QTimer(this);
m_autoActivationTimer->setSingleShot(true);
m_autoActivationTimer->setInterval(-1);
- connect(m_autoActivationTimer, SIGNAL(timeout()), this, SLOT(slotAutoActivationTimeout()));
+ connect(m_autoActivationTimer, &QTimer::timeout, this, &KItemListController::slotAutoActivationTimeout);
setModel(model);
setView(view);
@@ -127,7 +125,7 @@ void KItemListController::setView(KItemListView* view)
KItemListView* oldView = m_view;
if (oldView) {
- disconnect(oldView, SIGNAL(scrollOffsetChanged(qreal,qreal)), this, SLOT(slotViewScrollOffsetChanged(qreal,qreal)));
+ disconnect(oldView, &KItemListView::scrollOffsetChanged, this, &KItemListController::slotViewScrollOffsetChanged);
oldView->deleteLater();
}
@@ -137,7 +135,7 @@ void KItemListController::setView(KItemListView* view)
m_view->setParent(this);
m_view->setController(this);
m_view->setModel(m_model);
- connect(m_view, SIGNAL(scrollOffsetChanged(qreal,qreal)), this, SLOT(slotViewScrollOffsetChanged(qreal,qreal)));
+ connect(m_view, &KItemListView::scrollOffsetChanged, this, &KItemListController::slotViewScrollOffsetChanged);
updateExtendedSelectionRegion();
}
@@ -538,8 +536,7 @@ bool KItemListController::mousePressEvent(QGraphicsSceneMouseEvent* event, const
m_pressedIndex = m_view->itemAt(m_pressedMousePos);
emit mouseButtonPressed(m_pressedIndex, event->buttons());
- // TODO: Qt5: Replace Qt::XButton1 by Qt::BackButton and Qt::XButton2 by Qt::ForwardButton
- if (event->buttons() & (Qt::XButton1 | Qt::XButton2)) {
+ if (event->buttons() & (Qt::BackButton | Qt::ForwardButton)) {
// Do not select items when clicking the back/forward buttons, see
// https://bugs.kde.org/show_bug.cgi?id=327412.
return true;
@@ -655,7 +652,7 @@ bool KItemListController::mousePressEvent(QGraphicsSceneMouseEvent* event, const
rubberBand->setStartPosition(startPos);
rubberBand->setEndPosition(startPos);
rubberBand->setActive(true);
- connect(rubberBand, SIGNAL(endPositionChanged(QPointF,QPointF)), this, SLOT(slotRubberBandChanged()));
+ connect(rubberBand, &KItemListRubberBand::endPositionChanged, this, &KItemListController::slotRubberBandChanged);
m_view->setAutoScroll(true);
}
@@ -743,7 +740,7 @@ bool KItemListController::mouseReleaseEvent(QGraphicsSceneMouseEvent* event, con
KItemListRubberBand* rubberBand = m_view->rubberBand();
if (rubberBand->isActive()) {
- disconnect(rubberBand, SIGNAL(endPositionChanged(QPointF,QPointF)), this, SLOT(slotRubberBandChanged()));
+ disconnect(rubberBand, &KItemListRubberBand::endPositionChanged, this, &KItemListController::slotRubberBandChanged);
rubberBand->setActive(false);
m_oldSelection.clear();
m_view->setAutoScroll(false);
@@ -774,7 +771,7 @@ bool KItemListController::mouseReleaseEvent(QGraphicsSceneMouseEvent* event, con
} else if (shiftOrControlPressed) {
// The mouse click should only update the selection, not trigger the item
emitItemActivated = false;
- } else if (!(KGlobalSettings::singleClick() || m_singleClickActivationEnforced)) {
+ } else if (!(m_view->style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick) || m_singleClickActivationEnforced)) {
emitItemActivated = false;
}
if (emitItemActivated) {
@@ -804,7 +801,7 @@ bool KItemListController::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event,
}
}
- bool emitItemActivated = !(KGlobalSettings::singleClick() || m_singleClickActivationEnforced) &&
+ bool emitItemActivated = !(m_view->style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick) || m_singleClickActivationEnforced) &&
(event->button() & Qt::LeftButton) &&
index >= 0 && index < m_model->count();
if (emitItemActivated) {
@@ -920,7 +917,8 @@ bool KItemListController::dropEvent(QGraphicsSceneDragDropEvent* event, const QT
emit itemDropEvent(m_view->itemAt(pos), event);
}
- QAccessible::updateAccessibility(view(), 0, QAccessible::DragDropEnd);
+ QAccessibleEvent accessibilityEvent(view(), QAccessible::DragDropEnd);
+ QAccessible::updateAccessibility(&accessibilityEvent);
return true;
}
@@ -1174,7 +1172,9 @@ void KItemListController::startDragging()
drag->setHotSpot(hotSpot);
drag->exec(Qt::MoveAction | Qt::CopyAction | Qt::LinkAction, Qt::CopyAction);
- QAccessible::updateAccessibility(view(), 0, QAccessible::DragDropStart);
+
+ QAccessibleEvent accessibilityEvent(view(), QAccessible::DragDropStart);
+ QAccessible::updateAccessibility(&accessibilityEvent);
}
KItemListWidget* KItemListController::hoveredWidget() const
@@ -1310,4 +1310,3 @@ void KItemListController::updateExtendedSelectionRegion()
}
}
-#include "kitemlistcontroller.moc"
diff --git a/src/kitemviews/kitemlistcontroller.h b/src/kitemviews/kitemlistcontroller.h
index e9b70cdda..b8a93edac 100644
--- a/src/kitemviews/kitemlistcontroller.h
+++ b/src/kitemviews/kitemlistcontroller.h
@@ -23,14 +23,13 @@
#ifndef KITEMLISTCONTROLLER_H
#define KITEMLISTCONTROLLER_H
-#include <libdolphin_export.h>
+#include "dolphin_export.h"
#include "kitemset.h"
#include <QObject>
-#include <QPixmap>
#include <QPointF>
-
+class QTimer;
class KItemModelBase;
class KItemListKeyboardSearchManager;
class KItemListSelectionManager;
@@ -44,7 +43,6 @@ class QGraphicsSceneWheelEvent;
class QHideEvent;
class QInputMethodEvent;
class QKeyEvent;
-class QMimeData;
class QShowEvent;
class QTransform;
@@ -58,7 +56,7 @@ class QTransform;
* @see KItemModelBase
* @see KItemListSelectionManager
*/
-class LIBDOLPHINPRIVATE_EXPORT KItemListController : public QObject
+class DOLPHIN_EXPORT KItemListController : public QObject
{
Q_OBJECT
Q_ENUMS(SelectionBehavior)
@@ -131,7 +129,7 @@ public:
/**
* If set to true, the signals itemActivated() and itemsActivated() are emitted
* after a single-click of the left mouse button. If set to false (the default),
- * the setting from KGlobalSettings::singleClick() is used.
+ * the setting from style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick) is used.
*/
void setSingleClickActivationEnforced(bool singleClick);
bool singleClickActivationEnforced() const;
diff --git a/src/kitemviews/kitemlistgroupheader.cpp b/src/kitemviews/kitemlistgroupheader.cpp
index 17c95a97c..f8576b08c 100644
--- a/src/kitemviews/kitemlistgroupheader.cpp
+++ b/src/kitemviews/kitemlistgroupheader.cpp
@@ -27,7 +27,6 @@
#include <QGraphicsSceneResizeEvent>
#include <QPainter>
#include <QStyleOptionGraphicsItem>
-#include <KDebug>
KItemListGroupHeader::KItemListGroupHeader(QGraphicsWidget* parent) :
QGraphicsWidget(parent, 0),
@@ -233,4 +232,3 @@ QColor KItemListGroupHeader::baseColor() const
return styleOption().palette.color(group, normalBaseColorRole());
}
-#include "kitemlistgroupheader.moc"
diff --git a/src/kitemviews/kitemlistgroupheader.h b/src/kitemviews/kitemlistgroupheader.h
index 1e8ed2cca..4612bc4da 100644
--- a/src/kitemviews/kitemlistgroupheader.h
+++ b/src/kitemviews/kitemlistgroupheader.h
@@ -20,7 +20,7 @@
#ifndef KITEMLISTGROUPHEADER_H
#define KITEMLISTGROUPHEADER_H
-#include <libdolphin_export.h>
+#include "dolphin_export.h"
#include <kitemviews/kitemliststyleoption.h>
@@ -37,7 +37,7 @@ class KItemListView;
* the method paint() and draw the role within the given roleBounds() with
* the color roleColor().
*/
-class LIBDOLPHINPRIVATE_EXPORT KItemListGroupHeader : public QGraphicsWidget
+class DOLPHIN_EXPORT KItemListGroupHeader : public QGraphicsWidget
{
Q_OBJECT
@@ -65,7 +65,7 @@ public:
void setItemIndex(int index);
int itemIndex() const;
- virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
+ virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0) Q_DECL_OVERRIDE;
protected:
virtual void paintRole(QPainter* painter, const QRectF& roleBounds, const QColor& color) = 0;
@@ -101,8 +101,7 @@ protected:
*/
virtual void itemIndexChanged(int current, int previous);
- /** @reimp */
- virtual void resizeEvent(QGraphicsSceneResizeEvent* event);
+ virtual void resizeEvent(QGraphicsSceneResizeEvent* event) Q_DECL_OVERRIDE;
virtual QPalette::ColorRole normalTextColorRole() const;
virtual QPalette::ColorRole normalBaseColorRole() const;
diff --git a/src/kitemviews/kitemlistheader.cpp b/src/kitemviews/kitemlistheader.cpp
index e89ece0a1..a3fa14d35 100644
--- a/src/kitemviews/kitemlistheader.cpp
+++ b/src/kitemviews/kitemlistheader.cpp
@@ -81,8 +81,7 @@ KItemListHeader::KItemListHeader(KItemListView* listView) :
m_headerWidget = m_view->m_headerWidget;
Q_ASSERT(m_headerWidget);
- connect(m_headerWidget, SIGNAL(columnWidthChanged(QByteArray,qreal,qreal)),
- this, SIGNAL(columnWidthChanged(QByteArray,qreal,qreal)));
+ connect(m_headerWidget, &KItemListHeaderWidget::columnWidthChanged,
+ this, &KItemListHeader::columnWidthChanged);
}
-#include "kitemlistheader.moc"
diff --git a/src/kitemviews/kitemlistheader.h b/src/kitemviews/kitemlistheader.h
index fe2d0ac10..cc2b74793 100644
--- a/src/kitemviews/kitemlistheader.h
+++ b/src/kitemviews/kitemlistheader.h
@@ -20,7 +20,7 @@
#ifndef KITEMLISTHEADER_H
#define KITEMLISTHEADER_H
-#include <libdolphin_export.h>
+#include "dolphin_export.h"
#include <QHash>
#include <QObject>
@@ -33,7 +33,7 @@ class KItemListView;
* Each column of the header represents a visible role
* accessible by KItemListView::visibleRoles().
*/
-class LIBDOLPHINPRIVATE_EXPORT KItemListHeader : public QObject
+class DOLPHIN_EXPORT KItemListHeader : public QObject
{
Q_OBJECT
diff --git a/src/kitemviews/kitemlistselectionmanager.cpp b/src/kitemviews/kitemlistselectionmanager.cpp
index 1f0a89d06..46b77f7e4 100644
--- a/src/kitemviews/kitemlistselectionmanager.cpp
+++ b/src/kitemviews/kitemlistselectionmanager.cpp
@@ -24,7 +24,6 @@
#include "kitemlistselectionmanager.h"
#include "kitemmodelbase.h"
-#include <KDebug>
KItemListSelectionManager::KItemListSelectionManager(QObject* parent) :
QObject(parent),
@@ -396,4 +395,4 @@ int KItemListSelectionManager::indexAfterRangesRemoving(int index, const KItemRa
}
return qBound(-1, index - dec, m_model->count() - 1);
}
-#include "kitemlistselectionmanager.moc"
+
diff --git a/src/kitemviews/kitemlistselectionmanager.h b/src/kitemviews/kitemlistselectionmanager.h
index c4decd39e..16761428b 100644
--- a/src/kitemviews/kitemlistselectionmanager.h
+++ b/src/kitemviews/kitemlistselectionmanager.h
@@ -23,7 +23,7 @@
#ifndef KITEMLISTSELECTIONMANAGER_H
#define KITEMLISTSELECTIONMANAGER_H
-#include <libdolphin_export.h>
+#include "dolphin_export.h"
#include <kitemviews/kitemmodelbase.h>
#include <kitemviews/kitemset.h>
@@ -35,7 +35,7 @@ class KItemModelBase;
/**
* @brief Allows to select and deselect items of a KItemListView.
*/
-class LIBDOLPHINPRIVATE_EXPORT KItemListSelectionManager : public QObject
+class DOLPHIN_EXPORT KItemListSelectionManager : public QObject
{
Q_OBJECT
diff --git a/src/kitemviews/kitemliststyleoption.cpp b/src/kitemviews/kitemliststyleoption.cpp
index edd6363c8..1ebcad141 100644
--- a/src/kitemviews/kitemliststyleoption.cpp
+++ b/src/kitemviews/kitemliststyleoption.cpp
@@ -19,7 +19,6 @@
#include "kitemliststyleoption.h"
-#include <KIconLoader>
KItemListStyleOption::KItemListStyleOption() :
rect(),
diff --git a/src/kitemviews/kitemliststyleoption.h b/src/kitemviews/kitemliststyleoption.h
index 782dd0ec2..09b787c27 100644
--- a/src/kitemviews/kitemliststyleoption.h
+++ b/src/kitemviews/kitemliststyleoption.h
@@ -20,14 +20,14 @@
#ifndef KITEMLISTSTYLEOPTION_H
#define KITEMLISTSTYLEOPTION_H
-#include <libdolphin_export.h>
+#include "dolphin_export.h"
#include <QFont>
#include <QFontMetrics>
#include <QPalette>
#include <QRect>
-class LIBDOLPHINPRIVATE_EXPORT KItemListStyleOption
+class DOLPHIN_EXPORT KItemListStyleOption
{
public:
KItemListStyleOption();
diff --git a/src/kitemviews/kitemlistview.cpp b/src/kitemviews/kitemlistview.cpp
index 756f9e39a..9416f0dd7 100644
--- a/src/kitemviews/kitemlistview.cpp
+++ b/src/kitemviews/kitemlistview.cpp
@@ -22,7 +22,7 @@
#include "kitemlistview.h"
-#include <KDebug>
+#include "dolphindebug.h"
#include "kitemlistcontainer.h"
#include "kitemlistcontroller.h"
#include "kitemlistheader.h"
@@ -35,14 +35,13 @@
#include "private/kitemlistviewlayouter.h"
#include "private/kitemlistviewanimation.h"
-#include <QCursor>
#include <QGraphicsSceneMouseEvent>
#include <QGraphicsView>
#include <QPainter>
-#include <QPropertyAnimation>
#include <QStyle>
#include <QStyleOptionRubberBand>
#include <QTimer>
+#include <QElapsedTimer>
#include <algorithm>
@@ -58,7 +57,7 @@ namespace {
}
#ifndef QT_NO_ACCESSIBILITY
-QAccessibleInterface* accessibleInterfaceFactory(const QString &key, QObject *object)
+QAccessibleInterface* accessibleInterfaceFactory(const QString& key, QObject* object)
{
Q_UNUSED(key)
@@ -114,16 +113,16 @@ KItemListView::KItemListView(QGraphicsWidget* parent) :
m_layouter = new KItemListViewLayouter(m_sizeHintResolver, this);
m_animation = new KItemListViewAnimation(this);
- connect(m_animation, SIGNAL(finished(QGraphicsWidget*,KItemListViewAnimation::AnimationType)),
- this, SLOT(slotAnimationFinished(QGraphicsWidget*,KItemListViewAnimation::AnimationType)));
+ connect(m_animation, &KItemListViewAnimation::finished,
+ this, &KItemListView::slotAnimationFinished);
m_layoutTimer = new QTimer(this);
m_layoutTimer->setInterval(300);
m_layoutTimer->setSingleShot(true);
- connect(m_layoutTimer, SIGNAL(timeout()), this, SLOT(slotLayoutTimerFinished()));
+ connect(m_layoutTimer, &QTimer::timeout, this, &KItemListView::slotLayoutTimerFinished);
m_rubberBand = new KItemListRubberBand(this);
- connect(m_rubberBand, SIGNAL(activationChanged(bool)), this, SLOT(slotRubberBandActivationChanged(bool)));
+ connect(m_rubberBand, &KItemListRubberBand::activationChanged, this, &KItemListView::slotRubberBandActivationChanged);
m_headerWidget = new KItemListHeaderWidget(this);
m_headerWidget->setVisible(false);
@@ -267,7 +266,7 @@ void KItemListView::setAutoScroll(bool enabled)
if (enabled && !m_autoScrollTimer) {
m_autoScrollTimer = new QTimer(this);
m_autoScrollTimer->setSingleShot(true);
- connect(m_autoScrollTimer, SIGNAL(timeout()), this, SLOT(triggerAutoScrolling()));
+ connect(m_autoScrollTimer, &QTimer::timeout, this, &KItemListView::triggerAutoScrolling);
m_autoScrollTimer->start(InitialAutoScrollDelay);
} else if (!enabled && m_autoScrollTimer) {
delete m_autoScrollTimer;
@@ -544,7 +543,7 @@ void KItemListView::endTransaction()
--m_activeTransactions;
if (m_activeTransactions < 0) {
m_activeTransactions = 0;
- kWarning() << "Mismatch between beginTransaction()/endTransaction()";
+ qCWarning(DolphinDebug) << "Mismatch between beginTransaction()/endTransaction()";
}
if (m_activeTransactions == 0) {
@@ -572,26 +571,26 @@ void KItemListView::setHeaderVisible(bool visible)
m_headerWidget->setColumns(m_visibleRoles);
m_headerWidget->setZValue(1);
- connect(m_headerWidget, SIGNAL(columnWidthChanged(QByteArray,qreal,qreal)),
- this, SLOT(slotHeaderColumnWidthChanged(QByteArray,qreal,qreal)));
- connect(m_headerWidget, SIGNAL(columnMoved(QByteArray,int,int)),
- this, SLOT(slotHeaderColumnMoved(QByteArray,int,int)));
- connect(m_headerWidget, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder)),
- this, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder)));
- connect(m_headerWidget, SIGNAL(sortRoleChanged(QByteArray,QByteArray)),
- this, SIGNAL(sortRoleChanged(QByteArray,QByteArray)));
+ connect(m_headerWidget, &KItemListHeaderWidget::columnWidthChanged,
+ this, &KItemListView::slotHeaderColumnWidthChanged);
+ connect(m_headerWidget, &KItemListHeaderWidget::columnMoved,
+ this, &KItemListView::slotHeaderColumnMoved);
+ connect(m_headerWidget, &KItemListHeaderWidget::sortOrderChanged,
+ this, &KItemListView::sortOrderChanged);
+ connect(m_headerWidget, &KItemListHeaderWidget::sortRoleChanged,
+ this, &KItemListView::sortRoleChanged);
m_layouter->setHeaderHeight(headerSize.height());
m_headerWidget->setVisible(true);
} else if (!visible && m_headerWidget->isVisible()) {
- disconnect(m_headerWidget, SIGNAL(columnWidthChanged(QByteArray,qreal,qreal)),
- this, SLOT(slotHeaderColumnWidthChanged(QByteArray,qreal,qreal)));
- disconnect(m_headerWidget, SIGNAL(columnMoved(QByteArray,int,int)),
- this, SLOT(slotHeaderColumnMoved(QByteArray,int,int)));
- disconnect(m_headerWidget, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder)),
- this, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder)));
- disconnect(m_headerWidget, SIGNAL(sortRoleChanged(QByteArray,QByteArray)),
- this, SIGNAL(sortRoleChanged(QByteArray,QByteArray)));
+ disconnect(m_headerWidget, &KItemListHeaderWidget::columnWidthChanged,
+ this, &KItemListView::slotHeaderColumnWidthChanged);
+ disconnect(m_headerWidget, &KItemListHeaderWidget::columnMoved,
+ this, &KItemListView::slotHeaderColumnMoved);
+ disconnect(m_headerWidget, &KItemListHeaderWidget::sortOrderChanged,
+ this, &KItemListView::sortOrderChanged);
+ disconnect(m_headerWidget, &KItemListHeaderWidget::sortRoleChanged,
+ this, &KItemListView::sortRoleChanged);
m_layouter->setHeaderHeight(0);
m_headerWidget->setVisible(false);
@@ -637,10 +636,10 @@ void KItemListView::editRole(int index, const QByteArray& role)
m_editingRole = true;
widget->setEditedRole(role);
- connect(widget, SIGNAL(roleEditingCanceled(int,QByteArray,QVariant)),
- this, SLOT(slotRoleEditingCanceled(int,QByteArray,QVariant)));
- connect(widget, SIGNAL(roleEditingFinished(int,QByteArray,QVariant)),
- this, SLOT(slotRoleEditingFinished(int,QByteArray,QVariant)));
+ connect(widget, &KItemListWidget::roleEditingCanceled,
+ this, &KItemListView::slotRoleEditingCanceled);
+ connect(widget, &KItemListWidget::roleEditingFinished,
+ this, &KItemListView::slotRoleEditingFinished);
}
void KItemListView::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
@@ -936,7 +935,7 @@ void KItemListView::dragEnterEvent(QGraphicsSceneDragDropEvent* event)
setAutoScroll(true);
}
-void KItemListView::dragMoveEvent(QGraphicsSceneDragDropEvent *event)
+void KItemListView::dragMoveEvent(QGraphicsSceneDragDropEvent* event)
{
QGraphicsWidget::dragMoveEvent(event);
@@ -946,7 +945,7 @@ void KItemListView::dragMoveEvent(QGraphicsSceneDragDropEvent *event)
}
}
-void KItemListView::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)
+void KItemListView::dragLeaveEvent(QGraphicsSceneDragDropEvent* event)
{
QGraphicsWidget::dragLeaveEvent(event);
setAutoScroll(false);
@@ -1007,7 +1006,7 @@ void KItemListView::slotItemsInserted(const KItemRangeList& itemRanges)
const int index = range.index + previouslyInsertedCount;
const int count = range.count;
if (index < 0 || count <= 0) {
- kWarning() << "Invalid item range (index:" << index << ", count:" << count << ")";
+ qCWarning(DolphinDebug) << "Invalid item range (index:" << index << ", count:" << count << ")";
continue;
}
previouslyInsertedCount += count;
@@ -1115,7 +1114,7 @@ void KItemListView::slotItemsRemoved(const KItemRangeList& itemRanges)
const int index = range.index;
const int count = range.count;
if (index < 0 || count <= 0) {
- kWarning() << "Invalid item range (index:" << index << ", count:" << count << ")";
+ qCWarning(DolphinDebug) << "Invalid item range (index:" << index << ", count:" << count << ")";
continue;
}
@@ -1268,8 +1267,12 @@ void KItemListView::slotItemsChanged(const KItemRangeList& itemRanges,
updateVisibleGroupHeaders();
doLayout(NoAnimation);
}
+
+ QAccessibleTableModelChangeEvent ev(this, QAccessibleTableModelChangeEvent::DataChanged);
+ ev.setFirstRow(itemRange.index);
+ ev.setLastRow(itemRange.index + itemRange.count);
+ QAccessible::updateAccessibility(&ev);
}
- QAccessible::updateAccessibility(this, 0, QAccessible::TableModelChanged);
}
void KItemListView::slotGroupsChanged()
@@ -1345,7 +1348,10 @@ void KItemListView::slotCurrentChanged(int current, int previous)
currentWidget->setCurrent(true);
}
}
- QAccessible::updateAccessibility(this, current+1, QAccessible::Focus);
+
+ QAccessibleEvent ev(this, QAccessible::Focus);
+ ev.setChild(current);
+ QAccessible::updateAccessibility(&ev);
}
void KItemListView::slotSelectionChanged(const KItemSet& current, const KItemSet& previous)
@@ -1412,12 +1418,12 @@ void KItemListView::slotRubberBandPosChanged()
void KItemListView::slotRubberBandActivationChanged(bool active)
{
if (active) {
- connect(m_rubberBand, SIGNAL(startPositionChanged(QPointF,QPointF)), this, SLOT(slotRubberBandPosChanged()));
- connect(m_rubberBand, SIGNAL(endPositionChanged(QPointF,QPointF)), this, SLOT(slotRubberBandPosChanged()));
+ connect(m_rubberBand, &KItemListRubberBand::startPositionChanged, this, &KItemListView::slotRubberBandPosChanged);
+ connect(m_rubberBand, &KItemListRubberBand::endPositionChanged, this, &KItemListView::slotRubberBandPosChanged);
m_skipAutoScrollForRubberBand = true;
} else {
- disconnect(m_rubberBand, SIGNAL(startPositionChanged(QPointF,QPointF)), this, SLOT(slotRubberBandPosChanged()));
- disconnect(m_rubberBand, SIGNAL(endPositionChanged(QPointF,QPointF)), this, SLOT(slotRubberBandPosChanged()));
+ disconnect(m_rubberBand, &KItemListRubberBand::startPositionChanged, this, &KItemListView::slotRubberBandPosChanged);
+ disconnect(m_rubberBand, &KItemListRubberBand::endPositionChanged, this, &KItemListView::slotRubberBandPosChanged);
m_skipAutoScrollForRubberBand = false;
}
@@ -1544,16 +1550,16 @@ void KItemListView::setController(KItemListController* controller)
KItemListController* previous = m_controller;
if (previous) {
KItemListSelectionManager* selectionManager = previous->selectionManager();
- disconnect(selectionManager, SIGNAL(currentChanged(int,int)), this, SLOT(slotCurrentChanged(int,int)));
- disconnect(selectionManager, SIGNAL(selectionChanged(KItemSet,KItemSet)), this, SLOT(slotSelectionChanged(KItemSet,KItemSet)));
+ disconnect(selectionManager, &KItemListSelectionManager::currentChanged, this, &KItemListView::slotCurrentChanged);
+ disconnect(selectionManager, &KItemListSelectionManager::selectionChanged, this, &KItemListView::slotSelectionChanged);
}
m_controller = controller;
if (controller) {
KItemListSelectionManager* selectionManager = controller->selectionManager();
- connect(selectionManager, SIGNAL(currentChanged(int,int)), this, SLOT(slotCurrentChanged(int,int)));
- connect(selectionManager, SIGNAL(selectionChanged(KItemSet,KItemSet)), this, SLOT(slotSelectionChanged(KItemSet,KItemSet)));
+ connect(selectionManager, &KItemListSelectionManager::currentChanged, this, &KItemListView::slotCurrentChanged);
+ connect(selectionManager, &KItemListSelectionManager::selectionChanged, this, &KItemListView::slotSelectionChanged);
}
onControllerChanged(controller, previous);
@@ -1569,22 +1575,22 @@ void KItemListView::setModel(KItemModelBase* model)
KItemModelBase* previous = m_model;
if (m_model) {
- disconnect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
- this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
- disconnect(m_model, SIGNAL(itemsInserted(KItemRangeList)),
- this, SLOT(slotItemsInserted(KItemRangeList)));
- disconnect(m_model, SIGNAL(itemsRemoved(KItemRangeList)),
- this, SLOT(slotItemsRemoved(KItemRangeList)));
- disconnect(m_model, SIGNAL(itemsMoved(KItemRange,QList<int>)),
- this, SLOT(slotItemsMoved(KItemRange,QList<int>)));
- disconnect(m_model, SIGNAL(groupsChanged()),
- this, SLOT(slotGroupsChanged()));
- disconnect(m_model, SIGNAL(groupedSortingChanged(bool)),
- this, SLOT(slotGroupedSortingChanged(bool)));
- disconnect(m_model, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder)),
- this, SLOT(slotSortOrderChanged(Qt::SortOrder,Qt::SortOrder)));
- disconnect(m_model, SIGNAL(sortRoleChanged(QByteArray,QByteArray)),
- this, SLOT(slotSortRoleChanged(QByteArray,QByteArray)));
+ disconnect(m_model, &KItemModelBase::itemsChanged,
+ this, &KItemListView::slotItemsChanged);
+ disconnect(m_model, &KItemModelBase::itemsInserted,
+ this, &KItemListView::slotItemsInserted);
+ disconnect(m_model, &KItemModelBase::itemsRemoved,
+ this, &KItemListView::slotItemsRemoved);
+ disconnect(m_model, &KItemModelBase::itemsMoved,
+ this, &KItemListView::slotItemsMoved);
+ disconnect(m_model, &KItemModelBase::groupsChanged,
+ this, &KItemListView::slotGroupsChanged);
+ disconnect(m_model, &KItemModelBase::groupedSortingChanged,
+ this, &KItemListView::slotGroupedSortingChanged);
+ disconnect(m_model, &KItemModelBase::sortOrderChanged,
+ this, &KItemListView::slotSortOrderChanged);
+ disconnect(m_model, &KItemModelBase::sortRoleChanged,
+ this, &KItemListView::slotSortRoleChanged);
m_sizeHintResolver->itemsRemoved(KItemRangeList() << KItemRange(0, m_model->count()));
}
@@ -1594,22 +1600,22 @@ void KItemListView::setModel(KItemModelBase* model)
m_grouped = model->groupedSorting();
if (m_model) {
- connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
- this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
- connect(m_model, SIGNAL(itemsInserted(KItemRangeList)),
- this, SLOT(slotItemsInserted(KItemRangeList)));
- connect(m_model, SIGNAL(itemsRemoved(KItemRangeList)),
- this, SLOT(slotItemsRemoved(KItemRangeList)));
- connect(m_model, SIGNAL(itemsMoved(KItemRange,QList<int>)),
- this, SLOT(slotItemsMoved(KItemRange,QList<int>)));
- connect(m_model, SIGNAL(groupsChanged()),
- this, SLOT(slotGroupsChanged()));
- connect(m_model, SIGNAL(groupedSortingChanged(bool)),
- this, SLOT(slotGroupedSortingChanged(bool)));
- connect(m_model, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder)),
- this, SLOT(slotSortOrderChanged(Qt::SortOrder,Qt::SortOrder)));
- connect(m_model, SIGNAL(sortRoleChanged(QByteArray,QByteArray)),
- this, SLOT(slotSortRoleChanged(QByteArray,QByteArray)));
+ connect(m_model, &KItemModelBase::itemsChanged,
+ this, &KItemListView::slotItemsChanged);
+ connect(m_model, &KItemModelBase::itemsInserted,
+ this, &KItemListView::slotItemsInserted);
+ connect(m_model, &KItemModelBase::itemsRemoved,
+ this, &KItemListView::slotItemsRemoved);
+ connect(m_model, &KItemModelBase::itemsMoved,
+ this, &KItemListView::slotItemsMoved);
+ connect(m_model, &KItemModelBase::groupsChanged,
+ this, &KItemListView::slotGroupsChanged);
+ connect(m_model, &KItemModelBase::groupedSortingChanged,
+ this, &KItemListView::slotGroupedSortingChanged);
+ connect(m_model, &KItemModelBase::sortOrderChanged,
+ this, &KItemListView::slotSortOrderChanged);
+ connect(m_model, &KItemModelBase::sortRoleChanged,
+ this, &KItemListView::slotSortRoleChanged);
const int itemCount = m_model->count();
if (itemCount > 0) {
@@ -2023,7 +2029,7 @@ void KItemListView::updateGroupHeaderForWidget(KItemListWidget* widget)
groupHeader = groupHeaderCreator()->create(this);
groupHeader->setParentItem(widget);
m_visibleGroups.insert(widget, groupHeader);
- connect(widget, SIGNAL(geometryChanged()), this, SLOT(slotGeometryOfGroupHeaderParentChanged()));
+ connect(widget, &KItemListWidget::geometryChanged, this, &KItemListView::slotGeometryOfGroupHeaderParentChanged);
}
Q_ASSERT(groupHeader->parentItem() == widget);
@@ -2070,7 +2076,7 @@ void KItemListView::recycleGroupHeaderForWidget(KItemListWidget* widget)
header->setParentItem(0);
groupHeaderCreator()->recycle(header);
m_visibleGroups.remove(widget);
- disconnect(widget, SIGNAL(geometryChanged()), this, SLOT(slotGeometryOfGroupHeaderParentChanged()));
+ disconnect(widget, &KItemListWidget::geometryChanged, this, &KItemListView::slotGeometryOfGroupHeaderParentChanged);
}
}
@@ -2624,8 +2630,8 @@ void KItemListView::disconnectRoleEditingSignals(int index)
return;
}
- widget->disconnect(SIGNAL(roleEditingCanceled(int,QByteArray,QVariant)), this);
- widget->disconnect(SIGNAL(roleEditingFinished(int,QByteArray,QVariant)), this);
+ disconnect(widget, &KItemListWidget::roleEditingCanceled, this, nullptr);
+ disconnect(widget, &KItemListWidget::roleEditingFinished, this, nullptr);
}
int KItemListView::calculateAutoScrollingIncrement(int pos, int range, int oldInc)
@@ -2719,4 +2725,3 @@ void KItemListGroupHeaderCreatorBase::recycle(KItemListGroupHeader* header)
pushRecycleableWidget(header);
}
-#include "kitemlistview.moc"
diff --git a/src/kitemviews/kitemlistview.h b/src/kitemviews/kitemlistview.h
index cf6f27c03..f20180289 100644
--- a/src/kitemviews/kitemlistview.h
+++ b/src/kitemviews/kitemlistview.h
@@ -23,7 +23,7 @@
#ifndef KITEMLISTVIEW_H
#define KITEMLISTVIEW_H
-#include <libdolphin_export.h>
+#include "dolphin_export.h"
#include <kitemviews/kstandarditemlistgroupheader.h>
#include <kitemviews/kitemliststyleoption.h>
@@ -44,7 +44,6 @@ class KItemListViewLayouter;
class KItemListWidget;
class KItemListWidgetInformant;
class KItemListWidgetCreatorBase;
-class KItemListViewCreatorBase;
class QTimer;
/**
@@ -60,7 +59,7 @@ class QTimer;
* @see KItemListWidget
* @see KItemModelBase
*/
-class LIBDOLPHINPRIVATE_EXPORT KItemListView : public QGraphicsWidget
+class DOLPHIN_EXPORT KItemListView : public QGraphicsWidget
{
Q_OBJECT
@@ -161,8 +160,7 @@ public:
const KItemListStyleOption& styleOption() const;
- /** @reimp */
- virtual void setGeometry(const QRectF& rect);
+ virtual void setGeometry(const QRectF& rect) Q_DECL_OVERRIDE;
/**
* @return The page step which should be used by the vertical scroll bar.
@@ -280,10 +278,7 @@ public:
*/
void editRole(int index, const QByteArray& role);
- /**
- * @reimp
- */
- virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
+ virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0) Q_DECL_OVERRIDE;
signals:
void scrollOrientationChanged(Qt::Orientation current, Qt::Orientation previous);
@@ -323,7 +318,7 @@ signals:
void roleEditingFinished(int index, const QByteArray& role, const QVariant& value);
protected:
- virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
+ virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value) Q_DECL_OVERRIDE;
void setItemSize(const QSizeF& size);
void setStyleOption(const KItemListStyleOption& option);
@@ -380,13 +375,13 @@ protected:
virtual void onTransactionBegin();
virtual void onTransactionEnd();
- virtual bool event(QEvent* event);
- virtual void mousePressEvent(QGraphicsSceneMouseEvent* event);
- virtual void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
- virtual void dragEnterEvent(QGraphicsSceneDragDropEvent* event);
- virtual void dragMoveEvent(QGraphicsSceneDragDropEvent* event);
- virtual void dragLeaveEvent(QGraphicsSceneDragDropEvent* event);
- virtual void dropEvent(QGraphicsSceneDragDropEvent* event);
+ virtual bool event(QEvent* event) Q_DECL_OVERRIDE;
+ virtual void mousePressEvent(QGraphicsSceneMouseEvent* event) Q_DECL_OVERRIDE;
+ virtual void mouseMoveEvent(QGraphicsSceneMouseEvent* event) Q_DECL_OVERRIDE;
+ virtual void dragEnterEvent(QGraphicsSceneDragDropEvent* event) Q_DECL_OVERRIDE;
+ virtual void dragMoveEvent(QGraphicsSceneDragDropEvent* event) Q_DECL_OVERRIDE;
+ virtual void dragLeaveEvent(QGraphicsSceneDragDropEvent* event) Q_DECL_OVERRIDE;
+ virtual void dropEvent(QGraphicsSceneDragDropEvent* event) Q_DECL_OVERRIDE;
QList<KItemListWidget*> visibleItemListWidgets() const;
@@ -774,7 +769,7 @@ private:
* KItemListWidgetCreatorBase and KItemListGroupHeaderCreatorBase.
* @internal
*/
-class LIBDOLPHINPRIVATE_EXPORT KItemListCreatorBase
+class DOLPHIN_EXPORT KItemListCreatorBase
{
public:
virtual ~KItemListCreatorBase();
@@ -798,7 +793,7 @@ private:
* expensive instantiations and deletions of KItemListWidgets by recycling existing widget
* instances.
*/
-class LIBDOLPHINPRIVATE_EXPORT KItemListWidgetCreatorBase : public KItemListCreatorBase
+class DOLPHIN_EXPORT KItemListWidgetCreatorBase : public KItemListCreatorBase
{
public:
virtual ~KItemListWidgetCreatorBase();
@@ -880,7 +875,7 @@ qreal KItemListWidgetCreator<T>::preferredRoleColumnWidth(const QByteArray& role
* The intention of the group-header creator is to prevent repetitive and expensive instantiations and
* deletions of KItemListGroupHeaders by recycling existing header instances.
*/
-class LIBDOLPHINPRIVATE_EXPORT KItemListGroupHeaderCreatorBase : public KItemListCreatorBase
+class DOLPHIN_EXPORT KItemListGroupHeaderCreatorBase : public KItemListCreatorBase
{
public:
virtual ~KItemListGroupHeaderCreatorBase();
diff --git a/src/kitemviews/kitemlistviewaccessible.cpp b/src/kitemviews/kitemlistviewaccessible.cpp
index d9ddd58f8..7b1605a0c 100644
--- a/src/kitemviews/kitemlistviewaccessible.cpp
+++ b/src/kitemviews/kitemlistviewaccessible.cpp
@@ -27,11 +27,10 @@
#include "kitemlistview.h"
#include "private/kitemlistviewlayouter.h"
-#include <QtGui/qaccessible2.h>
+#include <qaccessible.h>
#include <qgraphicsscene.h>
#include <qgraphicsview.h>
-#include <KDebug>
#include <QHash>
KItemListView* KItemListViewAccessible::view() const
@@ -40,35 +39,52 @@ KItemListView* KItemListViewAccessible::view() const
}
KItemListViewAccessible::KItemListViewAccessible(KItemListView* view_) :
- QAccessibleObjectEx(view_)
+ QAccessibleObject(view_)
{
Q_ASSERT(view());
+ m_cells.resize(childCount());
}
-void KItemListViewAccessible::modelReset()
+KItemListViewAccessible::~KItemListViewAccessible()
{
+ foreach (QAccessibleInterface* child, m_cells) {
+ if (child) {
+ QAccessible::Id childId = QAccessible::uniqueId(child);
+ QAccessible::deleteAccessibleInterface(childId);
+ }
+ }
}
-QAccessible::Role KItemListViewAccessible::cellRole() const
+void* KItemListViewAccessible::interface_cast(QAccessible::InterfaceType type)
{
- return QAccessible::Cell;
+ if (type == QAccessible::TableInterface) {
+ return static_cast<QAccessibleTableInterface*>(this);
+ }
+ return Q_NULLPTR;
}
-QAccessibleTable2CellInterface* KItemListViewAccessible::cell(int index) const
+void KItemListViewAccessible::modelReset()
+{
+}
+
+QAccessibleInterface* KItemListViewAccessible::cell(int index) const
{
if (index < 0 || index >= view()->model()->count()) {
return 0;
- } else {
- return new KItemListAccessibleCell(view(), index);
}
-}
-QVariant KItemListViewAccessible::invokeMethodEx(Method, int, const QVariantList&)
-{
- return QVariant();
+ 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;
}
-QAccessibleTable2CellInterface* KItemListViewAccessible::cellAt(int row, int column) const
+QAccessibleInterface* KItemListViewAccessible::cellAt(int row, int column) const
{
return cell(columnCount() * row + column);
}
@@ -127,9 +143,9 @@ QString KItemListViewAccessible::rowDescription(int) const
return QString();
}
-QList<QAccessibleTable2CellInterface*> KItemListViewAccessible::selectedCells() const
+QList<QAccessibleInterface*> KItemListViewAccessible::selectedCells() const
{
- QList<QAccessibleTable2CellInterface*> cells;
+ QList<QAccessibleInterface*> cells;
Q_FOREACH (int index, view()->controller()->selectionManager()->selectedItems()) {
cells.append(cell(index));
}
@@ -181,42 +197,31 @@ bool KItemListViewAccessible::unselectColumn(int)
return true;
}
-QAccessible2::TableModelChange KItemListViewAccessible::modelChange() const
+void KItemListViewAccessible::modelChange(QAccessibleTableModelChangeEvent* /*event*/)
+{}
+
+QAccessible::Role KItemListViewAccessible::role() const
{
- QAccessible2::TableModelChange change;
- change.lastRow = rowCount();
- change.lastColumn = columnCount();
- return change;
+ return QAccessible::Table;
}
-QAccessible::Role KItemListViewAccessible::role(int child) const
+QAccessible::State KItemListViewAccessible::state() const
{
- Q_ASSERT(child >= 0);
-
- if (child > 0) {
- return QAccessible::Cell;
- } else {
- return QAccessible::Table;
- }
+ QAccessible::State s;
+ return s;
}
-QAccessible::State KItemListViewAccessible::state(int child) const
+QAccessibleInterface* KItemListViewAccessible::childAt(int x, int y) const
{
- if (child) {
- QAccessibleInterface* interface = 0;
- navigate(Child, child, &interface);
- if (interface) {
- return interface->state(0);
- }
- }
-
- return QAccessible::Normal | QAccessible::HasInvokeExtension;
+ const QPointF point = QPointF(x, y);
+ int itemIndex = view()->itemAt(view()->mapFromScene(point));
+ return child(itemIndex);
}
-int KItemListViewAccessible::childAt(int x, int y) const
+QAccessibleInterface* KItemListViewAccessible::parent() const
{
- const QPointF point = QPointF(x,y);
- return view()->itemAt(view()->mapFromScene(point));
+ // FIXME: return KItemListContainerAccessible here
+ return Q_NULLPTR;
}
int KItemListViewAccessible::childCount() const
@@ -227,18 +232,16 @@ int KItemListViewAccessible::childCount() const
int KItemListViewAccessible::indexOfChild(const QAccessibleInterface* interface) const
{
const KItemListAccessibleCell* widget = static_cast<const KItemListAccessibleCell*>(interface);
- return widget->index() + 1;
+ return widget->index();
}
-QString KItemListViewAccessible::text(Text, int child) const
+QString KItemListViewAccessible::text(QAccessible::Text) const
{
- Q_ASSERT(child == 0);
return QString();
}
-QRect KItemListViewAccessible::rect(int child) const
+QRect KItemListViewAccessible::rect() const
{
- Q_UNUSED(child)
if (!view()->isVisible()) {
return QRect();
}
@@ -253,50 +256,14 @@ QRect KItemListViewAccessible::rect(int child) const
}
}
-int KItemListViewAccessible::navigate(RelationFlag relation, int index, QAccessibleInterface** interface) const
+QAccessibleInterface* KItemListViewAccessible::child(int index) const
{
- *interface = 0;
-
- switch (relation) {
- case QAccessible::Child:
- Q_ASSERT(index > 0);
- *interface = cell(index - 1);
- if (*interface) {
- return 0;
- }
- break;
-
- default:
- break;
+ if (index >= 0 && index < childCount()) {
+ return cell(index);
}
-
- return -1;
+ return Q_NULLPTR;
}
-QAccessible::Relation KItemListViewAccessible::relationTo(int, const QAccessibleInterface*, int) const
-{
- return QAccessible::Unrelated;
-}
-
-#ifndef QT_NO_ACTION
-
-int KItemListViewAccessible::userActionCount(int) const
-{
- return 0;
-}
-
-QString KItemListViewAccessible::actionText(int, Text, int) const
-{
- return QString();
-}
-
-bool KItemListViewAccessible::doAction(int, int, const QVariantList&)
-{
- return false;
-}
-
-#endif
-
// Table Cell
KItemListAccessibleCell::KItemListAccessibleCell(KItemListView* view, int index) :
@@ -306,6 +273,14 @@ KItemListAccessibleCell::KItemListAccessibleCell(KItemListView* view, int index)
Q_ASSERT(index >= 0 && index < view->model()->count());
}
+void* KItemListAccessibleCell::interface_cast(QAccessible::InterfaceType type)
+{
+ if (type == QAccessible::TableCellInterface) {
+ return static_cast<QAccessibleTableCellInterface*>(this);
+ }
+ return Q_NULLPTR;
+}
+
int KItemListAccessibleCell::columnExtent() const
{
return 1;
@@ -341,52 +316,39 @@ bool KItemListAccessibleCell::isSelected() const
return m_view->controller()->selectionManager()->isSelected(m_index);
}
-void KItemListAccessibleCell::rowColumnExtents(int* row, int* column, int* rowExtents, int* columnExtents, bool* selected) const
+QAccessibleInterface* KItemListAccessibleCell::table() const
{
- const KItemListViewLayouter* layouter = m_view->m_layouter;
- *row = layouter->itemRow(m_index);
- *column = layouter->itemColumn(m_index);
- *rowExtents = 1;
- *columnExtents = 1;
- *selected = isSelected();
+ return QAccessible::queryAccessibleInterface(m_view);
}
-QAccessibleTable2Interface* KItemListAccessibleCell::table() const
+QAccessible::Role KItemListAccessibleCell::role() const
{
- return QAccessible::queryAccessibleInterface(m_view)->table2Interface();
-}
-
-QAccessible::Role KItemListAccessibleCell::role(int child) const
-{
- Q_ASSERT(child == 0);
return QAccessible::Cell;
}
-QAccessible::State KItemListAccessibleCell::state(int child) const
+QAccessible::State KItemListAccessibleCell::state() const
{
- Q_ASSERT(child == 0);
- QAccessible::State state = Normal;
+ QAccessible::State state;
+ state.selectable = true;
if (isSelected()) {
- state |= Selected;
+ state.selected = true;
}
+ state.focusable = true;
if (m_view->controller()->selectionManager()->currentItem() == m_index) {
- state |= Focused;
+ state.focused = true;
}
- state |= Selectable;
- state |= Focusable;
-
if (m_view->controller()->selectionBehavior() == KItemListController::MultiSelection) {
- state |= MultiSelectable;
+ state.multiSelectable = true;
}
if (m_view->model()->isExpandable(m_index)) {
if (m_view->model()->isExpanded(m_index)) {
- state |= Expanded;
+ state.expanded = true;
} else {
- state |= Collapsed;
+ state.collapsed = true;
}
}
@@ -398,7 +360,7 @@ bool KItemListAccessibleCell::isExpandable() const
return m_view->model()->isExpandable(m_index);
}
-QRect KItemListAccessibleCell::rect(int) const
+QRect KItemListAccessibleCell::rect() const
{
QRect rect = m_view->itemRect(m_index).toRect();
@@ -411,13 +373,9 @@ QRect KItemListAccessibleCell::rect(int) const
return rect;
}
-QString KItemListAccessibleCell::text(QAccessible::Text t, int child) const
+QString KItemListAccessibleCell::text(QAccessible::Text t) const
{
- Q_ASSERT(child == 0);
- Q_UNUSED(child)
-
switch (t) {
- case QAccessible::Value:
case QAccessible::Name: {
const QHash<QByteArray, QVariant> data = m_view->model()->data(m_index);
return data["text"].toString();
@@ -430,9 +388,13 @@ QString KItemListAccessibleCell::text(QAccessible::Text t, int child) const
return QString();
}
-void KItemListAccessibleCell::setText(QAccessible::Text, int child, const QString&)
+void KItemListAccessibleCell::setText(QAccessible::Text, const QString&)
{
- Q_ASSERT(child == 0);
+}
+
+QAccessibleInterface* KItemListAccessibleCell::child(int) const
+{
+ return Q_NULLPTR;
}
bool KItemListAccessibleCell::isValid() const
@@ -440,9 +402,9 @@ bool KItemListAccessibleCell::isValid() const
return m_view && (m_index >= 0) && (m_index < m_view->model()->count());
}
-int KItemListAccessibleCell::childAt(int, int) const
+QAccessibleInterface* KItemListAccessibleCell::childAt(int, int) const
{
- return 0;
+ return Q_NULLPTR;
}
int KItemListAccessibleCell::childCount() const
@@ -456,43 +418,11 @@ int KItemListAccessibleCell::indexOfChild(const QAccessibleInterface* child) con
return -1;
}
-int KItemListAccessibleCell::navigate(RelationFlag relation, int index, QAccessibleInterface** interface) const
-{
- if (relation == Ancestor && index == 1) {
- *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
+QAccessibleInterface* KItemListAccessibleCell::parent() const
{
- return 0;
-}
-
-QString KItemListAccessibleCell::actionText(int, Text, int) const
-{
- return QString();
+ return QAccessible::queryAccessibleInterface(m_view);
}
-bool KItemListAccessibleCell::doAction(int, int, const QVariantList&)
-{
- return false;
-}
-
-#endif
-
int KItemListAccessibleCell::index() const
{
return m_index;
@@ -505,7 +435,7 @@ QObject* KItemListAccessibleCell::object() const
// Container Interface
KItemListContainerAccessible::KItemListContainerAccessible(KItemListContainer* container) :
- QAccessibleWidgetEx(container)
+ QAccessibleWidget(container)
{
}
@@ -521,20 +451,17 @@ int KItemListContainerAccessible::childCount() const
int KItemListContainerAccessible::indexOfChild(const QAccessibleInterface* child) const
{
if (child->object() == container()->controller()->view()) {
- return 1;
- } else {
- return -1;
+ return 0;
}
+ return -1;
}
-int KItemListContainerAccessible::navigate(QAccessible::RelationFlag relation, int index, QAccessibleInterface** target) const
+QAccessibleInterface* KItemListContainerAccessible::child(int index) const
{
- if (relation == QAccessible::Child) {
- *target = new KItemListViewAccessible(container()->controller()->view());
- return 0;
- } else {
- return QAccessibleWidgetEx::navigate(relation, index, target);
+ if (index == 0) {
+ return QAccessible::queryAccessibleInterface(container()->controller()->view());
}
+ return Q_NULLPTR;
}
const KItemListContainer* KItemListContainerAccessible::container() const
diff --git a/src/kitemviews/kitemlistviewaccessible.h b/src/kitemviews/kitemlistviewaccessible.h
index c2213cd67..afef2d5fe 100644
--- a/src/kitemviews/kitemlistviewaccessible.h
+++ b/src/kitemviews/kitemlistviewaccessible.h
@@ -22,118 +22,104 @@
#ifndef QT_NO_ACCESSIBILITY
+#include "dolphin_export.h"
+
#include <QtCore/qpointer.h>
-#include <QtGui/qaccessible.h>
-#include <QtGui/qaccessible2.h>
-#include <QtGui/qaccessiblewidget.h>
-#include <QtGui/qaccessibleobject.h>
+#include <qaccessible.h>
+#include <qaccessibleobject.h>
+#include <QtWidgets/qaccessiblewidget.h>
class KItemListView;
class KItemListContainer;
-class KItemListViewAccessible: public QAccessibleTable2Interface, public QAccessibleObjectEx
+class DOLPHIN_EXPORT KItemListViewAccessible: public QAccessibleObject, public QAccessibleTableInterface
{
- Q_ACCESSIBLE_OBJECT
-
public:
explicit KItemListViewAccessible(KItemListView* view);
+ ~KItemListViewAccessible();
- Role role(int child) const;
- State state(int child) const;
- QString text(Text t, int child) const;
- QRect rect(int child) const;
-
- int childAt(int x, int y) const;
- int childCount() const;
- int indexOfChild(const QAccessibleInterface*) const;
+ void* interface_cast(QAccessible::InterfaceType type) Q_DECL_OVERRIDE;
- int navigate(RelationFlag relation, int index, QAccessibleInterface** interface) const;
- Relation relationTo(int child, const QAccessibleInterface* other, int otherChild) const;
+ QAccessible::Role role() const Q_DECL_OVERRIDE;
+ QAccessible::State state() const Q_DECL_OVERRIDE;
+ QString text(QAccessible::Text t) const Q_DECL_OVERRIDE;
+ QRect rect() const Q_DECL_OVERRIDE;
-#ifndef QT_NO_ACTION
- int userActionCount(int child) const;
- QString actionText(int action, Text t, int child) const;
- bool doAction(int action, int child, const QVariantList& params);
-#endif
- QVariant invokeMethodEx(Method, int, const QVariantList&);
+ QAccessibleInterface* child(int index) const Q_DECL_OVERRIDE;
+ int childCount() const Q_DECL_OVERRIDE;
+ int indexOfChild(const QAccessibleInterface*) const Q_DECL_OVERRIDE;
+ QAccessibleInterface* childAt(int x, int y) const Q_DECL_OVERRIDE;
+ QAccessibleInterface* parent() const Q_DECL_OVERRIDE;
- // Table2 interface
- virtual QAccessibleTable2CellInterface* cellAt(int row, int column) const;
- virtual QAccessibleInterface* caption() const;
- virtual QAccessibleInterface* summary() const;
- virtual QString columnDescription(int column) const;
- virtual QString rowDescription(int row) const;
- virtual int columnCount() const;
- virtual int rowCount() const;
- virtual QAccessible2::TableModelChange modelChange() const;
- virtual void rowsInserted(const QModelIndex&, int, int) {}
- virtual void rowsRemoved(const QModelIndex&, int, int) {}
- virtual void columnsInserted(const QModelIndex&, int, int) {}
- virtual void columnsRemoved(const QModelIndex&, int, int) {}
- virtual void rowsMoved(const QModelIndex&, int, int, const QModelIndex&, int) {}
- virtual void columnsMoved(const QModelIndex&, int, int, const QModelIndex&, int) {}
+ // Table interface
+ virtual QAccessibleInterface* cellAt(int row, int column) const Q_DECL_OVERRIDE;
+ virtual QAccessibleInterface* caption() const Q_DECL_OVERRIDE;
+ virtual QAccessibleInterface* summary() const Q_DECL_OVERRIDE;
+ virtual QString columnDescription(int column) const Q_DECL_OVERRIDE;
+ virtual QString rowDescription(int row) const Q_DECL_OVERRIDE;
+ virtual int columnCount() const Q_DECL_OVERRIDE;
+ virtual int rowCount() const Q_DECL_OVERRIDE;
// Selection
- virtual int selectedCellCount() const;
- virtual int selectedColumnCount() const;
- virtual int selectedRowCount() const;
- virtual QList<QAccessibleTable2CellInterface*> selectedCells() const;
- virtual QList<int> selectedColumns() const;
- virtual QList<int> selectedRows() const;
- virtual bool isColumnSelected(int column) const;
- virtual bool isRowSelected(int row) const;
- virtual bool selectRow(int row);
- virtual bool selectColumn(int column);
- virtual bool unselectRow(int row);
- virtual bool unselectColumn(int column);
+ virtual int selectedCellCount() const Q_DECL_OVERRIDE;
+ virtual int selectedColumnCount() const Q_DECL_OVERRIDE;
+ virtual int selectedRowCount() const Q_DECL_OVERRIDE;
+ virtual QList<QAccessibleInterface*> selectedCells() const Q_DECL_OVERRIDE;
+ virtual QList<int> selectedColumns() const Q_DECL_OVERRIDE;
+ virtual QList<int> selectedRows() const Q_DECL_OVERRIDE;
+ virtual bool isColumnSelected(int column) const Q_DECL_OVERRIDE;
+ virtual bool isRowSelected(int row) const Q_DECL_OVERRIDE;
+ virtual bool selectRow(int row) Q_DECL_OVERRIDE;
+ virtual bool selectColumn(int column) Q_DECL_OVERRIDE;
+ virtual bool unselectRow(int row) Q_DECL_OVERRIDE;
+ virtual bool unselectColumn(int column) Q_DECL_OVERRIDE;
+ virtual void modelChange(QAccessibleTableModelChangeEvent*) Q_DECL_OVERRIDE;
KItemListView* view() const;
protected:
virtual void modelReset();
/**
- * Create an QAccessibleTable2CellInterface representing the table
+ * Create an QAccessibleTableCellInterface representing the table
* cell at the @index. Index is 0-based.
*/
- inline QAccessibleTable2CellInterface* cell(int index) const;
- inline QAccessible::Role cellRole() const;
+ inline QAccessibleInterface* cell(int index) const;
+
+private:
+ mutable QVector<QAccessibleInterface*> m_cells;
};
-class KItemListAccessibleCell: public QAccessibleTable2CellInterface
+class DOLPHIN_EXPORT KItemListAccessibleCell: public QAccessibleInterface, public QAccessibleTableCellInterface
{
public:
KItemListAccessibleCell(KItemListView* view, int m_index);
- QObject* object() const;
- Role role(int) const;
- State state(int) const;
- QRect rect(int) const;
- bool isValid() const;
- int childAt(int, int) const;
- int childCount() const;
- int indexOfChild(const QAccessibleInterface*) const;
- QString text(Text t, int child) const;
- void setText(Text t, int child, const QString& text);
- int navigate(RelationFlag relation, int m_index, QAccessibleInterface** interface) const;
- Relation relationTo(int child, const QAccessibleInterface* other, int otherChild) const;
- bool isExpandable() const;
+ void* interface_cast(QAccessible::InterfaceType type) Q_DECL_OVERRIDE;
+ QObject* object() const Q_DECL_OVERRIDE;
+ bool isValid() const Q_DECL_OVERRIDE;
+ QAccessible::Role role() const Q_DECL_OVERRIDE;
+ QAccessible::State state() const Q_DECL_OVERRIDE;
+ QRect rect() const Q_DECL_OVERRIDE;
+ QString text(QAccessible::Text t) const Q_DECL_OVERRIDE;
+ void setText(QAccessible::Text t, const QString& text) Q_DECL_OVERRIDE;
-#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
+ QAccessibleInterface* child(int index) const Q_DECL_OVERRIDE;
+ int childCount() const Q_DECL_OVERRIDE;
+ QAccessibleInterface* childAt(int x, int y) const Q_DECL_OVERRIDE;
+ int indexOfChild(const QAccessibleInterface*) const Q_DECL_OVERRIDE;
+
+ QAccessibleInterface* parent() const Q_DECL_OVERRIDE;
+ bool isExpandable() const;
// Cell Interface
- virtual int columnExtent() const;
- virtual QList<QAccessibleInterface*> columnHeaderCells() const;
- virtual int columnIndex() const;
- virtual int rowExtent() const;
- virtual QList<QAccessibleInterface*> rowHeaderCells() const;
- virtual int rowIndex() const;
- virtual bool isSelected() const;
- virtual void rowColumnExtents(int* row, int* column, int* rowExtents, int* columnExtents, bool* selected) const;
- virtual QAccessibleTable2Interface* table() const;
+ virtual int columnExtent() const Q_DECL_OVERRIDE;
+ virtual QList<QAccessibleInterface*> columnHeaderCells() const Q_DECL_OVERRIDE;
+ virtual int columnIndex() const Q_DECL_OVERRIDE;
+ virtual int rowExtent() const Q_DECL_OVERRIDE;
+ virtual QList<QAccessibleInterface*> rowHeaderCells() const Q_DECL_OVERRIDE;
+ virtual int rowIndex() const Q_DECL_OVERRIDE;
+ virtual bool isSelected() const Q_DECL_OVERRIDE;
+ virtual QAccessibleInterface* table() const Q_DECL_OVERRIDE;
inline int index() const;
@@ -142,17 +128,15 @@ private:
int m_index;
};
-class KItemListContainerAccessible : public QAccessibleWidgetEx
+class DOLPHIN_EXPORT KItemListContainerAccessible : public QAccessibleWidget
{
- Q_ACCESSIBLE_OBJECT
-
public:
explicit KItemListContainerAccessible(KItemListContainer* container);
virtual ~KItemListContainerAccessible();
- int childCount() const;
- int indexOfChild(const QAccessibleInterface* child) const;
- int navigate(RelationFlag relation, int entry, QAccessibleInterface** target) const;
+ QAccessibleInterface* child(int index) const Q_DECL_OVERRIDE;
+ int childCount() const Q_DECL_OVERRIDE;
+ int indexOfChild(const QAccessibleInterface* child) const Q_DECL_OVERRIDE;
private:
const KItemListContainer* container() const;
diff --git a/src/kitemviews/kitemlistwidget.cpp b/src/kitemviews/kitemlistwidget.cpp
index 97a14763c..3eb6b1d71 100644
--- a/src/kitemviews/kitemlistwidget.cpp
+++ b/src/kitemviews/kitemlistwidget.cpp
@@ -27,9 +27,7 @@
#include "private/kitemlistselectiontoggle.h"
-#include <KDebug>
-#include <KGlobalSettings>
#include <QApplication>
#include <QPainter>
#include <QPropertyAnimation>
@@ -250,9 +248,9 @@ void KItemListWidget::setHovered(bool hovered)
if (!m_hoverAnimation) {
m_hoverAnimation = new QPropertyAnimation(this, "hoverOpacity", this);
- const int duration = (KGlobalSettings::graphicEffectsLevel() == KGlobalSettings::NoEffects) ? 1 : 200;
+ const int duration = style()->styleHint(QStyle::SH_Widget_Animate) ? 200 : 1;
m_hoverAnimation->setDuration(duration);
- connect(m_hoverAnimation, SIGNAL(finished()), this, SLOT(slotHoverAnimationFinished()));
+ connect(m_hoverAnimation, &QPropertyAnimation::finished, this, &KItemListWidget::slotHoverAnimationFinished);
}
m_hoverAnimation->stop();
@@ -526,4 +524,3 @@ void KItemListWidget::drawItemStyleOption(QPainter* painter, QWidget* widget, QS
widget->style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &viewItemOption, painter, widget);
}
-#include "kitemlistwidget.moc"
diff --git a/src/kitemviews/kitemlistwidget.h b/src/kitemviews/kitemlistwidget.h
index c086ee6d3..ae99a1f29 100644
--- a/src/kitemviews/kitemlistwidget.h
+++ b/src/kitemviews/kitemlistwidget.h
@@ -23,7 +23,7 @@
#ifndef KITEMLISTWIDGET_H
#define KITEMLISTWIDGET_H
-#include <libdolphin_export.h>
+#include "dolphin_export.h"
#include <kitemviews/kitemliststyleoption.h>
@@ -43,7 +43,7 @@ class QPropertyAnimation;
* size for the invisible items must be accessible. KItemListWidgetInformant
* provides this information.
*/
-class LIBDOLPHINPRIVATE_EXPORT KItemListWidgetInformant
+class DOLPHIN_EXPORT KItemListWidgetInformant
{
public:
KItemListWidgetInformant();
@@ -63,7 +63,7 @@ public:
* All properties are set by KItemListView, for each property there is a corresponding
* virtual protected method that allows to react on property changes.
*/
-class LIBDOLPHINPRIVATE_EXPORT KItemListWidget : public QGraphicsWidget
+class DOLPHIN_EXPORT KItemListWidget : public QGraphicsWidget
{
Q_OBJECT
@@ -82,7 +82,7 @@ public:
* to show the data of the custom model provided by KItemListWidget::data().
* @reimp
*/
- virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
+ virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0) Q_DECL_OVERRIDE;
void setVisibleRoles(const QList<QByteArray>& roles);
QList<QByteArray> visibleRoles() const;
@@ -203,7 +203,7 @@ protected:
virtual void alternateBackgroundChanged(bool enabled);
virtual void siblingsInformationChanged(const QBitArray& current, const QBitArray& previous);
virtual void editedRoleChanged(const QByteArray& current, const QByteArray& previous);
- virtual void resizeEvent(QGraphicsSceneResizeEvent* event);
+ virtual void resizeEvent(QGraphicsSceneResizeEvent* event) Q_DECL_OVERRIDE;
/**
* @return The current opacity of the hover-animation. When implementing a custom painting-code for a hover-state
diff --git a/src/kitemviews/kitemmodelbase.cpp b/src/kitemviews/kitemmodelbase.cpp
index 4312640e4..bf41b1c84 100644
--- a/src/kitemviews/kitemmodelbase.cpp
+++ b/src/kitemviews/kitemmodelbase.cpp
@@ -159,4 +159,3 @@ void KItemModelBase::onSortOrderChanged(Qt::SortOrder current, Qt::SortOrder pre
Q_UNUSED(previous);
}
-#include "kitemmodelbase.moc"
diff --git a/src/kitemviews/kitemmodelbase.h b/src/kitemviews/kitemmodelbase.h
index 283cfa552..bd5ca1d65 100644
--- a/src/kitemviews/kitemmodelbase.h
+++ b/src/kitemviews/kitemmodelbase.h
@@ -23,7 +23,7 @@
#ifndef KITEMMODELBASE_H
#define KITEMMODELBASE_H
-#include <libdolphin_export.h>
+#include "dolphin_export.h"
#include <kitemviews/kitemrange.h>
#include <kitemviews/kitemset.h>
@@ -49,7 +49,7 @@ class QMimeData;
* Also optionally it is possible to provide a tree of items by implementing the methods
* setExpanded(), isExpanded(), isExpandable() and expandedParentsCount().
*/
-class LIBDOLPHINPRIVATE_EXPORT KItemModelBase : public QObject
+class DOLPHIN_EXPORT KItemModelBase : public QObject
{
Q_OBJECT
diff --git a/src/kitemviews/kstandarditem.cpp b/src/kitemviews/kstandarditem.cpp
index 6cb5b049b..f3fd258f9 100644
--- a/src/kitemviews/kstandarditem.cpp
+++ b/src/kitemviews/kstandarditem.cpp
@@ -18,8 +18,8 @@
***************************************************************************/
#include "kstandarditem.h"
-
-#include <KDebug>
+#include <QSet>
+#include <QByteArray>
#include "kstandarditemmodel.h"
KStandardItem::KStandardItem(KStandardItem* parent) :
diff --git a/src/kitemviews/kstandarditem.h b/src/kitemviews/kstandarditem.h
index 689db4251..5bb2bb36f 100644
--- a/src/kitemviews/kstandarditem.h
+++ b/src/kitemviews/kstandarditem.h
@@ -20,11 +20,10 @@
#ifndef KSTANDARDITEM_H
#define KSTANDARDITEM_H
-#include <libdolphin_export.h>
+#include "dolphin_export.h"
#include <QByteArray>
#include <QHash>
-#include <QIcon>
#include <QList>
#include <QVariant>
@@ -37,7 +36,7 @@ class KStandardItemModel;
* used roles. It is possible to assign values for custom
* roles by using setDataValue().
*/
-class LIBDOLPHINPRIVATE_EXPORT KStandardItem
+class DOLPHIN_EXPORT KStandardItem
{
public:
diff --git a/src/kitemviews/kstandarditemlistgroupheader.cpp b/src/kitemviews/kstandarditemlistgroupheader.cpp
index 1e23c0a56..2afaa168c 100644
--- a/src/kitemviews/kstandarditemlistgroupheader.cpp
+++ b/src/kitemviews/kstandarditemlistgroupheader.cpp
@@ -22,7 +22,7 @@
#include "kstandarditemlistgroupheader.h"
-#include <kratingpainter.h>
+#include <KRatingPainter>
#include <QPainter>
KStandardItemListGroupHeader::KStandardItemListGroupHeader(QGraphicsWidget* parent) :
@@ -122,4 +122,3 @@ void KStandardItemListGroupHeader::updateCache()
}
}
-#include "kstandarditemlistgroupheader.moc"
diff --git a/src/kitemviews/kstandarditemlistgroupheader.h b/src/kitemviews/kstandarditemlistgroupheader.h
index 26158d6ba..f0eacfd49 100644
--- a/src/kitemviews/kstandarditemlistgroupheader.h
+++ b/src/kitemviews/kstandarditemlistgroupheader.h
@@ -20,14 +20,14 @@
#ifndef KSTANDARDITEMLISTGROUPHEADER_H
#define KSTANDARDITEMLISTGROUPHEADER_H
-#include <libdolphin_export.h>
+#include "dolphin_export.h"
#include <kitemviews/kitemlistgroupheader.h>
#include <QPixmap>
#include <QStaticText>
-class LIBDOLPHINPRIVATE_EXPORT KStandardItemListGroupHeader : public KItemListGroupHeader
+class DOLPHIN_EXPORT KStandardItemListGroupHeader : public KItemListGroupHeader
{
Q_OBJECT
@@ -35,14 +35,14 @@ public:
KStandardItemListGroupHeader(QGraphicsWidget* parent = 0);
virtual ~KStandardItemListGroupHeader();
- virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
+ virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0) Q_DECL_OVERRIDE;
protected:
- virtual void paintRole(QPainter* painter, const QRectF& roleBounds, const QColor& color);
- virtual void paintSeparator(QPainter* painter, const QColor& color);
- virtual void roleChanged(const QByteArray &current, const QByteArray &previous);
- virtual void dataChanged(const QVariant& current, const QVariant& previous);
- virtual void resizeEvent(QGraphicsSceneResizeEvent* event);
+ virtual void paintRole(QPainter* painter, const QRectF& roleBounds, const QColor& color) Q_DECL_OVERRIDE;
+ virtual void paintSeparator(QPainter* painter, const QColor& color) Q_DECL_OVERRIDE;
+ virtual void roleChanged(const QByteArray &current, const QByteArray &previous) Q_DECL_OVERRIDE;
+ virtual void dataChanged(const QVariant& current, const QVariant& previous) Q_DECL_OVERRIDE;
+ virtual void resizeEvent(QGraphicsSceneResizeEvent* event) Q_DECL_OVERRIDE;
private:
void updateCache();
diff --git a/src/kitemviews/kstandarditemlistview.cpp b/src/kitemviews/kstandarditemlistview.cpp
index 135cd0b7d..6471002c7 100644
--- a/src/kitemviews/kstandarditemlistview.cpp
+++ b/src/kitemviews/kstandarditemlistview.cpp
@@ -19,7 +19,6 @@
#include "kstandarditemlistview.h"
-#include <KDebug>
#include <KIconLoader>
#include "kstandarditemlistwidget.h"
#include "kstandarditemlistgroupheader.h"
@@ -30,7 +29,7 @@ KStandardItemListView::KStandardItemListView(QGraphicsWidget* parent) :
{
setAcceptDrops(true);
setScrollOrientation(Qt::Vertical);
- setVisibleRoles(QList<QByteArray>() << "text");
+ setVisibleRoles({"text"});
}
KStandardItemListView::~KStandardItemListView()
@@ -179,4 +178,3 @@ void KStandardItemListView::updateLayoutOfVisibleItems()
}
}
-#include "kstandarditemlistview.moc"
diff --git a/src/kitemviews/kstandarditemlistview.h b/src/kitemviews/kstandarditemlistview.h
index f5b0bfd8c..2e4c7a0a0 100644
--- a/src/kitemviews/kstandarditemlistview.h
+++ b/src/kitemviews/kstandarditemlistview.h
@@ -20,7 +20,7 @@
#ifndef KSTANDARDITEMLISTVIEW_H
#define KSTANDARDITEMLISTVIEW_H
-#include <libdolphin_export.h>
+#include "dolphin_export.h"
#include <kitemviews/kitemlistview.h>
@@ -40,7 +40,7 @@
* KItemListContainer* container = new KItemListContainer(controller, parentWidget);
* </code>
*/
-class LIBDOLPHINPRIVATE_EXPORT KStandardItemListView : public KItemListView
+class DOLPHIN_EXPORT KStandardItemListView : public KItemListView
{
Q_OBJECT
@@ -59,15 +59,15 @@ public:
ItemLayout itemLayout() const;
protected:
- virtual KItemListWidgetCreatorBase* defaultWidgetCreator() const;
- virtual KItemListGroupHeaderCreatorBase* defaultGroupHeaderCreator() const;
- virtual void initializeItemListWidget(KItemListWidget* item);
- virtual bool itemSizeHintUpdateRequired(const QSet<QByteArray>& changedRoles) const;
+ virtual KItemListWidgetCreatorBase* defaultWidgetCreator() const Q_DECL_OVERRIDE;
+ virtual KItemListGroupHeaderCreatorBase* defaultGroupHeaderCreator() const Q_DECL_OVERRIDE;
+ virtual void initializeItemListWidget(KItemListWidget* item) Q_DECL_OVERRIDE;
+ virtual bool itemSizeHintUpdateRequired(const QSet<QByteArray>& changedRoles) const Q_DECL_OVERRIDE;
virtual bool itemLayoutSupportsItemExpanding(ItemLayout layout) const;
virtual void onItemLayoutChanged(ItemLayout current, ItemLayout previous);
- virtual void onScrollOrientationChanged(Qt::Orientation current, Qt::Orientation previous);
- virtual void onSupportsItemExpandingChanged(bool supportsExpanding);
- virtual void polishEvent();
+ virtual void onScrollOrientationChanged(Qt::Orientation current, Qt::Orientation previous) Q_DECL_OVERRIDE;
+ virtual void onSupportsItemExpandingChanged(bool supportsExpanding) Q_DECL_OVERRIDE;
+ virtual void polishEvent() Q_DECL_OVERRIDE;
private:
void applyDefaultStyleOption(int iconSize, int padding, int horizontalMargin, int verticalMargin);
diff --git a/src/kitemviews/kstandarditemlistwidget.cpp b/src/kitemviews/kstandarditemlistwidget.cpp
index 6407efc22..f663b8725 100644
--- a/src/kitemviews/kstandarditemlistwidget.cpp
+++ b/src/kitemviews/kstandarditemlistwidget.cpp
@@ -22,19 +22,16 @@
#include "kfileitemlistview.h"
#include "kfileitemmodel.h"
-#include <KIcon>
+#include <QIcon>
#include <KIconEffect>
#include <KIconLoader>
-#include <KLocale>
-#include <kratingpainter.h>
+#include <KRatingPainter>
#include <KStringHandler>
-#include <KDebug>
#include "private/kfileitemclipboard.h"
#include "private/kitemlistroleeditor.h"
#include "private/kpixmapmodifier.h"
-#include <QFontMetricsF>
#include <QGraphicsScene>
#include <QGraphicsSceneResizeEvent>
#include <QGraphicsView>
@@ -120,6 +117,8 @@ QString KStandardItemListWidgetInformant::itemText(int index, const KItemListVie
bool KStandardItemListWidgetInformant::itemIsLink(int index, const KItemListView* view) const
{
+ Q_UNUSED(index);
+ Q_UNUSED(view);
return false;
}
@@ -682,7 +681,7 @@ void KStandardItemListWidget::dataChanged(const QHash<QByteArray, QVariant>& cur
// The URL might have changed (i.e., if the sort order of the items has
// been changed). Therefore, the "is cut" state must be updated.
KFileItemClipboard* clipboard = KFileItemClipboard::instance();
- const KUrl itemUrl = data().value("url").value<KUrl>();
+ const QUrl itemUrl = data().value("url").value<QUrl>();
m_isCut = clipboard->isCut(itemUrl);
// The icon-state might depend from other roles and hence is
@@ -758,10 +757,10 @@ void KStandardItemListWidget::editedRoleChanged(const QByteArray& current, const
if (m_roleEditor) {
emit roleEditingCanceled(index(), current, data().value(current));
- disconnect(m_roleEditor, SIGNAL(roleEditingCanceled(QByteArray,QVariant)),
- this, SLOT(slotRoleEditingCanceled(QByteArray,QVariant)));
- disconnect(m_roleEditor, SIGNAL(roleEditingFinished(QByteArray,QVariant)),
- this, SLOT(slotRoleEditingFinished(QByteArray,QVariant)));
+ disconnect(m_roleEditor, &KItemListRoleEditor::roleEditingCanceled,
+ this, &KStandardItemListWidget::slotRoleEditingCanceled);
+ disconnect(m_roleEditor, &KItemListRoleEditor::roleEditingFinished,
+ this, &KStandardItemListWidget::slotRoleEditingFinished);
if (m_oldRoleEditor) {
m_oldRoleEditor->deleteLater();
@@ -796,10 +795,10 @@ void KStandardItemListWidget::editedRoleChanged(const QByteArray& current, const
m_roleEditor->setTextCursor(cursor);
}
- connect(m_roleEditor, SIGNAL(roleEditingCanceled(QByteArray,QVariant)),
- this, SLOT(slotRoleEditingCanceled(QByteArray,QVariant)));
- connect(m_roleEditor, SIGNAL(roleEditingFinished(QByteArray,QVariant)),
- this, SLOT(slotRoleEditingFinished(QByteArray,QVariant)));
+ connect(m_roleEditor, &KItemListRoleEditor::roleEditingCanceled,
+ this, &KStandardItemListWidget::slotRoleEditingCanceled);
+ connect(m_roleEditor, &KItemListRoleEditor::roleEditingFinished,
+ this, &KStandardItemListWidget::slotRoleEditingFinished);
// Adjust the geometry of the editor
QRectF rect = roleEditingRect(current);
@@ -833,24 +832,24 @@ void KStandardItemListWidget::showEvent(QShowEvent* event)
// Listen to changes of the clipboard to mark the item as cut/uncut
KFileItemClipboard* clipboard = KFileItemClipboard::instance();
- const KUrl itemUrl = data().value("url").value<KUrl>();
+ const QUrl itemUrl = data().value("url").value<QUrl>();
m_isCut = clipboard->isCut(itemUrl);
- connect(clipboard, SIGNAL(cutItemsChanged()),
- this, SLOT(slotCutItemsChanged()));
+ connect(clipboard, &KFileItemClipboard::cutItemsChanged,
+ this, &KStandardItemListWidget::slotCutItemsChanged);
}
void KStandardItemListWidget::hideEvent(QHideEvent* event)
{
- disconnect(KFileItemClipboard::instance(), SIGNAL(cutItemsChanged()),
- this, SLOT(slotCutItemsChanged()));
+ disconnect(KFileItemClipboard::instance(), &KFileItemClipboard::cutItemsChanged,
+ this, &KStandardItemListWidget::slotCutItemsChanged);
KItemListWidget::hideEvent(event);
}
void KStandardItemListWidget::slotCutItemsChanged()
{
- const KUrl itemUrl = data().value("url").value<KUrl>();
+ const QUrl itemUrl = data().value("url").value<QUrl>();
const bool isCut = KFileItemClipboard::instance()->isCut(itemUrl);
if (m_isCut != isCut) {
m_isCut = isCut;
@@ -1415,10 +1414,10 @@ QRectF KStandardItemListWidget::roleEditingRect(const QByteArray& role) const
void KStandardItemListWidget::closeRoleEditor()
{
- disconnect(m_roleEditor, SIGNAL(roleEditingCanceled(QByteArray,QVariant)),
- this, SLOT(slotRoleEditingCanceled(QByteArray,QVariant)));
- disconnect(m_roleEditor, SIGNAL(roleEditingFinished(QByteArray,QVariant)),
- this, SLOT(slotRoleEditingFinished(QByteArray,QVariant)));
+ disconnect(m_roleEditor, &KItemListRoleEditor::roleEditingCanceled,
+ this, &KStandardItemListWidget::slotRoleEditingCanceled);
+ disconnect(m_roleEditor, &KItemListRoleEditor::roleEditingFinished,
+ this, &KStandardItemListWidget::slotRoleEditingFinished);
if (m_roleEditor->hasFocus()) {
// If the editing was not ended by a FocusOut event, we have
@@ -1440,7 +1439,7 @@ QPixmap KStandardItemListWidget::pixmapForIcon(const QString& name, const QStrin
QPixmap pixmap;
if (!QPixmapCache::find(key, pixmap)) {
- const KIcon icon(name);
+ const QIcon icon = QIcon::fromTheme(name);
int requestedSize;
if (size <= KIconLoader::SizeSmall) {
@@ -1497,4 +1496,3 @@ qreal KStandardItemListWidget::columnPadding(const KItemListStyleOption& option)
return option.padding * 6;
}
-#include "kstandarditemlistwidget.moc"
diff --git a/src/kitemviews/kstandarditemlistwidget.h b/src/kitemviews/kstandarditemlistwidget.h
index 403794fc3..826452255 100644
--- a/src/kitemviews/kstandarditemlistwidget.h
+++ b/src/kitemviews/kstandarditemlistwidget.h
@@ -20,7 +20,7 @@
#ifndef KSTANDARDITEMLISTWIDGET_H
#define KSTANDARDITEMLISTWIDGET_H
-#include <libdolphin_export.h>
+#include "dolphin_export.h"
#include <kitemviews/kitemlistwidget.h>
@@ -32,17 +32,17 @@ class KItemListRoleEditor;
class KItemListStyleOption;
class KItemListView;
-class LIBDOLPHINPRIVATE_EXPORT KStandardItemListWidgetInformant : public KItemListWidgetInformant
+class DOLPHIN_EXPORT KStandardItemListWidgetInformant : public KItemListWidgetInformant
{
public:
KStandardItemListWidgetInformant();
virtual ~KStandardItemListWidgetInformant();
- virtual void calculateItemSizeHints(QVector<qreal>& logicalHeightHints, qreal& logicalWidthHint, const KItemListView* view) const;
+ virtual void calculateItemSizeHints(QVector<qreal>& logicalHeightHints, qreal& logicalWidthHint, const KItemListView* view) const Q_DECL_OVERRIDE;
virtual qreal preferredRoleColumnWidth(const QByteArray& role,
int index,
- const KItemListView* view) const;
+ const KItemListView* view) const Q_DECL_OVERRIDE;
protected:
/**
* @return The value of the "text" role. The default implementation returns
@@ -83,7 +83,7 @@ protected:
/**
* @brief Itemlist widget implementation for KStandardItemView and KStandardItemModel.
*/
-class LIBDOLPHINPRIVATE_EXPORT KStandardItemListWidget : public KItemListWidget
+class DOLPHIN_EXPORT KStandardItemListWidget : public KItemListWidget
{
Q_OBJECT
@@ -106,13 +106,13 @@ public:
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
- virtual QRectF iconRect() const;
- virtual QRectF textRect() const;
- virtual QRectF textFocusRect() const;
- virtual QRectF selectionRect() const;
- virtual QRectF expansionToggleRect() const;
- virtual QRectF selectionToggleRect() const;
- virtual QPixmap createDragPixmap(const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
+ virtual QRectF iconRect() const Q_DECL_OVERRIDE;
+ virtual QRectF textRect() const Q_DECL_OVERRIDE;
+ virtual QRectF textFocusRect() const Q_DECL_OVERRIDE;
+ virtual QRectF selectionRect() const Q_DECL_OVERRIDE;
+ virtual QRectF expansionToggleRect() const Q_DECL_OVERRIDE;
+ virtual QRectF selectionToggleRect() const Q_DECL_OVERRIDE;
+ virtual QPixmap createDragPixmap(const QStyleOptionGraphicsItem* option, QWidget* widget = 0) Q_DECL_OVERRIDE;
static KItemListWidgetInformant* createInformant();
@@ -172,17 +172,17 @@ protected:
*/
virtual int selectionLength(const QString& text) const;
- virtual void dataChanged(const QHash<QByteArray, QVariant>& current, const QSet<QByteArray>& roles = QSet<QByteArray>());
- virtual void visibleRolesChanged(const QList<QByteArray>& current, const QList<QByteArray>& previous);
- virtual void columnWidthChanged(const QByteArray& role, qreal current, qreal previous);
- virtual void styleOptionChanged(const KItemListStyleOption& current, const KItemListStyleOption& previous);
- virtual void hoveredChanged(bool hovered);
- virtual void selectedChanged(bool selected);
- virtual void siblingsInformationChanged(const QBitArray& current, const QBitArray& previous);
- virtual void editedRoleChanged(const QByteArray& current, const QByteArray& previous);
- virtual void resizeEvent(QGraphicsSceneResizeEvent* event);
- virtual void showEvent(QShowEvent* event);
- virtual void hideEvent(QHideEvent* event);
+ virtual void dataChanged(const QHash<QByteArray, QVariant>& current, const QSet<QByteArray>& roles = QSet<QByteArray>()) Q_DECL_OVERRIDE;
+ virtual void visibleRolesChanged(const QList<QByteArray>& current, const QList<QByteArray>& previous) Q_DECL_OVERRIDE;
+ virtual void columnWidthChanged(const QByteArray& role, qreal current, qreal previous) Q_DECL_OVERRIDE;
+ virtual void styleOptionChanged(const KItemListStyleOption& current, const KItemListStyleOption& previous) Q_DECL_OVERRIDE;
+ virtual void hoveredChanged(bool hovered) Q_DECL_OVERRIDE;
+ virtual void selectedChanged(bool selected) Q_DECL_OVERRIDE;
+ virtual void siblingsInformationChanged(const QBitArray& current, const QBitArray& previous) Q_DECL_OVERRIDE;
+ virtual void editedRoleChanged(const QByteArray& current, const QByteArray& previous) Q_DECL_OVERRIDE;
+ virtual void resizeEvent(QGraphicsSceneResizeEvent* event) Q_DECL_OVERRIDE;
+ virtual void showEvent(QShowEvent* event) Q_DECL_OVERRIDE;
+ virtual void hideEvent(QHideEvent* event) Q_DECL_OVERRIDE;
private slots:
void slotCutItemsChanged();
@@ -274,5 +274,3 @@ private:
};
#endif
-
-
diff --git a/src/kitemviews/kstandarditemmodel.cpp b/src/kitemviews/kstandarditemmodel.cpp
index e8c1b6204..25288e50f 100644
--- a/src/kitemviews/kstandarditemmodel.cpp
+++ b/src/kitemviews/kstandarditemmodel.cpp
@@ -19,9 +19,9 @@
#include "kstandarditemmodel.h"
-#include <KDebug>
#include "kstandarditem.h"
-
+#include <QSet>
+#include <QByteArray>
KStandardItemModel::KStandardItemModel(QObject* parent) :
KItemModelBase(parent),
m_items(),
@@ -237,5 +237,3 @@ void KStandardItemModel::onItemRemoved(int index, KStandardItem* removedItem)
Q_UNUSED(removedItem);
}
-
-#include "kstandarditemmodel.moc"
diff --git a/src/kitemviews/kstandarditemmodel.h b/src/kitemviews/kstandarditemmodel.h
index 721e15529..58c5a5d88 100644
--- a/src/kitemviews/kstandarditemmodel.h
+++ b/src/kitemviews/kstandarditemmodel.h
@@ -20,7 +20,7 @@
#ifndef KSTANDARDITEMMODEL_H
#define KSTANDARDITEMMODEL_H
-#include <libdolphin_export.h>
+#include "dolphin_export.h"
#include <kitemviews/kitemmodelbase.h>
#include <QHash>
#include <QList>
@@ -35,7 +35,7 @@ class KStandardItem;
*
* @see KStandardItem
*/
-class LIBDOLPHINPRIVATE_EXPORT KStandardItemModel : public KItemModelBase
+class DOLPHIN_EXPORT KStandardItemModel : public KItemModelBase
{
Q_OBJECT
@@ -69,14 +69,14 @@ public:
*/
void appendItem(KStandardItem* item);
- virtual int count() const;
- virtual QHash<QByteArray, QVariant> data(int index) const;
- virtual bool setData(int index, const QHash<QByteArray, QVariant>& values);
- virtual QMimeData* createMimeData(const KItemSet& indexes) const;
- virtual int indexForKeyboardSearch(const QString& text, int startFromIndex = 0) const;
- virtual bool supportsDropping(int index) const;
- virtual QString roleDescription(const QByteArray& role) const;
- virtual QList<QPair<int, QVariant> > groups() const;
+ virtual int count() const Q_DECL_OVERRIDE;
+ virtual QHash<QByteArray, QVariant> data(int index) const Q_DECL_OVERRIDE;
+ virtual bool setData(int index, const QHash<QByteArray, QVariant>& values) Q_DECL_OVERRIDE;
+ virtual QMimeData* createMimeData(const KItemSet& indexes) const Q_DECL_OVERRIDE;
+ virtual int indexForKeyboardSearch(const QString& text, int startFromIndex = 0) const Q_DECL_OVERRIDE;
+ virtual bool supportsDropping(int index) const Q_DECL_OVERRIDE;
+ virtual QString roleDescription(const QByteArray& role) const Q_DECL_OVERRIDE;
+ virtual QList<QPair<int, QVariant> > groups() const Q_DECL_OVERRIDE;
virtual void clear();
protected:
diff --git a/src/kitemviews/private/kbaloorolesprovider.cpp b/src/kitemviews/private/kbaloorolesprovider.cpp
index c0ae0c544..920ce0671 100644
--- a/src/kitemviews/private/kbaloorolesprovider.cpp
+++ b/src/kitemviews/private/kbaloorolesprovider.cpp
@@ -20,12 +20,12 @@
#include "kbaloorolesprovider.h"
-#include <KDebug>
-#include <KGlobal>
-#include <KLocale>
+#include <QDebug>
+#include <KLocalizedString>
-#include <baloo/file.h>
-#include <kfilemetadata/propertyinfo.h>
+#include <Baloo/File>
+#include <KFileMetaData/PropertyInfo>
+#include <KFileMetaData/UserMetaData>
#include <QTime>
#include <QMap>
@@ -34,7 +34,7 @@ struct KBalooRolesProviderSingleton
{
KBalooRolesProvider instance;
};
-K_GLOBAL_STATIC(KBalooRolesProviderSingleton, s_balooRolesProvider)
+Q_GLOBAL_STATIC(KBalooRolesProviderSingleton, s_balooRolesProvider)
KBalooRolesProvider& KBalooRolesProvider::instance()
@@ -99,14 +99,15 @@ QHash<QByteArray, QVariant> KBalooRolesProvider::roleValues(const Baloo::File& f
}
}
+ KFileMetaData::UserMetaData md(file.path());
if (roles.contains("tags")) {
- values.insert("tags", tagsFromValues(file.tags()));
+ values.insert("tags", tagsFromValues(md.tags()));
}
if (roles.contains("rating")) {
- values.insert("rating", QString::number(file.rating()));
+ values.insert("rating", QString::number(md.rating()));
}
if (roles.contains("comment")) {
- values.insert("comment", file.userComment());
+ values.insert("comment", md.userComment());
}
return values;
diff --git a/src/kitemviews/private/kbaloorolesprovider.h b/src/kitemviews/private/kbaloorolesprovider.h
index f1ad5c740..9673bff4f 100644
--- a/src/kitemviews/private/kbaloorolesprovider.h
+++ b/src/kitemviews/private/kbaloorolesprovider.h
@@ -21,12 +21,11 @@
#ifndef KBALOO_ROLESPROVIDER_H
#define KBALOO_ROLESPROVIDER_H
-#include <libdolphin_export.h>
+#include "dolphin_export.h"
#include <QHash>
#include <QSet>
-#include <QUrl>
-
+#include <QVariant>
namespace Baloo {
class File;
}
@@ -37,7 +36,7 @@ namespace Baloo {
* Is a helper class for KFileItemModelRolesUpdater to retrieve roles that
* are only accessible with Baloo.
*/
-class LIBDOLPHINPRIVATE_EXPORT KBalooRolesProvider
+class DOLPHIN_EXPORT KBalooRolesProvider
{
public:
static KBalooRolesProvider& instance();
diff --git a/src/kitemviews/private/kdirectorycontentscounter.cpp b/src/kitemviews/private/kdirectorycontentscounter.cpp
index 7d1e76999..af7312ad2 100644
--- a/src/kitemviews/private/kdirectorycontentscounter.cpp
+++ b/src/kitemviews/private/kdirectorycontentscounter.cpp
@@ -35,8 +35,8 @@ KDirectoryContentsCounter::KDirectoryContentsCounter(KFileItemModel* model, QObj
m_dirWatcher(0),
m_watchedDirs()
{
- connect(m_model, SIGNAL(itemsRemoved(KItemRangeList)),
- this, SLOT(slotItemsRemoved()));
+ connect(m_model, &KFileItemModel::itemsRemoved,
+ this, &KDirectoryContentsCounter::slotItemsRemoved);
if (!m_workerThread) {
m_workerThread = new QThread();
@@ -47,13 +47,13 @@ KDirectoryContentsCounter::KDirectoryContentsCounter(KFileItemModel* model, QObj
m_worker->moveToThread(m_workerThread);
++m_workersCount;
- connect(this, SIGNAL(requestDirectoryContentsCount(QString,KDirectoryContentsCounterWorker::Options)),
- m_worker, SLOT(countDirectoryContents(QString,KDirectoryContentsCounterWorker::Options)));
- connect(m_worker, SIGNAL(result(QString,int)),
- this, SLOT(slotResult(QString,int)));
+ connect(this, &KDirectoryContentsCounter::requestDirectoryContentsCount,
+ m_worker, &KDirectoryContentsCounterWorker::countDirectoryContents);
+ connect(m_worker, &KDirectoryContentsCounterWorker::result,
+ this, &KDirectoryContentsCounter::slotResult);
m_dirWatcher = new KDirWatch(this);
- connect(m_dirWatcher, SIGNAL(dirty(QString)), this, SLOT(slotDirWatchDirty(QString)));
+ connect(m_dirWatcher, &KDirWatch::dirty, this, &KDirectoryContentsCounter::slotDirWatchDirty);
}
KDirectoryContentsCounter::~KDirectoryContentsCounter()
@@ -122,7 +122,7 @@ void KDirectoryContentsCounter::slotResult(const QString& path, int count)
void KDirectoryContentsCounter::slotDirWatchDirty(const QString& path)
{
- const int index = m_model->index(KUrl(path));
+ const int index = m_model->index(QUrl::fromLocalFile(path));
if (index >= 0) {
if (!m_model->fileItem(index).isDir()) {
// If INotify is used, KDirWatch issues the dirty() signal
@@ -151,7 +151,7 @@ void KDirectoryContentsCounter::slotItemsRemoved()
QMutableSetIterator<QString> it(m_watchedDirs);
while (it.hasNext()) {
const QString& path = it.next();
- if (m_model->index(KUrl(path)) < 0) {
+ if (m_model->index(QUrl::fromLocalFile(path)) < 0) {
m_dirWatcher->removeDir(path);
it.remove();
}
@@ -181,4 +181,4 @@ void KDirectoryContentsCounter::startWorker(const QString& path)
}
QThread* KDirectoryContentsCounter::m_workerThread = 0;
-int KDirectoryContentsCounter::m_workersCount = 0; \ No newline at end of file
+int KDirectoryContentsCounter::m_workersCount = 0;
diff --git a/src/kitemviews/private/kdirectorycontentscounterworker.h b/src/kitemviews/private/kdirectorycontentscounterworker.h
index 96831ef81..b2e31ef0f 100644
--- a/src/kitemviews/private/kdirectorycontentscounterworker.h
+++ b/src/kitemviews/private/kdirectorycontentscounterworker.h
@@ -20,7 +20,6 @@
#ifndef KDIRECTORYCONTENTENTSCOUNTERWORKER_H
#define KDIRECTORYCONTENTENTSCOUNTERWORKER_H
-#include <QFlags>
#include <QMetaType>
#include <QObject>
diff --git a/src/kitemviews/private/kfileitemclipboard.cpp b/src/kitemviews/private/kfileitemclipboard.cpp
index 0dcc81f4f..e12767853 100644
--- a/src/kitemviews/private/kfileitemclipboard.cpp
+++ b/src/kitemviews/private/kfileitemclipboard.cpp
@@ -19,17 +19,17 @@
#include "kfileitemclipboard.h"
-#include <KGlobal>
#include <QApplication>
#include <QClipboard>
#include <QMimeData>
+#include <KUrlMimeData>
class KFileItemClipboardSingleton
{
public:
KFileItemClipboard instance;
};
-K_GLOBAL_STATIC(KFileItemClipboardSingleton, s_KFileItemClipboard)
+Q_GLOBAL_STATIC(KFileItemClipboardSingleton, s_KFileItemClipboard)
@@ -38,12 +38,12 @@ KFileItemClipboard* KFileItemClipboard::instance()
return &s_KFileItemClipboard->instance;
}
-bool KFileItemClipboard::isCut(const KUrl& url) const
+bool KFileItemClipboard::isCut(const QUrl& url) const
{
return m_cutItems.contains(url);
}
-QList<KUrl> KFileItemClipboard::cutItems() const
+QList<QUrl> KFileItemClipboard::cutItems() const
{
return m_cutItems.toList();
}
@@ -66,7 +66,7 @@ void KFileItemClipboard::updateCutItems()
const QByteArray data = mimeData->data("application/x-kde-cutselection");
const bool isCutSelection = (!data.isEmpty() && data.at(0) == QLatin1Char('1'));
if (isCutSelection) {
- m_cutItems = KUrl::List::fromMimeData(mimeData).toSet();
+ m_cutItems = KUrlMimeData::urlsFromMimeData(mimeData).toSet();
} else {
m_cutItems.clear();
}
@@ -79,8 +79,6 @@ KFileItemClipboard::KFileItemClipboard() :
{
updateCutItems();
- connect(QApplication::clipboard(), SIGNAL(dataChanged()),
- this, SLOT(updateCutItems()));
+ connect(QApplication::clipboard(), &QClipboard::dataChanged,
+ this, &KFileItemClipboard::updateCutItems);
}
-
-#include "kfileitemclipboard.moc"
diff --git a/src/kitemviews/private/kfileitemclipboard.h b/src/kitemviews/private/kfileitemclipboard.h
index 86eb8e9fc..3ee50d661 100644
--- a/src/kitemviews/private/kfileitemclipboard.h
+++ b/src/kitemviews/private/kfileitemclipboard.h
@@ -20,27 +20,27 @@
#ifndef KFILEITEMCLIPBOARD_H
#define KFILEITEMCLIPBOARD_H
-#include <KUrl>
+#include <QUrl>
#include <QList>
#include <QSet>
#include <QObject>
-#include "libdolphin_export.h"
+#include "dolphin_export.h"
/**
* @brief Wrapper for QClipboard to provide fast access for checking
* whether a KFileItem has been clipped.
*/
-class LIBDOLPHINPRIVATE_EXPORT KFileItemClipboard : public QObject
+class DOLPHIN_EXPORT KFileItemClipboard : public QObject
{
Q_OBJECT
public:
static KFileItemClipboard* instance();
- bool isCut(const KUrl& url) const;
+ bool isCut(const QUrl& url) const;
- QList<KUrl> cutItems() const;
+ QList<QUrl> cutItems() const;
signals:
void cutItemsChanged();
@@ -54,7 +54,7 @@ private slots:
private:
KFileItemClipboard();
- QSet<KUrl> m_cutItems;
+ QSet<QUrl> m_cutItems;
friend class KFileItemClipboardSingleton;
};
diff --git a/src/kitemviews/private/kfileitemmodeldirlister.cpp b/src/kitemviews/private/kfileitemmodeldirlister.cpp
index 3d36386a9..778625573 100644
--- a/src/kitemviews/private/kfileitemmodeldirlister.cpp
+++ b/src/kitemviews/private/kfileitemmodeldirlister.cpp
@@ -18,8 +18,8 @@
***************************************************************************/
#include "kfileitemmodeldirlister.h"
-#include <KLocale>
-#include <KIO/JobClasses>
+#include <KLocalizedString>
+#include <KIO/Job>
KFileItemModelDirLister::KFileItemModelDirLister(QObject* parent) :
KDirLister(parent)
@@ -45,4 +45,3 @@ void KFileItemModelDirLister::handleError(KIO::Job* job)
}
}
-#include "kfileitemmodeldirlister.moc"
diff --git a/src/kitemviews/private/kfileitemmodeldirlister.h b/src/kitemviews/private/kfileitemmodeldirlister.h
index 688ee9c5b..c2c621aed 100644
--- a/src/kitemviews/private/kfileitemmodeldirlister.h
+++ b/src/kitemviews/private/kfileitemmodeldirlister.h
@@ -20,15 +20,16 @@
#ifndef KFILEITEMMODELDIRLISTER_H
#define KFILEITEMMODELDIRLISTER_H
-#include <libdolphin_export.h>
+#include "dolphin_export.h"
#include <KDirLister>
+#include <QUrl>
/**
* @brief Extends the class KDirLister by emitting a signal when an
* error occurred instead of showing an error dialog.
* KDirLister::autoErrorHandlingEnabled() is set to false.
*/
-class LIBDOLPHINPRIVATE_EXPORT KFileItemModelDirLister : public KDirLister
+class DOLPHIN_EXPORT KFileItemModelDirLister : public KDirLister
{
Q_OBJECT
@@ -44,7 +45,7 @@ signals:
* Is emitted when the URL of the directory lister represents a file.
* In this case no signal errorMessage() will be emitted.
*/
- void urlIsFileError(const KUrl& url);
+ void urlIsFileError(const QUrl& url);
protected:
virtual void handleError(KIO::Job* job);
diff --git a/src/kitemviews/private/kfileitemmodelfilter.h b/src/kitemviews/private/kfileitemmodelfilter.h
index e4fb0a2ee..67c1c280c 100644
--- a/src/kitemviews/private/kfileitemmodelfilter.h
+++ b/src/kitemviews/private/kfileitemmodelfilter.h
@@ -21,7 +21,7 @@
#ifndef KFILEITEMMODELFILTER_H
#define KFILEITEMMODELFILTER_H
-#include <libdolphin_export.h>
+#include "dolphin_export.h"
#include <QStringList>
class KFileItem;
@@ -35,7 +35,7 @@ class QRegExp;
* property of the KFileItem, but this might get extended in
* future.
*/
-class LIBDOLPHINPRIVATE_EXPORT KFileItemModelFilter
+class DOLPHIN_EXPORT KFileItemModelFilter
{
public:
diff --git a/src/kitemviews/private/kfileitemmodelsortalgorithm.h b/src/kitemviews/private/kfileitemmodelsortalgorithm.h
index 1d5689432..50db9900d 100644
--- a/src/kitemviews/private/kfileitemmodelsortalgorithm.h
+++ b/src/kitemviews/private/kfileitemmodelsortalgorithm.h
@@ -22,7 +22,7 @@
#ifndef KFILEITEMMODELSORTALGORITHM_H
#define KFILEITEMMODELSORTALGORITHM_H
-#include <QtCore>
+#include <QtConcurrent/QtConcurrent>
#include <algorithm>
diff --git a/src/kitemviews/private/kitemlistheaderwidget.cpp b/src/kitemviews/private/kitemlistheaderwidget.cpp
index 1f210ab5a..45ce4e759 100644
--- a/src/kitemviews/private/kitemlistheaderwidget.cpp
+++ b/src/kitemviews/private/kitemlistheaderwidget.cpp
@@ -19,8 +19,6 @@
#include "kitemlistheaderwidget.h"
-#include <KAction>
-#include <KMenu>
#include <kitemviews/kitemmodelbase.h>
#include <QApplication>
@@ -28,7 +26,6 @@
#include <QPainter>
#include <QStyleOptionHeader>
-#include <KDebug>
KItemListHeaderWidget::KItemListHeaderWidget(QGraphicsWidget* parent) :
QGraphicsWidget(parent),
@@ -62,19 +59,19 @@ void KItemListHeaderWidget::setModel(KItemModelBase* model)
}
if (m_model) {
- disconnect(m_model, SIGNAL(sortRoleChanged(QByteArray,QByteArray)),
- this, SLOT(slotSortRoleChanged(QByteArray,QByteArray)));
- disconnect(m_model, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder)),
- this, SLOT(slotSortOrderChanged(Qt::SortOrder,Qt::SortOrder)));
+ disconnect(m_model, &KItemModelBase::sortRoleChanged,
+ this, &KItemListHeaderWidget::slotSortRoleChanged);
+ disconnect(m_model, &KItemModelBase::sortOrderChanged,
+ this, &KItemListHeaderWidget::slotSortOrderChanged);
}
m_model = model;
if (m_model) {
- connect(m_model, SIGNAL(sortRoleChanged(QByteArray,QByteArray)),
- this, SLOT(slotSortRoleChanged(QByteArray,QByteArray)));
- connect(m_model, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder)),
- this, SLOT(slotSortOrderChanged(Qt::SortOrder,Qt::SortOrder)));
+ connect(m_model, &KItemModelBase::sortRoleChanged,
+ this, &KItemListHeaderWidget::slotSortRoleChanged);
+ connect(m_model, &KItemModelBase::sortOrderChanged,
+ this, &KItemListHeaderWidget::slotSortOrderChanged);
}
}
@@ -569,4 +566,3 @@ qreal KItemListHeaderWidget::roleXPosition(const QByteArray& role) const
return -1;
}
-#include "kitemlistheaderwidget.moc"
diff --git a/src/kitemviews/private/kitemlistheaderwidget.h b/src/kitemviews/private/kitemlistheaderwidget.h
index b99f45f35..307def74d 100644
--- a/src/kitemviews/private/kitemlistheaderwidget.h
+++ b/src/kitemviews/private/kitemlistheaderwidget.h
@@ -20,7 +20,7 @@
#ifndef KITEMLISTHEADERWIDGET_H
#define KITEMLISTHEADERWIDGET_H
-#include <libdolphin_export.h>
+#include "dolphin_export.h"
#include <QGraphicsWidget>
#include <QHash>
#include <QList>
@@ -33,7 +33,7 @@ class KItemModelBase;
* The widget is an internal API, the user of KItemListView may only access the
* class KItemListHeader.
*/
-class LIBDOLPHINPRIVATE_EXPORT KItemListHeaderWidget : public QGraphicsWidget
+class DOLPHIN_EXPORT KItemListHeaderWidget : public QGraphicsWidget
{
Q_OBJECT
diff --git a/src/kitemviews/private/kitemlistkeyboardsearchmanager.cpp b/src/kitemviews/private/kitemlistkeyboardsearchmanager.cpp
index 3bd1b01f3..ffa92a1cf 100644
--- a/src/kitemviews/private/kitemlistkeyboardsearchmanager.cpp
+++ b/src/kitemviews/private/kitemlistkeyboardsearchmanager.cpp
@@ -22,8 +22,6 @@
#include "kitemlistkeyboardsearchmanager.h"
-#include <QApplication>
-#include <QElapsedTimer>
KItemListKeyboardSearchManager::KItemListKeyboardSearchManager(QObject* parent) :
QObject(parent),
diff --git a/src/kitemviews/private/kitemlistkeyboardsearchmanager.h b/src/kitemviews/private/kitemlistkeyboardsearchmanager.h
index 661178db8..2a14ca470 100644
--- a/src/kitemviews/private/kitemlistkeyboardsearchmanager.h
+++ b/src/kitemviews/private/kitemlistkeyboardsearchmanager.h
@@ -23,7 +23,7 @@
#ifndef KITEMLISTKEYBOARDSEARCHMANAGER_H
#define KITEMLISTKEYBOARDSEARCHMANAGER_H
-#include <libdolphin_export.h>
+#include "dolphin_export.h"
#include <QObject>
#include <QString>
@@ -35,7 +35,7 @@
* @see KItemListController
* @see KItemModelBase
*/
-class LIBDOLPHINPRIVATE_EXPORT KItemListKeyboardSearchManager : public QObject
+class DOLPHIN_EXPORT KItemListKeyboardSearchManager : public QObject
{
Q_OBJECT
diff --git a/src/kitemviews/private/kitemlistroleeditor.cpp b/src/kitemviews/private/kitemlistroleeditor.cpp
index 0a48f1ba0..5ff013429 100644
--- a/src/kitemviews/private/kitemlistroleeditor.cpp
+++ b/src/kitemviews/private/kitemlistroleeditor.cpp
@@ -19,8 +19,7 @@
#include "kitemlistroleeditor.h"
-#include <KDebug>
-#include <kio/global.h>
+#include <KIO/Global>
#include <QKeyEvent>
KItemListRoleEditor::KItemListRoleEditor(QWidget *parent) :
@@ -38,7 +37,7 @@ KItemListRoleEditor::KItemListRoleEditor(QWidget *parent) :
parent->installEventFilter(this);
}
- connect(this, SIGNAL(textChanged()), this, SLOT(autoAdjustSize()));
+ connect(this, &KItemListRoleEditor::textChanged, this, &KItemListRoleEditor::autoAdjustSize);
}
KItemListRoleEditor::~KItemListRoleEditor()
@@ -148,4 +147,3 @@ void KItemListRoleEditor::emitRoleEditingFinished()
}
}
-#include "kitemlistroleeditor.moc"
diff --git a/src/kitemviews/private/kitemlistroleeditor.h b/src/kitemviews/private/kitemlistroleeditor.h
index 7c2b61e2d..3b8f96865 100644
--- a/src/kitemviews/private/kitemlistroleeditor.h
+++ b/src/kitemviews/private/kitemlistroleeditor.h
@@ -20,7 +20,7 @@
#ifndef KITEMLISTROLEEDITOR_H
#define KITEMLISTROLEEDITOR_H
-#include "libdolphin_export.h"
+#include "dolphin_export.h"
#include <KTextEdit>
@@ -33,7 +33,7 @@
*
* The size automatically gets increased if the text does not fit.
*/
-class LIBDOLPHINPRIVATE_EXPORT KItemListRoleEditor : public KTextEdit
+class DOLPHIN_EXPORT KItemListRoleEditor : public KTextEdit
{
Q_OBJECT
diff --git a/src/kitemviews/private/kitemlistrubberband.cpp b/src/kitemviews/private/kitemlistrubberband.cpp
index 58567c460..702873126 100644
--- a/src/kitemviews/private/kitemlistrubberband.cpp
+++ b/src/kitemviews/private/kitemlistrubberband.cpp
@@ -88,4 +88,3 @@ bool KItemListRubberBand::isActive() const
return m_active;
}
-#include "kitemlistrubberband.moc"
diff --git a/src/kitemviews/private/kitemlistrubberband.h b/src/kitemviews/private/kitemlistrubberband.h
index aea58af46..b47c30c1f 100644
--- a/src/kitemviews/private/kitemlistrubberband.h
+++ b/src/kitemviews/private/kitemlistrubberband.h
@@ -20,14 +20,14 @@
#ifndef KITEMLISTRUBBERBAND_H
#define KITEMLISTRUBBERBAND_H
-#include <libdolphin_export.h>
+#include "dolphin_export.h"
#include <QObject>
#include <QPointF>
/**
* @brief Manages the rubberband when selecting items.
*/
-class LIBDOLPHINPRIVATE_EXPORT KItemListRubberBand : public QObject
+class DOLPHIN_EXPORT KItemListRubberBand : public QObject
{
Q_OBJECT
diff --git a/src/kitemviews/private/kitemlistselectiontoggle.cpp b/src/kitemviews/private/kitemlistselectiontoggle.cpp
index accbe5181..d4081a690 100644
--- a/src/kitemviews/private/kitemlistselectiontoggle.cpp
+++ b/src/kitemviews/private/kitemlistselectiontoggle.cpp
@@ -19,11 +19,9 @@
#include "kitemlistselectiontoggle.h"
-#include <KIconEffect>
#include <KIconLoader>
#include <QPainter>
-#include <KDebug>
KItemListSelectionToggle::KItemListSelectionToggle(QGraphicsItem* parent) :
QGraphicsWidget(parent, 0),
@@ -115,4 +113,3 @@ int KItemListSelectionToggle::iconSize() const
return iconSize;
}
-#include "kitemlistselectiontoggle.moc"
diff --git a/src/kitemviews/private/kitemlistselectiontoggle.h b/src/kitemviews/private/kitemlistselectiontoggle.h
index 758dc63bb..d058ee988 100644
--- a/src/kitemviews/private/kitemlistselectiontoggle.h
+++ b/src/kitemviews/private/kitemlistselectiontoggle.h
@@ -20,17 +20,16 @@
#ifndef KITEMLISTSELECTIONTOGGLE_H
#define KITEMLISTSELECTIONTOGGLE_H
-#include <libdolphin_export.h>
+#include "dolphin_export.h"
#include <QGraphicsWidget>
#include <QPixmap>
-class QPropertyAnimation;
/**
* @brief Allows to toggle between the selected and unselected state of an item.
*/
-class LIBDOLPHINPRIVATE_EXPORT KItemListSelectionToggle : public QGraphicsWidget
+class DOLPHIN_EXPORT KItemListSelectionToggle : public QGraphicsWidget
{
Q_OBJECT
diff --git a/src/kitemviews/private/kitemlistsizehintresolver.h b/src/kitemviews/private/kitemlistsizehintresolver.h
index a0ad033f3..ff17f2de2 100644
--- a/src/kitemviews/private/kitemlistsizehintresolver.h
+++ b/src/kitemviews/private/kitemlistsizehintresolver.h
@@ -20,7 +20,7 @@
#ifndef KITEMLISTSIZEHINTRESOLVER_H
#define KITEMLISTSIZEHINTRESOLVER_H
-#include <libdolphin_export.h>
+#include "dolphin_export.h"
#include <kitemviews/kitemmodelbase.h>
#include <QSizeF>
@@ -31,7 +31,7 @@ class KItemListView;
/**
* @brief Calculates and caches the sizehints of items in KItemListView.
*/
-class LIBDOLPHINPRIVATE_EXPORT KItemListSizeHintResolver
+class DOLPHIN_EXPORT KItemListSizeHintResolver
{
public:
KItemListSizeHintResolver(const KItemListView* itemListView);
diff --git a/src/kitemviews/private/kitemlistsmoothscroller.cpp b/src/kitemviews/private/kitemlistsmoothscroller.cpp
index 491461b80..e70f47890 100644
--- a/src/kitemviews/private/kitemlistsmoothscroller.cpp
+++ b/src/kitemviews/private/kitemlistsmoothscroller.cpp
@@ -19,13 +19,11 @@
#include "kitemlistsmoothscroller.h"
-#include <KGlobalSettings>
#include <QEvent>
#include <QPropertyAnimation>
#include <QScrollBar>
#include <QWheelEvent>
-
-#include <KDebug>
+#include <QStyle>
KItemListSmoothScroller::KItemListSmoothScroller(QScrollBar* scrollBar,
QObject* parent) :
@@ -36,10 +34,10 @@ KItemListSmoothScroller::KItemListSmoothScroller(QScrollBar* scrollBar,
m_animation(0)
{
m_animation = new QPropertyAnimation(this);
- const int duration = (KGlobalSettings::graphicEffectsLevel() == KGlobalSettings::NoEffects) ? 1 : 100;
+ const int duration = m_scrollBar->style()->styleHint(QStyle::SH_Widget_Animate, nullptr, m_scrollBar) ? 100 : 1;
m_animation->setDuration(duration);
- connect(m_animation, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)),
- this, SLOT(slotAnimationStateChanged(QAbstractAnimation::State,QAbstractAnimation::State)));
+ connect(m_animation, &QPropertyAnimation::stateChanged,
+ this, &KItemListSmoothScroller::slotAnimationStateChanged);
m_scrollBar->installEventFilter(this);
}
@@ -209,4 +207,3 @@ void KItemListSmoothScroller::handleWheelEvent(QWheelEvent* event)
event->accept();
}
-#include "kitemlistsmoothscroller.moc"
diff --git a/src/kitemviews/private/kitemlistsmoothscroller.h b/src/kitemviews/private/kitemlistsmoothscroller.h
index ea5682208..fca4b0c53 100644
--- a/src/kitemviews/private/kitemlistsmoothscroller.h
+++ b/src/kitemviews/private/kitemlistsmoothscroller.h
@@ -20,7 +20,7 @@
#ifndef KITEMLISTSMOOTHSCROLLER_H
#define KITEMLISTSMOOTHSCROLLER_H
-#include <libdolphin_export.h>
+#include "dolphin_export.h"
#include <QAbstractAnimation>
#include <QObject>
@@ -33,7 +33,7 @@ class QWheelEvent;
* @brief Helper class for KItemListContainer to have a smooth
* scrolling when adjusting the scrollbars.
*/
-class LIBDOLPHINPRIVATE_EXPORT KItemListSmoothScroller : public QObject
+class DOLPHIN_EXPORT KItemListSmoothScroller : public QObject
{
Q_OBJECT
diff --git a/src/kitemviews/private/kitemlistviewanimation.cpp b/src/kitemviews/private/kitemlistviewanimation.cpp
index 5a00c8c3a..67ad192c6 100644
--- a/src/kitemviews/private/kitemlistviewanimation.cpp
+++ b/src/kitemviews/private/kitemlistviewanimation.cpp
@@ -21,22 +21,16 @@
#include <kitemviews/kitemlistview.h>
-#include <KDebug>
-#include <KGlobalSettings>
#include <QGraphicsWidget>
#include <QPropertyAnimation>
KItemListViewAnimation::KItemListViewAnimation(QObject* parent) :
QObject(parent),
- m_animationDuration(200),
m_scrollOrientation(Qt::Vertical),
m_scrollOffset(0),
m_animation()
{
- if (KGlobalSettings::graphicEffectsLevel() == KGlobalSettings::NoEffects) {
- m_animationDuration = 1;
- }
}
KItemListViewAnimation::~KItemListViewAnimation()
@@ -123,6 +117,7 @@ void KItemListViewAnimation::start(QGraphicsWidget* widget, AnimationType type,
stop(widget, type);
QPropertyAnimation* propertyAnim = 0;
+ const int animationDuration = widget->style()->styleHint(QStyle::SH_Widget_Animate) ? 200 : 1;
switch (type) {
case MovingAnimation: {
@@ -132,7 +127,7 @@ void KItemListViewAnimation::start(QGraphicsWidget* widget, AnimationType type,
}
propertyAnim = new QPropertyAnimation(widget, "pos");
- propertyAnim->setDuration(m_animationDuration);
+ propertyAnim->setDuration(animationDuration);
propertyAnim->setEndValue(newPos);
break;
}
@@ -140,7 +135,7 @@ void KItemListViewAnimation::start(QGraphicsWidget* widget, AnimationType type,
case CreateAnimation: {
propertyAnim = new QPropertyAnimation(widget, "opacity");
propertyAnim->setEasingCurve(QEasingCurve::InQuart);
- propertyAnim->setDuration(m_animationDuration);
+ propertyAnim->setDuration(animationDuration);
propertyAnim->setStartValue(0.0);
propertyAnim->setEndValue(1.0);
break;
@@ -149,7 +144,7 @@ void KItemListViewAnimation::start(QGraphicsWidget* widget, AnimationType type,
case DeleteAnimation: {
propertyAnim = new QPropertyAnimation(widget, "opacity");
propertyAnim->setEasingCurve(QEasingCurve::OutQuart);
- propertyAnim->setDuration(m_animationDuration);
+ propertyAnim->setDuration(animationDuration);
propertyAnim->setStartValue(1.0);
propertyAnim->setEndValue(0.0);
break;
@@ -162,7 +157,7 @@ void KItemListViewAnimation::start(QGraphicsWidget* widget, AnimationType type,
}
propertyAnim = new QPropertyAnimation(widget, "size");
- propertyAnim->setDuration(m_animationDuration);
+ propertyAnim->setDuration(animationDuration);
propertyAnim->setEndValue(newSize);
break;
}
@@ -172,7 +167,7 @@ void KItemListViewAnimation::start(QGraphicsWidget* widget, AnimationType type,
}
Q_ASSERT(propertyAnim);
- connect(propertyAnim, SIGNAL(finished()), this, SLOT(slotFinished()));
+ connect(propertyAnim, &QPropertyAnimation::finished, this, &KItemListViewAnimation::slotFinished);
m_animation[type].insert(widget, propertyAnim);
propertyAnim->start();
@@ -242,4 +237,3 @@ void KItemListViewAnimation::slotFinished()
Q_ASSERT(false);
}
-#include "kitemlistviewanimation.moc"
diff --git a/src/kitemviews/private/kitemlistviewanimation.h b/src/kitemviews/private/kitemlistviewanimation.h
index a3aceb0f5..06c81c9b8 100644
--- a/src/kitemviews/private/kitemlistviewanimation.h
+++ b/src/kitemviews/private/kitemlistviewanimation.h
@@ -20,7 +20,7 @@
#ifndef KITEMLISTVIEWANIMATION_H
#define KITEMLISTVIEWANIMATION_H
-#include <libdolphin_export.h>
+#include "dolphin_export.h"
#include <QHash>
#include <QObject>
@@ -28,7 +28,6 @@
class KItemListView;
class QGraphicsWidget;
-class QPointF;
class QPropertyAnimation;
/**
@@ -37,7 +36,7 @@ class QPropertyAnimation;
* Supports item animations for moving, creating, deleting and resizing
* an item. Several applications can be applied to one item in parallel.
*/
-class LIBDOLPHINPRIVATE_EXPORT KItemListViewAnimation : public QObject
+class DOLPHIN_EXPORT KItemListViewAnimation : public QObject
{
Q_OBJECT
@@ -95,7 +94,6 @@ private slots:
private:
enum { AnimationTypeCount = 4 };
- int m_animationDuration;
Qt::Orientation m_scrollOrientation;
qreal m_scrollOffset;
QHash<QGraphicsWidget*, QPropertyAnimation*> m_animation[AnimationTypeCount];
diff --git a/src/kitemviews/private/kitemlistviewlayouter.cpp b/src/kitemviews/private/kitemlistviewlayouter.cpp
index 04325c7d0..d54457908 100644
--- a/src/kitemviews/private/kitemlistviewlayouter.cpp
+++ b/src/kitemviews/private/kitemlistviewlayouter.cpp
@@ -22,7 +22,7 @@
#include <kitemviews/kitemmodelbase.h>
#include "kitemlistsizehintresolver.h"
-#include <KDebug>
+#include "dolphindebug.h"
// #define KITEMLISTVIEWLAYOUTER_DEBUG
@@ -516,7 +516,7 @@ void KItemListViewLayouter::doLayout()
}
#ifdef KITEMLISTVIEWLAYOUTER_DEBUG
- kDebug() << "[TIME] doLayout() for " << m_model->count() << "items:" << timer.elapsed();
+ qCDebug(DolphinDebug) << "[TIME] doLayout() for " << m_model->count() << "items:" << timer.elapsed();
#endif
m_dirty = false;
}
@@ -621,4 +621,3 @@ qreal KItemListViewLayouter::minimumGroupHeaderWidth() const
return 100;
}
-#include "kitemlistviewlayouter.moc"
diff --git a/src/kitemviews/private/kitemlistviewlayouter.h b/src/kitemviews/private/kitemlistviewlayouter.h
index 0efcab12b..3f1cf68d4 100644
--- a/src/kitemviews/private/kitemlistviewlayouter.h
+++ b/src/kitemviews/private/kitemlistviewlayouter.h
@@ -20,7 +20,7 @@
#ifndef KITEMLISTVIEWLAYOUTER_H
#define KITEMLISTVIEWLAYOUTER_H
-#include <libdolphin_export.h>
+#include "dolphin_export.h"
#include <QObject>
#include <QRectF>
@@ -45,7 +45,7 @@ class KItemListSizeHintResolver;
* changing properties of the layouter is not expensive, only the
* first read of a property can get expensive.
*/
-class LIBDOLPHINPRIVATE_EXPORT KItemListViewLayouter : public QObject
+class DOLPHIN_EXPORT KItemListViewLayouter : public QObject
{
Q_OBJECT
diff --git a/src/kitemviews/private/kpixmapmodifier.cpp b/src/kitemviews/private/kpixmapmodifier.cpp
index 29aceb66b..c564ecc30 100644
--- a/src/kitemviews/private/kpixmapmodifier.cpp
+++ b/src/kitemviews/private/kpixmapmodifier.cpp
@@ -39,7 +39,6 @@
#include <QPixmap>
#include <QSize>
-#include <KDebug>
#include <config-X11.h> // for HAVE_XRENDER
#if defined(Q_WS_X11) && defined(HAVE_XRENDER)
diff --git a/src/kitemviews/private/kpixmapmodifier.h b/src/kitemviews/private/kpixmapmodifier.h
index 4f863c349..e8ca11ac1 100644
--- a/src/kitemviews/private/kpixmapmodifier.h
+++ b/src/kitemviews/private/kpixmapmodifier.h
@@ -20,12 +20,12 @@
#ifndef KPIXMAPMODIFIER_H
#define KPIXMAPMODIFIER_H
-#include <libdolphin_export.h>
+#include "dolphin_export.h"
class QPixmap;
class QSize;
-class LIBDOLPHINPRIVATE_EXPORT KPixmapModifier
+class DOLPHIN_EXPORT KPixmapModifier
{
public:
static void scale(QPixmap& pixmap, const QSize& scaledSize);
diff --git a/src/libdolphin_export.h b/src/libdolphin_export.h
deleted file mode 100644
index ff0f125c4..000000000
--- a/src/libdolphin_export.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- This file is part of the KDE project
- Copyright (C) 2007 Montel Laurent <[email protected]>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License version 2 as published by the Free Software Foundation.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#ifndef LIBDOLPHIN_EXPORT_H
-#define LIBDOLPHIN_EXPORT_H
-
-/* needed for KDE_EXPORT macros */
-#include <kdemacros.h>
-
-/* needed, because e.g. Q_OS_UNIX is so frequently used */
-
-#ifndef LIBDOLPHINPRIVATE_EXPORT
-# if defined(MAKE_DOLPHINPRIVATE_LIB)
- /* We are building this library */
-# define LIBDOLPHINPRIVATE_EXPORT KDE_EXPORT
-# else
- /* We are using this library */
-# define LIBDOLPHINPRIVATE_EXPORT KDE_IMPORT
-# endif
-#endif
-
-#endif
diff --git a/src/main.cpp b/src/main.cpp
index f0ab1d9dc..e8d6c2d29 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,6 +1,7 @@
/***************************************************************************
* Copyright (C) 2006 by Peter Penz <[email protected]> *
* Copyright (C) 2006 by Stefan Monov <[email protected]> *
+ * Copyright (C) 2015 by Mathieu Tarral <[email protected]> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@@ -18,80 +19,142 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
-#include "dolphinapplication.h"
-
#include "dolphinmainwindow.h"
+#include "dolphin_generalsettings.h"
+#include <KDBusService>
#include <KAboutData>
-#include <KCmdLineArgs>
-#include <KLocale>
-#include <kmainwindow.h>
-#include <KDebug>
+#include <QCommandLineParser>
+#include <QCommandLineOption>
+#include <QApplication>
+#include <KLocalizedString>
+#include "dolphindebug.h"
+#include <kdelibs4configmigrator.h>
-extern "C"
-KDE_EXPORT int kdemain(int argc, char **argv)
+extern "C" Q_DECL_EXPORT int kdemain(int argc, char **argv)
{
- KAboutData about("dolphin", 0,
- ki18nc("@title", "Dolphin"),
- "14.12.3",
- ki18nc("@title", "File Manager"),
- KAboutData::License_GPL,
- ki18nc("@info:credit", "(C) 2006-2014 Peter Penz, Frank Reininghaus, and Emmanuel Pescosta"));
- about.setHomepage("http://dolphin.kde.org");
- about.addAuthor(ki18nc("@info:credit", "Emmanuel Pescosta"),
- ki18nc("@info:credit", "Maintainer (since 2014) and developer"),
- about.addAuthor(ki18nc("@info:credit", "Frank Reininghaus"),
- ki18nc("@info:credit", "Maintainer (2012-2014) and developer"),
- about.addAuthor(ki18nc("@info:credit", "Peter Penz"),
- ki18nc("@info:credit", "Maintainer and developer (2006-2012)"),
- about.addAuthor(ki18nc("@info:credit", "Sebastian Trüg"),
- ki18nc("@info:credit", "Developer"),
- about.addAuthor(ki18nc("@info:credit", "David Faure"),
- ki18nc("@info:credit", "Developer"),
- about.addAuthor(ki18nc("@info:credit", "Aaron J. Seigo"),
- ki18nc("@info:credit", "Developer"),
- about.addAuthor(ki18nc("@info:credit", "Rafael Fernández López"),
- ki18nc("@info:credit", "Developer"),
- about.addAuthor(ki18nc("@info:credit", "Kevin Ottens"),
- ki18nc("@info:credit", "Developer"),
- about.addAuthor(ki18nc("@info:credit", "Holger Freyther"),
- ki18nc("@info:credit", "Developer"),
- about.addAuthor(ki18nc("@info:credit", "Max Blazejak"),
- ki18nc("@info:credit", "Developer"),
- about.addAuthor(ki18nc("@info:credit", "Michael Austin"),
- ki18nc("@info:credit", "Documentation"),
- // the .desktop file is not taken into account when launching manually, so
- // set the icon precautionally:
- about.setProgramIconName("system-file-manager");
+ QApplication app(argc, argv);
+ Kdelibs4ConfigMigrator migrate(QStringLiteral("dolphin"));
+ migrate.setConfigFiles(QStringList() << QStringLiteral("dolphinrc"));
+ migrate.setUiFiles(QStringList() << QStringLiteral("dolphinpart.rc") << QStringLiteral("dolphinui.rc"));
+ migrate.migrate();
+
+ app.setWindowIcon(QIcon::fromTheme("system-file-manager"));
+
+ KAboutData aboutData("dolphin", i18n("Dolphin"), "14.12.95",
+ i18nc("@title", "File Manager"),
+ KAboutLicense::GPL,
+ i18nc("@info:credit", "(C) 2006-2014 Peter Penz, Frank Reininghaus, and Emmanuel Pescosta"));
+ aboutData.setHomepage("http://dolphin.kde.org");
+ aboutData.addAuthor(i18nc("@info:credit", "Emmanuel Pescosta"),
+ i18nc("@info:credit", "Maintainer (since 2014) and developer"),
+ aboutData.addAuthor(i18nc("@info:credit", "Frank Reininghaus"),
+ i18nc("@info:credit", "Maintainer (2012-2014) and developer"),
+ aboutData.addAuthor(i18nc("@info:credit", "Peter Penz"),
+ i18nc("@info:credit", "Maintainer and developer (2006-2012)"),
+ aboutData.addAuthor(i18nc("@info:credit", "Sebastian Trüg"),
+ i18nc("@info:credit", "Developer"),
+ aboutData.addAuthor(i18nc("@info:credit", "David Faure"),
+ i18nc("@info:credit", "Developer"),
+ aboutData.addAuthor(i18nc("@info:credit", "Aaron J. Seigo"),
+ i18nc("@info:credit", "Developer"),
+ aboutData.addAuthor(i18nc("@info:credit", "Rafael Fernández López"),
+ i18nc("@info:credit", "Developer"),
+ aboutData.addAuthor(i18nc("@info:credit", "Kevin Ottens"),
+ i18nc("@info:credit", "Developer"),
+ aboutData.addAuthor(i18nc("@info:credit", "Holger Freyther"),
+ i18nc("@info:credit", "Developer"),
+ aboutData.addAuthor(i18nc("@info:credit", "Max Blazejak"),
+ i18nc("@info:credit", "Developer"),
+ aboutData.addAuthor(i18nc("@info:credit", "Michael Austin"),
+ i18nc("@info:credit", "Documentation"),
+
+ KAboutData::setApplicationData(aboutData);
+
+ KDBusService dolphinDBusService;
+
+ QCommandLineParser parser;
+ parser.addVersionOption();
+ parser.addHelpOption();
+ aboutData.setupCommandLine(&parser);
+
+ // command line options
+ parser.addOption(QCommandLineOption(QStringList() << QLatin1String("select"), i18nc("@info:shell", "The files and directories passed as arguments "
+ "will be selected.")));
+ parser.addOption(QCommandLineOption(QStringList() << QLatin1String("split"), i18nc("@info:shell", "Dolphin will get started with a split view.")));
+ parser.addPositionalArgument(QLatin1String("+[Url]"), i18nc("@info:shell", "Document to open"));
+
+ parser.process(app);
+ aboutData.processCommandLine(&parser);
+
+
+ DolphinMainWindow* m_mainWindow = new DolphinMainWindow();
+ m_mainWindow->setAttribute(Qt::WA_DeleteOnClose);
- KCmdLineArgs::init(argc, argv, &about);
+ QList<QUrl> urls;
+ const QStringList args = parser.positionalArguments();
+ foreach (const QString& str, args) {
+ const QUrl url = QUrl::fromUserInput(str, QString(), QUrl::AssumeLocalFile);
+ if (url.isValid()) {
+ urls.append(url);
+ } else {
+ qCWarning(DolphinDebug) << "Invalid URL: " << str;
+ }
+ }
+
+ bool resetSplitSettings = false;
+ if (parser.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));
+ }
+ }
- KCmdLineOptions options;
+ if (!urls.isEmpty()) {
+ if (parser.isSet("select")) {
+ m_mainWindow->openFiles(urls);
+ } else {
+ m_mainWindow->openDirectories(urls);
+ }
+ } else {
+ const QUrl homeUrl(QUrl::fromLocalFile(GeneralSettings::homeUrl()));
+ m_mainWindow->openNewActivatedTab(homeUrl);
+ }
+
+ if (resetSplitSettings) {
+ GeneralSettings::setSplitView(false);
+ }
- options.add("select", ki18nc("@info:shell", "The files and directories passed as arguments "
- "will be selected."));
- options.add("split", ki18nc("@info:shell", "Dolphin will get started with a split view."));
- options.add("+[Url]", ki18nc("@info:shell", "Document to open"));
- KCmdLineArgs::addCmdLineOptions(options);
+ m_mainWindow->show();
- {
- DolphinApplication app;
- if (app.isSessionRestored()) {
- app.restoreSession();
+ if (app.isSessionRestored()) {
+ const QString className = KXmlGuiWindow::classNameOfToplevel(1);
+ if (className == QLatin1String("DolphinMainWindow")) {
+ m_mainWindow->restore(1);
+ } else {
+ qCWarning(DolphinDebug) << "Unknown class " << className << " in session saved data!";
}
- app.exec(); // krazy:exclude=crashy
}
- return 0;
+ return app.exec(); // krazy:exclude=crash;
}
diff --git a/src/dolphin.desktop b/src/org.kde.dolphin.desktop
index 364bf7920..8c8c86402 100755
--- a/src/dolphin.desktop
+++ b/src/org.kde.dolphin.desktop
@@ -88,7 +88,7 @@ Name[wa]=Dolphin
Name[x-test]=xxDolphinxx
Name[zh_CN]=Dolphin
Name[zh_TW]=Dolphin
-Exec=dolphin %i -caption %c %u
+Exec=dolphin %u
Icon=system-file-manager
Type=Application
X-DocPath=dolphin/index.html
@@ -186,3 +186,4 @@ GenericName[zh_TW]=檔案管理員
Terminal=false
MimeType=inode/directory;
InitialPreference=10
+X-DBUS-ServiceName=org.kde.dolphin
diff --git a/src/panels/folders/foldersitemlistwidget.cpp b/src/panels/folders/foldersitemlistwidget.cpp
index b4f9a5be8..5b2b20698 100644
--- a/src/panels/folders/foldersitemlistwidget.cpp
+++ b/src/panels/folders/foldersitemlistwidget.cpp
@@ -33,4 +33,3 @@ QPalette::ColorRole FoldersItemListWidget::normalTextColorRole() const
return QPalette::WindowText;
}
-#include "foldersitemlistwidget.moc"
diff --git a/src/panels/folders/foldersitemlistwidget.h b/src/panels/folders/foldersitemlistwidget.h
index 08d41b829..2278762e3 100644
--- a/src/panels/folders/foldersitemlistwidget.h
+++ b/src/panels/folders/foldersitemlistwidget.h
@@ -34,7 +34,7 @@ public:
virtual ~FoldersItemListWidget();
protected:
- virtual QPalette::ColorRole normalTextColorRole() const;
+ virtual QPalette::ColorRole normalTextColorRole() const Q_DECL_OVERRIDE;
};
#endif
diff --git a/src/panels/folders/folderspanel.cpp b/src/panels/folders/folderspanel.cpp
index 46c1b3450..13df9019b 100644
--- a/src/panels/folders/folderspanel.cpp
+++ b/src/panels/folders/folderspanel.cpp
@@ -33,7 +33,11 @@
#include <kitemviews/kfileitemmodel.h>
#include <KFileItem>
-#include <konq_operations.h>
+#include <KJobWidgets>
+#include <KJobUiDelegate>
+#include <KIO/CopyJob>
+#include <KIO/DropJob>
+#include <KIO/FileUndoManager>
#include <QApplication>
#include <QBoxLayout>
@@ -45,7 +49,7 @@
#include <views/draganddrophelper.h>
-#include <KDebug>
+#include "dolphindebug.h"
FoldersPanel::FoldersPanel(QWidget* parent) :
Panel(parent),
@@ -58,7 +62,7 @@ FoldersPanel::FoldersPanel(QWidget* parent) :
FoldersPanel::~FoldersPanel()
{
- FoldersPanelSettings::self()->writeConfig();
+ FoldersPanelSettings::self()->save();
if (m_controller) {
KItemListView* view = m_controller->view();
@@ -105,7 +109,7 @@ void FoldersPanel::rename(const KFileItem& item)
bool FoldersPanel::urlChanged()
{
- if (!url().isValid() || url().protocol().contains("search")) {
+ if (!url().isValid() || url().scheme().contains("search")) {
// Skip results shown by a search, as possible identical
// directory names are useless without parent-path information.
return false;
@@ -137,15 +141,15 @@ void FoldersPanel::showEvent(QShowEvent* event)
// opening the folders panel.
view->setOpacity(0);
- connect(view, SIGNAL(roleEditingFinished(int,QByteArray,QVariant)),
- this, SLOT(slotRoleEditingFinished(int,QByteArray,QVariant)));
+ connect(view, &KFileItemListView::roleEditingFinished,
+ this, &FoldersPanel::slotRoleEditingFinished);
m_model = new KFileItemModel(this);
m_model->setShowDirectoriesOnly(true);
m_model->setShowHiddenFiles(FoldersPanelSettings::hiddenFilesShown());
// Use a QueuedConnection to give the view the possibility to react first on the
// finished loading.
- connect(m_model, SIGNAL(directoryLoadingCompleted()), this, SLOT(slotLoadingCompleted()), Qt::QueuedConnection);
+ connect(m_model, &KFileItemModel::directoryLoadingCompleted, this, &FoldersPanel::slotLoadingCompleted, Qt::QueuedConnection);
m_controller = new KItemListController(m_model, view, this);
m_controller->setSelectionBehavior(KItemListController::SingleSelection);
@@ -154,11 +158,11 @@ void FoldersPanel::showEvent(QShowEvent* event)
m_controller->setAutoActivationDelay(750);
m_controller->setSingleClickActivationEnforced(true);
- connect(m_controller, SIGNAL(itemActivated(int)), this, SLOT(slotItemActivated(int)));
- connect(m_controller, SIGNAL(itemMiddleClicked(int)), this, SLOT(slotItemMiddleClicked(int)));
- connect(m_controller, SIGNAL(itemContextMenuRequested(int,QPointF)), this, SLOT(slotItemContextMenuRequested(int,QPointF)));
- connect(m_controller, SIGNAL(viewContextMenuRequested(QPointF)), this, SLOT(slotViewContextMenuRequested(QPointF)));
- connect(m_controller, SIGNAL(itemDropEvent(int,QGraphicsSceneDragDropEvent*)), this, SLOT(slotItemDropEvent(int,QGraphicsSceneDragDropEvent*)));
+ connect(m_controller, &KItemListController::itemActivated, this, &FoldersPanel::slotItemActivated);
+ connect(m_controller, &KItemListController::itemMiddleClicked, this, &FoldersPanel::slotItemMiddleClicked);
+ connect(m_controller, &KItemListController::itemContextMenuRequested, this, &FoldersPanel::slotItemContextMenuRequested);
+ connect(m_controller, &KItemListController::viewContextMenuRequested, this, &FoldersPanel::slotViewContextMenuRequested);
+ connect(m_controller, &KItemListController::itemDropEvent, this, &FoldersPanel::slotItemDropEvent);
KItemListContainer* container = new KItemListContainer(m_controller, this);
container->setEnabledFrame(false);
@@ -204,7 +208,7 @@ void FoldersPanel::slotItemContextMenuRequested(int index, const QPointF& pos)
const KFileItem fileItem = m_model->fileItem(index);
- QWeakPointer<TreeViewContextMenu> contextMenu = new TreeViewContextMenu(this, fileItem);
+ QPointer<TreeViewContextMenu> contextMenu = new TreeViewContextMenu(this, fileItem);
contextMenu.data()->open();
if (contextMenu.data()) {
delete contextMenu.data();
@@ -215,7 +219,7 @@ void FoldersPanel::slotViewContextMenuRequested(const QPointF& pos)
{
Q_UNUSED(pos);
- QWeakPointer<TreeViewContextMenu> contextMenu = new TreeViewContextMenu(this, KFileItem());
+ QPointer<TreeViewContextMenu> contextMenu = new TreeViewContextMenu(this, KFileItem());
contextMenu.data()->open();
if (contextMenu.data()) {
delete contextMenu.data();
@@ -236,10 +240,9 @@ void FoldersPanel::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* eve
event->buttons(),
event->modifiers());
- QString error;
- DragAndDropHelper::dropUrls(destItem, destItem.url(), &dropEvent, error);
- if (!error.isEmpty()) {
- emit errorMessage(error);
+ KIO::DropJob *job = DragAndDropHelper::dropUrls(destItem.url(), &dropEvent, this);
+ if (job) {
+ connect(job, &KIO::DropJob::result, this, [this](KJob *job) { if (job->error()) emit errorMessage(job->errorString()); });
}
}
}
@@ -250,7 +253,14 @@ void FoldersPanel::slotRoleEditingFinished(int index, const QByteArray& role, co
const KFileItem item = m_model->fileItem(index);
const QString newName = value.toString();
if (!newName.isEmpty() && newName != item.text() && newName != QLatin1String(".") && newName != QLatin1String("..")) {
- KonqOperations::rename(this, item.url(), newName);
+ const QUrl oldUrl = item.url();
+ QUrl newUrl = oldUrl.adjusted(QUrl::RemoveFilename);
+ newUrl.setPath(newUrl.path() + KIO::encodeFileName(newName));
+
+ KIO::Job* job = KIO::moveAs(oldUrl, newUrl);
+ KJobWidgets::setWindow(job, this);
+ KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Rename, {oldUrl}, newUrl, job);
+ job->ui()->setAutoErrorHandlingEnabled(true);
}
}
}
@@ -286,16 +296,16 @@ void FoldersPanel::startFadeInAnimation()
anim->setDuration(200);
}
-void FoldersPanel::loadTree(const KUrl& url)
+void FoldersPanel::loadTree(const QUrl& url)
{
Q_ASSERT(m_controller);
m_updateCurrentItem = false;
- KUrl baseUrl;
+ QUrl baseUrl;
if (url.isLocalFile()) {
// Use the root directory as base for local URLs (#150941)
- baseUrl = QDir::rootPath();
+ baseUrl = QUrl::fromLocalFile(QDir::rootPath());
} else {
// Clear the path for non-local URLs and use it as base
baseUrl = url;
@@ -328,4 +338,3 @@ void FoldersPanel::updateCurrentItem(int index)
m_controller->view()->scrollToItem(index);
}
-#include "folderspanel.moc"
diff --git a/src/panels/folders/folderspanel.h b/src/panels/folders/folderspanel.h
index 14d8e8782..7c591cc20 100644
--- a/src/panels/folders/folderspanel.h
+++ b/src/panels/folders/folderspanel.h
@@ -20,13 +20,13 @@
#ifndef FOLDERSPANEL_H
#define FOLDERSPANEL_H
-#include <KUrl>
+#include <QUrl>
#include <panels/panel.h>
class KFileItemModel;
class KItemListController;
class QGraphicsSceneDragDropEvent;
-
+class KFileItem;
/**
* @brief Shows a tree view of the directories starting from
* the currently selected place.
@@ -51,19 +51,19 @@ public:
void rename(const KFileItem& item);
signals:
- void folderActivated(const KUrl& url);
- void folderMiddleClicked(const KUrl& url);
+ void folderActivated(const QUrl& url);
+ void folderMiddleClicked(const QUrl& url);
void errorMessage(const QString& error);
protected:
/** @see Panel::urlChanged() */
- virtual bool urlChanged();
+ virtual bool urlChanged() Q_DECL_OVERRIDE;
/** @see QWidget::showEvent() */
- virtual void showEvent(QShowEvent* event);
+ virtual void showEvent(QShowEvent* event) Q_DECL_OVERRIDE;
/** @see QWidget::keyPressEvent() */
- virtual void keyPressEvent(QKeyEvent* event);
+ virtual void keyPressEvent(QKeyEvent* event) Q_DECL_OVERRIDE;
private slots:
void slotItemActivated(int index);
@@ -87,7 +87,7 @@ private:
* directories until \a url.
* @param url URL of the leaf directory that should get expanded.
*/
- void loadTree(const KUrl& url);
+ void loadTree(const QUrl& url);
/**
* Sets the item with the index \a index as current item, selects
diff --git a/src/panels/folders/treeviewcontextmenu.cpp b/src/panels/folders/treeviewcontextmenu.cpp
index 83ffa87a7..e45fcd67e 100644
--- a/src/panels/folders/treeviewcontextmenu.cpp
+++ b/src/panels/folders/treeviewcontextmenu.cpp
@@ -21,19 +21,28 @@
#include "treeviewcontextmenu.h"
#include <KFileItem>
-#include <KIconLoader>
+#include <KIO/CopyJob>
#include <KIO/DeleteJob>
-#include <KMenu>
-#include <konqmimedata.h>
+#include <KIO/JobUiDelegate>
+#include <QMenu>
+#include <QIcon>
+#include <KJobWidgets>
+#include <KSharedConfig>
+#include <KConfigGroup>
+#include <KUrlMimeData>
#include <KFileItemListProperties>
-#include <konq_operations.h>
-#include <KLocale>
+#include <KLocalizedString>
+#include <KIO/PasteJob>
+#include <KIO/Paste>
+#include <KIO/FileUndoManager>
#include <KPropertiesDialog>
#include "folderspanel.h"
#include <QApplication>
#include <QClipboard>
+#include <QMimeData>
+#include <QPointer>
TreeViewContextMenu::TreeViewContextMenu(FoldersPanel* parent,
const KFileItem& fileInfo) :
@@ -49,23 +58,25 @@ TreeViewContextMenu::~TreeViewContextMenu()
void TreeViewContextMenu::open()
{
- KMenu* popup = new KMenu(m_parent);
+ QMenu* popup = new QMenu(m_parent);
if (!m_fileItem.isNull()) {
KFileItemListProperties capabilities(KFileItemList() << m_fileItem);
// insert 'Cut', 'Copy' and 'Paste'
- QAction* cutAction = new QAction(KIcon("edit-cut"), i18nc("@action:inmenu", "Cut"), this);
+ QAction* cutAction = new QAction(QIcon::fromTheme("edit-cut"), i18nc("@action:inmenu", "Cut"), this);
cutAction->setEnabled(capabilities.supportsMoving());
- connect(cutAction, SIGNAL(triggered()), this, SLOT(cut()));
+ connect(cutAction, &QAction::triggered, this, &TreeViewContextMenu::cut);
- QAction* copyAction = new QAction(KIcon("edit-copy"), i18nc("@action:inmenu", "Copy"), this);
- connect(copyAction, SIGNAL(triggered()), this, SLOT(copy()));
+ QAction* copyAction = new QAction(QIcon::fromTheme("edit-copy"), i18nc("@action:inmenu", "Copy"), this);
+ connect(copyAction, &QAction::triggered, this, &TreeViewContextMenu::copy);
- const QPair<bool, QString> pasteInfo = KonqOperations::pasteInfo(m_fileItem.url());
- QAction* pasteAction = new QAction(KIcon("edit-paste"), pasteInfo.second, this);
- connect(pasteAction, SIGNAL(triggered()), this, SLOT(paste()));
- pasteAction->setEnabled(pasteInfo.first);
+ const QMimeData *mimeData = QApplication::clipboard()->mimeData();
+ bool canPaste;
+ const QString text = KIO::pasteActionText(mimeData, &canPaste, m_fileItem);
+ QAction* pasteAction = new QAction(QIcon::fromTheme("edit-paste"), text, this);
+ connect(pasteAction, &QAction::triggered, this, &TreeViewContextMenu::paste);
+ pasteAction->setEnabled(canPaste);
popup->addAction(cutAction);
popup->addAction(copyAction);
@@ -75,8 +86,8 @@ void TreeViewContextMenu::open()
// insert 'Rename'
QAction* renameAction = new QAction(i18nc("@action:inmenu", "Rename..."), this);
renameAction->setEnabled(capabilities.supportsMoving());
- renameAction->setIcon(KIcon("edit-rename"));
- connect(renameAction, SIGNAL(triggered()), this, SLOT(rename()));
+ renameAction->setIcon(QIcon::fromTheme("edit-rename"));
+ connect(renameAction, &QAction::triggered, this, &TreeViewContextMenu::rename);
popup->addAction(renameAction);
// insert 'Move to Trash' and (optionally) 'Delete'
@@ -84,22 +95,22 @@ void TreeViewContextMenu::open()
KConfigGroup configGroup(globalConfig, "KDE");
bool showDeleteCommand = configGroup.readEntry("ShowDeleteCommand", false);
- const KUrl url = m_fileItem.url();
+ const QUrl url = m_fileItem.url();
if (url.isLocalFile()) {
- QAction* moveToTrashAction = new QAction(KIcon("user-trash"),
+ QAction* moveToTrashAction = new QAction(QIcon::fromTheme("user-trash"),
i18nc("@action:inmenu", "Move to Trash"), this);
const bool enableMoveToTrash = capabilities.isLocal() && capabilities.supportsMoving();
moveToTrashAction->setEnabled(enableMoveToTrash);
- connect(moveToTrashAction, SIGNAL(triggered()), this, SLOT(moveToTrash()));
+ connect(moveToTrashAction, &QAction::triggered, this, &TreeViewContextMenu::moveToTrash);
popup->addAction(moveToTrashAction);
} else {
showDeleteCommand = true;
}
if (showDeleteCommand) {
- QAction* deleteAction = new QAction(KIcon("edit-delete"), i18nc("@action:inmenu", "Delete"), this);
+ QAction* deleteAction = new QAction(QIcon::fromTheme("edit-delete"), i18nc("@action:inmenu", "Delete"), this);
deleteAction->setEnabled(capabilities.supportsDeleting());
- connect(deleteAction, SIGNAL(triggered()), this, SLOT(deleteItem()));
+ connect(deleteAction, &QAction::triggered, this, &TreeViewContextMenu::deleteItem);
popup->addAction(deleteAction);
}
@@ -111,7 +122,7 @@ void TreeViewContextMenu::open()
showHiddenFilesAction->setCheckable(true);
showHiddenFilesAction->setChecked(m_parent->showHiddenFiles());
popup->addAction(showHiddenFilesAction);
- connect(showHiddenFilesAction, SIGNAL(toggled(bool)), this, SLOT(setShowHiddenFiles(bool)));
+ connect(showHiddenFilesAction, &QAction::toggled, this, &TreeViewContextMenu::setShowHiddenFiles);
// insert 'Automatic Scrolling'
QAction* autoScrollingAction = new QAction(i18nc("@action:inmenu", "Automatic Scrolling"), this);
@@ -120,13 +131,13 @@ void TreeViewContextMenu::open()
// TODO: Temporary disabled. Horizontal autoscrolling will be implemented later either
// in KItemViews or manually as part of the FoldersPanel
//popup->addAction(autoScrollingAction);
- connect(autoScrollingAction, SIGNAL(toggled(bool)), this, SLOT(setAutoScrolling(bool)));
+ connect(autoScrollingAction, &QAction::toggled, this, &TreeViewContextMenu::setAutoScrolling);
if (!m_fileItem.isNull()) {
// insert 'Properties' entry
QAction* propertiesAction = new QAction(i18nc("@action:inmenu", "Properties"), this);
- propertiesAction->setIcon(KIcon("document-properties"));
- connect(propertiesAction, SIGNAL(triggered()), this, SLOT(showProperties()));
+ propertiesAction->setIcon(QIcon::fromTheme("document-properties"));
+ connect(propertiesAction, &QAction::triggered, this, &TreeViewContextMenu::showProperties);
popup->addAction(propertiesAction);
}
@@ -138,7 +149,7 @@ void TreeViewContextMenu::open()
}
}
- QWeakPointer<KMenu> popupPtr = popup;
+ QPointer<QMenu> popupPtr = popup;
popup->exec(QCursor::pos());
if (popupPtr.data()) {
popupPtr.data()->deleteLater();
@@ -147,12 +158,13 @@ void TreeViewContextMenu::open()
void TreeViewContextMenu::populateMimeData(QMimeData* mimeData, bool cut)
{
- KUrl::List kdeUrls;
+ QList<QUrl> kdeUrls;
kdeUrls.append(m_fileItem.url());
- KUrl::List mostLocalUrls;
+ QList<QUrl> mostLocalUrls;
bool dummy;
mostLocalUrls.append(m_fileItem.mostLocalUrl(dummy));
- KonqMimeData::populateMimeData(mimeData, kdeUrls, mostLocalUrls, cut);
+ KIO::setClipboardDataCut(mimeData, cut);
+ KUrlMimeData::setUrls(kdeUrls, mostLocalUrls, mimeData);
}
void TreeViewContextMenu::cut()
@@ -171,7 +183,8 @@ void TreeViewContextMenu::copy()
void TreeViewContextMenu::paste()
{
- KonqOperations::doPaste(m_parent, m_fileItem.url());
+ KIO::PasteJob *job = KIO::paste(QApplication::clipboard()->mimeData(), m_fileItem.url());
+ KJobWidgets::setWindow(job, m_parent);
}
void TreeViewContextMenu::rename()
@@ -181,12 +194,27 @@ void TreeViewContextMenu::rename()
void TreeViewContextMenu::moveToTrash()
{
- KonqOperations::del(m_parent, KonqOperations::TRASH, m_fileItem.url());
+ const QList<QUrl> list{m_fileItem.url()};
+ KIO::JobUiDelegate uiDelegate;
+ uiDelegate.setWindow(m_parent);
+ if (uiDelegate.askDeleteConfirmation(list, KIO::JobUiDelegate::Trash, KIO::JobUiDelegate::DefaultConfirmation)) {
+ KIO::Job* job = KIO::trash(list);
+ KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Trash, list, QUrl("trash:/"), job);
+ KJobWidgets::setWindow(job, m_parent);
+ job->ui()->setAutoErrorHandlingEnabled(true);
+ }
}
void TreeViewContextMenu::deleteItem()
{
- KonqOperations::del(m_parent, KonqOperations::DEL, m_fileItem.url());
+ const QList<QUrl> list{m_fileItem.url()};
+ KIO::JobUiDelegate uiDelegate;
+ uiDelegate.setWindow(m_parent);
+ if (uiDelegate.askDeleteConfirmation(list, KIO::JobUiDelegate::Delete, KIO::JobUiDelegate::DefaultConfirmation)) {
+ KIO::Job* job = KIO::del(list);
+ KJobWidgets::setWindow(job, m_parent);
+ job->ui()->setAutoErrorHandlingEnabled(true);
+ }
}
void TreeViewContextMenu::showProperties()
@@ -206,4 +234,3 @@ void TreeViewContextMenu::setAutoScrolling(bool enable)
m_parent->setAutoScrolling(enable);
}
-#include "treeviewcontextmenu.moc"
diff --git a/src/panels/folders/treeviewcontextmenu.h b/src/panels/folders/treeviewcontextmenu.h
index 0b3fd79bd..598ffaed6 100644
--- a/src/panels/folders/treeviewcontextmenu.h
+++ b/src/panels/folders/treeviewcontextmenu.h
@@ -23,6 +23,7 @@
#include <QObject>
#include <KFileItem>
+class QMimeData;
class FoldersPanel;
/**
diff --git a/src/panels/information/filemetadataconfigurationdialog.cpp b/src/panels/information/filemetadataconfigurationdialog.cpp
index 4ad9066c4..2f8c16037 100644
--- a/src/panels/information/filemetadataconfigurationdialog.cpp
+++ b/src/panels/information/filemetadataconfigurationdialog.cpp
@@ -22,22 +22,33 @@
#ifndef HAVE_BALOO
#include <kfilemetadataconfigurationwidget.h>
#else
-#include <baloo/filemetadataconfigwidget.h>
+#include <Baloo/FileMetaDataConfigWidget>
#endif
-
-#include <KLocale>
+#include <KSharedConfig>
+#include <KLocalizedString>
#include <QLabel>
#include <QVBoxLayout>
+#include <KConfigGroup>
+#include <KWindowConfig>
+#include <QDialogButtonBox>
+#include <QPushButton>
FileMetaDataConfigurationDialog::FileMetaDataConfigurationDialog(QWidget* parent) :
- KDialog(parent),
+ QDialog(parent),
m_descriptionLabel(0),
m_configWidget(0)
{
- setCaption(i18nc("@title:window", "Configure Shown Data"));
- setButtons(KDialog::Ok | KDialog::Cancel);
- setDefaultButton(KDialog::Ok);
+ setWindowTitle(i18nc("@title:window", "Configure Shown Data"));
+ QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
+ QVBoxLayout *mainLayout = new QVBoxLayout;
+ setLayout(mainLayout);
+ QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
+ okButton->setDefault(true);
+ okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
+ connect(buttonBox, SIGNAL(accepted()), this, SLOT(slotAccepted()));
+ connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
+ buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
m_descriptionLabel = new QLabel(i18nc("@label::textbox",
"Select which data should "
@@ -55,18 +66,20 @@ FileMetaDataConfigurationDialog::FileMetaDataConfigurationDialog(QWidget* parent
QVBoxLayout* topLayout = new QVBoxLayout(mainWidget);
topLayout->addWidget(m_descriptionLabel);
topLayout->addWidget(m_configWidget);
- setMainWidget(mainWidget);
+ mainLayout->addWidget(mainWidget);
+ mainLayout->addWidget(buttonBox);
+
const KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"),
"FileMetaDataConfigurationDialog");
- restoreDialogSize(dialogConfig);
+ KWindowConfig::restoreWindowSize(windowHandle(), dialogConfig);
}
FileMetaDataConfigurationDialog::~FileMetaDataConfigurationDialog()
{
KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"),
"FileMetaDataConfigurationDialog");
- saveDialogSize(dialogConfig, KConfigBase::Persistent);
+ KWindowConfig::saveWindowSize(windowHandle(), dialogConfig);
}
void FileMetaDataConfigurationDialog::setItems(const KFileItemList& items)
@@ -79,14 +92,10 @@ KFileItemList FileMetaDataConfigurationDialog::items() const
return m_configWidget->items();
}
-void FileMetaDataConfigurationDialog::slotButtonClicked(int button)
+void FileMetaDataConfigurationDialog::slotAccepted()
{
- if (button == KDialog::Ok) {
- m_configWidget->save();
- accept();
- } else {
- KDialog::slotButtonClicked(button);
- }
+ m_configWidget->save();
+ accept();
}
void FileMetaDataConfigurationDialog::setDescription(const QString& description)
@@ -99,4 +108,3 @@ QString FileMetaDataConfigurationDialog::description() const
return m_descriptionLabel->text();
}
-#include "filemetadataconfigurationdialog.moc"
diff --git a/src/panels/information/filemetadataconfigurationdialog.h b/src/panels/information/filemetadataconfigurationdialog.h
index a3ce9548b..13562ef5c 100644
--- a/src/panels/information/filemetadataconfigurationdialog.h
+++ b/src/panels/information/filemetadataconfigurationdialog.h
@@ -20,7 +20,7 @@
#ifndef FILEMETADATACONFIGURATIONDIALOG_H
#define FILEMETADATACONFIGURATIONDIALOG_H
-#include <KDialog>
+#include <QDialog>
#include <KFileItem>
#include "config-baloo.h"
@@ -38,7 +38,7 @@ class QLabel;
* @brief Dialog which allows to configure which meta data should be shown
* in the KFileMetaDataWidget.
*/
-class FileMetaDataConfigurationDialog : public KDialog
+class FileMetaDataConfigurationDialog : public QDialog
{
Q_OBJECT
@@ -67,8 +67,7 @@ public:
QString description() const;
protected slots:
- virtual void slotButtonClicked(int button);
-
+ void slotAccepted();
private:
QLabel* m_descriptionLabel;
#ifndef HAVE_BALOO
diff --git a/src/panels/information/informationpanel.cpp b/src/panels/information/informationpanel.cpp
index eda74f3b5..3f778b07a 100644
--- a/src/panels/information/informationpanel.cpp
+++ b/src/panels/information/informationpanel.cpp
@@ -22,10 +22,12 @@
#include "informationpanelcontent.h"
#include <KIO/Job>
#include <KIO/JobUiDelegate>
+#include <KJobWidgets>
#include <KDirNotify>
#include <QApplication>
#include <QShowEvent>
#include <QVBoxLayout>
+#include <QTimer>
InformationPanel::InformationPanel(QWidget* parent) :
Panel(parent),
@@ -184,10 +186,10 @@ void InformationPanel::showItemInfo()
// an item for the currently shown directory.
m_folderStatJob = KIO::stat(url(), KIO::HideProgressInfo);
if (m_folderStatJob->ui()) {
- m_folderStatJob->ui()->setWindow(this);
+ KJobWidgets::setWindow(m_folderStatJob, this);
}
- connect(m_folderStatJob, SIGNAL(result(KJob*)),
- this, SLOT(slotFolderStatFinished(KJob*)));
+ connect(m_folderStatJob, &KIO::Job::result,
+ this, &InformationPanel::slotFolderStatFinished);
} else {
m_content->showItem(item);
}
@@ -211,7 +213,7 @@ void InformationPanel::slotInfoTimeout()
void InformationPanel::reset()
{
if (m_invalidUrlCandidate == m_shownUrl) {
- m_invalidUrlCandidate = KUrl();
+ m_invalidUrlCandidate = QUrl();
// The current URL is still invalid. Reset
// the content to show the directory URL.
@@ -224,11 +226,11 @@ void InformationPanel::reset()
void InformationPanel::slotFileRenamed(const QString& source, const QString& dest)
{
- if (m_shownUrl == KUrl(source)) {
- m_shownUrl = KUrl(dest);
- m_fileItem = KFileItem(KFileItem::Unknown, KFileItem::Unknown, m_shownUrl);
+ if (m_shownUrl == QUrl::fromLocalFile(source)) {
+ m_shownUrl = QUrl::fromLocalFile(dest);
+ m_fileItem = KFileItem(m_shownUrl);
- if ((m_selection.count() == 1) && (m_selection[0].url() == KUrl(source))) {
+ if ((m_selection.count() == 1) && (m_selection[0].url() == QUrl::fromLocalFile(source))) {
m_selection[0] = m_fileItem;
// Implementation note: Updating the selection is only required if exactly one
// item is selected, as the name of the item is shown. If this should change
@@ -242,10 +244,10 @@ void InformationPanel::slotFileRenamed(const QString& source, const QString& des
void InformationPanel::slotFilesAdded(const QString& directory)
{
- if (m_shownUrl == KUrl(directory)) {
+ if (m_shownUrl == QUrl::fromLocalFile(directory)) {
// If the 'trash' icon changes because the trash has been emptied or got filled,
// the signal filesAdded("trash:/") will be emitted.
- KFileItem item(KFileItem::Unknown, KFileItem::Unknown, KUrl(directory));
+ KFileItem item(QUrl::fromLocalFile(directory));
requestDelayedItemInfo(item);
}
}
@@ -253,7 +255,7 @@ void InformationPanel::slotFilesAdded(const QString& directory)
void InformationPanel::slotFilesChanged(const QStringList& files)
{
foreach (const QString& fileName, files) {
- if (m_shownUrl == KUrl(fileName)) {
+ if (m_shownUrl == QUrl::fromLocalFile(fileName)) {
showItemInfo();
break;
}
@@ -263,7 +265,7 @@ void InformationPanel::slotFilesChanged(const QStringList& files)
void InformationPanel::slotFilesRemoved(const QStringList& files)
{
foreach (const QString& fileName, files) {
- if (m_shownUrl == KUrl(fileName)) {
+ if (m_shownUrl == QUrl::fromLocalFile(fileName)) {
// the currently shown item has been removed, show
// the parent directory as fallback
markUrlAsInvalid();
@@ -274,15 +276,15 @@ void InformationPanel::slotFilesRemoved(const QStringList& files)
void InformationPanel::slotEnteredDirectory(const QString& directory)
{
- if (m_shownUrl == KUrl(directory)) {
- KFileItem item(KFileItem::Unknown, KFileItem::Unknown, KUrl(directory));
+ if (m_shownUrl == QUrl::fromLocalFile(directory)) {
+ KFileItem item(QUrl::fromLocalFile(directory));
requestDelayedItemInfo(item);
}
}
void InformationPanel::slotLeftDirectory(const QString& directory)
{
- if (m_shownUrl == KUrl(directory)) {
+ if (m_shownUrl == QUrl::fromLocalFile(directory)) {
// The signal 'leftDirectory' is also emitted when a media
// has been unmounted. In this case no directory change will be
// done in Dolphin, but the Information Panel must be updated to
@@ -306,9 +308,9 @@ void InformationPanel::cancelRequest()
m_urlCandidate.clear();
}
-bool InformationPanel::isEqualToShownUrl(const KUrl& url) const
+bool InformationPanel::isEqualToShownUrl(const QUrl& url) const
{
- return m_shownUrl.equals(url, KUrl::CompareWithoutTrailingSlash);
+ return m_shownUrl.matches(url, QUrl::StripTrailingSlash);
}
void InformationPanel::markUrlAsInvalid()
@@ -322,35 +324,35 @@ void InformationPanel::init()
m_infoTimer = new QTimer(this);
m_infoTimer->setInterval(300);
m_infoTimer->setSingleShot(true);
- connect(m_infoTimer, SIGNAL(timeout()),
- this, SLOT(slotInfoTimeout()));
+ connect(m_infoTimer, &QTimer::timeout,
+ this, &InformationPanel::slotInfoTimeout);
m_urlChangedTimer = new QTimer(this);
m_urlChangedTimer->setInterval(200);
m_urlChangedTimer->setSingleShot(true);
- connect(m_urlChangedTimer, SIGNAL(timeout()),
- this, SLOT(showItemInfo()));
+ connect(m_urlChangedTimer, &QTimer::timeout,
+ this, &InformationPanel::showItemInfo);
m_resetUrlTimer = new QTimer(this);
m_resetUrlTimer->setInterval(1000);
m_resetUrlTimer->setSingleShot(true);
- connect(m_resetUrlTimer, SIGNAL(timeout()),
- this, SLOT(reset()));
+ connect(m_resetUrlTimer, &QTimer::timeout,
+ this, &InformationPanel::reset);
Q_ASSERT(m_urlChangedTimer->interval() < m_infoTimer->interval());
Q_ASSERT(m_urlChangedTimer->interval() < m_resetUrlTimer->interval());
org::kde::KDirNotify* dirNotify = new org::kde::KDirNotify(QString(), QString(),
QDBusConnection::sessionBus(), this);
- connect(dirNotify, SIGNAL(FileRenamed(QString,QString)), SLOT(slotFileRenamed(QString,QString)));
- connect(dirNotify, SIGNAL(FilesAdded(QString)), SLOT(slotFilesAdded(QString)));
- connect(dirNotify, SIGNAL(FilesChanged(QStringList)), SLOT(slotFilesChanged(QStringList)));
- connect(dirNotify, SIGNAL(FilesRemoved(QStringList)), SLOT(slotFilesRemoved(QStringList)));
- connect(dirNotify, SIGNAL(enteredDirectory(QString)), SLOT(slotEnteredDirectory(QString)));
- connect(dirNotify, SIGNAL(leftDirectory(QString)), SLOT(slotLeftDirectory(QString)));
+ connect(dirNotify, &OrgKdeKDirNotifyInterface::FileRenamed, this, &InformationPanel::slotFileRenamed);
+ connect(dirNotify, &OrgKdeKDirNotifyInterface::FilesAdded, this, &InformationPanel::slotFilesAdded);
+ connect(dirNotify, &OrgKdeKDirNotifyInterface::FilesChanged, this, &InformationPanel::slotFilesChanged);
+ connect(dirNotify, &OrgKdeKDirNotifyInterface::FilesRemoved, this, &InformationPanel::slotFilesRemoved);
+ connect(dirNotify, &OrgKdeKDirNotifyInterface::enteredDirectory, this, &InformationPanel::slotEnteredDirectory);
+ connect(dirNotify, &OrgKdeKDirNotifyInterface::leftDirectory, this, &InformationPanel::slotLeftDirectory);
m_content = new InformationPanelContent(this);
- connect(m_content, SIGNAL(urlActivated(KUrl)), this, SIGNAL(urlActivated(KUrl)));
+ connect(m_content, &InformationPanelContent::urlActivated, this, &InformationPanel::urlActivated);
QVBoxLayout* layout = new QVBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
@@ -359,4 +361,3 @@ void InformationPanel::init()
m_initialized = true;
}
-#include "informationpanel.moc"
diff --git a/src/panels/information/informationpanel.h b/src/panels/information/informationpanel.h
index c68b66ee1..78e2d71ff 100644
--- a/src/panels/information/informationpanel.h
+++ b/src/panels/information/informationpanel.h
@@ -21,7 +21,7 @@
#define INFORMATIONPANEL_H
#include <panels/panel.h>
-
+#include <KFileItem>
class InformationPanelContent;
namespace KIO
{
@@ -40,7 +40,7 @@ public:
virtual ~InformationPanel();
signals:
- void urlActivated(const KUrl& url);
+ void urlActivated(const QUrl& url);
public slots:
/**
@@ -59,16 +59,16 @@ public slots:
protected:
/** @see Panel::urlChanged() */
- virtual bool urlChanged();
+ virtual bool urlChanged() Q_DECL_OVERRIDE;
/** @see QWidget::showEvent() */
- virtual void showEvent(QShowEvent* event);
+ virtual void showEvent(QShowEvent* event) Q_DECL_OVERRIDE;
/** @see QWidget::resizeEvent() */
- virtual void resizeEvent(QResizeEvent* event);
+ virtual void resizeEvent(QResizeEvent* event) Q_DECL_OVERRIDE;
/** @see QWidget::contextMenuEvent() */
- virtual void contextMenuEvent(QContextMenuEvent* event);
+ virtual void contextMenuEvent(QContextMenuEvent* event) Q_DECL_OVERRIDE;
private slots:
/**
@@ -116,7 +116,7 @@ private:
/**
* Returns true, if \a url is equal to the shown URL m_shownUrl.
*/
- bool isEqualToShownUrl(const KUrl& url) const;
+ bool isEqualToShownUrl(const QUrl& url) const;
/**
* Marks the URL as invalid and will reset the Information Panel
@@ -136,17 +136,17 @@ private:
QTimer* m_resetUrlTimer;
// URL that is currently shown in the Information Panel.
- KUrl m_shownUrl;
+ QUrl m_shownUrl;
// URL candidate that will replace m_shownURL after a delay.
// Used to remember URLs when hovering items.
- KUrl m_urlCandidate;
+ QUrl m_urlCandidate;
// URL candidate that is marked as invalid (e. g. because the directory
// has been deleted or the shown item has been renamed). The Information
// Panel will be reset asynchronously to prevent unnecessary resets when
// a directory has been changed.
- KUrl m_invalidUrlCandidate;
+ QUrl m_invalidUrlCandidate;
KFileItem m_fileItem; // file item for m_shownUrl if available (otherwise null)
KFileItemList m_selection;
diff --git a/src/panels/information/informationpanelcontent.cpp b/src/panels/information/informationpanelcontent.cpp
index 4fb0d9442..c18d4738e 100644
--- a/src/panels/information/informationpanelcontent.cpp
+++ b/src/panels/information/informationpanelcontent.cpp
@@ -19,22 +19,23 @@
#include "informationpanelcontent.h"
-#include <KDialog>
#include <KFileItem>
-#include <KGlobalSettings>
#include <KIO/JobUiDelegate>
#include <KIO/PreviewJob>
+#include <KJobWidgets>
#include <KIconEffect>
#include <KIconLoader>
-#include <KLocale>
-#include <KMenu>
-#include <kseparator.h>
+#include <QIcon>
+#include <KLocalizedString>
+#include <QMenu>
+#include <KSeparator>
#include <KStringHandler>
+#include <QTextDocument>
#ifndef HAVE_BALOO
#include <KFileMetaDataWidget>
#else
-#include <baloo/filemetadatawidget.h>
+#include <Baloo/FileMetaDataWidget>
#endif
#include <panels/places/placesitem.h>
@@ -47,14 +48,14 @@
#include <QEvent>
#include <QLabel>
#include <QPixmap>
-#include <QPointer>
#include <QResizeEvent>
#include <QScrollArea>
-#include <QTextDocument>
#include <QTextLayout>
#include <QTextLine>
#include <QTimer>
#include <QVBoxLayout>
+#include <QFontDatabase>
+#include <QStyle>
#include "dolphin_informationpanelsettings.h"
#include "filemetadataconfigurationdialog.h"
@@ -81,11 +82,10 @@ InformationPanelContent::InformationPanelContent(QWidget* parent) :
m_outdatedPreviewTimer = new QTimer(this);
m_outdatedPreviewTimer->setInterval(300);
m_outdatedPreviewTimer->setSingleShot(true);
- connect(m_outdatedPreviewTimer, SIGNAL(timeout()),
- this, SLOT(markOutdatedPreview()));
+ connect(m_outdatedPreviewTimer, &QTimer::timeout,
+ this, &InformationPanelContent::markOutdatedPreview);
QVBoxLayout* layout = new QVBoxLayout(this);
- layout->setSpacing(KDialog::spacingHint());
// preview
const int minPreviewWidth = KIconLoader::SizeEnormous + KIconLoader::SizeMedium;
@@ -97,8 +97,8 @@ InformationPanelContent::InformationPanelContent(QWidget* parent) :
m_phononWidget = new PhononWidget(parent);
m_phononWidget->hide();
m_phononWidget->setMinimumWidth(minPreviewWidth);
- connect(m_phononWidget, SIGNAL(hasVideoChanged(bool)),
- this, SLOT(slotHasVideoChanged(bool)));
+ connect(m_phononWidget, &PhononWidget::hasVideoChanged,
+ this, &InformationPanelContent::slotHasVideoChanged);
// name
m_nameLabel = new QLabel(parent);
@@ -114,12 +114,15 @@ InformationPanelContent::InformationPanelContent(QWidget* parent) :
#ifndef HAVE_BALOO
m_metaDataWidget = new KFileMetaDataWidget(parent);
+ connect(m_metaDataWidget, &KFileMetaDataWidget::urlActivated,
+ this, &InformationPanelContent::urlActivated);
#else
m_metaDataWidget = new Baloo::FileMetaDataWidget(parent);
+ connect(m_metaDataWidget, &Baloo::FileMetaDataWidget::urlActivated,
+ this, &InformationPanelContent::urlActivated);
#endif
- m_metaDataWidget->setFont(KGlobalSettings::smallestReadableFont());
+ m_metaDataWidget->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
m_metaDataWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
- connect(m_metaDataWidget, SIGNAL(urlActivated(KUrl)), this, SIGNAL(urlActivated(KUrl)));
// Encapsulate the MetaDataWidget inside a container that has a dummy widget
// at the bottom. This prevents that the meta data widget gets vertically stretched
@@ -154,7 +157,7 @@ InformationPanelContent::InformationPanelContent(QWidget* parent) :
InformationPanelContent::~InformationPanelContent()
{
- InformationPanelSettings::self()->writeConfig();
+ InformationPanelSettings::self()->save();
}
void InformationPanelContent::showItem(const KFileItem& item)
@@ -165,8 +168,8 @@ void InformationPanelContent::showItem(const KFileItem& item)
m_previewJob->kill();
}
- const KUrl itemUrl = item.url();
- const bool isSearchUrl = itemUrl.protocol().contains("search") && item.localPath().isEmpty();
+ const QUrl itemUrl = item.url();
+ const bool isSearchUrl = itemUrl.scheme().contains("search") && item.localPath().isEmpty();
if (!applyPlace(itemUrl)) {
setNameLabelText(item.text());
if (isSearchUrl) {
@@ -193,13 +196,13 @@ void InformationPanelContent::showItem(const KFileItem& item)
m_previewJob->setScaleType(KIO::PreviewJob::Unscaled);
m_previewJob->setIgnoreMaximumSize(item.isLocalFile());
if (m_previewJob->ui()) {
- m_previewJob->ui()->setWindow(this);
+ KJobWidgets::setWindow(m_previewJob, this);
}
- connect(m_previewJob, SIGNAL(gotPreview(KFileItem,QPixmap)),
- this, SLOT(showPreview(KFileItem,QPixmap)));
- connect(m_previewJob, SIGNAL(failed(KFileItem)),
- this, SLOT(showIcon(KFileItem)));
+ connect(m_previewJob.data(), &KIO::PreviewJob::gotPreview,
+ this, &InformationPanelContent::showPreview);
+ connect(m_previewJob.data(), &KIO::PreviewJob::failed,
+ this, &InformationPanelContent::showIcon);
}
}
@@ -272,7 +275,7 @@ bool InformationPanelContent::eventFilter(QObject* obj, QEvent* event)
break;
case QEvent::FontChange:
- m_metaDataWidget->setFont(KGlobalSettings::smallestReadableFont());
+ m_metaDataWidget->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
break;
default:
@@ -284,15 +287,15 @@ bool InformationPanelContent::eventFilter(QObject* obj, QEvent* event)
void InformationPanelContent::configureSettings(const QList<QAction*>& customContextMenuActions)
{
- KMenu popup(this);
+ QMenu popup(this);
QAction* previewAction = popup.addAction(i18nc("@action:inmenu", "Preview"));
- previewAction->setIcon(KIcon("view-preview"));
+ previewAction->setIcon(QIcon::fromTheme("view-preview"));
previewAction->setCheckable(true);
previewAction->setChecked(InformationPanelSettings::previewsShown());
QAction* configureAction = popup.addAction(i18nc("@action:inmenu", "Configure..."));
- configureAction->setIcon(KIcon("configure"));
+ configureAction->setIcon(QIcon::fromTheme("configure"));
popup.addSeparator();
foreach (QAction* action, customContextMenuActions) {
@@ -319,7 +322,7 @@ void InformationPanelContent::configureSettings(const QList<QAction*>& customCon
dialog->show();
dialog->raise();
dialog->activateWindow();
- connect(dialog, SIGNAL(destroyed()), this, SLOT(refreshMetaData()));
+ connect(dialog, &FileMetaDataConfigurationDialog::destroyed, this, &InformationPanelContent::refreshMetaData);
}
}
@@ -327,8 +330,10 @@ void InformationPanelContent::showIcon(const KFileItem& item)
{
m_outdatedPreviewTimer->stop();
if (!applyPlace(item.targetUrl())) {
- KIcon icon(item.iconName(), KIconLoader::global(), item.overlays());
- m_preview->setPixmap(icon.pixmap(KIconLoader::SizeEnormous));
+ const QPixmap icon = KIconLoader::global()->loadIcon(item.iconName(), KIconLoader::Desktop,
+ KIconLoader::SizeEnormous, KIconLoader::DefaultState,
+ item.overlays());
+ m_preview->setPixmap(icon);
}
}
@@ -364,14 +369,14 @@ void InformationPanelContent::refreshMetaData()
}
}
-bool InformationPanelContent::applyPlace(const KUrl& url)
+bool InformationPanelContent::applyPlace(const QUrl& url)
{
const int count = m_placesItemModel->count();
for (int i = 0; i < count; ++i) {
const PlacesItem* item = m_placesItemModel->placesItem(i);
- if (item->url().equals(url, KUrl::CompareWithoutTrailingSlash)) {
+ if (item->url().matches(url, QUrl::StripTrailingSlash)) {
setNameLabelText(item->text());
- m_preview->setPixmap(KIcon(item->icon()).pixmap(128, 128));
+ m_preview->setPixmap(QIcon::fromTheme(item->icon()).pixmap(128, 128));
return true;
}
}
@@ -417,7 +422,7 @@ void InformationPanelContent::adjustWidgetSizes(int width)
// so that the width of the information panel gets increased.
// To prevent this, the maximum width is adjusted to
// the current width of the panel.
- const int maxWidth = width - KDialog::spacingHint() * 4;
+ const int maxWidth = width - style()->layoutSpacing(QSizePolicy::DefaultType, QSizePolicy::DefaultType, Qt::Horizontal) * 4;
m_nameLabel->setMaximumWidth(maxWidth);
// The metadata widget also contains a text widget which may return
@@ -435,4 +440,3 @@ void InformationPanelContent::adjustWidgetSizes(int width)
}
}
-#include "informationpanelcontent.moc"
diff --git a/src/panels/information/informationpanelcontent.h b/src/panels/information/informationpanelcontent.h
index 67fdf6c5a..533e9de3b 100644
--- a/src/panels/information/informationpanelcontent.h
+++ b/src/panels/information/informationpanelcontent.h
@@ -21,12 +21,11 @@
#define INFORMATIONPANELCONTENT_H
#include "config-baloo.h"
-#include <KConfig>
#include <KFileItem>
-#include <KUrl>
-#include <KVBox>
+#include <QUrl>
#include <QPointer>
+#include <QWidget>
class KFileItemList;
class PhononWidget;
@@ -82,11 +81,11 @@ public:
void configureSettings(const QList<QAction*>& customContextMenuActions);
signals:
- void urlActivated( const KUrl& url );
+ void urlActivated( const QUrl& url );
protected:
/** @see QObject::eventFilter() */
- virtual bool eventFilter(QObject* obj, QEvent* event);
+ virtual bool eventFilter(QObject* obj, QEvent* event) Q_DECL_OVERRIDE;
private slots:
/**
@@ -122,7 +121,7 @@ private:
* @return True, if the URL represents exactly a place.
* @param url The url to check.
*/
- bool applyPlace(const KUrl& url);
+ bool applyPlace(const QUrl& url);
/**
* Sets the text for the label \a m_nameLabel and assures that the
diff --git a/src/panels/information/phononwidget.cpp b/src/panels/information/phononwidget.cpp
index 63f5aa3a5..1d6361f19 100644
--- a/src/panels/information/phononwidget.cpp
+++ b/src/panels/information/phononwidget.cpp
@@ -30,11 +30,11 @@
#include <QHBoxLayout>
#include <QShowEvent>
#include <QToolButton>
-
-#include <KDialog>
-#include <KIcon>
-#include <KUrl>
-#include <KLocale>
+#include <QDialog>
+#include <QIcon>
+#include <KIconLoader>
+#include <QUrl>
+#include <KLocalizedString>
class EmbeddedVideoPlayer : public Phonon::VideoWidget
{
@@ -72,7 +72,7 @@ PhononWidget::PhononWidget(QWidget *parent)
{
}
-void PhononWidget::setUrl(const KUrl &url)
+void PhononWidget::setUrl(const QUrl &url)
{
if (m_url != url) {
stop(); // emits playingStopped() signal
@@ -80,7 +80,7 @@ void PhononWidget::setUrl(const KUrl &url)
}
}
-KUrl PhononWidget::url() const
+QUrl PhononWidget::url() const
{
return m_url;
}
@@ -108,7 +108,7 @@ void PhononWidget::showEvent(QShowEvent *event)
if (!m_topLayout) {
m_topLayout = new QVBoxLayout(this);
m_topLayout->setMargin(0);
- m_topLayout->setSpacing(KDialog::spacingHint());
+
QHBoxLayout *controlsLayout = new QHBoxLayout(this);
controlsLayout->setMargin(0);
controlsLayout->setSpacing(0);
@@ -128,16 +128,16 @@ void PhononWidget::showEvent(QShowEvent *event)
m_playButton->setToolTip(i18n("play"));
m_playButton->setIconSize(buttonSize);
- m_playButton->setIcon(KIcon("media-playback-start"));
+ m_playButton->setIcon(QIcon::fromTheme("media-playback-start"));
m_playButton->setAutoRaise(true);
- connect(m_playButton, SIGNAL(clicked()), this, SLOT(play()));
+ connect(m_playButton, &QToolButton::clicked, this, &PhononWidget::play);
m_stopButton->setToolTip(i18n("stop"));
m_stopButton->setIconSize(buttonSize);
- m_stopButton->setIcon(KIcon("media-playback-stop"));
+ m_stopButton->setIcon(QIcon::fromTheme("media-playback-stop"));
m_stopButton->setAutoRaise(true);
m_stopButton->hide();
- connect(m_stopButton, SIGNAL(clicked()), this, SLOT(stop()));
+ connect(m_stopButton, &QToolButton::clicked, this, &PhononWidget::stop);
m_seekSlider->setIconVisible(false);
@@ -183,10 +183,10 @@ void PhononWidget::play()
{
if (!m_media) {
m_media = new Phonon::MediaObject(this);
- connect(m_media, SIGNAL(stateChanged(Phonon::State,Phonon::State)),
- this, SLOT(stateChanged(Phonon::State)));
- connect(m_media, SIGNAL(hasVideoChanged(bool)),
- this, SLOT(slotHasVideoChanged(bool)));
+ connect(m_media, &Phonon::MediaObject::stateChanged,
+ this, &PhononWidget::stateChanged);
+ connect(m_media, &Phonon::MediaObject::hasVideoChanged,
+ this, &PhononWidget::slotHasVideoChanged);
m_seekSlider->setMediaObject(m_media);
}
diff --git a/src/panels/information/phononwidget.h b/src/panels/information/phononwidget.h
index b5aedfe4f..837a66888 100644
--- a/src/panels/information/phononwidget.h
+++ b/src/panels/information/phononwidget.h
@@ -21,8 +21,7 @@
#ifndef PHONONWIDGET_H
#define PHONONWIDGET_H
-#include <KUrl>
-
+#include <QUrl>
#include <QSize>
#include <QWidget>
@@ -46,8 +45,8 @@ class PhononWidget : public QWidget
public:
PhononWidget(QWidget *parent = 0);
- void setUrl(const KUrl &url);
- KUrl url() const;
+ void setUrl(const QUrl &url);
+ QUrl url() const;
void setVideoSize(const QSize& size);
QSize videoSize() const;
@@ -64,8 +63,8 @@ class PhononWidget : public QWidget
void hasVideoChanged(bool hasVideo);
protected:
- virtual void showEvent(QShowEvent *event);
- virtual void hideEvent(QHideEvent *event);
+ virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
+ virtual void hideEvent(QHideEvent *event) Q_DECL_OVERRIDE;
private slots:
void stateChanged(Phonon::State);
@@ -77,7 +76,7 @@ class PhononWidget : public QWidget
void applyVideoSize();
private:
- KUrl m_url;
+ QUrl m_url;
QSize m_videoSize;
QToolButton *m_playButton;
diff --git a/src/panels/information/pixmapviewer.cpp b/src/panels/information/pixmapviewer.cpp
index 45a8c17e2..0053e43f9 100644
--- a/src/panels/information/pixmapviewer.cpp
+++ b/src/panels/information/pixmapviewer.cpp
@@ -21,10 +21,8 @@
#include <KIconLoader>
-#include <QLayout>
#include <QPainter>
#include <QPixmap>
-#include <QKeyEvent>
PixmapViewer::PixmapViewer(QWidget* parent, Transition transition) :
QWidget(parent),
@@ -39,8 +37,8 @@ PixmapViewer::PixmapViewer(QWidget* parent, Transition transition) :
m_animation.setCurveShape(QTimeLine::LinearCurve);
if (m_transition != NoTransition) {
- connect(&m_animation, SIGNAL(valueChanged(qreal)), this, SLOT(update()));
- connect(&m_animation, SIGNAL(finished()), this, SLOT(checkPendingPixmaps()));
+ connect(&m_animation, &QTimeLine::valueChanged, this, static_cast<void(PixmapViewer::*)()>(&PixmapViewer::update));
+ connect(&m_animation, &QTimeLine::finished, this, &PixmapViewer::checkPendingPixmaps);
}
}
@@ -129,4 +127,3 @@ void PixmapViewer::checkPendingPixmaps()
}
}
-#include "pixmapviewer.moc"
diff --git a/src/panels/information/pixmapviewer.h b/src/panels/information/pixmapviewer.h
index 8197df979..ddc183351 100644
--- a/src/panels/information/pixmapviewer.h
+++ b/src/panels/information/pixmapviewer.h
@@ -71,10 +71,10 @@ public:
* of the parent widget. Per default no size hint is given.
*/
void setSizeHint(const QSize& size);
- virtual QSize sizeHint() const;
+ virtual QSize sizeHint() const Q_DECL_OVERRIDE;
protected:
- virtual void paintEvent(QPaintEvent* event);
+ virtual void paintEvent(QPaintEvent* event) Q_DECL_OVERRIDE;
private Q_SLOTS:
void checkPendingPixmaps();
diff --git a/src/panels/panel.cpp b/src/panels/panel.cpp
index 14b7c0230..348191c98 100644
--- a/src/panels/panel.cpp
+++ b/src/panels/panel.cpp
@@ -19,7 +19,7 @@
***************************************************************************/
#include "panel.h"
-#include <KUrl>
+#include <QUrl>
Panel::Panel(QWidget* parent) :
QWidget(parent),
@@ -32,7 +32,7 @@ Panel::~Panel()
{
}
-KUrl Panel::url() const
+QUrl Panel::url() const
{
return m_url;
}
@@ -57,13 +57,13 @@ QSize Panel::sizeHint() const
return QSize(180, 180);
}
-void Panel::setUrl(const KUrl& url)
+void Panel::setUrl(const QUrl& url)
{
- if (url.equals(m_url, KUrl::CompareWithoutTrailingSlash)) {
+ if (url.matches(m_url, QUrl::StripTrailingSlash)) {
return;
}
- const KUrl oldUrl = m_url;
+ const QUrl oldUrl = m_url;
m_url = url;
const bool accepted = urlChanged();
if (!accepted) {
@@ -76,4 +76,3 @@ void Panel::readSettings()
}
-#include "panel.moc"
diff --git a/src/panels/panel.h b/src/panels/panel.h
index a0b25d6cc..d3460bf13 100644
--- a/src/panels/panel.h
+++ b/src/panels/panel.h
@@ -22,8 +22,7 @@
#define PANEL_H
#include <QWidget>
-#include <KUrl>
-#include <KFileItem>
+#include <QUrl>
/**
* @brief Base widget for all panels that can be docked on the window borders.
@@ -40,7 +39,7 @@ public:
virtual ~Panel();
/** Returns the current set URL of the active Dolphin view. */
- KUrl url() const;
+ QUrl url() const;
/**
* Sets custom context menu actions that are added to the panel specific
@@ -50,15 +49,14 @@ public:
void setCustomContextMenuActions(const QList<QAction*>& actions);
QList<QAction*> customContextMenuActions() const;
- /** @see QWidget::sizeHint() */
- virtual QSize sizeHint() const;
+ virtual QSize sizeHint() const Q_DECL_OVERRIDE;
public slots:
/**
* This is invoked every time the folder being displayed in the
* active Dolphin view changes.
*/
- void setUrl(const KUrl& url);
+ void setUrl(const QUrl &url);
/**
* Refreshes the view to get synchronized with the settings.
@@ -76,7 +74,7 @@ protected:
virtual bool urlChanged() = 0;
private:
- KUrl m_url;
+ QUrl m_url;
QList<QAction*> m_customContextMenuActions;
};
diff --git a/src/panels/places/placesitem.cpp b/src/panels/places/placesitem.cpp
index 173da29c5..638d59ec0 100644
--- a/src/panels/places/placesitem.cpp
+++ b/src/panels/places/placesitem.cpp
@@ -23,10 +23,9 @@
#include "placesitem.h"
#include <KBookmarkManager>
-#include <KDebug>
+#include "dolphindebug.h"
#include <KDirLister>
-#include <KIcon>
-#include <KLocale>
+#include <KLocalizedString>
#include "placesitemsignalhandler.h"
#include <QDateTime>
#include <Solid/Block>
@@ -52,16 +51,16 @@ PlacesItem::~PlacesItem()
delete m_trashDirLister;
}
-void PlacesItem::setUrl(const KUrl& url)
+void PlacesItem::setUrl(const QUrl &url)
{
// The default check in KStandardItem::setDataValue()
// for equal values does not work with a custom value
- // like KUrl. Hence do a manual check to prevent that
+ // like QUrl. Hence do a manual check to prevent that
// setting an equal URL results in an itemsChanged()
// signal.
- if (dataValue("url").value<KUrl>() != url) {
+ if (dataValue("url").value<QUrl>() != url) {
delete m_trashDirLister;
- if (url.protocol() == QLatin1String("trash")) {
+ if (url.scheme() == QLatin1String("trash")) {
// The trash icon must always be updated dependent on whether
// the trash is empty or not. We use a KDirLister that automatically
// watches for changes if the number of items has been changed.
@@ -69,8 +68,8 @@ void PlacesItem::setUrl(const KUrl& url)
m_trashDirLister = new KDirLister();
m_trashDirLister->setAutoErrorHandlingEnabled(false, 0);
m_trashDirLister->setDelayedMimeTypes(true);
- QObject::connect(m_trashDirLister, SIGNAL(completed()),
- m_signalHandler, SLOT(onTrashDirListerCompleted()));
+ QObject::connect(m_trashDirLister.data(), static_cast<void(KDirLister::*)()>(&KDirLister::completed),
+ m_signalHandler.data(), &PlacesItemSignalHandler::onTrashDirListerCompleted);
m_trashDirLister->openUrl(url);
}
@@ -78,9 +77,9 @@ void PlacesItem::setUrl(const KUrl& url)
}
}
-KUrl PlacesItem::url() const
+QUrl PlacesItem::url() const
{
- return dataValue("url").value<KUrl>();
+ return dataValue("url").value<QUrl>();
}
void PlacesItem::setUdi(const QString& udi)
@@ -135,7 +134,7 @@ void PlacesItem::setBookmark(const KBookmark& bookmark)
const QString udi = bookmark.metaDataItem("UDI");
if (udi.isEmpty()) {
setIcon(bookmark.icon());
- setText(i18nc("KFile System Bookmarks", bookmark.text().toUtf8().data()));
+ setText(i18nc("KFile System Bookmarks", bookmark.text().toUtf8().constData()));
setUrl(bookmark.url());
} else {
initializeDevice(udi);
@@ -171,7 +170,7 @@ KBookmark PlacesItem::bookmark() const
PlacesItem::GroupType PlacesItem::groupType() const
{
if (udi().isEmpty()) {
- const QString protocol = url().protocol();
+ const QString protocol = url().scheme();
if (protocol == QLatin1String("timeline")) {
return RecentlySavedType;
}
@@ -197,7 +196,7 @@ bool PlacesItem::storageSetupNeeded() const
KBookmark PlacesItem::createBookmark(KBookmarkManager* manager,
const QString& text,
- const KUrl& url,
+ const QUrl& url,
const QString& iconName)
{
KBookmarkGroup root = manager->root();
@@ -270,31 +269,31 @@ void PlacesItem::initializeDevice(const QString& udi)
setUdi(udi);
if (m_access) {
- setUrl(m_access->filePath());
- QObject::connect(m_access, SIGNAL(accessibilityChanged(bool,QString)),
- m_signalHandler, SLOT(onAccessibilityChanged()));
+ setUrl(QUrl::fromLocalFile(m_access->filePath()));
+ QObject::connect(m_access.data(), SIGNAL(accessibilityChanged(bool,QString)),
+ m_signalHandler.data(), SLOT(onAccessibilityChanged()));
} else if (m_disc && (m_disc->availableContent() & Solid::OpticalDisc::Audio) != 0) {
Solid::Block *block = m_device.as<Solid::Block>();
if (block) {
const QString device = block->device();
- setUrl(QString("audiocd:/?device=%1").arg(device));
+ setUrl(QStringLiteral("audiocd:/?device=%1").arg(device));
} else {
- setUrl(QString("audiocd:/"));
+ setUrl(QStringLiteral("audiocd:/"));
}
} else if (m_mtp) {
- setUrl(QString("mtp:udi=%1").arg(m_device.udi()));
+ setUrl(QStringLiteral("mtp:udi=%1").arg(m_device.udi()));
}
}
void PlacesItem::onAccessibilityChanged()
{
setIconOverlays(m_device.emblems());
- setUrl(m_access->filePath());
+ setUrl(QUrl::fromLocalFile(m_access->filePath()));
}
void PlacesItem::onTrashDirListerCompleted()
{
- Q_ASSERT(url().protocol() == QLatin1String("trash"));
+ Q_ASSERT(url().scheme() == QLatin1String("trash"));
const bool isTrashEmpty = m_trashDirLister->items().isEmpty();
setIcon(isTrashEmpty ? "user-trash" : "user-trash-full");
diff --git a/src/panels/places/placesitem.h b/src/panels/places/placesitem.h
index 4c636ec63..4ae4fd677 100644
--- a/src/panels/places/placesitem.h
+++ b/src/panels/places/placesitem.h
@@ -22,7 +22,7 @@
#include <KBookmark>
#include <kitemviews/kstandarditem.h>
-#include <KUrl>
+#include <QUrl>
#include <QPointer>
#include <Solid/Device>
#include <Solid/OpticalDisc>
@@ -51,8 +51,8 @@ public:
explicit PlacesItem(const KBookmark& bookmark, PlacesItem* parent = 0);
virtual ~PlacesItem();
- void setUrl(const KUrl& url);
- KUrl url() const;
+ void setUrl(const QUrl& url);
+ QUrl url() const;
void setUdi(const QString& udi);
QString udi() const;
@@ -74,7 +74,7 @@ public:
static KBookmark createBookmark(KBookmarkManager* manager,
const QString& text,
- const KUrl& url,
+ const QUrl& url,
const QString& iconName);
static KBookmark createDeviceBookmark(KBookmarkManager* manager,
const QString& udi);
@@ -82,10 +82,10 @@ public:
protected:
virtual void onDataValueChanged(const QByteArray& role,
const QVariant& current,
- const QVariant& previous);
+ const QVariant& previous) Q_DECL_OVERRIDE;
virtual void onDataChanged(const QHash<QByteArray, QVariant>& current,
- const QHash<QByteArray, QVariant>& previous);
+ const QHash<QByteArray, QVariant>& previous) Q_DECL_OVERRIDE;
private:
PlacesItem(const PlacesItem& item);
diff --git a/src/panels/places/placesitemeditdialog.cpp b/src/panels/places/placesitemeditdialog.cpp
index 08c910d17..d035b0403 100644
--- a/src/panels/places/placesitemeditdialog.cpp
+++ b/src/panels/places/placesitemeditdialog.cpp
@@ -24,21 +24,22 @@
#include "placesitemeditdialog.h"
#include <KAboutData>
-#include <KComponentData>
-#include <KDebug>
+#include "dolphindebug.h"
#include <KFile>
#include <KIconButton>
-#include <KLineEdit>
-#include <KLocale>
-#include <KMimeType>
+#include <KLocalizedString>
+#include <QMimeDatabase>
#include <KUrlRequester>
#include <QCheckBox>
#include <QEvent>
#include <QFormLayout>
#include <QVBoxLayout>
+#include <QDialogButtonBox>
+#include <QPushButton>
+#include <QLineEdit>
PlacesItemEditDialog::PlacesItemEditDialog(QWidget* parent) :
- KDialog(parent),
+ QDialog(parent),
m_icon(),
m_text(),
m_url(),
@@ -48,9 +49,6 @@ PlacesItemEditDialog::PlacesItemEditDialog(QWidget* parent) :
m_iconButton(0),
m_appLocal(0)
{
- setButtons( Ok | Cancel );
- setModal(true);
- setDefaultButton(Ok);
}
void PlacesItemEditDialog::setIcon(const QString& icon)
@@ -72,18 +70,18 @@ QString PlacesItemEditDialog::text() const
{
QString text = m_textEdit->text();
if (text.isEmpty()) {
- const KUrl url = m_urlEdit->url();
- text = url.fileName().isEmpty() ? url.prettyUrl() : url.fileName();
+ const QUrl url = m_urlEdit->url();
+ text = url.fileName().isEmpty() ? url.toDisplayString(QUrl::PreferLocalFile) : url.fileName();
}
return text;
}
-void PlacesItemEditDialog::setUrl(const KUrl& url)
+void PlacesItemEditDialog::setUrl(const QUrl& url)
{
m_url = url;
}
-KUrl PlacesItemEditDialog::url() const
+QUrl PlacesItemEditDialog::url() const
{
return m_urlEdit->url();
}
@@ -108,7 +106,7 @@ bool PlacesItemEditDialog::event(QEvent* event)
void PlacesItemEditDialog::slotUrlChanged(const QString& text)
{
- enableButtonOk(!text.isEmpty());
+ m_okButton->setEnabled(!text.isEmpty());
}
PlacesItemEditDialog::~PlacesItemEditDialog()
@@ -117,42 +115,51 @@ PlacesItemEditDialog::~PlacesItemEditDialog()
void PlacesItemEditDialog::initialize()
{
+ QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
+ m_okButton = buttonBox->button(QDialogButtonBox::Ok);
+ m_okButton->setDefault(true);
+ m_okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
+ connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
+ connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
+ setModal(true);
+ m_okButton->setDefault(true);
+
+ QVBoxLayout *mainLayout = new QVBoxLayout;
+ setLayout(mainLayout);
QWidget* mainWidget = new QWidget(this);
+ mainLayout->addWidget(mainWidget);
+ mainLayout->addWidget(buttonBox);
+
QVBoxLayout* vBox = new QVBoxLayout(mainWidget);
QFormLayout* formLayout = new QFormLayout();
vBox->addLayout( formLayout );
- m_textEdit = new KLineEdit(mainWidget);
+ m_textEdit = new QLineEdit(mainWidget);
formLayout->addRow(i18nc("@label", "Label:"), m_textEdit);
m_textEdit->setText(m_text);
- m_textEdit->setClickMessage(i18n("Enter descriptive label here"));
+ m_textEdit->setPlaceholderText(i18n("Enter descriptive label here"));
- m_urlEdit = new KUrlRequester(m_url.prettyUrl(), mainWidget);
+ m_urlEdit = new KUrlRequester(m_url, mainWidget);
m_urlEdit->setMode(KFile::Directory);
formLayout->addRow(i18nc("@label", "Location:"), m_urlEdit);
// Provide room for at least 40 chars (average char width is half of height)
m_urlEdit->setMinimumWidth(m_urlEdit->fontMetrics().height() * (40 / 2));
- connect(m_urlEdit->lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(slotUrlChanged(QString)));
+ connect(m_urlEdit, &KUrlRequester::textChanged, this, &PlacesItemEditDialog::slotUrlChanged);
m_iconButton = new KIconButton(mainWidget);
formLayout->addRow(i18nc("@label", "Choose an icon:"), m_iconButton);
m_iconButton->setIconSize(IconSize(KIconLoader::Desktop));
m_iconButton->setIconType(KIconLoader::NoGroup, KIconLoader::Place);
if (m_icon.isEmpty()) {
- m_iconButton->setIcon(KMimeType::iconNameForUrl(m_url));
+ QMimeDatabase db;
+ m_iconButton->setIcon(db.mimeTypeForUrl(m_url).iconName());
} else {
m_iconButton->setIcon(m_icon);
}
if (m_allowGlobal) {
- QString appName;
- if (KGlobal::mainComponent().aboutData()) {
- appName = KGlobal::mainComponent().aboutData()->programName();
- }
- if (appName.isEmpty()) {
- appName = KGlobal::mainComponent().componentName();
- }
+ const QString appName = KAboutData::applicationData().displayName();
m_appLocal = new QCheckBox( i18n("&Only show when using this application (%1)", appName ), mainWidget );
m_appLocal->setChecked(false);
vBox->addWidget(m_appLocal);
@@ -164,7 +171,5 @@ void PlacesItemEditDialog::initialize()
m_textEdit->setFocus();
}
- setMainWidget(mainWidget);
}
-#include "placesitemeditdialog.moc"
diff --git a/src/panels/places/placesitemeditdialog.h b/src/panels/places/placesitemeditdialog.h
index bf348479c..8a0dc0471 100644
--- a/src/panels/places/placesitemeditdialog.h
+++ b/src/panels/places/placesitemeditdialog.h
@@ -24,15 +24,16 @@
#ifndef PLACESITEMEDITDIALOG_H
#define PLACESITEMEDITDIALOG_H
-#include <KDialog>
-#include <KUrl>
+#include <QDialog>
+#include <QUrl>
class KIconButton;
-class KLineEdit;
class KUrlRequester;
+class QLineEdit;
class QCheckBox;
+class QPushButton;
-class PlacesItemEditDialog: public KDialog
+class PlacesItemEditDialog: public QDialog
{
Q_OBJECT
@@ -46,14 +47,14 @@ public:
void setText(const QString& text);
QString text() const;
- void setUrl(const KUrl& url);
- KUrl url() const;
+ void setUrl(const QUrl& url);
+ QUrl url() const;
void setAllowGlobal(bool allow);
bool allowGlobal() const;
protected:
- virtual bool event(QEvent* event);
+ virtual bool event(QEvent* event) Q_DECL_OVERRIDE;
private slots:
void slotUrlChanged(const QString& text);
@@ -64,13 +65,14 @@ private:
private:
QString m_icon;
QString m_text;
- KUrl m_url;
+ QUrl m_url;
bool m_allowGlobal;
KUrlRequester* m_urlEdit;
- KLineEdit* m_textEdit;
+ QLineEdit* m_textEdit;
KIconButton* m_iconButton;
QCheckBox* m_appLocal;
+ QPushButton *m_okButton;
};
#endif
diff --git a/src/panels/places/placesitemlistgroupheader.cpp b/src/panels/places/placesitemlistgroupheader.cpp
index ec7c4b18c..e17fd4d66 100644
--- a/src/panels/places/placesitemlistgroupheader.cpp
+++ b/src/panels/places/placesitemlistgroupheader.cpp
@@ -42,4 +42,3 @@ QPalette::ColorRole PlacesItemListGroupHeader::normalTextColorRole() const
return QPalette::WindowText;
}
-#include "placesitemlistgroupheader.moc"
diff --git a/src/panels/places/placesitemlistgroupheader.h b/src/panels/places/placesitemlistgroupheader.h
index 1c2d5cc25..7daaba602 100644
--- a/src/panels/places/placesitemlistgroupheader.h
+++ b/src/panels/places/placesitemlistgroupheader.h
@@ -31,7 +31,7 @@ public:
virtual ~PlacesItemListGroupHeader();
protected:
- virtual void paintSeparator(QPainter* painter, const QColor& color);
+ virtual void paintSeparator(QPainter* painter, const QColor& color) Q_DECL_OVERRIDE;
virtual QPalette::ColorRole normalTextColorRole() const;
};
diff --git a/src/panels/places/placesitemlistwidget.cpp b/src/panels/places/placesitemlistwidget.cpp
index e33d1daf9..18e561864 100644
--- a/src/panels/places/placesitemlistwidget.cpp
+++ b/src/panels/places/placesitemlistwidget.cpp
@@ -19,8 +19,6 @@
#include "placesitemlistwidget.h"
-#include "kdebug.h"
-
PlacesItemListWidget::PlacesItemListWidget(KItemListWidgetInformant* informant, QGraphicsItem* parent) :
KStandardItemListWidget(informant, parent)
{
@@ -40,4 +38,3 @@ QPalette::ColorRole PlacesItemListWidget::normalTextColorRole() const
return QPalette::WindowText;
}
-#include "placesitemlistwidget.moc"
diff --git a/src/panels/places/placesitemlistwidget.h b/src/panels/places/placesitemlistwidget.h
index a2a88c1f0..e9e6a0767 100644
--- a/src/panels/places/placesitemlistwidget.h
+++ b/src/panels/places/placesitemlistwidget.h
@@ -35,8 +35,8 @@ public:
virtual ~PlacesItemListWidget();
protected:
- virtual bool isHidden() const;
- virtual QPalette::ColorRole normalTextColorRole() const;
+ virtual bool isHidden() const Q_DECL_OVERRIDE;
+ virtual QPalette::ColorRole normalTextColorRole() const Q_DECL_OVERRIDE;
};
#endif
diff --git a/src/panels/places/placesitemmodel.cpp b/src/panels/places/placesitemmodel.cpp
index 637bfc107..bc7c2b7d3 100644
--- a/src/panels/places/placesitemmodel.cpp
+++ b/src/panels/places/placesitemmodel.cpp
@@ -26,20 +26,20 @@
#include "dolphin_generalsettings.h"
#include <KBookmark>
-#include <KBookmarkGroup>
#include <KBookmarkManager>
-#include <KComponentData>
-#include <KDebug>
-#include <KIcon>
-#include <kprotocolinfo.h>
-#include <KLocale>
-#include <KStandardDirs>
+#include "dolphindebug.h"
+#include <QIcon>
+#include <KProtocolInfo>
+#include <KLocalizedString>
+#include <QStandardPaths>
#include <KUser>
+#include <KAboutData>
#include "placesitem.h"
#include <QAction>
#include <QDate>
#include <QMimeData>
#include <QTimer>
+#include <KUrlMimeData>
#include <Solid/Device>
#include <Solid/DeviceNotifier>
@@ -52,8 +52,8 @@
#include <views/viewproperties.h>
#ifdef HAVE_BALOO
- #include <baloo/query.h>
- #include <baloo/indexerconfig.h>
+ #include <Baloo/Query>
+ #include <Baloo/IndexerConfig>
#endif
namespace {
@@ -64,7 +64,7 @@ namespace {
// be independent from changes in the Baloo-search-URL-syntax.
// Hence a prefix to the application-name of the stored bookmarks is
// added, which is only read by PlacesItemModel.
- const char* AppNamePrefix = "-places-panel";
+ const char AppNamePrefix[] = "-places-panel";
}
PlacesItemModel::PlacesItemModel(QObject* parent) :
@@ -85,7 +85,7 @@ PlacesItemModel::PlacesItemModel(QObject* parent) :
Baloo::IndexerConfig config;
m_fileIndexingEnabled = config.fileIndexingEnabled();
#endif
- const QString file = KStandardDirs::locateLocal("data", "kfileplaces/bookmarks.xml");
+ const QString file = QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kfileplaces/bookmarks.xml");
m_bookmarkManager = KBookmarkManager::managerForFile(file, "kfilePlaces");
createSystemBookmarks();
@@ -97,12 +97,12 @@ PlacesItemModel::PlacesItemModel(QObject* parent) :
m_updateBookmarksTimer = new QTimer(this);
m_updateBookmarksTimer->setInterval(syncBookmarksTimeout);
m_updateBookmarksTimer->setSingleShot(true);
- connect(m_updateBookmarksTimer, SIGNAL(timeout()), this, SLOT(updateBookmarks()));
+ connect(m_updateBookmarksTimer, &QTimer::timeout, this, &PlacesItemModel::updateBookmarks);
- connect(m_bookmarkManager, SIGNAL(changed(QString,QString)),
- m_updateBookmarksTimer, SLOT(start()));
- connect(m_bookmarkManager, SIGNAL(bookmarksChanged(QString)),
- m_updateBookmarksTimer, SLOT(start()));
+ connect(m_bookmarkManager, &KBookmarkManager::changed,
+ m_updateBookmarksTimer, static_cast<void(QTimer::*)()>(&QTimer::start));
+ connect(m_bookmarkManager, &KBookmarkManager::bookmarksChanged,
+ m_updateBookmarksTimer, static_cast<void(QTimer::*)()>(&QTimer::start));
}
PlacesItemModel::~PlacesItemModel()
@@ -112,7 +112,7 @@ PlacesItemModel::~PlacesItemModel()
}
PlacesItem* PlacesItemModel::createPlacesItem(const QString& text,
- const KUrl& url,
+ const QUrl& url,
const QString& iconName)
{
const KBookmark bookmark = PlacesItem::createBookmark(m_bookmarkManager, text, url, iconName);
@@ -188,7 +188,7 @@ void PlacesItemModel::setHiddenItemsShown(bool show)
}
#ifdef PLACESITEMMODEL_DEBUG
- kDebug() << "Changed visibility of hidden items";
+ qCDebug(DolphinDebug) << "Changed visibility of hidden items";
showModelState();
#endif
}
@@ -198,15 +198,19 @@ bool PlacesItemModel::hiddenItemsShown() const
return m_hiddenItemsShown;
}
-int PlacesItemModel::closestItem(const KUrl& url) const
+int PlacesItemModel::closestItem(const QUrl& url) const
{
int foundIndex = -1;
int maxLength = 0;
for (int i = 0; i < count(); ++i) {
- const KUrl itemUrl = placesItem(i)->url();
- if (itemUrl.isParentOf(url)) {
- const int length = itemUrl.prettyUrl().length();
+ const QUrl itemUrl = placesItem(i)->url();
+ if (url == itemUrl) {
+ // We can't find a closer one, so stop here.
+ foundIndex = i;
+ break;
+ } else if (itemUrl.isParentOf(url)) {
+ const int length = itemUrl.path().length();
if (length > maxLength) {
foundIndex = i;
maxLength = length;
@@ -247,7 +251,7 @@ QAction* PlacesItemModel::ejectAction(int index) const
{
const PlacesItem* item = placesItem(index);
if (item && item->device().is<Solid::OpticalDisc>()) {
- return new QAction(KIcon("media-eject"), i18nc("@item", "Eject '%1'", item->text()), 0);
+ return new QAction(QIcon::fromTheme("media-eject"), i18nc("@item", "Eject '%1'", item->text()), 0);
}
return 0;
@@ -296,7 +300,7 @@ QAction* PlacesItemModel::teardownAction(int index) const
return new QAction(text, 0);
}
- return new QAction(KIcon(iconName), text, 0);
+ return new QAction(QIcon::fromTheme(iconName), text, 0);
}
void PlacesItemModel::requestEject(int index)
@@ -305,9 +309,8 @@ void PlacesItemModel::requestEject(int index)
if (item) {
Solid::OpticalDrive* drive = item->device().parent().as<Solid::OpticalDrive>();
if (drive) {
- connect(drive, SIGNAL(ejectDone(Solid::ErrorType,QVariant,QString)),
- this, SLOT(slotStorageTeardownDone(Solid::ErrorType,QVariant)),
- Qt::UniqueConnection);
+ connect(drive, &Solid::OpticalDrive::ejectDone,
+ this, &PlacesItemModel::slotStorageTeardownDone);
drive->eject();
} else {
const QString label = item->text();
@@ -323,9 +326,8 @@ void PlacesItemModel::requestTeardown(int index)
if (item) {
Solid::StorageAccess* access = item->device().as<Solid::StorageAccess>();
if (access) {
- connect(access, SIGNAL(teardownDone(Solid::ErrorType,QVariant,QString)),
- this, SLOT(slotStorageTeardownDone(Solid::ErrorType,QVariant)),
- Qt::UniqueConnection);
+ connect(access, &Solid::StorageAccess::teardownDone,
+ this, &PlacesItemModel::slotStorageTeardownDone);
access->teardown();
}
}
@@ -353,9 +355,8 @@ void PlacesItemModel::requestStorageSetup(int index)
m_storageSetupInProgress[access] = index;
- connect(access, SIGNAL(setupDone(Solid::ErrorType,QVariant,QString)),
- this, SLOT(slotStorageSetupDone(Solid::ErrorType,QVariant,QString)),
- Qt::UniqueConnection);
+ connect(access, &Solid::StorageAccess::setupDone,
+ this, &PlacesItemModel::slotStorageSetupDone);
access->setup();
}
@@ -363,13 +364,13 @@ void PlacesItemModel::requestStorageSetup(int index)
QMimeData* PlacesItemModel::createMimeData(const KItemSet& indexes) const
{
- KUrl::List urls;
+ QList<QUrl> urls;
QByteArray itemData;
QDataStream stream(&itemData, QIODevice::WriteOnly);
foreach (int index, indexes) {
- const KUrl itemUrl = placesItem(index)->url();
+ const QUrl itemUrl = placesItem(index)->url();
if (itemUrl.isValid()) {
urls << itemUrl;
}
@@ -378,7 +379,7 @@ QMimeData* PlacesItemModel::createMimeData(const KItemSet& indexes) const
QMimeData* mimeData = new QMimeData();
if (!urls.isEmpty()) {
- urls.populateMimeData(mimeData);
+ mimeData->setUrls(urls);
}
mimeData->setData(internalMimeType(), itemData);
@@ -419,9 +420,9 @@ void PlacesItemModel::dropMimeDataBefore(int index, const QMimeData* mimeData)
insertItem(dropIndex, newItem);
} else if (mimeData->hasFormat("text/uri-list")) {
// One or more items must be added to the model
- const KUrl::List urls = KUrl::List::fromMimeData(mimeData);
+ const QList<QUrl> urls = KUrlMimeData::urlsFromMimeData(mimeData);
for (int i = urls.count() - 1; i >= 0; --i) {
- const KUrl& url = urls[i];
+ const QUrl& url = urls[i];
QString text = url.fileName();
if (text.isEmpty()) {
@@ -429,7 +430,7 @@ void PlacesItemModel::dropMimeDataBefore(int index, const QMimeData* mimeData)
}
if ((url.isLocalFile() && !QFileInfo(url.toLocalFile()).isDir())
- || url.protocol() == "trash") {
+ || url.scheme() == "trash") {
// Only directories outside the trash are allowed
continue;
}
@@ -441,12 +442,12 @@ void PlacesItemModel::dropMimeDataBefore(int index, const QMimeData* mimeData)
}
}
-KUrl PlacesItemModel::convertedUrl(const KUrl& url)
+QUrl PlacesItemModel::convertedUrl(const QUrl& url)
{
- KUrl newUrl = url;
- if (url.protocol() == QLatin1String("timeline")) {
+ QUrl newUrl = url;
+ if (url.scheme() == QLatin1String("timeline")) {
newUrl = createTimelineUrl(url);
- } else if (url.protocol() == QLatin1String("search")) {
+ } else if (url.scheme() == QLatin1String("search")) {
newUrl = createSearchUrl(url);
}
@@ -492,7 +493,7 @@ void PlacesItemModel::onItemInserted(int index)
}
#ifdef PLACESITEMMODEL_DEBUG
- kDebug() << "Inserted item" << index;
+ qCDebug(DolphinDebug) << "Inserted item" << index;
showModelState();
#endif
}
@@ -510,7 +511,7 @@ void PlacesItemModel::onItemRemoved(int index, KStandardItem* removedItem)
m_bookmarkedItems.removeAt(boomarkIndex);
#ifdef PLACESITEMMODEL_DEBUG
- kDebug() << "Removed item" << index;
+ qCDebug(DolphinDebug) << "Removed item" << index;
showModelState();
#endif
}
@@ -589,14 +590,13 @@ void PlacesItemModel::slotStorageSetupDone(Solid::ErrorType error,
{
Q_UNUSED(udi);
- Q_ASSERT(!m_storageSetupInProgress.isEmpty());
const int index = m_storageSetupInProgress.take(sender());
const PlacesItem* item = placesItem(index);
if (!item) {
return;
}
- if (error) {
+ if (error != Solid::NoError) {
if (errorData.isValid()) {
emit errorMessage(i18nc("@info", "An error occurred while accessing '%1', the system responded: %2",
item->text(),
@@ -642,7 +642,7 @@ void PlacesItemModel::updateBookmarks()
found = true;
if (newBookmark.metaDataItem("UDI").isEmpty()) {
item->setBookmark(newBookmark);
- item->setText(i18nc("KFile System Bookmarks", newBookmark.text().toUtf8().data()));
+ item->setText(i18nc("KFile System Bookmarks", newBookmark.text().toUtf8().constData()));
}
break;
}
@@ -719,7 +719,7 @@ void PlacesItemModel::loadBookmarks()
KBookmark bookmark = root.first();
QSet<QString> devices = m_availableDevices;
- QSet<KUrl> missingSystemBookmarks;
+ QSet<QUrl> missingSystemBookmarks;
foreach (const SystemBookmarkData& data, m_systemBookmarks) {
missingSystemBookmarks.insert(data.url);
}
@@ -740,7 +740,7 @@ void PlacesItemModel::loadBookmarks()
devices.remove(item->udi());
devicesItems.append(item);
} else {
- const KUrl url = bookmark.url();
+ const QUrl url = bookmark.url();
if (missingSystemBookmarks.contains(url)) {
missingSystemBookmarks.remove(url);
@@ -749,7 +749,7 @@ void PlacesItemModel::loadBookmarks()
// text, the retranslation will fail and the users custom text is still used.
// It is important to use "KFile System Bookmarks" as context (see
// createSystemBookmarks()).
- item->setText(i18nc("KFile System Bookmarks", bookmark.text().toUtf8().data()));
+ item->setText(i18nc("KFile System Bookmarks", bookmark.text().toUtf8().constData()));
item->setSystemItem(true);
}
@@ -804,7 +804,7 @@ void PlacesItemModel::loadBookmarks()
}
#ifdef PLACESITEMMODEL_DEBUG
- kDebug() << "Loaded bookmarks";
+ qCDebug(DolphinDebug) << "Loaded bookmarks";
showModelState();
#endif
}
@@ -813,15 +813,15 @@ bool PlacesItemModel::acceptBookmark(const KBookmark& bookmark,
const QSet<QString>& availableDevices) const
{
const QString udi = bookmark.metaDataItem("UDI");
- const KUrl url = bookmark.url();
+ const QUrl url = bookmark.url();
const QString appName = bookmark.metaDataItem("OnlyInApp");
const bool deviceAvailable = availableDevices.contains(udi);
const bool allowedHere = (appName.isEmpty()
- || appName == KGlobal::mainComponent().componentName()
- || appName == KGlobal::mainComponent().componentName() + AppNamePrefix)
- && (m_fileIndexingEnabled || (url.protocol() != QLatin1String("timeline") &&
- url.protocol() != QLatin1String("search")));
+ || appName == KAboutData::applicationData().componentName()
+ || appName == KAboutData::applicationData().componentName() + AppNamePrefix)
+ && (m_fileIndexingEnabled || (url.scheme() != QLatin1String("timeline") &&
+ url.scheme() != QLatin1String("search")));
return (udi.isEmpty() && allowedHere) || deviceAvailable;
}
@@ -833,12 +833,12 @@ PlacesItem* PlacesItemModel::createSystemPlacesItem(const SystemBookmarkData& da
data.url,
data.icon);
- const QString protocol = data.url.protocol();
+ const QString protocol = data.url.scheme();
if (protocol == QLatin1String("timeline") || protocol == QLatin1String("search")) {
// As long as the KFilePlacesView from kdelibs is available, the system-bookmarks
// for "Recently Saved" and "Search For" should be a setting available only
// in the Places Panel (see description of AppNamePrefix for more details).
- const QString appName = KGlobal::mainComponent().componentName() + AppNamePrefix;
+ const QString appName = KAboutData::applicationData().componentName() + AppNamePrefix;
bookmark.setMetaDataItem("OnlyInApp", appName);
}
@@ -858,22 +858,22 @@ PlacesItem* PlacesItemModel::createSystemPlacesItem(const SystemBookmarkData& da
if (path == QLatin1String("/documents")) {
props.setViewMode(DolphinView::DetailsView);
props.setPreviewsShown(false);
- props.setVisibleRoles(QList<QByteArray>() << "text" << "path");
+ props.setVisibleRoles({"text", "path"});
} else if (path == QLatin1String("/images")) {
props.setViewMode(DolphinView::IconsView);
props.setPreviewsShown(true);
- props.setVisibleRoles(QList<QByteArray>() << "text" << "imageSize");
+ props.setVisibleRoles({"text", "imageSize"});
} else if (path == QLatin1String("/audio")) {
props.setViewMode(DolphinView::DetailsView);
props.setPreviewsShown(false);
- props.setVisibleRoles(QList<QByteArray>() << "text" << "artist" << "album");
+ props.setVisibleRoles({"text", "artist", "album"});
} else if (path == QLatin1String("/videos")) {
props.setViewMode(DolphinView::IconsView);
props.setPreviewsShown(true);
- props.setVisibleRoles(QList<QByteArray>() << "text");
- } else if (data.url.protocol() == "timeline") {
+ props.setVisibleRoles({"text"});
+ } else if (data.url.scheme() == "timeline") {
props.setViewMode(DolphinView::DetailsView);
- props.setVisibleRoles(QList<QByteArray>() << "text" << "date");
+ props.setVisibleRoles({"text", "date"});
}
}
}
@@ -890,42 +890,42 @@ void PlacesItemModel::createSystemBookmarks()
// i18nc call is done after reading the bookmark. The reason why the i18nc call is not
// done here is because otherwise switching the language would not result in retranslating the
// bookmarks.
- m_systemBookmarks.append(SystemBookmarkData(KUrl(KUser().homeDir()),
+ m_systemBookmarks.append(SystemBookmarkData(QUrl::fromLocalFile(KUser().homeDir()),
"user-home",
I18N_NOOP2("KFile System Bookmarks", "Home")));
- m_systemBookmarks.append(SystemBookmarkData(KUrl("remote:/"),
+ m_systemBookmarks.append(SystemBookmarkData(QUrl("remote:/"),
"network-workgroup",
I18N_NOOP2("KFile System Bookmarks", "Network")));
- m_systemBookmarks.append(SystemBookmarkData(KUrl("/"),
+ m_systemBookmarks.append(SystemBookmarkData(QUrl::fromLocalFile("/"),
"folder-red",
I18N_NOOP2("KFile System Bookmarks", "Root")));
- m_systemBookmarks.append(SystemBookmarkData(KUrl("trash:/"),
+ m_systemBookmarks.append(SystemBookmarkData(QUrl("trash:/"),
"user-trash",
I18N_NOOP2("KFile System Bookmarks", "Trash")));
if (m_fileIndexingEnabled) {
- m_systemBookmarks.append(SystemBookmarkData(KUrl("timeline:/today"),
+ m_systemBookmarks.append(SystemBookmarkData(QUrl("timeline:/today"),
"go-jump-today",
I18N_NOOP2("KFile System Bookmarks", "Today")));
- m_systemBookmarks.append(SystemBookmarkData(KUrl("timeline:/yesterday"),
+ m_systemBookmarks.append(SystemBookmarkData(QUrl("timeline:/yesterday"),
"view-calendar-day",
I18N_NOOP2("KFile System Bookmarks", "Yesterday")));
- m_systemBookmarks.append(SystemBookmarkData(KUrl("timeline:/thismonth"),
+ m_systemBookmarks.append(SystemBookmarkData(QUrl("timeline:/thismonth"),
"view-calendar-month",
I18N_NOOP2("KFile System Bookmarks", "This Month")));
- m_systemBookmarks.append(SystemBookmarkData(KUrl("timeline:/lastmonth"),
+ m_systemBookmarks.append(SystemBookmarkData(QUrl("timeline:/lastmonth"),
"view-calendar-month",
I18N_NOOP2("KFile System Bookmarks", "Last Month")));
- m_systemBookmarks.append(SystemBookmarkData(KUrl("search:/documents"),
+ m_systemBookmarks.append(SystemBookmarkData(QUrl("search:/documents"),
"folder-txt",
I18N_NOOP2("KFile System Bookmarks", "Documents")));
- m_systemBookmarks.append(SystemBookmarkData(KUrl("search:/images"),
+ m_systemBookmarks.append(SystemBookmarkData(QUrl("search:/images"),
"folder-image",
I18N_NOOP2("KFile System Bookmarks", "Images")));
- m_systemBookmarks.append(SystemBookmarkData(KUrl("search:/audio"),
+ m_systemBookmarks.append(SystemBookmarkData(QUrl("search:/audio"),
"folder-sound",
I18N_NOOP2("KFile System Bookmarks", "Audio Files")));
- m_systemBookmarks.append(SystemBookmarkData(KUrl("search:/videos"),
+ m_systemBookmarks.append(SystemBookmarkData(QUrl("search:/videos"),
"folder-video",
I18N_NOOP2("KFile System Bookmarks", "Videos")));
}
@@ -960,8 +960,8 @@ void PlacesItemModel::initializeAvailableDevices()
Q_ASSERT(m_predicate.isValid());
Solid::DeviceNotifier* notifier = Solid::DeviceNotifier::instance();
- connect(notifier, SIGNAL(deviceAdded(QString)), this, SLOT(slotDeviceAdded(QString)));
- connect(notifier, SIGNAL(deviceRemoved(QString)), this, SLOT(slotDeviceRemoved(QString)));
+ connect(notifier, &Solid::DeviceNotifier::deviceAdded, this, &PlacesItemModel::slotDeviceAdded);
+ connect(notifier, &Solid::DeviceNotifier::deviceRemoved, this, &PlacesItemModel::slotDeviceRemoved);
const QList<Solid::Device>& deviceList = Solid::Device::listFromQuery(m_predicate);
foreach (const Solid::Device& device, deviceList) {
@@ -1087,14 +1087,14 @@ bool PlacesItemModel::equalBookmarkIdentifiers(const KBookmark& b1, const KBookm
}
}
-KUrl PlacesItemModel::createTimelineUrl(const KUrl& url)
+QUrl PlacesItemModel::createTimelineUrl(const QUrl& url)
{
// TODO: Clarify with the Baloo-team whether it makes sense
// provide default-timeline-URLs like 'yesterday', 'this month'
// and 'last month'.
- KUrl timelineUrl;
+ QUrl timelineUrl;
- const QString path = url.pathOrUrl();
+ const QString path = url.toDisplayString(QUrl::PreferLocalFile);
if (path.endsWith(QLatin1String("yesterday"))) {
const QDate date = QDate::currentDate().addDays(-1);
const int year = date.year();
@@ -1135,12 +1135,12 @@ QString PlacesItemModel::timelineDateString(int year, int month, int day)
return date;
}
-KUrl PlacesItemModel::createSearchUrl(const KUrl& url)
+QUrl PlacesItemModel::createSearchUrl(const QUrl& url)
{
- KUrl searchUrl;
+ QUrl searchUrl;
#ifdef HAVE_BALOO
- const QString path = url.pathOrUrl();
+ const QString path = url.toDisplayString(QUrl::PreferLocalFile);
if (path.endsWith(QLatin1String("documents"))) {
searchUrl = searchUrlForType("Document");
} else if (path.endsWith(QLatin1String("images"))) {
@@ -1160,7 +1160,7 @@ KUrl PlacesItemModel::createSearchUrl(const KUrl& url)
}
#ifdef HAVE_BALOO
-KUrl PlacesItemModel::searchUrlForType(const QString& type)
+QUrl PlacesItemModel::searchUrlForType(const QString& type)
{
Baloo::Query query;
query.addType("File");
@@ -1173,25 +1173,25 @@ KUrl PlacesItemModel::searchUrlForType(const QString& type)
#ifdef PLACESITEMMODEL_DEBUG
void PlacesItemModel::showModelState()
{
- kDebug() << "=================================";
- kDebug() << "Model:";
- kDebug() << "hidden-index model-index text";
+ qCDebug(DolphinDebug) << "=================================";
+ qCDebug(DolphinDebug) << "Model:";
+ qCDebug(DolphinDebug) << "hidden-index model-index text";
int modelIndex = 0;
for (int i = 0; i < m_bookmarkedItems.count(); ++i) {
if (m_bookmarkedItems[i]) {
- kDebug() << i << "(Hidden) " << " " << m_bookmarkedItems[i]->dataValue("text").toString();
+ qCDebug(DolphinDebug) << i << "(Hidden) " << " " << m_bookmarkedItems[i]->dataValue("text").toString();
} else {
if (item(modelIndex)) {
- kDebug() << i << " " << modelIndex << " " << item(modelIndex)->dataValue("text").toString();
+ qCDebug(DolphinDebug) << i << " " << modelIndex << " " << item(modelIndex)->dataValue("text").toString();
} else {
- kDebug() << i << " " << modelIndex << " " << "(not available yet)";
+ qCDebug(DolphinDebug) << i << " " << modelIndex << " " << "(not available yet)";
}
++modelIndex;
}
}
- kDebug();
- kDebug() << "Bookmarks:";
+ qCDebug(DolphinDebug);
+ qCDebug(DolphinDebug) << "Bookmarks:";
int bookmarkIndex = 0;
KBookmarkGroup root = m_bookmarkManager->root();
@@ -1200,9 +1200,9 @@ void PlacesItemModel::showModelState()
const QString udi = bookmark.metaDataItem("UDI");
const QString text = udi.isEmpty() ? bookmark.text() : udi;
if (bookmark.metaDataItem("IsHidden") == QLatin1String("true")) {
- kDebug() << bookmarkIndex << "(Hidden)" << text;
+ qCDebug(DolphinDebug) << bookmarkIndex << "(Hidden)" << text;
} else {
- kDebug() << bookmarkIndex << " " << text;
+ qCDebug(DolphinDebug) << bookmarkIndex << " " << text;
}
bookmark = root.next(bookmark);
@@ -1211,4 +1211,3 @@ void PlacesItemModel::showModelState()
}
#endif
-#include "placesitemmodel.moc"
diff --git a/src/panels/places/placesitemmodel.h b/src/panels/places/placesitemmodel.h
index 7cbf99e95..aa8bb16fe 100644
--- a/src/panels/places/placesitemmodel.h
+++ b/src/panels/places/placesitemmodel.h
@@ -24,7 +24,7 @@
#include <kitemviews/kstandarditemmodel.h>
-#include <KUrl>
+#include <QUrl>
#include <QHash>
#include <QList>
#include <QSet>
@@ -58,7 +58,7 @@ public:
* attributes.
*/
PlacesItem* createPlacesItem(const QString& text,
- const KUrl& url,
+ const QUrl& url,
const QString& iconName = QString());
PlacesItem* placesItem(int index) const;
@@ -87,7 +87,7 @@ public:
* range of the URL. -1 is returned if no closest item
* could be found.
*/
- int closestItem(const KUrl& url) const;
+ int closestItem(const QUrl& url) const;
/**
* Appends the item \a item as last element of the group
@@ -107,11 +107,9 @@ public:
bool storageSetupNeeded(int index) const;
void requestStorageSetup(int index);
- /** @reimp */
- virtual QMimeData* createMimeData(const KItemSet& indexes) const;
+ virtual QMimeData* createMimeData(const KItemSet& indexes) const Q_DECL_OVERRIDE;
- /** @reimp */
- virtual bool supportsDropping(int index) const;
+ virtual bool supportsDropping(int index) const Q_DECL_OVERRIDE;
void dropMimeDataBefore(int index, const QMimeData* mimeData);
@@ -121,9 +119,9 @@ public:
* the corresponding IO-slave. Virtual URLs for bookmarks are used to
* be independent from internal format changes.
*/
- static KUrl convertedUrl(const KUrl& url);
+ static QUrl convertedUrl(const QUrl& url);
- virtual void clear();
+ virtual void clear() Q_DECL_OVERRIDE;
/**
* Saves the bookmarks and indicates to other applications that the
@@ -137,9 +135,9 @@ signals:
void storageSetupDone(int index, bool success);
protected:
- virtual void onItemInserted(int index);
- virtual void onItemRemoved(int index, KStandardItem* removedItem);
- virtual void onItemChanged(int index, const QSet<QByteArray>& changedRoles);
+ virtual void onItemInserted(int index) Q_DECL_OVERRIDE;
+ virtual void onItemRemoved(int index, KStandardItem* removedItem) Q_DECL_OVERRIDE;
+ virtual void onItemChanged(int index, const QSet<QByteArray>& changedRoles) Q_DECL_OVERRIDE;
private slots:
void slotDeviceAdded(const QString& udi);
@@ -219,7 +217,7 @@ private:
/**
* @return URL using the timeline-protocol for searching (see convertedUrl()).
*/
- static KUrl createTimelineUrl(const KUrl& url);
+ static QUrl createTimelineUrl(const QUrl& url);
/**
* Helper method for createTimelineUrl().
@@ -233,7 +231,7 @@ private:
* for a given term. The URL \a url represents a places-internal
* URL like e.g. "search:/documents" (see convertedUrl()).
*/
- static KUrl createSearchUrl(const KUrl& url);
+ static QUrl createSearchUrl(const QUrl& url);
#ifdef HAVE_BALOO
/**
@@ -241,7 +239,7 @@ private:
* @return URL that can be listed by KIO and results in searching
* for the given type
*/
- static KUrl searchUrlForType(const QString& type);
+ static QUrl searchUrlForType(const QString& type);
#endif
#ifdef PLACESITEMMODEL_DEBUG
@@ -258,17 +256,17 @@ private:
struct SystemBookmarkData
{
- SystemBookmarkData(const KUrl& url,
+ SystemBookmarkData(const QUrl& url,
const QString& icon,
const QString& text) :
url(url), icon(icon), text(text) {}
- KUrl url;
+ QUrl url;
QString icon;
QString text;
};
QList<SystemBookmarkData> m_systemBookmarks;
- QHash<KUrl, int> m_systemBookmarksIndexes;
+ QHash<QUrl, int> m_systemBookmarksIndexes;
// Contains hidden and unhidden items that are stored as
// bookmark (the model itself only contains items that
diff --git a/src/panels/places/placesitemsignalhandler.cpp b/src/panels/places/placesitemsignalhandler.cpp
index 54a916de7..c9bc0db3f 100644
--- a/src/panels/places/placesitemsignalhandler.cpp
+++ b/src/panels/places/placesitemsignalhandler.cpp
@@ -47,4 +47,3 @@ void PlacesItemSignalHandler::onTrashDirListerCompleted()
}
}
-#include "placesitemsignalhandler.moc"
diff --git a/src/panels/places/placesitemsignalhandler.h b/src/panels/places/placesitemsignalhandler.h
index d767b58d3..af66568ad 100644
--- a/src/panels/places/placesitemsignalhandler.h
+++ b/src/panels/places/placesitemsignalhandler.h
@@ -29,7 +29,7 @@ class PlacesItem;
* and performing a corresponding action.
*
* PlacesItem is derived from KStandardItem, which is no QObject-class
- * on purpose. To be able to internally listening to signals and performing a
+ * on purpose. To be able to internally listen to signals and performing a
* corresponding action, PlacesItemSignalHandler is used.
*
* E.g. if the PlacesItem wants to react on accessibility-changes of a storage-access,
diff --git a/src/panels/places/placespanel.cpp b/src/panels/places/placespanel.cpp
index 6b840ef57..50ed7e73a 100644
--- a/src/panels/places/placespanel.cpp
+++ b/src/panels/places/placespanel.cpp
@@ -25,17 +25,22 @@
#include "dolphin_generalsettings.h"
-#include <KDebug>
+#include <KFileItem>
+#include "dolphindebug.h"
#include <KDirNotify>
-#include <KIcon>
+#include <QIcon>
#include <KIO/Job>
+#include <KIO/DropJob>
+#include <KIO/EmptyTrashJob>
#include <KIO/JobUiDelegate>
-#include <KLocale>
+#include <KJobWidgets>
+#include <KLocalizedString>
+#include <KIconLoader>
#include <kitemviews/kitemlistcontainer.h>
#include <kitemviews/kitemlistcontroller.h>
#include <kitemviews/kitemlistselectionmanager.h>
#include <kitemviews/kstandarditem.h>
-#include <KMenu>
+#include <QMenu>
#include <KMessageBox>
#include <KNotification>
#include "placesitem.h"
@@ -48,6 +53,7 @@
#include <QGraphicsSceneDragDropEvent>
#include <QVBoxLayout>
#include <QShowEvent>
+#include <QMimeData>
PlacesPanel::PlacesPanel(QWidget* parent) :
Panel(parent),
@@ -67,7 +73,7 @@ PlacesPanel::~PlacesPanel()
bool PlacesPanel::urlChanged()
{
- if (!url().isValid() || url().protocol().contains("search")) {
+ if (!url().isValid() || url().scheme().contains("search")) {
// Skip results shown by a search, as possible identical
// directory names are useless without parent-path information.
return false;
@@ -101,8 +107,8 @@ void PlacesPanel::showEvent(QShowEvent* event)
// used at all and stays invisible.
m_model = new PlacesItemModel(this);
m_model->setGroupedSorting(true);
- connect(m_model, SIGNAL(errorMessage(QString)),
- this, SIGNAL(errorMessage(QString)));
+ connect(m_model, &PlacesItemModel::errorMessage,
+ this, &PlacesPanel::errorMessage);
m_view = new PlacesView();
m_view->setWidgetCreator(new KItemListWidgetCreator<PlacesItemListWidget>());
@@ -112,14 +118,14 @@ void PlacesPanel::showEvent(QShowEvent* event)
m_controller->setSelectionBehavior(KItemListController::SingleSelection);
m_controller->setSingleClickActivationEnforced(true);
- readSettings();
+ readSettings();
- connect(m_controller, SIGNAL(itemActivated(int)), this, SLOT(slotItemActivated(int)));
- connect(m_controller, SIGNAL(itemMiddleClicked(int)), this, SLOT(slotItemMiddleClicked(int)));
- connect(m_controller, SIGNAL(itemContextMenuRequested(int,QPointF)), this, SLOT(slotItemContextMenuRequested(int,QPointF)));
- connect(m_controller, SIGNAL(viewContextMenuRequested(QPointF)), this, SLOT(slotViewContextMenuRequested(QPointF)));
- connect(m_controller, SIGNAL(itemDropEvent(int,QGraphicsSceneDragDropEvent*)), this, SLOT(slotItemDropEvent(int,QGraphicsSceneDragDropEvent*)));
- connect(m_controller, SIGNAL(aboveItemDropEvent(int,QGraphicsSceneDragDropEvent*)), this, SLOT(slotAboveItemDropEvent(int,QGraphicsSceneDragDropEvent*)));
+ connect(m_controller, &KItemListController::itemActivated, this, &PlacesPanel::slotItemActivated);
+ connect(m_controller, &KItemListController::itemMiddleClicked, this, &PlacesPanel::slotItemMiddleClicked);
+ connect(m_controller, &KItemListController::itemContextMenuRequested, this, &PlacesPanel::slotItemContextMenuRequested);
+ connect(m_controller, &KItemListController::viewContextMenuRequested, this, &PlacesPanel::slotViewContextMenuRequested);
+ connect(m_controller, &KItemListController::itemDropEvent, this, &PlacesPanel::slotItemDropEvent);
+ connect(m_controller, &KItemListController::aboveItemDropEvent, this, &PlacesPanel::slotAboveItemDropEvent);
KItemListContainer* container = new KItemListContainer(m_controller, this);
container->setEnabledFrame(false);
@@ -151,7 +157,7 @@ void PlacesPanel::slotItemContextMenuRequested(int index, const QPointF& pos)
return;
}
- KMenu menu(this);
+ QMenu menu(this);
QAction* emptyTrashAction = 0;
QAction* addAction = 0;
@@ -180,26 +186,26 @@ void PlacesPanel::slotItemContextMenuRequested(int index, const QPointF& pos)
mainSeparator = menu.addSeparator();
}
} else {
- if (item->url() == KUrl("trash:/")) {
- emptyTrashAction = menu.addAction(KIcon("trash-empty"), i18nc("@action:inmenu", "Empty Trash"));
+ if (item->url() == QUrl("trash:/")) {
+ emptyTrashAction = menu.addAction(QIcon::fromTheme("trash-empty"), i18nc("@action:inmenu", "Empty Trash"));
emptyTrashAction->setEnabled(item->icon() == "user-trash-full");
menu.addSeparator();
}
- addAction = menu.addAction(KIcon("document-new"), i18nc("@item:inmenu", "Add Entry..."));
+ addAction = menu.addAction(QIcon::fromTheme("document-new"), i18nc("@item:inmenu", "Add Entry..."));
mainSeparator = menu.addSeparator();
- editAction = menu.addAction(KIcon("document-properties"), i18nc("@item:inmenu", "Edit '%1'...", label));
+ editAction = menu.addAction(QIcon::fromTheme("document-properties"), i18nc("@item:inmenu", "Edit '%1'...", label));
}
if (!addAction) {
- addAction = menu.addAction(KIcon("document-new"), i18nc("@item:inmenu", "Add Entry..."));
+ addAction = menu.addAction(QIcon::fromTheme("document-new"), i18nc("@item:inmenu", "Add Entry..."));
}
QAction* openInNewTabAction = menu.addAction(i18nc("@item:inmenu", "Open '%1' in New Tab", label));
- openInNewTabAction->setIcon(KIcon("tab-new"));
+ openInNewTabAction->setIcon(QIcon::fromTheme("tab-new"));
QAction* removeAction = 0;
if (!isDevice && !item->isSystemItem()) {
- removeAction = menu.addAction(KIcon("edit-delete"), i18nc("@item:inmenu", "Remove '%1'", label));
+ removeAction = menu.addAction(QIcon::fromTheme("edit-delete"), i18nc("@item:inmenu", "Remove '%1'", label));
}
QAction* hideAction = menu.addAction(i18nc("@item:inmenu", "Hide '%1'", label));
@@ -217,7 +223,7 @@ void PlacesPanel::slotItemContextMenuRequested(int index, const QPointF& pos)
}
menu.addSeparator();
- KMenu* iconSizeSubMenu = new KMenu(i18nc("@item:inmenu", "Icon Size"), &menu);
+ QMenu* iconSizeSubMenu = new QMenu(i18nc("@item:inmenu", "Icon Size"), &menu);
struct IconSizeInfo
{
@@ -301,9 +307,9 @@ void PlacesPanel::slotItemContextMenuRequested(int index, const QPointF& pos)
void PlacesPanel::slotViewContextMenuRequested(const QPointF& pos)
{
- KMenu menu(this);
+ QMenu menu(this);
- QAction* addAction = menu.addAction(KIcon("document-new"), i18nc("@item:inmenu", "Add Entry..."));
+ QAction* addAction = menu.addAction(QIcon::fromTheme("document-new"), i18nc("@item:inmenu", "Add Entry..."));
QAction* showAllAction = 0;
if (m_model->hiddenCount() > 0) {
@@ -342,8 +348,8 @@ void PlacesPanel::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* even
}
if (m_model->storageSetupNeeded(index)) {
- connect(m_model, SIGNAL(storageSetupDone(int,bool)),
- this, SLOT(slotItemDropEventStorageSetupDone(int,bool)));
+ connect(m_model, &PlacesItemModel::storageSetupDone,
+ this, &PlacesPanel::slotItemDropEventStorageSetupDone);
m_itemDropEventIndex = index;
@@ -365,34 +371,25 @@ void PlacesPanel::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* even
return;
}
- KUrl destUrl = destItem->url();
+ QUrl destUrl = destItem->url();
QDropEvent dropEvent(event->pos().toPoint(),
event->possibleActions(),
event->mimeData(),
event->buttons(),
event->modifiers());
- QString error;
- DragAndDropHelper::dropUrls(KFileItem(), destUrl, &dropEvent, error);
- if (!error.isEmpty()) {
- emit errorMessage(error);
- }
+ slotUrlsDropped(destUrl, &dropEvent, this);
}
void PlacesPanel::slotItemDropEventStorageSetupDone(int index, bool success)
{
- disconnect(m_model, SIGNAL(storageSetupDone(int,bool)),
- this, SLOT(slotItemDropEventStorageSetupDone(int,bool)));
+ disconnect(m_model, &PlacesItemModel::storageSetupDone,
+ this, &PlacesPanel::slotItemDropEventStorageSetupDone);
if ((index == m_itemDropEventIndex) && m_itemDropEvent && m_itemDropEventMimeData) {
if (success) {
- KUrl destUrl = m_model->placesItem(index)->url();
-
- QString error;
- DragAndDropHelper::dropUrls(KFileItem(), destUrl, m_itemDropEvent, error);
- if (!error.isEmpty()) {
- emit errorMessage(error);
- }
+ QUrl destUrl = m_model->placesItem(index)->url();
+ slotUrlsDropped(destUrl, m_itemDropEvent, this);
}
delete m_itemDropEventMimeData;
@@ -410,15 +407,12 @@ void PlacesPanel::slotAboveItemDropEvent(int index, QGraphicsSceneDragDropEvent*
m_model->saveBookmarks();
}
-void PlacesPanel::slotUrlsDropped(const KUrl& dest, QDropEvent* event, QWidget* parent)
+void PlacesPanel::slotUrlsDropped(const QUrl& dest, QDropEvent* event, QWidget* parent)
{
- Q_UNUSED(parent);
- QString error;
- DragAndDropHelper::dropUrls(KFileItem(), dest, event, error);
- if (!error.isEmpty()) {
- emit errorMessage(error);
+ KIO::DropJob *job = DragAndDropHelper::dropUrls(dest, event, parent);
+ if (job) {
+ connect(job, &KIO::DropJob::result, this, [this](KJob *job) { if (job->error()) emit errorMessage(job->errorString()); });
}
-
}
void PlacesPanel::slotTrashUpdated(KJob* job)
@@ -426,13 +420,14 @@ void PlacesPanel::slotTrashUpdated(KJob* job)
if (job->error()) {
emit errorMessage(job->errorString());
}
- org::kde::KDirNotify::emitFilesAdded("trash:/");
+ // as long as KIO doesn't do this, do it ourselves
+ KNotification::event("Trash: emptied", QString(), QPixmap(), 0, KNotification::DefaultEvent);
}
void PlacesPanel::slotStorageSetupDone(int index, bool success)
{
- disconnect(m_model, SIGNAL(storageSetupDone(int,bool)),
- this, SLOT(slotStorageSetupDone(int,bool)));
+ disconnect(m_model, &PlacesItemModel::storageSetupDone,
+ this, &PlacesPanel::slotStorageSetupDone);
if (m_triggerStorageSetupButton == Qt::NoButton) {
return;
@@ -444,37 +439,28 @@ void PlacesPanel::slotStorageSetupDone(int index, bool success)
m_triggerStorageSetupButton = Qt::NoButton;
} else {
setUrl(m_storageSetupFailedUrl);
- m_storageSetupFailedUrl = KUrl();
+ m_storageSetupFailedUrl = QUrl();
}
}
void PlacesPanel::emptyTrash()
{
- const QString text = i18nc("@info", "Do you really want to empty the Trash? All items will be deleted.");
- const bool del = KMessageBox::warningContinueCancel(window(),
- text,
- QString(),
- KGuiItem(i18nc("@action:button", "Empty Trash"),
- KIcon("user-trash"))
- ) == KMessageBox::Continue;
- if (del) {
- QByteArray packedArgs;
- QDataStream stream(&packedArgs, QIODevice::WriteOnly);
- stream << int(1);
- KIO::Job *job = KIO::special(KUrl("trash:/"), packedArgs);
- KNotification::event("Trash: emptied", QString() , QPixmap() , 0, KNotification::DefaultEvent);
- job->ui()->setWindow(parentWidget());
- connect(job, SIGNAL(result(KJob*)), SLOT(slotTrashUpdated(KJob*)));
+ KIO::JobUiDelegate uiDelegate;
+ uiDelegate.setWindow(window());
+ if (uiDelegate.askDeleteConfirmation(QList<QUrl>(), KIO::JobUiDelegate::EmptyTrash, KIO::JobUiDelegate::DefaultConfirmation)) {
+ KIO::Job* job = KIO::emptyTrash();
+ KJobWidgets::setWindow(job, window());
+ connect(job, &KIO::Job::result, this, &PlacesPanel::slotTrashUpdated);
}
}
void PlacesPanel::addEntry()
{
const int index = m_controller->selectionManager()->currentItem();
- const KUrl url = m_model->data(index).value("url").value<KUrl>();
+ const QUrl url = m_model->data(index).value("url").value<QUrl>();
QPointer<PlacesItemEditDialog> dialog = new PlacesItemEditDialog(this);
- dialog->setCaption(i18nc("@title:window", "Add Places Entry"));
+ dialog->setWindowTitle(i18nc("@title:window", "Add Places Entry"));
dialog->setAllowGlobal(true);
dialog->setUrl(url);
if (dialog->exec() == QDialog::Accepted) {
@@ -491,10 +477,10 @@ void PlacesPanel::editEntry(int index)
QHash<QByteArray, QVariant> data = m_model->data(index);
QPointer<PlacesItemEditDialog> dialog = new PlacesItemEditDialog(this);
- dialog->setCaption(i18nc("@title:window", "Edit Places Entry"));
+ dialog->setWindowTitle(i18nc("@title:window", "Edit Places Entry"));
dialog->setIcon(data.value("iconName").toString());
dialog->setText(data.value("text").toString());
- dialog->setUrl(data.value("url").value<KUrl>());
+ dialog->setUrl(data.value("url").value<QUrl>());
dialog->setAllowGlobal(true);
if (dialog->exec() == QDialog::Accepted) {
PlacesItem* oldItem = m_model->placesItem(index);
@@ -529,14 +515,14 @@ void PlacesPanel::triggerItem(int index, Qt::MouseButton button)
m_triggerStorageSetupButton = button;
m_storageSetupFailedUrl = url();
- connect(m_model, SIGNAL(storageSetupDone(int,bool)),
- this, SLOT(slotStorageSetupDone(int,bool)));
+ connect(m_model, &PlacesItemModel::storageSetupDone,
+ this, &PlacesPanel::slotStorageSetupDone);
m_model->requestStorageSetup(index);
} else {
m_triggerStorageSetupButton = Qt::NoButton;
- const KUrl url = m_model->data(index).value("url").value<KUrl>();
+ const QUrl url = m_model->data(index).value("url").value<QUrl>();
if (!url.isEmpty()) {
if (button == Qt::MiddleButton) {
emit placeMiddleClicked(PlacesItemModel::convertedUrl(url));
@@ -546,6 +532,3 @@ void PlacesPanel::triggerItem(int index, Qt::MouseButton button)
}
}
}
-
-
-#include "placespanel.moc"
diff --git a/src/panels/places/placespanel.h b/src/panels/places/placespanel.h
index 16112e8b2..81aeedb28 100644
--- a/src/panels/places/placespanel.h
+++ b/src/panels/places/placespanel.h
@@ -21,16 +21,16 @@
#ifndef PLACESPANEL_H
#define PLACESPANEL_H
-#include <KUrl>
+#include <QUrl>
+#include <QMimeData>
#include <panels/panel.h>
class KItemListController;
-class PlacesItemEditDialog;
class PlacesItem;
class PlacesItemModel;
class PlacesView;
class QGraphicsSceneDragDropEvent;
-
+class KJob;
/**
* @brief Combines bookmarks and mounted devices as list.
*/
@@ -43,13 +43,13 @@ public:
virtual ~PlacesPanel();
signals:
- void placeActivated(const KUrl& url);
- void placeMiddleClicked(const KUrl& url);
+ void placeActivated(const QUrl& url);
+ void placeMiddleClicked(const QUrl& url);
void errorMessage(const QString& error);
protected:
- virtual bool urlChanged();
- virtual void showEvent(QShowEvent* event);
+ virtual bool urlChanged() Q_DECL_OVERRIDE;
+ virtual void showEvent(QShowEvent* event) Q_DECL_OVERRIDE;
public slots:
virtual void readSettings();
@@ -62,7 +62,7 @@ private slots:
void slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event);
void slotItemDropEventStorageSetupDone(int index, bool success);
void slotAboveItemDropEvent(int index, QGraphicsSceneDragDropEvent* event);
- void slotUrlsDropped(const KUrl& dest, QDropEvent* event, QWidget* parent);
+ void slotUrlsDropped(const QUrl& dest, QDropEvent* event, QWidget* parent);
void slotTrashUpdated(KJob* job);
void slotStorageSetupDone(int index, bool success);
@@ -84,7 +84,7 @@ private:
PlacesItemModel* m_model;
PlacesView* m_view;
- KUrl m_storageSetupFailedUrl;
+ QUrl m_storageSetupFailedUrl;
Qt::MouseButton m_triggerStorageSetupButton;
int m_itemDropEventIndex;
diff --git a/src/panels/places/placesview.cpp b/src/panels/places/placesview.cpp
index a298a5250..d755d46b5 100644
--- a/src/panels/places/placesview.cpp
+++ b/src/panels/places/placesview.cpp
@@ -35,7 +35,7 @@ void PlacesView::setIconSize(int size)
if (size != iconSize()) {
PlacesPanelSettings* settings = PlacesPanelSettings::self();
settings->setIconSize(size);
- settings->writeConfig();
+ settings->save();
KItemListStyleOption option = styleOption();
option.iconSize = size;
@@ -49,4 +49,3 @@ int PlacesView::iconSize() const
return option.iconSize;
}
-#include "placesview.moc"
diff --git a/src/panels/terminal/terminalpanel.cpp b/src/panels/terminal/terminalpanel.cpp
index f827503a2..ee88bd4c5 100644
--- a/src/panels/terminal/terminalpanel.cpp
+++ b/src/panels/terminal/terminalpanel.cpp
@@ -24,15 +24,16 @@
#include <KPluginLoader>
#include <KPluginFactory>
#include <KService>
-#include <kde_terminal_interface_v2.h>
-#include <KParts/Part>
+#include <kde_terminal_interface.h>
+#include <KParts/ReadOnlyPart>
#include <KShell>
#include <KIO/Job>
#include <KIO/JobUiDelegate>
+#include <KJobWidgets>
-#include <QBoxLayout>
#include <QDir>
#include <QShowEvent>
+#include <QVBoxLayout>
TerminalPanel::TerminalPanel(QWidget* parent) :
Panel(parent),
@@ -70,7 +71,7 @@ void TerminalPanel::dockVisibilityChanged()
this, SLOT(slotKonsolePartCurrentDirectoryChanged(QString)));
// Make sure this terminal does not prevent unmounting any removable drives
- changeDir(KUrl::fromPath("/"));
+ changeDir(QUrl::fromLocalFile("/"));
// Because we have disconnected from the part's currentDirectoryChanged()
// signal, we have to update m_konsolePartCurrentDirectory manually. If this
@@ -110,10 +111,10 @@ void TerminalPanel::showEvent(QShowEvent* event)
}
m_konsolePart = factory ? (factory->create<KParts::ReadOnlyPart>(this)) : 0;
if (m_konsolePart) {
- connect(m_konsolePart, SIGNAL(destroyed(QObject*)), this, SLOT(terminalExited()));
+ connect(m_konsolePart, &KParts::ReadOnlyPart::destroyed, this, &TerminalPanel::terminalExited);
m_terminalWidget = m_konsolePart->widget();
m_layout->addWidget(m_terminalWidget);
- m_terminal = qobject_cast<TerminalInterfaceV2 *>(m_konsolePart);
+ m_terminal = qobject_cast<TerminalInterface*>(m_konsolePart);
}
}
if (m_terminal) {
@@ -127,7 +128,7 @@ void TerminalPanel::showEvent(QShowEvent* event)
Panel::showEvent(event);
}
-void TerminalPanel::changeDir(const KUrl& url)
+void TerminalPanel::changeDir(const QUrl& url)
{
delete m_mostLocalUrlJob;
m_mostLocalUrlJob = 0;
@@ -137,9 +138,9 @@ void TerminalPanel::changeDir(const KUrl& url)
} else {
m_mostLocalUrlJob = KIO::mostLocalUrl(url, KIO::HideProgressInfo);
if (m_mostLocalUrlJob->ui()) {
- m_mostLocalUrlJob->ui()->setWindow(this);
+ KJobWidgets::setWindow(m_mostLocalUrlJob, this);
}
- connect(m_mostLocalUrlJob, SIGNAL(result(KJob*)), this, SLOT(slotMostLocalUrlResult(KJob*)));
+ connect(m_mostLocalUrlJob, &KIO::StatJob::result, this, &TerminalPanel::slotMostLocalUrlResult);
}
}
@@ -178,7 +179,7 @@ void TerminalPanel::sendCdToTerminal(const QString& dir)
void TerminalPanel::slotMostLocalUrlResult(KJob* job)
{
KIO::StatJob* statJob = static_cast<KIO::StatJob *>(job);
- const KUrl url = statJob->mostLocalUrl();
+ const QUrl url = statJob->mostLocalUrl();
if (url.isLocalFile()) {
sendCdToTerminal(url.toLocalFile());
}
@@ -198,7 +199,6 @@ void TerminalPanel::slotKonsolePartCurrentDirectoryChanged(const QString& dir)
}
}
- emit changeUrl(dir);
+ const QUrl url(QUrl::fromLocalFile(dir));
+ emit changeUrl(url);
}
-
-#include "terminalpanel.moc"
diff --git a/src/panels/terminal/terminalpanel.h b/src/panels/terminal/terminalpanel.h
index b65239baf..75e198e1a 100644
--- a/src/panels/terminal/terminalpanel.h
+++ b/src/panels/terminal/terminalpanel.h
@@ -24,7 +24,7 @@
#include <QQueue>
-class TerminalInterfaceV2;
+class TerminalInterface;
class QVBoxLayout;
class QWidget;
@@ -35,7 +35,7 @@ namespace KIO {
namespace KParts {
class ReadOnlyPart;
}
-
+class KJob;
/**
* @brief Shows the terminal which is synchronized with the URL of the
* active view.
@@ -58,21 +58,19 @@ signals:
/**
* Is emitted if the an URL change is requested.
*/
- void changeUrl(const KUrl& url);
+ void changeUrl(const QUrl& url);
protected:
- /** @see Panel::urlChanged() */
- virtual bool urlChanged();
+ virtual bool urlChanged() Q_DECL_OVERRIDE;
- /** @see QWidget::showEvent() */
- virtual void showEvent(QShowEvent* event);
+ virtual void showEvent(QShowEvent* event) Q_DECL_OVERRIDE;
private slots:
void slotMostLocalUrlResult(KJob* job);
void slotKonsolePartCurrentDirectoryChanged(const QString& dir);
private:
- void changeDir(const KUrl& url);
+ void changeDir(const QUrl& url);
void sendCdToTerminal(const QString& path);
private:
@@ -80,7 +78,7 @@ private:
KIO::StatJob* m_mostLocalUrlJob;
QVBoxLayout* m_layout;
- TerminalInterfaceV2* m_terminal;
+ TerminalInterface* m_terminal;
QWidget* m_terminalWidget;
KParts::ReadOnlyPart* m_konsolePart;
QString m_konsolePartCurrentDirectory;
diff --git a/src/search/dolphinfacetswidget.cpp b/src/search/dolphinfacetswidget.cpp
index f20ae68d5..b183eb8a1 100644
--- a/src/search/dolphinfacetswidget.cpp
+++ b/src/search/dolphinfacetswidget.cpp
@@ -19,7 +19,7 @@
#include "dolphinfacetswidget.h"
-#include <KLocale>
+#include <KLocalizedString>
#include <QButtonGroup>
#include <QCheckBox>
#include <QDate>
@@ -295,9 +295,8 @@ QRadioButton* DolphinFacetsWidget::createRadioButton(const QString& text,
QButtonGroup* group)
{
QRadioButton* button = new QRadioButton(text);
- connect(button, SIGNAL(clicked()), this, SIGNAL(facetChanged()));
+ connect(button, &QRadioButton::clicked, this, &DolphinFacetsWidget::facetChanged);
group->addButton(button);
return button;
}
-#include "dolphinfacetswidget.moc"
diff --git a/src/search/dolphinfacetswidget.h b/src/search/dolphinfacetswidget.h
index 757dcd482..03fb1279d 100644
--- a/src/search/dolphinfacetswidget.h
+++ b/src/search/dolphinfacetswidget.h
@@ -24,11 +24,10 @@
#include <config-baloo.h>
#ifdef HAVE_BALOO
- #include <baloo/term.h>
+ #include <Baloo/Term>
#endif
class QButtonGroup;
-class QCheckBox;
class QDate;
class QRadioButton;
diff --git a/src/search/dolphinsearchbox.cpp b/src/search/dolphinsearchbox.cpp
index 46ca01a4c..524c4462f 100644
--- a/src/search/dolphinsearchbox.cpp
+++ b/src/search/dolphinsearchbox.cpp
@@ -22,15 +22,14 @@
#include "dolphin_searchsettings.h"
#include "dolphinfacetswidget.h"
-#include <KIcon>
-#include <KLineEdit>
-#include <KLocale>
+#include <QIcon>
+#include <QLineEdit>
+#include <KLocalizedString>
#include <KSeparator>
#include <QButtonGroup>
#include <QDir>
#include <QEvent>
-#include <QFormLayout>
#include <QHBoxLayout>
#include <QKeyEvent>
#include <QLabel>
@@ -38,13 +37,15 @@
#include <QTimer>
#include <QToolButton>
#include <QVBoxLayout>
+#include <QUrlQuery>
#include <config-baloo.h>
#ifdef HAVE_BALOO
- #include <baloo/query.h>
- #include <baloo/term.h>
- #include <baloo/indexerconfig.h>
+ #include <Baloo/Query>
+ #include <Baloo/Term>
+ #include <Baloo/IndexerConfig>
#endif
+#include <QFontDatabase>
DolphinSearchBox::DolphinSearchBox(QWidget* parent) :
QWidget(parent),
@@ -81,7 +82,7 @@ QString DolphinSearchBox::text() const
return m_searchInput->text();
}
-void DolphinSearchBox::setSearchPath(const KUrl& url)
+void DolphinSearchBox::setSearchPath(const QUrl& url)
{
m_searchPath = url;
@@ -93,7 +94,7 @@ void DolphinSearchBox::setSearchPath(const KUrl& url)
if (url.isLocalFile()) {
location = QLatin1String("/");
} else {
- location = url.protocol() + QLatin1String(" - ") + url.host();
+ location = url.scheme() + QLatin1String(" - ") + url.host();
}
}
@@ -113,14 +114,14 @@ void DolphinSearchBox::setSearchPath(const KUrl& url)
m_facetsWidget->setEnabled(hasFacetsSupport);
}
-KUrl DolphinSearchBox::searchPath() const
+QUrl DolphinSearchBox::searchPath() const
{
return m_searchPath;
}
-KUrl DolphinSearchBox::urlForSearching() const
+QUrl DolphinSearchBox::urlForSearching() const
{
- KUrl url;
+ QUrl url;
bool useBalooSearch = false;
#ifdef HAVE_BALOO
const Baloo::IndexerConfig searchInfo;
@@ -129,10 +130,12 @@ KUrl DolphinSearchBox::urlForSearching() const
if (useBalooSearch) {
url = balooUrlForSearching();
} else {
- url.setProtocol("filenamesearch");
- url.addQueryItem("search", m_searchInput->text());
+ url.setScheme("filenamesearch");
+
+ QUrlQuery query;
+ query.addQueryItem("search", m_searchInput->text());
if (m_contentButton->isChecked()) {
- url.addQueryItem("checkContent", "yes");
+ query.addQueryItem("checkContent", "yes");
}
QString encodedUrl;
@@ -144,21 +147,23 @@ KUrl DolphinSearchBox::urlForSearching() const
} else {
encodedUrl = m_searchPath.url();
}
- url.addQueryItem("url", encodedUrl);
+ query.addQueryItem("url", encodedUrl);
+
+ url.setQuery(query);
}
return url;
}
-void DolphinSearchBox::fromSearchUrl(const KUrl& url)
+void DolphinSearchBox::fromSearchUrl(const QUrl& url)
{
- if (url.protocol() == "baloosearch") {
+ if (url.scheme() == "baloosearch") {
fromBalooSearchUrl(url);
- } else if (url.protocol() == "filenamesearch") {
- const QMap<QString, QString>& queryItems = url.queryItems();
- setText(queryItems.value("search"));
- setSearchPath(queryItems.value("url"));
- m_contentButton->setChecked(queryItems.value("checkContent") == "yes");
+ } else if (url.scheme() == "filenamesearch") {
+ const QUrlQuery query(url);
+ setText(query.queryItemValue("search"));
+ setSearchPath(QUrl::fromUserInput(query.queryItemValue("url"), QString(), QUrl::AssumeLocalFile));
+ m_contentButton->setChecked(query.queryItemValue("checkContent") == "yes");
} else {
setText(QString());
setSearchPath(url);
@@ -253,6 +258,7 @@ void DolphinSearchBox::slotConfigurationChanged()
void DolphinSearchBox::slotSearchTextChanged(const QString& text)
{
+
if (text.isEmpty()) {
m_startSearchTimer->stop();
} else {
@@ -261,10 +267,10 @@ void DolphinSearchBox::slotSearchTextChanged(const QString& text)
emit searchTextChanged(text);
}
-void DolphinSearchBox::slotReturnPressed(const QString& text)
+void DolphinSearchBox::slotReturnPressed()
{
emitSearchRequest();
- emit returnPressed(text);
+ emit returnPressed();
}
void DolphinSearchBox::slotFacetsButtonToggled()
@@ -287,7 +293,7 @@ void DolphinSearchBox::initButton(QToolButton* button)
button->setAutoExclusive(true);
button->setAutoRaise(true);
button->setCheckable(true);
- connect(button, SIGNAL(clicked(bool)), this, SLOT(slotConfigurationChanged()));
+ connect(button, &QToolButton::clicked, this, &DolphinSearchBox::slotConfigurationChanged);
}
void DolphinSearchBox::loadSettings()
@@ -312,7 +318,7 @@ void DolphinSearchBox::saveSettings()
SearchSettings::setLocation(m_fromHereButton->isChecked() ? "FromHere" : "Everywhere");
SearchSettings::setWhat(m_fileNameButton->isChecked() ? "FileName" : "Content");
SearchSettings::setShowFacetsWidget(m_facetsToggleButton->isChecked());
- SearchSettings::self()->writeConfig();
+ SearchSettings::self()->save();
}
void DolphinSearchBox::init()
@@ -320,23 +326,23 @@ void DolphinSearchBox::init()
// Create close button
QToolButton* closeButton = new QToolButton(this);
closeButton->setAutoRaise(true);
- closeButton->setIcon(KIcon("dialog-close"));
+ closeButton->setIcon(QIcon::fromTheme("dialog-close"));
closeButton->setToolTip(i18nc("@info:tooltip", "Quit searching"));
- connect(closeButton, SIGNAL(clicked()), this, SLOT(emitCloseRequest()));
+ connect(closeButton, &QToolButton::clicked, this, &DolphinSearchBox::emitCloseRequest);
// Create search label
m_searchLabel = new QLabel(this);
// Create search box
- m_searchInput = new KLineEdit(this);
+ m_searchInput = new QLineEdit(this);
m_searchInput->installEventFilter(this);
- m_searchInput->setClearButtonShown(true);
- m_searchInput->setFont(KGlobalSettings::generalFont());
+ m_searchInput->setClearButtonEnabled(true);
+ m_searchInput->setFont(QFontDatabase::systemFont(QFontDatabase::GeneralFont));
+ connect(m_searchInput, &QLineEdit::returnPressed,
+ this, &DolphinSearchBox::slotReturnPressed);
+ connect(m_searchInput, &QLineEdit::textChanged,
+ this, &DolphinSearchBox::slotSearchTextChanged);
setFocusProxy(m_searchInput);
- connect(m_searchInput, SIGNAL(returnPressed(QString)),
- this, SLOT(slotReturnPressed(QString)));
- connect(m_searchInput, SIGNAL(textChanged(QString)),
- this, SLOT(slotSearchTextChanged(QString)));
// Apply layout for the search input
QHBoxLayout* searchInputLayout = new QHBoxLayout();
@@ -377,12 +383,12 @@ void DolphinSearchBox::init()
m_facetsToggleButton = new QToolButton(this);
m_facetsToggleButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
initButton(m_facetsToggleButton);
- connect(m_facetsToggleButton, SIGNAL(clicked()), this, SLOT(slotFacetsButtonToggled()));
+ connect(m_facetsToggleButton, &QToolButton::clicked, this, &DolphinSearchBox::slotFacetsButtonToggled);
m_facetsWidget = new DolphinFacetsWidget(this);
m_facetsWidget->installEventFilter(this);
m_facetsWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
- connect(m_facetsWidget, SIGNAL(facetChanged()), this, SLOT(slotFacetChanged()));
+ connect(m_facetsWidget, &DolphinFacetsWidget::facetChanged, this, &DolphinSearchBox::slotFacetChanged);
// Apply layout for the options
QHBoxLayout* optionsLayout = new QHBoxLayout();
@@ -422,12 +428,12 @@ void DolphinSearchBox::init()
m_startSearchTimer = new QTimer(this);
m_startSearchTimer->setSingleShot(true);
m_startSearchTimer->setInterval(1000);
- connect(m_startSearchTimer, SIGNAL(timeout()), this, SLOT(emitSearchRequest()));
+ connect(m_startSearchTimer, &QTimer::timeout, this, &DolphinSearchBox::emitSearchRequest);
updateFacetsToggleButton();
}
-KUrl DolphinSearchBox::balooUrlForSearching() const
+QUrl DolphinSearchBox::balooUrlForSearching() const
{
#ifdef HAVE_BALOO
const QString text = m_searchInput->text();
@@ -450,7 +456,7 @@ KUrl DolphinSearchBox::balooUrlForSearching() const
}
if (m_fromHereButton->isChecked()) {
- query.addCustomOption("includeFolder", m_searchPath.toLocalFile());
+ query.setIncludeFolder(m_searchPath.toLocalFile());
}
query.setTerm(term);
@@ -458,11 +464,11 @@ KUrl DolphinSearchBox::balooUrlForSearching() const
return query.toSearchUrl(i18nc("@title UDS_DISPLAY_NAME for a KIO directory listing. %1 is the query the user entered.",
"Query Results from '%1'", text));
#else
- return KUrl();
+ return QUrl();
#endif
}
-void DolphinSearchBox::fromBalooSearchUrl(const KUrl& url)
+void DolphinSearchBox::fromBalooSearchUrl(const QUrl& url)
{
#ifdef HAVE_BALOO
const Baloo::Query query = Baloo::Query::fromSearchUrl(url);
@@ -472,16 +478,14 @@ void DolphinSearchBox::fromBalooSearchUrl(const KUrl& url)
// while we adjust the search text and the facet widget.
blockSignals(true);
- const QVariantHash customOptions = query.customOptions();
- if (customOptions.contains("includeFolder")) {
- setSearchPath(customOptions.value("includeFolder").toString());
+ const QString customDir = query.includeFolder();
+ if (!customDir.isEmpty()) {
+ setSearchPath(QUrl::fromLocalFile(customDir));
} else {
setSearchPath(QDir::homePath());
}
- if (!query.searchString().isEmpty()) {
- setText(query.searchString());
- }
+ setText(query.searchString());
QStringList types = query.types();
types.removeOne("File"); // We are only interested in facet widget types
@@ -501,6 +505,8 @@ void DolphinSearchBox::fromBalooSearchUrl(const KUrl& url)
m_startSearchTimer->stop();
blockSignals(false);
+#else
+ Q_UNUSED(url);
#endif
}
@@ -508,8 +514,7 @@ void DolphinSearchBox::updateFacetsToggleButton()
{
const bool facetsIsVisible = SearchSettings::showFacetsWidget();
m_facetsToggleButton->setChecked(facetsIsVisible ? true : false);
- m_facetsToggleButton->setIcon(KIcon(facetsIsVisible ? "arrow-up-double" : "arrow-down-double"));
+ m_facetsToggleButton->setIcon(QIcon::fromTheme(facetsIsVisible ? "arrow-up-double" : "arrow-down-double"));
m_facetsToggleButton->setText(facetsIsVisible ? i18nc("action:button", "Fewer Options") : i18nc("action:button", "More Options"));
}
-#include "dolphinsearchbox.moc"
diff --git a/src/search/dolphinsearchbox.h b/src/search/dolphinsearchbox.h
index 53b12ffab..a80617476 100644
--- a/src/search/dolphinsearchbox.h
+++ b/src/search/dolphinsearchbox.h
@@ -20,12 +20,11 @@
#ifndef DOLPHINSEARCHBOX_H
#define DOLPHINSEARCHBOX_H
-#include <KUrl>
-#include <QList>
+#include <QUrl>
#include <QWidget>
class DolphinFacetsWidget;
-class KLineEdit;
+class QLineEdit;
class KSeparator;
class QToolButton;
class QScrollArea;
@@ -65,17 +64,17 @@ public:
* Sets the current path that is used as root for
* searching files, if "From Here" has been selected.
*/
- void setSearchPath(const KUrl& url);
- KUrl searchPath() const;
+ void setSearchPath(const QUrl& url);
+ QUrl searchPath() const;
/** @return URL that will start the searching of files. */
- KUrl urlForSearching() const;
+ QUrl urlForSearching() const;
/**
* Extracts information from the given search \a url to
* initialize the search box properly.
*/
- void fromSearchUrl(const KUrl& url);
+ void fromSearchUrl(const QUrl& url);
/**
* Selects the whole text of the search box.
@@ -99,10 +98,10 @@ public:
bool isActive() const;
protected:
- virtual bool event(QEvent* event);
- virtual void showEvent(QShowEvent* event);
- virtual void keyReleaseEvent(QKeyEvent* event);
- virtual bool eventFilter(QObject* obj, QEvent* event);
+ virtual bool event(QEvent* event) Q_DECL_OVERRIDE;
+ virtual void showEvent(QShowEvent* event) Q_DECL_OVERRIDE;
+ virtual void keyReleaseEvent(QKeyEvent* event) Q_DECL_OVERRIDE;
+ virtual bool eventFilter(QObject* obj, QEvent* event) Q_DECL_OVERRIDE;
signals:
/**
@@ -116,7 +115,7 @@ signals:
*/
void searchTextChanged(const QString& text);
- void returnPressed(const QString& text);
+ void returnPressed();
/**
* Emitted as soon as the search box should get closed.
@@ -135,7 +134,7 @@ private slots:
void emitCloseRequest();
void slotConfigurationChanged();
void slotSearchTextChanged(const QString& text);
- void slotReturnPressed(const QString& text);
+ void slotReturnPressed();
void slotFacetsButtonToggled();
void slotFacetChanged();
@@ -148,15 +147,16 @@ private:
/**
* @return URL that represents the Baloo query for starting the search.
*/
- KUrl balooUrlForSearching() const;
+ QUrl balooUrlForSearching() const;
/**
* Extracts information from the given Baloo search \a url to
* initialize the search box properly.
*/
- void fromBalooSearchUrl(const KUrl& url);
+ void fromBalooSearchUrl(const QUrl& url);
void updateFacetsToggleButton();
+
private:
bool m_startedSearching;
bool m_active;
@@ -164,7 +164,7 @@ private:
QVBoxLayout* m_topLayout;
QLabel* m_searchLabel;
- KLineEdit* m_searchInput;
+ QLineEdit* m_searchInput;
QScrollArea* m_optionsScrollArea;
QToolButton* m_fileNameButton;
QToolButton* m_contentButton;
@@ -174,7 +174,7 @@ private:
QToolButton* m_facetsToggleButton;
DolphinFacetsWidget* m_facetsWidget;
- KUrl m_searchPath;
+ QUrl m_searchPath;
QTimer* m_startSearchTimer;
};
diff --git a/src/search/filenamesearch.protocol b/src/search/filenamesearch.protocol
deleted file mode 100644
index 06aec0e6b..000000000
--- a/src/search/filenamesearch.protocol
+++ /dev/null
@@ -1,17 +0,0 @@
-[Protocol]
-exec=kio_filenamesearch
-protocol=filenamesearch
-input=none
-output=filesystem
-reading=true
-writing=false
-deleting=true
-linking=false
-makedir=false
-moving=false
-listing=Name,Type,Size,Date,AccessDate,Access,Owner,Group,Link
-source=false
-Icon=edit-find
-Class=:local
-determineMimetypeFromExtension=false
-maxInstances=10
diff --git a/src/search/filenamesearchprotocol.cpp b/src/search/filenamesearchprotocol.cpp
deleted file mode 100644
index 38dd26b23..000000000
--- a/src/search/filenamesearchprotocol.cpp
+++ /dev/null
@@ -1,191 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2010 by Peter Penz <[email protected]> *
- * *
- * 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 "filenamesearchprotocol.h"
-
-#include <KComponentData>
-#include <KDirLister>
-#include <KFileItem>
-#include <KIO/NetAccess>
-#include <KIO/Job>
-#include <KUrl>
-#include <ktemporaryfile.h>
-
-#include <QCoreApplication>
-#include <QEventLoop>
-#include <QRegExp>
-
-FileNameSearchProtocol::FileNameSearchProtocol( const QByteArray &pool, const QByteArray &app ) :
- SlaveBase("search", pool, app),
- m_checkContent(false),
- m_regExp(0),
- m_iteratedDirs()
-{
-}
-
-FileNameSearchProtocol::~FileNameSearchProtocol()
-{
- cleanup();
-}
-
-void FileNameSearchProtocol::listDir(const KUrl& url)
-{
- cleanup();
-
- const QString search = url.queryItem("search");
- if (!search.isEmpty()) {
- m_regExp = new QRegExp(search, Qt::CaseInsensitive, QRegExp::Wildcard);
- }
-
- m_checkContent = false;
- const QString checkContent = url.queryItem("checkContent");
- if (checkContent == QLatin1String("yes")) {
- m_checkContent = true;
- }
-
- const QString urlString = url.queryItem("url");
- searchDirectory(KUrl(urlString));
-
- cleanup();
- finished();
-}
-
-void FileNameSearchProtocol::searchDirectory(const KUrl& directory)
-{
- if (directory.path() == QLatin1String("/proc")) {
- // Don't try to iterate the /proc directory of Linux
- return;
- }
-
- // Get all items of the directory
- KDirLister *dirLister = new KDirLister();
- dirLister->setDelayedMimeTypes(false);
- dirLister->setAutoErrorHandlingEnabled(false, 0);
- dirLister->openUrl(directory);
-
- QEventLoop eventLoop;
- QObject::connect(dirLister, SIGNAL(canceled()), &eventLoop, SLOT(quit()));
- QObject::connect(dirLister, SIGNAL(completed()), &eventLoop, SLOT(quit()));
- eventLoop.exec();
-
- // Visualize all items that match the search pattern
- QList<KUrl> pendingDirs;
- const KFileItemList items = dirLister->items();
- foreach (const KFileItem& item, items) {
- bool addItem = false;
- if (!m_regExp || item.name().contains(*m_regExp)) {
- addItem = true;
- } else if (m_checkContent && item.determineMimeType()->is(QLatin1String("text/plain"))) {
- addItem = contentContainsPattern(item.url());
- }
-
- if (addItem) {
- KIO::UDSEntry entry = item.entry();
- entry.insert(KIO::UDSEntry::UDS_URL, item.url().url() );
- listEntry(entry,false);
- }
-
- if (item.isDir()) {
- if (item.isLink()) {
- // Assure that no endless searching is done in directories that
- // have already been iterated.
- const KUrl linkDest(item.url(), item.linkDest());
- if (!m_iteratedDirs.contains(linkDest.path())) {
- pendingDirs.append(linkDest);
- }
- } else {
- pendingDirs.append(item.url());
- }
- }
- }
- listEntry(KIO::UDSEntry(), true);
-
- m_iteratedDirs.insert(directory.path());
-
- delete dirLister;
- dirLister = 0;
-
- // Recursively iterate all sub directories
- foreach (const KUrl& pendingDir, pendingDirs) {
- searchDirectory(pendingDir);
- }
-}
-
-bool FileNameSearchProtocol::contentContainsPattern(const KUrl& fileName) const
-{
- Q_ASSERT(m_regExp);
-
- QString path;
- KTemporaryFile tempFile;
-
- if (fileName.isLocalFile()) {
- path = fileName.path();
- } else if (tempFile.open()) {
- KIO::Job* getJob = KIO::file_copy(fileName,
- tempFile.fileName(),
- -1,
- KIO::Overwrite | KIO::HideProgressInfo);
- if (!KIO::NetAccess::synchronousRun(getJob, 0)) {
- // The non-local file could not be downloaded
- return false;
- }
- path = tempFile.fileName();
- } else {
- // No temporary file could be created for downloading non-local files
- return false;
- }
-
- QFile file(path);
- if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
- return false;
- }
-
- QTextStream in(&file);
- while (!in.atEnd()) {
- const QString line = in.readLine();
- if (line.contains(*m_regExp)) {
- return true;
- }
- }
-
- return false;
-}
-
-void FileNameSearchProtocol::cleanup()
-{
- delete m_regExp;
- m_regExp = 0;
- m_iteratedDirs.clear();
-}
-
-extern "C" int KDE_EXPORT kdemain( int argc, char **argv )
-{
- KComponentData instance("kio_search");
- QCoreApplication app(argc, argv);
-
- if (argc != 4) {
- fprintf(stderr, "Usage: kio_filenamesearch protocol domain-socket1 domain-socket2\n");
- exit(-1);
- }
-
- FileNameSearchProtocol slave(argv[2], argv[3]);
- slave.dispatchLoop();
-
- return 0;
-}
diff --git a/src/settings/additionalinfodialog.cpp b/src/settings/additionalinfodialog.cpp
index 0de639540..783f5685e 100644
--- a/src/settings/additionalinfodialog.cpp
+++ b/src/settings/additionalinfodialog.cpp
@@ -21,33 +21,39 @@
#include <config-baloo.h>
-#include <KLocale>
+#include <KSharedConfig>
+#include <KLocalizedString>
#include "kitemviews/kfileitemmodel.h"
+#include <KConfigGroup>
+#include <KWindowConfig>
+
#include <QCheckBox>
#include <QLabel>
#include <QVBoxLayout>
+#include <QDialogButtonBox>
+#include <QPushButton>
#ifdef HAVE_BALOO
- #include <baloo/indexerconfig.h>
+ #include <Baloo/IndexerConfig>
#endif
AdditionalInfoDialog::AdditionalInfoDialog(QWidget* parent,
const QList<QByteArray>& visibleRoles) :
- KDialog(parent),
+ QDialog(parent),
m_visibleRoles(visibleRoles),
m_listWidget(0)
{
- setCaption(i18nc("@title:window", "Additional Information"));
- setButtons(Ok | Cancel);
- setDefaultButton(Ok);
+ setWindowTitle(i18nc("@title:window", "Additional Information"));
+ setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
- QWidget* mainWidget = new QWidget(this);
- mainWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
+ auto layout = new QVBoxLayout(this);
+ setLayout(layout);
// Add header
- QLabel* header = new QLabel(mainWidget);
+ auto header = new QLabel(this);
header->setText(i18nc("@label", "Select which additional information should be shown:"));
header->setWordWrap(true);
+ layout->addWidget(header);
// Add checkboxes
bool indexingEnabled = false;
@@ -56,7 +62,7 @@ AdditionalInfoDialog::AdditionalInfoDialog(QWidget* parent,
indexingEnabled = config.fileIndexingEnabled();
#endif
- m_listWidget = new QListWidget(mainWidget);
+ m_listWidget = new QListWidget(this);
m_listWidget->setSelectionMode(QAbstractItemView::NoSelection);
const QList<KFileItemModel::RoleInfo> rolesInfo = KFileItemModel::rolesInformation();
foreach (const KFileItemModel::RoleInfo& info, rolesInfo) {
@@ -71,23 +77,25 @@ AdditionalInfoDialog::AdditionalInfoDialog(QWidget* parent,
item->setFlags(item->flags() & ~Qt::ItemIsEnabled);
}
}
-
- QVBoxLayout* layout = new QVBoxLayout(mainWidget);
- layout->addWidget(header);
layout->addWidget(m_listWidget);
- setMainWidget(mainWidget);
+ auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
+ connect(buttonBox, &QDialogButtonBox::accepted, this, &AdditionalInfoDialog::accept);
+ connect(buttonBox, &QDialogButtonBox::rejected, this, &AdditionalInfoDialog::reject);
+ layout->addWidget(buttonBox);
- const KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"), "AdditionalInfoDialog");
- restoreDialogSize(dialogConfig);
+ auto okButton = buttonBox->button(QDialogButtonBox::Ok);
+ okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
+ okButton->setDefault(true);
- connect(this, SIGNAL(okClicked()), this, SLOT(slotOk()));
+ const KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"), "AdditionalInfoDialog");
+ KWindowConfig::restoreWindowSize(windowHandle(), dialogConfig);
}
AdditionalInfoDialog::~AdditionalInfoDialog()
{
KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"), "AdditionalInfoDialog");
- saveDialogSize(dialogConfig, KConfigBase::Persistent);
+ KWindowConfig::saveWindowSize(windowHandle(), dialogConfig);
}
QList<QByteArray> AdditionalInfoDialog::visibleRoles() const
@@ -95,7 +103,7 @@ QList<QByteArray> AdditionalInfoDialog::visibleRoles() const
return m_visibleRoles;
}
-void AdditionalInfoDialog::slotOk()
+void AdditionalInfoDialog::accept()
{
m_visibleRoles.clear();
@@ -108,6 +116,6 @@ void AdditionalInfoDialog::slotOk()
}
++index;
}
-}
-#include "additionalinfodialog.moc"
+ QDialog::accept();
+}
diff --git a/src/settings/additionalinfodialog.h b/src/settings/additionalinfodialog.h
index dd51768e5..fd72a7ce1 100644
--- a/src/settings/additionalinfodialog.h
+++ b/src/settings/additionalinfodialog.h
@@ -20,16 +20,15 @@
#ifndef ADDITIONALINFODIALOG_H
#define ADDITIONALINFODIALOG_H
-#include <KDialog>
+#include <QDialog>
#include <QList>
#include <QListWidget>
-class QCheckBox;
/**
* @brief Dialog for changing the additional information shown in the view.
*/
-class AdditionalInfoDialog : public KDialog
+class AdditionalInfoDialog : public QDialog
{
Q_OBJECT
@@ -38,8 +37,8 @@ public:
virtual ~AdditionalInfoDialog();
QList<QByteArray> visibleRoles() const;
-private slots:
- void slotOk();
+public slots:
+ void accept() Q_DECL_OVERRIDE;
private:
QList<QByteArray> m_visibleRoles;
diff --git a/src/settings/applyviewpropsjob.cpp b/src/settings/applyviewpropsjob.cpp
index 4bc77caee..591966759 100644
--- a/src/settings/applyviewpropsjob.cpp
+++ b/src/settings/applyviewpropsjob.cpp
@@ -23,7 +23,7 @@
#include "applyviewpropsjob.h"
#include <views/viewproperties.h>
-ApplyViewPropsJob::ApplyViewPropsJob(const KUrl& dir,
+ApplyViewPropsJob::ApplyViewPropsJob(const QUrl& dir,
const ViewProperties& viewProps) :
KIO::Job(),
m_viewProps(0),
@@ -38,8 +38,8 @@ ApplyViewPropsJob::ApplyViewPropsJob(const KUrl& dir,
m_viewProps->setSortOrder(viewProps.sortOrder());
KIO::ListJob* listJob = KIO::listRecursive(dir, KIO::HideProgressInfo);
- connect(listJob, SIGNAL(entries(KIO::Job*,KIO::UDSEntryList)),
- SLOT(slotEntries(KIO::Job*,KIO::UDSEntryList)));
+ connect(listJob, &KIO::ListJob::entries,
+ this, &ApplyViewPropsJob::slotEntries);
addSubjob(listJob);
}
@@ -56,8 +56,9 @@ void ApplyViewPropsJob::slotEntries(KIO::Job*, const KIO::UDSEntryList& list)
if (name != QLatin1String(".") && name != QLatin1String("..") && entry.isDir()) {
++m_progress;
- KUrl url(m_dir);
- url.addPath(name);
+ QUrl url(m_dir);
+ url = url.adjusted(QUrl::StripTrailingSlash);
+ url.setPath(url.path() + '/' + name);
Q_ASSERT(m_viewProps);
@@ -76,4 +77,3 @@ void ApplyViewPropsJob::slotResult(KJob* job)
emitResult();
}
-#include "applyviewpropsjob.moc"
diff --git a/src/settings/applyviewpropsjob.h b/src/settings/applyviewpropsjob.h
index 68fdcc46b..ea9688718 100644
--- a/src/settings/applyviewpropsjob.h
+++ b/src/settings/applyviewpropsjob.h
@@ -24,8 +24,7 @@
#define APPLYVIEWPROPSJOB_H
#include <KIO/Job>
-#include <KFileItem>
-#include <KUrl>
+#include <QUrl>
class ViewProperties;
@@ -60,19 +59,19 @@ public:
* @param viewProps View properties for the directory \a dir including its
* sub directories.
*/
- ApplyViewPropsJob(const KUrl& dir, const ViewProperties& viewProps);
+ ApplyViewPropsJob(const QUrl& dir, const ViewProperties& viewProps);
virtual ~ApplyViewPropsJob();
int progress() const;
private slots:
- virtual void slotResult(KJob* job);
+ virtual void slotResult(KJob* job) Q_DECL_OVERRIDE;
void slotEntries(KIO::Job*, const KIO::UDSEntryList&);
private:
ViewProperties* m_viewProps;
int m_currentItem;
int m_progress;
- KUrl m_dir;
+ QUrl m_dir;
};
inline int ApplyViewPropsJob::progress() const
diff --git a/src/settings/dolphin_compactmodesettings.kcfg b/src/settings/dolphin_compactmodesettings.kcfg
index b9000c8e2..93f9947ab 100644
--- a/src/settings/dolphin_compactmodesettings.kcfg
+++ b/src/settings/dolphin_compactmodesettings.kcfg
@@ -4,7 +4,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd">
- <include>kglobalsettings.h</include>
+ <include>QFontDatabase</include>
<include>kiconloader.h</include>
<kcfgfile name="dolphinrc"/>
<group name="CompactMode">
@@ -14,11 +14,11 @@
</entry>
<entry name="FontFamily" type="String">
<label>Font family</label>
- <default code="true">KGlobalSettings::generalFont().family()</default>
+ <default code="true">QFontDatabase::systemFont(QFontDatabase::GeneralFont).family()</default>
</entry>
<entry name="FontSize" type="Double">
<label>Font size</label>
- <default code="true">KGlobalSettings::generalFont().pointSizeF()</default>
+ <default code="true">QFontDatabase::systemFont(QFontDatabase::GeneralFont).pointSizeF()</default>
</entry>
<entry name="ItalicFont" type="Bool">
<label>Italic</label>
diff --git a/src/settings/dolphin_detailsmodesettings.kcfg b/src/settings/dolphin_detailsmodesettings.kcfg
index 64e99898a..e9a8fb28d 100644
--- a/src/settings/dolphin_detailsmodesettings.kcfg
+++ b/src/settings/dolphin_detailsmodesettings.kcfg
@@ -5,12 +5,12 @@
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd">
<include>kiconloader.h</include>
- <include>kglobalsettings.h</include>
+ <include>QFontDatabase</include>
<kcfgfile name="dolphinrc"/>
<group name="DetailsMode">
<entry name="FontFamily" type="String">
<label>Font family</label>
- <default code="true">KGlobalSettings::generalFont().family()</default>
+ <default code="true">QFontDatabase::systemFont(QFontDatabase::GeneralFont).family()</default>
</entry>
<entry name="UseSystemFont" type="Bool">
<label>Use system font</label>
@@ -18,7 +18,7 @@
</entry>
<entry name="FontSize" type="Double">
<label>Font size</label>
- <default code="true">KGlobalSettings::generalFont().pointSizeF()</default>
+ <default code="true">QFontDatabase::systemFont(QFontDatabase::GeneralFont).pointSizeF()</default>
</entry>
<entry name="ItalicFont" type="Bool">
<label>Italic</label>
diff --git a/src/settings/dolphin_generalsettings.kcfg b/src/settings/dolphin_generalsettings.kcfg
index 849a9c75c..9ff14d1f7 100644
--- a/src/settings/dolphin_generalsettings.kcfg
+++ b/src/settings/dolphin_generalsettings.kcfg
@@ -5,9 +5,10 @@
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd">
<include>QDir</include>
- <include>KUrl</include>
- <include>kglobalsettings.h</include>
+ <include>QUrl</include>
+ <include>KCompletion</include>
<kcfgfile name="dolphinrc"/>
+ <signal name="naturalSortingChanged" />
<group name="General">
<entry name="EditableUrl" type="Bool">
<label>Should the URL be editable for the user</label>
@@ -15,7 +16,7 @@
</entry>
<entry name="UrlCompletionMode" type="Enum">
<label>Text completion mode of the URL Navigator</label>
- <default code="true">KGlobalSettings::completionMode()</default>
+ <default>KCompletion::CompletionPopup</default>
</entry>
<entry name="ShowFullPath" type="Bool">
<label>Should the full path be shown inside the location bar</label>
@@ -31,7 +32,7 @@
</entry>
<entry name="HomeUrl" type="String">
<label>Home URL</label>
- <default code="true">KUrl(QDir::homePath()).prettyUrl()</default>
+ <default code="true">QUrl::fromLocalFile(QDir::homePath()).toDisplayString(QUrl::PreferLocalFile)</default>
</entry>
<entry name="SplitView" type="Bool">
<label>Split the view into two panes</label>
@@ -82,7 +83,7 @@
</entry>
<entry name="ShowSpaceInfo" type="Bool">
<label>Show the space information in the statusbar</label>
- <default>false</default>
+ <default>true</default>
</entry>
<entry name="LockPanels" type="Bool">
<label>Lock the layout of the panels</label>
@@ -92,5 +93,10 @@
<label>Enlarge Small Previews</label>
<default>true</default>
</entry>
+ <entry name="NaturalSorting" type="Bool">
+ <label>Natural sorting of items</label>
+ <default>true</default>
+ <emit signal="naturalSortingChanged" />
+ </entry>
</group>
</kcfg>
diff --git a/src/settings/dolphin_iconsmodesettings.kcfg b/src/settings/dolphin_iconsmodesettings.kcfg
index 52cd9a28c..9b286d139 100644
--- a/src/settings/dolphin_iconsmodesettings.kcfg
+++ b/src/settings/dolphin_iconsmodesettings.kcfg
@@ -4,7 +4,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd">
- <include>kglobalsettings.h</include>
+ <include>QFontDatabase</include>
<include>kiconloader.h</include>
<kcfgfile name="dolphinrc"/>
<group name="IconsMode">
@@ -14,11 +14,11 @@
</entry>
<entry name="FontFamily" type="String">
<label>Font family</label>
- <default code="true">KGlobalSettings::generalFont().family()</default>
+ <default code="true">QFontDatabase::systemFont(QFontDatabase::GeneralFont).family()</default>
</entry>
<entry name="FontSize" type="Double">
<label>Font size</label>
- <default code="true">KGlobalSettings::generalFont().pointSizeF()</default>
+ <default code="true">QFontDatabase::systemFont(QFontDatabase::GeneralFont).pointSizeF()</default>
</entry>
<entry name="ItalicFont" type="Bool">
<label>Italic</label>
diff --git a/src/settings/dolphinsettingsdialog.cpp b/src/settings/dolphinsettingsdialog.cpp
index 609e2ab92..820fc0e68 100644
--- a/src/settings/dolphinsettingsdialog.cpp
+++ b/src/settings/dolphinsettingsdialog.cpp
@@ -20,7 +20,6 @@
#include "dolphinsettingsdialog.h"
-#include <dolphinapplication.h>
#include <dolphinmainwindow.h>
#include "dolphin_generalsettings.h"
#include "general/generalsettingspage.h"
@@ -30,11 +29,14 @@
#include "viewmodes/viewsettingspage.h"
#include "trash/trashsettingspage.h"
-#include <KLocale>
-#include <KMessageBox>
-#include <KIcon>
+#include <KWindowConfig>
+#include <KLocalizedString>
+#include <QIcon>
-DolphinSettingsDialog::DolphinSettingsDialog(const KUrl& url, QWidget* parent) :
+#include <QPushButton>
+#include <QDialogButtonBox>
+
+DolphinSettingsDialog::DolphinSettingsDialog(const QUrl& url, QWidget* parent) :
KPageDialog(parent),
m_pages()
@@ -43,55 +45,58 @@ DolphinSettingsDialog::DolphinSettingsDialog(const KUrl& url, QWidget* parent) :
setMinimumSize(QSize(512, minSize.height()));
setFaceType(List);
- setCaption(i18nc("@title:window", "Dolphin Preferences"));
- setButtons(Ok | Apply | Cancel | Default);
- enableButtonApply(false);
- setDefaultButton(Ok);
+ setWindowTitle(i18nc("@title:window", "Dolphin Preferences"));
+ QDialogButtonBox* box = new QDialogButtonBox(QDialogButtonBox::Ok
+ | QDialogButtonBox::Apply | QDialogButtonBox::Cancel | QDialogButtonBox::RestoreDefaults);
+ box->button(QDialogButtonBox::Apply)->setEnabled(false);
+ box->button(QDialogButtonBox::Ok)->setDefault(true);
+ setButtonBox(box);
+
+ connect(box->button(QDialogButtonBox::Ok), &QAbstractButton::clicked, this, &DolphinSettingsDialog::applySettings);
+ connect(box->button(QDialogButtonBox::Apply), &QAbstractButton::clicked, this, &DolphinSettingsDialog::applySettings);
+ connect(box->button(QDialogButtonBox::RestoreDefaults), &QAbstractButton::clicked, this, &DolphinSettingsDialog::restoreDefaults);
// Startup
StartupSettingsPage* startupSettingsPage = new StartupSettingsPage(url, this);
KPageWidgetItem* startupSettingsFrame = addPage(startupSettingsPage,
i18nc("@title:group", "Startup"));
- startupSettingsFrame->setIcon(KIcon("go-home"));
- connect(startupSettingsPage, SIGNAL(changed()), this, SLOT(enableApply()));
+ startupSettingsFrame->setIcon(QIcon::fromTheme("go-home"));
+ connect(startupSettingsPage, &StartupSettingsPage::changed, this, &DolphinSettingsDialog::enableApply);
// View Modes
ViewSettingsPage* viewSettingsPage = new ViewSettingsPage(this);
KPageWidgetItem* viewSettingsFrame = addPage(viewSettingsPage,
i18nc("@title:group", "View Modes"));
- viewSettingsFrame->setIcon(KIcon("view-choose"));
- connect(viewSettingsPage, SIGNAL(changed()), this, SLOT(enableApply()));
+ viewSettingsFrame->setIcon(QIcon::fromTheme("view-choose"));
+ connect(viewSettingsPage, &ViewSettingsPage::changed, this, &DolphinSettingsDialog::enableApply);
// Navigation
NavigationSettingsPage* navigationSettingsPage = new NavigationSettingsPage(this);
KPageWidgetItem* navigationSettingsFrame = addPage(navigationSettingsPage,
i18nc("@title:group", "Navigation"));
- navigationSettingsFrame->setIcon(KIcon("input-mouse"));
- connect(navigationSettingsPage, SIGNAL(changed()), this, SLOT(enableApply()));
+ navigationSettingsFrame->setIcon(QIcon::fromTheme("input-mouse"));
+ connect(navigationSettingsPage, &NavigationSettingsPage::changed, this, &DolphinSettingsDialog::enableApply);
// Services
ServicesSettingsPage* servicesSettingsPage = new ServicesSettingsPage(this);
KPageWidgetItem* servicesSettingsFrame = addPage(servicesSettingsPage,
i18nc("@title:group", "Services"));
- servicesSettingsFrame->setIcon(KIcon("services"));
- connect(servicesSettingsPage, SIGNAL(changed()), this, SLOT(enableApply()));
+ servicesSettingsFrame->setIcon(QIcon::fromTheme("services"));
+ connect(servicesSettingsPage, &ServicesSettingsPage::changed, this, &DolphinSettingsDialog::enableApply);
// Trash
TrashSettingsPage* trashSettingsPage = new TrashSettingsPage(this);
KPageWidgetItem* trashSettingsFrame = addPage(trashSettingsPage,
i18nc("@title:group", "Trash"));
- trashSettingsFrame->setIcon(KIcon("user-trash"));
- connect(trashSettingsPage, SIGNAL(changed()), this, SLOT(enableApply()));
+ trashSettingsFrame->setIcon(QIcon::fromTheme("user-trash"));
+ connect(trashSettingsPage, &TrashSettingsPage::changed, this, &DolphinSettingsDialog::enableApply);
// General
GeneralSettingsPage* generalSettingsPage = new GeneralSettingsPage(url, this);
KPageWidgetItem* generalSettingsFrame = addPage(generalSettingsPage,
i18nc("@title:group General settings", "General"));
- generalSettingsFrame->setIcon(KIcon("system-run"));
- connect(generalSettingsPage, SIGNAL(changed()), this, SLOT(enableApply()));
-
- const KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"), "SettingsDialog");
- restoreDialogSize(dialogConfig);
+ generalSettingsFrame->setIcon(QIcon::fromTheme("system-run"));
+ connect(generalSettingsPage, &GeneralSettingsPage::changed, this, &DolphinSettingsDialog::enableApply);
m_pages.append(startupSettingsPage);
m_pages.append(viewSettingsPage);
@@ -99,28 +104,20 @@ DolphinSettingsDialog::DolphinSettingsDialog(const KUrl& url, QWidget* parent) :
m_pages.append(servicesSettingsPage);
m_pages.append(trashSettingsPage);
m_pages.append(generalSettingsPage);
+
+ const KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"), "SettingsDialog");
+ KWindowConfig::restoreWindowSize(windowHandle(), dialogConfig);
}
DolphinSettingsDialog::~DolphinSettingsDialog()
{
KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"), "SettingsDialog");
- saveDialogSize(dialogConfig);
-}
-
-void DolphinSettingsDialog::slotButtonClicked(int button)
-{
- if ((button == Ok) || (button == Apply)) {
- applySettings();
- } else if (button == Default) {
- restoreDefaults();
- }
-
- KPageDialog::slotButtonClicked(button);
+ KWindowConfig::saveWindowSize(windowHandle(), dialogConfig);
}
void DolphinSettingsDialog::enableApply()
{
- enableButtonApply(true);
+ buttonBox()->button(QDialogButtonBox::Apply)->setEnabled(true);
}
void DolphinSettingsDialog::applySettings()
@@ -136,10 +133,9 @@ void DolphinSettingsDialog::applySettings()
// Reset the modified startup settings hint. The changed startup settings
// have been applied already due to emitting settingsChanged().
settings->setModifiedStartupSettings(false);
- settings->writeConfig();
+ settings->save();
}
-
- enableButtonApply(false);
+ buttonBox()->button(QDialogButtonBox::Apply)->setEnabled(false);
}
void DolphinSettingsDialog::restoreDefaults()
@@ -149,4 +145,3 @@ void DolphinSettingsDialog::restoreDefaults()
}
}
-#include "dolphinsettingsdialog.moc"
diff --git a/src/settings/dolphinsettingsdialog.h b/src/settings/dolphinsettingsdialog.h
index 2de195017..93f714799 100644
--- a/src/settings/dolphinsettingsdialog.h
+++ b/src/settings/dolphinsettingsdialog.h
@@ -23,7 +23,7 @@
#include <kpagedialog.h>
-class KUrl;
+class QUrl;
class SettingsPageBase;
/**
@@ -36,21 +36,15 @@ class DolphinSettingsDialog : public KPageDialog
Q_OBJECT
public:
- explicit DolphinSettingsDialog(const KUrl& url, QWidget* parent = 0);
+ explicit DolphinSettingsDialog(const QUrl& url, QWidget* parent = 0);
virtual ~DolphinSettingsDialog();
signals:
void settingsChanged();
-protected slots:
- /** @see KDialog::slotButtonClicked() */
- virtual void slotButtonClicked(int button);
-
private slots:
/** Enables the Apply button. */
void enableApply();
-
-private:
void applySettings();
void restoreDefaults();
diff --git a/src/settings/general/behaviorsettingspage.cpp b/src/settings/general/behaviorsettingspage.cpp
index cbbde1d7c..093a1f4e1 100644
--- a/src/settings/general/behaviorsettingspage.cpp
+++ b/src/settings/general/behaviorsettingspage.cpp
@@ -22,20 +22,16 @@
#include "dolphin_generalsettings.h"
-#include <KComboBox>
-#include <KDialog>
-#include <KLocale>
+#include <KLocalizedString>
#include <QCheckBox>
#include <QGroupBox>
-#include <QHBoxLayout>
-#include <QLabel>
#include <QRadioButton>
#include <QVBoxLayout>
#include <views/viewproperties.h>
-BehaviorSettingsPage::BehaviorSettingsPage(const KUrl& url, QWidget* parent) :
+BehaviorSettingsPage::BehaviorSettingsPage(const QUrl& url, QWidget* parent) :
SettingsPageBase(parent),
m_url(url),
m_localViewProps(0),
@@ -79,12 +75,12 @@ BehaviorSettingsPage::BehaviorSettingsPage(const KUrl& url, QWidget* parent) :
loadSettings();
- connect(m_localViewProps, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
- connect(m_globalViewProps, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
- connect(m_showToolTips, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
- connect(m_showSelectionToggle, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
- connect(m_naturalSorting, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
- connect(m_renameInline, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
+ connect(m_localViewProps, &QRadioButton::toggled, this, &BehaviorSettingsPage::changed);
+ connect(m_globalViewProps, &QRadioButton::toggled, this, &BehaviorSettingsPage::changed);
+ connect(m_showToolTips, &QCheckBox::toggled, this, &BehaviorSettingsPage::changed);
+ connect(m_showSelectionToggle, &QCheckBox::toggled, this, &BehaviorSettingsPage::changed);
+ connect(m_naturalSorting, &QCheckBox::toggled, this, &BehaviorSettingsPage::changed);
+ connect(m_renameInline, &QCheckBox::toggled, this, &BehaviorSettingsPage::changed);
}
BehaviorSettingsPage::~BehaviorSettingsPage()
@@ -101,8 +97,9 @@ void BehaviorSettingsPage::applySettings()
settings->setShowToolTips(m_showToolTips->isChecked());
settings->setShowSelectionToggle(m_showSelectionToggle->isChecked());
+ settings->setNaturalSorting(m_naturalSorting->isChecked());
settings->setRenameInline(m_renameInline->isChecked());
- settings->writeConfig();
+ settings->save();
if (useGlobalViewProps) {
// Remember the global view properties by applying the current view properties.
@@ -112,13 +109,6 @@ void BehaviorSettingsPage::applySettings()
ViewProperties globalProps(m_url);
globalProps.setDirProperties(props);
}
-
- const bool naturalSorting = m_naturalSorting->isChecked();
- if (KGlobalSettings::naturalSorting() != naturalSorting) {
- KConfigGroup group(KGlobal::config(), "KDE");
- group.writeEntry("NaturalSorting", naturalSorting, KConfig::Persistent | KConfig::Global);
- KGlobalSettings::emitChange(KGlobalSettings::NaturalSortingChanged);
- }
}
void BehaviorSettingsPage::restoreDefaults()
@@ -137,8 +127,7 @@ void BehaviorSettingsPage::loadSettings()
m_showToolTips->setChecked(GeneralSettings::showToolTips());
m_showSelectionToggle->setChecked(GeneralSettings::showSelectionToggle());
- m_naturalSorting->setChecked(KGlobalSettings::naturalSorting());
+ m_naturalSorting->setChecked(GeneralSettings::naturalSorting());
m_renameInline->setChecked(GeneralSettings::renameInline());
}
-#include "behaviorsettingspage.moc"
diff --git a/src/settings/general/behaviorsettingspage.h b/src/settings/general/behaviorsettingspage.h
index 7a9c2f027..6e491696c 100644
--- a/src/settings/general/behaviorsettingspage.h
+++ b/src/settings/general/behaviorsettingspage.h
@@ -21,9 +21,8 @@
#define BEHAVIORSETTINGSPAGE_H
#include <settings/settingspagebase.h>
-#include <KUrl>
+#include <QUrl>
-class KComboBox;
class QCheckBox;
class QLabel;
class QRadioButton;
@@ -36,20 +35,20 @@ class BehaviorSettingsPage : public SettingsPageBase
Q_OBJECT
public:
- BehaviorSettingsPage(const KUrl& url, QWidget* parent);
+ BehaviorSettingsPage(const QUrl &url, QWidget* parent);
virtual ~BehaviorSettingsPage();
/** @see SettingsPageBase::applySettings() */
- virtual void applySettings();
+ virtual void applySettings() Q_DECL_OVERRIDE;
/** @see SettingsPageBase::restoreDefaults() */
- virtual void restoreDefaults();
+ virtual void restoreDefaults() Q_DECL_OVERRIDE;
private:
void loadSettings();
private:
- KUrl m_url;
+ QUrl m_url;
QRadioButton* m_localViewProps;
QRadioButton* m_globalViewProps;
diff --git a/src/settings/general/configurepreviewplugindialog.cpp b/src/settings/general/configurepreviewplugindialog.cpp
index 3ca08dfd0..15cd92667 100644
--- a/src/settings/general/configurepreviewplugindialog.cpp
+++ b/src/settings/general/configurepreviewplugindialog.cpp
@@ -19,63 +19,66 @@
#include "configurepreviewplugindialog.h"
-#include <KLibrary>
-#include <KLocale>
-#include <KIO/NetAccess>
-#include <kio/thumbcreator.h>
+#include <KPluginLoader>
+#include <KLocalizedString>
+#include <KJobWidgets>
+#include <KIO/JobUiDelegate>
+#include <KIO/DeleteJob>
+#include <KIO/ThumbCreator>
-#include <QApplication>
-#include <QDir>
+#include <QUrl>
+#include <QLibrary>
#include <QVBoxLayout>
+#include <QStandardPaths>
+#include <QDialogButtonBox>
+#include <QPushButton>
ConfigurePreviewPluginDialog::ConfigurePreviewPluginDialog(const QString& pluginName,
const QString& desktopEntryName,
QWidget* parent) :
- KDialog(parent),
- m_configurationWidget(0),
- m_previewPlugin(0)
+ QDialog(parent)
{
- KLibrary library(desktopEntryName);
- if (library.load()) {
- newCreator create = (newCreator)library.resolveFunction("new_creator");
+ QSharedPointer<ThumbCreator> previewPlugin;
+ const QString pluginPath = KPluginLoader::findPlugin(desktopEntryName);
+ if (!pluginPath.isEmpty()) {
+ newCreator create = (newCreator)QLibrary::resolve(pluginPath, "new_creator");
if (create) {
- m_previewPlugin = dynamic_cast<ThumbCreatorV2*>(create());
+ previewPlugin.reset(dynamic_cast<ThumbCreator*>(create()));
}
}
- setCaption(i18nc("@title:window", "Configure Preview for %1", pluginName));
+ setWindowTitle(i18nc("@title:window", "Configure Preview for %1", pluginName));
+ setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
setMinimumWidth(400);
- setButtons(Ok | Cancel);
- setDefaultButton(Ok);
- QWidget* mainWidget = new QWidget(this);
- mainWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
- QVBoxLayout* layout = new QVBoxLayout(mainWidget);
- if (m_previewPlugin) {
- m_configurationWidget = m_previewPlugin->createConfigurationWidget();
- layout->addWidget(m_configurationWidget);
- }
- layout->addStretch(1);
+ auto layout = new QVBoxLayout(this);
+ setLayout(layout);
- setMainWidget(mainWidget);
+ if (previewPlugin) {
+ auto configurationWidget = previewPlugin->createConfigurationWidget();
+ configurationWidget->setParent(this);
+ layout->addWidget(configurationWidget);
- connect(this, SIGNAL(okClicked()), this, SLOT(slotOk()));
-}
+ layout->addStretch();
-ConfigurePreviewPluginDialog::~ConfigurePreviewPluginDialog()
-{
-}
+ connect(this, &ConfigurePreviewPluginDialog::accepted, this, [=] {
+ // TODO: It would be great having a mechanism to tell PreviewJob that only previews
+ // for a specific MIME-type should be regenerated. As this is not available yet we
+ // delete the whole thumbnails directory.
+ previewPlugin->writeConfiguration(configurationWidget);
-void ConfigurePreviewPluginDialog::slotOk()
-{
- m_previewPlugin->writeConfiguration(m_configurationWidget);
- // TODO: It would be great having a mechanism to tell PreviewJob that only previews
- // for a specific MIME-type should be regenerated. As this is not available yet we
- // delete the whole thumbnails directory.
- QApplication::changeOverrideCursor(Qt::BusyCursor);
- KIO::NetAccess::del(QString(QDir::homePath() + "/.thumbnails/"), this);
- QApplication::restoreOverrideCursor();
+ // http://specifications.freedesktop.org/thumbnail-spec/thumbnail-spec-latest.html#DIRECTORY
+ const QString thumbnailsPath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + QLatin1String("/thumbnails/");
+ KIO::del(QUrl::fromLocalFile(thumbnailsPath), KIO::HideProgressInfo);
+ });
+ }
-}
+ auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
+ connect(buttonBox, &QDialogButtonBox::accepted, this, &ConfigurePreviewPluginDialog::accept);
+ connect(buttonBox, &QDialogButtonBox::rejected, this, &ConfigurePreviewPluginDialog::reject);
+ layout->addWidget(buttonBox);
-#include "configurepreviewplugindialog.moc"
+ auto okButton = buttonBox->button(QDialogButtonBox::Ok);
+ okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
+ okButton->setDefault(true);
+} \ No newline at end of file
diff --git a/src/settings/general/configurepreviewplugindialog.h b/src/settings/general/configurepreviewplugindialog.h
index 5a3f5354a..620caeb51 100644
--- a/src/settings/general/configurepreviewplugindialog.h
+++ b/src/settings/general/configurepreviewplugindialog.h
@@ -20,14 +20,12 @@
#ifndef CONFIGUREPREVIEWPLUGINDIALOG_H
#define CONFIGUREPREVIEWPLUGINDIALOG_H
-#include <KDialog>
-
-class ThumbCreatorV2;
+#include <QDialog>
/**
* @brief Dialog for configuring preview-plugins.
*/
-class ConfigurePreviewPluginDialog : public KDialog
+class ConfigurePreviewPluginDialog : public QDialog
{
Q_OBJECT
@@ -39,17 +37,10 @@ public:
* widget.
* @param parent Parent widget.
*/
- explicit ConfigurePreviewPluginDialog(const QString& pluginName,
- const QString& desktopEntryName,
- QWidget* parent = 0);
- virtual ~ConfigurePreviewPluginDialog();
-
-private slots:
- void slotOk();
-
-private:
- QWidget* m_configurationWidget;
- ThumbCreatorV2* m_previewPlugin;
+ ConfigurePreviewPluginDialog(const QString& pluginName,
+ const QString& desktopEntryName,
+ QWidget* parent);
+ virtual ~ConfigurePreviewPluginDialog() = default;
};
#endif
diff --git a/src/settings/general/confirmationssettingspage.cpp b/src/settings/general/confirmationssettingspage.cpp
index ab23a1908..264024abd 100644
--- a/src/settings/general/confirmationssettingspage.cpp
+++ b/src/settings/general/confirmationssettingspage.cpp
@@ -21,8 +21,7 @@
#include <dolphin_generalsettings.h>
-#include <KDialog>
-#include <KLocale>
+#include <KLocalizedString>
#include <QCheckBox>
#include <QLabel>
@@ -31,6 +30,7 @@
namespace {
const bool ConfirmTrash = false;
const bool ConfirmDelete = true;
+ const bool ConfirmScriptExecution = true;
}
ConfirmationsSettingsPage::ConfirmationsSettingsPage(QWidget* parent) :
@@ -48,6 +48,8 @@ ConfirmationsSettingsPage::ConfirmationsSettingsPage(QWidget* parent) :
"Moving files or folders to trash"), this);
m_confirmDelete = new QCheckBox(i18nc("@option:check Ask for confirmation when",
"Deleting files or folders"), this);
+ m_confirmScriptExecution = new QCheckBox(i18nc("@option:check Ask for confirmation when",
+ "Executing scripts or desktop files"), this);
QLabel* confirmLabelDolphin = new QLabel(i18nc("@title:group", "Ask for confirmation when:"), this);
confirmLabelDolphin->setWordWrap(true);
@@ -55,22 +57,20 @@ ConfirmationsSettingsPage::ConfirmationsSettingsPage(QWidget* parent) :
m_confirmClosingMultipleTabs = new QCheckBox(i18nc("@option:check Ask for confirmation when",
"Closing Dolphin windows with multiple tabs"), this);
- topLayout->addSpacing(KDialog::spacingHint());
topLayout->addWidget(confirmLabelKde);
- topLayout->addSpacing(KDialog::spacingHint());
topLayout->addWidget(m_confirmMoveToTrash);
topLayout->addWidget(m_confirmDelete);
- topLayout->addSpacing(KDialog::spacingHint());
+ topLayout->addWidget(m_confirmScriptExecution);
topLayout->addWidget(confirmLabelDolphin);
- topLayout->addSpacing(KDialog::spacingHint());
topLayout->addWidget(m_confirmClosingMultipleTabs);
topLayout->addStretch();
loadSettings();
- connect(m_confirmMoveToTrash, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
- connect(m_confirmDelete, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
- connect(m_confirmClosingMultipleTabs, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
+ connect(m_confirmMoveToTrash, &QCheckBox::toggled, this, &ConfirmationsSettingsPage::changed);
+ connect(m_confirmDelete, &QCheckBox::toggled, this, &ConfirmationsSettingsPage::changed);
+ connect(m_confirmScriptExecution, &QCheckBox::toggled, this, &ConfirmationsSettingsPage::changed);
+ connect(m_confirmClosingMultipleTabs, &QCheckBox::toggled, this, &ConfirmationsSettingsPage::changed);
}
ConfirmationsSettingsPage::~ConfirmationsSettingsPage()
@@ -85,9 +85,15 @@ void ConfirmationsSettingsPage::applySettings()
confirmationGroup.writeEntry("ConfirmDelete", m_confirmDelete->isChecked());
confirmationGroup.sync();
+ if (m_confirmScriptExecution->isChecked()) {
+ KConfigGroup scriptExecutionGroup(kioConfig, "Executable scripts");
+ scriptExecutionGroup.writeEntry("behaviourOnLaunch", "alwaysAsk");
+ scriptExecutionGroup.sync();
+ }
+
GeneralSettings* settings = GeneralSettings::self();
settings->setConfirmClosingMultipleTabs(m_confirmClosingMultipleTabs->isChecked());
- settings->writeConfig();
+ settings->save();
}
void ConfirmationsSettingsPage::restoreDefaults()
@@ -99,6 +105,7 @@ void ConfirmationsSettingsPage::restoreDefaults()
m_confirmMoveToTrash->setChecked(ConfirmTrash);
m_confirmDelete->setChecked(ConfirmDelete);
+ m_confirmScriptExecution->setChecked(ConfirmScriptExecution);
}
void ConfirmationsSettingsPage::loadSettings()
@@ -108,7 +115,10 @@ void ConfirmationsSettingsPage::loadSettings()
m_confirmMoveToTrash->setChecked(confirmationGroup.readEntry("ConfirmTrash", ConfirmTrash));
m_confirmDelete->setChecked(confirmationGroup.readEntry("ConfirmDelete", ConfirmDelete));
+ const KConfigGroup scriptExecutionGroup(KSharedConfig::openConfig("kiorc"), "Executable scripts");
+ const QString value = scriptExecutionGroup.readEntry("behaviourOnLaunch", "alwaysAsk");
+ m_confirmScriptExecution->setChecked(value == "alwaysAsk");
+
m_confirmClosingMultipleTabs->setChecked(GeneralSettings::confirmClosingMultipleTabs());
}
-#include "confirmationssettingspage.moc"
diff --git a/src/settings/general/confirmationssettingspage.h b/src/settings/general/confirmationssettingspage.h
index 45f0be1fc..e702fe8ae 100644
--- a/src/settings/general/confirmationssettingspage.h
+++ b/src/settings/general/confirmationssettingspage.h
@@ -35,10 +35,10 @@ public:
virtual ~ConfirmationsSettingsPage();
/** @see SettingsPageBase::applySettings() */
- virtual void applySettings();
+ virtual void applySettings() Q_DECL_OVERRIDE;
/** @see SettingsPageBase::restoreDefaults() */
- virtual void restoreDefaults();
+ virtual void restoreDefaults() Q_DECL_OVERRIDE;
private:
void loadSettings();
@@ -47,6 +47,7 @@ private:
QCheckBox* m_confirmMoveToTrash;
QCheckBox* m_confirmDelete;
QCheckBox* m_confirmClosingMultipleTabs;
+ QCheckBox* m_confirmScriptExecution;
};
#endif
diff --git a/src/settings/general/generalsettingspage.cpp b/src/settings/general/generalsettingspage.cpp
index 18e152880..d8f61ef90 100644
--- a/src/settings/general/generalsettingspage.cpp
+++ b/src/settings/general/generalsettingspage.cpp
@@ -26,42 +26,39 @@
#include <settings/settingspagebase.h>
#include "statusbarsettingspage.h"
-#include <KDialog>
-#include <KLocale>
-#include <KIconLoader>
-#include <KTabWidget>
+#include <KLocalizedString>
+#include <QTabWidget>
#include <QVBoxLayout>
-GeneralSettingsPage::GeneralSettingsPage(const KUrl& url, QWidget* parent) :
+GeneralSettingsPage::GeneralSettingsPage(const QUrl& url, QWidget* parent) :
SettingsPageBase(parent),
m_pages()
{
QVBoxLayout* topLayout = new QVBoxLayout(this);
topLayout->setMargin(0);
- topLayout->setSpacing(KDialog::spacingHint());
- KTabWidget* tabWidget = new KTabWidget(this);
+ QTabWidget* tabWidget = new QTabWidget(this);
// initialize 'Behavior' tab
BehaviorSettingsPage* behaviorPage = new BehaviorSettingsPage(url, tabWidget);
tabWidget->addTab(behaviorPage, i18nc("@title:tab Behavior settings", "Behavior"));
- connect(behaviorPage, SIGNAL(changed()), this, SIGNAL(changed()));
+ connect(behaviorPage, &BehaviorSettingsPage::changed, this, &GeneralSettingsPage::changed);
// initialize 'Previews' tab
PreviewsSettingsPage* previewsPage = new PreviewsSettingsPage(tabWidget);
tabWidget->addTab(previewsPage, i18nc("@title:tab Previews settings", "Previews"));
- connect(previewsPage, SIGNAL(changed()), this, SIGNAL(changed()));
+ connect(previewsPage, &PreviewsSettingsPage::changed, this, &GeneralSettingsPage::changed);
// initialize 'Context Menu' tab
ConfirmationsSettingsPage* confirmationsPage = new ConfirmationsSettingsPage(tabWidget);
tabWidget->addTab(confirmationsPage, i18nc("@title:tab Confirmations settings", "Confirmations"));
- connect(confirmationsPage, SIGNAL(changed()), this, SIGNAL(changed()));
+ connect(confirmationsPage, &ConfirmationsSettingsPage::changed, this, &GeneralSettingsPage::changed);
// initialize 'Status Bar' tab
StatusBarSettingsPage* statusBarPage = new StatusBarSettingsPage(tabWidget);
tabWidget->addTab(statusBarPage, i18nc("@title:tab Status Bar settings", "Status Bar"));
- connect(statusBarPage, SIGNAL(changed()), this, SIGNAL(changed()));
+ connect(statusBarPage, &StatusBarSettingsPage::changed, this, &GeneralSettingsPage::changed);
m_pages.append(behaviorPage);
m_pages.append(previewsPage);
@@ -89,4 +86,3 @@ void GeneralSettingsPage::restoreDefaults()
}
}
-#include "generalsettingspage.moc"
diff --git a/src/settings/general/generalsettingspage.h b/src/settings/general/generalsettingspage.h
index 0d28664f5..7073258ff 100644
--- a/src/settings/general/generalsettingspage.h
+++ b/src/settings/general/generalsettingspage.h
@@ -23,7 +23,7 @@
#include <QWidget>
#include <settings/settingspagebase.h>
-class KUrl;
+class QUrl;
class SettingsPageBase;
/**
@@ -40,14 +40,14 @@ class GeneralSettingsPage : public SettingsPageBase
Q_OBJECT
public:
- GeneralSettingsPage(const KUrl& url, QWidget* parent);
+ GeneralSettingsPage(const QUrl& url, QWidget* parent);
virtual ~GeneralSettingsPage();
/** @see SettingsPageBase::applySettings() */
- virtual void applySettings();
+ virtual void applySettings() Q_DECL_OVERRIDE;
/** @see SettingsPageBase::restoreDefaults() */
- virtual void restoreDefaults();
+ virtual void restoreDefaults() Q_DECL_OVERRIDE;
private:
QList<SettingsPageBase*> m_pages;
diff --git a/src/settings/general/previewssettingspage.cpp b/src/settings/general/previewssettingspage.cpp
index 38b61b996..37e05197a 100644
--- a/src/settings/general/previewssettingspage.cpp
+++ b/src/settings/general/previewssettingspage.cpp
@@ -23,10 +23,7 @@
#include "configurepreviewplugindialog.h"
#include <KConfigGroup>
-#include <KDialog>
-#include <KGlobal>
-#include <KLocale>
-#include <KNumInput>
+#include <KLocalizedString>
#include <KServiceTypeTrader>
#include <KService>
@@ -42,6 +39,7 @@
#include <QScrollBar>
#include <QShowEvent>
#include <QSlider>
+#include <QSpinBox>
#include <QSortFilterProxyModel>
#include <QVBoxLayout>
@@ -65,8 +63,8 @@ PreviewsSettingsPage::PreviewsSettingsPage(QWidget* parent) :
m_listView = new QListView(this);
ServiceItemDelegate* delegate = new ServiceItemDelegate(m_listView, m_listView);
- connect(delegate, SIGNAL(requestServiceConfiguration(QModelIndex)),
- this, SLOT(configureService(QModelIndex)));
+ connect(delegate, &ServiceItemDelegate::requestServiceConfiguration,
+ this, &PreviewsSettingsPage::configureService);
ServiceModel* serviceModel = new ServiceModel(this);
QSortFilterProxyModel* proxyModel = new QSortFilterProxyModel(this);
@@ -79,7 +77,7 @@ PreviewsSettingsPage::PreviewsSettingsPage(QWidget* parent) :
QLabel* remoteFileSizeLabel = new QLabel(i18nc("@label", "Skip previews for remote files above:"), this);
- m_remoteFileSizeBox = new KIntSpinBox(this);
+ m_remoteFileSizeBox = new QSpinBox(this);
m_remoteFileSizeBox->setSingleStep(1);
m_remoteFileSizeBox->setSuffix(QLatin1String(" MB"));
m_remoteFileSizeBox->setRange(0, 9999999); /* MB */
@@ -88,15 +86,14 @@ PreviewsSettingsPage::PreviewsSettingsPage(QWidget* parent) :
fileSizeBoxLayout->addWidget(remoteFileSizeLabel, 0, Qt::AlignRight);
fileSizeBoxLayout->addWidget(m_remoteFileSizeBox);
- topLayout->addSpacing(KDialog::spacingHint());
topLayout->addWidget(showPreviewsLabel);
topLayout->addWidget(m_listView);
topLayout->addLayout(fileSizeBoxLayout);
loadSettings();
- connect(m_listView, SIGNAL(clicked(QModelIndex)), this, SIGNAL(changed()));
- connect(m_remoteFileSizeBox, SIGNAL(valueChanged(int)), this, SIGNAL(changed()));
+ connect(m_listView, &QListView::clicked, this, &PreviewsSettingsPage::changed);
+ connect(m_remoteFileSizeBox, static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &PreviewsSettingsPage::changed);
}
PreviewsSettingsPage::~PreviewsSettingsPage()
@@ -119,7 +116,7 @@ void PreviewsSettingsPage::applySettings()
}
}
- KConfigGroup globalConfig(KGlobal::config(), QLatin1String("PreviewSettings"));
+ KConfigGroup globalConfig(KSharedConfig::openConfig(), QLatin1String("PreviewSettings"));
globalConfig.writeEntry("Plugins", m_enabledPreviewPlugins);
const qulonglong maximumRemoteSize = static_cast<qulonglong>(m_remoteFileSizeBox->value()) * 1024 * 1024;
@@ -159,7 +156,7 @@ void PreviewsSettingsPage::loadPreviewPlugins()
QAbstractItemModel* model = m_listView->model();
const KService::List plugins = KServiceTypeTrader::self()->query(QLatin1String("ThumbCreator"));
- foreach (const KSharedPtr<KService>& service, plugins) {
+ foreach (const KService::Ptr& service, plugins) {
const bool configurable = service->property("Configurable", QVariant::Bool).toBool();
const bool show = m_enabledPreviewPlugins.contains(service->desktopEntryName());
@@ -176,29 +173,15 @@ void PreviewsSettingsPage::loadPreviewPlugins()
void PreviewsSettingsPage::loadSettings()
{
- KConfigGroup globalConfig(KGlobal::config(), "PreviewSettings");
+ KConfigGroup globalConfig(KSharedConfig::openConfig(), "PreviewSettings");
m_enabledPreviewPlugins = globalConfig.readEntry("Plugins", QStringList()
<< QLatin1String("directorythumbnail")
<< QLatin1String("imagethumbnail")
<< QLatin1String("jpegthumbnail"));
- // If the user is upgrading from KDE <= 4.6, we must check if he had the 'jpegrotatedthumbnail' plugin enabled.
- // This plugin does not exist any more in KDE >= 4.7, so we have to replace it with the 'jpegthumbnail' plugin.
- //
- // Note that the upgrade to the correct plugin is done already in KFilePreviewGenerator. However, if Konqueror is
- // opened in web browsing mode and the Settings dialog is opened, we might end up here before KFilePreviewGenerator's
- // constructor is ever called -> the plugin replacement should be done here as well.
- if (m_enabledPreviewPlugins.contains(QLatin1String("jpegrotatedthumbnail"))) {
- m_enabledPreviewPlugins.removeAll(QLatin1String("jpegrotatedthumbnail"));
- m_enabledPreviewPlugins.append(QLatin1String("jpegthumbnail"));
- globalConfig.writeEntry("Plugins", m_enabledPreviewPlugins);
- globalConfig.sync();
- }
-
const qulonglong defaultRemotePreview = static_cast<qulonglong>(MaxRemotePreviewSize) * 1024 * 1024;
const qulonglong maxRemoteByteSize = globalConfig.readEntry("MaximumRemoteSize", defaultRemotePreview);
const int maxRemoteMByteSize = maxRemoteByteSize / (1024 * 1024);
m_remoteFileSizeBox->setValue(maxRemoteMByteSize);
}
-#include "previewssettingspage.moc"
diff --git a/src/settings/general/previewssettingspage.h b/src/settings/general/previewssettingspage.h
index a43535133..6e896f05e 100644
--- a/src/settings/general/previewssettingspage.h
+++ b/src/settings/general/previewssettingspage.h
@@ -22,7 +22,7 @@
#include <settings/settingspagebase.h>
-class KIntSpinBox;
+class QSpinBox;
class QListView;
class QModelIndex;
@@ -42,13 +42,13 @@ public:
* The settings are persisted automatically when
* closing Dolphin.
*/
- virtual void applySettings();
+ virtual void applySettings() Q_DECL_OVERRIDE;
/** Restores the settings to default values. */
- virtual void restoreDefaults();
+ virtual void restoreDefaults() Q_DECL_OVERRIDE;
protected:
- virtual void showEvent(QShowEvent* event);
+ virtual void showEvent(QShowEvent* event) Q_DECL_OVERRIDE;
private slots:
void configureService(const QModelIndex& index);
@@ -61,7 +61,7 @@ private:
bool m_initialized;
QListView *m_listView;
QStringList m_enabledPreviewPlugins;
- KIntSpinBox* m_remoteFileSizeBox;
+ QSpinBox* m_remoteFileSizeBox;
};
#endif
diff --git a/src/settings/general/statusbarsettingspage.cpp b/src/settings/general/statusbarsettingspage.cpp
index 48622ac4c..03846253b 100644
--- a/src/settings/general/statusbarsettingspage.cpp
+++ b/src/settings/general/statusbarsettingspage.cpp
@@ -21,8 +21,7 @@
#include <dolphin_generalsettings.h>
-#include <KDialog>
-#include <KLocale>
+#include <KLocalizedString>
#include <QCheckBox>
#include <QVBoxLayout>
@@ -36,15 +35,14 @@ StatusBarSettingsPage::StatusBarSettingsPage(QWidget* parent) :
m_showSpaceInfo = new QCheckBox(i18nc("@option:check", "Show space information"), this);
QVBoxLayout* topLayout = new QVBoxLayout(this);
- topLayout->addSpacing(KDialog::spacingHint());
topLayout->addWidget(m_showZoomSlider);
topLayout->addWidget(m_showSpaceInfo);
topLayout->addStretch();
loadSettings();
- connect(m_showZoomSlider, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
- connect(m_showSpaceInfo, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
+ connect(m_showZoomSlider, &QCheckBox::toggled, this, &StatusBarSettingsPage::changed);
+ connect(m_showSpaceInfo, &QCheckBox::toggled, this, &StatusBarSettingsPage::changed);
}
StatusBarSettingsPage::~StatusBarSettingsPage()
@@ -56,7 +54,7 @@ void StatusBarSettingsPage::applySettings()
GeneralSettings* settings = GeneralSettings::self();
settings->setShowZoomSlider(m_showZoomSlider->isChecked());
settings->setShowSpaceInfo(m_showSpaceInfo->isChecked());
- settings->writeConfig();
+ settings->save();
}
void StatusBarSettingsPage::restoreDefaults()
@@ -73,4 +71,3 @@ void StatusBarSettingsPage::loadSettings()
m_showSpaceInfo->setChecked(GeneralSettings::showSpaceInfo());
}
-#include "statusbarsettingspage.moc"
diff --git a/src/settings/general/statusbarsettingspage.h b/src/settings/general/statusbarsettingspage.h
index 17bc799bc..608354371 100644
--- a/src/settings/general/statusbarsettingspage.h
+++ b/src/settings/general/statusbarsettingspage.h
@@ -35,10 +35,10 @@ public:
virtual ~StatusBarSettingsPage();
/** @see SettingsPageBase::applySettings() */
- virtual void applySettings();
+ virtual void applySettings() Q_DECL_OVERRIDE;
/** @see SettingsPageBase::restoreDefaults() */
- virtual void restoreDefaults();
+ virtual void restoreDefaults() Q_DECL_OVERRIDE;
private:
void loadSettings();
diff --git a/src/settings/kcm/kcmdolphingeneral.cpp b/src/settings/kcm/kcmdolphingeneral.cpp
index 26cb580f0..fb3956880 100644
--- a/src/settings/kcm/kcmdolphingeneral.cpp
+++ b/src/settings/kcm/kcmdolphingeneral.cpp
@@ -19,9 +19,7 @@
#include "kcmdolphingeneral.h"
-#include <KTabWidget>
-#include <KDialog>
-#include <KLocale>
+#include <KLocalizedString>
#include <KPluginFactory>
#include <KPluginLoader>
@@ -31,40 +29,38 @@
#include <QDir>
#include <QVBoxLayout>
+#include <QTabWidget>
K_PLUGIN_FACTORY(KCMDolphinGeneralConfigFactory, registerPlugin<DolphinGeneralConfigModule>("dolphingeneral");)
K_EXPORT_PLUGIN(KCMDolphinGeneralConfigFactory("kcmdolphingeneral"))
DolphinGeneralConfigModule::DolphinGeneralConfigModule(QWidget* parent, const QVariantList& args) :
- KCModule(KCMDolphinGeneralConfigFactory::componentData(), parent),
+ KCModule(parent),
m_pages()
{
Q_UNUSED(args);
- KGlobal::locale()->insertCatalog("dolphin");
-
setButtons(KCModule::Default | KCModule::Help);
QVBoxLayout* topLayout = new QVBoxLayout(this);
topLayout->setMargin(0);
- topLayout->setSpacing(KDialog::spacingHint());
- KTabWidget* tabWidget = new KTabWidget(this);
+ QTabWidget* tabWidget = new QTabWidget(this);
// initialize 'Behavior' tab
BehaviorSettingsPage* behaviorPage = new BehaviorSettingsPage(QDir::homePath(), tabWidget);
tabWidget->addTab(behaviorPage, i18nc("@title:tab Behavior settings", "Behavior"));
- connect(behaviorPage, SIGNAL(changed()), this, SLOT(changed()));
+ connect(behaviorPage, &BehaviorSettingsPage::changed, this, static_cast<void(DolphinGeneralConfigModule::*)()>(&DolphinGeneralConfigModule::changed));
// initialize 'Previews' tab
PreviewsSettingsPage* previewsPage = new PreviewsSettingsPage(tabWidget);
tabWidget->addTab(previewsPage, i18nc("@title:tab Previews settings", "Previews"));
- connect(previewsPage, SIGNAL(changed()), this, SLOT(changed()));
+ connect(previewsPage, &PreviewsSettingsPage::changed, this, static_cast<void(DolphinGeneralConfigModule::*)()>(&DolphinGeneralConfigModule::changed));
// initialize 'Confirmations' tab
ConfirmationsSettingsPage* confirmationsPage = new ConfirmationsSettingsPage(tabWidget);
tabWidget->addTab(confirmationsPage, i18nc("@title:tab Confirmations settings", "Confirmations"));
- connect(confirmationsPage, SIGNAL(changed()), this, SLOT(changed()));
+ connect(confirmationsPage, &ConfirmationsSettingsPage::changed, this, static_cast<void(DolphinGeneralConfigModule::*)()>(&DolphinGeneralConfigModule::changed));
m_pages.append(behaviorPage);
m_pages.append(previewsPage);
diff --git a/src/settings/kcm/kcmdolphingeneral.desktop b/src/settings/kcm/kcmdolphingeneral.desktop
index 3982e49c4..02e72da9a 100644
--- a/src/settings/kcm/kcmdolphingeneral.desktop
+++ b/src/settings/kcm/kcmdolphingeneral.desktop
@@ -141,7 +141,7 @@ Comment[zh_TW]=此服務允許設定 Dolphin 的一般設定。
Icon=system-run
Type=Service
X-KDE-ServiceTypes=KCModule
-Exec=kcmshell4 kcmdolphingeneral
+Exec=kcmshell5 kcmdolphingeneral
X-KDE-Library=kcm_dolphingeneral
X-KDE-PluginKeyword=dolphingeneral
diff --git a/src/settings/kcm/kcmdolphingeneral.h b/src/settings/kcm/kcmdolphingeneral.h
index 6b844c9a8..50331a75c 100644
--- a/src/settings/kcm/kcmdolphingeneral.h
+++ b/src/settings/kcm/kcmdolphingeneral.h
@@ -36,8 +36,8 @@ public:
DolphinGeneralConfigModule(QWidget* parent, const QVariantList& args);
virtual ~DolphinGeneralConfigModule();
- virtual void save();
- virtual void defaults();
+ virtual void save() Q_DECL_OVERRIDE;
+ virtual void defaults() Q_DECL_OVERRIDE;
private:
QList<SettingsPageBase*> m_pages;
diff --git a/src/settings/kcm/kcmdolphinnavigation.cpp b/src/settings/kcm/kcmdolphinnavigation.cpp
index 36345a515..0b2729c33 100644
--- a/src/settings/kcm/kcmdolphinnavigation.cpp
+++ b/src/settings/kcm/kcmdolphinnavigation.cpp
@@ -19,9 +19,6 @@
#include "kcmdolphinnavigation.h"
-#include <KTabWidget>
-#include <KDialog>
-#include <KLocale>
#include <KPluginFactory>
#include <KPluginLoader>
@@ -33,21 +30,18 @@ K_PLUGIN_FACTORY(KCMDolphinNavigationConfigFactory, registerPlugin<DolphinNaviga
K_EXPORT_PLUGIN(KCMDolphinNavigationConfigFactory("kcmdolphinnavigation"))
DolphinNavigationConfigModule::DolphinNavigationConfigModule(QWidget* parent, const QVariantList& args) :
- KCModule(KCMDolphinNavigationConfigFactory::componentData(), parent),
+ KCModule(parent),
m_navigation(0)
{
Q_UNUSED(args);
- KGlobal::locale()->insertCatalog("dolphin");
-
setButtons(KCModule::Default | KCModule::Help);
QVBoxLayout* topLayout = new QVBoxLayout(this);
topLayout->setMargin(0);
- topLayout->setSpacing(KDialog::spacingHint());
m_navigation = new NavigationSettingsPage(this);
- connect(m_navigation, SIGNAL(changed()), this, SLOT(changed()));
+ connect(m_navigation, &NavigationSettingsPage::changed, this, static_cast<void(DolphinNavigationConfigModule::*)()>(&DolphinNavigationConfigModule::changed));
topLayout->addWidget(m_navigation, 0, 0);
}
diff --git a/src/settings/kcm/kcmdolphinnavigation.desktop b/src/settings/kcm/kcmdolphinnavigation.desktop
index e7f0bc4b9..4312fb406 100644
--- a/src/settings/kcm/kcmdolphinnavigation.desktop
+++ b/src/settings/kcm/kcmdolphinnavigation.desktop
@@ -142,7 +142,7 @@ Comment[zh_TW]=此服務允許設定 Dolphin 的導覽。
Icon=input-mouse
Type=Service
X-KDE-ServiceTypes=KCModule
-Exec=kcmshell4 kcmdolphinnavigation
+Exec=kcmshell5 kcmdolphinnavigation
X-KDE-Library=kcm_dolphinnavigation
X-KDE-PluginKeyword=dolphinnavigation
diff --git a/src/settings/kcm/kcmdolphinnavigation.h b/src/settings/kcm/kcmdolphinnavigation.h
index e7634d661..e8de0753e 100644
--- a/src/settings/kcm/kcmdolphinnavigation.h
+++ b/src/settings/kcm/kcmdolphinnavigation.h
@@ -35,8 +35,8 @@ public:
DolphinNavigationConfigModule(QWidget* parent, const QVariantList& args);
virtual ~DolphinNavigationConfigModule();
- virtual void save();
- virtual void defaults();
+ virtual void save() Q_DECL_OVERRIDE;
+ virtual void defaults() Q_DECL_OVERRIDE;
private:
NavigationSettingsPage* m_navigation;
diff --git a/src/settings/kcm/kcmdolphinservices.cpp b/src/settings/kcm/kcmdolphinservices.cpp
index 6d8c76192..8bfdefebb 100644
--- a/src/settings/kcm/kcmdolphinservices.cpp
+++ b/src/settings/kcm/kcmdolphinservices.cpp
@@ -19,9 +19,6 @@
#include "kcmdolphinservices.h"
-#include <KTabWidget>
-#include <KDialog>
-#include <KLocale>
#include <KPluginFactory>
#include <KPluginLoader>
@@ -33,21 +30,18 @@ K_PLUGIN_FACTORY(KCMDolphinServicesConfigFactory, registerPlugin<DolphinServices
K_EXPORT_PLUGIN(KCMDolphinServicesConfigFactory("kcmdolphinservices"))
DolphinServicesConfigModule::DolphinServicesConfigModule(QWidget* parent, const QVariantList& args) :
- KCModule(KCMDolphinServicesConfigFactory::componentData(), parent),
+ KCModule(parent),
m_services(0)
{
Q_UNUSED(args);
- KGlobal::locale()->insertCatalog("dolphin");
-
setButtons(KCModule::Default | KCModule::Help);
QVBoxLayout* topLayout = new QVBoxLayout(this);
topLayout->setMargin(0);
- topLayout->setSpacing(KDialog::spacingHint());
m_services = new ServicesSettingsPage(this);
- connect(m_services, SIGNAL(changed()), this, SLOT(changed()));
+ connect(m_services, &ServicesSettingsPage::changed, this, static_cast<void(DolphinServicesConfigModule::*)()>(&DolphinServicesConfigModule::changed));
topLayout->addWidget(m_services, 0, 0);
}
diff --git a/src/settings/kcm/kcmdolphinservices.desktop b/src/settings/kcm/kcmdolphinservices.desktop
index c96baa2bf..cb08a6a60 100644
--- a/src/settings/kcm/kcmdolphinservices.desktop
+++ b/src/settings/kcm/kcmdolphinservices.desktop
@@ -72,7 +72,7 @@ Name[zh_TW]=Dolphin 服務
Icon=services
Type=Service
X-KDE-ServiceTypes=KCModule
-Exec=kcmshell4 kcmdolphinservices
+Exec=kcmshell5 kcmdolphinservices
X-KDE-Library=kcm_dolphinservices
X-KDE-PluginKeyword=dolphinservices
diff --git a/src/settings/kcm/kcmdolphinservices.h b/src/settings/kcm/kcmdolphinservices.h
index 70ed366fe..8a63bb045 100644
--- a/src/settings/kcm/kcmdolphinservices.h
+++ b/src/settings/kcm/kcmdolphinservices.h
@@ -35,8 +35,8 @@ public:
DolphinServicesConfigModule(QWidget* parent, const QVariantList& args);
virtual ~DolphinServicesConfigModule();
- virtual void save();
- virtual void defaults();
+ virtual void save() Q_DECL_OVERRIDE;
+ virtual void defaults() Q_DECL_OVERRIDE;
private:
ServicesSettingsPage* m_services;
diff --git a/src/settings/kcm/kcmdolphinviewmodes.cpp b/src/settings/kcm/kcmdolphinviewmodes.cpp
index a7a9db36d..0859e568a 100644
--- a/src/settings/kcm/kcmdolphinviewmodes.cpp
+++ b/src/settings/kcm/kcmdolphinviewmodes.cpp
@@ -19,54 +19,49 @@
#include "kcmdolphinviewmodes.h"
-#include <KTabWidget>
-#include <KDialog>
-#include <KLocale>
+#include <KLocalizedString>
#include <KPluginFactory>
#include <KPluginLoader>
-#include <KIcon>
+#include <QIcon>
#include <settings/viewmodes/viewsettingstab.h>
#include <QDBusConnection>
#include <QDBusMessage>
-#include <QDir>
#include <QPushButton>
#include <QVBoxLayout>
+#include <QTabWidget>
K_PLUGIN_FACTORY(KCMDolphinViewModesConfigFactory, registerPlugin<DolphinViewModesConfigModule>("dolphinviewmodes");)
K_EXPORT_PLUGIN(KCMDolphinViewModesConfigFactory("kcmdolphinviewmodes"))
DolphinViewModesConfigModule::DolphinViewModesConfigModule(QWidget* parent, const QVariantList& args) :
- KCModule(KCMDolphinViewModesConfigFactory::componentData(), parent),
+ KCModule(parent),
m_tabs()
{
Q_UNUSED(args);
- KGlobal::locale()->insertCatalog("dolphin");
-
setButtons(KCModule::Default | KCModule::Help);
QVBoxLayout* topLayout = new QVBoxLayout(this);
topLayout->setMargin(0);
- topLayout->setSpacing(KDialog::spacingHint());
- KTabWidget* tabWidget = new KTabWidget(this);
+ QTabWidget* tabWidget = new QTabWidget(this);
// Initialize 'Icons' tab
ViewSettingsTab* iconsTab = new ViewSettingsTab(ViewSettingsTab::IconsMode, tabWidget);
- tabWidget->addTab(iconsTab, KIcon("view-list-icons"), i18nc("@title:tab", "Icons"));
- connect(iconsTab, SIGNAL(changed()), this, SLOT(viewModeChanged()));
+ tabWidget->addTab(iconsTab, QIcon::fromTheme("view-list-icons"), i18nc("@title:tab", "Icons"));
+ connect(iconsTab, &ViewSettingsTab::changed, this, &DolphinViewModesConfigModule::viewModeChanged);
// Initialize 'Compact' tab
ViewSettingsTab* compactTab = new ViewSettingsTab(ViewSettingsTab::CompactMode, tabWidget);
- tabWidget->addTab(compactTab, KIcon("view-list-details"), i18nc("@title:tab", "Compact"));
- connect(compactTab, SIGNAL(changed()), this, SLOT(viewModeChanged()));
+ tabWidget->addTab(compactTab, QIcon::fromTheme("view-list-details"), i18nc("@title:tab", "Compact"));
+ connect(compactTab, &ViewSettingsTab::changed, this, &DolphinViewModesConfigModule::viewModeChanged);
// Initialize 'Details' tab
ViewSettingsTab* detailsTab = new ViewSettingsTab(ViewSettingsTab::DetailsMode, tabWidget);
- tabWidget->addTab(detailsTab, KIcon("view-list-tree"), i18nc("@title:tab", "Details"));
- connect(detailsTab, SIGNAL(changed()), this, SLOT(viewModeChanged()));
+ tabWidget->addTab(detailsTab, QIcon::fromTheme("view-list-tree"), i18nc("@title:tab", "Details"));
+ connect(detailsTab, &ViewSettingsTab::changed, this, &DolphinViewModesConfigModule::viewModeChanged);
m_tabs.append(iconsTab);
m_tabs.append(compactTab);
diff --git a/src/settings/kcm/kcmdolphinviewmodes.desktop b/src/settings/kcm/kcmdolphinviewmodes.desktop
index 39cc0e2a5..74d2d11c8 100644
--- a/src/settings/kcm/kcmdolphinviewmodes.desktop
+++ b/src/settings/kcm/kcmdolphinviewmodes.desktop
@@ -141,7 +141,7 @@ Comment[zh_TW]=此服務允許設定 Dolphin 的檢視模式。
Icon=view-choose
Type=Service
X-KDE-ServiceTypes=KCModule
-Exec=kcmshell4 kcmdolphinviewmodes
+Exec=kcmshell5 kcmdolphinviewmodes
X-KDE-Library=kcm_dolphinviewmodes
X-KDE-PluginKeyword=dolphinviewmodes
diff --git a/src/settings/kcm/kcmdolphinviewmodes.h b/src/settings/kcm/kcmdolphinviewmodes.h
index 3181198fe..0a0b0ff10 100644
--- a/src/settings/kcm/kcmdolphinviewmodes.h
+++ b/src/settings/kcm/kcmdolphinviewmodes.h
@@ -35,8 +35,8 @@ public:
DolphinViewModesConfigModule(QWidget* parent, const QVariantList& args);
virtual ~DolphinViewModesConfigModule();
- virtual void save();
- virtual void defaults();
+ virtual void save() Q_DECL_OVERRIDE;
+ virtual void defaults() Q_DECL_OVERRIDE;
private:
void reparseConfiguration();
diff --git a/src/settings/navigation/navigationsettingspage.cpp b/src/settings/navigation/navigationsettingspage.cpp
index 8076d705d..f9c7a4dfc 100644
--- a/src/settings/navigation/navigationsettingspage.cpp
+++ b/src/settings/navigation/navigationsettingspage.cpp
@@ -21,15 +21,9 @@
#include "dolphin_generalsettings.h"
-#include <KDialog>
-#include <KGlobalSettings>
-#include <KLocale>
-#include <KVBox>
+#include <KLocalizedString>
#include <QCheckBox>
-#include <QGroupBox>
-#include <QLabel>
-#include <QRadioButton>
#include <QVBoxLayout>
NavigationSettingsPage::NavigationSettingsPage(QWidget* parent) :
@@ -37,27 +31,17 @@ NavigationSettingsPage::NavigationSettingsPage(QWidget* parent) :
m_openArchivesAsFolder(0),
m_autoExpandFolders(0)
{
- const int spacing = KDialog::spacingHint();
-
QVBoxLayout* topLayout = new QVBoxLayout(this);
- KVBox* vBox = new KVBox(this);
- vBox->setSpacing(spacing);
-
- // create 'Mouse' group
- QGroupBox* mouseBox = new QGroupBox(i18nc("@title:group", "Mouse"), vBox);
- mouseBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
- m_singleClick = new QRadioButton(i18nc("@option:check Mouse Settings",
- "Single-click to open files and folders"), mouseBox);
- m_doubleClick = new QRadioButton(i18nc("@option:check Mouse Settings",
- "Double-click to open files and folders"), mouseBox);
-
- QVBoxLayout* mouseBoxLayout = new QVBoxLayout(mouseBox);
- mouseBoxLayout->addWidget(m_singleClick);
- mouseBoxLayout->addWidget(m_doubleClick);
+ QWidget* vBox = new QWidget(this);
+ QVBoxLayout *vBoxLayout = new QVBoxLayout(vBox);
+ vBoxLayout->setMargin(0);
+ vBoxLayout->setAlignment(Qt::AlignTop);
m_openArchivesAsFolder = new QCheckBox(i18nc("@option:check", "Open archives as folder"), vBox);
+ vBoxLayout->addWidget(m_openArchivesAsFolder);
m_autoExpandFolders = new QCheckBox(i18nc("option:check", "Open folders during drag operations"), vBox);
+ vBoxLayout->addWidget(m_autoExpandFolders);
// Add a dummy widget with no restriction regarding
// a vertical resizing. This assures that the dialog layout
@@ -68,10 +52,8 @@ NavigationSettingsPage::NavigationSettingsPage(QWidget* parent) :
loadSettings();
- connect(m_singleClick, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
- connect(m_doubleClick, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
- connect(m_openArchivesAsFolder, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
- connect(m_autoExpandFolders, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
+ connect(m_openArchivesAsFolder, &QCheckBox::toggled, this, &NavigationSettingsPage::changed);
+ connect(m_autoExpandFolders, &QCheckBox::toggled, this, &NavigationSettingsPage::changed);
}
NavigationSettingsPage::~NavigationSettingsPage()
@@ -80,17 +62,11 @@ NavigationSettingsPage::~NavigationSettingsPage()
void NavigationSettingsPage::applySettings()
{
- KConfig config("kcminputrc");
- KConfigGroup group = config.group("KDE");
- group.writeEntry("SingleClick", m_singleClick->isChecked(), KConfig::Persistent|KConfig::Global);
- config.sync();
- KGlobalSettings::self()->emitChange(KGlobalSettings::SettingsChanged, KGlobalSettings::SETTINGS_MOUSE);
-
GeneralSettings* settings = GeneralSettings::self();
settings->setBrowseThroughArchives(m_openArchivesAsFolder->isChecked());
settings->setAutoExpandFolders(m_autoExpandFolders->isChecked());
- settings->writeConfig();
+ settings->save();
}
void NavigationSettingsPage::restoreDefaults()
@@ -99,20 +75,11 @@ void NavigationSettingsPage::restoreDefaults()
settings->useDefaults(true);
loadSettings();
settings->useDefaults(false);
-
- // The mouse settings stored in KGlobalSettings must be reset to
- // the default values (= single click) manually.
- m_singleClick->setChecked(true);
- m_doubleClick->setChecked(false);
}
void NavigationSettingsPage::loadSettings()
{
- const bool singleClick = KGlobalSettings::singleClick();
- m_singleClick->setChecked(singleClick);
- m_doubleClick->setChecked(!singleClick);
m_openArchivesAsFolder->setChecked(GeneralSettings::browseThroughArchives());
m_autoExpandFolders->setChecked(GeneralSettings::autoExpandFolders());
}
-#include "navigationsettingspage.moc"
diff --git a/src/settings/navigation/navigationsettingspage.h b/src/settings/navigation/navigationsettingspage.h
index 7d5b981d4..5410a4efa 100644
--- a/src/settings/navigation/navigationsettingspage.h
+++ b/src/settings/navigation/navigationsettingspage.h
@@ -22,7 +22,6 @@
#include <settings/settingspagebase.h>
class QCheckBox;
-class QRadioButton;
/**
* @brief Page for the 'Navigation' settings of the Dolphin settings dialog.
@@ -36,17 +35,15 @@ public:
virtual ~NavigationSettingsPage();
/** @see SettingsPageBase::applySettings() */
- virtual void applySettings();
+ virtual void applySettings() Q_DECL_OVERRIDE;
/** @see SettingsPageBase::restoreDefaults() */
- virtual void restoreDefaults();
+ virtual void restoreDefaults() Q_DECL_OVERRIDE;
private:
void loadSettings();
private:
- QRadioButton* m_singleClick;
- QRadioButton* m_doubleClick;
QCheckBox* m_openArchivesAsFolder;
QCheckBox* m_autoExpandFolders;
};
diff --git a/src/settings/serviceitemdelegate.cpp b/src/settings/serviceitemdelegate.cpp
index 7538e038b..a72dd9ec8 100644
--- a/src/settings/serviceitemdelegate.cpp
+++ b/src/settings/serviceitemdelegate.cpp
@@ -19,9 +19,9 @@
#include "serviceitemdelegate.h"
-#include <KDebug>
-#include <KPushButton>
-#include <KIcon>
+#include "dolphindebug.h"
+#include <QPushButton>
+#include <QIcon>
#include "servicemodel.h"
@@ -66,18 +66,18 @@ void ServiceItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& o
painter->restore();
}
-QList<QWidget*> ServiceItemDelegate::createItemWidgets() const
+QList<QWidget*> ServiceItemDelegate::createItemWidgets(const QModelIndex&) const
{
QCheckBox* checkBox = new QCheckBox();
QPalette palette = checkBox->palette();
palette.setColor(QPalette::WindowText, palette.color(QPalette::Text));
checkBox->setPalette(palette);
- connect(checkBox, SIGNAL(clicked(bool)), this, SLOT(slotCheckBoxClicked(bool)));
+ connect(checkBox, &QCheckBox::clicked, this, &ServiceItemDelegate::slotCheckBoxClicked);
- KPushButton* configureButton = new KPushButton();
- connect(configureButton, SIGNAL(clicked()), this, SLOT(slotConfigureButtonClicked()));
+ QPushButton* configureButton = new QPushButton();
+ connect(configureButton, &QPushButton::clicked, this, &ServiceItemDelegate::slotConfigureButtonClicked);
- return QList<QWidget*>() << checkBox << configureButton;
+ return {checkBox, configureButton};
}
void ServiceItemDelegate::updateItemWidgets(const QList<QWidget*> widgets,
@@ -85,7 +85,7 @@ void ServiceItemDelegate::updateItemWidgets(const QList<QWidget*> widgets,
const QPersistentModelIndex& index) const
{
QCheckBox* checkBox = static_cast<QCheckBox*>(widgets[0]);
- KPushButton *configureButton = static_cast<KPushButton*>(widgets[1]);
+ QPushButton *configureButton = static_cast<QPushButton*>(widgets[1]);
const int itemHeight = sizeHint(option, index).height();
@@ -94,7 +94,7 @@ void ServiceItemDelegate::updateItemWidgets(const QList<QWidget*> widgets,
checkBox->setText(model->data(index).toString());
const QString iconName = model->data(index, Qt::DecorationRole).toString();
if (!iconName.isEmpty()) {
- checkBox->setIcon(KIcon(iconName));
+ checkBox->setIcon(QIcon::fromTheme(iconName));
}
checkBox->setChecked(model->data(index, Qt::CheckStateRole).toBool());
@@ -110,7 +110,7 @@ void ServiceItemDelegate::updateItemWidgets(const QList<QWidget*> widgets,
// Update the configuration button
if (configurable) {
configureButton->setEnabled(checkBox->isChecked());
- configureButton->setIcon(KIcon("configure"));
+ configureButton->setIcon(QIcon::fromTheme("configure"));
configureButton->resize(configureButton->sizeHint());
configureButton->move(option.rect.right() - configureButton->width(),
(itemHeight - configureButton->height()) / 2);
@@ -129,4 +129,3 @@ void ServiceItemDelegate::slotConfigureButtonClicked()
emit requestServiceConfiguration(focusedIndex());
}
-#include "serviceitemdelegate.moc"
diff --git a/src/settings/serviceitemdelegate.h b/src/settings/serviceitemdelegate.h
index ea9681a5a..9f0ced40c 100644
--- a/src/settings/serviceitemdelegate.h
+++ b/src/settings/serviceitemdelegate.h
@@ -37,16 +37,16 @@ public:
virtual ~ServiceItemDelegate();
virtual QSize sizeHint(const QStyleOptionViewItem &option,
- const QModelIndex &index) const;
+ const QModelIndex &index) const Q_DECL_OVERRIDE;
virtual void paint(QPainter* painter, const QStyleOptionViewItem& option,
- const QModelIndex& index) const;
+ const QModelIndex& index) const Q_DECL_OVERRIDE;
- virtual QList<QWidget*> createItemWidgets() const;
+ virtual QList<QWidget*> createItemWidgets(const QModelIndex&) const Q_DECL_OVERRIDE;
virtual void updateItemWidgets(const QList<QWidget*> widgets,
const QStyleOptionViewItem& option,
- const QPersistentModelIndex& index) const;
+ const QPersistentModelIndex& index) const Q_DECL_OVERRIDE;
signals:
void requestServiceConfiguration(const QModelIndex& index);
diff --git a/src/settings/servicemodel.cpp b/src/settings/servicemodel.cpp
index 315b90dff..e3b015147 100644
--- a/src/settings/servicemodel.cpp
+++ b/src/settings/servicemodel.cpp
@@ -105,4 +105,3 @@ int ServiceModel::rowCount(const QModelIndex& parent) const
return m_items.count();
}
-#include "servicemodel.moc"
diff --git a/src/settings/servicemodel.h b/src/settings/servicemodel.h
index b8c2d5248..f2b91c7e4 100644
--- a/src/settings/servicemodel.h
+++ b/src/settings/servicemodel.h
@@ -47,10 +47,10 @@ public:
explicit ServiceModel(QObject* parent = 0);
virtual ~ServiceModel();
- virtual bool insertRows(int row, int count, const QModelIndex & parent = QModelIndex());
- virtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
- virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
- virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;
+ virtual bool insertRows(int row, int count, const QModelIndex & parent = QModelIndex()) Q_DECL_OVERRIDE;
+ virtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) Q_DECL_OVERRIDE;
+ virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
+ virtual int rowCount(const QModelIndex& parent = QModelIndex()) const Q_DECL_OVERRIDE;
private:
struct ServiceItem
diff --git a/src/settings/services/servicessettingspage.cpp b/src/settings/services/servicessettingspage.cpp
index 48e816be7..f258b53e2 100644
--- a/src/settings/services/servicessettingspage.cpp
+++ b/src/settings/services/servicessettingspage.cpp
@@ -26,13 +26,13 @@
#include <KConfigGroup>
#include <KDesktopFile>
#include <kdesktopfileactions.h>
-#include <KIcon>
-#include <KLocale>
+#include <QIcon>
+#include <KLocalizedString>
#include <KMessageBox>
-#include <knewstuff3/knewstuffbutton.h>
+#include <KNS3/Button>
#include <KService>
#include <KServiceTypeTrader>
-#include <KStandardDirs>
+#include <QStandardPaths>
#include <settings/serviceitemdelegate.h>
#include <settings/servicemodel.h>
@@ -49,9 +49,9 @@
namespace
{
const bool ShowDeleteDefault = false;
- const char* VersionControlServicePrefix = "_version_control_";
- const char* DeleteService = "_delete";
- const char* CopyToMoveToService ="_copy_to_move_to";
+ const char VersionControlServicePrefix[] = "_version_control_";
+ const char DeleteService[] = "_delete";
+ const char CopyToMoveToService[] ="_copy_to_move_to";
}
ServicesSettingsPage::ServicesSettingsPage(QWidget* parent) :
@@ -78,12 +78,12 @@ ServicesSettingsPage::ServicesSettingsPage(QWidget* parent) :
m_listView->setModel(m_sortModel);
m_listView->setItemDelegate(delegate);
m_listView->setVerticalScrollMode(QListView::ScrollPerPixel);
- connect(m_listView, SIGNAL(clicked(QModelIndex)), this, SIGNAL(changed()));
+ connect(m_listView, &QListView::clicked, this, &ServicesSettingsPage::changed);
KNS3::Button* downloadButton = new KNS3::Button(i18nc("@action:button", "Download New Services..."),
"servicemenu.knsrc",
this);
- connect(downloadButton, SIGNAL(dialogFinished(KNS3::Entry::List)), this, SLOT(loadServices()));
+ connect(downloadButton, &KNS3::Button::dialogFinished, this, &ServicesSettingsPage::loadServices);
topLayout->addWidget(label);
topLayout->addWidget(m_listView);
@@ -125,7 +125,7 @@ void ServicesSettingsPage::applySettings()
configGroup.sync();
} else if (service == QLatin1String(CopyToMoveToService)) {
GeneralSettings::setShowCopyMoveMenu(checked);
- GeneralSettings::self()->writeConfig();
+ GeneralSettings::self()->save();
} else {
showGroup.writeEntry(service, checked);
}
@@ -135,7 +135,7 @@ void ServicesSettingsPage::applySettings()
if (m_enabledVcsPlugins != enabledPlugins) {
VersionControlSettings::setEnabledPlugins(enabledPlugins);
- VersionControlSettings::self()->writeConfig();
+ VersionControlSettings::self()->save();
KMessageBox::information(window(),
i18nc("@info", "Dolphin must be restarted to apply the "
@@ -194,8 +194,8 @@ void ServicesSettingsPage::loadServices()
// Load generic services
const KService::List entries = KServiceTypeTrader::self()->query("KonqPopupMenu/Plugin");
- foreach (const KSharedPtr<KService>& service, entries) {
- const QString file = KStandardDirs::locate("services", service->entryPath());
+ foreach (const KService::Ptr& service, entries) {
+ const QString file = QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kservices5/" % service->entryPath());
const QList<KServiceAction> serviceActions =
KDesktopFileActions::userDefinedServices(file, true);
@@ -220,7 +220,7 @@ void ServicesSettingsPage::loadServices()
// Load service plugins that implement the KFileItemActionPlugin interface
const KService::List pluginServices = KServiceTypeTrader::self()->query("KFileItemAction/Plugin");
- foreach (const KSharedPtr<KService>& service, pluginServices) {
+ foreach (const KService::Ptr& service, pluginServices) {
const QString desktopEntryName = service->desktopEntryName();
if (!isInServicesList(desktopEntryName)) {
const bool checked = showGroup.readEntry(desktopEntryName, true);
@@ -273,4 +273,3 @@ void ServicesSettingsPage::addRow(const QString& icon,
m_serviceModel->setData(index, checked, Qt::CheckStateRole);
}
-#include "servicessettingspage.moc"
diff --git a/src/settings/services/servicessettingspage.h b/src/settings/services/servicessettingspage.h
index 80af42f88..a883aa947 100644
--- a/src/settings/services/servicessettingspage.h
+++ b/src/settings/services/servicessettingspage.h
@@ -21,11 +21,8 @@
#include <settings/settingspagebase.h>
-#include <QMap>
#include <QString>
-class QCheckBox;
-class QGroupBox;
class QListView;
class QSortFilterProxyModel;
class ServiceModel;
@@ -42,13 +39,13 @@ public:
virtual ~ServicesSettingsPage();
/** @see SettingsPageBase::applySettings() */
- virtual void applySettings();
+ virtual void applySettings() Q_DECL_OVERRIDE;
/** @see SettingsPageBase::restoreDefaults() */
- virtual void restoreDefaults();
+ virtual void restoreDefaults() Q_DECL_OVERRIDE;
protected:
- virtual void showEvent(QShowEvent* event);
+ virtual void showEvent(QShowEvent* event) Q_DECL_OVERRIDE;
private slots:
/**
diff --git a/src/settings/settingspagebase.cpp b/src/settings/settingspagebase.cpp
index 6f8dcbfb6..70549fd2c 100644
--- a/src/settings/settingspagebase.cpp
+++ b/src/settings/settingspagebase.cpp
@@ -28,4 +28,3 @@ SettingsPageBase::~SettingsPageBase()
{}
-#include "settingspagebase.moc"
diff --git a/src/settings/startup/startupsettingspage.cpp b/src/settings/startup/startupsettingspage.cpp
index 693826318..21b213cd5 100644
--- a/src/settings/startup/startupsettingspage.cpp
+++ b/src/settings/startup/startupsettingspage.cpp
@@ -24,22 +24,22 @@
#include "dolphin_generalsettings.h"
-#include <KDialog>
-#include <KFileDialog>
-#include <KLocale>
-#include <KLineEdit>
+#include <KLocalizedString>
+#include <QLineEdit>
#include <KMessageBox>
-#include <KVBox>
+#include <QVBoxLayout>
#include <QCheckBox>
#include <QGroupBox>
#include <QLabel>
#include <QPushButton>
-#include <QRadioButton>
+#include <QHBoxLayout>
+#include <QVBoxLayout>
+#include <QFileDialog>
#include "views/dolphinview.h"
-StartupSettingsPage::StartupSettingsPage(const KUrl& url, QWidget* parent) :
+StartupSettingsPage::StartupSettingsPage(const QUrl& url, QWidget* parent) :
SettingsPageBase(parent),
m_url(url),
m_homeUrl(0),
@@ -48,40 +48,48 @@ StartupSettingsPage::StartupSettingsPage(const KUrl& url, QWidget* parent) :
m_showFullPath(0),
m_filterBar(0)
{
- const int spacing = KDialog::spacingHint();
-
QVBoxLayout* topLayout = new QVBoxLayout(this);
- KVBox* vBox = new KVBox(this);
- vBox->setSpacing(spacing);
+ QWidget* vBox = new QWidget(this);
+ QVBoxLayout *vBoxLayout = new QVBoxLayout(vBox);
+ vBoxLayout->setMargin(0);
+ vBoxLayout->setAlignment(Qt::AlignTop);
// create 'Home URL' editor
QGroupBox* homeBox = new QGroupBox(i18nc("@title:group", "Home Folder"), vBox);
+ vBoxLayout->addWidget(homeBox);
- KHBox* homeUrlBox = new KHBox(homeBox);
- homeUrlBox->setSpacing(spacing);
+ QWidget* homeUrlBox = new QWidget(homeBox);
+ QHBoxLayout *homeUrlBoxLayout = new QHBoxLayout(homeUrlBox);
+ homeUrlBoxLayout->setMargin(0);
- new QLabel(i18nc("@label:textbox", "Location:"), homeUrlBox);
- m_homeUrl = new KLineEdit(homeUrlBox);
- m_homeUrl->setClearButtonShown(true);
+ QLabel* homeUrlLabel = new QLabel(i18nc("@label:textbox", "Location:"), homeUrlBox);
+ homeUrlBoxLayout->addWidget(homeUrlLabel);
+ m_homeUrl = new QLineEdit(homeUrlBox);
+ homeUrlBoxLayout->addWidget(m_homeUrl);
+ m_homeUrl->setClearButtonEnabled(true);
- QPushButton* selectHomeUrlButton = new QPushButton(KIcon("folder-open"), QString(), homeUrlBox);
+ QPushButton* selectHomeUrlButton = new QPushButton(QIcon::fromTheme("folder-open"), QString(), homeUrlBox);
+ homeUrlBoxLayout->addWidget(selectHomeUrlButton);
#ifndef QT_NO_ACCESSIBILITY
selectHomeUrlButton->setAccessibleName(i18nc("@action:button", "Select Home Location"));
#endif
- connect(selectHomeUrlButton, SIGNAL(clicked()),
- this, SLOT(selectHomeUrl()));
+ connect(selectHomeUrlButton, &QPushButton::clicked,
+ this, &StartupSettingsPage::selectHomeUrl);
- KHBox* buttonBox = new KHBox(homeBox);
- buttonBox->setSpacing(spacing);
+ QWidget* buttonBox = new QWidget(homeBox);
+ QHBoxLayout *buttonBoxLayout = new QHBoxLayout(buttonBox);
+ buttonBoxLayout->setMargin(0);
QPushButton* useCurrentButton = new QPushButton(i18nc("@action:button", "Use Current Location"), buttonBox);
- connect(useCurrentButton, SIGNAL(clicked()),
- this, SLOT(useCurrentLocation()));
+ buttonBoxLayout->addWidget(useCurrentButton);
+ connect(useCurrentButton, &QPushButton::clicked,
+ this, &StartupSettingsPage::useCurrentLocation);
QPushButton* useDefaultButton = new QPushButton(i18nc("@action:button", "Use Default Location"), buttonBox);
- connect(useDefaultButton, SIGNAL(clicked()),
- this, SLOT(useDefaultLocation()));
+ buttonBoxLayout->addWidget(useDefaultButton);
+ connect(useDefaultButton, &QPushButton::clicked,
+ this, &StartupSettingsPage::useDefaultLocation);
QVBoxLayout* homeBoxLayout = new QVBoxLayout(homeBox);
homeBoxLayout->addWidget(homeUrlBox);
@@ -89,9 +97,13 @@ StartupSettingsPage::StartupSettingsPage(const KUrl& url, QWidget* parent) :
// create 'Split view', 'Show full path', 'Editable location' and 'Filter bar' checkboxes
m_splitView = new QCheckBox(i18nc("@option:check Startup Settings", "Split view mode"), vBox);
+ vBoxLayout->addWidget(m_splitView);
m_editableUrl = new QCheckBox(i18nc("@option:check Startup Settings", "Editable location bar"), vBox);
+ vBoxLayout->addWidget(m_editableUrl);
m_showFullPath = new QCheckBox(i18nc("@option:check Startup Settings", "Show full path inside location bar"), vBox);
+ vBoxLayout->addWidget(m_showFullPath);
m_filterBar = new QCheckBox(i18nc("@option:check Startup Settings", "Show filter bar"), vBox);
+ vBoxLayout->addWidget(m_filterBar);
// Add a dummy widget with no restriction regarding
// a vertical resizing. This assures that the dialog layout
@@ -102,11 +114,11 @@ StartupSettingsPage::StartupSettingsPage(const KUrl& url, QWidget* parent) :
loadSettings();
- connect(m_homeUrl, SIGNAL(textChanged(QString)), this, SLOT(slotSettingsChanged()));
- connect(m_splitView, SIGNAL(toggled(bool)), this, SLOT(slotSettingsChanged()));
- connect(m_editableUrl, SIGNAL(toggled(bool)), this, SLOT(slotSettingsChanged()));
- connect(m_showFullPath, SIGNAL(toggled(bool)), this, SLOT(slotSettingsChanged()));
- connect(m_filterBar, SIGNAL(toggled(bool)), this, SLOT(slotSettingsChanged()));
+ connect(m_homeUrl, &QLineEdit::textChanged, this, &StartupSettingsPage::slotSettingsChanged);
+ connect(m_splitView, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged);
+ connect(m_editableUrl, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged);
+ connect(m_showFullPath, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged);
+ connect(m_filterBar, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged);
}
StartupSettingsPage::~StartupSettingsPage()
@@ -117,10 +129,10 @@ void StartupSettingsPage::applySettings()
{
GeneralSettings* settings = GeneralSettings::self();
- const KUrl url(m_homeUrl->text());
- KFileItem fileItem(KFileItem::Unknown, KFileItem::Unknown, url);
- if ((url.isValid() && fileItem.isDir()) || (url.protocol() == QLatin1String("timeline"))) {
- settings->setHomeUrl(url.prettyUrl());
+ const QUrl url(QUrl::fromLocalFile(m_homeUrl->text()));
+ KFileItem fileItem(url);
+ if ((url.isValid() && fileItem.isDir()) || (url.scheme() == QLatin1String("timeline"))) {
+ settings->setHomeUrl(url.toDisplayString(QUrl::PreferLocalFile));
} else {
KMessageBox::error(this, i18nc("@info", "The location for the home folder is invalid or does not exist, it will not be applied."));
}
@@ -130,7 +142,7 @@ void StartupSettingsPage::applySettings()
settings->setShowFullPath(m_showFullPath->isChecked());
settings->setFilterBar(m_filterBar->isChecked());
- settings->writeConfig();
+ settings->save();
}
void StartupSettingsPage::restoreDefaults()
@@ -153,32 +165,29 @@ void StartupSettingsPage::slotSettingsChanged()
void StartupSettingsPage::selectHomeUrl()
{
const QString homeUrl = m_homeUrl->text();
- KUrl url = KFileDialog::getExistingDirectoryUrl(homeUrl, this);
+ QUrl url = QFileDialog::getExistingDirectoryUrl(this, QString(), QUrl::fromLocalFile(homeUrl));
if (!url.isEmpty()) {
- m_homeUrl->setText(url.prettyUrl());
+ m_homeUrl->setText(url.toDisplayString(QUrl::PreferLocalFile));
slotSettingsChanged();
}
}
void StartupSettingsPage::useCurrentLocation()
{
- m_homeUrl->setText(m_url.prettyUrl());
+ m_homeUrl->setText(m_url.toDisplayString(QUrl::PreferLocalFile));
}
void StartupSettingsPage::useDefaultLocation()
{
- KUrl url(QDir::homePath());
- m_homeUrl->setText(url.prettyUrl());
+ m_homeUrl->setText(QDir::homePath());
}
void StartupSettingsPage::loadSettings()
{
- const KUrl url(GeneralSettings::homeUrl());
- m_homeUrl->setText(url.prettyUrl());
+ const QUrl url(QUrl::fromLocalFile(GeneralSettings::homeUrl()));
+ m_homeUrl->setText(url.toDisplayString(QUrl::PreferLocalFile));
m_splitView->setChecked(GeneralSettings::splitView());
m_editableUrl->setChecked(GeneralSettings::editableUrl());
m_showFullPath->setChecked(GeneralSettings::showFullPath());
m_filterBar->setChecked(GeneralSettings::filterBar());
}
-
-#include "startupsettingspage.moc"
diff --git a/src/settings/startup/startupsettingspage.h b/src/settings/startup/startupsettingspage.h
index 29cdc6300..9bcc31131 100644
--- a/src/settings/startup/startupsettingspage.h
+++ b/src/settings/startup/startupsettingspage.h
@@ -20,9 +20,9 @@
#define STARTUPSETTINGSPAGE_H
#include <settings/settingspagebase.h>
-#include <KUrl>
+#include <QUrl>
-class KLineEdit;
+class QLineEdit;
class QCheckBox;
/**
@@ -36,14 +36,14 @@ class StartupSettingsPage : public SettingsPageBase
Q_OBJECT
public:
- StartupSettingsPage(const KUrl& url, QWidget* parent);
+ StartupSettingsPage(const QUrl& url, QWidget* parent);
virtual ~StartupSettingsPage();
/** @see SettingsPageBase::applySettings() */
- virtual void applySettings();
+ virtual void applySettings() Q_DECL_OVERRIDE;
/** @see SettingsPageBase::restoreDefaults() */
- virtual void restoreDefaults();
+ virtual void restoreDefaults() Q_DECL_OVERRIDE;
private slots:
void slotSettingsChanged();
@@ -55,8 +55,8 @@ private:
void loadSettings();
private:
- KUrl m_url;
- KLineEdit* m_homeUrl;
+ QUrl m_url;
+ QLineEdit* m_homeUrl;
QCheckBox* m_splitView;
QCheckBox* m_editableUrl;
diff --git a/src/settings/trash/trashsettingspage.cpp b/src/settings/trash/trashsettingspage.cpp
index cd699856c..237a17987 100644
--- a/src/settings/trash/trashsettingspage.cpp
+++ b/src/settings/trash/trashsettingspage.cpp
@@ -20,19 +20,16 @@
#include "trashsettingspage.h"
#include <KCModuleProxy>
-#include <KDialog>
-#include <KVBox>
#include <QVBoxLayout>
TrashSettingsPage::TrashSettingsPage(QWidget* parent) :
SettingsPageBase(parent)
{
- const int spacing = KDialog::spacingHint();
-
QVBoxLayout* topLayout = new QVBoxLayout(this);
- KVBox* vBox = new KVBox(this);
- vBox->setSpacing(spacing);
+ QWidget* vBox = new QWidget(this);
+ QVBoxLayout *vBoxVBoxLayout = new QVBoxLayout(vBox);
+ vBoxVBoxLayout->setMargin(0);
m_proxy = new KCModuleProxy("kcmtrash");
topLayout->addWidget(m_proxy);
@@ -40,12 +37,14 @@ TrashSettingsPage::TrashSettingsPage(QWidget* parent) :
// Add a dummy widget with no restriction regarding
// a vertical resizing. This assures that the dialog layout
// is not stretched vertically.
- new QWidget(vBox);
+ QWidget *w = new QWidget(vBox);
+ vBoxVBoxLayout->addWidget(w);
+
topLayout->addWidget(vBox);
loadSettings();
- connect(m_proxy, SIGNAL(changed(bool)), this, SIGNAL(changed()));
+ connect(m_proxy, static_cast<void(KCModuleProxy::*)(bool)>(&KCModuleProxy::changed), this, &TrashSettingsPage::changed);
}
TrashSettingsPage::~TrashSettingsPage()
@@ -67,4 +66,3 @@ void TrashSettingsPage::loadSettings()
m_proxy->load();
}
-#include "trashsettingspage.moc"
diff --git a/src/settings/trash/trashsettingspage.h b/src/settings/trash/trashsettingspage.h
index bf4a71ea4..5c88aeab7 100644
--- a/src/settings/trash/trashsettingspage.h
+++ b/src/settings/trash/trashsettingspage.h
@@ -34,10 +34,10 @@ public:
virtual ~TrashSettingsPage();
/** @see SettingsPageBase::applySettings() */
- virtual void applySettings();
+ virtual void applySettings() Q_DECL_OVERRIDE;
/** @see SettingsPageBase::restoreDefaults() */
- virtual void restoreDefaults();
+ virtual void restoreDefaults() Q_DECL_OVERRIDE;
private:
void loadSettings();
diff --git a/src/settings/viewmodes/dolphinfontrequester.cpp b/src/settings/viewmodes/dolphinfontrequester.cpp
index 6cb7b9929..b9c5d97cf 100644
--- a/src/settings/viewmodes/dolphinfontrequester.cpp
+++ b/src/settings/viewmodes/dolphinfontrequester.cpp
@@ -19,14 +19,13 @@
#include "dolphinfontrequester.h"
-#include <KFontDialog>
-#include <KGlobalSettings>
-#include <KLocale>
+#include <KLocalizedString>
#include <KComboBox>
-#include <QEvent>
#include <QHBoxLayout>
#include <QPushButton>
+#include <QFontDatabase>
+#include <QFontDialog>
DolphinFontRequester::DolphinFontRequester(QWidget* parent) :
QWidget(parent),
@@ -41,12 +40,12 @@ DolphinFontRequester::DolphinFontRequester(QWidget* parent) :
m_modeCombo = new KComboBox(this);
m_modeCombo->addItem(i18nc("@item:inlistbox Font", "System Font"));
m_modeCombo->addItem(i18nc("@item:inlistbox Font", "Custom Font"));
- connect(m_modeCombo, SIGNAL(activated(int)),
- this, SLOT(changeMode(int)));
+ connect(m_modeCombo, static_cast<void(KComboBox::*)(int)>(&KComboBox::activated),
+ this, &DolphinFontRequester::changeMode);
m_chooseFontButton = new QPushButton(i18nc("@action:button Choose font", "Choose..."), this);
- connect(m_chooseFontButton, SIGNAL(clicked()),
- this, SLOT(openFontDialog()));
+ connect(m_chooseFontButton, &QPushButton::clicked,
+ this, &DolphinFontRequester::openFontDialog);
changeMode(m_modeCombo->currentIndex());
@@ -72,7 +71,7 @@ DolphinFontRequester::Mode DolphinFontRequester::mode() const
QFont DolphinFontRequester::currentFont() const
{
- return (m_mode == CustomFont) ? m_customFont : KGlobalSettings::generalFont();
+ return (m_mode == CustomFont) ? m_customFont : QFontDatabase::systemFont(QFontDatabase::GeneralFont);
}
void DolphinFontRequester::setCustomFont(const QFont& font)
@@ -87,11 +86,9 @@ QFont DolphinFontRequester::customFont() const
void DolphinFontRequester::openFontDialog()
{
- QFont font = m_customFont;
- const int result = KFontDialog::getFont(font,
- KFontChooser::NoDisplayFlags,
- this);
- if (result == KFontDialog::Accepted) {
+ bool ok = false;
+ const QFont font = QFontDialog::getFont(&ok, this);
+ if (ok) {
m_customFont = font;
m_modeCombo->setFont(m_customFont);
emit changed();
@@ -104,4 +101,3 @@ void DolphinFontRequester::changeMode(int index)
emit changed();
}
-#include "dolphinfontrequester.moc"
diff --git a/src/settings/viewmodes/viewmodesettings.cpp b/src/settings/viewmodes/viewmodesettings.cpp
index 5b9334c22..2191b76fe 100644
--- a/src/settings/viewmodes/viewmodesettings.cpp
+++ b/src/settings/viewmodes/viewmodesettings.cpp
@@ -125,19 +125,19 @@ int ViewModeSettings::fontWeight() const
void ViewModeSettings::readConfig()
{
switch (m_mode) {
- case ViewModeSettings::IconsMode: IconsModeSettings::self()->readConfig(); break;
- case ViewModeSettings::CompactMode: CompactModeSettings::self()->readConfig(); break;
- case ViewModeSettings::DetailsMode: DetailsModeSettings::self()->readConfig(); break;
+ case ViewModeSettings::IconsMode: IconsModeSettings::self()->load(); break;
+ case ViewModeSettings::CompactMode: CompactModeSettings::self()->load(); break;
+ case ViewModeSettings::DetailsMode: DetailsModeSettings::self()->load(); break;
default: Q_ASSERT(false); break;
}
}
-void ViewModeSettings::writeConfig()
+void ViewModeSettings::save()
{
switch (m_mode) {
- case ViewModeSettings::IconsMode: IconsModeSettings::self()->writeConfig(); break;
- case ViewModeSettings::CompactMode: CompactModeSettings::self()->writeConfig(); break;
- case ViewModeSettings::DetailsMode: DetailsModeSettings::self()->writeConfig(); break;
+ case ViewModeSettings::IconsMode: IconsModeSettings::self()->save(); break;
+ case ViewModeSettings::CompactMode: CompactModeSettings::self()->save(); break;
+ case ViewModeSettings::DetailsMode: DetailsModeSettings::self()->save(); break;
default: Q_ASSERT(false); break;
}
}
diff --git a/src/settings/viewmodes/viewmodesettings.h b/src/settings/viewmodes/viewmodesettings.h
index be41ae284..9f0b44e9b 100644
--- a/src/settings/viewmodes/viewmodesettings.h
+++ b/src/settings/viewmodes/viewmodesettings.h
@@ -61,7 +61,7 @@ public:
int fontWeight() const;
void readConfig();
- void writeConfig();
+ void save();
private:
ViewMode m_mode;
diff --git a/src/settings/viewmodes/viewsettingspage.cpp b/src/settings/viewmodes/viewsettingspage.cpp
index 4f8a3f00d..21bb1e178 100644
--- a/src/settings/viewmodes/viewsettingspage.cpp
+++ b/src/settings/viewmodes/viewsettingspage.cpp
@@ -24,11 +24,9 @@
#include "viewsettingstab.h"
#include <QVBoxLayout>
+#include <QTabWidget>
-#include <KDialog>
-#include <KLocale>
-#include <KIconLoader>
-#include <KTabWidget>
+#include <KLocalizedString>
ViewSettingsPage::ViewSettingsPage(QWidget* parent) :
SettingsPageBase(parent),
@@ -36,24 +34,23 @@ ViewSettingsPage::ViewSettingsPage(QWidget* parent) :
{
QVBoxLayout* topLayout = new QVBoxLayout(this);
topLayout->setMargin(0);
- topLayout->setSpacing(KDialog::spacingHint());
- KTabWidget* tabWidget = new KTabWidget(this);
+ QTabWidget* tabWidget = new QTabWidget(this);
// Initialize 'Icons' tab
ViewSettingsTab* iconsTab = new ViewSettingsTab(ViewSettingsTab::IconsMode, tabWidget);
- tabWidget->addTab(iconsTab, KIcon("view-list-icons"), i18nc("@title:tab", "Icons"));
- connect(iconsTab, SIGNAL(changed()), this, SIGNAL(changed()));
+ tabWidget->addTab(iconsTab, QIcon::fromTheme("view-list-icons"), i18nc("@title:tab", "Icons"));
+ connect(iconsTab, &ViewSettingsTab::changed, this, &ViewSettingsPage::changed);
// Initialize 'Compact' tab
ViewSettingsTab* compactTab = new ViewSettingsTab(ViewSettingsTab::CompactMode, tabWidget);
- tabWidget->addTab(compactTab, KIcon("view-list-details"), i18nc("@title:tab", "Compact"));
- connect(compactTab, SIGNAL(changed()), this, SIGNAL(changed()));
+ tabWidget->addTab(compactTab, QIcon::fromTheme("view-list-details"), i18nc("@title:tab", "Compact"));
+ connect(compactTab, &ViewSettingsTab::changed, this, &ViewSettingsPage::changed);
// Initialize 'Details' tab
ViewSettingsTab* detailsTab = new ViewSettingsTab(ViewSettingsTab::DetailsMode, tabWidget);
- tabWidget->addTab(detailsTab, KIcon("view-list-tree"), i18nc("@title:tab", "Details"));
- connect(detailsTab, SIGNAL(changed()), this, SIGNAL(changed()));
+ tabWidget->addTab(detailsTab, QIcon::fromTheme("view-list-tree"), i18nc("@title:tab", "Details"));
+ connect(detailsTab, &ViewSettingsTab::changed, this, &ViewSettingsPage::changed);
m_tabs.append(iconsTab);
m_tabs.append(compactTab);
@@ -80,4 +77,3 @@ void ViewSettingsPage::restoreDefaults()
}
}
-#include "viewsettingspage.moc"
diff --git a/src/settings/viewmodes/viewsettingspage.h b/src/settings/viewmodes/viewsettingspage.h
index 446403182..61671077e 100644
--- a/src/settings/viewmodes/viewsettingspage.h
+++ b/src/settings/viewmodes/viewsettingspage.h
@@ -40,10 +40,10 @@ public:
virtual ~ViewSettingsPage();
/** @see SettingsPageBase::applySettings() */
- virtual void applySettings();
+ virtual void applySettings() Q_DECL_OVERRIDE;
/** @see SettingsPageBase::restoreDefaults() */
- virtual void restoreDefaults();
+ virtual void restoreDefaults() Q_DECL_OVERRIDE;
private:
QList<ViewSettingsTab*> m_tabs;
diff --git a/src/settings/viewmodes/viewsettingstab.cpp b/src/settings/viewmodes/viewsettingstab.cpp
index bc124516d..632ae99da 100644
--- a/src/settings/viewmodes/viewsettingstab.cpp
+++ b/src/settings/viewmodes/viewsettingstab.cpp
@@ -25,7 +25,7 @@
#include "dolphin_iconsmodesettings.h"
#include <KComboBox>
-#include <KLocale>
+#include <KLocalizedString>
#include <QCheckBox>
#include <QGroupBox>
@@ -61,16 +61,16 @@ ViewSettingsTab::ViewSettingsTab(Mode mode, QWidget* parent) :
m_defaultSizeSlider->setPageStep(1);
m_defaultSizeSlider->setTickPosition(QSlider::TicksBelow);
m_defaultSizeSlider->setRange(minRange, maxRange);
- connect(m_defaultSizeSlider, SIGNAL(valueChanged(int)),
- this, SLOT(slotDefaultSliderMoved(int)));
+ connect(m_defaultSizeSlider, &QSlider::valueChanged,
+ this, &ViewSettingsTab::slotDefaultSliderMoved);
QLabel* previewLabel = new QLabel(i18nc("@label:listbox", "Preview:"), this);
m_previewSizeSlider = new QSlider(Qt::Horizontal, this);
m_previewSizeSlider->setPageStep(1);
m_previewSizeSlider->setTickPosition(QSlider::TicksBelow);
m_previewSizeSlider->setRange(minRange, maxRange);
- connect(m_previewSizeSlider, SIGNAL(valueChanged(int)),
- this, SLOT(slotPreviewSliderMoved(int)));
+ connect(m_previewSizeSlider, &QSlider::valueChanged,
+ this, &ViewSettingsTab::slotPreviewSliderMoved);
QGridLayout* layout = new QGridLayout(iconSizeGroup);
layout->addWidget(defaultLabel, 0, 0, Qt::AlignRight);
@@ -138,20 +138,20 @@ ViewSettingsTab::ViewSettingsTab(Mode mode, QWidget* parent) :
loadSettings();
- connect(m_defaultSizeSlider, SIGNAL(valueChanged(int)), this, SIGNAL(changed()));
- connect(m_previewSizeSlider, SIGNAL(valueChanged(int)), this, SIGNAL(changed()));
- connect(m_fontRequester, SIGNAL(changed()), this, SIGNAL(changed()));
+ connect(m_defaultSizeSlider, &QSlider::valueChanged, this, &ViewSettingsTab::changed);
+ connect(m_previewSizeSlider, &QSlider::valueChanged, this, &ViewSettingsTab::changed);
+ connect(m_fontRequester, &DolphinFontRequester::changed, this, &ViewSettingsTab::changed);
switch (m_mode) {
case IconsMode:
- connect(m_widthBox, SIGNAL(currentIndexChanged(int)), this, SIGNAL(changed()));
- connect(m_maxLinesBox, SIGNAL(currentIndexChanged(int)), this, SIGNAL(changed()));
+ connect(m_widthBox, static_cast<void(KComboBox::*)(int)>(&KComboBox::currentIndexChanged), this, &ViewSettingsTab::changed);
+ connect(m_maxLinesBox, static_cast<void(KComboBox::*)(int)>(&KComboBox::currentIndexChanged), this, &ViewSettingsTab::changed);
break;
case CompactMode:
- connect(m_widthBox, SIGNAL(currentIndexChanged(int)), this, SIGNAL(changed()));
+ connect(m_widthBox, static_cast<void(KComboBox::*)(int)>(&KComboBox::currentIndexChanged), this, &ViewSettingsTab::changed);
break;
case DetailsMode:
- connect(m_expandableFolders, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
+ connect(m_expandableFolders, &QCheckBox::toggled, this, &ViewSettingsTab::changed);
break;
default:
break;
@@ -195,7 +195,7 @@ void ViewSettingsTab::applySettings()
settings.setItalicFont(font.italic());
settings.setFontWeight(font.weight());
- settings.writeConfig();
+ settings.save();
}
void ViewSettingsTab::restoreDefaultSettings()
@@ -289,4 +289,4 @@ void ViewSettingsTab::showToolTip(QSlider* slider, int value)
QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), slider->mapToGlobal(global));
QApplication::sendEvent(slider, &toolTipEvent);
}
-#include "viewsettingstab.moc"
+
diff --git a/src/settings/viewpropertiesdialog.cpp b/src/settings/viewpropertiesdialog.cpp
index 574f8e18e..be7fe0d86 100644
--- a/src/settings/viewpropertiesdialog.cpp
+++ b/src/settings/viewpropertiesdialog.cpp
@@ -29,30 +29,27 @@
#include <config-baloo.h>
-#include <KComponentData>
-#include <KLocale>
-#include <KIconLoader>
-#include <KIO/NetAccess>
+#include <KLocalizedString>
#include <KMessageBox>
-#include <KStandardDirs>
-#include <KUrl>
+#include <QUrl>
#include <KComboBox>
+#include <KConfigGroup>
+#include <KWindowConfig>
-#include <QAction>
#include <QButtonGroup>
#include <QCheckBox>
#include <QGridLayout>
#include <QGroupBox>
#include <QLabel>
-#include <QMenu>
#include <QPushButton>
#include <QRadioButton>
-#include <QBoxLayout>
+#include <QDialogButtonBox>
+#include <QVBoxLayout>
#include <views/viewproperties.h>
ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
- KDialog(dolphinView),
+ QDialog(dolphinView),
m_isDirty(false),
m_dolphinView(dolphinView),
m_viewProps(0),
@@ -72,29 +69,31 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
Q_ASSERT(dolphinView);
const bool useGlobalViewProps = GeneralSettings::globalViewProps();
- setCaption(i18nc("@title:window", "View Properties"));
- setButtons(KDialog::Ok | KDialog::Cancel | KDialog::Apply);
+ setWindowTitle(i18nc("@title:window", "View Properties"));
+ setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
- const KUrl& url = dolphinView->url();
+ const QUrl& url = dolphinView->url();
m_viewProps = new ViewProperties(url);
m_viewProps->setAutoSaveEnabled(false);
- QWidget* main = new QWidget();
- QVBoxLayout* topLayout = new QVBoxLayout();
+ auto layout = new QVBoxLayout(this);
+ setLayout(layout);
+
+ auto propsGrid = new QWidget(this);
+ layout->addWidget(propsGrid);
// create 'Properties' group containing view mode, sorting, sort order and show hidden files
- QWidget* propsBox = main;
+ QWidget* propsBox = this;
if (!useGlobalViewProps) {
- propsBox = new QGroupBox(i18nc("@title:group", "Properties"), main);
+ propsBox = new QGroupBox(i18nc("@title:group", "Properties"), this);
+ layout->addWidget(propsBox);
}
- QWidget* propsGrid = new QWidget();
-
QLabel* viewModeLabel = new QLabel(i18nc("@label:listbox", "View mode:"), propsGrid);
m_viewMode = new KComboBox(propsGrid);
- m_viewMode->addItem(KIcon("view-list-icons"), i18nc("@item:inlistbox", "Icons"), DolphinView::IconsView);
- m_viewMode->addItem(KIcon("view-list-details"), i18nc("@item:inlistbox", "Compact"), DolphinView::CompactView);
- m_viewMode->addItem(KIcon("view-list-tree"), i18nc("@item:inlistbox", "Details"), DolphinView::DetailsView);
+ m_viewMode->addItem(QIcon::fromTheme("view-list-icons"), i18nc("@item:inlistbox", "Icons"), DolphinView::IconsView);
+ m_viewMode->addItem(QIcon::fromTheme("view-list-details"), i18nc("@item:inlistbox", "Compact"), DolphinView::CompactView);
+ m_viewMode->addItem(QIcon::fromTheme("view-list-tree"), i18nc("@item:inlistbox", "Details"), DolphinView::DetailsView);
QLabel* sortingLabel = new QLabel(i18nc("@label:listbox", "Sorting:"), propsGrid);
QWidget* sortingBox = new QWidget(propsGrid);
@@ -136,33 +135,29 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
propsBoxLayout->addWidget(m_showHiddenFiles);
propsBoxLayout->addWidget(m_additionalInfo);
- topLayout->addWidget(propsBox);
-
- connect(m_viewMode, SIGNAL(currentIndexChanged(int)),
- this, SLOT(slotViewModeChanged(int)));
- connect(m_sorting, SIGNAL(currentIndexChanged(int)),
- this, SLOT(slotSortingChanged(int)));
- connect(m_sortOrder, SIGNAL(currentIndexChanged(int)),
- this, SLOT(slotSortOrderChanged(int)));
- connect(m_additionalInfo, SIGNAL(clicked()),
- this, SLOT(configureAdditionalInfo()));
- connect(m_sortFoldersFirst, SIGNAL(clicked()),
- this, SLOT(slotSortFoldersFirstChanged()));
- connect(m_previewsShown, SIGNAL(clicked()),
- this, SLOT(slotShowPreviewChanged()));
- connect(m_showInGroups, SIGNAL(clicked()),
- this, SLOT(slotGroupedSortingChanged()));
- connect(m_showHiddenFiles, SIGNAL(clicked()),
- this, SLOT(slotShowHiddenFilesChanged()));
-
- connect(this, SIGNAL(okClicked()), this, SLOT(slotOk()));
- connect(this, SIGNAL(applyClicked()), this, SLOT(slotApply()));
+ connect(m_viewMode, static_cast<void(KComboBox::*)(int)>(&KComboBox::currentIndexChanged),
+ this, &ViewPropertiesDialog::slotViewModeChanged);
+ connect(m_sorting, static_cast<void(KComboBox::*)(int)>(&KComboBox::currentIndexChanged),
+ this, &ViewPropertiesDialog::slotSortingChanged);
+ connect(m_sortOrder, static_cast<void(KComboBox::*)(int)>(&KComboBox::currentIndexChanged),
+ this, &ViewPropertiesDialog::slotSortOrderChanged);
+ connect(m_additionalInfo, &QPushButton::clicked,
+ this, &ViewPropertiesDialog::configureAdditionalInfo);
+ connect(m_sortFoldersFirst, &QCheckBox::clicked,
+ this, &ViewPropertiesDialog::slotSortFoldersFirstChanged);
+ connect(m_previewsShown, &QCheckBox::clicked,
+ this, &ViewPropertiesDialog::slotShowPreviewChanged);
+ connect(m_showInGroups, &QCheckBox::clicked,
+ this, &ViewPropertiesDialog::slotGroupedSortingChanged);
+ connect(m_showHiddenFiles, &QCheckBox::clicked,
+ this, &ViewPropertiesDialog::slotShowHiddenFilesChanged);
// Only show the following settings if the view properties are remembered
// for each directory:
if (!useGlobalViewProps) {
// create 'Apply View Properties To' group
- QGroupBox* applyBox = new QGroupBox(i18nc("@title:group", "Apply View Properties To"), main);
+ QGroupBox* applyBox = new QGroupBox(i18nc("@title:group", "Apply View Properties To"), this);
+ layout->addWidget(applyBox);
m_applyToCurrentFolder = new QRadioButton(i18nc("@option:radio Apply View Properties To",
"Current folder"), applyBox);
@@ -182,27 +177,38 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
applyBoxLayout->addWidget(m_applyToSubFolders);
applyBoxLayout->addWidget(m_applyToAllFolders);
- m_useAsDefault = new QCheckBox(i18nc("@option:check", "Use these view properties as default"), main);
-
- topLayout->addWidget(applyBox);
- topLayout->addWidget(m_useAsDefault);
+ m_useAsDefault = new QCheckBox(i18nc("@option:check", "Use these view properties as default"), this);
+ layout->addWidget(m_useAsDefault);
- connect(m_applyToCurrentFolder, SIGNAL(clicked(bool)),
- this, SLOT(markAsDirty(bool)));
- connect(m_applyToSubFolders, SIGNAL(clicked(bool)),
- this, SLOT(markAsDirty(bool)));
- connect(m_applyToAllFolders, SIGNAL(clicked(bool)),
- this, SLOT(markAsDirty(bool)));
- connect(m_useAsDefault, SIGNAL(clicked(bool)),
- this, SLOT(markAsDirty(bool)));
+ connect(m_applyToCurrentFolder, &QRadioButton::clicked,
+ this, &ViewPropertiesDialog::markAsDirty);
+ connect(m_applyToSubFolders, &QRadioButton::clicked,
+ this, &ViewPropertiesDialog::markAsDirty);
+ connect(m_applyToAllFolders, &QRadioButton::clicked,
+ this, &ViewPropertiesDialog::markAsDirty);
+ connect(m_useAsDefault, &QCheckBox::clicked,
+ this, &ViewPropertiesDialog::markAsDirty);
}
- main->setLayout(topLayout);
- setMainWidget(main);
+ layout->addStretch();
- const KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"),
- "ViewPropertiesDialog");
- restoreDialogSize(dialogConfig);
+ auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Apply, this);
+ connect(buttonBox, &QDialogButtonBox::accepted, this, &ViewPropertiesDialog::accept);
+ connect(buttonBox, &QDialogButtonBox::rejected, this, &ViewPropertiesDialog::reject);
+ layout->addWidget(buttonBox);
+
+ auto okButton = buttonBox->button(QDialogButtonBox::Ok);
+ okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
+ okButton->setDefault(true);
+
+ auto applyButton = buttonBox->button(QDialogButtonBox::Apply);
+ connect(applyButton, &QPushButton::clicked, this, &ViewPropertiesDialog::slotApply);
+ connect(this, &ViewPropertiesDialog::isDirtyChanged, applyButton, [applyButton](bool isDirty) {
+ applyButton->setEnabled(isDirty);
+ });
+
+ const KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"), "ViewPropertiesDialog");
+ KWindowConfig::restoreWindowSize(windowHandle(), dialogConfig);
loadSettings();
}
@@ -213,15 +219,14 @@ ViewPropertiesDialog::~ViewPropertiesDialog()
delete m_viewProps;
m_viewProps = 0;
- KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"),
- "ViewPropertiesDialog");
- saveDialogSize(dialogConfig, KConfigBase::Persistent);
+ KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"), "ViewPropertiesDialog");
+ KWindowConfig::saveWindowSize(windowHandle(), dialogConfig);
}
-void ViewPropertiesDialog::slotOk()
+void ViewPropertiesDialog::accept()
{
applyViewProperties();
- accept();
+ QDialog::accept();
}
void ViewPropertiesDialog::slotApply()
@@ -281,8 +286,10 @@ void ViewPropertiesDialog::slotShowHiddenFilesChanged()
void ViewPropertiesDialog::markAsDirty(bool isDirty)
{
- m_isDirty = isDirty;
- enableButtonApply(isDirty);
+ if (m_isDirty != isDirty) {
+ m_isDirty = isDirty;
+ emit isDirtyChanged(isDirty);
+ }
}
void ViewPropertiesDialog::configureAdditionalInfo()
@@ -358,7 +365,7 @@ void ViewPropertiesDialog::applyViewProperties()
// all existing viewproperties invalid, as they have a smaller time stamp.
GeneralSettings* settings = GeneralSettings::self();
settings->setViewPropsTimestamp(QDateTime::currentDateTime());
- settings->writeConfig();
+ settings->save();
}
m_dolphinView->setMode(m_viewProps->viewMode());
@@ -408,4 +415,3 @@ void ViewPropertiesDialog::loadSettings()
markAsDirty(false);
}
-#include "viewpropertiesdialog.moc"
diff --git a/src/settings/viewpropertiesdialog.h b/src/settings/viewpropertiesdialog.h
index 6b0e9ff48..5490be85b 100644
--- a/src/settings/viewpropertiesdialog.h
+++ b/src/settings/viewpropertiesdialog.h
@@ -21,9 +21,9 @@
#ifndef VIEWPROPERTIESDIALOG_H
#define VIEWPROPERTIESDIALOG_H
-#include "libdolphin_export.h"
+#include "dolphin_export.h"
-#include <KDialog>
+#include <QDialog>
class QCheckBox;
class KComboBox;
@@ -39,7 +39,7 @@ class DolphinView;
* and previews should be shown. The properties can be assigned to the current folder,
* or recursively to all sub folders.
*/
-class LIBDOLPHINPRIVATE_EXPORT ViewPropertiesDialog : public KDialog
+class DOLPHIN_EXPORT ViewPropertiesDialog : public QDialog
{
Q_OBJECT
@@ -47,8 +47,10 @@ public:
explicit ViewPropertiesDialog(DolphinView* dolphinView);
virtual ~ViewPropertiesDialog();
+public slots:
+ void accept() Q_DECL_OVERRIDE;
+
private slots:
- void slotOk();
void slotApply();
void slotViewModeChanged(int index);
void slotSortingChanged(int index);
@@ -60,6 +62,9 @@ private slots:
void markAsDirty(bool isDirty);
void configureAdditionalInfo();
+signals:
+ void isDirtyChanged(bool isDirty);
+
private:
void applyViewProperties();
void loadSettings();
diff --git a/src/settings/viewpropsprogressinfo.cpp b/src/settings/viewpropsprogressinfo.cpp
index 9b7797d02..56fee8027 100644
--- a/src/settings/viewpropsprogressinfo.cpp
+++ b/src/settings/viewpropsprogressinfo.cpp
@@ -24,17 +24,20 @@
#include <QLabel>
#include <QProgressBar>
#include <QTimer>
-#include <QBoxLayout>
+#include <QVBoxLayout>
+#include <QDialogButtonBox>
+#include <QPushButton>
-#include <KLocale>
-#include <KIO/JobClasses>
+#include <KConfigGroup>
+#include <KLocalizedString>
+#include <KIO/Job>
#include <views/viewproperties.h>
ViewPropsProgressInfo::ViewPropsProgressInfo(QWidget* parent,
- const KUrl& dir,
+ const QUrl& dir,
const ViewProperties& viewProps) :
- KDialog(parent),
+ QDialog(parent),
m_dir(dir),
m_viewProps(0),
m_label(0),
@@ -45,9 +48,8 @@ ViewPropsProgressInfo::ViewPropsProgressInfo(QWidget* parent,
{
const QSize minSize = minimumSize();
setMinimumSize(QSize(320, minSize.height()));
-
- setCaption(i18nc("@title:window", "Applying View Properties"));
- setButtons(KDialog::Cancel);
+ setWindowTitle(i18nc("@title:window", "Applying View Properties"));
+ setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
m_viewProps = new ViewProperties(dir);
m_viewProps->setDirProperties(viewProps);
@@ -56,37 +58,39 @@ ViewPropsProgressInfo::ViewPropsProgressInfo(QWidget* parent,
// that the view properties are saved twice:
m_viewProps->setAutoSaveEnabled(false);
- QWidget* main = new QWidget();
- QVBoxLayout* topLayout = new QVBoxLayout();
+ auto layout = new QVBoxLayout(this);
+ setLayout(layout);
+
+ m_label = new QLabel(i18nc("@info:progress", "Counting folders: %1", 0), this);
+ layout->addWidget(m_label);
- m_label = new QLabel(i18nc("@info:progress", "Counting folders: %1", 0), main);
- m_progressBar = new QProgressBar(main);
+ m_progressBar = new QProgressBar(this);
m_progressBar->setMinimum(0);
m_progressBar->setMaximum(0);
m_progressBar->setValue(0);
+ layout->addWidget(m_progressBar);
- topLayout->addWidget(m_label);
- topLayout->addWidget(m_progressBar);
+ layout->addStretch();
- main->setLayout(topLayout);
- setMainWidget(main);
+ auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel, this);
+ connect(buttonBox, &QDialogButtonBox::accepted, this, &ViewPropsProgressInfo::accept);
+ connect(buttonBox, &QDialogButtonBox::rejected, this, &ViewPropsProgressInfo::reject);
+ layout->addWidget(buttonBox);
// Use the directory size job to count the number of directories first. This
// allows to give a progress indication for the user when applying the view
// properties later.
m_dirSizeJob = KIO::directorySize(dir);
- connect(m_dirSizeJob, SIGNAL(result(KJob*)),
- this, SLOT(applyViewProperties()));
+ connect(m_dirSizeJob, &KIO::DirectorySizeJob::result,
+ this, &ViewPropsProgressInfo::applyViewProperties);
// The directory size job cannot emit any progress signal, as it is not aware
// about the total number of directories. Therefor a timer is triggered, which
// periodically updates the current directory count.
m_timer = new QTimer(this);
- connect(m_timer, SIGNAL(timeout()),
- this, SLOT(updateProgress()));
+ connect(m_timer, &QTimer::timeout,
+ this, &ViewPropsProgressInfo::updateProgress);
m_timer->start(300);
-
- connect(this, SIGNAL(cancelClicked()), this, SLOT(cancelApplying()));
}
ViewPropsProgressInfo::~ViewPropsProgressInfo()
@@ -99,7 +103,22 @@ void ViewPropsProgressInfo::closeEvent(QCloseEvent* event)
{
m_timer->stop();
m_applyViewPropsJob = 0;
- KDialog::closeEvent(event);
+ QDialog::closeEvent(event);
+}
+
+void ViewPropsProgressInfo::reject()
+{
+ if (m_dirSizeJob) {
+ m_dirSizeJob->kill();
+ m_dirSizeJob = 0;
+ }
+
+ if (m_applyViewPropsJob) {
+ m_applyViewPropsJob->kill();
+ m_applyViewPropsJob = 0;
+ }
+
+ QDialog::reject();
}
void ViewPropsProgressInfo::updateProgress()
@@ -128,21 +147,7 @@ void ViewPropsProgressInfo::applyViewProperties()
m_dirSizeJob = 0;
m_applyViewPropsJob = new ApplyViewPropsJob(m_dir, *m_viewProps);
- connect(m_applyViewPropsJob, SIGNAL(result(KJob*)),
- this, SLOT(close()));
-}
-
-void ViewPropsProgressInfo::cancelApplying()
-{
- if (m_dirSizeJob) {
- m_dirSizeJob->kill();
- m_dirSizeJob = 0;
- }
-
- if (m_applyViewPropsJob) {
- m_applyViewPropsJob->kill();
- m_applyViewPropsJob = 0;
- }
+ connect(m_applyViewPropsJob, &ApplyViewPropsJob::result,
+ this, &ViewPropsProgressInfo::close);
}
-#include "viewpropsprogressinfo.moc"
diff --git a/src/settings/viewpropsprogressinfo.h b/src/settings/viewpropsprogressinfo.h
index 6f8c763c3..cd7aa50ce 100644
--- a/src/settings/viewpropsprogressinfo.h
+++ b/src/settings/viewpropsprogressinfo.h
@@ -20,9 +20,9 @@
#ifndef VIEWPROPSPROGRESSINFO_H
#define VIEWPROPSPROGRESSINFO_H
-#include <KDialog>
+#include <QDialog>
#include <kio/directorysizejob.h>
-#include <KUrl>
+#include <QUrl>
class ApplyViewPropsJob;
class QLabel;
@@ -37,7 +37,7 @@ class ViewProperties;
* It is possible to cancel the applying. In this case the already applied
* view properties won't get reverted.
*/
-class ViewPropsProgressInfo : public KDialog
+class ViewPropsProgressInfo : public QDialog
{
Q_OBJECT
@@ -50,21 +50,23 @@ public:
* sub directories.
*/
ViewPropsProgressInfo(QWidget* parent,
- const KUrl& dir,
+ const QUrl& dir,
const ViewProperties& viewProps);
virtual ~ViewPropsProgressInfo();
protected:
- virtual void closeEvent(QCloseEvent* event);
+ virtual void closeEvent(QCloseEvent* event) Q_DECL_OVERRIDE;
+
+public slots:
+ void reject() Q_DECL_OVERRIDE;
private slots:
void updateProgress();
void applyViewProperties();
- void cancelApplying();
private:
- KUrl m_dir;
+ QUrl m_dir;
ViewProperties* m_viewProps;
QLabel* m_label;
diff --git a/src/statusbar/dolphinstatusbar.cpp b/src/statusbar/dolphinstatusbar.cpp
index e0fdc8703..166f6ab14 100644
--- a/src/statusbar/dolphinstatusbar.cpp
+++ b/src/statusbar/dolphinstatusbar.cpp
@@ -21,11 +21,9 @@
#include "dolphin_generalsettings.h"
-#include <KIconLoader>
-#include <KIcon>
-#include <KLocale>
-#include <KMenu>
-#include <KVBox>
+#include <QIcon>
+#include <KLocalizedString>
+#include <QMenu>
#include "statusbarspaceinfo.h"
@@ -33,10 +31,12 @@
#include <QHBoxLayout>
#include <QLabel>
#include <QProgressBar>
-#include <QTextDocument>
#include <QToolButton>
#include <QTime>
#include <QTimer>
+#include <QSlider>
+#include <QTextDocument>
+#include <QHelpEvent>
#include <views/dolphinview.h>
#include <views/zoomlevelinfo.h>
@@ -72,21 +72,21 @@ DolphinStatusBar::DolphinStatusBar(QWidget* parent) :
m_zoomSlider->setPageStep(1);
m_zoomSlider->setRange(ZoomLevelInfo::minimumLevel(), ZoomLevelInfo::maximumLevel());
- connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SIGNAL(zoomLevelChanged(int)));
- connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(updateZoomSliderToolTip(int)));
- connect(m_zoomSlider, SIGNAL(sliderMoved(int)), this, SLOT(showZoomSliderToolTip(int)));
+ connect(m_zoomSlider, &QSlider::valueChanged, this, &DolphinStatusBar::zoomLevelChanged);
+ connect(m_zoomSlider, &QSlider::valueChanged, this, &DolphinStatusBar::updateZoomSliderToolTip);
+ connect(m_zoomSlider, &QSlider::sliderMoved, this, &DolphinStatusBar::showZoomSliderToolTip);
// Initialize space information
m_spaceInfo = new StatusBarSpaceInfo(this);
// Initialize progress information
m_stopButton = new QToolButton(this);
- m_stopButton->setIcon(KIcon("process-stop"));
+ m_stopButton->setIcon(QIcon::fromTheme("process-stop"));
m_stopButton->setAccessibleName(i18n("Stop"));
m_stopButton->setAutoRaise(true);
m_stopButton->setToolTip(i18nc("@tooltip", "Stop loading"));
m_stopButton->hide();
- connect(m_stopButton, SIGNAL(clicked()), this, SIGNAL(stopPressed()));
+ connect(m_stopButton, &QToolButton::clicked, this, &DolphinStatusBar::stopPressed);
m_progressTextLabel = new QLabel(this);
m_progressTextLabel->hide();
@@ -97,12 +97,12 @@ DolphinStatusBar::DolphinStatusBar(QWidget* parent) :
m_showProgressBarTimer = new QTimer(this);
m_showProgressBarTimer->setInterval(500);
m_showProgressBarTimer->setSingleShot(true);
- connect(m_showProgressBarTimer, SIGNAL(timeout()), this, SLOT(updateProgressInfo()));
+ connect(m_showProgressBarTimer, &QTimer::timeout, this, &DolphinStatusBar::updateProgressInfo);
m_resetToDefaultTextTimer = new QTimer(this);
m_resetToDefaultTextTimer->setInterval(ResetToDefaultTimeout);
m_resetToDefaultTextTimer->setSingleShot(true);
- connect(m_resetToDefaultTextTimer, SIGNAL(timeout()), this, SLOT(slotResetToDefaultText()));
+ connect(m_resetToDefaultTextTimer, &QTimer::timeout, this, &DolphinStatusBar::slotResetToDefaultText);
// Initialize top layout and size policies
const int fontHeight = QFontMetrics(m_label->font()).height();
@@ -228,12 +228,12 @@ QString DolphinStatusBar::defaultText() const
return m_defaultText;
}
-void DolphinStatusBar::setUrl(const KUrl& url)
+void DolphinStatusBar::setUrl(const QUrl& url)
{
m_spaceInfo->setUrl(url);
}
-KUrl DolphinStatusBar::url() const
+QUrl DolphinStatusBar::url() const
{
return m_spaceInfo->url();
}
@@ -259,7 +259,7 @@ void DolphinStatusBar::contextMenuEvent(QContextMenuEvent* event)
{
Q_UNUSED(event);
- KMenu menu(this);
+ QMenu menu(this);
QAction* showZoomSliderAction = menu.addAction(i18nc("@action:inmenu", "Show Zoom Slider"));
showZoomSliderAction->setCheckable(true);
@@ -357,4 +357,3 @@ void DolphinStatusBar::setExtensionsVisible(bool visible)
m_zoomSlider->setVisible(showZoomSlider);
}
-#include "dolphinstatusbar.moc"
diff --git a/src/statusbar/dolphinstatusbar.h b/src/statusbar/dolphinstatusbar.h
index 4d6dbb20f..1a4ccf682 100644
--- a/src/statusbar/dolphinstatusbar.h
+++ b/src/statusbar/dolphinstatusbar.h
@@ -23,7 +23,7 @@
#include <QTime>
#include <QWidget>
-class KUrl;
+class QUrl;
class StatusBarSpaceInfo;
class QLabel;
class QProgressBar;
@@ -79,7 +79,7 @@ public:
void setDefaultText(const QString& text);
QString defaultText() const;
- KUrl url() const;
+ QUrl url() const;
int zoomLevel() const;
/**
@@ -89,7 +89,7 @@ public:
public slots:
void setText(const QString& text);
- void setUrl(const KUrl& url);
+ void setUrl(const QUrl& url);
void setZoomLevel(int zoomLevel);
signals:
@@ -101,8 +101,8 @@ signals:
void zoomLevelChanged(int zoomLevel);
protected:
- virtual void contextMenuEvent(QContextMenuEvent* event);
- virtual bool eventFilter(QObject* obj, QEvent* event);
+ virtual void contextMenuEvent(QContextMenuEvent* event) Q_DECL_OVERRIDE;
+ virtual bool eventFilter(QObject* obj, QEvent* event) Q_DECL_OVERRIDE;
private slots:
void showZoomSliderToolTip(int zoomLevel);
diff --git a/src/statusbar/mountpointobserver.cpp b/src/statusbar/mountpointobserver.cpp
index 4a23be6b6..df2a4898f 100644
--- a/src/statusbar/mountpointobserver.cpp
+++ b/src/statusbar/mountpointobserver.cpp
@@ -17,20 +17,21 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
+#include <KIO/FileSystemFreeSpaceJob>
+
#include "mountpointobserver.h"
#include "mountpointobservercache.h"
-MountPointObserver::MountPointObserver(const QString& mountPoint, QObject* parent) :
+MountPointObserver::MountPointObserver(const QUrl& url, QObject* parent) :
QObject(parent),
- m_mountPoint(mountPoint),
- m_referenceCount(0),
- m_spaceInfo(KDiskFreeSpaceInfo::freeSpaceInfo(mountPoint))
+ m_url(url),
+ m_referenceCount(0)
{
}
-MountPointObserver* MountPointObserver::observerForPath(const QString& path)
+MountPointObserver* MountPointObserver::observerForUrl(const QUrl& url)
{
- MountPointObserver* observer = MountPointObserverCache::instance()->observerForPath(path);
+ MountPointObserver* observer = MountPointObserverCache::instance()->observerForUrl(url);
return observer;
}
@@ -39,10 +40,16 @@ void MountPointObserver::update()
if (m_referenceCount == 0) {
delete this;
} else {
- const KDiskFreeSpaceInfo spaceInfo = KDiskFreeSpaceInfo::freeSpaceInfo(m_mountPoint);
- if (spaceInfo.size() != m_spaceInfo.size() || spaceInfo.available() != m_spaceInfo.available()) {
- m_spaceInfo = spaceInfo;
- emit spaceInfoChanged();
- }
+ KIO::FileSystemFreeSpaceJob* job = KIO::fileSystemFreeSpace(m_url);
+ connect(job, &KIO::FileSystemFreeSpaceJob::result, this, &MountPointObserver::freeSpaceResult);
+ }
+}
+
+void MountPointObserver::freeSpaceResult(KIO::Job* job, KIO::filesize_t size, KIO::filesize_t available)
+{
+ if (!job->error()) {
+ emit spaceInfoChanged(size, available);
+ } else {
+ emit spaceInfoChanged(0, 0);
}
}
diff --git a/src/statusbar/mountpointobserver.h b/src/statusbar/mountpointobserver.h
index ac5f8ecc3..c3d2aa677 100644
--- a/src/statusbar/mountpointobserver.h
+++ b/src/statusbar/mountpointobserver.h
@@ -20,9 +20,10 @@
#ifndef MOUNTPOINTOBSERVER_H
#define MOUNTPOINTOBSERVER_H
-#include <KDiskFreeSpaceInfo>
+#include <KIO/Job>
#include <QObject>
+#include <QUrl>
/**
* A MountPointObserver can be used to determine the free space on a mount
@@ -52,16 +53,11 @@ class MountPointObserver : public QObject
{
Q_OBJECT
- explicit MountPointObserver(const QString& mountPoint, QObject* parent = 0);
+ explicit MountPointObserver(const QUrl& url, QObject* parent = 0);
virtual ~MountPointObserver() {}
public:
/**
- * Obtains information about the available space on the observed mount point.
- */
- KDiskFreeSpaceInfo spaceInfo() const { return m_spaceInfo; }
-
- /**
* Call this function to indicate that the caller intends to continue using this object. An
* internal reference count is increased then. When the observer is not needed any more,
* deref() should be called, which decreases the reference count again.
@@ -80,28 +76,30 @@ public:
}
/**
- * Returns a MountPointObserver for the given \a path. If the caller intends to continue using
+ * Returns a MountPointObserver for the given \a url. If the caller intends to continue using
* the returned object, it must call its ref() method.
*/
- static MountPointObserver* observerForPath(const QString& path);
+ static MountPointObserver* observerForUrl(const QUrl& url);
signals:
/**
- * This signal is emitted if the information that spaceInfo() will return has changed.
+ * This signal is emitted when the size has been retrieved.
*/
- void spaceInfoChanged();
+ void spaceInfoChanged(quint64 size, quint64 available);
public slots:
/**
- * If this slot is invoked, MountPointObserver checks if the available space on the observed
- * mount point has changed, and emits spaceInfoChanged() if that is the case.
+ * If this slot is invoked, MountPointObserver starts a new driveSize job
+ * to get the drive's size.
*/
void update();
+private slots:
+ void freeSpaceResult(KIO::Job* job, KIO::filesize_t size, KIO::filesize_t available);
+
private:
- const QString m_mountPoint;
+ const QUrl m_url;
int m_referenceCount;
- KDiskFreeSpaceInfo m_spaceInfo;
friend class MountPointObserverCache;
};
diff --git a/src/statusbar/mountpointobservercache.cpp b/src/statusbar/mountpointobservercache.cpp
index aff0c8e2f..ab3744eac 100644
--- a/src/statusbar/mountpointobservercache.cpp
+++ b/src/statusbar/mountpointobservercache.cpp
@@ -21,7 +21,6 @@
#include "mountpointobserver.h"
-#include <KGlobal>
#include <KMountPoint>
#include <QTimer>
@@ -31,7 +30,7 @@ class MountPointObserverCacheSingleton
public:
MountPointObserverCache instance;
};
-K_GLOBAL_STATIC(MountPointObserverCacheSingleton, s_MountPointObserverCache)
+Q_GLOBAL_STATIC(MountPointObserverCacheSingleton, s_MountPointObserverCache)
MountPointObserverCache::MountPointObserverCache() :
@@ -51,33 +50,38 @@ MountPointObserverCache* MountPointObserverCache::instance()
return &s_MountPointObserverCache->instance;
}
-MountPointObserver* MountPointObserverCache::observerForPath(const QString& path)
+MountPointObserver* MountPointObserverCache::observerForUrl(const QUrl& url)
{
- // Try to share the observer with other paths that have the same mount point.
- QString mountPointPath;
- KMountPoint::Ptr mountPoint = KMountPoint::currentMountPoints().findByPath(path);
- if (mountPoint) {
- mountPointPath = mountPoint->mountPoint();
+ QUrl cachedObserverUrl;
+ // If the url is a local path we can extract the root dir by checking the mount points.
+ if (url.isLocalFile()) {
+ // Try to share the observer with other paths that have the same mount point.
+ KMountPoint::Ptr mountPoint = KMountPoint::currentMountPoints().findByPath(url.toLocalFile());
+ if (mountPoint) {
+ cachedObserverUrl = QUrl::fromLocalFile(mountPoint->mountPoint());
+ } else {
+ // Even if determining the mount point failed, the observer might still
+ // be able to retrieve information about the url.
+ cachedObserverUrl = url.toLocalFile();
+ }
} else {
- // Even if determining the mount point failed, KDiskFreeSpaceInfo might still
- // be able to retrieve information about the path.
- mountPointPath = path;
+ cachedObserverUrl = url.url();
}
- MountPointObserver* observer = m_observerForMountPoint.value(mountPointPath);
+ MountPointObserver* observer = m_observerForMountPoint.value(cachedObserverUrl);
if (!observer) {
- observer = new MountPointObserver(mountPointPath, this);
- m_observerForMountPoint.insert(mountPointPath, observer);
- m_mountPointForObserver.insert(observer, mountPointPath);
+ observer = new MountPointObserver(cachedObserverUrl, this);
+ m_observerForMountPoint.insert(cachedObserverUrl, observer);
+ m_mountPointForObserver.insert(observer, cachedObserverUrl);
Q_ASSERT(m_observerForMountPoint.count() == m_mountPointForObserver.count());
- connect(observer, SIGNAL(destroyed(QObject*)), this, SLOT(slotObserverDestroyed(QObject*)));
+ connect(observer, &MountPointObserver::destroyed, this, &MountPointObserverCache::slotObserverDestroyed);
if (!m_updateTimer->isActive()) {
m_updateTimer->start(10000);
}
- connect(m_updateTimer, SIGNAL(timeout()), observer, SLOT(update()));
+ connect(m_updateTimer, &QTimer::timeout, observer, &MountPointObserver::update);
}
return observer;
@@ -86,9 +90,9 @@ MountPointObserver* MountPointObserverCache::observerForPath(const QString& path
void MountPointObserverCache::slotObserverDestroyed(QObject* observer)
{
Q_ASSERT(m_mountPointForObserver.contains(observer));
- const QString& path = m_mountPointForObserver.value(observer);
- Q_ASSERT(m_observerForMountPoint.contains(path));
- m_observerForMountPoint.remove(path);
+ const QUrl& url = m_mountPointForObserver.value(observer);
+ Q_ASSERT(m_observerForMountPoint.contains(url));
+ m_observerForMountPoint.remove(url);
m_mountPointForObserver.remove(observer);
Q_ASSERT(m_observerForMountPoint.count() == m_mountPointForObserver.count());
diff --git a/src/statusbar/mountpointobservercache.h b/src/statusbar/mountpointobservercache.h
index 425000645..8a1496d89 100644
--- a/src/statusbar/mountpointobservercache.h
+++ b/src/statusbar/mountpointobservercache.h
@@ -37,9 +37,9 @@ public:
static MountPointObserverCache* instance();
/**
- * Returns a MountPointObserver for the given \a path. A new observer is created if necessary.
+ * Returns a MountPointObserver for the given \a url. A new observer is created if necessary.
*/
- MountPointObserver* observerForPath(const QString& path);
+ MountPointObserver* observerForUrl(const QUrl& url);
private slots:
/**
@@ -48,8 +48,8 @@ private slots:
void slotObserverDestroyed(QObject* observer);
private:
- QHash<QString, MountPointObserver*> m_observerForMountPoint;
- QHash<QObject*, QString> m_mountPointForObserver;
+ QHash<QUrl, MountPointObserver*> m_observerForMountPoint;
+ QHash<QObject*, QUrl> m_mountPointForObserver;
QTimer* m_updateTimer;
friend class MountPointObserverCacheSingleton;
diff --git a/src/statusbar/spaceinfoobserver.cpp b/src/statusbar/spaceinfoobserver.cpp
index 9125a9308..0fb018727 100644
--- a/src/statusbar/spaceinfoobserver.cpp
+++ b/src/statusbar/spaceinfoobserver.cpp
@@ -21,17 +21,18 @@
#include "mountpointobserver.h"
-#include <KUrl>
+#include <QUrl>
-SpaceInfoObserver::SpaceInfoObserver(const KUrl& url, QObject* parent) :
+SpaceInfoObserver::SpaceInfoObserver(const QUrl& url, QObject* parent) :
QObject(parent),
- m_mountPointObserver(0)
+ m_mountPointObserver(0),
+ m_dataSize(0),
+ m_dataAvailable(0)
{
- if (url.isLocalFile()) {
- m_mountPointObserver = MountPointObserver::observerForPath(url.toLocalFile());
- m_mountPointObserver->ref();
- connect(m_mountPointObserver, SIGNAL(spaceInfoChanged()), this, SIGNAL(valuesChanged()));
- }
+ m_mountPointObserver = MountPointObserver::observerForUrl(url);
+ m_mountPointObserver->ref();
+ connect(m_mountPointObserver, &MountPointObserver::spaceInfoChanged, this, &SpaceInfoObserver::spaceInfoChanged);
+ m_mountPointObserver->update();
}
SpaceInfoObserver::~SpaceInfoObserver()
@@ -44,46 +45,41 @@ SpaceInfoObserver::~SpaceInfoObserver()
quint64 SpaceInfoObserver::size() const
{
- if (m_mountPointObserver && m_mountPointObserver->spaceInfo().isValid()) {
- return m_mountPointObserver->spaceInfo().size();
- } else {
- return 0;
- }
+ return m_dataSize;
}
quint64 SpaceInfoObserver::available() const
{
- if (m_mountPointObserver && m_mountPointObserver->spaceInfo().isValid()) {
- return m_mountPointObserver->spaceInfo().available();
- } else {
- return 0;
- }
+ return m_dataAvailable;
}
-void SpaceInfoObserver::setUrl(const KUrl& url)
+void SpaceInfoObserver::setUrl(const QUrl& url)
{
- if (url.isLocalFile()) {
- MountPointObserver* newObserver = MountPointObserver::observerForPath(url.toLocalFile());
- if (newObserver != m_mountPointObserver) {
- if (m_mountPointObserver) {
- disconnect(m_mountPointObserver, SIGNAL(spaceInfoChanged()), this, SIGNAL(valuesChanged()));
- m_mountPointObserver->deref();
- m_mountPointObserver = 0;
- }
-
- m_mountPointObserver = newObserver;
- m_mountPointObserver->ref();
- connect(m_mountPointObserver, SIGNAL(spaceInfoChanged()), this, SIGNAL(valuesChanged()));
-
- emit valuesChanged();
- }
- } else {
+ MountPointObserver* newObserver = MountPointObserver::observerForUrl(url);
+ if (newObserver != m_mountPointObserver) {
if (m_mountPointObserver) {
- disconnect(m_mountPointObserver, SIGNAL(spaceInfoChanged()), this, SIGNAL(valuesChanged()));
+ disconnect(m_mountPointObserver, &MountPointObserver::spaceInfoChanged, this, &SpaceInfoObserver::spaceInfoChanged);
m_mountPointObserver->deref();
m_mountPointObserver = 0;
-
- emit valuesChanged();
}
+
+ m_mountPointObserver = newObserver;
+ m_mountPointObserver->ref();
+ connect(m_mountPointObserver, &MountPointObserver::spaceInfoChanged, this, &SpaceInfoObserver::spaceInfoChanged);
+
+ // If newObserver is cached it won't call update until the next timer update,
+ // so update the observer now.
+ m_mountPointObserver->update();
+ }
+}
+
+void SpaceInfoObserver::spaceInfoChanged(quint64 size, quint64 available)
+{
+ // Make sure that the size has actually changed
+ if (m_dataSize != size || m_dataAvailable != available) {
+ m_dataSize = size;
+ m_dataAvailable = available;
+
+ emit valuesChanged();
}
}
diff --git a/src/statusbar/spaceinfoobserver.h b/src/statusbar/spaceinfoobserver.h
index d2fb6ebf3..e1311abde 100644
--- a/src/statusbar/spaceinfoobserver.h
+++ b/src/statusbar/spaceinfoobserver.h
@@ -22,7 +22,9 @@
#include <QObject>
-class KUrl;
+#include <KIO/Job>
+
+class QUrl;
class MountPointObserver;
class SpaceInfoObserver : public QObject
@@ -30,22 +32,28 @@ class SpaceInfoObserver : public QObject
Q_OBJECT
public:
- explicit SpaceInfoObserver(const KUrl& url, QObject* parent = 0);
+ explicit SpaceInfoObserver(const QUrl& url, QObject* parent = 0);
virtual ~SpaceInfoObserver();
quint64 size() const;
quint64 available() const;
- void setUrl(const KUrl& url);
+ void setUrl(const QUrl& url);
signals:
/**
- * This signal is emitted if the information that size() and/or available() will return has changed.
+ * This signal is emitted when the size or available space changes.
*/
void valuesChanged();
+private slots:
+ void spaceInfoChanged(quint64 size, quint64 available);
+
private:
MountPointObserver* m_mountPointObserver;
+
+ quint64 m_dataSize;
+ quint64 m_dataAvailable;
};
#endif
diff --git a/src/statusbar/spaceinfotoolsmenu.cpp b/src/statusbar/spaceinfotoolsmenu.cpp
new file mode 100644
index 000000000..bce5ba11d
--- /dev/null
+++ b/src/statusbar/spaceinfotoolsmenu.cpp
@@ -0,0 +1,103 @@
+/***************************************************************************
+ * Copyright (C) 2014 by Gregor Mi <[email protected]> *
+ * *
+ * 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 "spaceinfotoolsmenu.h"
+
+#include <QAction>
+#include <QUrl>
+
+#include <KMountPoint>
+#include <KLocalizedString>
+#include <KRun>
+#include <KService>
+
+SpaceInfoToolsMenu::SpaceInfoToolsMenu(QWidget* parent, QUrl url)
+ : QMenu(parent)
+{
+ const QString notInstalled = " [" + i18nc("@action:inmenu", "not installed") + "]";
+
+ // find service
+ //
+ const auto filelightService = KService::serviceByDesktopName("org.kde.filelight");
+ if (filelightService && filelightService->isApplication()) {
+ const auto filelightIcon = QIcon::fromTheme(filelightService->icon());
+
+ if (url.isLocalFile()) { // 2015-01-12: Filelight can handle FTP connections but KIO/kioexec cannot (bug or feature?), so we don't offer it in this case
+ // add action and connect signals
+ //
+ const auto startFilelightDirectoryAction = addAction(filelightService->genericName() + " - "
+ + i18nc("@action:inmenu", "current folder"));
+ startFilelightDirectoryAction->setIcon(filelightIcon);
+
+ connect(startFilelightDirectoryAction, &QAction::triggered, this, [filelightService, url](bool) {
+ KRun::runService(*filelightService, { url }, nullptr);
+ });
+ }
+
+ if (url.isLocalFile()) { // makes no sense for non-local URLs (e.g. FTP server), so we don't offer it in this case
+ // add action and connect signals
+ //
+ const auto startFilelightDeviceAction = addAction(filelightService->genericName() + " - "
+ + i18nc("@action:inmenu", "current device"));
+ startFilelightDeviceAction->setIcon(filelightIcon);
+
+ connect(startFilelightDeviceAction, &QAction::triggered, this, [filelightService, url](bool) {
+ KMountPoint::Ptr mountPoint = KMountPoint::currentMountPoints().findByPath(url.toLocalFile());
+ KRun::runService(*filelightService, { mountPoint->mountPoint() }, nullptr);
+ });
+ }
+
+ // add action and connect signals
+ //
+ const auto startFilelightAllDevicesAction = addAction(filelightService->genericName() + " - "
+ + i18nc("@action:inmenu", "all devices"));
+ startFilelightAllDevicesAction->setIcon(filelightIcon);
+
+ connect(startFilelightAllDevicesAction, &QAction::triggered, this, [filelightService](bool) {
+ KRun::runService(*filelightService, { }, nullptr);
+ });
+ } else {
+ const auto startFilelightDirectoryAction = addAction("Filelight" + notInstalled);
+ startFilelightDirectoryAction->setEnabled(false);
+ }
+
+ // find service
+ //
+ const auto kdiskfreeService = KService::serviceByDesktopName("kdf");
+ if (kdiskfreeService && kdiskfreeService->isApplication()) {
+ //
+ // add action and connect signals
+ //
+ const auto startKDiskFreeAction = addAction(kdiskfreeService->genericName());
+ startKDiskFreeAction->setIcon(QIcon::fromTheme(kdiskfreeService->icon()));
+
+ connect(startKDiskFreeAction, &QAction::triggered, this, [kdiskfreeService](bool) {
+ KRun::runService(*kdiskfreeService, { }, nullptr);
+ });
+ } else {
+ const auto startKDiskFreeAction = addAction("KDiskFree" + notInstalled);
+ startKDiskFreeAction->setEnabled(false);
+ }
+}
+
+SpaceInfoToolsMenu::~SpaceInfoToolsMenu()
+{
+}
+
+
diff --git a/src/statusbar/spaceinfotoolsmenu.h b/src/statusbar/spaceinfotoolsmenu.h
new file mode 100644
index 000000000..3ca2e184f
--- /dev/null
+++ b/src/statusbar/spaceinfotoolsmenu.h
@@ -0,0 +1,41 @@
+/***************************************************************************
+ * Copyright (C) 2014 by Gregor Mi <[email protected]> *
+ * *
+ * 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 *
+ ***************************************************************************/
+
+#ifndef SPACEINFOTOOLSMENU_H
+#define SPACEINFOTOOLSMENU_H
+
+#include <QObject>
+#include <QMenu>
+
+class QWidget;
+class QUrl;
+
+/**
+ * A menu with tools that help to find out more about free disk space for the given url.
+ */
+class SpaceInfoToolsMenu : public QMenu
+{
+ Q_OBJECT
+
+public:
+ explicit SpaceInfoToolsMenu(QWidget* parent, QUrl url);
+ virtual ~SpaceInfoToolsMenu();
+};
+
+#endif
diff --git a/src/statusbar/statusbarspaceinfo.cpp b/src/statusbar/statusbarspaceinfo.cpp
index 3692947b1..127641e60 100644
--- a/src/statusbar/statusbarspaceinfo.cpp
+++ b/src/statusbar/statusbarspaceinfo.cpp
@@ -21,11 +21,13 @@
#include "statusbarspaceinfo.h"
#include "spaceinfoobserver.h"
+#include "spaceinfotoolsmenu.h"
-#include <KLocale>
+#include <QMouseEvent>
+
+#include <KLocalizedString>
#include <KIO/Job>
-#include <QKeyEvent>
StatusBarSpaceInfo::StatusBarSpaceInfo(QWidget* parent) :
KCapacityBar(KCapacityBar::DrawTextInline, parent),
@@ -37,7 +39,7 @@ StatusBarSpaceInfo::~StatusBarSpaceInfo()
{
}
-void StatusBarSpaceInfo::setUrl(const KUrl& url)
+void StatusBarSpaceInfo::setUrl(const QUrl& url)
{
if (m_url != url) {
m_url = url;
@@ -47,7 +49,7 @@ void StatusBarSpaceInfo::setUrl(const KUrl& url)
}
}
-KUrl StatusBarSpaceInfo::url() const
+QUrl StatusBarSpaceInfo::url() const
{
return m_url;
}
@@ -57,7 +59,7 @@ void StatusBarSpaceInfo::showEvent(QShowEvent* event)
KCapacityBar::showEvent(event);
m_observer.reset(new SpaceInfoObserver(m_url, this));
slotValuesChanged();
- connect(m_observer.data(), SIGNAL(valuesChanged()), this, SLOT(slotValuesChanged()));
+ connect(m_observer.data(), &SpaceInfoObserver::valuesChanged, this, &StatusBarSpaceInfo::slotValuesChanged);
}
void StatusBarSpaceInfo::hideEvent(QHideEvent* event)
@@ -66,6 +68,14 @@ void StatusBarSpaceInfo::hideEvent(QHideEvent* event)
KCapacityBar::hideEvent(event);
}
+void StatusBarSpaceInfo::mousePressEvent(QMouseEvent* event)
+{
+ if (event->button() == Qt::LeftButton) {
+ SpaceInfoToolsMenu spaceInfoToolsMenu(this, m_url);
+ spaceInfoToolsMenu.exec(QCursor::pos());
+ }
+}
+
void StatusBarSpaceInfo::slotValuesChanged()
{
Q_ASSERT(m_observer);
@@ -87,4 +97,3 @@ void StatusBarSpaceInfo::slotValuesChanged()
}
}
-#include "statusbarspaceinfo.moc"
diff --git a/src/statusbar/statusbarspaceinfo.h b/src/statusbar/statusbarspaceinfo.h
index 1065d9f45..326c419ab 100644
--- a/src/statusbar/statusbarspaceinfo.h
+++ b/src/statusbar/statusbarspaceinfo.h
@@ -20,16 +20,14 @@
#ifndef STATUSBARSPACEINFO_H
#define STATUSBARSPACEINFO_H
-#include <KUrl>
+#include <QUrl>
-#include <QColor>
-#include <QKeyEvent>
-#include <QString>
-#include <kcapacitybar.h>
+#include <KCapacityBar>
class QHideEvent;
class QShowEvent;
+class QMouseEvent;
class SpaceInfoObserver;
@@ -45,19 +43,20 @@ public:
explicit StatusBarSpaceInfo(QWidget* parent = 0);
virtual ~StatusBarSpaceInfo();
- void setUrl(const KUrl& url);
- KUrl url() const;
+ void setUrl(const QUrl& url);
+ QUrl url() const;
protected:
- void showEvent(QShowEvent* event);
- void hideEvent(QHideEvent* event);
+ void showEvent(QShowEvent* event) Q_DECL_OVERRIDE;
+ void hideEvent(QHideEvent* event) Q_DECL_OVERRIDE;
+ void mousePressEvent(QMouseEvent* event) Q_DECL_OVERRIDE;
private slots:
void slotValuesChanged();
private:
QScopedPointer<SpaceInfoObserver> m_observer;
- KUrl m_url;
+ QUrl m_url;
};
#endif
diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt
index c1f4124ff..22a8b4849 100644
--- a/src/tests/CMakeLists.txt
+++ b/src/tests/CMakeLists.txt
@@ -1,23 +1,32 @@
set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} )
-include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_BUILD_DIR}/.. ${KDE4_INCLUDES} )
+
+find_package(Qt5Test CONFIG REQUIRED)
+include(ECMMarkAsTest)
# needed on windows to correctly use the files from dolphinprivate
-add_definitions(-DLIBDOLPHINPRIVATE_EXPORT=)
+add_definitions(-DDOLPHIN_EXPORT=)
# KItemSetTest
set(kitemsettest_SRCS
kitemsettest.cpp
../kitemviews/kitemset.cpp
)
-kde4_add_unit_test(kitemsettest TEST ${kitemsettest_SRCS})
-target_link_libraries(kitemsettest dolphinprivate ${KDE4_KIO_LIBS} ${QT_QTTEST_LIBRARY})
+
+add_executable(kitemsettest ${kitemsettest_SRCS})
+add_test(kitemsettest kitemsettest)
+ecm_mark_as_test(kitemsettest)
+target_link_libraries(kitemsettest dolphinprivate Qt5::Test)
# KItemRangeTest
set(kitemrangetest_SRCS
kitemrangetest.cpp
)
-kde4_add_unit_test(kitemrangetest TEST ${kitemrangetest_SRCS})
-target_link_libraries(kitemrangetest dolphinprivate ${KDE4_KIO_LIBS} ${QT_QTTEST_LIBRARY})
+
+add_executable(kitemrangetest ${kitemrangetest_SRCS})
+add_test(kitemrangetest kitemrangetest)
+ecm_mark_as_test(kitemrangetest)
+target_link_libraries(kitemrangetest dolphinprivate Qt5::Test)
+
# KItemListSelectionManagerTest
set(kitemlistselectionmanagertest_SRCS
@@ -26,8 +35,11 @@ set(kitemlistselectionmanagertest_SRCS
../kitemviews/kitemmodelbase.cpp
../kitemviews/kitemset.cpp
)
-kde4_add_unit_test(kitemlistselectionmanagertest TEST ${kitemlistselectionmanagertest_SRCS})
-target_link_libraries(kitemlistselectionmanagertest dolphinprivate ${KDE4_KIO_LIBS} ${QT_QTTEST_LIBRARY})
+
+add_executable(kitemlistselectionmanagertest ${kitemlistselectionmanagertest_SRCS})
+add_test(kitemlistselectionmanagertest kitemlistselectionmanagertest)
+ecm_mark_as_test(kitemlistselectionmanagertest)
+target_link_libraries(kitemlistselectionmanagertest dolphinprivate Qt5::Test)
# KItemListControllerTest
set(kitemlistcontrollertest_SRCS
@@ -44,9 +56,17 @@ set(kitemlistcontrollertest_SRCS
../kitemviews/kitemset.cpp
../kitemviews/kstandarditemlistview.cpp
../kitemviews/kstandarditemlistwidget.cpp
+ ../dolphindebug.cpp
)
-kde4_add_unit_test(kitemlistcontrollertest TEST ${kitemlistcontrollertest_SRCS})
-target_link_libraries(kitemlistcontrollertest dolphinprivate ${KDE4_KIO_LIBS} ${QT_QTTEST_LIBRARY})
+
+kconfig_add_kcfg_files(kitemlistcontrollertest_SRCS GENERATE_MOC
+ ../settings/dolphin_generalsettings.kcfgc
+)
+
+add_executable(kitemlistcontrollertest ${kitemlistcontrollertest_SRCS})
+add_test(kitemlistcontrollertest kitemlistcontrollertest)
+ecm_mark_as_test(kitemlistcontrollertest)
+target_link_libraries(kitemlistcontrollertest dolphinprivate Qt5::Test)
# KFileItemListViewTest
set(kfileitemlistviewtest_SRCS
@@ -62,9 +82,17 @@ set(kfileitemlistviewtest_SRCS
../kitemviews/kitemset.cpp
../kitemviews/kstandarditemlistview.cpp
../kitemviews/kstandarditemlistwidget.cpp
+ ../dolphindebug.cpp
)
-kde4_add_unit_test(kfileitemlistviewtest TEST ${kfileitemlistviewtest_SRCS})
-target_link_libraries(kfileitemlistviewtest dolphinprivate ${KDE4_KIO_LIBS} ${QT_QTTEST_LIBRARY})
+
+kconfig_add_kcfg_files(kfileitemlistviewtest_SRCS GENERATE_MOC
+ ../settings/dolphin_generalsettings.kcfgc
+)
+
+add_executable(kfileitemlistviewtest ${kfileitemlistviewtest_SRCS})
+add_test(kfileitemlistviewtest kfileitemlistviewtest)
+ecm_mark_as_test(kfileitemlistviewtest)
+target_link_libraries(kfileitemlistviewtest dolphinprivate Qt5::Test)
# KFileItemModelTest
set(kfileitemmodeltest_SRCS
@@ -73,9 +101,17 @@ set(kfileitemmodeltest_SRCS
../kitemviews/kfileitemmodel.cpp
../kitemviews/kitemmodelbase.cpp
../kitemviews/kitemset.cpp
+ ../dolphindebug.cpp
)
-kde4_add_unit_test(kfileitemmodeltest TEST ${kfileitemmodeltest_SRCS})
-target_link_libraries(kfileitemmodeltest dolphinprivate ${KDE4_KIO_LIBS} ${QT_QTTEST_LIBRARY})
+
+kconfig_add_kcfg_files(kfileitemmodeltest_SRCS GENERATE_MOC
+ ../settings/dolphin_generalsettings.kcfgc
+)
+
+add_executable(kfileitemmodeltest ${kfileitemmodeltest_SRCS})
+add_test(kfileitemmodeltest kfileitemmodeltest)
+ecm_mark_as_test(kfileitemmodeltest)
+target_link_libraries(kfileitemmodeltest dolphinprivate Qt5::Test)
# KFileItemModelBenchmark
set(kfileitemmodelbenchmark_SRCS
@@ -83,31 +119,44 @@ set(kfileitemmodelbenchmark_SRCS
testdir.cpp
../kitemviews/kfileitemmodel.cpp
../kitemviews/kitemmodelbase.cpp
+ ../dolphindebug.cpp
+)
+
+kconfig_add_kcfg_files(kfileitemmodelbenchmark_SRCS GENERATE_MOC
+ ../settings/dolphin_generalsettings.kcfgc
)
-kde4_add_executable(kfileitemmodelbenchmark TEST ${kfileitemmodelbenchmark_SRCS})
-target_link_libraries(kfileitemmodelbenchmark dolphinprivate ${KDE4_KIO_LIBS} ${QT_QTTEST_LIBRARY})
+
+add_executable(kfileitemmodelbenchmark ${kfileitemmodelbenchmark_SRCS})
+ecm_mark_as_test(kfileitemmodelbenchmark)
+target_link_libraries(kfileitemmodelbenchmark dolphinprivate Qt5::Test)
# KItemListKeyboardSearchManagerTest
set(kitemlistkeyboardsearchmanagertest_SRCS
kitemlistkeyboardsearchmanagertest.cpp
../kitemviews/private/kitemlistkeyboardsearchmanager.cpp
)
-kde4_add_unit_test(kitemlistkeyboardsearchmanagertest TEST ${kitemlistkeyboardsearchmanagertest_SRCS})
-target_link_libraries(kitemlistkeyboardsearchmanagertest ${KDE4_KIO_LIBS} ${QT_QTTEST_LIBRARY})
+
+add_executable(kitemlistkeyboardsearchmanagertest ${kitemlistkeyboardsearchmanagertest_SRCS})
+add_test(kitemlistkeyboardsearchmanagertest kitemlistkeyboardsearchmanagertest)
+ecm_mark_as_test(kitemlistkeyboardsearchmanagertest)
+target_link_libraries(kitemlistkeyboardsearchmanagertest dolphinprivate Qt5::Test)
# DolphinSearchBox
-if (Baloo_FOUND)
+if (KF5Baloo_FOUND)
set(dolphinsearchboxtest_SRCS
dolphinsearchboxtest.cpp
../search/dolphinfacetswidget.cpp
../search/dolphinsearchbox.cpp
)
- kde4_add_kcfg_files(dolphinsearchboxtest_SRCS
+ kconfig_add_kcfg_files(dolphinsearchboxtest_SRCS
../search/dolphin_searchsettings.kcfgc
)
- kde4_add_unit_test(dolphinsearchboxtest TEST ${dolphinsearchboxtest_SRCS})
- target_link_libraries(dolphinsearchboxtest ${KDE4_KIO_LIBS} ${BALOO_LIBRARIES} ${QT_QTTEST_LIBRARY})
-endif (Baloo_FOUND)
+
+ add_executable(dolphinsearchboxtest ${dolphinsearchboxtest_SRCS})
+ add_test(dolphinsearchboxtest dolphinsearchboxtest)
+ ecm_mark_as_test(dolphinsearchboxtest)
+ target_link_libraries(dolphinsearchboxtest dolphinprivate Qt5::Test)
+endif()
# KStandardItemModelTest
set(kstandarditemmodeltest_SRCS
@@ -115,19 +164,27 @@ set(kstandarditemmodeltest_SRCS
../kitemviews/kstandarditem.cpp
../kitemviews/kstandarditemmodel.cpp
../kitemviews/kitemmodelbase.cpp
+ ../dolphindebug.cpp
)
-kde4_add_unit_test(kstandarditemmodeltest TEST ${kstandarditemmodeltest_SRCS})
-target_link_libraries(kstandarditemmodeltest dolphinprivate ${KDE4_KIO_LIBS} ${QT_QTTEST_LIBRARY})
+
+add_executable(kstandarditemmodeltest ${kstandarditemmodeltest_SRCS})
+add_test(kstandarditemmodeltest kstandarditemmodeltest)
+ecm_mark_as_test(kstandarditemmodeltest)
+target_link_libraries(kstandarditemmodeltest dolphinprivate Qt5::Test)
# ViewPropertiesTest
set(viewpropertiestest_SRCS
viewpropertiestest.cpp
testdir.cpp
../views/viewproperties.cpp
+ ../dolphindebug.cpp
)
-kde4_add_kcfg_files(viewpropertiestest_SRCS
+kconfig_add_kcfg_files(viewpropertiestest_SRCS GENERATE_MOC
../settings/dolphin_generalsettings.kcfgc
../settings/dolphin_directoryviewpropertysettings.kcfgc
)
-kde4_add_unit_test(viewpropertiestest TEST ${viewpropertiestest_SRCS})
-target_link_libraries(viewpropertiestest dolphinprivate ${KDE4_KIO_LIBS} ${QT_QTTEST_LIBRARY})
+
+add_executable(viewpropertiestest ${viewpropertiestest_SRCS})
+add_test(viewpropertiestest viewpropertiestest)
+ecm_mark_as_test(viewpropertiestest)
+target_link_libraries(viewpropertiestest dolphinprivate Qt5::Test)
diff --git a/src/tests/dolphinsearchboxtest.cpp b/src/tests/dolphinsearchboxtest.cpp
index af6b58d32..862a398a5 100644
--- a/src/tests/dolphinsearchboxtest.cpp
+++ b/src/tests/dolphinsearchboxtest.cpp
@@ -17,10 +17,9 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
-#include <qtest_kde.h>
-
#include "search/dolphinsearchbox.h"
-#include <qtestkeyboard.h>
+
+#include <QTest>
class DolphinSearchBoxTest : public QObject
{
@@ -65,6 +64,6 @@ void DolphinSearchBoxTest::testTextClearing()
QVERIFY(m_searchBox->text().isEmpty());
}
-QTEST_KDEMAIN(DolphinSearchBoxTest, GUI)
+QTEST_MAIN(DolphinSearchBoxTest)
#include "dolphinsearchboxtest.moc"
diff --git a/src/tests/kfileitemlistviewtest.cpp b/src/tests/kfileitemlistviewtest.cpp
index 9f1745840..cac4f7a58 100644
--- a/src/tests/kfileitemlistviewtest.cpp
+++ b/src/tests/kfileitemlistviewtest.cpp
@@ -17,18 +17,14 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
-#include <qtest_kde.h>
-
#include "kitemviews/kfileitemlistview.h"
#include "kitemviews/kfileitemmodel.h"
#include "kitemviews/private/kfileitemmodeldirlister.h"
#include "testdir.h"
#include <QGraphicsView>
-
-namespace {
- const int DefaultTimeout = 2000;
-};
+#include <QTest>
+#include <QSignalSpy>
class KFileItemListViewTest : public QObject
{
@@ -60,7 +56,7 @@ void KFileItemListViewTest::init()
m_graphicsView = new QGraphicsView();
m_graphicsView->show();
- QTest::qWaitForWindowShown(m_graphicsView);
+ QTest::qWaitForWindowExposed(m_graphicsView);
}
void KFileItemListViewTest::cleanup()
@@ -91,27 +87,29 @@ void KFileItemListViewTest::cleanup()
*/
void KFileItemListViewTest::testGroupedItemChanges()
{
- m_model->setGroupedSorting(true);
+ QSignalSpy itemsInsertedSpy(m_model, SIGNAL(itemsInserted(KItemRangeList)));
+ QVERIFY(itemsInsertedSpy.isValid());
+ QSignalSpy itemsRemovedSpy(m_model, SIGNAL(itemsRemoved(KItemRangeList)));
+ QVERIFY(itemsRemovedSpy.isValid());
- m_testDir->createFiles(QStringList() << "1" << "3" << "5");
+ m_model->setGroupedSorting(true);
+ m_testDir->createFiles({"1", "3", "5"});
m_model->loadDirectory(m_testDir->url());
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
QCOMPARE(m_model->count(), 3);
- m_testDir->createFiles(QStringList() << "2" << "4");
+ m_testDir->createFiles({"2", "4"});
m_model->m_dirLister->updateDirectory(m_testDir->url());
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
QCOMPARE(m_model->count(), 5);
- m_testDir->removeFile("1");
- m_testDir->removeFile("3");
- m_testDir->removeFile("5");
+ m_testDir->removeFiles({"1", "3", "5"});
m_model->m_dirLister->updateDirectory(m_testDir->url());
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsRemoved(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsRemovedSpy.wait());
QCOMPARE(m_model->count(), 2);
}
-QTEST_KDEMAIN(KFileItemListViewTest, GUI)
+QTEST_MAIN(KFileItemListViewTest)
#include "kfileitemlistviewtest.moc"
diff --git a/src/tests/kfileitemmodelbenchmark.cpp b/src/tests/kfileitemmodelbenchmark.cpp
index 66918b6ee..b73485efb 100644
--- a/src/tests/kfileitemmodelbenchmark.cpp
+++ b/src/tests/kfileitemmodelbenchmark.cpp
@@ -18,37 +18,37 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
-#include <qtest_kde.h>
+#include <QTest>
+#include <QSignalSpy>
+
+#include <algorithm>
+#include <random>
#include "kitemviews/kfileitemmodel.h"
#include "kitemviews/private/kfileitemmodelsortalgorithm.h"
#include "testdir.h"
-#include <KRandomSequence>
-
-void myMessageOutput(QtMsgType type, const char* msg)
+void myMessageOutput(QtMsgType type, const QMessageLogContext& context, const QString& msg)
{
+ Q_UNUSED(context);
+
switch (type) {
case QtDebugMsg:
break;
case QtWarningMsg:
break;
case QtCriticalMsg:
- fprintf(stderr, "Critical: %s\n", msg);
+ fprintf(stderr, "Critical: %s\n", msg.toLocal8Bit().data());
break;
case QtFatalMsg:
- fprintf(stderr, "Fatal: %s\n", msg);
+ fprintf(stderr, "Fatal: %s\n", msg.toLocal8Bit().data());
abort();
default:
break;
}
}
-namespace {
- const int DefaultTimeout = 5000;
-};
-
Q_DECLARE_METATYPE(KFileItemList)
Q_DECLARE_METATYPE(KItemRangeList)
@@ -167,7 +167,7 @@ void KFileItemModelBenchmark::insertAndRemoveManyItems()
// Avoid overhead caused by natural sorting
// and determining the isDir/isLink roles.
model.m_naturalSorting = false;
- model.setRoles(QSet<QByteArray>() << "text");
+ model.setRoles({"text"});
QSignalSpy spyItemsInserted(&model, SIGNAL(itemsInserted(KItemRangeList)));
QSignalSpy spyItemsRemoved(&model, SIGNAL(itemsRemoved(KItemRangeList)));
@@ -294,8 +294,9 @@ void KFileItemModelBenchmark::insertManyChildItems()
}
// Bring the items into random order.
- KRandomSequence randomSequence(0);
- randomSequence.randomize(newItems);
+ std::random_device rd;
+ std::mt19937 g(rd());
+ std::shuffle(newItems.begin(), newItems.end(), g);
// Measure how long it takes to insert and then remove all files.
QBENCHMARK {
@@ -318,17 +319,16 @@ void KFileItemModelBenchmark::insertManyChildItems()
KFileItemList KFileItemModelBenchmark::createFileItemList(const QStringList& fileNames, const QString& prefix)
{
// Suppress 'file does not exist anymore' messages from KFileItemPrivate::init().
- qInstallMsgHandler(myMessageOutput);
+ qInstallMessageHandler(myMessageOutput);
KFileItemList result;
foreach (const QString& name, fileNames) {
- const KUrl url(prefix + name);
- const KFileItem item(url, QString(), KFileItem::Unknown);
+ const KFileItem item(QUrl::fromLocalFile(prefix + name), QString(), KFileItem::Unknown);
result << item;
}
return result;
}
-QTEST_KDEMAIN(KFileItemModelBenchmark, NoGUI)
+QTEST_MAIN(KFileItemModelBenchmark)
#include "kfileitemmodelbenchmark.moc"
diff --git a/src/tests/kfileitemmodeltest.cpp b/src/tests/kfileitemmodeltest.cpp
index c584c5e62..eba32e1e1 100644
--- a/src/tests/kfileitemmodeltest.cpp
+++ b/src/tests/kfileitemmodeltest.cpp
@@ -18,37 +18,37 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
-#include <qtest_kde.h>
+#include <QTest>
+#include <QSignalSpy>
+#include <QTimer>
+#include <QMimeData>
-#include <KDirLister>
#include <kio/job.h>
#include "kitemviews/kfileitemmodel.h"
#include "kitemviews/private/kfileitemmodeldirlister.h"
#include "testdir.h"
-void myMessageOutput(QtMsgType type, const char* msg)
+void myMessageOutput(QtMsgType type, const QMessageLogContext& context, const QString& msg)
{
+ Q_UNUSED(context);
+
switch (type) {
case QtDebugMsg:
break;
case QtWarningMsg:
break;
case QtCriticalMsg:
- fprintf(stderr, "Critical: %s\n", msg);
+ fprintf(stderr, "Critical: %s\n", msg.toLocal8Bit().data());
break;
case QtFatalMsg:
- fprintf(stderr, "Fatal: %s\n", msg);
+ fprintf(stderr, "Fatal: %s\n", msg.toLocal8Bit().data());
abort();
default:
break;
}
}
-namespace {
- const int DefaultTimeout = 5000;
-};
-
Q_DECLARE_METATYPE(KItemRange)
Q_DECLARE_METATYPE(KItemRangeList)
Q_DECLARE_METATYPE(QList<int>)
@@ -109,7 +109,7 @@ void KFileItemModelTest::init()
{
// The item-model tests result in a huge number of debugging
// output from kdelibs. Only show critical and fatal messages.
- qInstallMsgHandler(myMessageOutput);
+ qInstallMessageHandler(myMessageOutput);
qRegisterMetaType<KItemRange>("KItemRange");
qRegisterMetaType<KItemRangeList>("KItemRangeList");
@@ -143,15 +143,15 @@ void KFileItemModelTest::testDefaultRoles()
void KFileItemModelTest::testDefaultSortRole()
{
- QCOMPARE(m_model->sortRole(), QByteArray("text"));
+ QSignalSpy itemsInsertedSpy(m_model, SIGNAL(itemsInserted(KItemRangeList)));
+ QVERIFY(itemsInsertedSpy.isValid());
- QStringList files;
- files << "c.txt" << "a.txt" << "b.txt";
+ QCOMPARE(m_model->sortRole(), QByteArray("text"));
- m_testDir->createFiles(files);
+ m_testDir->createFiles({"c.txt", "a.txt", "b.txt"});
m_model->loadDirectory(m_testDir->url());
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
QCOMPARE(m_model->count(), 3);
QCOMPARE(m_model->data(0)["text"].toString(), QString("a.txt"));
@@ -166,12 +166,12 @@ void KFileItemModelTest::testDefaultGroupedSorting()
void KFileItemModelTest::testNewItems()
{
- QStringList files;
- files << "a.txt" << "b.txt" << "c.txt";
- m_testDir->createFiles(files);
+ QSignalSpy itemsInsertedSpy(m_model, SIGNAL(itemsInserted(KItemRangeList)));
+
+ m_testDir->createFiles({"a.txt", "b.txt", "c.txt"});
m_model->loadDirectory(m_testDir->url());
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
QCOMPARE(m_model->count(), 3);
@@ -180,16 +180,18 @@ void KFileItemModelTest::testNewItems()
void KFileItemModelTest::testRemoveItems()
{
- m_testDir->createFile("a.txt");
- m_testDir->createFile("b.txt");
+ QSignalSpy itemsInsertedSpy(m_model, SIGNAL(itemsInserted(KItemRangeList)));
+ QSignalSpy itemsRemovedSpy(m_model, SIGNAL(itemsRemoved(KItemRangeList)));
+
+ m_testDir->createFiles({"a.txt", "b.txt"});
m_model->loadDirectory(m_testDir->url());
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
QCOMPARE(m_model->count(), 2);
QVERIFY(m_model->isConsistent());
m_testDir->removeFile("a.txt");
m_model->m_dirLister->updateDirectory(m_testDir->url());
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsRemoved(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsRemovedSpy.wait());
QCOMPARE(m_model->count(), 1);
QVERIFY(m_model->isConsistent());
}
@@ -200,18 +202,18 @@ void KFileItemModelTest::testDirLoadingCompleted()
QSignalSpy itemsInsertedSpy(m_model, SIGNAL(itemsInserted(KItemRangeList)));
QSignalSpy itemsRemovedSpy(m_model, SIGNAL(itemsRemoved(KItemRangeList)));
- m_testDir->createFiles(QStringList() << "a.txt" << "b.txt" << "c.txt");
+ m_testDir->createFiles({"a.txt", "b.txt", "c.txt"});
m_model->loadDirectory(m_testDir->url());
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(directoryLoadingCompleted()), DefaultTimeout));
+ QVERIFY(loadingCompletedSpy.wait());
QCOMPARE(loadingCompletedSpy.count(), 1);
QCOMPARE(itemsInsertedSpy.count(), 1);
QCOMPARE(itemsRemovedSpy.count(), 0);
QCOMPARE(m_model->count(), 3);
- m_testDir->createFiles(QStringList() << "d.txt" << "e.txt");
+ m_testDir->createFiles({"d.txt", "e.txt"});
m_model->m_dirLister->updateDirectory(m_testDir->url());
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(directoryLoadingCompleted()), DefaultTimeout));
+ QVERIFY(loadingCompletedSpy.wait());
QCOMPARE(loadingCompletedSpy.count(), 2);
QCOMPARE(itemsInsertedSpy.count(), 2);
QCOMPARE(itemsRemovedSpy.count(), 0);
@@ -220,7 +222,7 @@ void KFileItemModelTest::testDirLoadingCompleted()
m_testDir->removeFile("a.txt");
m_testDir->createFile("f.txt");
m_model->m_dirLister->updateDirectory(m_testDir->url());
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(directoryLoadingCompleted()), DefaultTimeout));
+ QVERIFY(loadingCompletedSpy.wait());
QCOMPARE(loadingCompletedSpy.count(), 3);
QCOMPARE(itemsInsertedSpy.count(), 3);
QCOMPARE(itemsRemovedSpy.count(), 1);
@@ -228,7 +230,7 @@ void KFileItemModelTest::testDirLoadingCompleted()
m_testDir->removeFile("b.txt");
m_model->m_dirLister->updateDirectory(m_testDir->url());
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsRemoved(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsRemovedSpy.wait());
QCOMPARE(loadingCompletedSpy.count(), 4);
QCOMPARE(itemsInsertedSpy.count(), 3);
QCOMPARE(itemsRemovedSpy.count(), 2);
@@ -239,16 +241,20 @@ void KFileItemModelTest::testDirLoadingCompleted()
void KFileItemModelTest::testSetData()
{
+ QSignalSpy itemsInsertedSpy(m_model, SIGNAL(itemsInserted(KItemRangeList)));
+ QVERIFY(itemsInsertedSpy.isValid());
+ QSignalSpy itemsChangedSpy(m_model, SIGNAL(itemsChanged(KItemRangeList, QSet<QByteArray>)));
+ QVERIFY(itemsChangedSpy.isValid());
+
m_testDir->createFile("a.txt");
m_model->loadDirectory(m_testDir->url());
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
QHash<QByteArray, QVariant> values;
values.insert("customRole1", "Test1");
values.insert("customRole2", "Test2");
- QSignalSpy itemsChangedSpy(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)));
m_model->setData(0, values);
QCOMPARE(itemsChangedSpy.count(), 1);
@@ -290,18 +296,21 @@ void KFileItemModelTest::testSetDataWithModifiedSortRole()
QFETCH(int, ratingIndex1);
QFETCH(int, ratingIndex2);
+ QSignalSpy itemsInsertedSpy(m_model, SIGNAL(itemsInserted(KItemRangeList)));
+ QVERIFY(itemsInsertedSpy.isValid());
+ QSignalSpy itemsMovedSpy(m_model, SIGNAL(itemsMoved(KItemRange,QList<int>)));
+ QVERIFY(itemsMovedSpy.isValid());
+
// Changing the value of a sort-role must result in
// a reordering of the items.
QCOMPARE(m_model->sortRole(), QByteArray("text"));
m_model->setSortRole("rating");
QCOMPARE(m_model->sortRole(), QByteArray("rating"));
- QStringList files;
- files << "a.txt" << "b.txt" << "c.txt";
- m_testDir->createFiles(files);
+ m_testDir->createFiles({"a.txt", "b.txt", "c.txt"});
m_model->loadDirectory(m_testDir->url());
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
// Fill the "rating" role of each file:
// a.txt -> 2
@@ -331,7 +340,7 @@ void KFileItemModelTest::testSetDataWithModifiedSortRole()
m_model->setData(changedIndex, rating);
if (expectMoveSignal) {
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsMoved(KItemRange,QList<int>)), DefaultTimeout));
+ QVERIFY(itemsMovedSpy.wait());
}
QCOMPARE(m_model->data(0).value("rating").toInt(), ratingIndex0);
@@ -342,14 +351,16 @@ void KFileItemModelTest::testSetDataWithModifiedSortRole()
void KFileItemModelTest::testChangeSortRole()
{
+ QSignalSpy itemsInsertedSpy(m_model, SIGNAL(itemsInserted(KItemRangeList)));
+ QSignalSpy itemsMovedSpy(m_model, SIGNAL(itemsMoved(KItemRange,QList<int>)));
+ QVERIFY(itemsMovedSpy.isValid());
+
QCOMPARE(m_model->sortRole(), QByteArray("text"));
- QStringList files;
- files << "a.txt" << "b.jpg" << "c.txt";
- m_testDir->createFiles(files);
+ m_testDir->createFiles({"a.txt", "b.jpg", "c.txt"});
m_model->loadDirectory(m_testDir->url());
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
QCOMPARE(itemsInModel(), QStringList() << "a.txt" << "b.jpg" << "c.txt");
// Simulate that KFileItemModelRolesUpdater determines the mime type.
@@ -360,10 +371,9 @@ void KFileItemModelTest::testChangeSortRole()
}
// Now: sort by type.
- QSignalSpy spyItemsMoved(m_model, SIGNAL(itemsMoved(KItemRange,QList<int>)));
m_model->setSortRole("type");
QCOMPARE(m_model->sortRole(), QByteArray("type"));
- QVERIFY(!spyItemsMoved.isEmpty());
+ QVERIFY(!itemsMovedSpy.isEmpty());
// The actual order of the files might depend on the translation of the
// result of KFileItem::mimeComment() in the user's language.
@@ -381,16 +391,18 @@ void KFileItemModelTest::testChangeSortRole()
void KFileItemModelTest::testResortAfterChangingName()
{
+ QSignalSpy itemsInsertedSpy(m_model, SIGNAL(itemsInserted(KItemRangeList)));
+ QSignalSpy itemsMovedSpy(m_model, SIGNAL(itemsMoved(KItemRange,QList<int>)));
+ QVERIFY(itemsMovedSpy.isValid());
+
// We sort by size in a directory where all files have the same size.
// Therefore, the files are sorted by their names.
m_model->setSortRole("size");
- QStringList files;
- files << "a.txt" << "b.txt" << "c.txt";
- m_testDir->createFiles(files);
+ m_testDir->createFiles({"a.txt", "b.txt", "c.txt"});
m_model->loadDirectory(m_testDir->url());
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
QCOMPARE(itemsInModel(), QStringList() << "a.txt" << "b.txt" << "c.txt");
// We rename a.txt to d.txt. Even though the size has not changed at all,
@@ -399,25 +411,25 @@ void KFileItemModelTest::testResortAfterChangingName()
data.insert("text", "d.txt");
m_model->setData(0, data);
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsMoved(KItemRange,QList<int>)), DefaultTimeout));
+ QVERIFY(itemsMovedSpy.wait());
QCOMPARE(itemsInModel(), QStringList() << "b.txt" << "c.txt" << "d.txt");
// We rename d.txt back to a.txt using the dir lister's refreshItems() signal.
const KFileItem fileItemD = m_model->fileItem(2);
KFileItem fileItemA = fileItemD;
- KUrl urlA = fileItemA.url();
- urlA.setFileName("a.txt");
+ QUrl urlA = fileItemA.url().adjusted(QUrl::RemoveFilename);
+ urlA.setPath(urlA.path() + "a.txt");
fileItemA.setUrl(urlA);
- m_model->slotRefreshItems(QList<QPair<KFileItem, KFileItem> >() << qMakePair(fileItemD, fileItemA));
+ m_model->slotRefreshItems({qMakePair(fileItemD, fileItemA)});
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsMoved(KItemRange,QList<int>)), DefaultTimeout));
+ QVERIFY(itemsMovedSpy.wait());
QCOMPARE(itemsInModel(), QStringList() << "a.txt" << "b.txt" << "c.txt");
}
void KFileItemModelTest::testModelConsistencyWhenInsertingItems()
{
- //QSKIP("Temporary disabled", SkipSingle);
+ QSignalSpy itemsInsertedSpy(m_model, SIGNAL(itemsInserted(KItemRangeList)));
// KFileItemModel prevents that inserting a punch of items sequentially
// results in an itemsInserted()-signal for each item. Instead internally
@@ -427,14 +439,14 @@ void KFileItemModelTest::testModelConsistencyWhenInsertingItems()
// the timeout to 1 millisecond.
m_testDir->createFile("1");
m_model->loadDirectory(m_testDir->url());
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
QCOMPARE(m_model->count(), 1);
// Insert 10 items for 20 times. After each insert operation the model consistency
// is checked.
QSet<int> insertedItems;
for (int i = 0; i < 20; ++i) {
- QSignalSpy spy(m_model, SIGNAL(itemsInserted(KItemRangeList)));
+ itemsInsertedSpy.clear();
for (int j = 0; j < 10; ++j) {
int itemName = qrand();
@@ -447,8 +459,8 @@ void KFileItemModelTest::testModelConsistencyWhenInsertingItems()
}
m_model->m_dirLister->updateDirectory(m_testDir->url());
- if (spy.count() == 0) {
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ if (itemsInsertedSpy.count() == 0) {
+ QVERIFY(itemsInsertedSpy.wait());
}
QVERIFY(m_model->isConsistent());
@@ -459,18 +471,17 @@ void KFileItemModelTest::testModelConsistencyWhenInsertingItems()
void KFileItemModelTest::testItemRangeConsistencyWhenInsertingItems()
{
- QStringList files;
- files << "B" << "E" << "G";
- m_testDir->createFiles(files);
+ QSignalSpy itemsInsertedSpy(m_model, SIGNAL(itemsInserted(KItemRangeList)));
+
+ m_testDir->createFiles({"B", "E", "G"});
// Due to inserting the 3 items one item-range with index == 0 and
// count == 3 must be given
- QSignalSpy spy1(m_model, SIGNAL(itemsInserted(KItemRangeList)));
m_model->loadDirectory(m_testDir->url());
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
- QCOMPARE(spy1.count(), 1);
- QList<QVariant> arguments = spy1.takeFirst();
+ QCOMPARE(itemsInsertedSpy.count(), 1);
+ QList<QVariant> arguments = itemsInsertedSpy.takeFirst();
KItemRangeList itemRangeList = arguments.at(0).value<KItemRangeList>();
QCOMPARE(itemRangeList, KItemRangeList() << KItemRange(0, 3));
@@ -486,22 +497,26 @@ void KFileItemModelTest::testItemRangeConsistencyWhenInsertingItems()
// index: 1, count: 2 for B, C
// index: 2, count: 1 for G
- files.clear();
- files << "A" << "C" << "D" << "F";
- m_testDir->createFiles(files);
+ m_testDir->createFiles({"A", "C", "D", "F"});
- QSignalSpy spy2(m_model, SIGNAL(itemsInserted(KItemRangeList)));
m_model->m_dirLister->updateDirectory(m_testDir->url());
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
- QCOMPARE(spy2.count(), 1);
- arguments = spy2.takeFirst();
+ QCOMPARE(itemsInsertedSpy.count(), 1);
+ arguments = itemsInsertedSpy.takeFirst();
itemRangeList = arguments.at(0).value<KItemRangeList>();
QCOMPARE(itemRangeList, KItemRangeList() << KItemRange(0, 1) << KItemRange(1, 2) << KItemRange(2, 1));
}
void KFileItemModelTest::testExpandItems()
{
+ QSignalSpy itemsInsertedSpy(m_model, SIGNAL(itemsInserted(KItemRangeList)));
+ QVERIFY(itemsInsertedSpy.isValid());
+ QSignalSpy itemsRemovedSpy(m_model, SIGNAL(itemsRemoved(KItemRangeList)));
+ QVERIFY(itemsRemovedSpy.isValid());
+ QSignalSpy loadingCompletedSpy(m_model, SIGNAL(directoryLoadingCompleted()));
+ QVERIFY(loadingCompletedSpy.isValid());
+
// Test expanding subfolders in a folder with the items "a/", "a/a/", "a/a/1", "a/a-1/", "a/a-1/1".
// Besides testing the basic item expansion functionality, the test makes sure that
// KFileItemModel::expansionLevelsCompare(const KFileItem& a, const KFileItem& b)
@@ -512,16 +527,16 @@ void KFileItemModelTest::testExpandItems()
modelRoles << "isExpanded" << "isExpandable" << "expandedParentsCount";
m_model->setRoles(modelRoles);
- QStringList files;
- files << "a/a/1" << "a/a-1/1"; // missing folders are created automatically
- m_testDir->createFiles(files);
+ m_testDir->createFiles({"a/a/1", "a/a-1/1"});
// Store the URLs of all folders in a set.
- QSet<KUrl> allFolders;
- allFolders << KUrl(m_testDir->name() + 'a') << KUrl(m_testDir->name() + "a/a") << KUrl(m_testDir->name() + "a/a-1");
+ QSet<QUrl> allFolders;
+ allFolders << QUrl::fromLocalFile(m_testDir->path() + "/a")
+ << QUrl::fromLocalFile(m_testDir->path() + "/a/a")
+ << QUrl::fromLocalFile(m_testDir->path() + "/a/a-1");
m_model->loadDirectory(m_testDir->url());
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
// So far, the model contains only "a/"
QCOMPARE(m_model->count(), 1);
@@ -529,17 +544,19 @@ void KFileItemModelTest::testExpandItems()
QVERIFY(!m_model->isExpanded(0));
QVERIFY(m_model->expandedDirectories().empty());
- QSignalSpy spyInserted(m_model, SIGNAL(itemsInserted(KItemRangeList)));
+ QCOMPARE(itemsInsertedSpy.count(), 1);
+ KItemRangeList itemRangeList = itemsInsertedSpy.takeFirst().at(0).value<KItemRangeList>();
+ QCOMPARE(itemRangeList, KItemRangeList() << KItemRange(0, 1)); // 1 new item "a/" with index 0
// Expand the folder "a/" -> "a/a/" and "a/a-1/" become visible
m_model->setExpanded(0, true);
QVERIFY(m_model->isExpanded(0));
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
QCOMPARE(m_model->count(), 3); // 3 items: "a/", "a/a/", "a/a-1/"
- QCOMPARE(m_model->expandedDirectories(), QSet<KUrl>() << KUrl(m_testDir->name() + 'a'));
+ QCOMPARE(m_model->expandedDirectories(), QSet<QUrl>() << QUrl::fromLocalFile(m_testDir->path() + "/a"));
- QCOMPARE(spyInserted.count(), 1);
- KItemRangeList itemRangeList = spyInserted.takeFirst().at(0).value<KItemRangeList>();
+ QCOMPARE(itemsInsertedSpy.count(), 1);
+ itemRangeList = itemsInsertedSpy.takeFirst().at(0).value<KItemRangeList>();
QCOMPARE(itemRangeList, KItemRangeList() << KItemRange(1, 2)); // 2 new items "a/a/" and "a/a-1/" with indices 1 and 2
QVERIFY(m_model->isExpandable(1));
@@ -550,12 +567,13 @@ void KFileItemModelTest::testExpandItems()
// Expand the folder "a/a/" -> "a/a/1" becomes visible
m_model->setExpanded(1, true);
QVERIFY(m_model->isExpanded(1));
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
QCOMPARE(m_model->count(), 4); // 4 items: "a/", "a/a/", "a/a/1", "a/a-1/"
- QCOMPARE(m_model->expandedDirectories(), QSet<KUrl>() << KUrl(m_testDir->name() + 'a') << KUrl(m_testDir->name() + "a/a"));
+ QCOMPARE(m_model->expandedDirectories(), QSet<QUrl>() << QUrl::fromLocalFile(m_testDir->path() + "/a")
+ << QUrl::fromLocalFile(m_testDir->path() + "/a/a"));
- QCOMPARE(spyInserted.count(), 1);
- itemRangeList = spyInserted.takeFirst().at(0).value<KItemRangeList>();
+ QCOMPARE(itemsInsertedSpy.count(), 1);
+ itemRangeList = itemsInsertedSpy.takeFirst().at(0).value<KItemRangeList>();
QCOMPARE(itemRangeList, KItemRangeList() << KItemRange(2, 1)); // 1 new item "a/a/1" with index 2
QVERIFY(!m_model->isExpandable(2));
@@ -564,27 +582,25 @@ void KFileItemModelTest::testExpandItems()
// Expand the folder "a/a-1/" -> "a/a-1/1" becomes visible
m_model->setExpanded(3, true);
QVERIFY(m_model->isExpanded(3));
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
QCOMPARE(m_model->count(), 5); // 5 items: "a/", "a/a/", "a/a/1", "a/a-1/", "a/a-1/1"
QCOMPARE(m_model->expandedDirectories(), allFolders);
- QCOMPARE(spyInserted.count(), 1);
- itemRangeList = spyInserted.takeFirst().at(0).value<KItemRangeList>();
+ QCOMPARE(itemsInsertedSpy.count(), 1);
+ itemRangeList = itemsInsertedSpy.takeFirst().at(0).value<KItemRangeList>();
QCOMPARE(itemRangeList, KItemRangeList() << KItemRange(4, 1)); // 1 new item "a/a-1/1" with index 4
QVERIFY(!m_model->isExpandable(4));
QVERIFY(!m_model->isExpanded(4));
- QSignalSpy spyRemoved(m_model, SIGNAL(itemsRemoved(KItemRangeList)));
-
// Collapse the top-level folder -> all other items should disappear
m_model->setExpanded(0, false);
QVERIFY(!m_model->isExpanded(0));
QCOMPARE(m_model->count(), 1);
- QVERIFY(!m_model->expandedDirectories().contains(KUrl(m_testDir->name() + 'a'))); // TODO: Make sure that child URLs are also removed
+ QVERIFY(!m_model->expandedDirectories().contains(QUrl::fromLocalFile(m_testDir->path() + "/a"))); // TODO: Make sure that child URLs are also removed
- QCOMPARE(spyRemoved.count(), 1);
- itemRangeList = spyRemoved.takeFirst().at(0).value<KItemRangeList>();
+ QCOMPARE(itemsRemovedSpy.count(), 1);
+ itemRangeList = itemsRemovedSpy.takeFirst().at(0).value<KItemRangeList>();
QCOMPARE(itemRangeList, KItemRangeList() << KItemRange(1, 4)); // 4 items removed
QVERIFY(m_model->isConsistent());
@@ -595,7 +611,7 @@ void KFileItemModelTest::testExpandItems()
m_model->loadDirectory(m_testDir->url());
m_model->restoreExpandedDirectories(allFolders);
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(directoryLoadingCompleted()), DefaultTimeout));
+ QVERIFY(loadingCompletedSpy.wait());
QCOMPARE(m_model->count(), 5); // 5 items: "a/", "a/a/", "a/a/1", "a/a-1/", "a/a-1/1"
QVERIFY(m_model->isExpanded(0));
QVERIFY(m_model->isExpanded(1));
@@ -607,30 +623,34 @@ void KFileItemModelTest::testExpandItems()
// Move to a sub folder, then call restoreExpandedFolders() *before* going back.
// This is how DolphinView restores the expanded folders when navigating in history.
- m_model->loadDirectory(KUrl(m_testDir->name() + "a/a/"));
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(directoryLoadingCompleted()), DefaultTimeout));
+ m_model->loadDirectory(QUrl::fromLocalFile(m_testDir->path() + "/a/a/"));
+ QVERIFY(loadingCompletedSpy.wait());
QCOMPARE(m_model->count(), 1); // 1 item: "1"
m_model->restoreExpandedDirectories(allFolders);
m_model->loadDirectory(m_testDir->url());
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(directoryLoadingCompleted()), DefaultTimeout));
+ QVERIFY(loadingCompletedSpy.wait());
QCOMPARE(m_model->count(), 5); // 5 items: "a/", "a/a/", "a/a/1", "a/a-1/", "a/a-1/1"
QCOMPARE(m_model->expandedDirectories(), allFolders);
// Remove all expanded items by changing the roles
- spyRemoved.clear();
+ itemsRemovedSpy.clear();
m_model->setRoles(originalModelRoles);
QVERIFY(!m_model->isExpanded(0));
QCOMPARE(m_model->count(), 1);
- QVERIFY(!m_model->expandedDirectories().contains(KUrl(m_testDir->name() + 'a')));
+ QVERIFY(!m_model->expandedDirectories().contains(QUrl::fromLocalFile(m_testDir->path() + "/a")));
- QCOMPARE(spyRemoved.count(), 1);
- itemRangeList = spyRemoved.takeFirst().at(0).value<KItemRangeList>();
+ QCOMPARE(itemsRemovedSpy.count(), 1);
+ itemRangeList = itemsRemovedSpy.takeFirst().at(0).value<KItemRangeList>();
QCOMPARE(itemRangeList, KItemRangeList() << KItemRange(1, 4)); // 4 items removed
QVERIFY(m_model->isConsistent());
}
void KFileItemModelTest::testExpandParentItems()
{
+ QSignalSpy itemsInsertedSpy(m_model, SIGNAL(itemsInserted(KItemRangeList)));
+ QSignalSpy loadingCompletedSpy(m_model, SIGNAL(directoryLoadingCompleted()));
+ QVERIFY(loadingCompletedSpy.isValid());
+
// Create a tree structure of folders:
// a 1/
// a 1/b1/
@@ -643,20 +663,18 @@ void KFileItemModelTest::testExpandParentItems()
modelRoles << "isExpanded" << "isExpandable" << "expandedParentsCount";
m_model->setRoles(modelRoles);
- QStringList files;
- files << "a 1/b1/c1/file.txt" << "a2/b2/c2/d2/file.txt"; // missing folders are created automatically
- m_testDir->createFiles(files);
+ m_testDir->createFiles({"a 1/b1/c1/file.txt", "a2/b2/c2/d2/file.txt"});
m_model->loadDirectory(m_testDir->url());
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
// So far, the model contains only "a 1/" and "a2/".
QCOMPARE(m_model->count(), 2);
QVERIFY(m_model->expandedDirectories().empty());
// Expand the parents of "a2/b2/c2".
- m_model->expandParentDirectories(KUrl(m_testDir->name() + "a2/b2/c2"));
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(directoryLoadingCompleted()), DefaultTimeout));
+ m_model->expandParentDirectories(QUrl::fromLocalFile(m_testDir->path() + "a2/b2/c2"));
+ QVERIFY(loadingCompletedSpy.wait());
// The model should now contain "a 1/", "a2/", "a2/b2/", and "a2/b2/c2/".
// It's important that only the parents of "a1/b1/c1" are expanded.
@@ -667,8 +685,8 @@ void KFileItemModelTest::testExpandParentItems()
QVERIFY(!m_model->isExpanded(3));
// Expand the parents of "a 1/b1".
- m_model->expandParentDirectories(KUrl(m_testDir->name() + "a 1/b1"));
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(directoryLoadingCompleted()), DefaultTimeout));
+ m_model->expandParentDirectories(QUrl::fromLocalFile(m_testDir->path() + "a 1/b1"));
+ QVERIFY(loadingCompletedSpy.wait());
// The model should now contain "a 1/", "a 1/b1/", "a2/", "a2/b2", and "a2/b2/c2/".
// It's important that only the parents of "a 1/b1/" and "a2/b2/c2/" are expanded.
@@ -682,7 +700,7 @@ void KFileItemModelTest::testExpandParentItems()
// Expand "a 1/b1/".
m_model->setExpanded(1, true);
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(directoryLoadingCompleted()), DefaultTimeout));
+ QVERIFY(loadingCompletedSpy.wait());
QCOMPARE(m_model->count(), 6);
QVERIFY(m_model->isExpanded(0));
QVERIFY(m_model->isExpanded(1));
@@ -710,38 +728,37 @@ void KFileItemModelTest::testExpandParentItems()
*/
void KFileItemModelTest::testMakeExpandedItemHidden()
{
+ QSignalSpy itemsInsertedSpy(m_model, SIGNAL(itemsInserted(KItemRangeList)));
+ QSignalSpy itemsRemovedSpy(m_model, SIGNAL(itemsRemoved(KItemRangeList)));
+
QSet<QByteArray> modelRoles = m_model->roles();
modelRoles << "isExpanded" << "isExpandable" << "expandedParentsCount";
m_model->setRoles(modelRoles);
- QStringList files;
- m_testDir->createFile("1a/2a/3a");
- m_testDir->createFile("1a/2a/3b");
- m_testDir->createFile("1a/2b");
- m_testDir->createFile("1b");
+ m_testDir->createFiles({"1a/2a/3a", "1a/2a/3b", "1a/2b", "1b"});
m_model->loadDirectory(m_testDir->url());
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
// So far, the model contains only "1a/" and "1b".
QCOMPARE(m_model->count(), 2);
m_model->setExpanded(0, true);
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
// Now "1a/2a" and "1a/2b" have appeared.
QCOMPARE(m_model->count(), 4);
m_model->setExpanded(1, true);
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
QCOMPARE(m_model->count(), 6);
// Rename "1a/2" and make it hidden.
- const QString oldPath = m_model->fileItem(0).url().path() + "/2a";
- const QString newPath = m_model->fileItem(0).url().path() + "/.2a";
+ const QUrl oldUrl = QUrl::fromLocalFile(m_model->fileItem(0).url().path() + "/2a");
+ const QUrl newUrl = QUrl::fromLocalFile(m_model->fileItem(0).url().path() + "/.2a");
- KIO::SimpleJob* job = KIO::rename(oldPath, newPath, KIO::HideProgressInfo);
+ KIO::SimpleJob* job = KIO::rename(oldUrl, newUrl, KIO::HideProgressInfo);
bool ok = job->exec();
QVERIFY(ok);
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsRemoved(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsRemovedSpy.wait());
// "1a/2" and its subfolders have disappeared now.
QVERIFY(m_model->isConsistent());
@@ -754,17 +771,17 @@ void KFileItemModelTest::testMakeExpandedItemHidden()
void KFileItemModelTest::testRemoveFilteredExpandedItems()
{
+ QSignalSpy itemsInsertedSpy(m_model, SIGNAL(itemsInserted(KItemRangeList)));
+
QSet<QByteArray> originalModelRoles = m_model->roles();
QSet<QByteArray> modelRoles = originalModelRoles;
modelRoles << "isExpanded" << "isExpandable" << "expandedParentsCount";
m_model->setRoles(modelRoles);
- QStringList files;
- files << "folder/child" << "file"; // missing folders are created automatically
- m_testDir->createFiles(files);
+ m_testDir->createFiles({"folder/child", "file"});
m_model->loadDirectory(m_testDir->url());
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
// So far, the model contains only "folder/" and "file".
QCOMPARE(m_model->count(), 2);
@@ -777,7 +794,7 @@ void KFileItemModelTest::testRemoveFilteredExpandedItems()
// Expand "folder" -> "folder/child" becomes visible.
m_model->setExpanded(0, true);
QVERIFY(m_model->isExpanded(0));
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
QCOMPARE(itemsInModel(), QStringList() << "folder" << "child" << "file");
// Add a name filter.
@@ -799,6 +816,10 @@ void KFileItemModelTest::testRemoveFilteredExpandedItems()
void KFileItemModelTest::testSorting()
{
+ QSignalSpy itemsInsertedSpy(m_model, SIGNAL(itemsInserted(KItemRangeList)));
+ QSignalSpy itemsMovedSpy(m_model, SIGNAL(itemsMoved(KItemRange,QList<int>)));
+ QVERIFY(itemsMovedSpy.isValid());
+
// Create some files with different sizes and modification times to check the different sorting options
QDateTime now = QDateTime::currentDateTime();
@@ -821,15 +842,15 @@ void KFileItemModelTest::testSorting()
m_testDir->createFile(".f");
m_model->loadDirectory(m_testDir->url());
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
- int index = m_model->index(KUrl(m_testDir->url().url() + 'c'));
+ int index = m_model->index(QUrl(m_testDir->url().url() + "/c"));
m_model->setExpanded(index, true);
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
- index = m_model->index(KUrl(m_testDir->url().url() + "c/c-2"));
+ index = m_model->index(QUrl(m_testDir->url().url() + "/c/c-2"));
m_model->setExpanded(index, true);
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
// Default: Sort by Name, ascending
QCOMPARE(m_model->sortRole(), QByteArray("text"));
@@ -838,16 +859,14 @@ void KFileItemModelTest::testSorting()
QVERIFY(!m_model->showHiddenFiles());
QCOMPARE(itemsInModel(), QStringList() << "c" << "c-2" << "c-3" << "c-1" << "a" << "b" << "d" << "e");
- QSignalSpy spyItemsMoved(m_model, SIGNAL(itemsMoved(KItemRange,QList<int>)));
-
// Sort by Name, ascending, 'Sort Folders First' disabled
m_model->setSortDirectoriesFirst(false);
QCOMPARE(m_model->sortRole(), QByteArray("text"));
QCOMPARE(m_model->sortOrder(), Qt::AscendingOrder);
QCOMPARE(itemsInModel(), QStringList() << "a" << "b" << "c" << "c-1" << "c-2" << "c-3" << "d" << "e");
- QCOMPARE(spyItemsMoved.count(), 1);
- QCOMPARE(spyItemsMoved.first().at(0).value<KItemRange>(), KItemRange(0, 6));
- QCOMPARE(spyItemsMoved.takeFirst().at(1).value<QList<int> >(), QList<int>() << 2 << 4 << 5 << 3 << 0 << 1);
+ QCOMPARE(itemsMovedSpy.count(), 1);
+ QCOMPARE(itemsMovedSpy.first().at(0).value<KItemRange>(), KItemRange(0, 6));
+ QCOMPARE(itemsMovedSpy.takeFirst().at(1).value<QList<int> >(), QList<int>() << 2 << 4 << 5 << 3 << 0 << 1);
// Sort by Name, descending
m_model->setSortDirectoriesFirst(true);
@@ -855,11 +874,11 @@ void KFileItemModelTest::testSorting()
QCOMPARE(m_model->sortRole(), QByteArray("text"));
QCOMPARE(m_model->sortOrder(), Qt::DescendingOrder);
QCOMPARE(itemsInModel(), QStringList() << "c" << "c-2" << "c-3" << "c-1" << "e" << "d" << "b" << "a");
- QCOMPARE(spyItemsMoved.count(), 2);
- QCOMPARE(spyItemsMoved.first().at(0).value<KItemRange>(), KItemRange(0, 6));
- QCOMPARE(spyItemsMoved.takeFirst().at(1).value<QList<int> >(), QList<int>() << 4 << 5 << 0 << 3 << 1 << 2);
- QCOMPARE(spyItemsMoved.first().at(0).value<KItemRange>(), KItemRange(4, 4));
- QCOMPARE(spyItemsMoved.takeFirst().at(1).value<QList<int> >(), QList<int>() << 7 << 6 << 5 << 4);
+ QCOMPARE(itemsMovedSpy.count(), 2);
+ QCOMPARE(itemsMovedSpy.first().at(0).value<KItemRange>(), KItemRange(0, 6));
+ QCOMPARE(itemsMovedSpy.takeFirst().at(1).value<QList<int> >(), QList<int>() << 4 << 5 << 0 << 3 << 1 << 2);
+ QCOMPARE(itemsMovedSpy.first().at(0).value<KItemRange>(), KItemRange(4, 4));
+ QCOMPARE(itemsMovedSpy.takeFirst().at(1).value<QList<int> >(), QList<int>() << 7 << 6 << 5 << 4);
// Sort by Date, descending
m_model->setSortDirectoriesFirst(true);
@@ -867,18 +886,18 @@ void KFileItemModelTest::testSorting()
QCOMPARE(m_model->sortRole(), QByteArray("date"));
QCOMPARE(m_model->sortOrder(), Qt::DescendingOrder);
QCOMPARE(itemsInModel(), QStringList() << "c" << "c-2" << "c-3" << "c-1" << "b" << "d" << "a" << "e");
- QCOMPARE(spyItemsMoved.count(), 1);
- QCOMPARE(spyItemsMoved.first().at(0).value<KItemRange>(), KItemRange(4, 4));
- QCOMPARE(spyItemsMoved.takeFirst().at(1).value<QList<int> >(), QList<int>() << 7 << 5 << 4 << 6);
+ QCOMPARE(itemsMovedSpy.count(), 1);
+ QCOMPARE(itemsMovedSpy.first().at(0).value<KItemRange>(), KItemRange(4, 4));
+ QCOMPARE(itemsMovedSpy.takeFirst().at(1).value<QList<int> >(), QList<int>() << 7 << 5 << 4 << 6);
// Sort by Date, ascending
m_model->setSortOrder(Qt::AscendingOrder);
QCOMPARE(m_model->sortRole(), QByteArray("date"));
QCOMPARE(m_model->sortOrder(), Qt::AscendingOrder);
QCOMPARE(itemsInModel(), QStringList() << "c" << "c-2" << "c-3" << "c-1" << "e" << "a" << "d" << "b");
- QCOMPARE(spyItemsMoved.count(), 1);
- QCOMPARE(spyItemsMoved.first().at(0).value<KItemRange>(), KItemRange(4, 4));
- QCOMPARE(spyItemsMoved.takeFirst().at(1).value<QList<int> >(), QList<int>() << 7 << 6 << 5 << 4);
+ QCOMPARE(itemsMovedSpy.count(), 1);
+ QCOMPARE(itemsMovedSpy.first().at(0).value<KItemRange>(), KItemRange(4, 4));
+ QCOMPARE(itemsMovedSpy.takeFirst().at(1).value<QList<int> >(), QList<int>() << 7 << 6 << 5 << 4);
// Sort by Date, ascending, 'Sort Folders First' disabled
m_model->setSortDirectoriesFirst(false);
@@ -886,18 +905,18 @@ void KFileItemModelTest::testSorting()
QCOMPARE(m_model->sortOrder(), Qt::AscendingOrder);
QVERIFY(!m_model->sortDirectoriesFirst());
QCOMPARE(itemsInModel(), QStringList() << "e" << "a" << "c" << "c-1" << "c-2" << "c-3" << "d" << "b");
- QCOMPARE(spyItemsMoved.count(), 1);
- QCOMPARE(spyItemsMoved.first().at(0).value<KItemRange>(), KItemRange(0, 6));
- QCOMPARE(spyItemsMoved.takeFirst().at(1).value<QList<int> >(), QList<int>() << 2 << 4 << 5 << 3 << 0 << 1);
+ QCOMPARE(itemsMovedSpy.count(), 1);
+ QCOMPARE(itemsMovedSpy.first().at(0).value<KItemRange>(), KItemRange(0, 6));
+ QCOMPARE(itemsMovedSpy.takeFirst().at(1).value<QList<int> >(), QList<int>() << 2 << 4 << 5 << 3 << 0 << 1);
// Sort by Name, ascending, 'Sort Folders First' disabled
m_model->setSortRole("text");
QCOMPARE(m_model->sortOrder(), Qt::AscendingOrder);
QVERIFY(!m_model->sortDirectoriesFirst());
QCOMPARE(itemsInModel(), QStringList() << "a" << "b" << "c" << "c-1" << "c-2" << "c-3" << "d" << "e");
- QCOMPARE(spyItemsMoved.count(), 1);
- QCOMPARE(spyItemsMoved.first().at(0).value<KItemRange>(), KItemRange(0, 8));
- QCOMPARE(spyItemsMoved.takeFirst().at(1).value<QList<int> >(), QList<int>() << 7 << 0 << 2 << 3 << 4 << 5 << 6 << 1);
+ QCOMPARE(itemsMovedSpy.count(), 1);
+ QCOMPARE(itemsMovedSpy.first().at(0).value<KItemRange>(), KItemRange(0, 8));
+ QCOMPARE(itemsMovedSpy.takeFirst().at(1).value<QList<int> >(), QList<int>() << 7 << 0 << 2 << 3 << 4 << 5 << 6 << 1);
// Sort by Size, ascending, 'Sort Folders First' disabled
m_model->setSortRole("size");
@@ -905,9 +924,9 @@ void KFileItemModelTest::testSorting()
QCOMPARE(m_model->sortOrder(), Qt::AscendingOrder);
QVERIFY(!m_model->sortDirectoriesFirst());
QCOMPARE(itemsInModel(), QStringList() << "c" << "c-2" << "c-3" << "c-1" << "a" << "b" << "e" << "d");
- QCOMPARE(spyItemsMoved.count(), 1);
- QCOMPARE(spyItemsMoved.first().at(0).value<KItemRange>(), KItemRange(0, 8));
- QCOMPARE(spyItemsMoved.takeFirst().at(1).value<QList<int> >(), QList<int>() << 4 << 5 << 0 << 3 << 1 << 2 << 7 << 6);
+ QCOMPARE(itemsMovedSpy.count(), 1);
+ QCOMPARE(itemsMovedSpy.first().at(0).value<KItemRange>(), KItemRange(0, 8));
+ QCOMPARE(itemsMovedSpy.takeFirst().at(1).value<QList<int> >(), QList<int>() << 4 << 5 << 0 << 3 << 1 << 2 << 7 << 6);
// In 'Sort by Size' mode, folders are always first -> changing 'Sort Folders First' does not resort the model
m_model->setSortDirectoriesFirst(true);
@@ -915,7 +934,7 @@ void KFileItemModelTest::testSorting()
QCOMPARE(m_model->sortOrder(), Qt::AscendingOrder);
QVERIFY(m_model->sortDirectoriesFirst());
QCOMPARE(itemsInModel(), QStringList() << "c" << "c-2" << "c-3" << "c-1" << "a" << "b" << "e" << "d");
- QCOMPARE(spyItemsMoved.count(), 0);
+ QCOMPARE(itemsMovedSpy.count(), 0);
// Sort by Size, descending, 'Sort Folders First' enabled
m_model->setSortOrder(Qt::DescendingOrder);
@@ -923,21 +942,21 @@ void KFileItemModelTest::testSorting()
QCOMPARE(m_model->sortOrder(), Qt::DescendingOrder);
QVERIFY(m_model->sortDirectoriesFirst());
QCOMPARE(itemsInModel(), QStringList() << "c" << "c-2" << "c-3" << "c-1" << "d" << "e" << "b" << "a");
- QCOMPARE(spyItemsMoved.count(), 1);
- QCOMPARE(spyItemsMoved.first().at(0).value<KItemRange>(), KItemRange(4, 4));
- QCOMPARE(spyItemsMoved.takeFirst().at(1).value<QList<int> >(), QList<int>() << 7 << 6 << 5 << 4);
+ QCOMPARE(itemsMovedSpy.count(), 1);
+ QCOMPARE(itemsMovedSpy.first().at(0).value<KItemRange>(), KItemRange(4, 4));
+ QCOMPARE(itemsMovedSpy.takeFirst().at(1).value<QList<int> >(), QList<int>() << 7 << 6 << 5 << 4);
// TODO: Sort by other roles; show/hide hidden files
}
void KFileItemModelTest::testIndexForKeyboardSearch()
{
- QStringList files;
- files << "a" << "aa" << "Image.jpg" << "Image.png" << "Text" << "Text1" << "Text2" << "Text11";
- m_testDir->createFiles(files);
+ QSignalSpy itemsInsertedSpy(m_model, SIGNAL(itemsInserted(KItemRangeList)));
+
+ m_testDir->createFiles({"a", "aa", "Image.jpg", "Image.png", "Text", "Text1", "Text2", "Text11"});
m_model->loadDirectory(m_testDir->url());
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
// Search from index 0
QCOMPARE(m_model->indexForKeyboardSearch("a", 0), 0);
@@ -982,12 +1001,12 @@ void KFileItemModelTest::testIndexForKeyboardSearch()
void KFileItemModelTest::testNameFilter()
{
- QStringList files;
- files << "A1" << "A2" << "Abc" << "Bcd" << "Cde";
- m_testDir->createFiles(files);
+ QSignalSpy itemsInsertedSpy(m_model, SIGNAL(itemsInserted(KItemRangeList)));
+
+ m_testDir->createFiles({"A1", "A2", "Abc", "Bcd", "Cde"});
m_model->loadDirectory(m_testDir->url());
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
m_model->setNameFilter("A"); // Shows A1, A2 and Abc
QCOMPARE(m_model->count(), 3);
@@ -1022,10 +1041,10 @@ void KFileItemModelTest::testEmptyPath()
roles.insert("expandedParentsCount");
m_model->setRoles(roles);
- const KUrl emptyUrl;
+ const QUrl emptyUrl;
QVERIFY(emptyUrl.path().isEmpty());
- const KUrl url("file:///test/");
+ const QUrl url("file:///test/");
KFileItemList items;
items << KFileItem(emptyUrl, QString(), KFileItem::Unknown) << KFileItem(url, QString(), KFileItem::Unknown);
@@ -1039,28 +1058,28 @@ void KFileItemModelTest::testEmptyPath()
*/
void KFileItemModelTest::testRefreshExpandedItem()
{
+ QSignalSpy itemsInsertedSpy(m_model, SIGNAL(itemsInserted(KItemRangeList)));
+ QSignalSpy itemsChangedSpy(m_model, SIGNAL(itemsChanged(KItemRangeList, QSet<QByteArray>)));
+ QVERIFY(itemsChangedSpy.isValid());
+
QSet<QByteArray> modelRoles = m_model->roles();
modelRoles << "isExpanded" << "isExpandable" << "expandedParentsCount";
m_model->setRoles(modelRoles);
- QStringList files;
- files << "a/1" << "a/2" << "3" << "4";
- m_testDir->createFiles(files);
+ m_testDir->createFiles({"a/1", "a/2", "3", "4"});
m_model->loadDirectory(m_testDir->url());
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
QCOMPARE(m_model->count(), 3); // "a/", "3", "4"
m_model->setExpanded(0, true);
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
QCOMPARE(m_model->count(), 5); // "a/", "a/1", "a/2", "3", "4"
QVERIFY(m_model->isExpanded(0));
- QSignalSpy spyItemsChanged(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)));
-
const KFileItem item = m_model->fileItem(0);
- m_model->slotRefreshItems(QList<QPair<KFileItem, KFileItem> >() << qMakePair(item, item));
- QVERIFY(!spyItemsChanged.isEmpty());
+ m_model->slotRefreshItems({qMakePair(item, item)});
+ QVERIFY(!itemsChangedSpy.isEmpty());
QCOMPARE(m_model->count(), 5); // "a/", "a/1", "a/2", "3", "4"
QVERIFY(m_model->isExpanded(0));
@@ -1076,39 +1095,39 @@ void KFileItemModelTest::testRemoveHiddenItems()
m_testDir->createDir(".b");
m_testDir->createDir("c");
m_testDir->createDir("d");
- m_testDir->createFiles(QStringList() << ".f" << ".g" << "h" << "i");
+ m_testDir->createFiles({".f", ".g", "h", "i"});
- QSignalSpy spyItemsInserted(m_model, SIGNAL(itemsInserted(KItemRangeList)));
- QSignalSpy spyItemsRemoved(m_model, SIGNAL(itemsRemoved(KItemRangeList)));
+ QSignalSpy itemsInsertedSpy(m_model, SIGNAL(itemsInserted(KItemRangeList)));
+ QSignalSpy itemsRemovedSpy(m_model, SIGNAL(itemsRemoved(KItemRangeList)));
m_model->setShowHiddenFiles(true);
m_model->loadDirectory(m_testDir->url());
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
QCOMPARE(itemsInModel(), QStringList() << ".a" << ".b" << "c" << "d" <<".f" << ".g" << "h" << "i");
- QCOMPARE(spyItemsInserted.count(), 1);
- QCOMPARE(spyItemsRemoved.count(), 0);
- KItemRangeList itemRangeList = spyItemsInserted.takeFirst().at(0).value<KItemRangeList>();
+ QCOMPARE(itemsInsertedSpy.count(), 1);
+ QCOMPARE(itemsRemovedSpy.count(), 0);
+ KItemRangeList itemRangeList = itemsInsertedSpy.takeFirst().at(0).value<KItemRangeList>();
QCOMPARE(itemRangeList, KItemRangeList() << KItemRange(0, 8));
m_model->setShowHiddenFiles(false);
QCOMPARE(itemsInModel(), QStringList() << "c" << "d" << "h" << "i");
- QCOMPARE(spyItemsInserted.count(), 0);
- QCOMPARE(spyItemsRemoved.count(), 1);
- itemRangeList = spyItemsRemoved.takeFirst().at(0).value<KItemRangeList>();
+ QCOMPARE(itemsInsertedSpy.count(), 0);
+ QCOMPARE(itemsRemovedSpy.count(), 1);
+ itemRangeList = itemsRemovedSpy.takeFirst().at(0).value<KItemRangeList>();
QCOMPARE(itemRangeList, KItemRangeList() << KItemRange(0, 2) << KItemRange(4, 2));
m_model->setShowHiddenFiles(true);
QCOMPARE(itemsInModel(), QStringList() << ".a" << ".b" << "c" << "d" <<".f" << ".g" << "h" << "i");
- QCOMPARE(spyItemsInserted.count(), 1);
- QCOMPARE(spyItemsRemoved.count(), 0);
- itemRangeList = spyItemsInserted.takeFirst().at(0).value<KItemRangeList>();
+ QCOMPARE(itemsInsertedSpy.count(), 1);
+ QCOMPARE(itemsRemovedSpy.count(), 0);
+ itemRangeList = itemsInsertedSpy.takeFirst().at(0).value<KItemRangeList>();
QCOMPARE(itemRangeList, KItemRangeList() << KItemRange(0, 2) << KItemRange(2, 2));
m_model->clear();
QCOMPARE(itemsInModel(), QStringList());
- QCOMPARE(spyItemsInserted.count(), 0);
- QCOMPARE(spyItemsRemoved.count(), 1);
- itemRangeList = spyItemsRemoved.takeFirst().at(0).value<KItemRangeList>();
+ QCOMPARE(itemsInsertedSpy.count(), 0);
+ QCOMPARE(itemsRemovedSpy.count(), 1);
+ itemRangeList = itemsRemovedSpy.takeFirst().at(0).value<KItemRangeList>();
QCOMPARE(itemRangeList, KItemRangeList() << KItemRange(0, 8));
// Hiding hidden files makes the dir lister emit its itemsDeleted signal.
@@ -1121,42 +1140,43 @@ void KFileItemModelTest::testRemoveHiddenItems()
*/
void KFileItemModelTest::collapseParentOfHiddenItems()
{
+ QSignalSpy itemsInsertedSpy(m_model, SIGNAL(itemsInserted(KItemRangeList)));
+ QSignalSpy itemsRemovedSpy(m_model, SIGNAL(itemsRemoved(KItemRangeList)));
+
QSet<QByteArray> modelRoles = m_model->roles();
modelRoles << "isExpanded" << "isExpandable" << "expandedParentsCount";
m_model->setRoles(modelRoles);
- QStringList files;
- files << "a/1" << "a/b/1" << "a/b/c/1" << "a/b/c/d/1";
- m_testDir->createFiles(files);
+ m_testDir->createFiles({"a/1", "a/b/1", "a/b/c/1", "a/b/c/d/1"});
m_model->loadDirectory(m_testDir->url());
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
QCOMPARE(m_model->count(), 1); // Only "a/"
// Expand "a/".
m_model->setExpanded(0, true);
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
QCOMPARE(m_model->count(), 3); // 3 items: "a/", "a/b/", "a/1"
// Expand "a/b/".
m_model->setExpanded(1, true);
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
QCOMPARE(m_model->count(), 5); // 5 items: "a/", "a/b/", "a/b/c", "a/b/1", "a/1"
// Expand "a/b/c/".
m_model->setExpanded(2, true);
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
QCOMPARE(m_model->count(), 7); // 7 items: "a/", "a/b/", "a/b/c", "a/b/c/d/", "a/b/c/1", "a/b/1", "a/1"
// Set a name filter that matches nothing -> only the expanded folders remain.
m_model->setNameFilter("xyz");
+ QCOMPARE(itemsRemovedSpy.count(), 1);
QCOMPARE(m_model->count(), 3);
QCOMPARE(itemsInModel(), QStringList() << "a" << "b" << "c");
// Collapse the folder "a/".
- QSignalSpy spyItemsRemoved(m_model, SIGNAL(itemsRemoved(KItemRangeList)));
m_model->setExpanded(0, false);
- QCOMPARE(spyItemsRemoved.count(), 1);
+ QCOMPARE(itemsRemovedSpy.count(), 2);
QCOMPARE(m_model->count(), 1);
QCOMPARE(itemsInModel(), QStringList() << "a");
@@ -1170,42 +1190,43 @@ void KFileItemModelTest::collapseParentOfHiddenItems()
*/
void KFileItemModelTest::removeParentOfHiddenItems()
{
+ QSignalSpy itemsInsertedSpy(m_model, SIGNAL(itemsInserted(KItemRangeList)));
+ QSignalSpy itemsRemovedSpy(m_model, SIGNAL(itemsRemoved(KItemRangeList)));
+
QSet<QByteArray> modelRoles = m_model->roles();
modelRoles << "isExpanded" << "isExpandable" << "expandedParentsCount";
m_model->setRoles(modelRoles);
- QStringList files;
- files << "a/1" << "a/b/1" << "a/b/c/1" << "a/b/c/d/1";
- m_testDir->createFiles(files);
+ m_testDir->createFiles({"a/1", "a/b/1", "a/b/c/1", "a/b/c/d/1"});
m_model->loadDirectory(m_testDir->url());
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
QCOMPARE(m_model->count(), 1); // Only "a/"
// Expand "a/".
m_model->setExpanded(0, true);
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
QCOMPARE(m_model->count(), 3); // 3 items: "a/", "a/b/", "a/1"
// Expand "a/b/".
m_model->setExpanded(1, true);
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
QCOMPARE(m_model->count(), 5); // 5 items: "a/", "a/b/", "a/b/c", "a/b/1", "a/1"
// Expand "a/b/c/".
m_model->setExpanded(2, true);
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
QCOMPARE(m_model->count(), 7); // 7 items: "a/", "a/b/", "a/b/c", "a/b/c/d/", "a/b/c/1", "a/b/1", "a/1"
// Set a name filter that matches nothing -> only the expanded folders remain.
m_model->setNameFilter("xyz");
+ QCOMPARE(itemsRemovedSpy.count(), 1);
QCOMPARE(m_model->count(), 3);
QCOMPARE(itemsInModel(), QStringList() << "a" << "b" << "c");
// Simulate the deletion of the directory "a/b/".
- QSignalSpy spyItemsRemoved(m_model, SIGNAL(itemsRemoved(KItemRangeList)));
m_model->slotItemsDeleted(KFileItemList() << m_model->fileItem(1));
- QCOMPARE(spyItemsRemoved.count(), 1);
+ QCOMPARE(itemsRemovedSpy.count(), 2);
QCOMPARE(m_model->count(), 1);
QCOMPARE(itemsInModel(), QStringList() << "a");
@@ -1222,63 +1243,63 @@ void KFileItemModelTest::removeParentOfHiddenItems()
*/
void KFileItemModelTest::testGeneralParentChildRelationships()
{
+ QSignalSpy itemsInsertedSpy(m_model, SIGNAL(itemsInserted(KItemRangeList)));
+ QSignalSpy itemsRemovedSpy(m_model, SIGNAL(itemsRemoved(KItemRangeList)));
+
QSet<QByteArray> modelRoles = m_model->roles();
modelRoles << "isExpanded" << "isExpandable" << "expandedParentsCount";
m_model->setRoles(modelRoles);
- QStringList files;
- files << "parent1/realChild1/realGrandChild1" << "parent2/realChild2/realGrandChild2";
- m_testDir->createFiles(files);
+ m_testDir->createFiles({"parent1/realChild1/realGrandChild1", "parent2/realChild2/realGrandChild2"});
m_model->loadDirectory(m_testDir->url());
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
QCOMPARE(itemsInModel(), QStringList() << "parent1" << "parent2");
// Expand all folders.
m_model->setExpanded(0, true);
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
QCOMPARE(itemsInModel(), QStringList() << "parent1" << "realChild1" << "parent2");
m_model->setExpanded(1, true);
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
QCOMPARE(itemsInModel(), QStringList() << "parent1" << "realChild1" << "realGrandChild1" << "parent2");
m_model->setExpanded(3, true);
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
QCOMPARE(itemsInModel(), QStringList() << "parent1" << "realChild1" << "realGrandChild1" << "parent2" << "realChild2");
m_model->setExpanded(4, true);
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
QCOMPARE(itemsInModel(), QStringList() << "parent1" << "realChild1" << "realGrandChild1" << "parent2" << "realChild2" << "realGrandChild2");
// Add some more children and grand-children.
- const KUrl parent1 = m_model->fileItem(0).url();
- const KUrl parent2 = m_model->fileItem(3).url();
- const KUrl realChild1 = m_model->fileItem(1).url();
- const KUrl realChild2 = m_model->fileItem(4).url();
+ const QUrl parent1 = m_model->fileItem(0).url();
+ const QUrl parent2 = m_model->fileItem(3).url();
+ const QUrl realChild1 = m_model->fileItem(1).url();
+ const QUrl realChild2 = m_model->fileItem(4).url();
- m_model->slotItemsAdded(parent1, KFileItemList() << KFileItem(KUrl("child1"), QString(), KFileItem::Unknown));
+ m_model->slotItemsAdded(parent1, KFileItemList() << KFileItem(QUrl("child1"), QString(), KFileItem::Unknown));
m_model->slotCompleted();
QCOMPARE(itemsInModel(), QStringList() << "parent1" << "realChild1" << "realGrandChild1" << "child1" << "parent2" << "realChild2" << "realGrandChild2");
- m_model->slotItemsAdded(parent2, KFileItemList() << KFileItem(KUrl("child2"), QString(), KFileItem::Unknown));
+ m_model->slotItemsAdded(parent2, KFileItemList() << KFileItem(QUrl("child2"), QString(), KFileItem::Unknown));
m_model->slotCompleted();
QCOMPARE(itemsInModel(), QStringList() << "parent1" << "realChild1" << "realGrandChild1" << "child1" << "parent2" << "realChild2" << "realGrandChild2" << "child2");
- m_model->slotItemsAdded(realChild1, KFileItemList() << KFileItem(KUrl("grandChild1"), QString(), KFileItem::Unknown));
+ m_model->slotItemsAdded(realChild1, KFileItemList() << KFileItem(QUrl("grandChild1"), QString(), KFileItem::Unknown));
m_model->slotCompleted();
QCOMPARE(itemsInModel(), QStringList() << "parent1" << "realChild1" << "grandChild1" << "realGrandChild1" << "child1" << "parent2" << "realChild2" << "realGrandChild2" << "child2");
- m_model->slotItemsAdded(realChild1, KFileItemList() << KFileItem(KUrl("grandChild1"), QString(), KFileItem::Unknown));
+ m_model->slotItemsAdded(realChild1, KFileItemList() << KFileItem(QUrl("grandChild1"), QString(), KFileItem::Unknown));
m_model->slotCompleted();
QCOMPARE(itemsInModel(), QStringList() << "parent1" << "realChild1" << "grandChild1" << "realGrandChild1" << "child1" << "parent2" << "realChild2" << "realGrandChild2" << "child2");
- m_model->slotItemsAdded(realChild2, KFileItemList() << KFileItem(KUrl("grandChild2"), QString(), KFileItem::Unknown));
+ m_model->slotItemsAdded(realChild2, KFileItemList() << KFileItem(QUrl("grandChild2"), QString(), KFileItem::Unknown));
m_model->slotCompleted();
QCOMPARE(itemsInModel(), QStringList() << "parent1" << "realChild1" << "grandChild1" << "realGrandChild1" << "child1" << "parent2" << "realChild2" << "grandChild2" << "realGrandChild2" << "child2");
// Set a name filter that matches nothing -> only expanded folders remain.
- QSignalSpy itemsRemovedSpy(m_model, SIGNAL(itemsRemoved(KItemRangeList)));
m_model->setNameFilter("xyz");
QCOMPARE(itemsInModel(), QStringList() << "parent1" << "realChild1" << "parent2" << "realChild2");
QCOMPARE(itemsRemovedSpy.count(), 1);
@@ -1309,14 +1330,17 @@ void KFileItemModelTest::testGeneralParentChildRelationships()
void KFileItemModelTest::testNameRoleGroups()
{
- QStringList files;
- files << "b.txt" << "c.txt" << "d.txt" << "e.txt";
+ QSignalSpy itemsInsertedSpy(m_model, SIGNAL(itemsInserted(KItemRangeList)));
+ QSignalSpy itemsMovedSpy(m_model, SIGNAL(itemsMoved(KItemRange,QList<int>)));
+ QVERIFY(itemsMovedSpy.isValid());
+ QSignalSpy groupsChangedSpy(m_model, SIGNAL(groupsChanged()));
+ QVERIFY(groupsChangedSpy.isValid());
- m_testDir->createFiles(files);
+ m_testDir->createFiles({"b.txt", "c.txt", "d.txt", "e.txt"});
m_model->setGroupedSorting(true);
m_model->loadDirectory(m_testDir->url());
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
QCOMPARE(itemsInModel(), QStringList() << "b.txt" << "c.txt" << "d.txt" << "e.txt");
QList<QPair<int, QVariant> > expectedGroups;
@@ -1330,7 +1354,7 @@ void KFileItemModelTest::testNameRoleGroups()
QHash<QByteArray, QVariant> data;
data.insert("text", "a.txt");
m_model->setData(2, data);
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsMoved(KItemRange,QList<int>)), DefaultTimeout));
+ QVERIFY(itemsMovedSpy.wait());
QCOMPARE(itemsInModel(), QStringList() << "a.txt" << "b.txt" << "c.txt" << "e.txt");
expectedGroups.clear();
@@ -1343,7 +1367,7 @@ void KFileItemModelTest::testNameRoleGroups()
// Rename c.txt to d.txt.
data.insert("text", "d.txt");
m_model->setData(2, data);
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(groupsChanged()), DefaultTimeout));
+ QVERIFY(groupsChangedSpy.wait());
QCOMPARE(itemsInModel(), QStringList() << "a.txt" << "b.txt" << "d.txt" << "e.txt");
expectedGroups.clear();
@@ -1356,12 +1380,12 @@ void KFileItemModelTest::testNameRoleGroups()
// Change d.txt back to c.txt, but this time using the dir lister's refreshItems() signal.
const KFileItem fileItemD = m_model->fileItem(2);
KFileItem fileItemC = fileItemD;
- KUrl urlC = fileItemC.url();
- urlC.setFileName("c.txt");
+ QUrl urlC = fileItemC.url().adjusted(QUrl::RemoveFilename);
+ urlC.setPath(urlC.path() + "c.txt");
fileItemC.setUrl(urlC);
- m_model->slotRefreshItems(QList<QPair<KFileItem, KFileItem> >() << qMakePair(fileItemD, fileItemC));
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(groupsChanged()), DefaultTimeout));
+ m_model->slotRefreshItems({qMakePair(fileItemD, fileItemC)});
+ QVERIFY(groupsChangedSpy.wait());
QCOMPARE(itemsInModel(), QStringList() << "a.txt" << "b.txt" << "c.txt" << "e.txt");
expectedGroups.clear();
@@ -1374,18 +1398,17 @@ void KFileItemModelTest::testNameRoleGroups()
void KFileItemModelTest::testNameRoleGroupsWithExpandedItems()
{
+ QSignalSpy itemsInsertedSpy(m_model, SIGNAL(itemsInserted(KItemRangeList)));
+
QSet<QByteArray> modelRoles = m_model->roles();
modelRoles << "isExpanded" << "isExpandable" << "expandedParentsCount";
m_model->setRoles(modelRoles);
- QStringList files;
- files << "a/b.txt" << "a/c.txt" << "d/e.txt" << "d/f.txt";
-
- m_testDir->createFiles(files);
+ m_testDir->createFiles({"a/b.txt", "a/c.txt", "d/e.txt", "d/f.txt"});
m_model->setGroupedSorting(true);
m_model->loadDirectory(m_testDir->url());
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
QCOMPARE(itemsInModel(), QStringList() << "a" << "d");
QList<QPair<int, QVariant> > expectedGroups;
@@ -1400,41 +1423,40 @@ void KFileItemModelTest::testNameRoleGroupsWithExpandedItems()
m_model->setExpanded(0, true);
QVERIFY(m_model->isExpanded(0));
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
QCOMPARE(itemsInModel(), QStringList() << "a" << "b.txt" << "c.txt" << "d");
QCOMPARE(m_model->groups(), expectedGroups);
m_model->setExpanded(3, true);
QVERIFY(m_model->isExpanded(3));
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
QCOMPARE(itemsInModel(), QStringList() << "a" << "b.txt" << "c.txt" << "d" << "e.txt" << "f.txt");
QCOMPARE(m_model->groups(), expectedGroups);
}
void KFileItemModelTest::testInconsistentModel()
{
+ QSignalSpy itemsInsertedSpy(m_model, SIGNAL(itemsInserted(KItemRangeList)));
+
QSet<QByteArray> modelRoles = m_model->roles();
modelRoles << "isExpanded" << "isExpandable" << "expandedParentsCount";
m_model->setRoles(modelRoles);
- QStringList files;
- files << "a/b/c1.txt" << "a/b/c2.txt";
-
- m_testDir->createFiles(files);
+ m_testDir->createFiles({"a/b/c1.txt", "a/b/c2.txt"});
m_model->loadDirectory(m_testDir->url());
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
QCOMPARE(itemsInModel(), QStringList() << "a");
// Expand "a/" and "a/b/".
m_model->setExpanded(0, true);
QVERIFY(m_model->isExpanded(0));
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
QCOMPARE(itemsInModel(), QStringList() << "a" << "b");
m_model->setExpanded(1, true);
QVERIFY(m_model->isExpanded(1));
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
QCOMPARE(itemsInModel(), QStringList() << "a" << "b" << "c1.txt" << "c2.txt");
// Add the files "c1.txt" and "c2.txt" to the model also as top-level items.
@@ -1446,8 +1468,8 @@ void KFileItemModelTest::testInconsistentModel()
// Note that the first item in the list of added items must be new (i.e., not
// in the model yet). Otherwise, KFileItemModel::slotItemsAdded() will see that
// it receives items that are in the model already and ignore them.
- KUrl url(m_model->directory().url() + "/a2");
- KFileItem newItem(KFileItem::Unknown, KFileItem::Unknown, url);
+ QUrl url(m_model->directory().url() + "/a2");
+ KFileItem newItem(url);
KFileItemList items;
items << newItem << m_model->fileItem(2) << m_model->fileItem(3);
@@ -1470,16 +1492,16 @@ void KFileItemModelTest::testInconsistentModel()
void KFileItemModelTest::testChangeRolesForFilteredItems()
{
+ QSignalSpy itemsInsertedSpy(m_model, SIGNAL(itemsInserted(KItemRangeList)));
+
QSet<QByteArray> modelRoles = m_model->roles();
modelRoles << "owner";
m_model->setRoles(modelRoles);
- QStringList files;
- files << "a.txt" << "aa.txt" << "aaa.txt";
- m_testDir->createFiles(files);
+ m_testDir->createFiles({"a.txt", "aa.txt", "aaa.txt"});
m_model->loadDirectory(m_testDir->url());
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
QCOMPARE(itemsInModel(), QStringList() << "a.txt" << "aa.txt" << "aaa.txt");
for (int index = 0; index < m_model->count(); ++index) {
@@ -1567,12 +1589,12 @@ void KFileItemModelTest::testChangeSortRoleWhileFiltering()
void KFileItemModelTest::testRefreshFilteredItems()
{
- QStringList files;
- files << "a.txt" << "b.txt" << "c.jpg" << "d.jpg";
- m_testDir->createFiles(files);
+ QSignalSpy itemsInsertedSpy(m_model, SIGNAL(itemsInserted(KItemRangeList)));
+
+ m_testDir->createFiles({"a.txt", "b.txt", "c.jpg", "d.jpg"});
m_model->loadDirectory(m_testDir->url());
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
QCOMPARE(itemsInModel(), QStringList() << "a.txt" << "b.txt" << "c.jpg" << "d.jpg");
const KFileItem fileItemC = m_model->fileItem(2);
@@ -1583,11 +1605,11 @@ void KFileItemModelTest::testRefreshFilteredItems()
// Rename one of the .jpg files.
KFileItem fileItemE = fileItemC;
- KUrl urlE = fileItemE.url();
- urlE.setFileName("e.jpg");
+ QUrl urlE = fileItemE.url().adjusted(QUrl::RemoveFilename);
+ urlE.setPath(urlE.path() + "/e.jpg");
fileItemE.setUrl(urlE);
- m_model->slotRefreshItems(QList<QPair<KFileItem, KFileItem> >() << qMakePair(fileItemC, fileItemE));
+ m_model->slotRefreshItems({qMakePair(fileItemC, fileItemE)});
// Show all files again, and verify that the model has updated the file name.
m_model->setNameFilter(QString());
@@ -1596,21 +1618,21 @@ void KFileItemModelTest::testRefreshFilteredItems()
void KFileItemModelTest::testCreateMimeData()
{
+ QSignalSpy itemsInsertedSpy(m_model, SIGNAL(itemsInserted(KItemRangeList)));
+
QSet<QByteArray> modelRoles = m_model->roles();
modelRoles << "isExpanded" << "isExpandable" << "expandedParentsCount";
m_model->setRoles(modelRoles);
- QStringList files;
- files << "a/1";
- m_testDir->createFiles(files);
+ m_testDir->createFile("a/1");
m_model->loadDirectory(m_testDir->url());
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
QCOMPARE(itemsInModel(), QStringList() << "a");
// Expand "a/".
m_model->setExpanded(0, true);
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
QCOMPARE(itemsInModel(), QStringList() << "a" << "1");
// Verify that creating the MIME data for a child of an expanded folder does
@@ -1623,39 +1645,40 @@ void KFileItemModelTest::testCreateMimeData()
void KFileItemModelTest::testCollapseFolderWhileLoading()
{
+ QSignalSpy itemsInsertedSpy(m_model, SIGNAL(itemsInserted(KItemRangeList)));
+
QSet<QByteArray> modelRoles = m_model->roles();
modelRoles << "isExpanded" << "isExpandable" << "expandedParentsCount";
m_model->setRoles(modelRoles);
- QStringList files;
- files << "a2/b/c1.txt";
- m_testDir->createFiles(files);
+ m_testDir->createFile("a2/b/c1.txt");
m_model->loadDirectory(m_testDir->url());
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
QCOMPARE(itemsInModel(), QStringList() << "a2");
// Expand "a2/".
m_model->setExpanded(0, true);
QVERIFY(m_model->isExpanded(0));
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
QCOMPARE(itemsInModel(), QStringList() << "a2" << "b");
// Expand "a2/b/".
m_model->setExpanded(1, true);
QVERIFY(m_model->isExpanded(1));
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
QCOMPARE(itemsInModel(), QStringList() << "a2" << "b" << "c1.txt");
// Simulate that a new item "c2.txt" appears, but that the dir lister's completed()
// signal is not emitted yet.
const KFileItem fileItemC1 = m_model->fileItem(2);
KFileItem fileItemC2 = fileItemC1;
- KUrl urlC2 = fileItemC2.url();
- urlC2.setFileName("c2.txt");
+ QUrl urlC2 = fileItemC2.url();
+ urlC2.adjusted(QUrl::RemoveFilename);
+ urlC2.setPath(urlC2.path() + "c2.txt");
fileItemC2.setUrl(urlC2);
- const KUrl urlB = m_model->fileItem(1).url();
+ const QUrl urlB = m_model->fileItem(1).url();
m_model->slotItemsAdded(urlB, KFileItemList() << fileItemC2);
QCOMPARE(itemsInModel(), QStringList() << "a2" << "b" << "c1.txt");
@@ -1675,15 +1698,15 @@ void KFileItemModelTest::testCollapseFolderWhileLoading()
// Expand "a2/" again.
m_model->setExpanded(0, true);
QVERIFY(m_model->isExpanded(0));
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
QCOMPARE(itemsInModel(), QStringList() << "a2" << "b");
// Now simulate that a new folder "a1/" is appears, but that the dir lister's
// completed() signal is not emitted yet.
const KFileItem fileItemA2 = m_model->fileItem(0);
KFileItem fileItemA1 = fileItemA2;
- KUrl urlA1 = fileItemA1.url();
- urlA1.setFileName("a1");
+ QUrl urlA1 = fileItemA1.url().adjusted(QUrl::RemoveFilename);
+ urlA1.setPath(urlA1.path() + "a1");
fileItemA1.setUrl(urlA1);
m_model->slotItemsAdded(m_model->directory(), KFileItemList() << fileItemA1);
@@ -1700,12 +1723,12 @@ void KFileItemModelTest::testCollapseFolderWhileLoading()
void KFileItemModelTest::testDeleteFileMoreThanOnce()
{
- QStringList files;
- files << "a.txt" << "b.txt" << "c.txt" << "d.txt";
- m_testDir->createFiles(files);
+ QSignalSpy itemsInsertedSpy(m_model, SIGNAL(itemsInserted(KItemRangeList)));
+
+ m_testDir->createFiles({"a.txt", "b.txt", "c.txt", "d.txt"});
m_model->loadDirectory(m_testDir->url());
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout));
+ QVERIFY(itemsInsertedSpy.wait());
QCOMPARE(itemsInModel(), QStringList() << "a.txt" << "b.txt" << "c.txt" << "d.txt");
const KFileItem fileItemB = m_model->fileItem(1);
@@ -1728,6 +1751,6 @@ QStringList KFileItemModelTest::itemsInModel() const
return items;
}
-QTEST_KDEMAIN(KFileItemModelTest, NoGUI)
+QTEST_MAIN(KFileItemModelTest)
#include "kfileitemmodeltest.moc"
diff --git a/src/tests/kitemlistcontrollertest.cpp b/src/tests/kitemlistcontrollertest.cpp
index 7dd37bf0a..e34731fa4 100644
--- a/src/tests/kitemlistcontrollertest.cpp
+++ b/src/tests/kitemlistcontrollertest.cpp
@@ -17,10 +17,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
-#include <qtest_kde.h>
-#include <qtestmouse.h>
-#include <qtestkeyboard.h>
-
#include "kitemviews/kitemlistcontainer.h"
#include "kitemviews/kfileitemlistview.h"
#include "kitemviews/kfileitemmodel.h"
@@ -29,13 +25,50 @@
#include "kitemviews/private/kitemlistviewlayouter.h"
#include "testdir.h"
-#include <KConfigGroup>
-#include <KGlobalSettings>
-
+#include <QTest>
#include <QGraphicsSceneMouseEvent>
+#include <QSignalSpy>
+#include <QProxyStyle>
+
+/**
+ * \class KItemListControllerTestStyle is a proxy style for testing the
+ * KItemListController with different style hint options, e.g. single/double
+ * click activation.
+ */
+class KItemListControllerTestStyle : public QProxyStyle
+{
+public:
+ KItemListControllerTestStyle(QStyle* style) :
+ QProxyStyle(style),
+ m_activateItemOnSingleClick((bool)style->styleHint(SH_ItemView_ActivateItemOnSingleClick))
+ {
+ }
+
+ void setActivateItemOnSingleClick(bool activateItemOnSingleClick)
+ {
+ m_activateItemOnSingleClick = activateItemOnSingleClick;
+ }
-namespace {
- const int DefaultTimeout = 2000;
+ bool activateItemOnSingleClick() const
+ {
+ return m_activateItemOnSingleClick;
+ }
+
+ int styleHint(StyleHint hint,
+ const QStyleOption* option = nullptr,
+ const QWidget* widget = nullptr,
+ QStyleHintReturn* returnData = nullptr) const Q_DECL_OVERRIDE
+ {
+ switch (hint) {
+ case QStyle::SH_ItemView_ActivateItemOnSingleClick:
+ return (int)activateItemOnSingleClick();
+ default:
+ return QProxyStyle::styleHint(hint, option, widget, returnData);
+ }
+ }
+
+private:
+ bool m_activateItemOnSingleClick;
};
Q_DECLARE_METATYPE(KFileItemListView::ItemLayout);
@@ -72,6 +105,7 @@ private:
KFileItemModel* m_model;
TestDir* m_testDir;
KItemListContainer* m_container;
+ KItemListControllerTestStyle* m_testStyle;
};
/**
@@ -91,6 +125,8 @@ void KItemListControllerTest::initTestCase()
m_controller = m_container->controller();
m_controller->setSelectionBehavior(KItemListController::MultiSelection);
m_selectionManager = m_controller->selectionManager();
+ m_testStyle = new KItemListControllerTestStyle(m_view->style());
+ m_view->setStyle(m_testStyle);
QStringList files;
files
@@ -102,10 +138,11 @@ void KItemListControllerTest::initTestCase()
m_testDir->createFiles(files);
m_model->loadDirectory(m_testDir->url());
- QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(directoryLoadingCompleted()), DefaultTimeout));
+ QSignalSpy spyDirectoryLoadingCompleted(m_model, SIGNAL(directoryLoadingCompleted()));
+ QVERIFY(spyDirectoryLoadingCompleted.wait());
m_container->show();
- QTest::qWaitForWindowShown(m_container);
+ QTest::qWaitForWindowExposed(m_container);
}
void KItemListControllerTest::cleanupTestCase()
@@ -423,7 +460,7 @@ void KItemListControllerTest::testKeyboardNavigation_data()
selectionBehaviorNames[selectionBehavior] + ", " +
groupingEnabledNames[groupingEnabled];
- const QByteArray testNameAscii = testName.toAscii();
+ const QByteArray testNameAscii = testName.toLatin1();
QTest::newRow(testNameAscii.data())
<< layout
@@ -534,10 +571,7 @@ void KItemListControllerTest::testMouseClickActivation()
const QPointF pos = m_view->itemContextRect(0).center();
// Save the "single click" setting.
- const bool restoreKGlobalSettingsSingleClick = KGlobalSettings::singleClick();
-
- KConfig config("kcminputrc");
- KConfigGroup group = config.group("KDE");
+ const bool restoreSettingsSingleClick = m_testStyle->activateItemOnSingleClick();
QGraphicsSceneMouseEvent mousePressEvent(QEvent::GraphicsSceneMousePress);
mousePressEvent.setPos(pos);
@@ -552,43 +586,14 @@ void KItemListControllerTest::testMouseClickActivation()
QSignalSpy spyItemActivated(m_controller, SIGNAL(itemActivated(int)));
// Default setting: single click activation.
- group.writeEntry("SingleClick", true, KConfig::Persistent|KConfig::Global);
- config.sync();
- KGlobalSettings::self()->emitChange(KGlobalSettings::SettingsChanged, KGlobalSettings::SETTINGS_MOUSE);
-
- int iterations = 0;
- const int maxIterations = 20;
- while (!KGlobalSettings::singleClick() && iterations < maxIterations) {
- QTest::qWait(50);
- ++iterations;
- }
-
- if (!KGlobalSettings::singleClick()) {
- // TODO: Try to find a way to make sure that changing the global setting works.
- QSKIP("Failed to change the KGlobalSettings::singleClick() setting!", SkipSingle);
- }
-
+ m_testStyle->setActivateItemOnSingleClick(true);
m_view->event(&mousePressEvent);
m_view->event(&mouseReleaseEvent);
QCOMPARE(spyItemActivated.count(), 1);
spyItemActivated.clear();
// Set the global setting to "double click activation".
- group.writeEntry("SingleClick", false, KConfig::Persistent|KConfig::Global);
- config.sync();
- KGlobalSettings::self()->emitChange(KGlobalSettings::SettingsChanged, KGlobalSettings::SETTINGS_MOUSE);
-
- iterations = 0;
- while (KGlobalSettings::singleClick() && iterations < maxIterations) {
- QTest::qWait(50);
- ++iterations;
- }
-
- if (KGlobalSettings::singleClick()) {
- // TODO: Try to find a way to make sure that changing the global setting works.
- QSKIP("Failed to change the KGlobalSettings::singleClick() setting!", SkipSingle);
- }
-
+ m_testStyle->setActivateItemOnSingleClick(false);
m_view->event(&mousePressEvent);
m_view->event(&mouseReleaseEvent);
QCOMPARE(spyItemActivated.count(), 0);
@@ -609,21 +614,7 @@ void KItemListControllerTest::testMouseClickActivation()
spyItemActivated.clear();
// Set the global setting back to "single click activation".
- group.writeEntry("SingleClick", true, KConfig::Persistent|KConfig::Global);
- config.sync();
- KGlobalSettings::self()->emitChange(KGlobalSettings::SettingsChanged, KGlobalSettings::SETTINGS_MOUSE);
-
- iterations = 0;
- while (!KGlobalSettings::singleClick() && iterations < maxIterations) {
- QTest::qWait(50);
- ++iterations;
- }
-
- if (!KGlobalSettings::singleClick()) {
- // TODO: Try to find a way to make sure that changing the global setting works.
- QSKIP("Failed to change the KGlobalSettings::singleClick() setting!", SkipSingle);
- }
-
+ m_testStyle->setActivateItemOnSingleClick(true);
m_view->event(&mousePressEvent);
m_view->event(&mouseReleaseEvent);
QCOMPARE(spyItemActivated.count(), 1);
@@ -638,20 +629,7 @@ void KItemListControllerTest::testMouseClickActivation()
// Restore previous settings.
m_controller->setSingleClickActivationEnforced(true);
- group.writeEntry("SingleClick", restoreKGlobalSettingsSingleClick, KConfig::Persistent|KConfig::Global);
- config.sync();
- KGlobalSettings::self()->emitChange(KGlobalSettings::SettingsChanged, KGlobalSettings::SETTINGS_MOUSE);
-
- iterations = 0;
- while (KGlobalSettings::singleClick() != restoreKGlobalSettingsSingleClick && iterations < maxIterations) {
- QTest::qWait(50);
- ++iterations;
- }
-
- if (KGlobalSettings::singleClick() != restoreKGlobalSettingsSingleClick) {
- // TODO: Try to find a way to make sure that changing the global setting works.
- QSKIP("Failed to change the KGlobalSettings::singleClick() setting!", SkipSingle);
- }
+ m_testStyle->setActivateItemOnSingleClick(restoreSettingsSingleClick);
}
void KItemListControllerTest::adjustGeometryForColumnCount(int count)
@@ -670,6 +648,6 @@ void KItemListControllerTest::adjustGeometryForColumnCount(int count)
}
}
-QTEST_KDEMAIN(KItemListControllerTest, GUI)
+QTEST_MAIN(KItemListControllerTest)
#include "kitemlistcontrollertest.moc"
diff --git a/src/tests/kitemlistkeyboardsearchmanagertest.cpp b/src/tests/kitemlistkeyboardsearchmanagertest.cpp
index 7d5fc3b9a..45fe112ce 100644
--- a/src/tests/kitemlistkeyboardsearchmanagertest.cpp
+++ b/src/tests/kitemlistkeyboardsearchmanagertest.cpp
@@ -17,10 +17,11 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
-#include <qtest_kde.h>
-
#include "kitemviews/private/kitemlistkeyboardsearchmanager.h"
+#include <QTest>
+#include <QSignalSpy>
+
class KItemListKeyboardSearchManagerTest : public QObject
{
Q_OBJECT
@@ -45,7 +46,8 @@ void KItemListKeyboardSearchManagerTest::init()
void KItemListKeyboardSearchManagerTest::testBasicKeyboardSearch()
{
- QSignalSpy spy(&m_keyboardSearchManager, SIGNAL(changeCurrentItem(QString,bool)));
+ QSignalSpy spy(&m_keyboardSearchManager, SIGNAL(changeCurrentItem(QString, bool)));
+ QVERIFY(spy.isValid());
m_keyboardSearchManager.addKeys("f");
QCOMPARE(spy.count(), 1);
@@ -70,7 +72,8 @@ void KItemListKeyboardSearchManagerTest::testAbortedKeyboardSearch()
// to save time when running this test.
m_keyboardSearchManager.setTimeout(100);
- QSignalSpy spy(&m_keyboardSearchManager, SIGNAL(changeCurrentItem(QString,bool)));
+ QSignalSpy spy(&m_keyboardSearchManager, SIGNAL(changeCurrentItem(QString, bool)));
+ QVERIFY(spy.isValid());
m_keyboardSearchManager.addKeys("f");
QCOMPARE(spy.count(), 1);
@@ -101,7 +104,8 @@ void KItemListKeyboardSearchManagerTest::testRepeatedKeyPress()
// 1. the string contains the repeated key only once, and
// 2. the bool searchFromNextItem is true.
- QSignalSpy spy(&m_keyboardSearchManager, SIGNAL(changeCurrentItem(QString,bool)));
+ QSignalSpy spy(&m_keyboardSearchManager, SIGNAL(changeCurrentItem(QString, bool)));
+ QVERIFY(spy.isValid());
m_keyboardSearchManager.addKeys("p");
QCOMPARE(spy.count(), 1);
@@ -128,7 +132,8 @@ void KItemListKeyboardSearchManagerTest::testPressShift()
// string. Make sure that this does not reset the current search. See
// https://bugs.kde.org/show_bug.cgi?id=321286
- QSignalSpy spy(&m_keyboardSearchManager, SIGNAL(changeCurrentItem(QString,bool)));
+ QSignalSpy spy(&m_keyboardSearchManager, SIGNAL(changeCurrentItem(QString, bool)));
+ QVERIFY(spy.isValid());
// Simulate that the user enters "a_b".
m_keyboardSearchManager.addKeys("a");
@@ -147,6 +152,6 @@ void KItemListKeyboardSearchManagerTest::testPressShift()
QCOMPARE(spy.takeFirst(), QList<QVariant>() << "a_b" << false);
}
-QTEST_KDEMAIN(KItemListKeyboardSearchManagerTest, NoGUI)
+QTEST_GUILESS_MAIN(KItemListKeyboardSearchManagerTest)
#include "kitemlistkeyboardsearchmanagertest.moc"
diff --git a/src/tests/kitemlistselectionmanagertest.cpp b/src/tests/kitemlistselectionmanagertest.cpp
index 492d0234f..7cf60df42 100644
--- a/src/tests/kitemlistselectionmanagertest.cpp
+++ b/src/tests/kitemlistselectionmanagertest.cpp
@@ -18,11 +18,12 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
-#include <qtest_kde.h>
-
#include "kitemviews/kitemmodelbase.h"
#include "kitemviews/kitemlistselectionmanager.h"
+#include <QTest>
+#include <QSignalSpy>
+
class DummyModel : public KItemModelBase
{
public:
@@ -369,7 +370,7 @@ void KItemListSelectionManagerTest::testChangeSelection_data()
<< 2 << 3
<< (KItemSet() << 2 << 3 << 5 << 6)
<< NoChange
- << QList<QVariant>()
+ << QList<QVariant>{}
<< (KItemSet() << 2 << 3 << 5 << 6);
QTest::newRow("Insert Items")
@@ -377,7 +378,7 @@ void KItemListSelectionManagerTest::testChangeSelection_data()
<< 2 << 3
<< (KItemSet() << 2 << 3 << 5 << 6)
<< InsertItems
- << (QList<QVariant>() << QVariant::fromValue(KItemRangeList() << KItemRange(1, 1) << KItemRange(5, 2) << KItemRange(10, 5)))
+ << QList<QVariant>{QVariant::fromValue(KItemRangeList() << KItemRange(1, 1) << KItemRange(5, 2) << KItemRange(10, 5))}
<< (KItemSet() << 3 << 4 << 8 << 9);
QTest::newRow("Remove Items")
@@ -385,7 +386,7 @@ void KItemListSelectionManagerTest::testChangeSelection_data()
<< 2 << 3
<< (KItemSet() << 2 << 3 << 5 << 6)
<< RemoveItems
- << (QList<QVariant>() << QVariant::fromValue(KItemRangeList() << KItemRange(1, 1) << KItemRange(3, 1) << KItemRange(10, 5)))
+ << QList<QVariant>{QVariant::fromValue(KItemRangeList() << KItemRange(1, 1) << KItemRange(3, 1) << KItemRange(10, 5))}
<< (KItemSet() << 1 << 2 << 3 << 4);
QTest::newRow("Empty Anchored Selection")
@@ -393,7 +394,7 @@ void KItemListSelectionManagerTest::testChangeSelection_data()
<< 2 << 2
<< KItemSet()
<< EndAnchoredSelection
- << QList<QVariant>()
+ << QList<QVariant>{}
<< KItemSet();
QTest::newRow("Toggle selection")
@@ -401,7 +402,7 @@ void KItemListSelectionManagerTest::testChangeSelection_data()
<< 6 << 8
<< (KItemSet() << 1 << 3 << 4 << 6 << 7 << 8)
<< SetSelected
- << (QList<QVariant>() << 0 << 10 << QVariant::fromValue(KItemListSelectionManager::Toggle))
+ << QList<QVariant>{0, 10, QVariant::fromValue(KItemListSelectionManager::Toggle)}
<< (KItemSet() << 0 << 2 << 5 << 9);
// Swap items 2, 3 and 4, 5
@@ -410,8 +411,8 @@ void KItemListSelectionManagerTest::testChangeSelection_data()
<< -1 << -1
<< (KItemSet() << 0 << 1 << 2 << 3)
<< MoveItems
- << (QList<QVariant>() << QVariant::fromValue(KItemRange(2, 4))
- << QVariant::fromValue(QList<int>() << 4 << 5 << 2 << 3))
+ << QList<QVariant>{QVariant::fromValue(KItemRange(2, 4)),
+ QVariant::fromValue(QList<int>{4, 5, 2, 3})}
<< (KItemSet() << 0 << 1 << 4 << 5);
QTest::newRow("Move items with active anchored selection")
@@ -419,8 +420,8 @@ void KItemListSelectionManagerTest::testChangeSelection_data()
<< 0 << 3
<< (KItemSet() << 0 << 1 << 2 << 3)
<< MoveItems
- << (QList<QVariant>() << QVariant::fromValue(KItemRange(2, 4))
- << QVariant::fromValue(QList<int>() << 4 << 5 << 2 << 3))
+ << QList<QVariant>{QVariant::fromValue(KItemRange(2, 4)),
+ QVariant::fromValue(QList<int>{4, 5, 2, 3})}
<< (KItemSet() << 0 << 1 << 4 << 5);
// Revert sort order
@@ -429,8 +430,8 @@ void KItemListSelectionManagerTest::testChangeSelection_data()
<< 3 << 4
<< (KItemSet() << 0 << 1 << 3 << 4)
<< MoveItems
- << (QList<QVariant>() << QVariant::fromValue(KItemRange(0, 10))
- << QVariant::fromValue(QList<int>() << 9 << 8 << 7 << 6 << 5 << 4 << 3 << 2 << 1 << 0))
+ << QList<QVariant>{QVariant::fromValue(KItemRange(0, 10)),
+ QVariant::fromValue(QList<int>{9, 8, 7, 6, 5, 4, 3, 2, 1, 0})}
<< (KItemSet() << 5 << 6 << 8 << 9);
}
@@ -476,7 +477,7 @@ void KItemListSelectionManagerTest::testChangeSelection()
break;
case MoveItems:
m_selectionManager->itemsMoved(data.at(0).value<KItemRange>(),
- data.at(1).value<QList<int> >());
+ data.at(1).value<QList<int>>());
break;
case EndAnchoredSelection:
m_selectionManager->endAnchoredSelection();
@@ -535,7 +536,7 @@ void KItemListSelectionManagerTest::testAnchoredSelectionAfterMovingItems()
m_selectionManager->beginAnchoredSelection(4);
// Reverse the items between 0 and 5.
- m_selectionManager->itemsMoved(KItemRange(0, 6), QList<int>() << 5 << 4 << 3 << 2 << 1 << 0);
+ m_selectionManager->itemsMoved(KItemRange(0, 6), {5, 4, 3, 2, 1, 0});
QCOMPARE(m_selectionManager->currentItem(), 1);
QCOMPARE(m_selectionManager->m_anchorItem, 1);
@@ -571,6 +572,6 @@ void KItemListSelectionManagerTest::verifySelectionChange(QSignalSpy& spy,
}
}
-QTEST_KDEMAIN(KItemListSelectionManagerTest, NoGUI)
+QTEST_GUILESS_MAIN(KItemListSelectionManagerTest)
#include "kitemlistselectionmanagertest.moc"
diff --git a/src/tests/kitemrangetest.cpp b/src/tests/kitemrangetest.cpp
index 9f3f79980..ce7b48012 100644
--- a/src/tests/kitemrangetest.cpp
+++ b/src/tests/kitemrangetest.cpp
@@ -17,10 +17,9 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
-#include <qtest_kde.h>
-
#include "kitemviews/kitemrange.h"
+#include <QTest>
#include <QVector>
Q_DECLARE_METATYPE(QVector<int>);
@@ -40,25 +39,25 @@ void KItemRangeTest::testFromSortedContainer_data()
QTest::addColumn<QVector<int> >("sortedNumbers");
QTest::addColumn<KItemRangeList>("expected");
- QTest::newRow("empty") << QVector<int>() << KItemRangeList();
- QTest::newRow("[1]") << (QVector<int>() << 1) << (KItemRangeList() << KItemRange(1, 1));
- QTest::newRow("[9]") << (QVector<int>() << 9) << (KItemRangeList() << KItemRange(9, 1));
- QTest::newRow("[1-2]") << (QVector<int>() << 1 << 2) << (KItemRangeList() << KItemRange(1, 2));
- QTest::newRow("[1-3]") << (QVector<int>() << 1 << 2 << 3) << (KItemRangeList() << KItemRange(1, 3));
- QTest::newRow("[1] [4]") << (QVector<int>() << 1 << 4) << (KItemRangeList() << KItemRange(1, 1) << KItemRange(4, 1));
- QTest::newRow("[1-3] [5]") << (QVector<int>() << 1 << 2 << 3 << 5) << (KItemRangeList() << KItemRange(1, 3) << KItemRange(5, 1));
- QTest::newRow("[1] [5-6]") << (QVector<int>() << 1 << 5 << 6) << (KItemRangeList() << KItemRange(1, 1) << KItemRange(5, 2));
- QTest::newRow("duplicates: 1 1") << (QVector<int>() << 1 << 1) << (KItemRangeList() << KItemRange(1, 1));
- QTest::newRow("duplicates: 1 1 1") << (QVector<int>() << 1 << 1 << 1) << (KItemRangeList() << KItemRange(1, 1));
- QTest::newRow("duplicates: 1 1 5") << (QVector<int>() << 1 << 1 << 5) << (KItemRangeList() << KItemRange(1, 1) << KItemRange(5, 1));
- QTest::newRow("duplicates: 1 5 5") << (QVector<int>() << 1 << 5 << 5) << (KItemRangeList() << KItemRange(1, 1) << KItemRange(5, 1));
- QTest::newRow("duplicates: 1 1 1 5") << (QVector<int>() << 1 << 1 << 1 << 5) << (KItemRangeList() << KItemRange(1, 1) << KItemRange(5, 1));
- QTest::newRow("duplicates: 1 5 5 5") << (QVector<int>() << 1 << 5 << 5 << 5) << (KItemRangeList() << KItemRange(1, 1) << KItemRange(5, 1));
- QTest::newRow("duplicates: 1 1 2") << (QVector<int>() << 1 << 1 << 2) << (KItemRangeList() << KItemRange(1, 2));
- QTest::newRow("duplicates: 1 2 2") << (QVector<int>() << 1 << 2 << 2) << (KItemRangeList() << KItemRange(1, 2));
- QTest::newRow("duplicates: 1 1 2 3") << (QVector<int>() << 1 << 1 << 2 << 3) << (KItemRangeList() << KItemRange(1, 3));
- QTest::newRow("duplicates: 1 2 2 3") << (QVector<int>() << 1 << 2 << 2 << 3) << (KItemRangeList() << KItemRange(1, 3));
- QTest::newRow("duplicates: 1 2 3 3") << (QVector<int>() << 1 << 2 << 3 << 3) << (KItemRangeList() << KItemRange(1, 3));
+ QTest::newRow("empty") << QVector<int>{} << KItemRangeList();
+ QTest::newRow("[1]") << QVector<int>{1} << (KItemRangeList() << KItemRange(1, 1));
+ QTest::newRow("[9]") << QVector<int>{9} << (KItemRangeList() << KItemRange(9, 1));
+ QTest::newRow("[1-2]") << QVector<int>{1, 2} << (KItemRangeList() << KItemRange(1, 2));
+ QTest::newRow("[1-3]") << QVector<int>{1, 2, 3} << (KItemRangeList() << KItemRange(1, 3));
+ QTest::newRow("[1] [4]") << QVector<int>{1, 4} << (KItemRangeList() << KItemRange(1, 1) << KItemRange(4, 1));
+ QTest::newRow("[1-3] [5]") << QVector<int>{1, 2, 3, 5} << (KItemRangeList() << KItemRange(1, 3) << KItemRange(5, 1));
+ QTest::newRow("[1] [5-6]") << QVector<int>{1, 5, 6} << (KItemRangeList() << KItemRange(1, 1) << KItemRange(5, 2));
+ QTest::newRow("duplicates: 1 1") << QVector<int>{1, 1} << (KItemRangeList() << KItemRange(1, 1));
+ QTest::newRow("duplicates: 1 1 1") << QVector<int>{1, 1, 1} << (KItemRangeList() << KItemRange(1, 1));
+ QTest::newRow("duplicates: 1 1 5") << QVector<int>{1, 1, 5} << (KItemRangeList() << KItemRange(1, 1) << KItemRange(5, 1));
+ QTest::newRow("duplicates: 1 5 5") << QVector<int>{1, 5, 5} << (KItemRangeList() << KItemRange(1, 1) << KItemRange(5, 1));
+ QTest::newRow("duplicates: 1 1 1 5") << QVector<int>{1, 1, 1, 5} << (KItemRangeList() << KItemRange(1, 1) << KItemRange(5, 1));
+ QTest::newRow("duplicates: 1 5 5 5") << QVector<int>{1, 5, 5, 5} << (KItemRangeList() << KItemRange(1, 1) << KItemRange(5, 1));
+ QTest::newRow("duplicates: 1 1 2") << QVector<int>{1, 1, 2} << (KItemRangeList() << KItemRange(1, 2));
+ QTest::newRow("duplicates: 1 2 2") << QVector<int>{1, 2, 2} << (KItemRangeList() << KItemRange(1, 2));
+ QTest::newRow("duplicates: 1 1 2 3") << QVector<int>{1, 1, 2, 3} << (KItemRangeList() << KItemRange(1, 3));
+ QTest::newRow("duplicates: 1 2 2 3") << QVector<int>{1, 2, 2, 3} << (KItemRangeList() << KItemRange(1, 3));
+ QTest::newRow("duplicates: 1 2 3 3") << QVector<int>{1, 2, 3, 3} << (KItemRangeList() << KItemRange(1, 3));
}
void KItemRangeTest::testFromSortedContainer()
@@ -70,6 +69,6 @@ void KItemRangeTest::testFromSortedContainer()
QCOMPARE(expected, result);
}
-QTEST_KDEMAIN(KItemRangeTest, NoGUI)
+QTEST_GUILESS_MAIN(KItemRangeTest)
#include "kitemrangetest.moc"
diff --git a/src/tests/kitemsettest.cpp b/src/tests/kitemsettest.cpp
index 2832596ba..0d14e20fa 100644
--- a/src/tests/kitemsettest.cpp
+++ b/src/tests/kitemsettest.cpp
@@ -17,10 +17,9 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
-#include <qtest_kde.h>
-
#include "kitemviews/kitemset.h"
+#include <QTest>
#include <QVector>
Q_DECLARE_METATYPE(KItemRangeList);
@@ -607,6 +606,6 @@ void KItemSetTest::testSymmetricDifference()
}
-QTEST_KDEMAIN(KItemSetTest, NoGUI)
+QTEST_GUILESS_MAIN(KItemSetTest)
#include "kitemsettest.moc"
diff --git a/src/tests/kstandarditemmodeltest.cpp b/src/tests/kstandarditemmodeltest.cpp
index 2de0d0b78..889748f35 100644
--- a/src/tests/kstandarditemmodeltest.cpp
+++ b/src/tests/kstandarditemmodeltest.cpp
@@ -18,11 +18,13 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
-#include <qtest_kde.h>
+#include "dolphindebug.h"
#include "kitemviews/kstandarditem.h"
#include "kitemviews/kstandarditemmodel.h"
+#include <QTest>
+
class KStandardItemModelTest : public QObject
{
Q_OBJECT
@@ -98,13 +100,13 @@ bool KStandardItemModelTest::isModelConsistent() const
for (int i = 0; i < m_model->count(); ++i) {
const KStandardItem* item = m_model->item(i);
if (!item) {
- qWarning() << "Item" << i << "is null";
+ qCWarning(DolphinDebug) << "Item" << i << "is null";
return false;
}
const int itemIndex = m_model->index(item);
if (itemIndex != i) {
- qWarning() << "Item" << i << "has a wrong index:" << itemIndex;
+ qCWarning(DolphinDebug) << "Item" << i << "has a wrong index:" << itemIndex;
return false;
}
}
@@ -112,6 +114,6 @@ bool KStandardItemModelTest::isModelConsistent() const
return true;
}
-QTEST_KDEMAIN(KStandardItemModelTest, NoGUI)
+QTEST_GUILESS_MAIN(KStandardItemModelTest)
#include "kstandarditemmodeltest.moc"
diff --git a/src/tests/testdir.cpp b/src/tests/testdir.cpp
index 8938e6082..b84b344b7 100644
--- a/src/tests/testdir.cpp
+++ b/src/tests/testdir.cpp
@@ -28,7 +28,7 @@
#endif
TestDir::TestDir(const QString& directoryPrefix) :
- KTempDir(directoryPrefix)
+ QTemporaryDir(directoryPrefix)
{
}
@@ -36,9 +36,9 @@ TestDir::~TestDir()
{
}
-KUrl TestDir::url() const
+QUrl TestDir::url() const
{
- return KUrl(name());
+ return QUrl::fromLocalFile(path());
}
/** The following function is taken from kdelibs/kio/tests/kiotesthelper.h, copyright (C) 2006 by David Faure */
@@ -85,7 +85,7 @@ void TestDir::createDir(const QString& path, const QDateTime& time)
{
QString absolutePath = path;
makePathAbsoluteAndCreateParents(absolutePath);
- QDir(name()).mkdir(absolutePath);
+ QDir(TestDir::path()).mkdir(absolutePath);
if (time.isValid()) {
setTimeStamp(absolutePath, time);
@@ -94,12 +94,19 @@ void TestDir::createDir(const QString& path, const QDateTime& time)
Q_ASSERT(QFile::exists(absolutePath));
}
+void TestDir::removeFiles(const QStringList& files)
+{
+ foreach (const QString& path, files) {
+ removeFile(path);
+ }
+}
+
void TestDir::removeFile(const QString& path)
{
QString absolutePath = path;
QFileInfo fileInfo(absolutePath);
if (!fileInfo.isAbsolute()) {
- absolutePath = name() + path;
+ absolutePath = TestDir::path() + QLatin1Char('/') + path;
}
QFile::remove(absolutePath);
}
@@ -108,7 +115,7 @@ void TestDir::makePathAbsoluteAndCreateParents(QString& path)
{
QFileInfo fileInfo(path);
if (!fileInfo.isAbsolute()) {
- path = name() + path;
+ path = TestDir::path() + QLatin1Char('/') + path;
fileInfo.setFile(path);
}
diff --git a/src/tests/testdir.h b/src/tests/testdir.h
index 0d3c5dd8d..3f244448c 100644
--- a/src/tests/testdir.h
+++ b/src/tests/testdir.h
@@ -20,23 +20,22 @@
#ifndef TESTDIR_H
#define TESTDIR_H
-#include <KTempDir>
-#include <KUrl>
-
+#include <QUrl>
+#include <QTemporaryDir>
#include <QDateTime>
/**
- * TestDir provides a temporary directory. In addition to KTempDir, it has
+ * TestDir provides a temporary directory. In addition to QTemporaryDir, it has
* methods that create files and subdirectories inside the directory.
*/
-class TestDir : public KTempDir
+class TestDir : public QTemporaryDir
{
public:
TestDir(const QString& directoryPrefix = QString());
virtual ~TestDir();
- KUrl url() const;
+ QUrl url() const;
/**
* The following functions create either a file, a list of files, or a directory.
@@ -50,6 +49,7 @@ public:
void createDir(const QString& path, const QDateTime& time = QDateTime());
void removeFile(const QString& path);
+ void removeFiles(const QStringList& files);
private:
void makePathAbsoluteAndCreateParents(QString& path);
diff --git a/src/tests/viewpropertiestest.cpp b/src/tests/viewpropertiestest.cpp
index c459f6874..482e4127d 100644
--- a/src/tests/viewpropertiestest.cpp
+++ b/src/tests/viewpropertiestest.cpp
@@ -17,13 +17,11 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
-#include <qtest_kde.h>
-
#include "dolphin_generalsettings.h"
#include "views/viewproperties.h"
#include "testdir.h"
-#include <QDebug>
+#include <QTest>
#include <QDir>
class ViewPropertiesTest : public QObject
@@ -69,33 +67,31 @@ void ViewPropertiesTest::cleanup()
*/
void ViewPropertiesTest::testReadOnlyBehavior()
{
- QString dotDirectoryFile = m_testDir->url().toLocalFile() + ".directory";
+ QString dotDirectoryFile = m_testDir->url().toLocalFile() + "/.directory";
QVERIFY(!QFile::exists(dotDirectoryFile));
- ViewProperties* props = new ViewProperties(m_testDir->url());
+ QScopedPointer<ViewProperties> props(new ViewProperties(m_testDir->url()));
QVERIFY(props->isAutoSaveEnabled());
const QByteArray sortRole = props->sortRole();
Q_UNUSED(sortRole);
- delete props;
- props = 0;
+ props.reset();
QVERIFY(!QFile::exists(dotDirectoryFile));
}
void ViewPropertiesTest::testAutoSave()
{
- QString dotDirectoryFile = m_testDir->url().toLocalFile() + ".directory";
+ QString dotDirectoryFile = m_testDir->url().toLocalFile() + "/.directory";
QVERIFY(!QFile::exists(dotDirectoryFile));
- ViewProperties* props = new ViewProperties(m_testDir->url());
+ QScopedPointer<ViewProperties> props(new ViewProperties(m_testDir->url()));
QVERIFY(props->isAutoSaveEnabled());
props->setSortRole("someNewSortRole");
- delete props;
- props = 0;
+ props.reset();
QVERIFY(QFile::exists(dotDirectoryFile));
}
-QTEST_KDEMAIN(ViewPropertiesTest, NoGUI)
+QTEST_GUILESS_MAIN(ViewPropertiesTest)
#include "viewpropertiestest.moc"
diff --git a/src/views/dolphinfileitemlistwidget.cpp b/src/views/dolphinfileitemlistwidget.cpp
index 33ee6a277..f15230841 100644
--- a/src/views/dolphinfileitemlistwidget.cpp
+++ b/src/views/dolphinfileitemlistwidget.cpp
@@ -19,12 +19,11 @@
#include "dolphinfileitemlistwidget.h"
-#include <KIcon>
+#include <QIcon>
#include <KIconLoader>
-#include <kversioncontrolplugin2.h>
#include <QColor>
-#include <KDebug>
+#include "dolphindebug.h"
DolphinFileItemListWidget::DolphinFileItemListWidget(KItemListWidgetInformant* informant,
QGraphicsItem* parent) :
@@ -43,7 +42,7 @@ void DolphinFileItemListWidget::refreshCache()
if (values.contains("version")) {
// The item is under version control. Apply the text color corresponding
// to its version state.
- const KVersionControlPlugin2::ItemVersion version = static_cast<KVersionControlPlugin2::ItemVersion>(values.value("version").toInt());
+ const KVersionControlPlugin::ItemVersion version = static_cast<KVersionControlPlugin::ItemVersion>(values.value("version").toInt());
const QColor textColor = styleOption().palette.text().color();
QColor tintColor = textColor;
@@ -51,16 +50,16 @@ void DolphinFileItemListWidget::refreshCache()
// as tint colors and are mixed with the current set text color. The tint colors
// have been optimized for the base colors of the corresponding Oxygen emblems.
switch (version) {
- case KVersionControlPlugin2::UpdateRequiredVersion: tintColor = Qt::yellow; break;
- case KVersionControlPlugin2::LocallyModifiedUnstagedVersion: tintColor = Qt::green; break;
- case KVersionControlPlugin2::LocallyModifiedVersion: tintColor = Qt::green; break;
- case KVersionControlPlugin2::AddedVersion: tintColor = Qt::green; break;
- case KVersionControlPlugin2::RemovedVersion: tintColor = Qt::darkRed; break;
- case KVersionControlPlugin2::ConflictingVersion: tintColor = Qt::red; break;
- case KVersionControlPlugin2::IgnoredVersion: tintColor = Qt::white; break;
- case KVersionControlPlugin2::MissingVersion: tintColor = Qt::red; break;
- case KVersionControlPlugin2::NormalVersion:
- case KVersionControlPlugin2::UnversionedVersion:
+ case KVersionControlPlugin::UpdateRequiredVersion: tintColor = Qt::yellow; break;
+ case KVersionControlPlugin::LocallyModifiedUnstagedVersion: tintColor = Qt::green; break;
+ case KVersionControlPlugin::LocallyModifiedVersion: tintColor = Qt::green; break;
+ case KVersionControlPlugin::AddedVersion: tintColor = Qt::green; break;
+ case KVersionControlPlugin::RemovedVersion: tintColor = Qt::darkRed; break;
+ case KVersionControlPlugin::ConflictingVersion: tintColor = Qt::red; break;
+ case KVersionControlPlugin::IgnoredVersion: tintColor = Qt::white; break;
+ case KVersionControlPlugin::MissingVersion: tintColor = Qt::red; break;
+ case KVersionControlPlugin::NormalVersion:
+ case KVersionControlPlugin::UnversionedVersion:
default:
break;
}
@@ -78,7 +77,7 @@ void DolphinFileItemListWidget::refreshCache()
setTextColor(color);
}
-QPixmap DolphinFileItemListWidget::overlayForState(KVersionControlPlugin2::ItemVersion version, int size)
+QPixmap DolphinFileItemListWidget::overlayForState(KVersionControlPlugin::ItemVersion version, int size)
{
int overlayHeight = KIconLoader::SizeSmall;
if (size >= KIconLoader::SizeEnormous) {
@@ -115,15 +114,14 @@ QPixmap DolphinFileItemListWidget::overlayForState(KVersionControlPlugin2::ItemV
iconName = "vcs-conflicting";
break;
case KVersionControlPlugin::UnversionedVersion:
- case KVersionControlPlugin2::IgnoredVersion:
- case KVersionControlPlugin2::MissingVersion:
+ case KVersionControlPlugin::IgnoredVersion:
+ case KVersionControlPlugin::MissingVersion:
break;
default:
Q_ASSERT(false);
break;
}
- return KIcon(iconName).pixmap(QSize(overlayHeight, overlayHeight));
+ return QIcon::fromTheme(iconName).pixmap(QSize(overlayHeight, overlayHeight));
}
-#include "dolphinfileitemlistwidget.moc"
diff --git a/src/views/dolphinfileitemlistwidget.h b/src/views/dolphinfileitemlistwidget.h
index b9de6fb19..af73ac937 100644
--- a/src/views/dolphinfileitemlistwidget.h
+++ b/src/views/dolphinfileitemlistwidget.h
@@ -20,10 +20,10 @@
#ifndef DOLPHINFILEITEMLISTWIDGET_H
#define DOLPHINFILEITEMLISTWIDGET_H
-#include <libdolphin_export.h>
+#include "dolphin_export.h"
#include <kitemviews/kfileitemlistwidget.h>
-#include <kversioncontrolplugin2.h>
+#include "versioncontrol/kversioncontrolplugin.h"
/**
* @brief Extends KFileItemListWidget to handle the "version" role.
@@ -31,7 +31,7 @@
* The "version" role is set if version-control-plugins have been enabled.
* @see KVersionControlPlugin
*/
-class LIBDOLPHINPRIVATE_EXPORT DolphinFileItemListWidget : public KFileItemListWidget
+class DOLPHIN_EXPORT DolphinFileItemListWidget : public KFileItemListWidget
{
Q_OBJECT
@@ -40,10 +40,10 @@ public:
virtual ~DolphinFileItemListWidget();
protected:
- virtual void refreshCache();
+ virtual void refreshCache() Q_DECL_OVERRIDE;
private:
- static QPixmap overlayForState(KVersionControlPlugin2::ItemVersion version, int size);
+ static QPixmap overlayForState(KVersionControlPlugin::ItemVersion version, int size);
};
diff --git a/src/views/dolphinitemlistview.cpp b/src/views/dolphinitemlistview.cpp
index db4dadf2f..60c8bb97c 100644
--- a/src/views/dolphinitemlistview.cpp
+++ b/src/views/dolphinitemlistview.cpp
@@ -30,7 +30,6 @@
#include <kitemviews/kitemlistcontroller.h>
#include <kitemviews/kitemliststyleoption.h>
-#include <KGlobalSettings>
#include <views/viewmodecontroller.h>
@@ -94,7 +93,7 @@ void DolphinItemListView::readSettings()
updateFont();
updateGridSize();
- const KConfigGroup globalConfig(KGlobal::config(), "PreviewSettings");
+ const KConfigGroup globalConfig(KSharedConfig::openConfig(), "PreviewSettings");
const QStringList plugins = globalConfig.readEntry("Plugins", QStringList()
<< "directorythumbnail"
<< "imagethumbnail"
@@ -106,9 +105,9 @@ void DolphinItemListView::readSettings()
void DolphinItemListView::writeSettings()
{
- IconsModeSettings::self()->writeConfig();
- CompactModeSettings::self()->writeConfig();
- DetailsModeSettings::self()->writeConfig();
+ IconsModeSettings::self()->save();
+ CompactModeSettings::self()->save();
+ DetailsModeSettings::self()->save();
}
KItemListWidgetCreatorBase* DolphinItemListView::defaultWidgetCreator() const
@@ -262,4 +261,3 @@ ViewModeSettings::ViewMode DolphinItemListView::viewMode() const
return mode;
}
-#include "dolphinitemlistview.moc"
diff --git a/src/views/dolphinitemlistview.h b/src/views/dolphinitemlistview.h
index 67302e44d..7eec6f17a 100644
--- a/src/views/dolphinitemlistview.h
+++ b/src/views/dolphinitemlistview.h
@@ -23,7 +23,7 @@
#include <kitemviews/kfileitemlistview.h>
#include <settings/viewmodes/viewmodesettings.h>
-#include <libdolphin_export.h>
+#include "dolphin_export.h"
class KFileItemListView;
@@ -34,7 +34,7 @@ class KFileItemListView;
* the view-properties into the corresponding KItemListView
* properties.
*/
-class LIBDOLPHINPRIVATE_EXPORT DolphinItemListView : public KFileItemListView
+class DOLPHIN_EXPORT DolphinItemListView : public KFileItemListView
{
Q_OBJECT
@@ -49,14 +49,14 @@ public:
void writeSettings();
protected:
- virtual KItemListWidgetCreatorBase* defaultWidgetCreator() const;
- virtual bool itemLayoutSupportsItemExpanding(ItemLayout layout) const;
- virtual void onItemLayoutChanged(ItemLayout current, ItemLayout previous);
- virtual void onPreviewsShownChanged(bool shown);
+ virtual KItemListWidgetCreatorBase* defaultWidgetCreator() const Q_DECL_OVERRIDE;
+ virtual bool itemLayoutSupportsItemExpanding(ItemLayout layout) const Q_DECL_OVERRIDE;
+ virtual void onItemLayoutChanged(ItemLayout current, ItemLayout previous) Q_DECL_OVERRIDE;
+ virtual void onPreviewsShownChanged(bool shown) Q_DECL_OVERRIDE;
virtual void onVisibleRolesChanged(const QList<QByteArray>& current,
- const QList<QByteArray>& previous);
+ const QList<QByteArray>& previous) Q_DECL_OVERRIDE;
- virtual void updateFont();
+ virtual void updateFont() Q_DECL_OVERRIDE;
private:
void updateGridSize();
diff --git a/src/views/dolphinnewfilemenuobserver.cpp b/src/views/dolphinnewfilemenuobserver.cpp
index 7669f1561..275e1c4fb 100644
--- a/src/views/dolphinnewfilemenuobserver.cpp
+++ b/src/views/dolphinnewfilemenuobserver.cpp
@@ -19,7 +19,6 @@
#include "dolphinnewfilemenuobserver.h"
-#include <KGlobal>
#include "dolphinnewfilemenu.h"
class DolphinNewFileMenuObserverSingleton
@@ -27,7 +26,7 @@ class DolphinNewFileMenuObserverSingleton
public:
DolphinNewFileMenuObserver instance;
};
-K_GLOBAL_STATIC(DolphinNewFileMenuObserverSingleton, s_DolphinNewFileMenuObserver)
+Q_GLOBAL_STATIC(DolphinNewFileMenuObserverSingleton, s_DolphinNewFileMenuObserver)
DolphinNewFileMenuObserver& DolphinNewFileMenuObserver::instance()
{
@@ -36,22 +35,22 @@ DolphinNewFileMenuObserver& DolphinNewFileMenuObserver::instance()
void DolphinNewFileMenuObserver::attach(const DolphinNewFileMenu* menu)
{
- connect(menu, SIGNAL(fileCreated(KUrl)),
- this, SIGNAL(itemCreated(KUrl)));
- connect(menu, SIGNAL(directoryCreated(KUrl)),
- this, SIGNAL(itemCreated(KUrl)));
- connect(menu, SIGNAL(errorMessage(QString)),
- this, SIGNAL(errorMessage(QString)));
+ connect(menu, &DolphinNewFileMenu::fileCreated,
+ this, &DolphinNewFileMenuObserver::itemCreated);
+ connect(menu, &DolphinNewFileMenu::directoryCreated,
+ this, &DolphinNewFileMenuObserver::itemCreated);
+ connect(menu, &DolphinNewFileMenu::errorMessage,
+ this, &DolphinNewFileMenuObserver::errorMessage);
}
void DolphinNewFileMenuObserver::detach(const DolphinNewFileMenu* menu)
{
- disconnect(menu, SIGNAL(fileCreated(KUrl)),
- this, SIGNAL(itemCreated(KUrl)));
- disconnect(menu, SIGNAL(directoryCreated(KUrl)),
- this, SIGNAL(itemCreated(KUrl)));
- disconnect(menu, SIGNAL(errorMessage(QString)),
- this, SIGNAL(errorMessage(QString)));
+ disconnect(menu, &DolphinNewFileMenu::fileCreated,
+ this, &DolphinNewFileMenuObserver::itemCreated);
+ disconnect(menu, &DolphinNewFileMenu::directoryCreated,
+ this, &DolphinNewFileMenuObserver::itemCreated);
+ disconnect(menu, &DolphinNewFileMenu::errorMessage,
+ this, &DolphinNewFileMenuObserver::errorMessage);
}
DolphinNewFileMenuObserver::DolphinNewFileMenuObserver() :
@@ -63,4 +62,3 @@ DolphinNewFileMenuObserver::~DolphinNewFileMenuObserver()
{
}
-#include "dolphinnewfilemenuobserver.moc"
diff --git a/src/views/dolphinnewfilemenuobserver.h b/src/views/dolphinnewfilemenuobserver.h
index 239476eb9..df4621f17 100644
--- a/src/views/dolphinnewfilemenuobserver.h
+++ b/src/views/dolphinnewfilemenuobserver.h
@@ -22,10 +22,9 @@
#include <QObject>
-#include "libdolphin_export.h"
+#include "dolphin_export.h"
class DolphinNewFileMenu;
-class KUrl;
/**
* @brief Allows to observe new file items that have been created
@@ -34,7 +33,7 @@ class KUrl;
* As soon as a DolphinNewFileMenu instance created a new item,
* the observer will emit the signal itemCreated().
*/
-class LIBDOLPHINPRIVATE_EXPORT DolphinNewFileMenuObserver : public QObject
+class DOLPHIN_EXPORT DolphinNewFileMenuObserver : public QObject
{
Q_OBJECT
@@ -44,7 +43,7 @@ public:
void detach(const DolphinNewFileMenu* menu);
signals:
- void itemCreated(const KUrl& url);
+ void itemCreated(const QUrl& url);
void errorMessage(const QString& error);
private:
diff --git a/src/views/dolphinremoteencoding.cpp b/src/views/dolphinremoteencoding.cpp
index 04b350eda..961a7c800 100644
--- a/src/views/dolphinremoteencoding.cpp
+++ b/src/views/dolphinremoteencoding.cpp
@@ -26,16 +26,14 @@
#include "dolphinremoteencoding.h"
#include "dolphinviewactionhandler.h"
-#include <KDebug>
+#include "dolphindebug.h"
#include <KActionMenu>
#include <KActionCollection>
-#include <KIcon>
-#include <KLocale>
-#include <KGlobal>
-#include <KMimeType>
+#include <QIcon>
+#include <KLocalizedString>
#include <KConfig>
#include <KCharsets>
-#include <KMenu>
+#include <QMenu>
#include <KProtocolInfo>
#include <KProtocolManager>
#include <KIO/Scheduler>
@@ -49,10 +47,10 @@ DolphinRemoteEncoding::DolphinRemoteEncoding(QObject* parent, DolphinViewActionH
m_loaded(false),
m_idDefault(0)
{
- m_menu = new KActionMenu(KIcon("character-set"), i18n("Select Remote Charset"), this);
+ m_menu = new KActionMenu(QIcon::fromTheme("character-set"), i18n("Select Remote Charset"), this);
m_actionHandler->actionCollection()->addAction("change_remote_encoding", m_menu);
- connect(m_menu->menu(), SIGNAL(aboutToShow()),
- this, SLOT(slotAboutToShow()));
+ connect(m_menu->menu(), &QMenu::aboutToShow,
+ this, &DolphinRemoteEncoding::slotAboutToShow);
m_menu->setEnabled(false);
m_menu->setDelayed(false);
@@ -70,17 +68,17 @@ void DolphinRemoteEncoding::slotReload()
void DolphinRemoteEncoding::loadSettings()
{
m_loaded = true;
- m_encodingDescriptions = KGlobal::charsets()->descriptiveEncodingNames();
+ m_encodingDescriptions = KCharsets::charsets()->descriptiveEncodingNames();
fillMenu();
}
void DolphinRemoteEncoding::slotAboutToOpenUrl()
{
- KUrl oldURL = m_currentURL;
+ QUrl oldURL = m_currentURL;
m_currentURL = m_actionHandler->currentView()->url();
- if (m_currentURL.protocol() != oldURL.protocol()) {
+ if (m_currentURL.scheme() != oldURL.scheme()) {
// This plugin works on ftp, fish, etc.
// everything whose type is T_FILESYSTEM except for local files
if (!m_currentURL.isLocalFile() &&
@@ -101,7 +99,7 @@ void DolphinRemoteEncoding::slotAboutToOpenUrl()
void DolphinRemoteEncoding::fillMenu()
{
- KMenu* menu = m_menu->menu();
+ QMenu* menu = m_menu->menu();
menu->clear();
@@ -117,7 +115,7 @@ void DolphinRemoteEncoding::fillMenu()
menu->addAction(i18n("Default"), this, SLOT(slotDefault()), 0)->setCheckable(true);
m_idDefault = m_encodingDescriptions.size() + 2;
- connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(slotItemSelected(QAction*)));
+ connect(menu, &QMenu::triggered, this, &DolphinRemoteEncoding::slotItemSelected);
}
void DolphinRemoteEncoding::updateMenu()
@@ -131,7 +129,7 @@ void DolphinRemoteEncoding::updateMenu()
m_menu->menu()->actions().at(i)->setChecked(false);
}
- const QString charset = KGlobal::charsets()->descriptionForEncoding(KProtocolManager::charsetFor(m_currentURL));
+ const QString charset = KCharsets::charsets()->descriptionForEncoding(KProtocolManager::charsetFor(m_currentURL));
if (!charset.isEmpty()) {
int id = 0;
bool isFound = false;
@@ -143,10 +141,10 @@ void DolphinRemoteEncoding::updateMenu()
}
}
- kDebug() << "URL=" << m_currentURL << " charset=" << charset;
+ qCDebug(DolphinDebug) << "URL=" << m_currentURL << " charset=" << charset;
if (!isFound) {
- kWarning() << "could not find entry for charset=" << charset ;
+ qCWarning(DolphinDebug) << "could not find entry for charset=" << charset ;
} else {
m_menu->menu()->actions().at(id)->setChecked(true);
}
@@ -169,10 +167,10 @@ void DolphinRemoteEncoding::slotItemSelected(QAction* action)
if (action) {
int id = action->data().toInt();
- KConfig config(("kio_" + m_currentURL.protocol() + "rc").toLatin1());
+ KConfig config(("kio_" + m_currentURL.scheme() + "rc").toLatin1());
QString host = m_currentURL.host();
if (m_menu->menu()->actions().at(id)->isChecked()) {
- QString charset = KGlobal::charsets()->encodingForName(m_encodingDescriptions.at(id));
+ QString charset = KCharsets::charsets()->encodingForName(m_encodingDescriptions.at(id));
KConfigGroup cg(&config, host);
cg.writeEntry(DATA_KEY, charset);
config.sync();
@@ -187,7 +185,7 @@ void DolphinRemoteEncoding::slotDefault()
{
// We have no choice but delete all higher domain level
// settings here since it affects what will be matched.
- KConfig config(("kio_" + m_currentURL.protocol() + "rc").toLatin1());
+ KConfig config(("kio_" + m_currentURL.scheme() + "rc").toLatin1());
QStringList partList = m_currentURL.host().split('.', QString::SkipEmptyParts);
if (!partList.isEmpty()) {
@@ -213,7 +211,7 @@ void DolphinRemoteEncoding::slotDefault()
}
for (QStringList::const_iterator it = domains.constBegin(); it != domains.constEnd();++it) {
- kDebug() << "Domain to remove: " << *it;
+ qCDebug(DolphinDebug) << "Domain to remove: " << *it;
if (config.hasGroup(*it)) {
config.deleteGroup(*it);
} else if (config.group("").hasKey(*it)) {
@@ -235,4 +233,3 @@ void DolphinRemoteEncoding::updateView()
m_actionHandler->currentView()->reload();
}
-#include "dolphinremoteencoding.moc"
diff --git a/src/views/dolphinremoteencoding.h b/src/views/dolphinremoteencoding.h
index 8dec518d0..28ff52cb3 100644
--- a/src/views/dolphinremoteencoding.h
+++ b/src/views/dolphinremoteencoding.h
@@ -22,8 +22,8 @@
#include <QStringList>
#include <QAction>
-#include <KUrl>
-#include "libdolphin_export.h"
+#include <QUrl>
+#include "dolphin_export.h"
class KActionMenu;
@@ -35,7 +35,7 @@ class DolphinViewActionHandler;
* When browsing remote url, its possible to change encoding from Tools Menu.
*/
-class LIBDOLPHINPRIVATE_EXPORT DolphinRemoteEncoding: public QObject
+class DOLPHIN_EXPORT DolphinRemoteEncoding: public QObject
{
Q_OBJECT
public:
@@ -59,7 +59,7 @@ private:
KActionMenu* m_menu;
QStringList m_encodingDescriptions;
- KUrl m_currentURL;
+ QUrl m_currentURL;
DolphinViewActionHandler* m_actionHandler;
bool m_loaded;
diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp
index 1de973bd5..191cd6511 100644
--- a/src/views/dolphinview.cpp
+++ b/src/views/dolphinview.cpp
@@ -24,24 +24,21 @@
#include <QAbstractItemView>
#include <QApplication>
-#include <QBoxLayout>
#include <QClipboard>
#include <QDropEvent>
#include <QGraphicsSceneDragDropEvent>
-#include <QKeyEvent>
-#include <QItemSelection>
#include <QTimer>
#include <QScrollBar>
-
+#include <QPointer>
+#include <QMenu>
+#include <QVBoxLayout>
#include <KDesktopFile>
#include <KProtocolManager>
-#include <KActionCollection>
#include <KColorScheme>
#include <KDirModel>
-#include <KIconEffect>
#include <KFileItem>
#include <KFileItemListProperties>
-#include <KLocale>
+#include <KLocalizedString>
#include <kitemviews/kfileitemmodel.h>
#include <kitemviews/kfileitemlistview.h>
#include <kitemviews/kitemlistcontainer.h>
@@ -49,18 +46,18 @@
#include <kitemviews/kitemlistselectionmanager.h>
#include <kitemviews/kitemlistview.h>
#include <kitemviews/kitemlistcontroller.h>
+#include <KIO/CopyJob>
#include <KIO/DeleteJob>
#include <KIO/JobUiDelegate>
-#include <KIO/NetAccess>
#include <KIO/PreviewJob>
+#include <KIO/DropJob>
+#include <KIO/PasteJob>
+#include <KIO/Paste>
#include <KJob>
-#include <KMenu>
+#include <QMenu>
#include <KMessageBox>
-#include <konq_fileitemcapabilities.h>
-#include <konq_operations.h>
-#include <konqmimedata.h>
-#include <KToggleAction>
-#include <KUrl>
+#include <KJobWidgets>
+#include <QUrl>
#include "dolphinnewfilemenuobserver.h"
#include "dolphin_detailsmodesettings.h"
@@ -75,14 +72,15 @@
#include "zoomlevelinfo.h"
#ifdef HAVE_BALOO
- #include <baloo/indexerconfig.h>
+ #include <Baloo/IndexerConfig>
#endif
+#include <KFormat>
namespace {
const int MaxModeEnum = DolphinView::CompactView;
};
-DolphinView::DolphinView(const KUrl& url, QWidget* parent) :
+DolphinView::DolphinView(const QUrl& url, QWidget* parent) :
QWidget(parent),
m_active(true),
m_tabsForFiles(false),
@@ -114,19 +112,19 @@ DolphinView::DolphinView(const KUrl& url, QWidget* parent) :
// When a new item has been created by the "Create New..." menu, the item should
// get selected and it must be assured that the item will get visible. As the
// creation is done asynchronously, several signals must be checked:
- connect(&DolphinNewFileMenuObserver::instance(), SIGNAL(itemCreated(KUrl)),
- this, SLOT(observeCreatedItem(KUrl)));
+ connect(&DolphinNewFileMenuObserver::instance(), &DolphinNewFileMenuObserver::itemCreated,
+ this, &DolphinView::observeCreatedItem);
m_selectionChangedTimer = new QTimer(this);
m_selectionChangedTimer->setSingleShot(true);
m_selectionChangedTimer->setInterval(300);
- connect(m_selectionChangedTimer, SIGNAL(timeout()),
- this, SLOT(emitSelectionChangedSignal()));
+ connect(m_selectionChangedTimer, &QTimer::timeout,
+ this, &DolphinView::emitSelectionChangedSignal);
m_model = new KFileItemModel(this);
m_view = new DolphinItemListView();
m_view->setEnabledSelectionToggles(GeneralSettings::showSelectionToggle());
- m_view->setVisibleRoles(QList<QByteArray>() << "text");
+ m_view->setVisibleRoles({"text"});
applyModeToView();
KItemListController* controller = new KItemListController(m_model, m_view, this);
@@ -140,60 +138,60 @@ DolphinView::DolphinView(const KUrl& url, QWidget* parent) :
m_container = new KItemListContainer(controller, this);
m_container->installEventFilter(this);
setFocusProxy(m_container);
- connect(m_container->horizontalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(hideToolTip()));
- connect(m_container->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(hideToolTip()));
+ connect(m_container->horizontalScrollBar(), &QScrollBar::valueChanged, this, &DolphinView::hideToolTip);
+ connect(m_container->verticalScrollBar(), &QScrollBar::valueChanged, this, &DolphinView::hideToolTip);
controller->setSelectionBehavior(KItemListController::MultiSelection);
- connect(controller, SIGNAL(itemActivated(int)), this, SLOT(slotItemActivated(int)));
- connect(controller, SIGNAL(itemsActivated(KItemSet)), this, SLOT(slotItemsActivated(KItemSet)));
- connect(controller, SIGNAL(itemMiddleClicked(int)), this, SLOT(slotItemMiddleClicked(int)));
- connect(controller, SIGNAL(itemContextMenuRequested(int,QPointF)), this, SLOT(slotItemContextMenuRequested(int,QPointF)));
- connect(controller, SIGNAL(viewContextMenuRequested(QPointF)), this, SLOT(slotViewContextMenuRequested(QPointF)));
- connect(controller, SIGNAL(headerContextMenuRequested(QPointF)), this, SLOT(slotHeaderContextMenuRequested(QPointF)));
- connect(controller, SIGNAL(mouseButtonPressed(int,Qt::MouseButtons)), this, SLOT(slotMouseButtonPressed(int,Qt::MouseButtons)));
- connect(controller, SIGNAL(itemHovered(int)), this, SLOT(slotItemHovered(int)));
- connect(controller, SIGNAL(itemUnhovered(int)), this, SLOT(slotItemUnhovered(int)));
- connect(controller, SIGNAL(itemDropEvent(int,QGraphicsSceneDragDropEvent*)), this, SLOT(slotItemDropEvent(int,QGraphicsSceneDragDropEvent*)));
- connect(controller, SIGNAL(escapePressed()), this, SLOT(stopLoading()));
- connect(controller, SIGNAL(modelChanged(KItemModelBase*,KItemModelBase*)), this, SLOT(slotModelChanged(KItemModelBase*,KItemModelBase*)));
+ connect(controller, &KItemListController::itemActivated, this, &DolphinView::slotItemActivated);
+ connect(controller, &KItemListController::itemsActivated, this, &DolphinView::slotItemsActivated);
+ connect(controller, &KItemListController::itemMiddleClicked, this, &DolphinView::slotItemMiddleClicked);
+ connect(controller, &KItemListController::itemContextMenuRequested, this, &DolphinView::slotItemContextMenuRequested);
+ connect(controller, &KItemListController::viewContextMenuRequested, this, &DolphinView::slotViewContextMenuRequested);
+ connect(controller, &KItemListController::headerContextMenuRequested, this, &DolphinView::slotHeaderContextMenuRequested);
+ connect(controller, &KItemListController::mouseButtonPressed, this, &DolphinView::slotMouseButtonPressed);
+ connect(controller, &KItemListController::itemHovered, this, &DolphinView::slotItemHovered);
+ connect(controller, &KItemListController::itemUnhovered, this, &DolphinView::slotItemUnhovered);
+ connect(controller, &KItemListController::itemDropEvent, this, &DolphinView::slotItemDropEvent);
+ connect(controller, &KItemListController::escapePressed, this, &DolphinView::stopLoading);
+ connect(controller, &KItemListController::modelChanged, this, &DolphinView::slotModelChanged);
- connect(m_model, SIGNAL(directoryLoadingStarted()), this, SLOT(slotDirectoryLoadingStarted()));
- connect(m_model, SIGNAL(directoryLoadingCompleted()), this, SLOT(slotDirectoryLoadingCompleted()));
- connect(m_model, SIGNAL(directoryLoadingCanceled()), this, SIGNAL(directoryLoadingCanceled()));
- connect(m_model, SIGNAL(directoryLoadingProgress(int)), this, SIGNAL(directoryLoadingProgress(int)));
- connect(m_model, SIGNAL(directorySortingProgress(int)), this, SIGNAL(directorySortingProgress(int)));
- connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
- this, SLOT(slotItemsChanged()));
- connect(m_model, SIGNAL(itemsRemoved(KItemRangeList)), this, SIGNAL(itemCountChanged()));
- connect(m_model, SIGNAL(itemsInserted(KItemRangeList)), this, SIGNAL(itemCountChanged()));
- connect(m_model, SIGNAL(infoMessage(QString)), this, SIGNAL(infoMessage(QString)));
- connect(m_model, SIGNAL(errorMessage(QString)), this, SIGNAL(errorMessage(QString)));
- connect(m_model, SIGNAL(directoryRedirection(KUrl,KUrl)), this, SLOT(slotDirectoryRedirection(KUrl,KUrl)));
- connect(m_model, SIGNAL(urlIsFileError(KUrl)), this, SIGNAL(urlIsFileError(KUrl)));
+ connect(m_model, &KFileItemModel::directoryLoadingStarted, this, &DolphinView::slotDirectoryLoadingStarted);
+ connect(m_model, &KFileItemModel::directoryLoadingCompleted, this, &DolphinView::slotDirectoryLoadingCompleted);
+ connect(m_model, &KFileItemModel::directoryLoadingCanceled, this, &DolphinView::directoryLoadingCanceled);
+ connect(m_model, &KFileItemModel::directoryLoadingProgress, this, &DolphinView::directoryLoadingProgress);
+ connect(m_model, &KFileItemModel::directorySortingProgress, this, &DolphinView::directorySortingProgress);
+ connect(m_model, &KFileItemModel::itemsChanged,
+ this, &DolphinView::slotItemsChanged);
+ connect(m_model, &KFileItemModel::itemsRemoved, this, &DolphinView::itemCountChanged);
+ connect(m_model, &KFileItemModel::itemsInserted, this, &DolphinView::itemCountChanged);
+ connect(m_model, &KFileItemModel::infoMessage, this, &DolphinView::infoMessage);
+ connect(m_model, &KFileItemModel::errorMessage, this, &DolphinView::errorMessage);
+ connect(m_model, &KFileItemModel::directoryRedirection, this, &DolphinView::slotDirectoryRedirection);
+ connect(m_model, &KFileItemModel::urlIsFileError, this, &DolphinView::urlIsFileError);
m_view->installEventFilter(this);
- connect(m_view, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder)),
- this, SLOT(slotSortOrderChangedByHeader(Qt::SortOrder,Qt::SortOrder)));
- connect(m_view, SIGNAL(sortRoleChanged(QByteArray,QByteArray)),
- this, SLOT(slotSortRoleChangedByHeader(QByteArray,QByteArray)));
- connect(m_view, SIGNAL(visibleRolesChanged(QList<QByteArray>,QList<QByteArray>)),
- this, SLOT(slotVisibleRolesChangedByHeader(QList<QByteArray>,QList<QByteArray>)));
- connect(m_view, SIGNAL(roleEditingCanceled(int,QByteArray,QVariant)),
- this, SLOT(slotRoleEditingCanceled()));
- connect(m_view->header(), SIGNAL(columnWidthChanged(QByteArray,qreal,qreal)),
- this, SLOT(slotHeaderColumnWidthChanged(QByteArray,qreal,qreal)));
+ connect(m_view, &DolphinItemListView::sortOrderChanged,
+ this, &DolphinView::slotSortOrderChangedByHeader);
+ connect(m_view, &DolphinItemListView::sortRoleChanged,
+ this, &DolphinView::slotSortRoleChangedByHeader);
+ connect(m_view, &DolphinItemListView::visibleRolesChanged,
+ this, &DolphinView::slotVisibleRolesChangedByHeader);
+ connect(m_view, &DolphinItemListView::roleEditingCanceled,
+ this, &DolphinView::slotRoleEditingCanceled);
+ connect(m_view->header(), &KItemListHeader::columnWidthChanged,
+ this, &DolphinView::slotHeaderColumnWidthChanged);
KItemListSelectionManager* selectionManager = controller->selectionManager();
- connect(selectionManager, SIGNAL(selectionChanged(KItemSet,KItemSet)),
- this, SLOT(slotSelectionChanged(KItemSet,KItemSet)));
+ connect(selectionManager, &KItemListSelectionManager::selectionChanged,
+ this, &DolphinView::slotSelectionChanged);
m_toolTipManager = new ToolTipManager(this);
m_versionControlObserver = new VersionControlObserver(this);
m_versionControlObserver->setModel(m_model);
- connect(m_versionControlObserver, SIGNAL(infoMessage(QString)), this, SIGNAL(infoMessage(QString)));
- connect(m_versionControlObserver, SIGNAL(errorMessage(QString)), this, SIGNAL(errorMessage(QString)));
- connect(m_versionControlObserver, SIGNAL(operationCompletedMessage(QString)), this, SIGNAL(operationCompletedMessage(QString)));
+ connect(m_versionControlObserver, &VersionControlObserver::infoMessage, this, &DolphinView::infoMessage);
+ connect(m_versionControlObserver, &VersionControlObserver::errorMessage, this, &DolphinView::errorMessage);
+ connect(m_versionControlObserver, &VersionControlObserver::operationCompletedMessage, this, &DolphinView::operationCompletedMessage);
applyViewProperties();
m_topLayout->addWidget(m_container);
@@ -205,7 +203,7 @@ DolphinView::~DolphinView()
{
}
-KUrl DolphinView::url() const
+QUrl DolphinView::url() const
{
return m_url;
}
@@ -364,12 +362,12 @@ int DolphinView::selectedItemsCount() const
return selectionManager->selectedItems().count();
}
-void DolphinView::markUrlsAsSelected(const QList<KUrl>& urls)
+void DolphinView::markUrlsAsSelected(const QList<QUrl>& urls)
{
m_selectedUrls = urls;
}
-void DolphinView::markUrlAsCurrent(const KUrl& url)
+void DolphinView::markUrlAsCurrent(const QUrl &url)
{
m_currentItemUrl = url;
m_scrollToCurrentItem = true;
@@ -485,7 +483,7 @@ void DolphinView::readSettings()
{
const int oldZoomLevel = m_view->zoomLevel();
- GeneralSettings::self()->readConfig();
+ GeneralSettings::self()->load();
m_view->readSettings();
applyViewProperties();
@@ -500,7 +498,7 @@ void DolphinView::readSettings()
void DolphinView::writeSettings()
{
- GeneralSettings::self()->writeConfig();
+ GeneralSettings::self()->save();
m_view->writeSettings();
}
@@ -563,11 +561,11 @@ QString DolphinView::statusBarText() const
if (fileCount > 0 && folderCount > 0) {
summary = i18nc("@info:status folders, files (size)", "%1, %2 (%3)",
foldersText, filesText,
- KGlobal::locale()->formatByteSize(totalFileSize));
+ KFormat().formatByteSize(totalFileSize));
} else if (fileCount > 0) {
summary = i18nc("@info:status files (size)", "%1 (%2)",
filesText,
- KGlobal::locale()->formatByteSize(totalFileSize));
+ KFormat().formatByteSize(totalFileSize));
} else if (folderCount > 0) {
summary = foldersText;
} else {
@@ -593,7 +591,7 @@ QList<QAction*> DolphinView::versionControlActions(const KFileItemList& items) c
return actions;
}
-void DolphinView::setUrl(const KUrl& url)
+void DolphinView::setUrl(const QUrl& url)
{
if (url == m_url) {
return;
@@ -606,8 +604,8 @@ void DolphinView::setUrl(const KUrl& url)
hideToolTip();
- disconnect(m_view, SIGNAL(roleEditingFinished(int,QByteArray,QVariant)),
- this, SLOT(slotRoleEditingFinished(int,QByteArray,QVariant)));
+ disconnect(m_view, &DolphinItemListView::roleEditingFinished,
+ this, &DolphinView::slotRoleEditingFinished);
// It is important to clear the items from the model before
// applying the view properties, otherwise expensive operations
@@ -651,8 +649,8 @@ void DolphinView::renameSelectedItems()
hideToolTip();
- connect(m_view, SIGNAL(roleEditingFinished(int,QByteArray,QVariant)),
- this, SLOT(slotRoleEditingFinished(int,QByteArray,QVariant)));
+ connect(m_view, &DolphinItemListView::roleEditingFinished,
+ this, &DolphinView::slotRoleEditingFinished);
} else {
RenameDialog* dialog = new RenameDialog(this, items);
dialog->setAttribute(Qt::WA_DeleteOnClose);
@@ -669,32 +667,36 @@ void DolphinView::renameSelectedItems()
void DolphinView::trashSelectedItems()
{
- const KUrl::List list = simplifiedSelectedUrls();
- KonqOperations::del(this, KonqOperations::TRASH, list);
+ const QList<QUrl> list = simplifiedSelectedUrls();
+ KIO::JobUiDelegate uiDelegate;
+ uiDelegate.setWindow(window());
+ if (uiDelegate.askDeleteConfirmation(list, KIO::JobUiDelegate::Trash, KIO::JobUiDelegate::DefaultConfirmation)) {
+ KIO::Job* job = KIO::trash(list);
+ KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Trash, list, QUrl("trash:/"), job);
+ KJobWidgets::setWindow(job, this);
+ connect(job, &KIO::Job::result,
+ this, &DolphinView::slotTrashFileFinished);
+ }
}
void DolphinView::deleteSelectedItems()
{
- const KUrl::List list = simplifiedSelectedUrls();
- const bool del = KonqOperations::askDeleteConfirmation(list,
- KonqOperations::DEL,
- KonqOperations::DEFAULT_CONFIRMATION,
- this);
+ const QList<QUrl> list = simplifiedSelectedUrls();
- if (del) {
+ KIO::JobUiDelegate uiDelegate;
+ uiDelegate.setWindow(window());
+ if (uiDelegate.askDeleteConfirmation(list, KIO::JobUiDelegate::Delete, KIO::JobUiDelegate::DefaultConfirmation)) {
KIO::Job* job = KIO::del(list);
- if (job->ui()) {
- job->ui()->setWindow(this);
- }
- connect(job, SIGNAL(result(KJob*)),
- this, SLOT(slotDeleteFileFinished(KJob*)));
+ KJobWidgets::setWindow(job, this);
+ connect(job, &KIO::Job::result,
+ this, &DolphinView::slotDeleteFileFinished);
}
}
void DolphinView::cutSelectedItems()
{
QMimeData* mimeData = selectionMimeData();
- KonqMimeData::addIsCutSelection(mimeData, true);
+ KIO::setClipboardDataCut(mimeData, true);
QApplication::clipboard()->setMimeData(mimeData);
}
@@ -817,7 +819,7 @@ void DolphinView::slotItemsActivated(const KItemSet& indexes)
foreach (int index, indexes) {
KFileItem item = m_model->fileItem(index);
- const KUrl& url = openItemAsFolderUrl(item);
+ const QUrl& url = openItemAsFolderUrl(item);
if (!url.isEmpty()) { // Open folders in new tabs
emit tabRequested(url);
@@ -836,7 +838,7 @@ void DolphinView::slotItemsActivated(const KItemSet& indexes)
void DolphinView::slotItemMiddleClicked(int index)
{
const KFileItem& item = m_model->fileItem(index);
- const KUrl& url = openItemAsFolderUrl(item);
+ const QUrl& url = openItemAsFolderUrl(item);
if (!url.isEmpty()) {
emit tabRequested(url);
} else if (isTabsForFilesEnabled()) {
@@ -865,7 +867,7 @@ void DolphinView::slotHeaderContextMenuRequested(const QPointF& pos)
{
ViewProperties props(viewPropertiesUrl());
- QPointer<KMenu> menu = new KMenu(QApplication::activeWindow());
+ QPointer<QMenu> menu = new QMenu(QApplication::activeWindow());
KItemListView* view = m_container->controller()->view();
const QSet<QByteArray> visibleRolesSet = view->visibleRoles().toSet();
@@ -1019,7 +1021,7 @@ void DolphinView::slotItemUnhovered(int index)
void DolphinView::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event)
{
- KUrl destUrl;
+ QUrl destUrl;
KFileItem destItem = m_model->fileItem(index);
if (destItem.isNull() || (!destItem.isDir() && !destItem.isDesktopFile())) {
// Use the URL of the view as drop target if the item is no directory
@@ -1036,35 +1038,40 @@ void DolphinView::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* even
event->mimeData(),
event->buttons(),
event->modifiers());
+ dropUrls(destUrl, &dropEvent);
- QString error;
- KonqOperations* op = DragAndDropHelper::dropUrls(destItem, destUrl, &dropEvent, error);
- if (!error.isEmpty()) {
- emit infoMessage(error);
- }
+ setActive(true);
+}
- if (op && destUrl == url()) {
- // Mark the dropped urls as selected.
- m_clearSelectionBeforeSelectingNewItems = true;
- m_markFirstNewlySelectedItemAsCurrent = true;
- connect(op, SIGNAL(aboutToCreate(KUrl::List)), this, SLOT(slotAboutToCreate(KUrl::List)));
- }
+void DolphinView::dropUrls(const QUrl &destUrl, QDropEvent *dropEvent)
+{
+ KIO::DropJob* job = DragAndDropHelper::dropUrls(destUrl, dropEvent, this);
- setActive(true);
+ if (job) {
+ connect(job, &KIO::DropJob::result, this, &DolphinView::slotPasteJobResult);
+
+ if (destUrl == url()) {
+ // Mark the dropped urls as selected.
+ m_clearSelectionBeforeSelectingNewItems = true;
+ m_markFirstNewlySelectedItemAsCurrent = true;
+ connect(job, &KIO::DropJob::itemCreated, this, &DolphinView::slotItemCreated);
+ }
+ }
}
void DolphinView::slotModelChanged(KItemModelBase* current, KItemModelBase* previous)
{
if (previous != 0) {
- disconnect(previous, SIGNAL(directoryLoadingCompleted()), this, SLOT(slotDirectoryLoadingCompleted()));
+ Q_ASSERT(qobject_cast<KFileItemModel*>(previous));
+ KFileItemModel* fileItemModel = static_cast<KFileItemModel*>(previous);
+ disconnect(fileItemModel, &KFileItemModel::directoryLoadingCompleted, this, &DolphinView::slotDirectoryLoadingCompleted);
m_versionControlObserver->setModel(0);
}
if (current) {
Q_ASSERT(qobject_cast<KFileItemModel*>(current));
- connect(current, SIGNAL(loadingCompleted()), this, SLOT(slotDirectoryLoadingCompleted()));
-
KFileItemModel* fileItemModel = static_cast<KFileItemModel*>(current);
+ connect(fileItemModel, &KFileItemModel::directoryLoadingCompleted, this, &DolphinView::slotDirectoryLoadingCompleted);
m_versionControlObserver->setModel(fileItemModel);
}
}
@@ -1075,22 +1082,29 @@ void DolphinView::slotMouseButtonPressed(int itemIndex, Qt::MouseButtons buttons
hideToolTip();
- // TODO: Qt5: Replace Qt::XButton1 by Qt::BackButton and Qt::XButton2 by Qt::ForwardButton
- if (buttons & Qt::XButton1) {
+ if (buttons & Qt::BackButton) {
emit goBackRequested();
- } else if (buttons & Qt::XButton2) {
+ } else if (buttons & Qt::ForwardButton) {
emit goForwardRequested();
}
}
-void DolphinView::slotAboutToCreate(const KUrl::List& urls)
+void DolphinView::slotItemCreated(const QUrl& url)
{
- if (!urls.isEmpty()) {
- if (m_markFirstNewlySelectedItemAsCurrent) {
- markUrlAsCurrent(urls.first());
- m_markFirstNewlySelectedItemAsCurrent = false;
- }
- m_selectedUrls << KDirModel::simplifiedUrlList(urls);
+ if (m_markFirstNewlySelectedItemAsCurrent) {
+ markUrlAsCurrent(url);
+ m_markFirstNewlySelectedItemAsCurrent = false;
+ }
+ m_selectedUrls << url;
+}
+
+void DolphinView::slotPasteJobResult(KJob *job)
+{
+ if (job->error()) {
+ emit errorMessage(job->errorString());
+ }
+ if (!m_selectedUrls.isEmpty()) {
+ m_selectedUrls << KDirModel::simplifiedUrlList(m_selectedUrls);
}
}
@@ -1147,7 +1161,10 @@ void DolphinView::updateSortFoldersFirst(bool foldersFirst)
QPair<bool, QString> DolphinView::pasteInfo() const
{
- return KonqOperations::pasteInfo(url());
+ const QMimeData *mimeData = QApplication::clipboard()->mimeData();
+ QPair<bool, QString> info;
+ info.second = KIO::pasteActionText(mimeData, &info.first, rootItem());
+ return info;
}
void DolphinView::setTabsForFilesEnabled(bool tabsForFiles)
@@ -1182,7 +1199,7 @@ void DolphinView::restoreState(QDataStream& stream)
stream >> m_restoredContentsPosition;
// Restore expanded folders (only relevant for the details view - will be ignored by the view in other view modes)
- QSet<KUrl> urls;
+ QSet<QUrl> urls;
stream >> urls;
m_model->restoreExpandedDirectories(urls);
}
@@ -1196,10 +1213,10 @@ void DolphinView::saveState(QDataStream& stream)
if (currentIndex != -1) {
KFileItem item = m_model->fileItem(currentIndex);
Q_ASSERT(!item.isNull()); // If the current index is valid a item must exist
- KUrl currentItemUrl = item.url();
+ QUrl currentItemUrl = item.url();
stream << currentItemUrl;
} else {
- stream << KUrl();
+ stream << QUrl();
}
// Save view position
@@ -1226,13 +1243,13 @@ QString DolphinView::viewPropertiesContext() const
return m_viewPropertiesContext;
}
-KUrl DolphinView::openItemAsFolderUrl(const KFileItem& item, const bool browseThroughArchives)
+QUrl DolphinView::openItemAsFolderUrl(const KFileItem& item, const bool browseThroughArchives)
{
if (item.isNull()) {
- return KUrl();
+ return QUrl();
}
- KUrl url = item.targetUrl();
+ QUrl url = item.targetUrl();
if (item.isDir()) {
return url;
@@ -1249,7 +1266,7 @@ KUrl DolphinView::openItemAsFolderUrl(const KFileItem& item, const bool browseTh
// open OpenDocument files as zip folders...
const QString& protocol = KProtocolManager::protocolForArchiveMimetype(mimetype);
if (!protocol.isEmpty()) {
- url.setProtocol(protocol);
+ url.setScheme(protocol);
return url;
}
}
@@ -1266,21 +1283,21 @@ KUrl DolphinView::openItemAsFolderUrl(const KFileItem& item, const bool browseTh
}
}
- return KUrl();
+ return QUrl();
}
-void DolphinView::observeCreatedItem(const KUrl& url)
+void DolphinView::observeCreatedItem(const QUrl& url)
{
if (m_active) {
clearSelection();
markUrlAsCurrent(url);
- markUrlsAsSelected(QList<KUrl>() << url);
+ markUrlsAsSelected({url});
}
}
-void DolphinView::slotDirectoryRedirection(const KUrl& oldUrl, const KUrl& newUrl)
+void DolphinView::slotDirectoryRedirection(const QUrl& oldUrl, const QUrl& newUrl)
{
- if (oldUrl.equals(url(), KUrl::CompareWithoutTrailingSlash)) {
+ if (oldUrl.matches(url(), QUrl::StripTrailingSlash)) {
emit redirection(oldUrl, newUrl);
m_url = newUrl; // #186947
}
@@ -1288,7 +1305,7 @@ void DolphinView::slotDirectoryRedirection(const KUrl& oldUrl, const KUrl& newUr
void DolphinView::updateViewState()
{
- if (m_currentItemUrl != KUrl()) {
+ if (m_currentItemUrl != QUrl()) {
KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager();
const int currentIndex = m_model->index(m_currentItemUrl);
if (currentIndex != -1) {
@@ -1303,7 +1320,7 @@ void DolphinView::updateViewState()
selectionManager->setCurrentItem(0);
}
- m_currentItemUrl = KUrl();
+ m_currentItemUrl = QUrl();
}
if (!m_restoredContentsPosition.isNull()) {
@@ -1325,7 +1342,7 @@ void DolphinView::updateViewState()
KItemSet selectedItems = selectionManager->selectedItems();
- QList<KUrl>::iterator it = m_selectedUrls.begin();
+ QList<QUrl>::iterator it = m_selectedUrls.begin();
while (it != m_selectedUrls.end()) {
const int index = m_model->index(*it);
if (index >= 0) {
@@ -1363,6 +1380,15 @@ void DolphinView::calculateItemCount(int& fileCount,
}
}
+void DolphinView::slotTrashFileFinished(KJob* job)
+{
+ if (job->error() == 0) {
+ emit operationCompletedMessage(i18nc("@info:status", "Trash operation completed."));
+ } else if (job->error() != KIO::ERR_USER_CANCELED) {
+ emit errorMessage(job->errorString());
+ }
+}
+
void DolphinView::slotDeleteFileFinished(KJob* job)
{
if (job->error() == 0) {
@@ -1372,13 +1398,19 @@ void DolphinView::slotDeleteFileFinished(KJob* job)
}
}
-void DolphinView::slotRenamingFailed(const KUrl& oldUrl, const KUrl& newUrl)
+void DolphinView::slotRenamingResult(KJob* job)
{
- const int index = m_model->index(newUrl);
- if (index >= 0) {
- QHash<QByteArray, QVariant> data;
- data.insert("text", oldUrl.fileName());
- m_model->setData(index, data);
+ if (job->error()) {
+ KIO::CopyJob *copyJob = qobject_cast<KIO::CopyJob *>(job);
+ Q_ASSERT(copyJob);
+ const QUrl newUrl = copyJob->destUrl();
+ const int index = m_model->index(newUrl);
+ if (index >= 0) {
+ QHash<QByteArray, QVariant> data;
+ const QUrl oldUrl = copyJob->srcUrls().first();
+ data.insert("text", oldUrl.fileName());
+ m_model->setData(index, data);
+ }
}
}
@@ -1450,14 +1482,14 @@ void DolphinView::slotVisibleRolesChangedByHeader(const QList<QByteArray>& curre
void DolphinView::slotRoleEditingCanceled()
{
- disconnect(m_view, SIGNAL(roleEditingFinished(int,QByteArray,QVariant)),
- this, SLOT(slotRoleEditingFinished(int,QByteArray,QVariant)));
+ disconnect(m_view, &DolphinItemListView::roleEditingFinished,
+ this, &DolphinView::slotRoleEditingFinished);
}
void DolphinView::slotRoleEditingFinished(int index, const QByteArray& role, const QVariant& value)
{
- disconnect(m_view, SIGNAL(roleEditingFinished(int,QByteArray,QVariant)),
- this, SLOT(slotRoleEditingFinished(int,QByteArray,QVariant)));
+ disconnect(m_view, &DolphinItemListView::roleEditingFinished,
+ this, &DolphinView::slotRoleEditingFinished);
if (index < 0 || index >= m_model->count()) {
return;
@@ -1467,14 +1499,16 @@ void DolphinView::slotRoleEditingFinished(int index, const QByteArray& role, con
const KFileItem oldItem = m_model->fileItem(index);
const QString newName = value.toString();
if (!newName.isEmpty() && newName != oldItem.text() && newName != QLatin1String(".") && newName != QLatin1String("..")) {
- const KUrl oldUrl = oldItem.url();
+ const QUrl oldUrl = oldItem.url();
+
+ QUrl newUrl = oldUrl.adjusted(QUrl::RemoveFilename);
+ newUrl.setPath(newUrl.path() + KIO::encodeFileName(newName));
- const KUrl newUrl(url().path(KUrl::AddTrailingSlash) + newName);
const bool newNameExistsAlready = (m_model->index(newUrl) >= 0);
if (!newNameExistsAlready) {
// Only change the data in the model if no item with the new name
// is in the model yet. If there is an item with the new name
- // already, calling KonqOperations::rename() will open a dialog
+ // already, calling KIO::CopyJob will open a dialog
// asking for a new name, and KFileItemModel will update the
// data when the dir lister signals that the file name has changed.
QHash<QByteArray, QVariant> data;
@@ -1482,20 +1516,24 @@ void DolphinView::slotRoleEditingFinished(int index, const QByteArray& role, con
m_model->setData(index, data);
}
- KonqOperations* op = KonqOperations::renameV2(this, oldUrl, newName);
- if (op && !newNameExistsAlready) {
- // Only connect the renamingFailed signal if there is no item with the new name
+ KIO::Job * job = KIO::moveAs(oldUrl, newUrl);
+ KJobWidgets::setWindow(job, this);
+ KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Rename, {oldUrl}, newUrl, job);
+ job->ui()->setAutoErrorHandlingEnabled(true);
+
+ if (!newNameExistsAlready) {
+ // Only connect the result signal if there is no item with the new name
// in the model yet, see bug 328262.
- connect(op, SIGNAL(renamingFailed(KUrl,KUrl)), SLOT(slotRenamingFailed(KUrl,KUrl)));
+ connect(job, &KJob::result, this, &DolphinView::slotRenamingResult);
}
}
}
}
-void DolphinView::loadDirectory(const KUrl& url, bool reload)
+void DolphinView::loadDirectory(const QUrl& url, bool reload)
{
if (!url.isValid()) {
- const QString location(url.pathOrUrl());
+ const QString location(url.toDisplayString(QUrl::PreferLocalFile));
if (location.isEmpty()) {
emit errorMessage(i18nc("@info:status", "The location is empty."));
} else {
@@ -1621,19 +1659,19 @@ void DolphinView::applyModeToView()
}
}
-void DolphinView::pasteToUrl(const KUrl& url)
+void DolphinView::pasteToUrl(const QUrl& url)
{
- KonqOperations* op = KonqOperations::doPasteV2(this, url);
- if (op) {
- m_clearSelectionBeforeSelectingNewItems = true;
- m_markFirstNewlySelectedItemAsCurrent = true;
- connect(op, SIGNAL(aboutToCreate(KUrl::List)), this, SLOT(slotAboutToCreate(KUrl::List)));
- }
+ KIO::PasteJob *job = KIO::paste(QApplication::clipboard()->mimeData(), url);
+ KJobWidgets::setWindow(job, this);
+ m_clearSelectionBeforeSelectingNewItems = true;
+ m_markFirstNewlySelectedItemAsCurrent = true;
+ connect(job, &KIO::PasteJob::itemCreated, this, &DolphinView::slotItemCreated);
+ connect(job, &KIO::PasteJob::result, this, &DolphinView::slotPasteJobResult);
}
-KUrl::List DolphinView::simplifiedSelectedUrls() const
+QList<QUrl> DolphinView::simplifiedSelectedUrls() const
{
- KUrl::List urls;
+ QList<QUrl> urls;
const KFileItemList items = selectedItems();
foreach (const KFileItem& item, items) {
@@ -1665,7 +1703,8 @@ void DolphinView::updateWritableState()
if (item.isNull()) {
// Try to find out if the URL is writable even if the "root item" is
// null, see https://bugs.kde.org/show_bug.cgi?id=330001
- item = KFileItem(KFileItem::Unknown, KFileItem::Unknown, url(), true);
+ item = KFileItem(url());
+ item.setDelayedMimeTypes(true);
}
KFileItemListProperties capabilities(KFileItemList() << item);
@@ -1676,16 +1715,14 @@ void DolphinView::updateWritableState()
}
}
-KUrl DolphinView::viewPropertiesUrl() const
+QUrl DolphinView::viewPropertiesUrl() const
{
if (m_viewPropertiesContext.isEmpty()) {
return m_url;
}
- KUrl url;
- url.setProtocol(m_url.protocol());
+ QUrl url;
+ url.setScheme(m_url.scheme());
url.setPath(m_viewPropertiesContext);
return url;
}
-
-#include "dolphinview.moc"
diff --git a/src/views/dolphinview.h b/src/views/dolphinview.h
index 06c09edc3..24b560f10 100644
--- a/src/views/dolphinview.h
+++ b/src/views/dolphinview.h
@@ -23,29 +23,23 @@
#include <config-baloo.h>
-#include "libdolphin_export.h"
+#include "dolphin_export.h"
#include <kparts/part.h>
#include <KFileItem>
-#include <KFileItemDelegate>
#include <kio/fileundomanager.h>
#include <KIO/Job>
-
-#include <QBoxLayout>
-#include <QKeyEvent>
-#include <QLinkedList>
+#include <QUrl>
+#include <QMimeData>
#include <QWidget>
typedef KIO::FileUndoManager::CommandType CommandType;
-
+class QVBoxLayout;
class DolphinItemListView;
-class KAction;
-class KActionCollection;
class KFileItemModel;
class KItemListContainer;
class KItemModelBase;
class KItemSet;
-class KUrl;
class ToolTipManager;
class VersionControlObserver;
class ViewProperties;
@@ -63,7 +57,7 @@ class QRegExp;
* - show previews
* - enable grouping
*/
-class LIBDOLPHINPRIVATE_EXPORT DolphinView : public QWidget
+class DOLPHIN_EXPORT DolphinView : public QWidget
{
Q_OBJECT
@@ -97,7 +91,7 @@ public:
* @param url Specifies the content which should be shown.
* @param parent Parent widget of the view.
*/
- DolphinView(const KUrl& url, QWidget* parent);
+ DolphinView(const QUrl& url, QWidget* parent);
virtual ~DolphinView();
@@ -105,7 +99,7 @@ public:
* Returns the current active URL, where all actions are applied.
* The URL navigator is synchronized with this URL.
*/
- KUrl url() const;
+ QUrl url() const;
/**
* If \a active is true, the view will marked as active. The active
@@ -178,13 +172,13 @@ public:
* gets selected if no loading of a directory has been triggered
* by DolphinView::setUrl() or DolphinView::reload().
*/
- void markUrlsAsSelected(const QList<KUrl>& urls);
+ void markUrlsAsSelected(const QList<QUrl> &urls);
/**
* Marks the item indicated by \p url to be scrolled to and as the
* current item after directory DolphinView::url() has been loaded.
*/
- void markUrlAsCurrent(const KUrl& url);
+ void markUrlAsCurrent(const QUrl& url);
/**
* All items that match to the pattern \a pattern will get selected
@@ -309,14 +303,14 @@ public:
* @return a valid and adjusted url if the item can be opened as folder,
* otherwise return an empty url.
*/
- static KUrl openItemAsFolderUrl(const KFileItem& item, const bool browseThroughArchives = true);
+ static QUrl openItemAsFolderUrl(const KFileItem& item, const bool browseThroughArchives = true);
public slots:
/**
* Changes the directory to \a url. If the current directory is equal to
* \a url, nothing will be done (use DolphinView::reload() instead).
*/
- void setUrl(const KUrl& url);
+ void setUrl(const QUrl& url);
/**
* Selects all items.
@@ -368,10 +362,15 @@ public slots:
*/
void pasteIntoFolder();
+ /**
+ * Handles a drop of @p dropEvent onto @p destUrl
+ */
+ void dropUrls(const QUrl &destUrl, QDropEvent *dropEvent);
+
void stopLoading();
/** Activates the view if the item list container gets focus. */
- virtual bool eventFilter(QObject* watched, QEvent* event);
+ virtual bool eventFilter(QObject* watched, QEvent* event) Q_DECL_OVERRIDE;
signals:
/**
@@ -384,10 +383,10 @@ signals:
* After the URL has been changed the signal urlChanged() will
* be emitted.
*/
- void urlAboutToBeChanged(const KUrl& url);
+ void urlAboutToBeChanged(const QUrl& url);
/** Is emitted if the URL of the view has been changed to \a url. */
- void urlChanged(const KUrl& url);
+ void urlChanged(const QUrl& url);
/**
* Is emitted when clicking on an item with the left mouse button.
@@ -408,7 +407,7 @@ signals:
/**
* Is emitted if a new tab should be opened for the URL \a url.
*/
- void tabRequested(const KUrl& url);
+ void tabRequested(const QUrl& url);
/**
* Is emitted if the view mode (IconsView, DetailsView,
@@ -463,7 +462,7 @@ signals:
*/
void requestContextMenu(const QPoint& pos,
const KFileItem& item,
- const KUrl& url,
+ const QUrl& url,
const QList<QAction*>& customActions);
/**
@@ -520,13 +519,13 @@ signals:
* Emitted when the file-item-model emits redirection.
* Testcase: fish://localhost
*/
- void redirection(const KUrl& oldUrl, const KUrl& newUrl);
+ void redirection(const QUrl& oldUrl, const QUrl& newUrl);
/**
* Is emitted when the URL set by DolphinView::setUrl() represents a file.
* In this case no signal errorMessage() will be emitted.
*/
- void urlIsFileError(const KUrl& url);
+ void urlIsFileError(const QUrl& url);
/**
* Is emitted when the write state of the folder has been changed. The application
@@ -549,11 +548,10 @@ signals:
protected:
/** Changes the zoom level if Control is pressed during a wheel event. */
- virtual void wheelEvent(QWheelEvent* event);
+ virtual void wheelEvent(QWheelEvent* event) Q_DECL_OVERRIDE;
- /** @reimp */
- virtual void hideEvent(QHideEvent* event);
- virtual bool event(QEvent* event);
+ virtual void hideEvent(QHideEvent* event) Q_DECL_OVERRIDE;
+ virtual bool event(QEvent* event) Q_DECL_OVERRIDE;
private slots:
/**
@@ -578,7 +576,11 @@ private slots:
/*
* Is called when new items get pasted or dropped.
*/
- void slotAboutToCreate(const KUrl::List& urls);
+ void slotItemCreated(const QUrl &url);
+ /*
+ * Is called after all pasted or dropped items have been copied to destination.
+ */
+ void slotPasteJobResult(KJob *job);
/**
* Emits the signal \a selectionChanged() with a small delay. This is
@@ -619,7 +621,16 @@ private slots:
*/
void slotDeleteFileFinished(KJob* job);
- void slotRenamingFailed(const KUrl& oldUrl, const KUrl& newUrl);
+ /**
+ * Indicates in the status bar that the trash operation
+ * of the job \a job has been finished.
+ */
+ void slotTrashFileFinished(KJob* job);
+
+ /**
+ * Invoked when the rename job is done, for error handling.
+ */
+ void slotRenamingResult(KJob* job);
/**
* Invoked when the file item model has started the loading
@@ -665,13 +676,13 @@ private slots:
* model indicates that the item is available, the item will
* get selected and it is assured that the item stays visible.
*/
- void observeCreatedItem(const KUrl& url);
+ void observeCreatedItem(const QUrl &url);
/**
* Called when a redirection happens.
* Testcase: fish://localhost
*/
- void slotDirectoryRedirection(const KUrl& oldUrl, const KUrl& newUrl);
+ void slotDirectoryRedirection(const QUrl& oldUrl, const QUrl& newUrl);
/**
* Applies the state that has been restored by restoreViewState()
@@ -692,7 +703,7 @@ private slots:
void calculateItemCount(int& fileCount, int& folderCount, KIO::filesize_t& totalFileSize) const;
private:
- void loadDirectory(const KUrl& url, bool reload = false);
+ void loadDirectory(const QUrl& url, bool reload = false);
/**
* Applies the view properties which are defined by the current URL
@@ -717,14 +728,14 @@ private:
* Helper method for DolphinView::paste() and DolphinView::pasteIntoFolder().
* Pastes the clipboard data into the URL \a url.
*/
- void pasteToUrl(const KUrl& url);
+ void pasteToUrl(const QUrl& url);
/**
* Returns a list of URLs for all selected items. The list is
* simplified, so that when the URLs are part of different tree
* levels, only the parent is returned.
*/
- KUrl::List simplifiedSelectedUrls() const;
+ QList<QUrl> simplifiedSelectedUrls() const;
/**
* Returns the MIME data for all selected items.
@@ -743,7 +754,7 @@ private:
* DolphinView::viewPropertiesContext(), otherwise the context
* is returned.
*/
- KUrl viewPropertiesUrl() const;
+ QUrl viewPropertiesUrl() const;
private:
bool m_active;
@@ -753,7 +764,7 @@ private:
bool m_dragging; // True if a dragging is done. Required to be able to decide whether a
// tooltip may be shown when hovering an item.
- KUrl m_url;
+ QUrl m_url;
QString m_viewPropertiesContext;
Mode m_mode;
QList<QByteArray> m_visibleRoles;
@@ -768,11 +779,11 @@ private:
QTimer* m_selectionChangedTimer;
- KUrl m_currentItemUrl; // Used for making the view to remember the current URL after F5
+ QUrl m_currentItemUrl; // Used for making the view to remember the current URL after F5
bool m_scrollToCurrentItem; // Used for marking we need to scroll to current item or not
QPoint m_restoredContentsPosition;
- QList<KUrl> m_selectedUrls; // Used for making the view to remember selections after F5
+ QList<QUrl> m_selectedUrls; // Used for making the view to remember selections after F5
bool m_clearSelectionBeforeSelectingNewItems;
bool m_markFirstNewlySelectedItemAsCurrent;
diff --git a/src/views/dolphinviewactionhandler.cpp b/src/views/dolphinviewactionhandler.cpp
index 48ec95c70..ac538a648 100644
--- a/src/views/dolphinviewactionhandler.cpp
+++ b/src/views/dolphinviewactionhandler.cpp
@@ -25,24 +25,24 @@
#include "settings/viewpropertiesdialog.h"
#include "views/dolphinview.h"
#include "views/zoomlevelinfo.h"
-#include <konq_operations.h>
-#include <KAction>
+#include <QPointer>
+#include <QMenu>
+
#include <KActionCollection>
#include <KActionMenu>
#include <kitemviews/kfileitemmodel.h>
-#include <KLocale>
-#include <KMenu>
+#include <KLocalizedString>
#include <KNewFileMenu>
#include <KSelectAction>
#include <KToggleAction>
#include <KPropertiesDialog>
-#include <KIcon>
+#include <QIcon>
-#include <KDebug>
+#include "dolphindebug.h"
#ifdef HAVE_BALOO
- #include <baloo/indexerconfig.h>
+ #include <Baloo/IndexerConfig>
#endif
DolphinViewActionHandler::DolphinViewActionHandler(KActionCollection* collection, QObject* parent) :
@@ -66,26 +66,26 @@ void DolphinViewActionHandler::setCurrentView(DolphinView* view)
m_currentView = view;
- connect(view, SIGNAL(modeChanged(DolphinView::Mode,DolphinView::Mode)),
- this, SLOT(updateViewActions()));
- connect(view, SIGNAL(previewsShownChanged(bool)),
- this, SLOT(slotPreviewsShownChanged(bool)));
- connect(view, SIGNAL(sortOrderChanged(Qt::SortOrder)),
- this, SLOT(slotSortOrderChanged(Qt::SortOrder)));
- connect(view, SIGNAL(sortFoldersFirstChanged(bool)),
- this, SLOT(slotSortFoldersFirstChanged(bool)));
- connect(view, SIGNAL(visibleRolesChanged(QList<QByteArray>,QList<QByteArray>)),
- this, SLOT(slotVisibleRolesChanged(QList<QByteArray>,QList<QByteArray>)));
- connect(view, SIGNAL(groupedSortingChanged(bool)),
- this, SLOT(slotGroupedSortingChanged(bool)));
- connect(view, SIGNAL(hiddenFilesShownChanged(bool)),
- this, SLOT(slotHiddenFilesShownChanged(bool)));
- connect(view, SIGNAL(sortRoleChanged(QByteArray)),
- this, SLOT(slotSortRoleChanged(QByteArray)));
- connect(view, SIGNAL(zoomLevelChanged(int,int)),
- this, SLOT(slotZoomLevelChanged(int,int)));
- connect(view, SIGNAL(writeStateChanged(bool)),
- this, SLOT(slotWriteStateChanged(bool)));
+ connect(view, &DolphinView::modeChanged,
+ this, &DolphinViewActionHandler::updateViewActions);
+ connect(view, &DolphinView::previewsShownChanged,
+ this, &DolphinViewActionHandler::slotPreviewsShownChanged);
+ connect(view, &DolphinView::sortOrderChanged,
+ this, &DolphinViewActionHandler::slotSortOrderChanged);
+ connect(view, &DolphinView::sortFoldersFirstChanged,
+ this, &DolphinViewActionHandler::slotSortFoldersFirstChanged);
+ connect(view, &DolphinView::visibleRolesChanged,
+ this, &DolphinViewActionHandler::slotVisibleRolesChanged);
+ connect(view, &DolphinView::groupedSortingChanged,
+ this, &DolphinViewActionHandler::slotGroupedSortingChanged);
+ connect(view, &DolphinView::hiddenFilesShownChanged,
+ this, &DolphinViewActionHandler::slotHiddenFilesShownChanged);
+ connect(view, &DolphinView::sortRoleChanged,
+ this, &DolphinViewActionHandler::slotSortRoleChanged);
+ connect(view, &DolphinView::zoomLevelChanged,
+ this, &DolphinViewActionHandler::slotZoomLevelChanged);
+ connect(view, &DolphinView::writeStateChanged,
+ this, &DolphinViewActionHandler::slotWriteStateChanged);
}
DolphinView* DolphinViewActionHandler::currentView()
@@ -97,51 +97,51 @@ void DolphinViewActionHandler::createActions()
{
// This action doesn't appear in the GUI, it's for the shortcut only.
// KNewFileMenu takes care of the GUI stuff.
- KAction* newDirAction = m_actionCollection->addAction("create_dir");
+ QAction* newDirAction = m_actionCollection->addAction("create_dir");
newDirAction->setText(i18nc("@action", "Create Folder..."));
- newDirAction->setShortcut(Qt::Key_F10);
- newDirAction->setIcon(KIcon("folder-new"));
+ m_actionCollection->setDefaultShortcut(newDirAction, Qt::Key_F10);
+ newDirAction->setIcon(QIcon::fromTheme("folder-new"));
newDirAction->setEnabled(false); // Will be enabled in slotWriteStateChanged(bool) if the current URL is writable
- connect(newDirAction, SIGNAL(triggered()), this, SIGNAL(createDirectory()));
+ connect(newDirAction, &QAction::triggered, this, &DolphinViewActionHandler::createDirectory);
// File menu
- KAction* rename = m_actionCollection->addAction("rename");
+ QAction* rename = m_actionCollection->addAction("rename");
rename->setText(i18nc("@action:inmenu File", "Rename..."));
- rename->setShortcut(Qt::Key_F2);
- rename->setIcon(KIcon("edit-rename"));
- connect(rename, SIGNAL(triggered()), this, SLOT(slotRename()));
+ m_actionCollection->setDefaultShortcut(rename, Qt::Key_F2);
+ rename->setIcon(QIcon::fromTheme("edit-rename"));
+ connect(rename, &QAction::triggered, this, &DolphinViewActionHandler::slotRename);
- KAction* moveToTrash = m_actionCollection->addAction("move_to_trash");
+ QAction* moveToTrash = m_actionCollection->addAction("move_to_trash");
moveToTrash->setText(i18nc("@action:inmenu File", "Move to Trash"));
- moveToTrash->setIcon(KIcon("user-trash"));
- moveToTrash->setShortcut(QKeySequence::Delete);
- connect(moveToTrash, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)),
- this, SLOT(slotTrashActivated(Qt::MouseButtons,Qt::KeyboardModifiers)));
+ moveToTrash->setIcon(QIcon::fromTheme("user-trash"));
+ m_actionCollection->setDefaultShortcut(moveToTrash, QKeySequence::Delete);
+ connect(moveToTrash, &QAction::triggered,
+ this, &DolphinViewActionHandler::slotTrashActivated);
- KAction* deleteAction = m_actionCollection->addAction("delete");
- deleteAction->setIcon(KIcon("edit-delete"));
+ QAction* deleteAction = m_actionCollection->addAction("delete");
+ deleteAction->setIcon(QIcon::fromTheme("edit-delete"));
deleteAction->setText(i18nc("@action:inmenu File", "Delete"));
- deleteAction->setShortcut(Qt::SHIFT | Qt::Key_Delete);
- connect(deleteAction, SIGNAL(triggered()), this, SLOT(slotDeleteItems()));
+ m_actionCollection->setDefaultShortcut(deleteAction, Qt::SHIFT | Qt::Key_Delete);
+ connect(deleteAction, &QAction::triggered, this, &DolphinViewActionHandler::slotDeleteItems);
// This action is useful for being enabled when "move_to_trash" should be
// disabled and "delete" is enabled (e.g. non-local files), so that Key_Del
// can be used for deleting the file (#76016). It needs to be a separate action
// so that the Edit menu isn't affected.
- KAction* deleteWithTrashShortcut = m_actionCollection->addAction("delete_shortcut");
+ QAction* deleteWithTrashShortcut = m_actionCollection->addAction("delete_shortcut");
// The descriptive text is just for the shortcuts editor.
deleteWithTrashShortcut->setText(i18nc("@action \"Move to Trash\" for non-local files, etc.", "Delete (using shortcut for Trash)"));
- deleteWithTrashShortcut->setShortcut(QKeySequence::Delete);
+ m_actionCollection->setDefaultShortcut(deleteWithTrashShortcut, QKeySequence::Delete);
deleteWithTrashShortcut->setEnabled(false);
- connect(deleteWithTrashShortcut, SIGNAL(triggered()), this, SLOT(slotDeleteItems()));
+ connect(deleteWithTrashShortcut, &QAction::triggered, this, &DolphinViewActionHandler::slotDeleteItems);
- KAction *propertiesAction = m_actionCollection->addAction( "properties" );
+ QAction *propertiesAction = m_actionCollection->addAction( "properties" );
// Well, it's the File menu in dolphinmainwindow and the Edit menu in dolphinpart... :)
propertiesAction->setText( i18nc("@action:inmenu File", "Properties") );
- propertiesAction->setIcon(KIcon("document-properties"));
- propertiesAction->setShortcuts(QList<QKeySequence>() << Qt::ALT + Qt::Key_Return << Qt::ALT + Qt::Key_Enter);
- connect(propertiesAction, SIGNAL(triggered()), SLOT(slotProperties()));
+ propertiesAction->setIcon(QIcon::fromTheme("document-properties"));
+ m_actionCollection->setDefaultShortcuts(propertiesAction, {Qt::ALT + Qt::Key_Return, Qt::ALT + Qt::Key_Enter});
+ connect(propertiesAction, &QAction::triggered, this, &DolphinViewActionHandler::slotProperties);
// View menu
KToggleAction* iconsAction = iconsModeAction();
@@ -154,7 +154,7 @@ void DolphinViewActionHandler::createActions()
viewModeActions->addAction(compactAction);
viewModeActions->addAction(detailsAction);
viewModeActions->setToolBarMode(KSelectAction::MenuMode);
- connect(viewModeActions, SIGNAL(triggered(QAction*)), this, SLOT(slotViewModeActionTriggered(QAction*)));
+ connect(viewModeActions, static_cast<void(KSelectAction::*)(QAction*)>(&KSelectAction::triggered), this, &DolphinViewActionHandler::slotViewModeActionTriggered);
KStandardAction::zoomIn(this,
SLOT(zoomIn()),
@@ -167,16 +167,16 @@ void DolphinViewActionHandler::createActions()
KToggleAction* showPreview = m_actionCollection->add<KToggleAction>("show_preview");
showPreview->setText(i18nc("@action:intoolbar", "Preview"));
showPreview->setToolTip(i18nc("@info", "Show preview of files and folders"));
- showPreview->setIcon(KIcon("view-preview"));
- connect(showPreview, SIGNAL(triggered(bool)), this, SLOT(togglePreview(bool)));
+ showPreview->setIcon(QIcon::fromTheme("view-preview"));
+ connect(showPreview, &KToggleAction::triggered, this, &DolphinViewActionHandler::togglePreview);
KToggleAction* sortDescending = m_actionCollection->add<KToggleAction>("descending");
sortDescending->setText(i18nc("@action:inmenu Sort", "Descending"));
- connect(sortDescending, SIGNAL(triggered()), this, SLOT(toggleSortOrder()));
+ connect(sortDescending, &KToggleAction::triggered, this, &DolphinViewActionHandler::toggleSortOrder);
KToggleAction* sortFoldersFirst = m_actionCollection->add<KToggleAction>("folders_first");
sortFoldersFirst->setText(i18nc("@action:inmenu Sort", "Folders First"));
- connect(sortFoldersFirst, SIGNAL(triggered()), this, SLOT(toggleSortFoldersFirst()));
+ connect(sortFoldersFirst, &KToggleAction::triggered, this, &DolphinViewActionHandler::toggleSortFoldersFirst);
// View -> Sort By
QActionGroup* sortByActionGroup = createFileItemRolesActionGroup("sort_by_");
@@ -204,18 +204,18 @@ void DolphinViewActionHandler::createActions()
}
KToggleAction* showInGroups = m_actionCollection->add<KToggleAction>("show_in_groups");
- showInGroups->setIcon(KIcon("view-group"));
+ showInGroups->setIcon(QIcon::fromTheme("view-group"));
showInGroups->setText(i18nc("@action:inmenu View", "Show in Groups"));
- connect(showInGroups, SIGNAL(triggered(bool)), this, SLOT(toggleGroupedSorting(bool)));
+ connect(showInGroups, &KToggleAction::triggered, this, &DolphinViewActionHandler::toggleGroupedSorting);
KToggleAction* showHiddenFiles = m_actionCollection->add<KToggleAction>("show_hidden_files");
showHiddenFiles->setText(i18nc("@action:inmenu View", "Show Hidden Files"));
- showHiddenFiles->setShortcuts(QList<QKeySequence>() << Qt::ALT + Qt::Key_Period << Qt::Key_F8);
- connect(showHiddenFiles, SIGNAL(triggered(bool)), this, SLOT(toggleShowHiddenFiles(bool)));
+ m_actionCollection->setDefaultShortcuts(showHiddenFiles, {Qt::ALT + Qt::Key_Period, Qt::Key_F8});
+ connect(showHiddenFiles, &KToggleAction::triggered, this, &DolphinViewActionHandler::toggleShowHiddenFiles);
- KAction* adjustViewProps = m_actionCollection->addAction("view_properties");
+ QAction* adjustViewProps = m_actionCollection->addAction("view_properties");
adjustViewProps->setText(i18nc("@action:inmenu View", "Adjust View Properties..."));
- connect(adjustViewProps, SIGNAL(triggered()), this, SLOT(slotAdjustViewProperties()));
+ connect(adjustViewProps, &QAction::triggered, this, &DolphinViewActionHandler::slotAdjustViewProperties);
}
QActionGroup* DolphinViewActionHandler::createFileItemRolesActionGroup(const QString& groupPrefix)
@@ -226,11 +226,11 @@ QActionGroup* DolphinViewActionHandler::createFileItemRolesActionGroup(const QSt
QActionGroup* rolesActionGroup = new QActionGroup(m_actionCollection);
rolesActionGroup->setExclusive(isSortGroup);
if (isSortGroup) {
- connect(rolesActionGroup, SIGNAL(triggered(QAction*)),
- this, SLOT(slotSortTriggered(QAction*)));
+ connect(rolesActionGroup, &QActionGroup::triggered,
+ this, &DolphinViewActionHandler::slotSortTriggered);
} else {
- connect(rolesActionGroup, SIGNAL(triggered(QAction*)),
- this, SLOT(toggleVisibleRole(QAction*)));
+ connect(rolesActionGroup, &QActionGroup::triggered,
+ this, &DolphinViewActionHandler::toggleVisibleRole);
}
QString groupName;
@@ -265,11 +265,11 @@ QActionGroup* DolphinViewActionHandler::createFileItemRolesActionGroup(const QSt
groupMenuGroup = new QActionGroup(groupMenu);
groupMenuGroup->setExclusive(isSortGroup);
if (isSortGroup) {
- connect(groupMenuGroup, SIGNAL(triggered(QAction*)),
- this, SLOT(slotSortTriggered(QAction*)));
+ connect(groupMenuGroup, &QActionGroup::triggered,
+ this, &DolphinViewActionHandler::slotSortTriggered);
} else {
- connect(groupMenuGroup, SIGNAL(triggered(QAction*)),
- this, SLOT(toggleVisibleRole(QAction*)));
+ connect(groupMenuGroup, &QActionGroup::triggered,
+ this, &DolphinViewActionHandler::toggleVisibleRole);
}
}
@@ -301,7 +301,7 @@ void DolphinViewActionHandler::slotViewModeActionTriggered(QAction* action)
m_currentView->setMode(mode);
QAction* viewModeMenu = m_actionCollection->action("view_mode");
- viewModeMenu->setIcon(KIcon(action->icon()));
+ viewModeMenu->setIcon(action->icon());
}
void DolphinViewActionHandler::slotRename()
@@ -310,7 +310,7 @@ void DolphinViewActionHandler::slotRename()
m_currentView->renameSelectedItems();
}
-void DolphinViewActionHandler::slotTrashActivated(Qt::MouseButtons, Qt::KeyboardModifiers modifiers)
+void DolphinViewActionHandler::slotTrashActivated()
{
emit actionBeingHandled();
m_currentView->trashSelectedItems();
@@ -364,7 +364,7 @@ void DolphinViewActionHandler::updateViewActions()
viewModeAction->setChecked(true);
QAction* viewModeMenu = m_actionCollection->action("view_mode");
- viewModeMenu->setIcon(KIcon(viewModeAction->icon()));
+ viewModeMenu->setIcon(viewModeAction->icon());
}
QAction* showPreviewAction = m_actionCollection->action("show_preview");
@@ -491,8 +491,8 @@ KToggleAction* DolphinViewActionHandler::iconsModeAction()
KToggleAction* iconsView = m_actionCollection->add<KToggleAction>("icons");
iconsView->setText(i18nc("@action:inmenu View Mode", "Icons"));
iconsView->setToolTip(i18nc("@info", "Icons view mode"));
- iconsView->setShortcut(Qt::CTRL | Qt::Key_1);
- iconsView->setIcon(KIcon("view-list-icons"));
+ m_actionCollection->setDefaultShortcut(iconsView, Qt::CTRL | Qt::Key_1);
+ iconsView->setIcon(QIcon::fromTheme("view-list-icons"));
iconsView->setData(QVariant::fromValue(DolphinView::IconsView));
return iconsView;
}
@@ -502,8 +502,8 @@ KToggleAction* DolphinViewActionHandler::compactModeAction()
KToggleAction* iconsView = m_actionCollection->add<KToggleAction>("compact");
iconsView->setText(i18nc("@action:inmenu View Mode", "Compact"));
iconsView->setToolTip(i18nc("@info", "Compact view mode"));
- iconsView->setShortcut(Qt::CTRL | Qt::Key_2);
- iconsView->setIcon(KIcon("view-list-details")); // TODO: discuss with Oxygen-team the wrong (?) name
+ m_actionCollection->setDefaultShortcut(iconsView, Qt::CTRL | Qt::Key_2);
+ iconsView->setIcon(QIcon::fromTheme("view-list-details")); // TODO: discuss with Oxygen-team the wrong (?) name
iconsView->setData(QVariant::fromValue(DolphinView::CompactView));
return iconsView;
}
@@ -513,8 +513,8 @@ KToggleAction* DolphinViewActionHandler::detailsModeAction()
KToggleAction* detailsView = m_actionCollection->add<KToggleAction>("details");
detailsView->setText(i18nc("@action:inmenu View Mode", "Details"));
detailsView->setToolTip(i18nc("@info", "Details view mode"));
- detailsView->setShortcut(Qt::CTRL | Qt::Key_3);
- detailsView->setIcon(KIcon("view-list-tree"));
+ m_actionCollection->setDefaultShortcut(detailsView, Qt::CTRL | Qt::Key_3);
+ detailsView->setIcon(QIcon::fromTheme("view-list-tree"));
detailsView->setData(QVariant::fromValue(DolphinView::DetailsView));
return detailsView;
}
@@ -527,7 +527,7 @@ void DolphinViewActionHandler::slotSortRoleChanged(const QByteArray& role)
if (!action->icon().isNull()) {
QAction* sortByMenu = m_actionCollection->action("sort");
- sortByMenu->setIcon(KIcon(action->icon()));
+ sortByMenu->setIcon(action->icon());
}
}
}
@@ -585,7 +585,7 @@ void DolphinViewActionHandler::slotProperties()
KPropertiesDialog* dialog = 0;
const KFileItemList list = m_currentView->selectedItems();
if (list.isEmpty()) {
- const KUrl url = m_currentView->url();
+ const QUrl url = m_currentView->url();
dialog = new KPropertiesDialog(url, m_currentView);
} else {
dialog = new KPropertiesDialog(list, m_currentView);
diff --git a/src/views/dolphinviewactionhandler.h b/src/views/dolphinviewactionhandler.h
index e80ffc0df..eb375b5c9 100644
--- a/src/views/dolphinviewactionhandler.h
+++ b/src/views/dolphinviewactionhandler.h
@@ -22,9 +22,7 @@
#ifndef DOLPHINVIEWACTIONHANDLER_H
#define DOLPHINVIEWACTIONHANDLER_H
-#include "libdolphin_export.h"
-#include <KActionMenu>
-#include <KSelectAction>
+#include "dolphin_export.h"
#include "views/dolphinview.h"
#include <QObject>
@@ -48,7 +46,7 @@ class KActionCollection;
* @see DolphinMainWindow
* @see DolphinPart
*/
-class LIBDOLPHINPRIVATE_EXPORT DolphinViewActionHandler : public QObject
+class DOLPHIN_EXPORT DolphinViewActionHandler : public QObject
{
Q_OBJECT
@@ -112,7 +110,7 @@ private Q_SLOTS:
* Moves the selected items of the active view to the trash.
* This methods adds "shift means del" handling.
*/
- void slotTrashActivated(Qt::MouseButtons, Qt::KeyboardModifiers);
+ void slotTrashActivated();
/**
* Deletes the selected items of the active view.
diff --git a/src/views/draganddrophelper.cpp b/src/views/draganddrophelper.cpp
index f8ae0ad03..c0044c96e 100644
--- a/src/views/draganddrophelper.cpp
+++ b/src/views/draganddrophelper.cpp
@@ -20,23 +20,17 @@
#include "draganddrophelper.h"
-#include <KFileItem>
-#include <KLocale>
-#include <konq_operations.h>
-#include <KUrl>
-#include <QApplication>
-#include <QtDBus>
+#include <QUrl>
+#include <QDBusMessage>
+#include <QDBusConnection>
#include <QDropEvent>
+#include <QMimeData>
-KonqOperations* DragAndDropHelper::dropUrls(const KFileItem& destItem, const KUrl& destUrl, QDropEvent* event, QString& error)
-{
- error.clear();
-
- if (!destItem.isNull() && !destItem.isWritable()) {
- error = i18nc("@info:status", "Access denied. Could not write to <filename>%1</filename>", destUrl.pathOrUrl());
- return 0;
- }
+#include <KIO/DropJob>
+#include <KJobWidgets>
+KIO::DropJob* DragAndDropHelper::dropUrls(const QUrl& destUrl, QDropEvent* event, QWidget* window)
+{
const QMimeData* mimeData = event->mimeData();
if (mimeData->hasFormat("application/x-kde-ark-dndextract-service") &&
mimeData->hasFormat("application/x-kde-ark-dndextract-path")) {
@@ -45,21 +39,13 @@ KonqOperations* DragAndDropHelper::dropUrls(const KFileItem& destItem, const KUr
QDBusMessage message = QDBusMessage::createMethodCall(remoteDBusClient, remoteDBusPath,
"org.kde.ark.DndExtract", "extractSelectedFilesTo");
- message.setArguments(QVariantList() << destUrl.pathOrUrl());
+ message.setArguments({destUrl.toDisplayString(QUrl::PreferLocalFile)});
QDBusConnection::sessionBus().call(message);
- } else if (!destItem.isNull() && (destItem.isDir() || destItem.isDesktopFile())) {
- // Drop into a directory or a desktop-file
- const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
- foreach (const KUrl& url, urls) {
- if (url == destUrl) {
- error = i18nc("@info:status", "A folder cannot be dropped into itself");
- return 0;
- }
- }
-
- return KonqOperations::doDrop(destItem, destUrl, event, QApplication::activeWindow(), QList<QAction*>());
} else {
- return KonqOperations::doDrop(KFileItem(), destUrl, event, QApplication::activeWindow(), QList<QAction*>());
+ // Drop into a directory or a desktop-file
+ KIO::DropJob *job = KIO::drop(event, destUrl);
+ KJobWidgets::setWindow(job, window);
+ return job;
}
return 0;
diff --git a/src/views/draganddrophelper.h b/src/views/draganddrophelper.h
index eda5fc5c2..fe77b1e6e 100644
--- a/src/views/draganddrophelper.h
+++ b/src/views/draganddrophelper.h
@@ -21,17 +21,15 @@
#ifndef DRAGANDDROPHELPER_H
#define DRAGANDDROPHELPER_H
-#include "libdolphin_export.h"
+#include "dolphin_export.h"
-#include <QString>
-class KFileItem;
-class KUrl;
+class QUrl;
class QDropEvent;
class QWidget;
-class KonqOperations;
+namespace KIO { class DropJob; }
-class LIBDOLPHINPRIVATE_EXPORT DragAndDropHelper
+class DOLPHIN_EXPORT DragAndDropHelper
{
public:
/**
@@ -40,22 +38,15 @@ public:
* offered to the user. The drag destination must represent a directory or
* a desktop-file, otherwise the dropping gets ignored.
*
- * @param destItem Item of the destination. Can be 0 (KFileItem::isNull()) if
- * no file-item is available for the destination. In this case
- * destUrl is used as fallback. For performance reasons it is
- * recommended to pass a file-item if available.
* @param destUrl URL of the item destination. Is used only if destItem::isNull()
* is true.
* @param event Drop event.
- * @param error Error message intended to be shown for users if dropping is not
- * possible. If an empty string is returned, the dropping has been
- * successful.
- * @return KonqOperations pointer
+ * @param window Associated widget.
+ * @return KIO::DropJob pointer
*/
- static KonqOperations* dropUrls(const KFileItem& destItem,
- const KUrl& destUrl,
- QDropEvent* event,
- QString& error);
+ static KIO::DropJob* dropUrls(const QUrl& destUrl,
+ QDropEvent* event,
+ QWidget *window);
};
#endif
diff --git a/src/views/renamedialog.cpp b/src/views/renamedialog.cpp
index 5c0ae6126..be9e34c4a 100644
--- a/src/views/renamedialog.cpp
+++ b/src/views/renamedialog.cpp
@@ -19,19 +19,24 @@
#include "renamedialog.h"
-#include <KLineEdit>
-#include <KLocale>
-#include <konq_operations.h>
-#include <KStringHandler>
-#include <knuminput.h>
-#include <kmimetype.h>
+#include <KLocalizedString>
+#include <KJobWidgets>
+#include <KIO/CopyJob>
+#include <KIO/FileUndoManager>
+#include <KJobUiDelegate>
#include <QHBoxLayout>
#include <QLabel>
#include <QVBoxLayout>
+#include <QMimeDatabase>
+#include <QDialogButtonBox>
+#include <QPushButton>
+#include <QLineEdit>
+#include <QSpinBox>
+#include <KGuiItem>
RenameDialog::RenameDialog(QWidget *parent, const KFileItemList& items) :
- KDialog(parent),
+ QDialog(parent),
m_renameOneItem(false),
m_newName(),
m_lineEdit(0),
@@ -46,23 +51,31 @@ RenameDialog::RenameDialog(QWidget *parent, const KFileItemList& items) :
Q_ASSERT(itemCount >= 1);
m_renameOneItem = (itemCount == 1);
- setCaption(m_renameOneItem ?
+ setWindowTitle(m_renameOneItem ?
i18nc("@title:window", "Rename Item") :
i18nc("@title:window", "Rename Items"));
- setButtons(Ok | Cancel);
- setDefaultButton(Ok);
+ QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
+ QVBoxLayout *mainLayout = new QVBoxLayout;
+ setLayout(mainLayout);
+ m_okButton = buttonBox->button(QDialogButtonBox::Ok);
+ m_okButton->setDefault(true);
+ m_okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
+ connect(buttonBox, SIGNAL(accepted()), this, SLOT(slotAccepted()));
+ connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
+ m_okButton->setDefault(true);
- setButtonGuiItem(Ok, KGuiItem(i18nc("@action:button", "&Rename"), "dialog-ok-apply"));
+ KGuiItem::assign(m_okButton, KGuiItem(i18nc("@action:button", "&Rename"), "dialog-ok-apply"));
QWidget* page = new QWidget(this);
- setMainWidget(page);
+ mainLayout->addWidget(page);
+ mainLayout->addWidget(buttonBox);
QVBoxLayout* topLayout = new QVBoxLayout(page);
QLabel* editLabel = 0;
if (m_renameOneItem) {
m_newName = items.first().name();
- editLabel = new QLabel(i18nc("@label:textbox", "Rename the item <filename>%1</filename> to:", m_newName),
+ editLabel = new QLabel(xi18nc("@label:textbox", "Rename the item <filename>%1</filename> to:", m_newName),
page);
editLabel->setTextFormat(Qt::PlainText);
} else {
@@ -73,13 +86,15 @@ RenameDialog::RenameDialog(QWidget *parent, const KFileItemList& items) :
page);
}
- m_lineEdit = new KLineEdit(page);
- connect(m_lineEdit, SIGNAL(textChanged(QString)), this, SLOT(slotTextChanged(QString)));
+ m_lineEdit = new QLineEdit(page);
+ mainLayout->addWidget(m_lineEdit);
+ connect(m_lineEdit, &QLineEdit::textChanged, this, &RenameDialog::slotTextChanged);
int selectionLength = m_newName.length();
if (m_renameOneItem) {
- const QString fileName = items.first().url().prettyUrl();
- const QString extension = KMimeType::extractKnownExtension(fileName.toLower());
+ const QString fileName = items.first().url().toDisplayString();
+ QMimeDatabase db;
+ const QString extension = db.suffixForFileName(fileName.toLower());
// If the current item is a directory, select the whole file name.
if ((extension.length() > 0) && !items.first().isDir()) {
@@ -101,7 +116,8 @@ RenameDialog::RenameDialog(QWidget *parent, const KFileItemList& items) :
if (!m_renameOneItem) {
QSet<QString> extensions;
foreach (const KFileItem& item, m_items) {
- const QString extension = KMimeType::extractKnownExtension(item.url().prettyUrl().toLower());
+ QMimeDatabase db;
+ const QString extension = db.suffixForFileName(item.url().toDisplayString().toLower());
if (extensions.contains(extension)) {
m_allExtensionsDifferent = false;
@@ -112,7 +128,13 @@ RenameDialog::RenameDialog(QWidget *parent, const KFileItemList& items) :
}
QLabel* infoLabel = new QLabel(i18nc("@info", "# will be replaced by ascending numbers starting with:"), page);
- m_spinBox = new KIntSpinBox(0, 10000, 1, 1, page, 10);
+ mainLayout->addWidget(infoLabel);
+ m_spinBox = new QSpinBox(page);
+ m_spinBox->setMaximum(10000);
+ m_spinBox->setMinimum(0);
+ m_spinBox->setSingleStep(1);
+ m_spinBox->setValue(1);
+ m_spinBox->setDisplayIntegerBase(10);
QHBoxLayout* horizontalLayout = new QHBoxLayout(page);
horizontalLayout->setMargin(0);
@@ -127,29 +149,34 @@ RenameDialog::~RenameDialog()
{
}
-void RenameDialog::slotButtonClicked(int button)
+void RenameDialog::renameItem(const KFileItem &item, const QString& newName)
{
- if (button == KDialog::Ok) {
- m_newName = m_lineEdit->text();
+ const QUrl oldUrl = item.url();
+ QUrl newUrl = oldUrl.adjusted(QUrl::RemoveFilename);
+ newUrl.setPath(newUrl.path() + KIO::encodeFileName(newName));
- if (m_renameOneItem) {
- Q_ASSERT(m_items.count() == 1);
- const KUrl oldUrl = m_items.first().url();
- KUrl newUrl = oldUrl;
- newUrl.setFileName(KIO::encodeFileName(m_newName));
+ QWidget* widget = parentWidget();
+ if (!widget) {
+ widget = this;
+ }
- QWidget* widget = parentWidget();
- if (!widget) {
- widget = this;
- }
+ KIO::Job * job = KIO::moveAs(oldUrl, newUrl);
+ KJobWidgets::setWindow(job, widget);
+ KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Rename, {oldUrl}, newUrl, job);
+ job->ui()->setAutoErrorHandlingEnabled(true);
+}
- KonqOperations::rename(widget, oldUrl, newUrl);
- } else {
- renameItems();
- }
- }
+void RenameDialog::slotAccepted()
+{
+ m_newName = m_lineEdit->text();
- KDialog::slotButtonClicked(button);
+ if (m_renameOneItem) {
+ Q_ASSERT(m_items.count() == 1);
+ renameItem(m_items.first(), m_newName);
+ } else {
+ renameItems();
+ }
+ accept();
}
void RenameDialog::slotTextChanged(const QString& newName)
@@ -167,7 +194,7 @@ void RenameDialog::slotTextChanged(const QString& newName)
enable = (last - first + 1 == count);
}
}
- enableButtonOk(enable);
+ m_okButton->setEnabled(enable);
}
void RenameDialog::renameItems()
@@ -178,23 +205,16 @@ void RenameDialog::renameItems()
QString newName = indexedName(m_newName, index, QLatin1Char('#'));
++index;
- const KUrl oldUrl = item.url();
- const QString extension = KMimeType::extractKnownExtension(oldUrl.prettyUrl().toLower());
+ const QUrl oldUrl = item.url();
+ QMimeDatabase db;
+ const QString extension = db.suffixForFileName(oldUrl.path().toLower());
if (!extension.isEmpty()) {
newName.append(QLatin1Char('.'));
newName.append(extension);
}
if (oldUrl.fileName() != newName) {
- KUrl newUrl = oldUrl;
- newUrl.setFileName(KIO::encodeFileName(newName));
-
- QWidget* widget = parentWidget();
- if (!widget) {
- widget = this;
- }
-
- KonqOperations::rename(widget, oldUrl, newUrl);
+ renameItem(item, newName);
}
}
}
@@ -218,4 +238,3 @@ QString RenameDialog::indexedName(const QString& name, int index, const QChar& i
return newName;
}
-#include "renamedialog.moc"
diff --git a/src/views/renamedialog.h b/src/views/renamedialog.h
index 29ef8bdf1..a1953e8b3 100644
--- a/src/views/renamedialog.h
+++ b/src/views/renamedialog.h
@@ -20,20 +20,20 @@
#ifndef RENAMEDIALOG_H
#define RENAMEDIALOG_H
-#include "libdolphin_export.h"
+#include "dolphin_export.h"
-#include <KDialog>
+#include <QDialog>
#include <KFileItem>
-
-class KLineEdit;
-class KIntSpinBox;
-
#include <QString>
+class QLineEdit;
+class QSpinBox;
+class QPushButton;
+
/**
* @brief Dialog for renaming a variable number of files.
*/
-class LIBDOLPHINPRIVATE_EXPORT RenameDialog : public KDialog
+class DOLPHIN_EXPORT RenameDialog : public QDialog
{
Q_OBJECT
@@ -41,14 +41,13 @@ public:
explicit RenameDialog(QWidget* parent, const KFileItemList& items);
virtual ~RenameDialog();
-protected slots:
- virtual void slotButtonClicked(int button);
-
private slots:
+ void slotAccepted();
void slotTextChanged(const QString& newName);
private:
void renameItems();
+ void renameItem(const KFileItem &item, const QString& newName);
/**
* @return Returns the string \p name, where the characters represented by
@@ -62,10 +61,11 @@ private:
private:
bool m_renameOneItem;
QString m_newName;
- KLineEdit* m_lineEdit;
+ QLineEdit* m_lineEdit;
KFileItemList m_items;
bool m_allExtensionsDifferent;
- KIntSpinBox* m_spinBox;
+ QSpinBox* m_spinBox;
+ QPushButton* m_okButton;
};
#endif
diff --git a/src/views/tooltips/filemetadatatooltip.cpp b/src/views/tooltips/filemetadatatooltip.cpp
index b72699664..11b9ecd1d 100644
--- a/src/views/tooltips/filemetadatatooltip.cpp
+++ b/src/views/tooltips/filemetadatatooltip.cpp
@@ -23,26 +23,24 @@
#include <KColorScheme>
#include <KSeparator>
-#include <KWindowSystem>
+// For the blurred tooltip background
+#include <KWindowEffects>
#include <KStringHandler>
+#include <QTextDocument>
#include <QLabel>
#include <QStyleOptionFrame>
#include <QStylePainter>
#include <QVBoxLayout>
-#include <QTextDocument>
#include <QTextLayout>
#include <QTextLine>
#ifndef HAVE_BALOO
#include <KFileMetaDataWidget>
#else
-#include <baloo/filemetadatawidget.h>
+#include <Baloo/FileMetaDataWidget>
#endif
-// For the blurred tooltip background
-#include <plasma/windoweffects.h>
-
FileMetaDataToolTip::FileMetaDataToolTip(QWidget* parent) :
QWidget(parent),
m_preview(0),
@@ -72,13 +70,15 @@ FileMetaDataToolTip::FileMetaDataToolTip(QWidget* parent) :
// Create widget for the meta data
#ifndef HAVE_BALOO
m_fileMetaDataWidget = new KFileMetaDataWidget(this);
+ connect(m_fileMetaDataWidget, &KFileMetaDataWidget::metaDataRequestFinished,
+ this, &FileMetaDataToolTip::metaDataRequestFinished);
#else
m_fileMetaDataWidget = new Baloo::FileMetaDataWidget(this);
+ connect(m_fileMetaDataWidget, &Baloo::FileMetaDataWidget::metaDataRequestFinished,
+ this, &FileMetaDataToolTip::metaDataRequestFinished);
#endif
m_fileMetaDataWidget->setForegroundRole(QPalette::ToolTipText);
m_fileMetaDataWidget->setReadOnly(true);
- connect(m_fileMetaDataWidget, SIGNAL(metaDataRequestFinished(KFileItemList)),
- this, SIGNAL(metaDataRequestFinished(KFileItemList)));
QVBoxLayout* textLayout = new QVBoxLayout();
textLayout->addWidget(m_name);
@@ -174,8 +174,8 @@ void FileMetaDataToolTip::paintEvent(QPaintEvent* event)
void FileMetaDataToolTip::showEvent(QShowEvent *)
{
- Plasma::WindowEffects::overrideShadow(winId(), true);
- Plasma::WindowEffects::enableBlurBehind(winId(), true, mask());
+#pragma message("TODO: port Plasma::WindowEffects::overrideShadow")
+ //Plasma::WindowEffects::overrideShadow(winId(), true);
+ KWindowEffects::enableBlurBehind(winId(), true, mask());
}
-#include "filemetadatatooltip.moc"
diff --git a/src/views/tooltips/filemetadatatooltip.h b/src/views/tooltips/filemetadatatooltip.h
index 7197871fc..379b025c8 100644
--- a/src/views/tooltips/filemetadatatooltip.h
+++ b/src/views/tooltips/filemetadatatooltip.h
@@ -70,8 +70,8 @@ signals:
void metaDataRequestFinished(const KFileItemList& items);
protected:
- virtual void paintEvent(QPaintEvent* event);
- virtual void showEvent(QShowEvent *);
+ virtual void paintEvent(QPaintEvent* event) Q_DECL_OVERRIDE;
+ virtual void showEvent(QShowEvent *) Q_DECL_OVERRIDE;
private:
QLabel* m_preview;
diff --git a/src/views/tooltips/tooltipmanager.cpp b/src/views/tooltips/tooltipmanager.cpp
index bd6948363..0636df795 100644
--- a/src/views/tooltips/tooltipmanager.cpp
+++ b/src/views/tooltips/tooltipmanager.cpp
@@ -20,15 +20,14 @@
#include "tooltipmanager.h"
#include "filemetadatatooltip.h"
-#include <KIcon>
+#include <QIcon>
#include <KIO/JobUiDelegate>
#include <KIO/PreviewJob>
+#include <KJobWidgets>
#include <QApplication>
#include <QDesktopWidget>
#include <QLayout>
-#include <QScrollArea>
-#include <QScrollBar>
#include <QStyle>
#include <QTimer>
@@ -51,12 +50,12 @@ ToolTipManager::ToolTipManager(QWidget* parent) :
m_showToolTipTimer = new QTimer(this);
m_showToolTipTimer->setSingleShot(true);
m_showToolTipTimer->setInterval(500);
- connect(m_showToolTipTimer, SIGNAL(timeout()), this, SLOT(showToolTip()));
+ connect(m_showToolTipTimer, &QTimer::timeout, this, static_cast<void(ToolTipManager::*)()>(&ToolTipManager::showToolTip));
m_contentRetrievalTimer = new QTimer(this);
m_contentRetrievalTimer->setSingleShot(true);
m_contentRetrievalTimer->setInterval(200);
- connect(m_contentRetrievalTimer, SIGNAL(timeout()), this, SLOT(startContentRetrieval()));
+ connect(m_contentRetrievalTimer, &QTimer::timeout, this, &ToolTipManager::startContentRetrieval);
Q_ASSERT(m_contentRetrievalTimer->interval() < m_showToolTipTimer->interval());
}
@@ -81,8 +80,8 @@ void ToolTipManager::showToolTip(const KFileItem& item, const QRectF& itemRect)
// meta data retrieval, when passing rapidly over a lot of items.
Q_ASSERT(!m_fileMetaDataToolTip);
m_fileMetaDataToolTip = new FileMetaDataToolTip();
- connect(m_fileMetaDataToolTip, SIGNAL(metaDataRequestFinished(KFileItemList)),
- this, SLOT(slotMetaDataRequestFinished()));
+ connect(m_fileMetaDataToolTip, &FileMetaDataToolTip::metaDataRequestFinished,
+ this, &ToolTipManager::slotMetaDataRequestFinished);
m_contentRetrievalTimer->start();
m_showToolTipTimer->start();
@@ -132,13 +131,13 @@ void ToolTipManager::startContentRetrieval()
KIO::PreviewJob* job = new KIO::PreviewJob(KFileItemList() << m_item, QSize(256, 256));
job->setIgnoreMaximumSize(m_item.isLocalFile());
if (job->ui()) {
- job->ui()->setWindow(qApp->activeWindow());
+ KJobWidgets::setWindow(job, qApp->activeWindow());
}
- connect(job, SIGNAL(gotPreview(KFileItem,QPixmap)),
- this, SLOT(setPreviewPix(KFileItem,QPixmap)));
- connect(job, SIGNAL(failed(KFileItem)),
- this, SLOT(previewFailed()));
+ connect(job, &KIO::PreviewJob::gotPreview,
+ this, &ToolTipManager::setPreviewPix);
+ connect(job, &KIO::PreviewJob::failed,
+ this, &ToolTipManager::previewFailed);
}
@@ -166,7 +165,7 @@ void ToolTipManager::previewFailed()
return;
}
- const QPixmap pixmap = KIcon(m_item.iconName()).pixmap(128, 128);
+ const QPixmap pixmap = QIcon::fromTheme(m_item.iconName()).pixmap(128, 128);
m_fileMetaDataToolTip->setPreview(pixmap);
if (!m_showToolTipTimer->isActive()) {
showToolTip();
@@ -266,4 +265,3 @@ void ToolTipManager::showToolTip()
m_toolTipRequested = false;
}
-#include "tooltipmanager.moc"
diff --git a/src/views/tooltips/tooltipmanager.h b/src/views/tooltips/tooltipmanager.h
index 4fd8f843e..f6d8b8f26 100644
--- a/src/views/tooltips/tooltipmanager.h
+++ b/src/views/tooltips/tooltipmanager.h
@@ -25,11 +25,7 @@
#include <KFileItem>
-class DolphinModel;
-class DolphinSortFilterProxyModel;
class FileMetaDataToolTip;
-class QAbstractItemView;
-class QModelIndex;
class QTimer;
/**
diff --git a/src/views/versioncontrol/kversioncontrolplugin.cpp b/src/views/versioncontrol/kversioncontrolplugin.cpp
new file mode 100644
index 000000000..2c0632878
--- /dev/null
+++ b/src/views/versioncontrol/kversioncontrolplugin.cpp
@@ -0,0 +1,29 @@
+/*****************************************************************************
+ * Copyright (C) 2011 by Vishesh Yadav <[email protected]> *
+ * Copyright (C) 2011 by Peter Penz <[email protected]> *
+ * *
+ * This library is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Library General Public *
+ * License version 2 as published by the Free Software Foundation. *
+ * *
+ * This library is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Library General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Library General Public License *
+ * along with this library; see the file COPYING.LIB. If not, write to *
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301, USA. *
+ *****************************************************************************/
+
+#include "kversioncontrolplugin.h"
+
+KVersionControlPlugin::KVersionControlPlugin(QObject* parent) :
+ QObject(parent)
+{
+}
+
+KVersionControlPlugin::~KVersionControlPlugin()
+{
+}
diff --git a/src/views/versioncontrol/kversioncontrolplugin.h b/src/views/versioncontrol/kversioncontrolplugin.h
new file mode 100644
index 000000000..e5a267848
--- /dev/null
+++ b/src/views/versioncontrol/kversioncontrolplugin.h
@@ -0,0 +1,223 @@
+/*****************************************************************************
+ * Copyright (C) 2011 by Vishesh Yadav <[email protected]> *
+ * Copyright (C) 2011 by Peter Penz <[email protected]> *
+ * *
+ * This library is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Library General Public *
+ * License version 2 as published by the Free Software Foundation. *
+ * *
+ * This library is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Library General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Library General Public License *
+ * along with this library; see the file COPYING.LIB. If not, write to *
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301, USA. *
+ *****************************************************************************/
+
+#ifndef KVERSIONCONTROLPLUGIN_H
+#define KVERSIONCONTROLPLUGIN_H
+
+#include <dolphin_export.h>
+
+#include <QObject>
+#include <KFileItem>
+#include <QAction>
+
+/**
+ * @brief Base class for version control plugins.
+ *
+ * Enables the file manager to show the version state
+ * of a versioned file. To write a custom plugin, the following
+ * steps are required (in the example below it is assumed that a plugin for
+ * Subversion will be written):
+ *
+ * - Create a fileviewsvnplugin.desktop file with the following content:
+ * <code>
+ * [Desktop Entry]
+ * Type=Service
+ * Name=Subversion
+ * X-KDE-ServiceTypes=FileViewVersionControlPlugin
+ * MimeType=text/plain;
+ * X-KDE-Library=fileviewsvnplugin
+ * </code>
+ *
+ * - Create a class FileViewSvnPlugin derived from KVersionControlPlugin and
+ * implement all abstract interfaces (fileviewsvnplugin.h, fileviewsvnplugin.cpp).
+ *
+ * - Take care that the constructor has the following signature:
+ * <code>
+ * FileViewSvnPlugin(QObject* parent, const QList<QVariant>& args);
+ * </code>
+ *
+ * - Add the following lines at the top of fileviewsvnplugin.cpp:
+ * <code>
+ * #include <KPluginFactory>
+ * #include <KPluginLoader>
+ * K_PLUGIN_FACTORY(FileViewSvnPluginFactory, registerPlugin<FileViewSvnPlugin>();)
+ * K_EXPORT_PLUGIN(FileViewSvnPluginFactory("fileviewsvnplugin"))
+ * </code>
+ *
+ * - Add the following lines to your CMakeLists.txt file:
+ * <code>
+ * kde4_add_plugin(fileviewsvnplugin fileviewsvnplugin.cpp)
+ * target_link_libraries(fileviewsvnplugin konq)
+ * install(FILES fileviewsvnplugin.desktop DESTINATION ${SERVICES_INSTALL_DIR})
+ * </code>
+ *
+ * General implementation notes:
+ *
+ * - The implementations of beginRetrieval(), endRetrieval() and versionState()
+ * can contain blocking operations, as Dolphin will execute
+ * those methods in a separate thread. It is assured that
+ * all other methods are invoked in a serialized way, so that it is not necessary for
+ * the plugin to use any mutex.
+ *
+ * - Dolphin keeps only one instance of the plugin, which is instantiated shortly after
+ * starting Dolphin. Take care that the constructor does no expensive and time
+ * consuming operations.
+ *
+ * @since 4.8
+ */
+class DOLPHIN_EXPORT KVersionControlPlugin : public QObject
+{
+ Q_OBJECT
+
+public:
+ enum ItemVersion
+ {
+ /** The file is not under version control. */
+ UnversionedVersion,
+ /**
+ * The file is under version control and represents
+ * the latest version.
+ */
+ NormalVersion,
+ /**
+ * The file is under version control and a newer
+ * version exists on the main branch.
+ */
+ UpdateRequiredVersion,
+ /**
+ * The file is under version control and has been
+ * modified locally. All modifications will be part
+ * of the next commit.
+ */
+ LocallyModifiedVersion,
+ /**
+ * The file has not been under version control but
+ * has been marked to get added with the next commit.
+ */
+ AddedVersion,
+ /**
+ * The file is under version control but has been marked
+ * for getting removed with the next commit.
+ */
+ RemovedVersion,
+ /**
+ * The file is under version control and has been locally
+ * modified. A modification has also been done on the main
+ * branch.
+ */
+ ConflictingVersion,
+ /**
+ * The file is under version control and has local
+ * modifications, which will not be part of the next
+ * commit (or are "unstaged" in git jargon).
+ * @since 4.6
+ */
+ LocallyModifiedUnstagedVersion,
+ /**
+ * The file is not under version control and is listed
+ * in the ignore list of the version control system.
+ * @since 4.8
+ */
+ IgnoredVersion,
+ /**
+ * The file is is tracked by the version control system, but
+ * is missing in the directory (e.g. by deleted without using
+ * a version control command).
+ * @since 4.8
+ */
+ MissingVersion
+ };
+
+ KVersionControlPlugin(QObject* parent = 0);
+ virtual ~KVersionControlPlugin();
+
+ /**
+ * Returns the name of the file which stores
+ * the version controls information.
+ * (e. g. .svn, .cvs, .git).
+ */
+ virtual QString fileName() const = 0;
+
+ /**
+ * Is invoked whenever the version control
+ * information will get retrieved for the directory
+ * \p directory. It is assured that the directory
+ * contains a trailing slash.
+ */
+ virtual bool beginRetrieval(const QString& directory) = 0;
+
+ /**
+ * Is invoked after the version control information has been
+ * received. It is assured that
+ * KVersionControlPluginV2::beginInfoRetrieval() has been
+ * invoked before.
+ */
+ virtual void endRetrieval() = 0;
+
+ /**
+ * @return The version for the item \p item.
+ * It is assured that KVersionControlPlugin::beginInfoRetrieval() has been
+ * invoked before and that the file is part of the directory specified
+ * in beginInfoRetrieval().
+ */
+ virtual ItemVersion itemVersion(const KFileItem& item) const = 0;
+
+ /**
+ * @return List of actions that are available for the items \p items.
+ * It is recommended to keep the number of returned actions small
+ * in case if an item is an unversioned directory that is not
+ * inside the hierarchy tree of the version control system. This
+ * prevents having a cluttered context menu for directories
+ * outside the version control system.
+ */
+ virtual QList<QAction*> actions(const KFileItemList& items) const = 0;
+
+Q_SIGNALS:
+ /**
+ * Should be emitted when the version state of items might have been changed
+ * after the last retrieval (e. g. by executing a context menu action
+ * of the version control plugin). The file manager will be triggered to
+ * update the version states of the directory \p directory by invoking
+ * KVersionControlPlugin::beginRetrieval(),
+ * KVersionControlPlugin::itemVersion() and
+ * KVersionControlPlugin::endRetrieval().
+ */
+ void itemVersionsChanged();
+
+ /**
+ * Is emitted if an information message with the content \a msg
+ * should be shown.
+ */
+ void infoMessage(const QString& msg);
+
+ /**
+ * Is emitted if an error message with the content \a msg
+ * should be shown.
+ */
+ void errorMessage(const QString& msg);
+
+ /**
+ * Is emitted if an "operation completed" message with the content \a msg
+ * should be shown.
+ */
+ void operationCompletedMessage(const QString& msg);
+};
+
+#endif // KVERSIONCONTROLPLUGIN_H
+
diff --git a/src/views/versioncontrol/updateitemstatesthread.cpp b/src/views/versioncontrol/updateitemstatesthread.cpp
index 62fcd09aa..e4413fabf 100644
--- a/src/views/versioncontrol/updateitemstatesthread.cpp
+++ b/src/views/versioncontrol/updateitemstatesthread.cpp
@@ -19,8 +19,7 @@
#include "updateitemstatesthread.h"
-#include <kversioncontrolplugin2.h>
-
+#include <QVector>
#include <QMutexLocker>
UpdateItemStatesThread::UpdateItemStatesThread(KVersionControlPlugin* plugin,
@@ -52,17 +51,10 @@ void UpdateItemStatesThread::run()
if (m_plugin->beginRetrieval(it.key())) {
QVector<VersionControlObserver::ItemState>& items = it.value();
const int count = items.count();
-
- KVersionControlPlugin2* pluginV2 = qobject_cast<KVersionControlPlugin2*>(m_plugin);
- if (pluginV2) {
- for (int i = 0; i < count; ++i) {
- items[i].version = pluginV2->itemVersion(items[i].item);
- }
- } else {
- for (int i = 0; i < count; ++i) {
- const KVersionControlPlugin::VersionState state = m_plugin->versionState(items[i].item);
- items[i].version = static_cast<KVersionControlPlugin2::ItemVersion>(state);
- }
+ for (int i = 0; i < count; ++i) {
+ const KFileItem& item = items.at(i).first;
+ const KVersionControlPlugin::ItemVersion version = m_plugin->itemVersion(item);
+ items[i].second = version;
}
}
@@ -75,4 +67,3 @@ QMap<QString, QVector<VersionControlObserver::ItemState> > UpdateItemStatesThrea
return m_itemStates;
}
-#include "updateitemstatesthread.moc"
diff --git a/src/views/versioncontrol/updateitemstatesthread.h b/src/views/versioncontrol/updateitemstatesthread.h
index 5c6c6a208..3dc03fc75 100644
--- a/src/views/versioncontrol/updateitemstatesthread.h
+++ b/src/views/versioncontrol/updateitemstatesthread.h
@@ -20,20 +20,18 @@
#ifndef UPDATEITEMSTATESTHREAD_H
#define UPDATEITEMSTATESTHREAD_H
-#include <libdolphin_export.h>
+#include "dolphin_export.h"
#include <views/versioncontrol/versioncontrolobserver.h>
#include <QMutex>
#include <QThread>
-class KVersionControlPlugin;
-
/**
* The performance of updating the version state of items depends
* on the used plugin. To prevent that Dolphin gets blocked by a
* slow plugin, the updating is delegated to a thread.
*/
-class LIBDOLPHINPRIVATE_EXPORT UpdateItemStatesThread : public QThread
+class DOLPHIN_EXPORT UpdateItemStatesThread : public QThread
{
Q_OBJECT
@@ -53,7 +51,7 @@ public:
QMap<QString, QVector<VersionControlObserver::ItemState> > itemStates() const;
protected:
- virtual void run();
+ virtual void run() Q_DECL_OVERRIDE;
private:
QMutex* m_globalPluginMutex; // Protects the m_plugin globally
diff --git a/src/views/versioncontrol/versioncontrolobserver.cpp b/src/views/versioncontrol/versioncontrolobserver.cpp
index 6affe80d3..4b0d65029 100644
--- a/src/views/versioncontrol/versioncontrolobserver.cpp
+++ b/src/views/versioncontrol/versioncontrolobserver.cpp
@@ -21,16 +21,15 @@
#include "dolphin_versioncontrolsettings.h"
-#include <KLocale>
+#include <KLocalizedString>
#include <KService>
+#include "dolphindebug.h"
#include <KServiceTypeTrader>
#include <kitemviews/kfileitemmodel.h>
-#include <kversioncontrolplugin2.h>
#include "updateitemstatesthread.h"
#include <QFile>
-#include <QMutexLocker>
#include <QTimer>
VersionControlObserver::VersionControlObserver(QObject* parent) :
@@ -51,8 +50,8 @@ VersionControlObserver::VersionControlObserver(QObject* parent) :
m_dirVerificationTimer = new QTimer(this);
m_dirVerificationTimer->setSingleShot(true);
m_dirVerificationTimer->setInterval(500);
- connect(m_dirVerificationTimer, SIGNAL(timeout()),
- this, SLOT(verifyDirectory()));
+ connect(m_dirVerificationTimer, &QTimer::timeout,
+ this, &VersionControlObserver::verifyDirectory);
}
VersionControlObserver::~VersionControlObserver()
@@ -66,19 +65,19 @@ VersionControlObserver::~VersionControlObserver()
void VersionControlObserver::setModel(KFileItemModel* model)
{
if (m_model) {
- disconnect(m_model, SIGNAL(itemsInserted(KItemRangeList)),
- this, SLOT(delayedDirectoryVerification()));
- disconnect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
- this, SLOT(delayedDirectoryVerification()));
+ disconnect(m_model, &KFileItemModel::itemsInserted,
+ this, &VersionControlObserver::delayedDirectoryVerification);
+ disconnect(m_model, &KFileItemModel::itemsChanged,
+ this, &VersionControlObserver::delayedDirectoryVerification);
}
m_model = model;
if (model) {
- connect(m_model, SIGNAL(itemsInserted(KItemRangeList)),
- this, SLOT(delayedDirectoryVerification()));
- connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
- this, SLOT(delayedDirectoryVerification()));
+ connect(m_model, &KFileItemModel::itemsInserted,
+ this, &VersionControlObserver::delayedDirectoryVerification);
+ connect(m_model, &KFileItemModel::itemsChanged,
+ this, &VersionControlObserver::delayedDirectoryVerification);
}
}
@@ -89,42 +88,20 @@ KFileItemModel* VersionControlObserver::model() const
QList<QAction*> VersionControlObserver::actions(const KFileItemList& items) const
{
- QList<QAction*> actions;
-
bool hasNullItems = false;
foreach (const KFileItem& item, items) {
if (item.isNull()) {
- kWarning() << "Requesting version-control-actions for empty items";
+ qCWarning(DolphinDebug) << "Requesting version-control-actions for empty items";
hasNullItems = true;
break;
}
}
- if (!m_model || hasNullItems) {
- return actions;
- }
-
- KVersionControlPlugin2* pluginV2 = qobject_cast<KVersionControlPlugin2*>(m_plugin);
- if (pluginV2) {
- // Use version 2 of the KVersionControlPlugin which allows providing actions
- // also for non-versioned directories.
- actions = pluginV2->actions(items);
- } else if (isVersioned()) {
- // Support deprecated interfaces from KVersionControlPlugin version 1.
- // Context menu actions where only available for versioned directories.
- QString directory;
- if (items.count() == 1) {
- const KFileItem rootItem = m_model->rootItem();
- if (!rootItem.isNull() && items.first().url() == rootItem.url()) {
- directory = rootItem.url().path(KUrl::AddTrailingSlash);
- }
- }
-
- actions = directory.isEmpty() ? m_plugin->contextMenuActions(items)
- : m_plugin->contextMenuActions(directory);
+ if (!m_model || hasNullItems || !isVersioned()) {
+ return {};
}
- return actions;
+ return m_plugin->actions(items);
}
void VersionControlObserver::delayedDirectoryVerification()
@@ -156,20 +133,14 @@ void VersionControlObserver::verifyDirectory()
m_plugin = searchPlugin(rootItem.url());
if (m_plugin) {
- KVersionControlPlugin2* pluginV2 = qobject_cast<KVersionControlPlugin2*>(m_plugin);
- if (pluginV2) {
- connect(pluginV2, SIGNAL(itemVersionsChanged()),
- this, SLOT(silentDirectoryVerification()));
- } else {
- connect(m_plugin, SIGNAL(versionStatesChanged()),
- this, SLOT(silentDirectoryVerification()));
- }
- connect(m_plugin, SIGNAL(infoMessage(QString)),
- this, SIGNAL(infoMessage(QString)));
- connect(m_plugin, SIGNAL(errorMessage(QString)),
- this, SIGNAL(errorMessage(QString)));
- connect(m_plugin, SIGNAL(operationCompletedMessage(QString)),
- this, SIGNAL(operationCompletedMessage(QString)));
+ connect(m_plugin, &KVersionControlPlugin::itemVersionsChanged,
+ this, &VersionControlObserver::silentDirectoryVerification);
+ connect(m_plugin, &KVersionControlPlugin::infoMessage,
+ this, &VersionControlObserver::infoMessage);
+ connect(m_plugin, &KVersionControlPlugin::errorMessage,
+ this, &VersionControlObserver::errorMessage);
+ connect(m_plugin, &KVersionControlPlugin::operationCompletedMessage,
+ this, &VersionControlObserver::operationCompletedMessage);
if (!m_versionedDirectory) {
m_versionedDirectory = true;
@@ -204,9 +175,11 @@ void VersionControlObserver::slotThreadFinished()
const QVector<ItemState>& items = it.value();
foreach (const ItemState& item, items) {
+ const KFileItem& fileItem = item.first;
+ const KVersionControlPlugin::ItemVersion version = item.second;
QHash<QByteArray, QVariant> values;
- values.insert("version", QVariant(item.version));
- m_model->setData(m_model->index(item.item), values);
+ values.insert("version", QVariant(version));
+ m_model->setData(m_model->index(fileItem), values);
}
}
@@ -241,10 +214,10 @@ void VersionControlObserver::updateItemStates()
emit infoMessage(i18nc("@info:status", "Updating version information..."));
}
m_updateItemStatesThread = new UpdateItemStatesThread(m_plugin, itemStates);
- connect(m_updateItemStatesThread, SIGNAL(finished()),
- this, SLOT(slotThreadFinished()));
- connect(m_updateItemStatesThread, SIGNAL(finished()),
- m_updateItemStatesThread, SLOT(deleteLater()));
+ connect(m_updateItemStatesThread, &UpdateItemStatesThread::finished,
+ this, &VersionControlObserver::slotThreadFinished);
+ connect(m_updateItemStatesThread, &UpdateItemStatesThread::finished,
+ m_updateItemStatesThread, &UpdateItemStatesThread::deleteLater);
m_updateItemStatesThread->start(); // slotThreadFinished() is called when finished
}
@@ -265,8 +238,8 @@ int VersionControlObserver::createItemStatesList(QMap<QString, QVector<ItemState
if (expansionLevel == currentExpansionLevel) {
ItemState itemState;
- itemState.item = m_model->fileItem(index);
- itemState.version = KVersionControlPlugin2::UnversionedVersion;
+ itemState.first = m_model->fileItem(index);
+ itemState.second = KVersionControlPlugin::UnversionedVersion;
items.append(itemState);
} else if (expansionLevel > currentExpansionLevel) {
@@ -278,14 +251,14 @@ int VersionControlObserver::createItemStatesList(QMap<QString, QVector<ItemState
}
if (items.count() > 0) {
- const KUrl& url = items.first().item.url();
- itemStates.insert(url.directory(KUrl::AppendTrailingSlash), items);
+ const QUrl& url = items.first().first.url();
+ itemStates.insert(url.adjusted(QUrl::RemoveFilename).path(), items);
}
return index - firstIndex; // number of processed items
}
-KVersionControlPlugin* VersionControlObserver::searchPlugin(const KUrl& directory) const
+KVersionControlPlugin* VersionControlObserver::searchPlugin(const QUrl& directory) const
{
static bool pluginsAvailable = true;
static QList<KVersionControlPlugin*> plugins;
@@ -324,7 +297,7 @@ KVersionControlPlugin* VersionControlObserver::searchPlugin(const KUrl& director
// Verify whether the current directory contains revision information
// like .svn, .git, ...
foreach (KVersionControlPlugin* plugin, plugins) {
- const QString fileName = directory.path(KUrl::AddTrailingSlash) + plugin->fileName();
+ const QString fileName = directory.path() + '/' + plugin->fileName();
if (QFile::exists(fileName)) {
// The score of this plugin is 0 (best), so we can just return this plugin,
// instead of going through the plugin scoring procedure, we can't find a better one ;)
@@ -338,11 +311,11 @@ KVersionControlPlugin* VersionControlObserver::searchPlugin(const KUrl& director
// m_versionedDirectory. Drawback: Until e. g. Git is recognized, the root directory
// must be shown at least once.
if (m_versionedDirectory) {
- KUrl dirUrl(directory);
- KUrl upUrl = dirUrl.upUrl();
+ QUrl dirUrl(directory);
+ QUrl upUrl = KIO::upUrl(dirUrl);
int upUrlCounter = 1;
while ((upUrlCounter < bestScore) && (upUrl != dirUrl)) {
- const QString fileName = dirUrl.path(KUrl::AddTrailingSlash) + plugin->fileName();
+ const QString fileName = dirUrl.path() + '/' + plugin->fileName();
if (QFile::exists(fileName)) {
if (upUrlCounter < bestScore) {
bestPlugin = plugin;
@@ -351,7 +324,7 @@ KVersionControlPlugin* VersionControlObserver::searchPlugin(const KUrl& director
break;
}
dirUrl = upUrl;
- upUrl = dirUrl.upUrl();
+ upUrl = KIO::upUrl(dirUrl);
++upUrlCounter;
}
}
@@ -365,4 +338,3 @@ bool VersionControlObserver::isVersioned() const
return m_versionedDirectory && m_plugin;
}
-#include "versioncontrolobserver.moc"
diff --git a/src/views/versioncontrol/versioncontrolobserver.h b/src/views/versioncontrol/versioncontrolobserver.h
index d12d2cfe0..c817c2187 100644
--- a/src/views/versioncontrol/versioncontrolobserver.h
+++ b/src/views/versioncontrol/versioncontrolobserver.h
@@ -20,12 +20,14 @@
#ifndef VERSIONCONTROLOBSERVER_H
#define VERSIONCONTROLOBSERVER_H
-#include <libdolphin_export.h>
+#include "dolphin_export.h"
+
+#include "kversioncontrolplugin.h"
#include <KFileItem>
-#include <kversioncontrolplugin2.h>
+
+#include <QUrl>
#include <QList>
-#include <QMutex>
#include <QObject>
#include <QString>
@@ -43,7 +45,7 @@ class UpdateItemStatesThread;
*
* @see VersionControlPlugin
*/
-class LIBDOLPHINPRIVATE_EXPORT VersionControlObserver : public QObject
+class DOLPHIN_EXPORT VersionControlObserver : public QObject
{
Q_OBJECT
@@ -100,11 +102,7 @@ private slots:
void slotThreadFinished();
private:
- struct ItemState
- {
- KFileItem item;
- KVersionControlPlugin2::ItemVersion version;
- };
+ typedef QPair<KFileItem, KVersionControlPlugin::ItemVersion> ItemState;
void updateItemStates();
@@ -128,7 +126,7 @@ private:
* Returns a matching plugin for the given directory.
* 0 is returned, if no matching plugin has been found.
*/
- KVersionControlPlugin* searchPlugin(const KUrl& directory) const;
+ KVersionControlPlugin* searchPlugin(const QUrl& directory) const;
/**
* Returns true, if the directory contains a version control information.
diff --git a/src/views/viewmodecontroller.cpp b/src/views/viewmodecontroller.cpp
index 26e181888..28f9ea472 100644
--- a/src/views/viewmodecontroller.cpp
+++ b/src/views/viewmodecontroller.cpp
@@ -33,12 +33,12 @@ ViewModeController::~ViewModeController()
{
}
-KUrl ViewModeController::url() const
+QUrl ViewModeController::url() const
{
return m_url;
}
-void ViewModeController::redirectToUrl(const KUrl& url)
+void ViewModeController::redirectToUrl(const QUrl& url)
{
m_url = url;
}
@@ -76,7 +76,7 @@ int ViewModeController::zoomLevel() const
return m_zoomLevel;
}
-void ViewModeController::setUrl(const KUrl& url)
+void ViewModeController::setUrl(const QUrl& url)
{
if (m_url != url) {
m_url = url;
@@ -85,4 +85,3 @@ void ViewModeController::setUrl(const KUrl& url)
}
}
-#include "viewmodecontroller.moc"
diff --git a/src/views/viewmodecontroller.h b/src/views/viewmodecontroller.h
index f4765955b..4b1ff2083 100644
--- a/src/views/viewmodecontroller.h
+++ b/src/views/viewmodecontroller.h
@@ -20,9 +20,9 @@
#ifndef VIEWMODECONTROLLER_H
#define VIEWMODECONTROLLER_H
-#include <KUrl>
+#include <QUrl>
#include <QObject>
-#include <libdolphin_export.h>
+#include "dolphin_export.h"
#include <views/dolphinview.h>
/**
@@ -33,7 +33,7 @@
* connect to signals of the ViewModeController to react on changes. The view
* implementations get only read-access to the ViewModeController.
*/
-class LIBDOLPHINPRIVATE_EXPORT ViewModeController : public QObject
+class DOLPHIN_EXPORT ViewModeController : public QObject
{
Q_OBJECT
@@ -44,13 +44,13 @@ public:
/**
* @return URL that is shown by the view mode implementation.
*/
- KUrl url() const;
+ QUrl url() const;
/**
* Sets the URL to \a url and does nothing else. Called when
* a redirection happens. See ViewModeController::setUrl()
*/
- void redirectToUrl(const KUrl& url);
+ void redirectToUrl(const QUrl& url);
/**
* Informs the view mode implementation about a change of the activation
@@ -83,13 +83,13 @@ public slots:
* Sets the URL to \a url and emits the signals cancelPreviews() and
* urlChanged() if \a url is different for the current URL.
*/
- void setUrl(const KUrl& url);
+ void setUrl(const QUrl& url);
signals:
/**
* Is emitted if the URL has been changed by ViewModeController::setUrl().
*/
- void urlChanged(const KUrl& url);
+ void urlChanged(const QUrl& url);
/**
* Is emitted, if ViewModeController::indicateActivationChange() has been
@@ -118,7 +118,7 @@ signals:
private:
int m_zoomLevel;
QString m_nameFilter;
- KUrl m_url;
+ QUrl m_url;
};
#endif
diff --git a/src/views/viewproperties.cpp b/src/views/viewproperties.cpp
index d4ecfafa0..05c993585 100644
--- a/src/views/viewproperties.cpp
+++ b/src/views/viewproperties.cpp
@@ -23,15 +23,14 @@
#include "dolphin_directoryviewpropertysettings.h"
#include "dolphin_generalsettings.h"
-#include <KComponentData>
-#include <KLocale>
-#include <KStandardDirs>
-#include <KUrl>
+#include <QUrl>
+#include "dolphindebug.h"
#include <QCryptographicHash>
#include <QDate>
#include <QFile>
#include <QFileInfo>
+#include <QStandardPaths>
namespace {
const int AdditionalInfoViewPropertiesVersion = 1;
@@ -41,13 +40,13 @@ namespace {
// String representation to mark the additional properties of
// the details view as customized by the user. See
// ViewProperties::visibleRoles() for more information.
- const char* CustomizedDetailsString = "CustomizedDetails";
+ const char CustomizedDetailsString[] = "CustomizedDetails";
// Filename that is used for storing the properties
- const char* ViewPropertiesFileName = ".directory";
+ const char ViewPropertiesFileName[] = ".directory";
}
-ViewProperties::ViewProperties(const KUrl& url) :
+ViewProperties::ViewProperties(const QUrl& url) :
m_changedProps(false),
m_autoSave(true),
m_node(0)
@@ -61,10 +60,10 @@ ViewProperties::ViewProperties(const KUrl& url) :
// we store the properties information in a local file.
if (useGlobalViewProps) {
m_filePath = destinationDir("global");
- } else if (url.protocol().contains("search")) {
+ } else if (url.scheme().contains("search")) {
m_filePath = destinationDir("search/") + directoryHashForUrl(url);
useDetailsViewWithPath = true;
- } else if (url.protocol() == QLatin1String("trash")) {
+ } else if (url.scheme() == QLatin1String("trash")) {
m_filePath = destinationDir("trash");
useDetailsViewWithPath = true;
} else if (url.isLocalFile()) {
@@ -97,13 +96,13 @@ ViewProperties::ViewProperties(const KUrl& url) :
if (useDefaultProps) {
if (useDetailsViewWithPath) {
setViewMode(DolphinView::DetailsView);
- setVisibleRoles(QList<QByteArray>() << "path");
+ setVisibleRoles({"path"});
} else {
// The global view-properties act as default for directories without
// any view-property configuration. Constructing a ViewProperties
- // instance for an empty KUrl ensures that the global view-properties
+ // instance for an empty QUrl ensures that the global view-properties
// are loaded.
- KUrl emptyUrl;
+ QUrl emptyUrl;
ViewProperties defaultProps(emptyUrl);
setDirProperties(defaultProps);
@@ -285,8 +284,7 @@ QList<QByteArray> ViewProperties::visibleRoles() const
// by "CustomizedDetails"), also a details-view with no additional information
// is accepted.
- QList<QByteArray> roles;
- roles.append("text");
+ QList<QByteArray> roles{"text"};
// Iterate through all stored keys and append all roles that match to
// the current view mode.
@@ -361,10 +359,11 @@ void ViewProperties::update()
void ViewProperties::save()
{
- kDebug() << "Saving view-properties to" << m_filePath;
- KStandardDirs::makeDir(m_filePath);
+ qCDebug(DolphinDebug) << "Saving view-properties to" << m_filePath;
+ QDir dir;
+ dir.mkpath(m_filePath);
m_node->setVersion(CurrentViewPropertiesVersion);
- m_node->writeConfig();
+ m_node->save();
m_changedProps = false;
}
@@ -376,9 +375,9 @@ bool ViewProperties::exist() const
QString ViewProperties::destinationDir(const QString& subDir) const
{
- QString basePath = KGlobal::mainComponent().componentName();
- basePath.append("/view_properties/").append(subDir);
- return KStandardDirs::locateLocal("data", basePath);
+ QString path = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
+ path.append("/view_properties/").append(subDir);
+ return path;
}
QString ViewProperties::viewModePrefix() const
@@ -389,7 +388,7 @@ QString ViewProperties::viewModePrefix() const
case DolphinView::IconsView: prefix = "Icons_"; break;
case DolphinView::CompactView: prefix = "Compact_"; break;
case DolphinView::DetailsView: prefix = "Details_"; break;
- default: kWarning() << "Unknown view-mode of the view properties";
+ default: qCWarning(DolphinDebug) << "Unknown view-mode of the view properties";
}
return prefix;
@@ -461,18 +460,10 @@ bool ViewProperties::isPartOfHome(const QString& filePath)
return filePath.startsWith(homePath);
}
-QString ViewProperties::directoryHashForUrl(const KUrl& url)
+QString ViewProperties::directoryHashForUrl(const QUrl& url)
{
- const QByteArray hashValue = QCryptographicHash::hash(url.prettyUrl().toLatin1(),
- QCryptographicHash::Sha1);
+ const QByteArray hashValue = QCryptographicHash::hash(url.toEncoded(), QCryptographicHash::Sha1);
QString hashString = hashValue.toBase64();
hashString.replace('/', '-');
return hashString;
}
-
-KUrl ViewProperties::mirroredDirectory()
-{
- QString basePath = KGlobal::mainComponent().componentName();
- basePath.append("/view_properties/");
- return KUrl(KStandardDirs::locateLocal("data", basePath));
-}
diff --git a/src/views/viewproperties.h b/src/views/viewproperties.h
index 69b507f1b..dc118e2d7 100644
--- a/src/views/viewproperties.h
+++ b/src/views/viewproperties.h
@@ -22,8 +22,8 @@
#define VIEWPROPERTIES_H
#include <views/dolphinview.h>
-#include <KUrl>
-#include <libdolphin_export.h>
+#include <QUrl>
+#include "dolphin_export.h"
class ViewPropertySettings;
/**
@@ -35,7 +35,7 @@ class ViewPropertySettings;
* just construct an instance by passing the path of the directory:
*
* \code
- * ViewProperties props(KUrl("/home/peter/Documents"));
+ * ViewProperties props(QUrl::fromLocalFile("/home/peter/Documents"));
* const DolphinView::Mode mode = props.viewMode();
* const bool hiddenFilesShown = props.hiddenFilesShown();
* \endcode
@@ -47,10 +47,10 @@ class ViewPropertySettings;
* (see GeneralSettings::globalViewMode()), the values from the global .directory file
* are used for initialization.
*/
-class LIBDOLPHINPRIVATE_EXPORT ViewProperties
+class DOLPHIN_EXPORT ViewProperties
{
public:
- explicit ViewProperties(const KUrl& url);
+ explicit ViewProperties(const QUrl& url);
virtual ~ViewProperties();
void setViewMode(DolphinView::Mode mode);
@@ -162,16 +162,7 @@ private:
* @return A hash-value for an URL that can be used as directory name.
* Is used to be able to remember view-properties for long baloo-URLs.
*/
- static QString directoryHashForUrl(const KUrl& url);
-
- /**
- * Returns the URL of the directory, where the mirrored view properties
- * are stored into. Mirrored view properties are used if:
- * - there is no write access for storing the view properties into
- * the original directory
- * - for non local directories
- */
- static KUrl mirroredDirectory();
+ static QString directoryHashForUrl(const QUrl &url);
Q_DISABLE_COPY(ViewProperties)