~ubuntu-branches/debian/sid/kdevelop/sid

« back to all changes in this revision

Viewing changes to editors/qeditor/qeditor_settings.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Lainé
  • Date: 2006-05-23 18:39:42 UTC
  • Revision ID: james.westby@ubuntu.com-20060523183942-hucifbvh68k2bwz7
Tags: upstream-3.3.2
Import upstream version 3.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  Copyright (C) 2003 Roberto Raggi (roberto@kdevelop.org)
 
3
 *
 
4
 *  This program is free software; you can redistribute it and/or
 
5
 *  modify it under the terms of the GNU General Public
 
6
 *  License as published by the Free Software Foundation; either
 
7
 *  version 2 of the License, or (at your option) any later version.
 
8
 *
 
9
 *  This program is distributed in the hope that it will be useful,
 
10
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
 *  Library General Public License for more details.
 
13
 *
 
14
 *  You should have received a copy of the GNU General Public License
 
15
 *  along with this program; see the file COPYING.LIB.  If not, write to
 
16
 *  the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
17
 *  Boston, MA 02111-1307, USA.
 
18
 *
 
19
 */
 
20
 
 
21
#include "qeditor_settings.h"
 
22
#include "qeditor_factory.h"
 
23
 
 
24
#include <kinstance.h>
 
25
#include <kconfig.h>
 
26
 
 
27
QEditorSettings* QEditorSettings::m_self = 0;
 
28
 
 
29
QEditorSettings::QEditorSettings( KConfig* config )
 
30
{
 
31
    m_config = config;
 
32
    init();
 
33
}
 
34
 
 
35
QEditorSettings::~QEditorSettings()
 
36
{
 
37
}
 
38
 
 
39
void QEditorSettings::init()
 
40
{
 
41
    if( !m_config )
 
42
        return;
 
43
 
 
44
    m_config->setGroup(generalGroup());
 
45
    m_wordWrap = m_config->readBoolEntry( "WordWrap", true );
 
46
    m_tabStop = m_config->readNumEntry( "TabStop", 8 );
 
47
    m_completeWordWithSpace = m_config->readBoolEntry( "CompleteWordWithSpace", false );
 
48
    m_parenthesesMatching = m_config->readBoolEntry( "ParenthesesMatching", true );
 
49
    m_showMarkers = m_config->readBoolEntry( "ShowMarkers", true );
 
50
    m_showLineNumber = m_config->readBoolEntry( "ShowLineNumber", false );
 
51
    m_showCodeFoldingMarkers = m_config->readBoolEntry( "ShowCodeFoldingMarkers", true );
 
52
}
 
53
 
 
54
QEditorSettings* QEditorSettings::self()
 
55
{
 
56
    if( !m_self )
 
57
        m_self = new QEditorSettings( QEditorPartFactory::instance()->config() );
 
58
 
 
59
    return m_self;
 
60
}
 
61
 
 
62
void QEditorSettings::setWordWrap( bool enable )
 
63
{
 
64
    m_wordWrap = enable;
 
65
    
 
66
    KConfigGroupSaver cgs( m_config, generalGroup() );
 
67
    m_config->writeEntry( "WordWrap", m_wordWrap );
 
68
    m_config->sync();
 
69
}
 
70
 
 
71
void QEditorSettings::setTabStop( int tabStop )
 
72
{
 
73
    m_tabStop = tabStop;
 
74
 
 
75
    KConfigGroupSaver cgs( m_config, generalGroup() );
 
76
    m_config->writeEntry( "TabStop", m_tabStop );
 
77
    m_config->sync();
 
78
}
 
79
 
 
80
void QEditorSettings::setCompleteWordWithSpace( bool enable )
 
81
{
 
82
    m_completeWordWithSpace = enable;
 
83
 
 
84
    KConfigGroupSaver cgs( m_config, generalGroup() );
 
85
    m_config->writeEntry( "CompleteWordWithSpace", m_completeWordWithSpace );
 
86
    m_config->sync();
 
87
}
 
88
 
 
89
void QEditorSettings::setParenthesesMatching( bool enable )
 
90
{
 
91
    m_parenthesesMatching = enable;
 
92
 
 
93
    KConfigGroupSaver cgs( m_config, generalGroup() );
 
94
    m_config->writeEntry( "ParenthesesMatching", m_parenthesesMatching );
 
95
    m_config->sync();
 
96
}
 
97
 
 
98
void QEditorSettings::setShowMarkers( bool enable )
 
99
{
 
100
    m_showMarkers = enable;
 
101
    
 
102
    KConfigGroupSaver cgs( m_config, generalGroup() );
 
103
    m_config->writeEntry( "ShowMarkers", m_showMarkers );
 
104
    m_config->sync();    
 
105
}
 
106
 
 
107
void QEditorSettings::setShowLineNumber( bool enable )
 
108
{
 
109
    m_showLineNumber = enable;
 
110
    
 
111
    KConfigGroupSaver cgs( m_config, generalGroup() );
 
112
    m_config->writeEntry( "ShowLineNumber", m_showLineNumber );
 
113
    m_config->sync();    
 
114
}
 
115
 
 
116
void QEditorSettings::setShowCodeFoldingMarkers( bool enable )
 
117
{
 
118
    m_showCodeFoldingMarkers = enable;
 
119
    
 
120
    KConfigGroupSaver cgs( m_config, generalGroup() );
 
121
    m_config->writeEntry( "ShowCodeFoldingMarkers", m_showCodeFoldingMarkers );
 
122
    m_config->sync();    
 
123
}
 
124