]> cloud.milkyroute.net Git - dolphin.git/commitdiff
First step of cleaning up the view properties: inheriting of viewproperties does...
authorPeter Penz <peter.penz19@gmail.com>
Mon, 4 Dec 2006 06:37:20 +0000 (06:37 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Mon, 4 Dec 2006 06:37:20 +0000 (06:37 +0000)
svn path=/trunk/playground/utils/dolphin/; revision=610383

src/directoryviewpropertysettings.kcfg
src/viewproperties.cpp
src/viewproperties.h
src/viewpropertiesdialog.cpp

index 7af729d2884dabe304d719eef32e079043addc13..247b8181bc6bdbe73fac9506c049d7f9a963bff3 100644 (file)
@@ -5,55 +5,43 @@
       http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
 
 <kcfgfile arg="true" />
-
-<group name="Settings">
-
-<entry name="ShowHiddenFiles" key="ShowDotFiles" type="Bool" >
-      <label>Show hidden files</label>
-      <whatsthis>When this option is enabled hidden files, such as those starting with a '.', will be shown in the file view.</whatsthis>
-      <default>false</default>
-   </entry>
-
-</group>
-
-<group name="Dolphin">
-
-<entry name="ViewMode" type="Int" >
-      <label>View Mode</label>
-      <whatsthis>This option controls the style of the view. Currently supported values include icons (0), details (1) and previews (2) views.</whatsthis>
-      <default>DolphinView::PreviewsView</default>
-      <min>0</min>
-      <max code="true">DolphinView::MaxModeEnum</max>
-   </entry>
-
-<entry name="Sorting" type="Int" >
-      <label>Sort files by</label>
-      <whatsthis>This option defines which attribute (name, size, date, etc) sorting is performed on.</whatsthis>
-      <default code="true">DolphinView::SortByName</default>
-      <min>0</min>
-      <max code="true">DolphinView::MaxSortEnum</max>
-   </entry>
-
-<entry name="SortOrder" type="Int" >
-      <label>Order to sort files in</label>
-      <default code="true">Qt::Ascending</default>
-      <min code="true">Qt::Ascending</min>
-      <max code="true">Qt::Descending</max>
-   </entry>
-
-<entry name="ValidForSubDirs" type="Bool" >
-      <label>Apply view setting to sub-directories</label>
-      <default>false</default>
-   </entry>
-
-
-<entry name="Timestamp" type="DateTime" >
-      <label>Properties last changed</label>
-      <whatsthis>The last time these properties were changed by the user.</whatsthis>
-   </entry>
-
-</group>
-
+    <group name="Settings">
+        <entry name="ShowHiddenFiles" key="ShowDotFiles" type="Bool" >
+            <label>Show hidden files</label>
+            <whatsthis>When this option is enabled hidden files, such as those starting with a '.', will be shown in the file view.</whatsthis>
+            <default>false</default>
+        </entry>
+    </group>
+
+    <group name="Dolphin">
+        <entry name="ViewMode" type="Int" >
+            <label>View Mode</label>
+            <whatsthis>This option controls the style of the view. Currently supported values include icons (0), details (1) and previews (2) views.</whatsthis>
+            <default>DolphinView::PreviewsView</default>
+            <min>0</min>
+            <max code="true">DolphinView::MaxModeEnum</max>
+        </entry>
+
+        <entry name="Sorting" type="Int" >
+            <label>Sort files by</label>
+            <whatsthis>This option defines which attribute (name, size, date, etc) sorting is performed on.</whatsthis>
+            <default code="true">DolphinView::SortByName</default>
+            <min>0</min>
+            <max code="true">DolphinView::MaxSortEnum</max>
+        </entry>
+
+        <entry name="SortOrder" type="Int" >
+            <label>Order to sort files in</label>
+            <default code="true">Qt::Ascending</default>
+            <min code="true">Qt::Ascending</min>
+            <max code="true">Qt::Descending</max>
+        </entry>
+
+        <entry name="Timestamp" type="DateTime" >
+            <label>Properties last changed</label>
+            <whatsthis>The last time these properties were changed by the user.</whatsthis>
+        </entry>
+    </group>
 </kcfg>
 
 
index a3a8ec46bbf16d3671bbad4821d71711733fdc0e..d099b3b22d48e244ba8eed9cd030f599e793677f 100644 (file)
 
 #define FILE_NAME "/.directory"
 
-ViewProperties::ViewProperties(KUrl url) :
+ViewProperties::ViewProperties(const KUrl& url) :
       m_changedProps(false),
       m_autoSave(true),
-      m_subDirValidityHidden(false),
       m_node(0)
 {
-    url.cleanPath();
-    m_filepath = url.path();
+    KUrl cleanUrl(url);
+
+    cleanUrl.cleanPath();
+    m_filepath = cleanUrl.path();
 
     if ((m_filepath.length() < 1) || (m_filepath.at(0) != QChar('/'))) {
         m_node = new ViewPropertySettings();
@@ -53,7 +54,7 @@ ViewProperties::ViewProperties(KUrl url) :
     // if the directory is not writable by the user or the directory is not local
     // we store the properties information in a local file
     QString rootDir("/"); // TODO: should this be set to the root of the bookmark, if any?
-    if (url.isLocalFile()) {
+    if (cleanUrl.isLocalFile()) {
         QFileInfo info(m_filepath);
 
         if (!info.isWritable()) {
@@ -65,37 +66,12 @@ ViewProperties::ViewProperties(KUrl url) :
     }
     else {
         QString basePath = KGlobal::instance()->instanceName();
-        basePath.append("/view_properties/remote/").append(url.host());
+        basePath.append("/view_properties/remote/").append(cleanUrl.host());
         rootDir = KStandardDirs::locateLocal("data", basePath);
         m_filepath = rootDir + m_filepath;
     }
 
     m_node = new ViewPropertySettings(KSharedConfig::openConfig(m_filepath + FILE_NAME));
-
-    QDir dir(m_filepath);
-    const bool isValidForSubDirs = m_node->validForSubDirs();
-    while ((dir.path() != rootDir) && dir.cdUp()) {
-        QString parentPath(dir.path() + FILE_NAME);
-
-        if (!QFile::exists(parentPath))
-        {
-            continue;
-        }
-
-        ViewPropertySettings parentNode(KSharedConfig::openConfig(dir.path() + FILE_NAME));
-        const bool inheritProps = parentNode.validForSubDirs() &&
-                                  (parentNode.timestamp() > m_node->timestamp());
-
-        if (inheritProps) {
-            delete m_node;
-            m_node = new ViewPropertySettings(KSharedConfig::openConfig(dir.path() + FILE_NAME));
-            break;
-        }
-    }
-
-    if (isValidForSubDirs) {
-        m_subDirValidityHidden = true;
-    }
 }
 
 ViewProperties::~ViewProperties()
@@ -105,6 +81,7 @@ ViewProperties::~ViewProperties()
     }
 
     delete m_node;
+    m_node = 0;
 }
 
 void ViewProperties::setViewMode(DolphinView::Mode mode)
@@ -159,19 +136,6 @@ Qt::SortOrder ViewProperties::sortOrder() const
     return static_cast<Qt::SortOrder>(m_node->sortOrder());
 }
 
-void ViewProperties::setValidForSubDirs(bool valid)
-{
-    if (m_node->validForSubDirs() != valid) {
-        m_node->setValidForSubDirs(valid);
-        updateTimeStamp();
-    }
-}
-
-bool ViewProperties::isValidForSubDirs() const
-{
-    return m_node->validForSubDirs();
-}
-
 void ViewProperties::setAutoSaveEnabled(bool autoSave)
 {
     m_autoSave = autoSave;
@@ -195,16 +159,12 @@ void ViewProperties::save()
     m_changedProps = false;
 }
 
-ViewProperties& ViewProperties::operator = (const ViewProperties& props)
+ViewProperties::ViewProperties(const ViewProperties& props)
 {
-    if (&props != this) {
-        m_changedProps = props.m_changedProps;
-        m_autoSave = props.m_autoSave;
-        m_subDirValidityHidden = props.m_subDirValidityHidden;
-        m_filepath = props.m_filepath;
-        m_node = new ViewPropertySettings();
-        //*m_node = *(props.m_node);
-    }
+    assert(false);
+}
 
-    return *this;
+ViewProperties& ViewProperties::operator = (const ViewProperties& props)
+{
+    assert(false);
 }
index 98d5a94b286595d52bc6ad1fa3e44066d327e85b..7f57f2eed205f17b4978acc027cc88106643a9a9 100644 (file)
@@ -50,7 +50,7 @@ class QFile;
 class ViewProperties
 {
 public:
-    ViewProperties(KUrl url);
+    ViewProperties(const KUrl& url);
     virtual ~ViewProperties();
 
     void setViewMode(DolphinView::Mode mode);
@@ -65,23 +65,21 @@ public:
     void setSortOrder(Qt::SortOrder sortOrder);
     Qt::SortOrder sortOrder() const;
 
-    void setValidForSubDirs(bool valid);
-    bool isValidForSubDirs() const;
-
     void setAutoSaveEnabled(bool autoSave);
     bool isAutoSaveEnabled() const;
 
     void updateTimeStamp();
     void save();
 
-    ViewProperties& operator = (const ViewProperties& props);
 
 private:
     bool m_changedProps;
     bool m_autoSave;
-    bool m_subDirValidityHidden;
     QString m_filepath;
     ViewPropertySettings* m_node;
+
+    ViewProperties(const ViewProperties& props);
+    ViewProperties& operator= (const ViewProperties& props);
 };
 
 #endif
index 82f3c5976839b85567a1fd58ae6c84201e79757b..594c487d2e64bdf28815d2eec11435587d6f5385 100644 (file)
@@ -110,12 +110,7 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
     buttonBoxLayout->addWidget(m_applyToAllFolders);
     buttonBox->setLayout(buttonBoxLayout);
 
-    if (m_viewProps->isValidForSubDirs()) {
-        m_applyToSubFolders->setChecked(true);
-    }
-    else {
-        m_applyToCurrentFolder->setChecked(true);
-    }
+    m_applyToCurrentFolder->setChecked(true);
 
     topLayout->addWidget(propsBox);
     topLayout->addWidget(buttonBox);
@@ -135,6 +130,9 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
     connect(m_applyToAllFolders, SIGNAL(clicked()),
             this, SLOT(slotApplyToAllFolders()));
 
+    connect(this, SIGNAL(okClicked()), this, SLOT(slotOk()));
+    connect(this, SIGNAL(applyClicked()), this, SLOT(slotApply()));
+
     main->setLayout(topLayout);
     setMainWidget(main);
 }
