diff options
| author | Peter Penz <[email protected]> | 2006-12-04 06:37:20 +0000 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2006-12-04 06:37:20 +0000 |
| commit | dde6f0a0772eee324e2838ba4a076a83193f163c (patch) | |
| tree | e138ffbf79a9e10ef555f854a1eb4d4e440b9298 /src | |
| parent | 45d82b30417ce8a747eab2baab7a5618a069bbfa (diff) | |
First step of cleaning up the view properties: inheriting of viewproperties does not work with the current approach of directoryviewpropertysettings.kcfg (2 nodes would be required for each directory, only one is used at the moment). Therefor the valid_for_subdirs property has been removed and the implementation model will be adjusted to match 1:1 to the users model. TODO: improve the viewpropertiesdialog be able to apply viewproperties recursively to sub directories.
svn path=/trunk/playground/utils/dolphin/; revision=610383
Diffstat (limited to 'src')
| -rw-r--r-- | src/directoryviewpropertysettings.kcfg | 78 | ||||
| -rw-r--r-- | src/viewproperties.cpp | 68 | ||||
| -rw-r--r-- | src/viewproperties.h | 10 | ||||
| -rw-r--r-- | src/viewpropertiesdialog.cpp | 18 |
4 files changed, 58 insertions, 116 deletions
diff --git a/src/directoryviewpropertysettings.kcfg b/src/directoryviewpropertysettings.kcfg index 7af729d28..247b8181b 100644 --- a/src/directoryviewpropertysettings.kcfg +++ b/src/directoryviewpropertysettings.kcfg @@ -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="Settings"> + <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="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> + <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> -</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> + <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> diff --git a/src/viewproperties.cpp b/src/viewproperties.cpp index a3a8ec46b..d099b3b22 100644 --- a/src/viewproperties.cpp +++ b/src/viewproperties.cpp @@ -35,14 +35,15 @@ #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); } diff --git a/src/viewproperties.h b/src/viewproperties.h index 98d5a94b2..7f57f2eed 100644 --- a/src/viewproperties.h +++ b/src/viewproperties.h @@ -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 diff --git a/src/viewpropertiesdialog.cpp b/src/viewpropertiesdialog.cpp index 82f3c5976..594c487d2 100644 --- a/src/viewpropertiesdialog.cpp +++ b/src/viewpropertiesdialog.cpp @@ -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?")); |
