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