1 /*************************************************************************** 2 * Copyright (C) 2002 by Gunnar Schmi Dt <kmouth@schmi-dt.de * 3 * (C) 2015 by Jeremy Whiting <jpwhiting@kde.org> * 4 * * 5 * This program is free software; you can redistribute it and/or modify * 6 * it under the terms of the GNU General Public License as published by * 7 * the Free Software Foundation; either version 2 of the License, or * 8 * (at your option) any later version. * 9 * * 10 * This program is distributed in the hope that it will be useful, * 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 13 * GNU General Public License for more details. * 14 * * 15 * You should have received a copy of the GNU General Public License * 16 * along with this program; if not, write to the * 17 * Free Software Foundation, Inc., * 18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 19 ***************************************************************************/ 20 21 #ifndef DICTIONARYCREATIONWIZARD_H 22 #define DICTIONARYCREATIONWIZARD_H 23 24 #include <QList> 25 #include <QMap> 26 #include <QWizard> 27 28 #include "ui_creationsourceui.h" 29 #include "ui_creationsourcedetailsui.h" 30 #include "ui_kdedocsourceui.h" 31 32 class CompletionWizardWidget; 33 class KComboBox; 34 class MergeWidget; 35 class QScrollArea; 36 class QSpinBox; 37 class QTextCodec; 38 39 class CreationSourceWidget : public QWizardPage, public Ui::CreationSourceUI 40 { 41 Q_OBJECT 42 public: CreationSourceWidget(QWidget * parent,const QString & name)43 CreationSourceWidget(QWidget *parent, const QString &name) 44 : QWizardPage(parent) 45 { 46 setupUi(this); 47 setObjectName(name); 48 connect(emptyButton, &QAbstractButton::toggled, this, &CreationSourceWidget::emptyToggled); 49 } 50 51 int nextId() const override; 52 private Q_SLOTS: 53 void emptyToggled(bool checked); 54 }; 55 56 class CreationSourceDetailsWidget : public QWizardPage, public Ui::CreationSourceDetailsUI 57 { 58 Q_OBJECT 59 public: CreationSourceDetailsWidget(QWidget * parent,const QString & name)60 CreationSourceDetailsWidget(QWidget *parent, const QString &name) 61 : QWizardPage(parent) 62 { 63 setupUi(this); 64 setObjectName(name); 65 } nextId()66 int nextId() const override 67 { 68 return -1; 69 } 70 }; 71 72 class KDEDocSourceWidget : public QWizardPage, public Ui::KDEDocSourceUI 73 { 74 Q_OBJECT 75 public: KDEDocSourceWidget(QWidget * parent,const char * name)76 KDEDocSourceWidget(QWidget *parent, const char *name) 77 : QWizardPage(parent) 78 { 79 setupUi(this); 80 setObjectName(QLatin1String(name)); 81 languageButton->showLanguageCodes(true); 82 languageButton->loadAllLanguages(); 83 84 ooDictURL->setFilter(QStringLiteral("*.dic")); 85 } nextId()86 int nextId() const override 87 { 88 return -1; 89 } 90 }; 91 92 /** 93 * This class represents a wizard that is used in order to gather all 94 * necessary information for creating a new dictionary for the word 95 * completion. 96 */ 97 class DictionaryCreationWizard : public QWizard 98 { 99 Q_OBJECT 100 public: 101 DictionaryCreationWizard(QWidget *parent, 102 const QStringList &dictionaryNames, 103 const QStringList &dictionaryFiles, 104 const QStringList &dictionaryLanguages); 105 ~DictionaryCreationWizard() override; 106 107 QString createDictionary(); 108 QString name(); 109 QString language(); 110 111 enum Pages { 112 CreationSourcePage, 113 FilePage, 114 DirPage, 115 KDEDocPage, 116 MergePage 117 }; 118 119 private: 120 void buildCodecList(); 121 void buildCodecCombo(KComboBox *combo); 122 123 CreationSourceWidget *creationSource; 124 CreationSourceDetailsWidget *fileWidget; 125 CreationSourceDetailsWidget *dirWidget; 126 KDEDocSourceWidget *kdeDocWidget; 127 MergeWidget *mergeWidget; 128 129 QList<QTextCodec*> *codecList; 130 }; 131 132 /** 133 * This class represents a widget for creating an initial dictionary from the 134 * KDE documentation. 135 * @author Gunnar Schmi Dt 136 */ 137 class MergeWidget : public QWizardPage 138 { 139 Q_OBJECT 140 public: 141 MergeWidget(QWidget *parent, const char *name, 142 const QStringList &dictionaryNames, 143 const QStringList &dictionaryFiles, 144 const QStringList &dictionaryLanguages); 145 ~MergeWidget() override; 146 147 QMap <QString, int> mergeParameters(); 148 QString language(); 149 150 private: 151 QScrollArea *scrollArea; 152 QHash<QString, QCheckBox*> dictionaries; 153 QHash<QString, QSpinBox*> weights; 154 QMap<QString, QString> languages; 155 }; 156 157 /** 158 * This class represents a widget for creating an initial dictionary from the 159 * KDE documentation. 160 * @author Gunnar Schmi Dt 161 */ 162 class CompletionWizardWidget : public QWizardPage, public Ui::KDEDocSourceUI 163 { 164 Q_OBJECT 165 friend class ConfigWizard; 166 public: 167 CompletionWizardWidget(QWidget *parent, const char *name); 168 ~CompletionWizardWidget() override; 169 170 void ok(); 171 }; 172 173 #endif 174