parley
grammardialog.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "grammardialog.h"
00015
00016 #include "docprop-dialogs/UsageOptPage.h"
00017 #include "docprop-dialogs/TypeOptPage.h"
00018 #include "docprop-dialogs/TenseOptPage.h"
00019 #include "docprop-dialogs/LangPropPage.h"
00020 #include "languagesettings.h"
00021 #include <keduvocdocument.h>
00022
00023 #include <KLocale>
00024 #include <KPageWidgetModel>
00025 #include <KIcon>
00026 #include <KConfig>
00027 #include <KGlobal>
00028
00029 #include <QList>
00030 #include <QPixmap>
00031
00032
00033 GrammarDialog::GrammarDialog(KEduVocDocument *doc, QWidget *parent) : KPageDialog(parent)
00034 {
00035 setCaption(i18n("Grammar Properties"));
00036 setButtons(Ok|Cancel);
00037 setDefaultButton(Ok);
00038 setModal(true);
00039
00040 setFaceType(KPageDialog::List);
00041
00042 typeOptPage = new WordTypeOptionPage(doc, this);
00043 addPage(typeOptPage, i18nc("word types","Types"));
00044
00045 tenseOptPage = new TenseOptPage(doc, 0);
00046 addPage(tenseOptPage, i18n("Tenses"));
00047
00048 useOptPage = new UsageOptPage(doc, 0);
00049 addPage(useOptPage, i18nc("usage (area) of an expression", "Usage"));
00050
00051
00052 LangPropPage *lpp;
00053 for (int i = 0; i < doc->identifierCount(); i++) {
00054 QString s;
00055 s = doc->identifier(i).name();
00056
00057 lpp = new LangPropPage(doc, i, 0);
00058 KPageWidgetItem *pageItem = new KPageWidgetItem(lpp, s);
00059 pageItem->setHeader(s);
00060
00061 LanguageSettings currentSettings(doc->identifier(i).locale());
00062 currentSettings.readConfig();
00063 QString icon = currentSettings.icon();
00064 if ( !icon.isEmpty() ) {
00065 pageItem->setIcon(KIcon(icon));
00066 }
00067 addPage(pageItem);
00068 langPages.append(lpp);
00069 }
00070
00071 KConfigGroup cg(KGlobal::config(), "GrammarDialog");
00072 restoreDialogSize(cg);
00073 }
00074
00075 GrammarDialog::~GrammarDialog()
00076 {
00077 KConfigGroup cg(KGlobal::config(), "GrammarDialog");
00078 KDialog::saveDialogSize(cg);
00079 useOptPage->deleteLater();
00080 typeOptPage->deleteLater();
00081 tenseOptPage->deleteLater();
00082 }
00083
00084
00085 void GrammarDialog::accept()
00086 {
00087 useOptPage->accept();
00088 typeOptPage->accept();
00089 tenseOptPage->accept();
00090
00091 foreach ( LangPropPage* langPage, langPages ) {
00092 langPage->accept();
00093 }
00094
00095 KDialog::accept();
00096 }
00097
00098 #include "grammardialog.moc"