[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kde-baseapps/frameworks] dolphin/src: Port away from KGlobalSettings::naturalSorting() by moving it
From:       Emmanuel Pescosta <emmanuelpescosta099 () gmail ! com>
Date:       2015-01-31 20:10:22
Message-ID: E1YHeN4-0004N8-TT () scm ! kde ! org
[Download RAW message or body]

Git commit 298d307055de6bab23f7e1d17e66a11ef39f2035 by Emmanuel Pescosta.
Committed on 30/01/2015 at 12:08.
Pushed by emmanuelp into branch 'frameworks'.

Port away from KGlobalSettings::naturalSorting() by moving it to Dolphin's \
GeneralSettings

REVIEW: 122310

M  +2    -2    dolphin/src/CMakeLists.txt
M  +5    -4    dolphin/src/kitemviews/kfileitemmodel.cpp
M  +6    -0    dolphin/src/settings/dolphin_generalsettings.kcfg
M  +2    -8    dolphin/src/settings/general/behaviorsettingspage.cpp
M  +17   -1    dolphin/src/tests/CMakeLists.txt

http://commits.kde.org/kde-baseapps/298d307055de6bab23f7e1d17e66a11ef39f2035

diff --git a/dolphin/src/CMakeLists.txt b/dolphin/src/CMakeLists.txt
index d2ea493..748b093 100644
--- a/dolphin/src/CMakeLists.txt
+++ b/dolphin/src/CMakeLists.txt
@@ -81,7 +81,7 @@ if(HAVE_BALOO)
     )
 endif()
 
-kconfig_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
@@ -204,7 +204,7 @@ set(dolphin_SRCS
     views/zoomlevelinfo.cpp
 )
 
-kconfig_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
diff --git a/dolphin/src/kitemviews/kfileitemmodel.cpp \
b/dolphin/src/kitemviews/kfileitemmodel.cpp index 98249db..0198912 100644
--- a/dolphin/src/kitemviews/kfileitemmodel.cpp
+++ b/dolphin/src/kitemviews/kfileitemmodel.cpp
@@ -21,7 +21,8 @@
 
 #include "kfileitemmodel.h"
 
-#include <KGlobalSettings>
+#include "dolphin_generalsettings.h"
+
 #include <KLocalizedString>
 #include <KStringHandler>
 #include <KDebug>
@@ -41,7 +42,7 @@
 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),
@@ -106,7 +107,7 @@ KFileItemModel::KFileItemModel(QObject* parent) :
     m_resortAllItemsTimer->setSingleShot(true);
     connect(m_resortAllItemsTimer, &QTimer::timeout, this, \
&KFileItemModel::resortAllItems);  
-    connect(KGlobalSettings::self(), &KGlobalSettings::naturalSortingChanged,
+    connect(GeneralSettings::self(), &GeneralSettings::naturalSortingChanged,
             this, &KFileItemModel::slotNaturalSortingChanged);
 }
 
@@ -1105,7 +1106,7 @@ void KFileItemModel::slotClear()
 
 void KFileItemModel::slotNaturalSortingChanged()
 {
-    m_naturalSorting = KGlobalSettings::naturalSorting();
+    m_naturalSorting = GeneralSettings::naturalSorting();
     resortAllItems();
 }
 
diff --git a/dolphin/src/settings/dolphin_generalsettings.kcfg \
b/dolphin/src/settings/dolphin_generalsettings.kcfg index 3c820e2..2f230bf 100644
--- a/dolphin/src/settings/dolphin_generalsettings.kcfg
+++ b/dolphin/src/settings/dolphin_generalsettings.kcfg
@@ -8,6 +8,7 @@
     <include>QUrl</include>
     <include>kglobalsettings.h</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>
@@ -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/dolphin/src/settings/general/behaviorsettingspage.cpp \
b/dolphin/src/settings/general/behaviorsettingspage.cpp index 83515be..093a1f4 100644
--- a/dolphin/src/settings/general/behaviorsettingspage.cpp
+++ b/dolphin/src/settings/general/behaviorsettingspage.cpp
@@ -97,6 +97,7 @@ void BehaviorSettingsPage::applySettings()
 
     settings->setShowToolTips(m_showToolTips->isChecked());
     settings->setShowSelectionToggle(m_showSelectionToggle->isChecked());
+    settings->setNaturalSorting(m_naturalSorting->isChecked());
     settings->setRenameInline(m_renameInline->isChecked());
     settings->save();
 
@@ -108,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(KSharedConfig::openConfig(), "KDE");
-        group.writeEntry("NaturalSorting", naturalSorting, KConfig::Persistent | \
                KConfig::Global);
-        KGlobalSettings::emitChange(KGlobalSettings::NaturalSortingChanged);
-    }
 }
 
 void BehaviorSettingsPage::restoreDefaults()
@@ -133,7 +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());
 }
 
diff --git a/dolphin/src/tests/CMakeLists.txt b/dolphin/src/tests/CMakeLists.txt
index a69400b..fe9665d 100644
--- a/dolphin/src/tests/CMakeLists.txt
+++ b/dolphin/src/tests/CMakeLists.txt
@@ -58,6 +58,10 @@ set(kitemlistcontrollertest_SRCS
     ../kitemviews/kstandarditemlistwidget.cpp
 )
 
+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)
@@ -79,6 +83,10 @@ set(kfileitemlistviewtest_SRCS
     ../kitemviews/kstandarditemlistwidget.cpp
 )
 
+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)
@@ -93,6 +101,10 @@ set(kfileitemmodeltest_SRCS
     ../kitemviews/kitemset.cpp
 )
 
+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)
@@ -106,6 +118,10 @@ set(kfileitemmodelbenchmark_SRCS
     ../kitemviews/kitemmodelbase.cpp
 )
 
+kconfig_add_kcfg_files(kfileitemmodelbenchmark_SRCS GENERATE_MOC
+    ../settings/dolphin_generalsettings.kcfgc
+)
+
 add_executable(kfileitemmodelbenchmark ${kfileitemmodelbenchmark_SRCS})
 ecm_mark_as_test(kfileitemmodelbenchmark)
 target_link_libraries(kfileitemmodelbenchmark dolphinprivate Qt5::Test)
@@ -157,7 +173,7 @@ set(viewpropertiestest_SRCS
     testdir.cpp
     ../views/viewproperties.cpp
 )
-kconfig_add_kcfg_files(viewpropertiestest_SRCS
+kconfig_add_kcfg_files(viewpropertiestest_SRCS GENERATE_MOC
   ../settings/dolphin_generalsettings.kcfgc
   ../settings/dolphin_directoryviewpropertysettings.kcfgc
 )


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic