]> cloud.milkyroute.net Git - dolphin.git/blob - src/viewproperties.h
updated the documentation
[dolphin.git] / src / viewproperties.h
1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz *
3 * peter.penz@gmx.at *
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 ***************************************************************************/
20
21 #ifndef VIEWPROPERTIES_H
22 #define VIEWPROPERTIES_H
23
24 #include <dolphinview.h>
25 #include <kurl.h>
26 #include <qdatetime.h>
27
28 #include "directoryviewpropertysettings.h"
29
30 class QFile;
31
32 /**
33 * @brief Maintains the view properties like 'view mode' or
34 * 'show hidden files' for a directory.
35 *
36 * The view properties are automatically stored inside the directory inside
37 * the hidden file '.directory'. To read out the view properties
38 * just construct an instance by passing the URL of the directory:
39 *
40 * \code
41 * ViewProperties props(KUrl("/home/peter/Documents"));
42 * const DolphinView::Mode mode = props.viewMode();
43 * const bool showHiddenFiles = props.isShowHiddenFilesEnabled();
44 * \endcode
45 *
46 * When modifying a view property, the '.directory' file is automatically updated
47 * inside the destructor.
48 */
49 class ViewProperties
50 {
51 public:
52 explicit ViewProperties(const KUrl& url);
53 virtual ~ViewProperties();
54
55 void setViewMode(DolphinView::Mode mode);
56 DolphinView::Mode viewMode() const;
57
58 void setShowPreview(bool show);
59 bool showPreview() const;
60
61 void setShowHiddenFiles(bool show);
62 bool showHiddenFiles() const;
63
64 void setSorting(DolphinView::Sorting sorting);
65 DolphinView::Sorting sorting() const;
66
67 void setSortOrder(Qt::SortOrder sortOrder);
68 Qt::SortOrder sortOrder() const;
69
70 /**
71 * Sets the directory properties view mode, show preview,
72 * show hidden files, sorting and sort order like
73 * set in \a props.
74 */
75 void setDirProperties(const ViewProperties& props);
76
77 /**
78 * If \a autoSave is true, the properties are automatically
79 * saved when the destructor is called. Per default autosaving
80 * is enabled.
81 */
82 void setAutoSaveEnabled(bool autoSave);
83 bool isAutoSaveEnabled() const;
84
85 void updateTimeStamp();
86
87 /**
88 * Saves the view properties for the directory specified
89 * in the constructor. The method is automatically
90 * invoked in the destructor, if
91 * ViewProperties::isAutoSaveEnabled() returns true and
92 * at least one property has been changed.
93 */
94 void save();
95
96 private:
97 /**
98 * Returns the destination directory path where the view
99 * properties are stored. \a subDir specifies the used sub
100 * directory.
101 */
102 QString destinationDir(const QString& subDir) const;
103
104 ViewProperties(const ViewProperties& props);
105 ViewProperties& operator= (const ViewProperties& props);
106
107 private:
108 bool m_changedProps;
109 bool m_autoSave;
110 QString m_filepath;
111 ViewPropertySettings* m_node;
112 };
113
114 #endif