]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/settings/viewpropertiesdialog.cpp
Interface cleanups to prepare the return of "grouped sorting"
[dolphin.git] / src / settings / viewpropertiesdialog.cpp
index f407f7c9029577391b1b8e553ab74cb286e0fc0c..7c4414ea24d8f3cc826a6f192d2fef6bf5fc8fce 100644 (file)
 #include "viewpropertiesdialog.h"
 
 #include "additionalinfodialog.h"
-#include "dolphinview.h"
+#include "views/dolphinview.h"
 #include "settings/dolphinsettings.h"
-#include "dolphinsortfilterproxymodel.h"
 #include "dolphin_generalsettings.h"
 #include "dolphin_iconsmodesettings.h"
-#include "viewproperties.h"
 #include "viewpropsprogressinfo.h"
 
 #include <config-nepomuk.h>
 #ifdef HAVE_NEPOMUK
-#include <nepomuk/resourcemanager.h>
+#include <Nepomuk/ResourceManager>
 #endif
 
-#include <kcomponentdata.h>
-#include <klocale.h>
-#include <kiconloader.h>
-#include <kio/netaccess.h>
-#include <kmessagebox.h>
-#include <kstandarddirs.h>
-#include <kurl.h>
-#include <kcombobox.h>
+#include <KComponentData>
+#include <KLocale>
+#include <KIconLoader>
+#include <KIO/NetAccess>
+#include <KMessageBox>
+#include <KStandardDirs>
+#include <KUrl>
+#include <KComboBox>
 
 #include <QAction>
 #include <QButtonGroup>
@@ -54,6 +52,8 @@
 #include <QRadioButton>
 #include <QBoxLayout>
 
+#include <views/viewproperties.h>
+
 ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
     KDialog(dolphinView),
     m_isDirty(false),
@@ -62,7 +62,8 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
     m_viewMode(0),
     m_sortOrder(0),
     m_sorting(0),
-    m_showPreview(0),
+    m_sortFoldersFirst(0),
+    m_previewsShown(0),
     m_showInGroups(0),
     m_showHiddenFiles(0),
     m_additionalInfo(0),
@@ -71,7 +72,7 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
     m_applyToAllFolders(0),
     m_useAsDefault(0)
 {
-    Q_ASSERT(dolphinView != 0);
+    Q_ASSERT(dolphinView);
     const bool useGlobalViewProps = DolphinSettings::instance().generalSettings()->globalViewProps();
 
     setCaption(i18nc("@title:window", "View Properties"));
@@ -95,8 +96,8 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
     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"));
-    m_viewMode->addItem(KIcon("view-list-details"), i18nc("@item:inlistbox", "Details"));
-    m_viewMode->addItem(KIcon("view-file-columns"), i18nc("@item:inlistbox", "Column"));
+    m_viewMode->addItem(KIcon("view-list-details"), i18nc("@item:inlistbox", "Compact"));
+    m_viewMode->addItem(KIcon("view-list-tree"), i18nc("@item:inlistbox", "Details"));
 
     QLabel* sortingLabel = new QLabel(i18nc("@label:listbox", "Sorting:"), propsGrid);
     QWidget* sortingBox = new QWidget(propsGrid);
@@ -122,7 +123,8 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
     //    m_sorting->addItem(i18nc("@item:inlistbox Sort", "By Tags"));
     // }
 #endif
-    m_showPreview = new QCheckBox(i18nc("@option:check", "Show preview"));
+    m_sortFoldersFirst = new QCheckBox(i18nc("@option:check", "Show folders first"));
+    m_previewsShown = new QCheckBox(i18nc("@option:check", "Show preview"));
     m_showInGroups = new QCheckBox(i18nc("@option:check", "Show in groups"));
     m_showHiddenFiles = new QCheckBox(i18nc("@option:check", "Show hidden files"));
 
@@ -142,7 +144,8 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
 
     QVBoxLayout* propsBoxLayout = new QVBoxLayout(propsBox);
     propsBoxLayout->addWidget(propsGrid);
-    propsBoxLayout->addWidget(m_showPreview);
+    propsBoxLayout->addWidget(m_sortFoldersFirst);
+    propsBoxLayout->addWidget(m_previewsShown);
     propsBoxLayout->addWidget(m_showInGroups);
     propsBoxLayout->addWidget(m_showHiddenFiles);
     propsBoxLayout->addWidget(m_additionalInfo);
@@ -157,7 +160,9 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
             this, SLOT(slotSortOrderChanged(int)));
     connect(m_additionalInfo, SIGNAL(clicked()),
             this, SLOT(configureAdditionalInfo()));
