]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinsettings.cpp
A small step in trying to make urlnavigator useable in kdelibs for the file dialog:
[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 <klocale.h>
31 #include <kstandarddirs.h>
32
33 #include "dolphin_generalsettings.h"
34 #include "dolphin_iconsmodesettings.h"
35 #include "dolphin_detailsmodesettings.h"
36
37 #include <Q3IconView>
38
39 DolphinSettings& DolphinSettings::instance()
40 {
41 static DolphinSettings* instance = 0;
42 if (instance == 0) {
43 instance = new DolphinSettings();
44 }
45 return *instance;
46 }
47
48 KBookmark DolphinSettings::bookmark(int index) const
49 {
50 return bookmarkManager()->findByAddress( QString('/')+QString::number(index) );
51 }
52
53 KBookmarkManager* DolphinSettings::bookmarkManager() const
54 {
55 QString basePath = KGlobal::mainComponent().componentName();
56 basePath.append("/bookmarks.xml");
57 const QString file = KStandardDirs::locateLocal("data", basePath);
58
59 return KBookmarkManager::managerForFile(file, "dolphin", false);
60 }
61
62 void DolphinSettings::save()
63 {
64 m_generalSettings->writeConfig();
65 m_iconsModeSettings->writeConfig();
66 m_detailsModeSettings->writeConfig();
67
68 QString basePath = KGlobal::mainComponent().componentName();
69 basePath.append("/bookmarks.xml");
70 const QString file = KStandardDirs::locateLocal( "data", basePath);
71
72 KBookmarkManager* manager = KBookmarkManager::managerForFile(file, "dolphin", false);
73 manager->save(false);
74 }
75
76 DolphinSettings::DolphinSettings()
77 {
78 m_generalSettings = new GeneralSettings();
79 m_iconsModeSettings = new IconsModeSettings();
80 m_detailsModeSettings = new DetailsModeSettings();
81 }
82
83 DolphinSettings::~DolphinSettings()
84 {
85 delete m_generalSettings;
86 m_generalSettings = 0;
87
88 delete m_iconsModeSettings;
89 m_iconsModeSettings = 0;
90
91 delete m_detailsModeSettings;
92 m_detailsModeSettings = 0;
93 }