~ubuntu-branches/ubuntu/intrepid/kdesdk/intrepid-updates

« back to all changes in this revision

Viewing changes to kbabel/commonui/projectpref.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2008-05-28 10:11:43 UTC
  • mto: This revision was merged to the branch mainline in revision 37.
  • Revision ID: james.westby@ubuntu.com-20080528101143-gzc3styjz1b70zxu
Tags: upstream-4.0.80
ImportĀ upstreamĀ versionĀ 4.0.80

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* ****************************************************************************
2
 
  This file is part of KBabel
3
 
 
4
 
  Copyright (C) 1999-2000 by Matthias Kiefer
5
 
                            <matthias.kiefer@gmx.de>
6
 
                2004-2005 by Stanislav Visnovsky
7
 
                            <visnovsky@kde.org>
8
 
 
9
 
  This program is free software; you can redistribute it and/or modify
10
 
  it under the terms of the GNU General Public License as published by
11
 
  the Free Software Foundation; either version 2 of the License, or
12
 
  (at your option) any later version.
13
 
 
14
 
  This program is distributed in the hope that it will be useful,
15
 
  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 
  GNU General Public License for more details.
18
 
 
19
 
  You should have received a copy of the GNU General Public License
20
 
  along with this program; if not, write to the Free Software
21
 
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
22
 
 
23
 
  In addition, as a special exception, the copyright holders give
24
 
  permission to link the code of this program with any edition of
25
 
  the Qt library by Trolltech AS, Norway (or with modified versions
26
 
  of Qt that use the same license as Qt), and distribute linked
27
 
  combinations including the two.  You must obey the GNU General
28
 
  Public License in all respects for all of the code used other than
29
 
  Qt. If you modify this file, you may extend this exception to
30
 
  your version of the file, but you are not obligated to do so.  If
31
 
  you do not wish to do so, delete this exception statement from
32
 
  your version.
33
 
 
34
 
**************************************************************************** */
35
 
#include "projectpref.h"
36
 
#include "projectprefwidgets.h"
37
 
#include "diffpreferences.h"
38
 
#include "kbprojectsettings.h"
39
 
 
40
 
#include <qlayout.h>
41
 
#include <qwhatsthis.h>
42
 
#include <qvbox.h>
43
 
 
44
 
#include <kdebug.h>
45
 
#include <klocale.h>
46
 
#include <kiconloader.h>
47
 
#include <kapplication.h>
48
 
 
49
 
 
50
 
#define PAGE_IDENTITY           0
51
 
#define PAGE_SAVE               1
52
 
#define PAGE_SPELL              2
53
 
#define PAGE_SOURCE             3
54
 
#define PAGE_MISC               4
55
 
#define PAGE_CATMAN             5
56
 
#define PAGE_DIRCOMMANDS        6
57
 
#define PAGE_FILECOMMANDS       7
58
 
#define PAGE_VIEW               8
59
 
#define PAGE_DIFF               9
60
 
 
61
 
using namespace KBabel;
62
 
 
63
 
ProjectDialog::ProjectDialog(Project::Ptr project)
64
 
    : KConfigDialog(0, "project dialog", project->settings(), 
65
 
                  IconList, Help|Default|Ok|Apply|Cancel)
66
 
    , _project( project )
67
 
