not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / kcontrol / kfontinst / viewpart / PreviewSelectAction.cpp
blob125e56a081f1922571d5e5aa1755c3aa6bc4c22f
1 /*
2 * KFontInst - KDE Font Installer
4 * Copyright 2003-2007 Craig Drummond <craig@kde.org>
6 * ----
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; see the file COPYING. If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
24 #include "PreviewSelectAction.h"
25 #include "UnicodeBlocks.h"
26 #include "UnicodeScripts.h"
27 #include <KDE/KLocale>
29 namespace KFI
32 CPreviewSelectAction::CPreviewSelectAction(QObject *parent, Mode mode)
33 : KSelectAction(KIcon("character-set"), i18n("Preview Type"), parent),
34 itsNumUnicodeBlocks(0)
36 setMode(mode);
38 connect(this, SIGNAL(triggered(int)), SLOT(selected(int)));
41 void CPreviewSelectAction::setStd()
43 setCurrentItem(0);
44 selected(0);
47 void CPreviewSelectAction::setMode(Mode mode)
49 QStringList items;
51 items.append(i18n("Standard Preview"));
52 items.append(i18n("All Characters"));
54 switch(mode)
56 default:
57 case Basic:
58 break;
59 case BlocksAndScripts:
60 for(itsNumUnicodeBlocks=0; constUnicodeBlocks[itsNumUnicodeBlocks].blockName; ++itsNumUnicodeBlocks)
61 items.append(i18n("Unicode Block: %1", i18n(constUnicodeBlocks[itsNumUnicodeBlocks].blockName)));
63 for(int i=0; constUnicodeScriptList[i]; ++i)
64 items.append(i18n("Unicode Script: %1", i18n(constUnicodeScriptList[i])));
65 break;
66 case ScriptsOnly:
67 for(int i=0; constUnicodeScriptList[i]; ++i)
68 items.append(i18n(constUnicodeScriptList[i]));
71 setItems(items);
72 setStd();
75 void CPreviewSelectAction::selected(int index)
77 QList<CFcEngine::TRange> list;
79 if(0==index)
81 else if(1==index)
82 list.append(CFcEngine::TRange());
83 else if(index<itsNumUnicodeBlocks+2)
84 list.append(CFcEngine::TRange(constUnicodeBlocks[index-2].start, constUnicodeBlocks[index-2].end));
85 else
87 int script(index-(2+itsNumUnicodeBlocks));
89 for(int i=0; constUnicodeScripts[i].scriptIndex>=0; ++i)
90 if(constUnicodeScripts[i].scriptIndex==script)
91 list.append(CFcEngine::TRange(constUnicodeScripts[i].start, constUnicodeScripts[i].end));
94 emit range(list);
99 #include "PreviewSelectAction.moc"