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