@@ -149,13 +147,12 @@ ViewPropertiesDialog::~ViewPropertiesDialog()
 void ViewPropertiesDialog::slotOk()
 {
     applyViewProperties();
-    // KDE4-TODO: KDialog::slotOk();
+    accept();
 }
 
 void ViewPropertiesDialog::slotApply()
 {
     applyViewProperties();
-    // KDE4-TODO: KDialog::slotApply();
 }
 
 void ViewPropertiesDialog::slotViewModeChanged(int index)
@@ -193,13 +190,12 @@ void ViewPropertiesDialog::slotShowHiddenFilesChanged()
 
 void ViewPropertiesDialog::slotApplyToCurrentFolder()
 {
-    m_viewProps->setValidForSubDirs(false);
     m_isDirty = true;
 }
 
 void ViewPropertiesDialog::slotApplyToSubFolders()
 {
-    m_viewProps->setValidForSubDirs(true);
+    //m_viewProps->setValidForSubDirs(true);
     m_isDirty = true;
 }
 
@@ -223,7 +219,7 @@ void ViewPropertiesDialog::applyViewProperties()
         props.setSorting(m_viewProps->sorting());
         props.setSortOrder(m_viewProps->sortOrder());
         props.setShowHiddenFilesEnabled(m_viewProps->isShowHiddenFilesEnabled());
-        props.setValidForSubDirs(true);
+        //props.setValidForSubDirs(true);
     }
     else if (m_applyToSubFolders->isChecked() && m_isDirty) {
         const QString text(i18n("The view properties of all sub folders will be replaced. Do you want to continue?"));