1
0
mirror of https://invent.kde.org/system/dolphin synced 2024-07-04 17:30:55 +00:00

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
This commit is contained in:
Peter Penz 2006-12-04 06:37:20 +00:00
parent 45d82b3041
commit dde6f0a077
4 changed files with 58 additions and 116 deletions

View 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="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>

View File

@ -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(const ViewProperties& props)
{
assert(false);
}
ViewProperties& ViewProperties::operator = (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);
}
return *this;
assert(false);
}

View 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

View 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?"));