-    connect(m_showPreview, SIGNAL(clicked()),
+    connect(m_sortFoldersFirst, SIGNAL(clicked()),
+            this, SLOT(slotSortFoldersFirstChanged()));
+    connect(m_previewsShown, SIGNAL(clicked()),
             this, SLOT(slotShowPreviewChanged()));
     connect(m_showInGroups, SIGNAL(clicked()),
             this, SLOT(slotCategorizedSortingChanged()));
@@ -177,7 +182,7 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
                                                         "Current folder"), applyBox);
         m_applyToCurrentFolder->setChecked(true);
         m_applyToSubFolders = new QRadioButton(i18nc("@option:radio Apply View Properties To",
-                                                     "Current folder including all sub folders"), applyBox);
+                                                     "Current folder including all sub-folders"), applyBox);
         m_applyToAllFolders = new QRadioButton(i18nc("@option:radio Apply View Properties To",
                                                      "All folders"), applyBox);
 
@@ -191,7 +196,7 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
         applyBoxLayout->addWidget(m_applyToSubFolders);
         applyBoxLayout->addWidget(m_applyToAllFolders);
 
-        m_useAsDefault = new QCheckBox(i18nc("@option:check", "Use as default for new folders"), main);
+        m_useAsDefault = new QCheckBox(i18nc("@option:check", "Use these view properties as default"), main);
 
         topLayout->addWidget(applyBox);
         topLayout->addWidget(m_useAsDefault);
@@ -243,17 +248,15 @@ void ViewPropertiesDialog::slotViewModeChanged(int index)
 {
     m_viewProps->setViewMode(static_cast<DolphinView::Mode>(index));
     markAsDirty(true);
-
-    const DolphinView::Mode mode = m_viewProps->viewMode();
-    m_showInGroups->setEnabled(mode == DolphinView::IconsView);
-    m_additionalInfo->setEnabled(mode != DolphinView::ColumnView);
 }
 
 void ViewPropertiesDialog::slotSortingChanged(int index)
 {
-    const DolphinView::Sorting sorting = DolphinSortFilterProxyModel::sortingForColumn(index);
-    m_viewProps->setSorting(sorting);
-    markAsDirty(true);
+    Q_UNUSED(index);
+    Q_ASSERT(false);
+    //const DolphinView::Sorting sorting = DolphinSortFilterProxyModel::sortingForColumn(index);
+    //m_viewProps->setSorting(sorting);
+    //markAsDirty(true);
 }
 
 void ViewPropertiesDialog::slotSortOrderChanged(int index)
@@ -265,21 +268,28 @@ void ViewPropertiesDialog::slotSortOrderChanged(int index)
 
 void ViewPropertiesDialog::slotCategorizedSortingChanged()
 {
-    m_viewProps->setCategorizedSorting(m_showInGroups->isChecked());
+    m_viewProps->setGroupedSorting(m_showInGroups->isChecked());
+    markAsDirty(true);
+}
+
+void ViewPropertiesDialog::slotSortFoldersFirstChanged()
+{
+    const bool foldersFirst = m_sortFoldersFirst->isChecked();
+    m_viewProps->setSortFoldersFirst(foldersFirst);
     markAsDirty(true);
 }
 
 void ViewPropertiesDialog::slotShowPreviewChanged()
 {
-    const bool show = m_showPreview->isChecked();
-    m_viewProps->setShowPreview(show);
+    const bool show = m_previewsShown->isChecked();
+    m_viewProps->setPreviewsShown(show);
     markAsDirty(true);
 }
 
 void ViewPropertiesDialog::slotShowHiddenFilesChanged()
 {
     const bool show = m_showHiddenFiles->isChecked();
-    m_viewProps->setShowHiddenFiles(show);
+    m_viewProps->setHiddenFilesShown(show);
     markAsDirty(true);
 }
 
