File indexing completed on 2024-04-28 03:40:31
0001 /*************************************************************************** 0002 * Copyright (C) 2002 by Gunnar Schmi Dt <kmouth@schmi-dt.de * 0003 * (C) 2015 by Jeremy Whiting <jpwhiting@kde.org> * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, * 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0013 * GNU General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU General Public License * 0016 * along with this program; if not, write to the * 0017 * Free Software Foundation, Inc., * 0018 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 0019 ***************************************************************************/ 0020 0021 #ifndef DICTIONARYCREATIONWIZARD_H 0022 #define DICTIONARYCREATIONWIZARD_H 0023 0024 #include <QList> 0025 #include <QMap> 0026 #include <QWizard> 0027 0028 #include "ui_creationsourcedetailsui.h" 0029 #include "ui_creationsourceui.h" 0030 #include "ui_kdedocsourceui.h" 0031 #include <kio_version.h> 0032 0033 class CompletionWizardWidget; 0034 class KComboBox; 0035 class MergeWidget; 0036 class QScrollArea; 0037 class QSpinBox; 0038 0039 class CreationSourceWidget : public QWizardPage, public Ui::CreationSourceUI 0040 { 0041 Q_OBJECT 0042 public: 0043 CreationSourceWidget(QWidget *parent, const QString &name) 0044 : QWizardPage(parent) 0045 { 0046 setupUi(this); 0047 setObjectName(name); 0048 connect(emptyButton, &QAbstractButton::toggled, this, &CreationSourceWidget::emptyToggled); 0049 } 0050 0051 int nextId() const override; 0052 private Q_SLOTS: 0053 void emptyToggled(bool checked); 0054 }; 0055 0056 class CreationSourceDetailsWidget : public QWizardPage, public Ui::CreationSourceDetailsUI 0057 { 0058 Q_OBJECT 0059 public: 0060 CreationSourceDetailsWidget(QWidget *parent, const QString &name) 0061 : QWizardPage(parent) 0062 { 0063 setupUi(this); 0064 setObjectName(name); 0065 } 0066 int nextId() const override 0067 { 0068 return -1; 0069 } 0070 }; 0071 0072 class KDEDocSourceWidget : public QWizardPage, public Ui::KDEDocSourceUI 0073 { 0074 Q_OBJECT 0075 public: 0076 KDEDocSourceWidget(QWidget *parent, const char *name) 0077 : QWizardPage(parent) 0078 { 0079 setupUi(this); 0080 setObjectName(QLatin1String(name)); 0081 languageButton->showLanguageCodes(true); 0082 languageButton->loadAllLanguages(); 0083 ooDictURL->setNameFilter(QStringLiteral("*.dic")); 0084 } 0085 int nextId() const override 0086 { 0087 return -1; 0088 } 0089 }; 0090 0091 /** 0092 * This class represents a wizard that is used in order to gather all 0093 * necessary information for creating a new dictionary for the word 0094 * completion. 0095 */ 0096 class DictionaryCreationWizard : public QWizard 0097 { 0098 Q_OBJECT 0099 public: 0100 DictionaryCreationWizard(QWidget *parent, const QStringList &dictionaryNames, const QStringList &dictionaryFiles, const QStringList &dictionaryLanguages); 0101 ~DictionaryCreationWizard() override; 0102 0103 QString createDictionary(); 0104 QString name(); 0105 QString language(); 0106 0107 enum Pages { 0108 CreationSourcePage, 0109 FilePage, 0110 DirPage, 0111 KDEDocPage, 0112 MergePage, 0113 }; 0114 0115 private: 0116 void buildCodecCombo(KComboBox *combo); 0117 0118 CreationSourceWidget *creationSource; 0119 CreationSourceDetailsWidget *fileWidget; 0120 CreationSourceDetailsWidget *dirWidget; 0121 KDEDocSourceWidget *kdeDocWidget; 0122 MergeWidget *mergeWidget; 0123 }; 0124 0125 /** 0126 * This class represents a widget for creating an initial dictionary from the 0127 * KDE documentation. 0128 * @author Gunnar Schmi Dt 0129 */ 0130 class MergeWidget : public QWizardPage 0131 { 0132 Q_OBJECT 0133 public: 0134 MergeWidget(QWidget *parent, const QStringList &dictionaryNames, const QStringList &dictionaryFiles, const QStringList &dictionaryLanguages); 0135 ~MergeWidget() override; 0136 0137 QMap<QString, int> mergeParameters(); 0138 QString language(); 0139 0140 private: 0141 QScrollArea *scrollArea; 0142 QHash<QString, QCheckBox *> dictionaries; 0143 QHash<QString, QSpinBox *> weights; 0144 QMap<QString, QString> languages; 0145 }; 0146 0147 /** 0148 * This class represents a widget for creating an initial dictionary from the 0149 * KDE documentation. 0150 * @author Gunnar Schmi Dt 0151 */ 0152 class CompletionWizardWidget : public QWizardPage, public Ui::KDEDocSourceUI 0153 { 0154 Q_OBJECT 0155 friend class ConfigWizard; 0156 0157 public: 0158 CompletionWizardWidget(QWidget *parent, const char *name); 0159 ~CompletionWizardWidget() override; 0160 0161 void ok(); 0162 }; 0163 0164 #endif