add more spacing
[personal-kdebase.git] / apps / dolphin / src / viewproperties.h
blob3237686c7f8ab428bb9dc4cadebe2b31b9a2faf4
1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz (<peter.penz@gmx.at>) *
3 * Copyright (C) 2006 by Aaron J. Seigo (<aseigo@kde.org>) *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
19 ***************************************************************************/
21 #ifndef VIEWPROPERTIES_H
22 #define VIEWPROPERTIES_H
24 #include <dolphinview.h>
25 #include <kurl.h>
26 #include <libdolphin_export.h>
28 class ViewPropertySettings;
29 /**
30 * @brief Maintains the view properties like 'view mode' or
31 * 'show hidden files' for a directory.
33 * The view properties are automatically stored as part of the file
34 * .directory inside the corresponding path. To read out the view properties
35 * just construct an instance by passing the path of the directory:
37 * \code
38 * ViewProperties props(KUrl("/home/peter/Documents"));
39 * const DolphinView::Mode mode = props.viewMode();
40 * const bool showHiddenFiles = props.isShowHiddenFilesEnabled();
41 * \endcode
43 * When modifying a view property, the '.directory' file is automatically updated
44 * inside the destructor.
46 * If no .directory file is available or the global view mode is turned on
47 * (see GeneralSettings::globalViewMode()), the values from the global .directory file
48 * are used for initialization.
50 class LIBDOLPHINPRIVATE_EXPORT ViewProperties
52 public:
53 explicit ViewProperties(const KUrl& url);
54 virtual ~ViewProperties();
56 void setViewMode(DolphinView::Mode mode);
57 DolphinView::Mode viewMode() const;
59 void setShowPreview(bool show);
60 bool showPreview() const;
62 void setShowHiddenFiles(bool show);
63 bool showHiddenFiles() const;
65 void setCategorizedSorting(bool categorized);
66 bool categorizedSorting() const;
68 void setSorting(DolphinView::Sorting sorting);
69 DolphinView::Sorting sorting() const;
71 void setSortOrder(Qt::SortOrder sortOrder);
72 Qt::SortOrder sortOrder() const;
74 /**
75 * Sets the additional information for the current set view-mode.
76 * Note that the additional-info property is the only property where
77 * the value is dependent from another property (in this case the view-mode).
79 void setAdditionalInfo(KFileItemDelegate::InformationList info);
81 /**
82 * Returns the additional information for the current set view-mode.
83 * Note that the additional-info property is the only property where
84 * the value is dependent from another property (in this case the view-mode).
86 KFileItemDelegate::InformationList additionalInfo() const;
88 /**
89 * Sets the directory properties view mode, show preview,
90 * show hidden files, sorting and sort order like
91 * set in \a props.
93 void setDirProperties(const ViewProperties& props);
95 /**
96 * If \a autoSave is true, the properties are automatically
97 * saved when the destructor is called. Per default autosaving
98 * is enabled.
100 void setAutoSaveEnabled(bool autoSave);
101 bool isAutoSaveEnabled() const;
103 void updateTimeStamp();
106 * Saves the view properties for the directory specified
107 * in the constructor. The method is automatically
108 * invoked in the destructor, if
109 * ViewProperties::isAutoSaveEnabled() returns true and
110 * at least one property has been changed.
112 void save();
115 * Returns the URL of the directory, where the mirrored view properties
116 * are stored into. Mirrored view properties are used if:
117 * - there is no write access for storing the view properties into
118 * the original directory
119 * - for non local directories
121 static KUrl mirroredDirectory();
123 private:
125 * Returns the destination directory path where the view
126 * properties are stored. \a subDir specifies the used sub
127 * directory.
129 QString destinationDir(const QString& subDir) const;
132 * Returns the encoded additional information that can be stored
133 * in the .directory file. See ViewProperties::decodedAdditionalInfo()
134 * for the coding format.
135 * @param info Additional information for the current view mode.
137 int encodedAdditionalInfo(int info) const;
140 * Returns the decoded additional information from the .directory
141 * file by respecting the current set view mode. The additional
142 * information from the .directory file is an integer value, where:
143 * - Byte 0 stores the additional info for the details view
144 * - Byte 1 stores the additional info for the icons view
145 * - Byte 2 stores the additional info for the column view
146 * The additional information property is the only property that is
147 * dependent from another property (in this case the view-mode).
149 int decodedAdditionalInfo() const;
151 Q_DISABLE_COPY(ViewProperties)
153 private:
154 enum AdditionalInfoValues
156 NoInfo = 0,
157 SizeInfo = 1,
158 DateInfo = 2,
159 PermissionsInfo = 4,
160 OwnerInfo = 8,
161 GroupInfo = 16,
162 TypeInfo = 32
165 bool m_changedProps;
166 bool m_autoSave;
167 QString m_filepath;
168 ViewPropertySettings* m_node;
170 static bool m_nepomukSupport;
173 #endif