{
68
 
    
69
 
    _identityPage = new IdentityPreferences(0, project->name());
70
 
    addPage(_identityPage, i18n("title of page in preferences dialog","Identity")
71
 
               , "pref_identity"
72
 
               , i18n("Information About You and Translation Team")
73
 
               );
74
 
 
75
 
    _savePage = new SavePreferences(0);
76
 
    addPage(_savePage, i18n("title of page in preferences dialog","Save")
77
 
            , "filesave"
78
 
            , i18n("Options for File Saving"));
79
 
 
80
 
 
81
 
    _spellPage = new SpellPreferences(0);
82
 
    addPage(_spellPage, i18n("title of page in preferences dialog","Spelling")
83
 
            , "spellcheck"
84
 
            , i18n("Options for Spell Checking"));
85
 
    connect( _spellPage, SIGNAL( settingsChanged() )
86
 
            , this, SLOT(updateButtons()) );
87
 
 
88
 
    _sourcePage = new SourceContextPreferences(0);
89
 
    addPage(_sourcePage, i18n("title of page in preferences dialog","Source")
90
 
                , "source"
91
 
                ,i18n("Options for Showing Source Context"));
92
 
    connect(_sourcePage, SIGNAL (itemsChanged())
93
 
        , this, SLOT (updateButtons()) );
94
 
 
95
 
    _miscPage = new MiscPreferences(0);
96
 
    addPage(_miscPage, i18n("title of page in preferences dialog","Miscellaneous")
97
 
                , "misc"
98
 
                ,i18n("Miscellaneous Settings"));
99
 
 
100
 
    _catmanPage = new CatmanPreferences(0);
101
 
    addPage(_catmanPage, i18n("title of page in preferences dialog","Folders")
102
 
                , "catalogmanager"
103
 
                , i18n("Paths to Message Catalogs & Catalog Templates"));
104
 
 
105
 
    _dirCommandsPage = new DirCommandsPreferences(0);
106
 
    addPage(_dirCommandsPage, i18n("title of page in preferences dialog","Folder Commands")
107
 
                , "folder"
108
 
                , i18n("User-Defined Commands for Folder Items"));
109
 
    connect( _dirCommandsPage, SIGNAL( settingsChanged() ), 
110
 
        this, SLOT(updateButtons()) );
111
 
 
112
 
    _fileCommandsPage = new FileCommandsPreferences(0);
113
 
    addPage(_fileCommandsPage, i18n("title of page in preferences dialog","File Commands")
114
 
                , "files"
115
 
                , i18n("User-Defined Commands for File Items"));
116
 
    connect( _fileCommandsPage, SIGNAL( settingsChanged() ), 
117
 
        this, SLOT(updateButtons()) );
118
 
 
119
 
    _viewPage = new ViewPreferences(0);
120
 
    addPage(_viewPage, i18n("title of page in preferences dialog","Catalog Manager")
121
 
                , "view_tree"
122
 
                , i18n("Catalog Manager View Settings"));
123
 
 
124
 
    _diffPage = new DiffPreferences(0);
125
 
    addPage(_diffPage, i18n("title of page in preferences dialog","Diff")
126
 
                , "diff"
127
 
                , i18n("Searching for Differences"));
128
 
 
129
 
    setHelp( "preferences-project-settings", "kbabel" );
130
 
 
131
 
    adjustSize();
132
 
}
133
 
 
134
 
void ProjectDialog::slotDefault()
135
 
{
136
 
    // redefine the KConfigDialog behavior to push default on the
137
 
    // current page only
138
 
    
139
 
    _project->settings()->useDefaults(true);
140
 
    
141
 
   switch(activePageIndex())
142
 
   {
143
 
      case PAGE_IDENTITY:
144
 
        _identityPage->defaults(_project->identitySettings());
145
 
        break;
146
 
      case PAGE_SAVE:
147
 
        _savePage->defaults(_project->saveSettings());
148
 
        break;
149
 
      case PAGE_MISC:
150
 
          _miscPage->defaults(_project->miscSettings());
151
 
          break;
152
 
      case PAGE_SPELL:
153
 
         _spellPage->defaults(_project->spellcheckSettings());
154
 
         break;
155
 
      case PAGE_SOURCE:
156
 
         _sourcePage->defaults(_project->sourceContextSettings());
157
 
         break;
158
 
      case PAGE_CATMAN:
159
 
         _catmanPage->defaults(_project->catManSettings());
160
 
         break;
161
 
      case PAGE_DIRCOMMANDS:
162
 
         _dirCommandsPage->defaults(_project->catManSettings());
163
 
         break;
164
 
      case PAGE_FILECOMMANDS:
165
 
         _fileCommandsPage->defaults(_project->catManSettings());
166
 
         break;
167
 
      case PAGE_VIEW:
168
 
         _viewPage->defaults(_project->catManSettings());
169
 
         break;
170
 
   }
171
 
 
172
 
    _project->settings()->useDefaults(false);
173
 
}
174
 
 
175
 
void ProjectDialog::updateSettings()
176
 
{
177
 
    KBabel::CatManSettings _CatManSettings;
178
 
    SourceContextSettings contextSettings;
179
 
    
180
 
   _spellPage->mergeSettings(_spellcheckSettings);
181
 
   _dirCommandsPage->mergeSettings(_CatManSettings);
182
 
   _fileCommandsPage->mergeSettings(_CatManSettings);
183
 
   _sourcePage->mergeSettings(contextSettings);
184
 
   
185
 
   _project->settings()->setDirCommands( _CatManSettings.dirCommands );
186
 
   _project->settings()->setDirCommandNames( _CatManSettings.dirCommandNames );
187
 
   _project->settings()->setFileCommands( _CatManSettings.fileCommands );
188
 
   _project->settings()->setFileCommandNames( _CatManSettings.fileCommandNames );
189
 
   
190
 
   _project->setSettings(_spellcheckSettings);
191
 
   
192
 
   _project->settings()->setPaths( contextSettings.sourcePaths );
193
 
}
194
 
 
195
 