@@ -291,24 +301,25 @@ void ViewPropertiesDialog::markAsDirty(bool isDirty)
 
 void ViewPropertiesDialog::configureAdditionalInfo()
 {
-    KFileItemDelegate::InformationList info = m_viewProps->additionalInfo();
+    QList<DolphinView::AdditionalInfo> infoList = m_viewProps->additionalInfoList();
     const bool useDefaultInfo = (m_viewProps->viewMode() == DolphinView::DetailsView) &&
-                                (info.isEmpty() || info.contains(KFileItemDelegate::NoInformation));
+                                (infoList.isEmpty() || infoList.contains(DolphinView::NoInfo));
     if (useDefaultInfo) {
         // Using the details view without any additional information (-> additional column)
         // makes no sense and leads to a usability problem as no viewport area is available
         // anymore. Hence as fallback provide at least a size and date column.
-        info.clear();
-        info.append(KFileItemDelegate::Size);
-        info.append(KFileItemDelegate::ModificationTime);
-        m_viewProps->setAdditionalInfo(info);
+        infoList.clear();
+        infoList.append(DolphinView::SizeInfo);
+        infoList.append(DolphinView::DateInfo);
+        m_viewProps->setAdditionalInfoList(infoList);
     }
 
-    AdditionalInfoDialog dialog(this, info);
-    if (dialog.exec() == QDialog::Accepted) {
-        m_viewProps->setAdditionalInfo(dialog.additionalInfo());
+    QPointer<AdditionalInfoDialog> dialog = new AdditionalInfoDialog(this, infoList);
+    if (dialog->exec() == QDialog::Accepted) {
+        m_viewProps->setAdditionalInfoList(dialog->informationList());
         markAsDirty(true);
     }
+    delete dialog;
 }
 
 void ViewPropertiesDialog::applyViewProperties()
@@ -318,10 +329,9 @@ void ViewPropertiesDialog::applyViewProperties()
         return;
     }
 
-    const bool applyToSubFolders = (m_applyToSubFolders != 0) &&
-                                   m_applyToSubFolders->isChecked();
+    const bool applyToSubFolders = m_applyToSubFolders && m_applyToSubFolders->isChecked();
     if (applyToSubFolders) {
-        const QString text(i18nc("@info", "The view properties of all sub folders will be changed. Do you want to continue?"));
+        const QString text(i18nc("@info", "The view properties of all sub-folders will be changed. Do you want to continue?"));
         if (KMessageBox::questionYesNo(this, text) == KMessageBox::No) {
             return;
         }
@@ -334,13 +344,11 @@ void ViewPropertiesDialog::applyViewProperties()
         info->show();
     }
 
-    const bool applyToAllFolders = (m_applyToAllFolders != 0) &&
-                                   m_applyToAllFolders->isChecked();
+    const bool applyToAllFolders = m_applyToAllFolders && m_applyToAllFolders->isChecked();
 
     // If the user selected 'Apply To All Folders' the view properties implicitely
     // are also used as default for new folders.
-    const bool useAsDefault = applyToAllFolders ||
-                              ((m_useAsDefault != 0) && m_useAsDefault->isChecked());
+    const bool useAsDefault = applyToAllFolders || (m_useAsDefault && m_useAsDefault->isChecked());
     if (useAsDefault) {
         // For directories where no .directory file is available, the .directory
         // file stored for the global view properties is used as fallback. To update
@@ -370,10 +378,11 @@ void ViewPropertiesDialog::applyViewProperties()
     m_dolphinView->setMode(m_viewProps->viewMode());
     m_dolphinView->setSorting(m_viewProps->sorting());
     m_dolphinView->setSortOrder(m_viewProps->sortOrder());
-    m_dolphinView->setCategorizedSorting(m_viewProps->categorizedSorting());
-    m_dolphinView->setAdditionalInfo(m_viewProps->additionalInfo());
-    m_dolphinView->setShowPreview(m_viewProps->showPreview());
-    m_dolphinView->setShowHiddenFiles(m_viewProps->showHiddenFiles());
+    m_dolphinView->setSortFoldersFirst(m_viewProps->sortFoldersFirst());
+    m_dolphinView->setGroupedSorting(m_viewProps->groupedSorting());
+    m_dolphinView->setAdditionalInfoList(m_viewProps->additionalInfoList());
+    m_dolphinView->setPreviewsShown(m_viewProps->previewsShown());
+    m_dolphinView->setHiddenFilesShown(m_viewProps->hiddenFilesShown());
 
     m_viewProps->save();
 
@@ -395,13 +404,14 @@ void ViewPropertiesDialog::loadSettings()
                          (index == DolphinView::IconsView);
     m_additionalInfo->setEnabled(enabled);
 
+    m_sortFoldersFirst->setChecked(m_viewProps->sortFoldersFirst());
     // load show preview, show in groups and show hidden files settings
-    m_showPreview->setChecked(m_viewProps->showPreview());
+    m_previewsShown->setChecked(m_viewProps->previewsShown());
 
-    m_showInGroups->setChecked(m_viewProps->categorizedSorting());
+    m_showInGroups->setChecked(m_viewProps->groupedSorting());
     m_showInGroups->setEnabled(index == DolphinView::IconsView); // only the icons view supports categorized sorting
 
-    m_showHiddenFiles->setChecked(m_viewProps->showHiddenFiles());
+    m_showHiddenFiles->setChecked(m_viewProps->hiddenFilesShown());
     markAsDirty(false);
 }