]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/viewpropertiesdialog.cpp
don't trigger an item if the user does a selection by using the control- or shift...
[dolphin.git] / src / viewpropertiesdialog.cpp
index 3f440633f17b1dd30a9a1d3cdb2e80157fef97e7..48e565a0910157f800b411eeb3055527f6452af3 100644 (file)
  *   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.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
  ***************************************************************************/
 
 #include "viewpropertiesdialog.h"
 #include "viewpropsprogressinfo.h"
+#include "dolphinview.h"
+#include "dolphinsettings.h"
+#include "dolphinsortfilterproxymodel.h"
+#include "generalsettings.h"
+#include "viewproperties.h"
 
 #include <klocale.h>
 #include <kiconloader.h>
@@ -34,9 +39,6 @@
 #include <QRadioButton>
 #include <QVBoxLayout>
 
-#include "viewproperties.h"
-#include "dolphinview.h"
-
 ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
     KDialog(dolphinView),
     m_isDirty(false),
@@ -77,14 +79,10 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
     m_sorting->addItem("By Name");
     m_sorting->addItem("By Size");
     m_sorting->addItem("By Date");
-    int sortingIdx = 0;
-    switch (m_viewProps->sorting()) {
-        case DolphinView::SortByName: sortingIdx = 0; break;
-        case DolphinView::SortBySize: sortingIdx = 1; break;
-        case DolphinView::SortByDate: sortingIdx = 2; break;
-        default: break;
-    }
-    m_sorting->setCurrentIndex(sortingIdx);
+    m_sorting->addItem("By Permissions");
+    m_sorting->addItem("By Owner");
+    m_sorting->addItem("By Group");
+    m_sorting->setCurrentIndex(m_viewProps->sorting());
 
     QLabel* sortOrderLabel = new QLabel(i18n("Sort order:"), propsBox);
     m_sortOrder = new QComboBox(propsBox);
@@ -110,12 +108,7 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
     propsBoxLayout->addWidget(m_showPreview, 3, 0);
     propsBoxLayout->addWidget(m_showHiddenFiles, 4, 0);
 
-    m_applyToSubFolders = new QCheckBox(i18n("Apply changes to all sub folders"), main);
-    m_useAsDefault = new QCheckBox(i18n("Use as default"), main);
-
     topLayout->addWidget(propsBox);
-    topLayout->addWidget(m_applyToSubFolders);
-    topLayout->addWidget(m_useAsDefault);
 
     connect(m_viewMode, SIGNAL(activated(int)),
             this, SLOT(slotViewModeChanged(int)));
@@ -128,14 +121,23 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
     connect(m_showHiddenFiles, SIGNAL(clicked()),
             this, SLOT(slotShowHiddenFilesChanged()));
 
-    connect(m_applyToSubFolders, SIGNAL(clicked()),
-            this, SLOT(markAsDirty()));
-    connect(m_applyToSubFolders, SIGNAL(clicked()),
-            this, SLOT(markAsDirty()));
-
     connect(this, SIGNAL(okClicked()), this, SLOT(slotOk()));
     connect(this, SIGNAL(applyClicked()), this, SLOT(slotApply()));
 
+    // Only show the following settings if the view properties are remembered
+    // for each directory:
+    if (!DolphinSettings::instance().generalSettings()->globalViewProps()) {
+        m_applyToSubFolders = new QCheckBox(i18n("Apply changes to all sub folders"), main);
+        m_useAsDefault = new QCheckBox(i18n("Use as default"), main);
+        topLayout->addWidget(m_applyToSubFolders);
+        topLayout->addWidget(m_useAsDefault);
+
+        connect(m_applyToSubFolders, SIGNAL(clicked()),
+                this, SLOT(markAsDirty()));
+        connect(m_useAsDefault, SIGNAL(clicked()),
+                this, SLOT(markAsDirty()));
+    }
+
     main->setLayout(topLayout);
     setMainWidget(main);
 }
@@ -167,12 +169,7 @@ void ViewPropertiesDialog::slotViewModeChanged(int index)
 
 void ViewPropertiesDialog::slotSortingChanged(int index)
 {
-    DolphinView::Sorting sorting = DolphinView::SortByName;
-    switch (index) {
-        case 1: sorting = DolphinView::SortBySize; break;
-        case 2: sorting = DolphinView::SortByDate; break;
-        default: break;
-    }
+    const DolphinView::Sorting sorting = DolphinSortFilterProxyModel::sortingForColumn(index);
     m_viewProps->setSorting(sorting);
     m_isDirty = true;
 }
@@ -205,7 +202,10 @@ void ViewPropertiesDialog::markAsDirty()
 
 void ViewPropertiesDialog::applyViewProperties()
 {
-    if (m_applyToSubFolders->isChecked() && m_isDirty) {
+    const bool applyToSubFolders = m_isDirty &&
+                                   (m_applyToSubFolders != 0) &&
+                                   m_applyToSubFolders->isChecked();
+    if (applyToSubFolders) {
         const QString text(i18n("The view properties of all sub folders will be changed. Do you want to continue?"));
         if (KMessageBox::questionYesNo(this, text) == KMessageBox::No) {
             return;
@@ -219,7 +219,13 @@ void ViewPropertiesDialog::applyViewProperties()
     }
 
     m_viewProps->save();
-    m_dolphinView->setViewProperties(*m_viewProps);
+
+    m_dolphinView->setMode(m_viewProps->viewMode());
+    m_dolphinView->setSorting(m_viewProps->sorting());
+    m_dolphinView->setSortOrder(m_viewProps->sortOrder());
+    m_dolphinView->setShowPreview(m_viewProps->showPreview());
+    m_dolphinView->setShowHiddenFiles(m_viewProps->showHiddenFiles());
+
     m_isDirty = false;
 
     // TODO: handle m_useAsDefault setting