void ProjectDialog::updateWidgets()
196
 
{
197
 
    _spellPage->updateWidgets(_project->spellcheckSettings());
198
 
    _dirCommandsPage->updateWidgets(_project->catManSettings());
199
 
    _fileCommandsPage->updateWidgets(_project->catManSettings());
200
 
    _sourcePage->updateWidgets(_project->sourceContextSettings());
201
 
}
202
 
 
203
 
void ProjectDialog::updateWidgetsDefault()
204
 
{
205
 
    _project->settings()->useDefaults( true );
206
 
    updateWidgets();
207
 
    _project->settings()->useDefaults( false );
208
 
}
209
 
 
210
 
bool ProjectDialog::isDefault()
211
 
{
212
 
    SourceContextSettings contextSettings, defaultContextSettings;
213
 
 
214
 
    // get the current values
215
 
   _spellPage->mergeSettings(_spellcheckSettings);
216
 
   _dirCommandsPage->mergeSettings(_CatManSettings);
217
 
   _fileCommandsPage->mergeSettings(_CatManSettings);
218
 
   _sourcePage->mergeSettings(defaultContextSettings);
219
 
 
220
 
    // get default values
221
 
    _project->settings()->useDefaults(true);    
222
 
    SpellcheckSettings defaultSpell = _project->spellcheckSettings();
223
 
    CatManSettings defaultCatMan = _project->catManSettings();
224
 
    defaultContextSettings = _project->sourceContextSettings();
225
 
    _project->settings()->useDefaults(false);    
226
 
    
227
 
    bool result = true;
228
 
    
229
 
    result &= _spellcheckSettings.noRootAffix == defaultSpell.noRootAffix;
230
 
    result &= _spellcheckSettings.runTogether == defaultSpell.runTogether;
231
 
    result &= _spellcheckSettings.spellClient == defaultSpell.spellClient;
232
 
    result &= _spellcheckSettings.spellDict == defaultSpell.spellDict;
233
 
    result &= _spellcheckSettings.spellEncoding == defaultSpell.spellEncoding;
234
 
 
235
 
    result &= _CatManSettings.dirCommandNames == defaultCatMan.dirCommandNames;
236
 
    result &= _CatManSettings.dirCommands == defaultCatMan.dirCommands;
237
 
    result &= _CatManSettings.fileCommandNames == defaultCatMan.fileCommandNames;
238
 
    result &= _CatManSettings.fileCommands == defaultCatMan.fileCommands;
239
 
 
240
 
    result &= contextSettings.sourcePaths != defaultContextSettings.sourcePaths;
241
 
 
242
 
    return result;
243
 
}
244
 
 
245
 
bool ProjectDialog::hasChanged()
246
 
{
247
 
    SourceContextSettings contextSettings, defaultContextSettings;
248
 
    
249
 
    // get the current values
250
 
   _spellPage->mergeSettings(_spellcheckSettings);
251
 
   _dirCommandsPage->mergeSettings(_CatManSettings);
252
 
   _fileCommandsPage->mergeSettings(_CatManSettings);
253
 
   _sourcePage->mergeSettings(contextSettings);
254
 
 
255
 
    // get project values
256
 
    SpellcheckSettings defaultSpell = _project->spellcheckSettings();
257
 
    CatManSettings defaultCatMan = _project->catManSettings();
258
 
    defaultContextSettings = _project->sourceContextSettings();
259
 
    
260
 
    bool result = false;
261
 
    
262
 
    result |= _spellcheckSettings.noRootAffix != defaultSpell.noRootAffix;
263
 
    result |= _spellcheckSettings.runTogether != defaultSpell.runTogether;
264
 
    result |= _spellcheckSettings.spellClient != defaultSpell.spellClient;
265
 
    result |= _spellcheckSettings.spellDict != defaultSpell.spellDict;
266
 
    result |= _spellcheckSettings.spellEncoding != defaultSpell.spellEncoding;
267
 
 
268
 
    result |= _CatManSettings.dirCommandNames != defaultCatMan.dirCommandNames;
269
 
    result |= _CatManSettings.dirCommands != defaultCatMan.dirCommands;
270
 
    result |= _CatManSettings.fileCommandNames != defaultCatMan.fileCommandNames;
271
 
    result |= _CatManSettings.fileCommands != defaultCatMan.fileCommands;
272
 
 
273
 
    result |= contextSettings.sourcePaths != defaultContextSettings.sourcePaths;
274
 
 
275
 
    return result;
276
 
}
277
 
 
278
 
#include "projectpref.moc"