]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinsettings.cpp
update to changes in class KGlobal (kdelibs)
[dolphin.git] / src / dolphinsettings.cpp
1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz (peter.penz@gmx.at), *
3 * Cvetoslav Ludmiloff and Patrice Tremblay *
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 #include "dolphinsettings.h"
22
23 #include <assert.h>
24 #include <qdir.h>
25
26 #include <kbookmark.h>
27 #include <kbookmarkmanager.h>
28 #include <kcomponentdata.h>
29 #include <kicontheme.h>
30 #include <kinstance.h>
31 #include <klocale.h>
32 #include <kstandarddirs.h>
33
34 #include "generalsettings.h"
35 #include "iconsmodesettings.h"
36 #include "detailsmodesettings.h"
37
38 #include <Q3IconView>
39
40 DolphinSettings& DolphinSettings::instance()
41 {
42 static DolphinSettings* instance = 0;
43 if (instance == 0) {
44 instance = new DolphinSettings();
45 }
46 return *instance;
47 }
48
49 KBookmark DolphinSettings::bookmark(int index) const
50 {
51 int i = 0;
52 KBookmarkGroup root = bookmarkManager()->root();
53 KBookmark bookmark = root.first();
54 while (!bookmark.isNull()) {
55 if (i == index) {
56 return bookmark;
57 }
58 ++i;
59 bookmark = root.next(bookmark);
60 }
61
62 return KBookmark();
63 }
64
65 KBookmarkManager* DolphinSettings::bookmarkManager() const
66 {
67 QString basePath = KGlobal::mainComponent().componentName();
68 basePath.append("/bookmarks.xml");
69 const QString file = KStandardDirs::locateLocal("data", basePath);
70
71 return KBookmarkManager::managerForFile(file, "dolphin", false);
72 }
73
74 void DolphinSettings::save()
75 {
76 m_generalSettings->writeConfig();
77 m_iconsModeSettings->writeConfig();
78 m_detailsModeSettings->writeConfig();
79
80 QString basePath = KGlobal::mainComponent().componentName();
81 basePath.append("/bookmarks.xml");
82 const QString file = KStandardDirs::locateLocal( "data", basePath);
83
84 KBookmarkManager* manager = KBookmarkManager::managerForFile(file, "dolphin", false);
85 manager->save(false);
86 }
87
88 DolphinSettings::DolphinSettings()
89 {
90 m_generalSettings = new GeneralSettings();
91 m_iconsModeSettings = new IconsModeSettings();
92 m_detailsModeSettings = new DetailsModeSettings();
93 }
94
95 DolphinSettings::~DolphinSettings()
96 {
97 delete m_generalSettings;
98 m_generalSettings = 0;
99
100 delete m_iconsModeSettings;
101 m_iconsModeSettings = 0;
102
103 delete m_detailsModeSettings;
104 m_detailsModeSettings = 0;
105 }