doc fixes found while translating
[kdepim.git] / knode / settings.cpp
blob1504ca30897bd98a8341768ebc4f7bd4a68414d7
2 /*
3 Copyright (c) 2005 by Volker Krause <vkrause@kde.org>
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 You should have received a copy of the GNU General Public License
10 along with this program; if not, write to the Free Software Foundation,
11 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, US
14 #include "settings.h"
16 #include "knconfig.h"
17 #include "knglobals.h"
18 #include "utilities.h"
20 #include <klocale.h>
21 #include <KPIMIdentities/Identity>
22 #include <KPIMIdentities/IdentityManager>
23 #include <kstandarddirs.h>
24 #include <QFile>
25 #include <QTextStream>
28 KNode::Settings::Settings() : SettingsBase()
30 // KConfigXT doesn't seem to support labels for parameterized fields
31 quoteColorItem( 0 )->setLabel( i18n("Quoted Text - First level") );
32 quoteColorItem( 1 )->setLabel( i18n("Quoted Text - Second level") );
33 quoteColorItem( 2 )->setLabel( i18n("Quoted Text - Third level") );
36 void KNode::Settings::usrReadConfig( )
38 // read extra header configuration
39 QString dir = KStandardDirs::locateLocal( "data", "knode/" );
40 if ( !dir.isNull() ) {
41 QFile f( dir + "xheaders" );
42 if ( f.open( QIODevice::ReadOnly ) ) {
43 mXHeaders.clear();
44 QTextStream ts( &f );
45 while ( !ts.atEnd() )
46 mXHeaders.append( XHeader( ts.readLine() ) );
47 f.close();
52 void KNode::Settings::usrWriteConfig( )
54 // write extra header configuration
55 QString dir = KStandardDirs::locateLocal( "data", "knode/" );
56 if ( dir.isNull() )
57 KNHelper::displayInternalFileError();
58 else {
59 QFile f( dir + "xheaders" );
60 if ( f.open( QIODevice::WriteOnly ) ) {
61 QTextStream ts( &f );
62 for ( XHeader::List::Iterator it = mXHeaders.begin(); it != mXHeaders.end(); ++it )
63 ts << (*it).header() << "\n";
64 ts.flush();
65 f.close();
66 } else
67 KNHelper::displayInternalFileError();
71 QColor KNode::Settings::effectiveColor( KConfigSkeleton::ItemColor * item ) const
73 if ( useCustomColors() )
74 return item->value();
75 item->swapDefault();
76 QColor rv = item->value();
77 item->swapDefault();
78 return rv;
81 QFont KNode::Settings::effectiveFont( KConfigSkeleton::ItemFont * item ) const
83 if ( useCustomFonts() )
84 return item->value();
85 item->swapDefault();
86 QFont rv = item->value();
87 item->swapDefault();
88 return rv;
91 const KPIMIdentities::Identity & KNode::Settings::identity() const
93 return KNGlobals::self()->identityManager()->identityForUoidOrDefault( SettingsBase::identity() );
96 void KNode::Settings::setIdentity( const KPIMIdentities::Identity &identity )
98 SettingsBase::setIdentity( identity.uoid() );