summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Whiting <[email protected]>2015-02-22 17:01:17 -0700
committerJeremy Whiting <[email protected]>2015-02-23 18:38:56 -0700
commit02dc634ea77f5b3b80afedd6c9185a544841caa2 (patch)
tree35803332ec6adb8263911ce02d71bcaf700fcdd6
parent2dd23c7554fc28764c7ce56bfb6a4e874d7a6de7 (diff)
Start migrating away from Qt3Support classes.
Port from Q3ButtonGroup to QButtonGroup. Port from KProgressDialog to QProgressDialog. Move phrasebookui.rc to top level and install from main CMakeLists.txt Port from K3Wizard to QWizard. Changed QWidgets to QWizardPage and made CreationSourceWidget control which page to go to next based on what is selected.
-rw-r--r--CMakeLists.txt46
-rw-r--r--configwizard.cpp51
-rw-r--r--configwizard.h17
-rw-r--r--kmouth.cpp8
-rw-r--r--phrasebook/CMakeLists.txt2
-rw-r--r--phrasebook/phrasebookdialog.cpp16
-rw-r--r--phrasebook/phrasebookdialog.h8
-rw-r--r--phrasebookdialogui.rc (renamed from phrasebook/phrasebookdialogui.rc)0
-rw-r--r--texttospeechconfigurationwidget.cpp2
-rw-r--r--texttospeechconfigurationwidget.h3
-rw-r--r--wordcompletion/dictionarycreationwizard.cpp126
-rw-r--r--wordcompletion/dictionarycreationwizard.h59
-rw-r--r--wordcompletion/wordlist.cpp41
-rw-r--r--wordcompletion/wordlist.h22
14 files changed, 190 insertions, 211 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 56fb3a0..c6937b6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,33 +11,32 @@ add_definitions(-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS)
include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${KDE4_INCLUDES})
-add_definitions (-DQT3_SUPPORT -DQT3_SUPPORT_WARNINGS)
-set(libphrasebook_SRCS
+add_definitions (-DQT3_SUPPORT)
+set(libphrasebook_SRCS
./phrasebook/phrasetree.cpp
./phrasebook/phrasebookparser.cpp
./phrasebook/phrasebookdialog.cpp
./phrasebook/phrasebook.cpp
)
-kde4_add_ui_files(libphrasebook_SRCS ./phrasebook/buttonboxui.ui)
+kde4_add_ui_files(libphrasebook_SRCS ./phrasebook/buttonboxui.ui)
set(libwordcompletion_SRCS
- ./wordcompletion/wordlist.cpp
- ./wordcompletion/wordcompletion.cpp
- ./wordcompletion/wordcompletionwidget.cpp
- ./wordcompletion/dictionarycreationwizard.cpp
+ ./wordcompletion/wordlist.cpp
+ ./wordcompletion/wordcompletion.cpp
+ ./wordcompletion/wordcompletionwidget.cpp
+ ./wordcompletion/dictionarycreationwizard.cpp
)
-
-kde4_add_ui_files(libwordcompletion_SRCS
- ./wordcompletion/creationsourceui.ui
- ./wordcompletion/creationsourcedetailsui.ui
+
+kde4_add_ui_files(libwordcompletion_SRCS
+ ./wordcompletion/creationsourceui.ui
+ ./wordcompletion/creationsourcedetailsui.ui
./wordcompletion/kdedocsourceui.ui
./wordcompletion/wordcompletionui.ui )
add_subdirectory( doc )
-add_subdirectory( icons )
-add_subdirectory( phrasebook )
-add_subdirectory( books )
+add_subdirectory( icons )
+add_subdirectory( books )
include_directories(./wordcompletion/ )
@@ -45,15 +44,15 @@ include_directories(./wordcompletion/ )
########### next target ###############
set(kmouth_SRCS ${libwordcompletion_SRCS} ${libphrasebook_SRCS}
- texttospeechconfigurationwidget.cpp
- optionsdialog.cpp
- configwizard.cpp
- phraseedit.cpp
- phraselist.cpp
- speech.cpp
- texttospeechsystem.cpp
- phraselistitem.cpp
- kmouth.cpp
+ texttospeechconfigurationwidget.cpp
+ optionsdialog.cpp
+ configwizard.cpp
+ phraseedit.cpp
+ phraselist.cpp
+ speech.cpp
+ texttospeechsystem.cpp
+ phraselistitem.cpp
+ kmouth.cpp
main.cpp )
set(kspeech_xml ${KDE4_DBUS_INTERFACES_DIR}/org.kde.KSpeech.xml)
@@ -73,6 +72,7 @@ install(TARGETS kmouth ${INSTALL_TARGETS_DEFAULT_ARGS} )
install( PROGRAMS kmouth.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} )
install( FILES kmouthrc DESTINATION ${CONFIG_INSTALL_DIR} )
install( FILES kmouthui.rc DESTINATION ${DATA_INSTALL_DIR}/kmouth )
+install( FILES phrasebookdialogui.rc DESTINATION ${DATA_INSTALL_DIR}/kmouth )
diff --git a/configwizard.cpp b/configwizard.cpp
index 5c4e2fc..1353922 100644
--- a/configwizard.cpp
+++ b/configwizard.cpp
@@ -32,20 +32,21 @@
#include "wordcompletion/wordcompletion.h"
#include "wordcompletion/dictionarycreationwizard.h"
-ConfigWizard::ConfigWizard (QWidget *parent, const char *name, KConfig *config)
- : K3Wizard(parent, name, true)
+ConfigWizard::ConfigWizard (QWidget *parent, KConfig *config)
+ : QWizard(parent), m_config(config)
{
setWindowTitle(i18n("Initial Configuration - KMouth"));
- initCommandPage (config);
+ initCommandPage ();
initBookPage ();
- initCompletion (config);
+ initCompletion ();
+ connect (this, SIGNAL(accepted()), this, SLOT(saveConfig()));
}
ConfigWizard::~ConfigWizard() {
}
-void ConfigWizard::initCommandPage(KConfig *config) {
- KConfigGroup cg(config, QLatin1String( "TTS System" ));
+void ConfigWizard::initCommandPage() {
+ KConfigGroup cg(m_config, QLatin1String( "TTS System" ));
bool displayCommand = false;
if (!cg.hasKey("Command")) displayCommand = true;
if (!cg.hasKey("StdIn")) displayCommand = true;
@@ -53,10 +54,10 @@ void ConfigWizard::initCommandPage(KConfig *config) {
if (displayCommand) {
commandWidget = new TextToSpeechConfigurationWidget (this, "ttsPage");
- commandWidget->readOptions (config, QLatin1String( "TTS System" ));
- addPage (commandWidget, i18n("Text-to-Speech Configuration"));
- setHelpEnabled (commandWidget, true);
- setFinishEnabled (commandWidget, true);
+ commandWidget->readOptions (m_config, QLatin1String( "TTS System" ));
+ commandWidget->setTitle(i18n("Text-to-Speech Configuration"));
+ addPage (commandWidget);
+ commandWidget->setFinalPage (true);
}
else
commandWidget = 0;
@@ -68,24 +69,24 @@ void ConfigWizard::initBookPage() {
if (displayBook) {
bookWidget = new InitialPhraseBookWidget (this, "pbPage");
- addPage (bookWidget, i18n("Initial Phrase Book"));
- setHelpEnabled (bookWidget, true);
- setFinishEnabled (bookWidget, true);
+ bookWidget->setTitle (i18n ("Initial Phrase Book"));
+ addPage (bookWidget);
+ bookWidget->setFinalPage (true);
if (commandWidget != 0)
- setFinishEnabled (commandWidget, false);
+ commandWidget->setFinalPage (false);
}
else
bookWidget = 0;
}
-void ConfigWizard::initCompletion (KConfig *config) {
+void ConfigWizard::initCompletion () {
if (!WordCompletion::isConfigured()) {
QString dictionaryFile = KGlobal::dirs()->findResource("appdata", QLatin1String( "dictionary.txt" ));
QFile file(dictionaryFile);
if (file.exists()) {
// If there is a word completion dictionary but no entry in the
// configuration file, we need to add it there.
- KConfigGroup cg (config ,"Dictionary 0");
+ KConfigGroup cg (m_config ,"Dictionary 0");
cg.writeEntry ("Filename", "dictionary.txt");
cg.writeEntry ("Name", "Default");
cg.writeEntry ("Language", QString());
@@ -93,37 +94,37 @@ void ConfigWizard::initCompletion (KConfig *config) {
}
}
- if (config->hasGroup("Completion")) {
+ if (m_config->hasGroup("Completion")) {
completionWidget = 0;
return;
}
if (!WordCompletion::isConfigured()) {
completionWidget = new CompletionWizardWidget(this, "completionPage");
- addPage (completionWidget, i18n("Word Completion"));
- setHelpEnabled (completionWidget, true);
- setFinishEnabled (completionWidget, true);
+ completionWidget->setTitle (i18n ("Word Completion"));
+ addPage (completionWidget);
+ completionWidget->setFinalPage (true);
if (commandWidget != 0)
- setFinishEnabled (commandWidget, false);
+ commandWidget->setFinalPage (false);
if (bookWidget != 0)
- setFinishEnabled (bookWidget, false);
+ bookWidget->setFinalPage (false);
}
else
completionWidget = 0;
}
-void ConfigWizard::saveConfig (KConfig *config) {
+void ConfigWizard::saveConfig () {
if (commandWidget != 0) {
commandWidget->ok();
- commandWidget->saveOptions (config, QLatin1String( "TTS System" ));
+ commandWidget->saveOptions (m_config, QLatin1String( "TTS System" ));
}
if (bookWidget != 0)
bookWidget->createBook();
if (completionWidget != 0)
- completionWidget->ok (config);
+ completionWidget->ok (m_config);
}
bool ConfigWizard::requestConfiguration () {
diff --git a/configwizard.h b/configwizard.h
index c34037c..688095b 100644
--- a/configwizard.h
+++ b/configwizard.h
@@ -19,8 +19,7 @@
#define CONFIGWIZARD_H
#include <QtGui/QWidget>
-
-#include <k3wizard.h>
+#include <QWizard>
class KConfig;
class TextToSpeechConfigurationWidget;
@@ -31,28 +30,30 @@ class CompletionWizardWidget;
* time. It asks the user to provide a first set of configuration data.
*@author Gunnar Schmi Dt
*/
-
-class ConfigWizard : public K3Wizard {
+class ConfigWizard : public QWizard {
Q_OBJECT
public:
- ConfigWizard (QWidget *parent, const char *name, KConfig *config);
+ ConfigWizard (QWidget *parent, KConfig *config);
~ConfigWizard();
bool configurationNeeded ();
bool requestConfiguration ();
- void saveConfig (KConfig *config);
+
+public slots:
+ void saveConfig ();
protected:
void help();
private:
- void initCommandPage (KConfig *config);
+ void initCommandPage ();
void initBookPage();
- void initCompletion (KConfig *config);
+ void initCompletion ();
TextToSpeechConfigurationWidget *commandWidget;
InitialPhraseBookWidget *bookWidget;
CompletionWizardWidget *completionWidget;
+ KConfig *m_config;
};
#endif
diff --git a/kmouth.cpp b/kmouth.cpp
index 319cfb8..c160318 100644
--- a/kmouth.cpp
+++ b/kmouth.cpp
@@ -70,12 +70,12 @@ KMouthApp::KMouthApp(QWidget* , const char* name):KXmlGuiWindow(0)
phrases = new KActionCollection (static_cast<QWidget*>(this));
readOptions();
- ConfigWizard *wizard = new ConfigWizard (this, "ConfigWizard", config.data());
+ ConfigWizard *wizard = new ConfigWizard (this, config.data());
if (wizard->configurationNeeded ()) {
if (wizard->requestConfiguration ()) {
isConfigured = true;
saveOptions();
- wizard->saveConfig (config.data());
+ wizard->saveConfig ();
readOptions();
}
else
@@ -400,11 +400,11 @@ void KMouthApp::slotFileQuit()
KMainWindow* w;
if (!memberList().isEmpty())
{
- for (int i = 0; i < memberList().size(); ++i)
+ for (int i = 0; i < memberList().size(); ++i)
{
// only close the window if the closeEvent is accepted. If the user presses Cancel on the saveModified() dialog,
// the window and the application stay open.
- w = memberList().at(i);
+ w = memberList().at(i);
if(!w->close())
break;
#ifdef __GNUC__
diff --git a/phrasebook/CMakeLists.txt b/phrasebook/CMakeLists.txt
deleted file mode 100644
index 55360a9..0000000
--- a/phrasebook/CMakeLists.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-
-install( FILES phrasebookdialogui.rc DESTINATION ${DATA_INSTALL_DIR}/kmouth )
diff --git a/phrasebook/phrasebookdialog.cpp b/phrasebook/phrasebookdialog.cpp
index 13b52d7..d1dffff 100644
--- a/phrasebook/phrasebookdialog.cpp
+++ b/phrasebook/phrasebookdialog.cpp
@@ -27,7 +27,6 @@
#include <QtGui/QPainter>
#include <QtGui/QPrintDialog>
#include <QtGui/QStyle>
-#include <Qt3Support/Q3GroupBox>
#include <QtGui/QMenu>
#include <QtCore/QStack>
#include <QtGui/QGridLayout>
@@ -148,7 +147,7 @@ void CheckBookItem::childChange (int numberDiff, int selDiff) {
/***************************************************************************/
InitialPhraseBookWidget::InitialPhraseBookWidget (QWidget *parent, const char *name)
- : QWidget(parent)
+ : QWizardPage(parent)
{
setObjectName( QLatin1String( name ) );
QVBoxLayout *mainLayout = new QVBoxLayout (this);
@@ -261,8 +260,8 @@ ButtonBoxWidget::ButtonBoxWidget (QWidget *parent, const char *name)
keyButtonPlaceLayout->addWidget (keyButton, 1,1);
keyButton->setWhatsThis( i18n("By clicking on this button you can select the keyboard shortcut associated with the selected phrase."));
- group = new Q3ButtonGroup (phrasebox);
- group->hide();
+ group = new QButtonGroup (phrasebox);
+ phrasebox->hide();
group->setExclusive (true);
group->insert (noKey);
group->insert (customKey);
@@ -447,6 +446,7 @@ QString PhraseBookDialog::displayPath (QString filename) {
}
StandardBookList PhraseBookDialog::standardPhraseBooks() {
+ // Get all the standard phrasebook filenames in bookPaths.
QStringList bookPaths = KGlobal::mainComponent().dirs()->findAllResources (
"data", QLatin1String( "kmouth/books/*.phrasebook" ),
KStandardDirs::Recursive |
@@ -454,8 +454,10 @@ StandardBookList PhraseBookDialog::standardPhraseBooks() {
QStringList bookNames;
QMap<QString,StandardBook> bookMap;
QStringList::iterator it;
+ // Iterate over all books creating a phrasebook for each, creating a StandardBook of each.
for (it = bookPaths.begin(); it != bookPaths.end(); ++it) {
PhraseBook pbook;
+ // Open the phrasebook.
if (pbook.open (KUrl( *it ))) {
StandardBook book;
book.name = (*pbook.begin()).getPhrase().getPhrase();
@@ -542,7 +544,7 @@ void PhraseBookDialog::selectionChanged () {
if (currentItem == 0) {
buttonBox->textLabel->setText (i18n("Text of the &phrase:"));
buttonBox->textLabel->setEnabled(false);
- buttonBox->group->setEnabled(false);
+ buttonBox->setEnabled(false);
buttonBox->lineEdit->setText(QLatin1String( "" ));
buttonBox->lineEdit->setEnabled(false);
buttonBox->shortcutLabel->setEnabled(false);
@@ -556,7 +558,7 @@ void PhraseBookDialog::selectionChanged () {
else if (currentItem->isPhrase()) {
buttonBox->textLabel->setText (i18n("Text of the &phrase:"));
buttonBox->textLabel->setEnabled(true);
- buttonBox->group->setEnabled(true);
+ buttonBox->setEnabled(true);
buttonBox->lineEdit->setText(currentItem->text(0));
buttonBox->lineEdit->setEnabled(true);
buttonBox->shortcutLabel->setEnabled(true);
@@ -580,7 +582,7 @@ void PhraseBookDialog::selectionChanged () {
else {
buttonBox->textLabel->setText (i18n("Name of the &phrase book:"));
buttonBox->textLabel->setEnabled(true);
- buttonBox->group->setEnabled(true);
+ buttonBox->setEnabled(true);
buttonBox->lineEdit->setText(currentItem->text(0));
buttonBox->lineEdit->setEnabled(true);
buttonBox->shortcutLabel->setEnabled(false);
diff --git a/phrasebook/phrasebookdialog.h b/phrasebook/phrasebookdialog.h
index f97b269..883333e 100644
--- a/phrasebook/phrasebookdialog.h
+++ b/phrasebook/phrasebookdialog.h
@@ -20,13 +20,14 @@
#include <Qt3Support/Q3Button>
#include <QtGui/QRadioButton>
-#include <Qt3Support/Q3ButtonGroup>
+#include <QButtonGroup>
#include <QtGui/QLabel>
#include <Qt3Support/Q3ListView>
#include <QtCore/QList>
#include <QtGui/QGridLayout>
#include <QtGui/QDropEvent>
#include <QtGui/QPrinter>
+#include <QWizardPage>
#include <kxmlguiwindow.h>
#include <klineedit.h>
@@ -78,8 +79,7 @@ private:
* This class represents a widget for configuring the initial phrasebook.
* @author Gunnar Schmi Dt
*/
-
-class InitialPhraseBookWidget : public QWidget {
+class InitialPhraseBookWidget : public QWizardPage {
Q_OBJECT
public:
InitialPhraseBookWidget(QWidget *parent, const char *name);
@@ -135,7 +135,7 @@ public:
~ButtonBoxWidget ();
KKeySequenceWidget *keyButton;
- Q3ButtonGroup *group;
+ QButtonGroup *group;
protected:
QGridLayout *keyButtonPlaceLayout;
diff --git a/phrasebook/phrasebookdialogui.rc b/phrasebookdialogui.rc
index c5150fe..c5150fe 100644
--- a/phrasebook/phrasebookdialogui.rc
+++ b/phrasebookdialogui.rc
diff --git a/texttospeechconfigurationwidget.cpp b/texttospeechconfigurationwidget.cpp
index 0879adc..96888ce 100644
--- a/texttospeechconfigurationwidget.cpp
+++ b/texttospeechconfigurationwidget.cpp
@@ -31,7 +31,7 @@
#include <kurlrequester.h>
TextToSpeechConfigurationWidget::TextToSpeechConfigurationWidget (QWidget *parent, const char *name)
- : QWidget (parent)
+ : QWizardPage (parent)
{
setObjectName( QLatin1String( name ) );
setupUi(this);
diff --git a/texttospeechconfigurationwidget.h b/texttospeechconfigurationwidget.h
index 12c05f7..2a14e71 100644
--- a/texttospeechconfigurationwidget.h
+++ b/texttospeechconfigurationwidget.h
@@ -20,12 +20,13 @@
#include "ui_texttospeechconfigurationui.h"
#include "texttospeechsystem.h"
+#include <QWizardPage>
/**This class represents a configuration widget for the text-to-speech system.
*@author Gunnar Schmi Dt
*/
-class TextToSpeechConfigurationWidget : public QWidget, public Ui::texttospeechconfigurationui {
+class TextToSpeechConfigurationWidget : public QWizardPage, public Ui::texttospeechconfigurationui {
friend class TextToSpeechConfigurationDialog;
public:
TextToSpeechConfigurationWidget(QWidget *parent, const char *name);
diff --git a/wordcompletion/dictionarycreationwizard.cpp b/wordcompletion/dictionarycreationwizard.cpp
index b26fd20..a553902 100644
--- a/wordcompletion/dictionarycreationwizard.cpp
+++ b/wordcompletion/dictionarycreationwizard.cpp
@@ -26,6 +26,8 @@
#include <QtGui/QGridLayout>
#include <QtCore/QTextCodec>
#include <QtCore/QTextStream>
+#include <QProgressDialog>
+#include <QDebug>
#include <k3listview.h>
#include <klineedit.h>
@@ -35,27 +37,49 @@
#include <kapplication.h>
#include <kstandarddirs.h>
#include <kconfig.h>
-#include <kprogressdialog.h>
#include <klanguagebutton.h>
+int CreationSourceWidget::nextId() const
+{
+ int nextPage = -1;
+ if (fileButton->isChecked()) {
+ nextPage = DictionaryCreationWizard::FilePage;
+ } else if (directoryButton->isChecked()) {
+ nextPage = DictionaryCreationWizard::DirPage;
+ } else if (kdeDocButton->isChecked()) {
+ nextPage = DictionaryCreationWizard::KDEDocPage;
+ } else if (mergeButton->isChecked()) {
+ nextPage = DictionaryCreationWizard::MergePage;
+ }
+ return nextPage;
+}
+
+void CreationSourceWidget::emptyToggled(bool checked)
+{
+ setFinalPage(checked);
+}
+
DictionaryCreationWizard::DictionaryCreationWizard (QWidget *parent, const char *name,
const QStringList &dictionaryNames, const QStringList &dictionaryFiles,
const QStringList &dictionaryLanguages)
- : K3Wizard (parent, name)
+ : QWizard (parent)
{
buildCodecList ();
creationSource = new CreationSourceWidget(this, "source page");
- addPage (creationSource, i18n("Source of New Dictionary (1)"));
- setHelpEnabled (creationSource, false);
- setFinishEnabled (creationSource, false);
+ creationSource->setTitle(i18n("Source of New Dictionary (1)"));
+ setPage (CreationSourcePage, creationSource);
+ setOption(QWizard::HaveHelpButton, false);
+ //setFinishEnabled (creationSource, false);
fileWidget= new CreationSourceDetailsWidget (this, "file source page");
- addPage (fileWidget, i18n("Source of New Dictionary (2)"));
+ fileWidget->setTitle(i18n("Source of New Dictionary (2)"));
+ setPage (FilePage, fileWidget);
buildCodecCombo (fileWidget->encodingCombo);
dirWidget= new CreationSourceDetailsWidget (this, "directory source page");
- addPage (dirWidget, i18n("Source of New Dictionary (2)"));
+ dirWidget->setTitle(i18n("Source of New Dictionary (2)"));
+ setPage (DirPage, dirWidget);
dirWidget->urlLabel->setText (i18nc("In which directory is the file located?", "&Directory:"));
dirWidget->urlLabel->setWhatsThis( i18n("With this input field you specify which directory you want to load for creating the new dictionary."));
dirWidget->url->setMode(KFile::Directory);
@@ -63,28 +87,18 @@ DictionaryCreationWizard::DictionaryCreationWizard (QWidget *parent, const char
buildCodecCombo (dirWidget->encodingCombo);
kdeDocWidget= new KDEDocSourceWidget (this, "KDE documentation source page");
- addPage (kdeDocWidget, i18n("Source of New Dictionary (2)"));
+ kdeDocWidget->setTitle(i18n("Source of New Dictionary (2)"));
+ setPage (KDEDocPage, kdeDocWidget);
kdeDocWidget->languageButton->showLanguageCodes(true);
kdeDocWidget->languageButton->loadAllLanguages();
mergeWidget = new MergeWidget (this, "merge source page", dictionaryNames, dictionaryFiles, dictionaryLanguages);
- addPage (mergeWidget, i18n("Source of New Dictionary (2)"));
-
- connect (creationSource->fileButton, SIGNAL (toggled(bool)), this, SLOT(calculateAppropriate(bool)) );
- connect (creationSource->directoryButton,SIGNAL(toggled(bool)), this, SLOT(calculateAppropriate(bool)) );
- connect (creationSource->kdeDocButton, SIGNAL (toggled(bool)), this, SLOT(calculateAppropriate(bool)) );
- connect (creationSource->mergeButton, SIGNAL (toggled(bool)), this, SLOT(calculateAppropriate(bool)) );
- connect (creationSource->emptyButton, SIGNAL (toggled(bool)), this, SLOT(calculateAppropriate(bool)) );
-
- calculateAppropriate (true);
+ mergeWidget->setTitle(i18n("Source of New Dictionary (2)"));
+ setPage (MergePage, mergeWidget);
}
DictionaryCreationWizard::~DictionaryCreationWizard () {
delete codecList;
- removePage (fileWidget); delete fileWidget;
- removePage (dirWidget); delete dirWidget;
- removePage (kdeDocWidget); delete kdeDocWidget;
- removePage (mergeWidget); delete mergeWidget;
}
void DictionaryCreationWizard::buildCodecList () {
@@ -107,56 +121,10 @@ void DictionaryCreationWizard::buildCodecCombo (KComboBox *combo) {
combo->addItem (QLatin1String( codecList->at(i)->name() ), i+3);
}
-void DictionaryCreationWizard::calculateAppropriate (bool) {
- if (creationSource->mergeButton->isChecked()) {
- setFinishEnabled (creationSource, false);
- removePage (fileWidget);
- removePage (dirWidget);
- removePage (kdeDocWidget);
- addPage (mergeWidget, i18n("Source of New Dictionary (2)"));
- setHelpEnabled (mergeWidget, false);
- setFinishEnabled (mergeWidget, true);
- }
- else if (creationSource->emptyButton->isChecked()) {
- removePage (fileWidget);
- removePage (dirWidget);
- removePage (kdeDocWidget);
- removePage (mergeWidget);
- setFinishEnabled (creationSource, true);
- }
- else if (creationSource->fileButton->isChecked()) {
- setFinishEnabled (creationSource, false);
- removePage (dirWidget);
- removePage (kdeDocWidget);
- removePage (mergeWidget);
- addPage (fileWidget, i18n("Source of New Dictionary (2)"));
- setHelpEnabled (fileWidget, false);
- setFinishEnabled (fileWidget, true);
- }
- else if (creationSource->directoryButton->isChecked()) {
- setFinishEnabled (creationSource, false);
- removePage (fileWidget);
- removePage (kdeDocWidget);
- removePage (mergeWidget);
- addPage (dirWidget, i18n("Source of New Dictionary (2)"));
- setHelpEnabled (dirWidget, false);
- setFinishEnabled (dirWidget, true);
- }
- else { // creationSource->kdeDocButton must be checked
- setFinishEnabled (creationSource, false);
- removePage (fileWidget);
- removePage (dirWidget);
- removePage (mergeWidget);
- addPage (kdeDocWidget, i18n("Source of New Dictionary (2)"));
- setHelpEnabled (kdeDocWidget, false);
- setFinishEnabled (kdeDocWidget, true);
- }
-}
-
QString DictionaryCreationWizard::createDictionary() {
WordList::WordMap map;
QString dicFile;
- KProgressDialog *pdlg = WordList::progressDialog();
+ QProgressDialog *pdlg = WordList::progressDialog();
if (creationSource->mergeButton->isChecked()) {
map = WordList::mergeFiles (mergeWidget->mergeParameters(), pdlg);
@@ -273,15 +241,11 @@ QString DictionaryCreationWizard::language() {
/***************************************************************************/
-MergeWidget::MergeWidget(K3Wizard *parent, const char *name,
+MergeWidget::MergeWidget(QWidget *parent, const char *name,
const QStringList &dictionaryNames, const QStringList &dictionaryFiles,
const QStringList &dictionaryLanguages)
-: Q3ScrollView (parent, name) {
-
- QWidget *contents = new QWidget(viewport());
- addChild(contents);
- QGridLayout *layout = new QGridLayout (contents);
- setResizePolicy (Q3ScrollView::AutoOneFit);
+: QWizardPage (parent) {
+ QGridLayout *layout = new QGridLayout (this);
layout->setColumnStretch (0, 0);
layout->setColumnStretch (1, 1);
@@ -290,8 +254,8 @@ MergeWidget::MergeWidget(K3Wizard *parent, const char *name,
QStringList::ConstIterator fIt = dictionaryFiles.begin();
QStringList::ConstIterator lIt = dictionaryLanguages.begin();
for (; nIt != dictionaryNames.end(); ++nIt, ++fIt, ++lIt) {
- QCheckBox *checkbox = new QCheckBox(*nIt, contents);
- KIntNumInput *numInput = new KIntNumInput(contents);
+ QCheckBox *checkbox = new QCheckBox(*nIt, this);
+ KIntNumInput *numInput = new KIntNumInput(this);
layout->addWidget (checkbox, row, 0);
layout->addWidget (numInput, row, 1);
@@ -306,6 +270,7 @@ MergeWidget::MergeWidget(K3Wizard *parent, const char *name,
languages [*fIt] = *lIt;
row++;
}
+ setLayout(layout);
}
MergeWidget::~MergeWidget() {
@@ -340,8 +305,8 @@ QString MergeWidget::language () {
/***************************************************************************/
-CompletionWizardWidget::CompletionWizardWidget (K3Wizard *parent, const char *name)
- : QWidget (parent) {
+CompletionWizardWidget::CompletionWizardWidget (QWidget *parent, const char *name)
+ : QWizardPage (parent) {
setupUi(this);
setObjectName( QLatin1String( name ) );
}
@@ -351,7 +316,7 @@ CompletionWizardWidget::~CompletionWizardWidget() {
void CompletionWizardWidget::ok (KConfig *config) {
WordList::WordMap map;
- KProgressDialog *pdlg = WordList::progressDialog();
+ QProgressDialog *pdlg = WordList::progressDialog();
QString language = languageButton->current();
map = WordList::parseKDEDoc (language, pdlg);
@@ -366,6 +331,7 @@ void CompletionWizardWidget::ok (KConfig *config) {
QString dictionaryFile;
dictionaryFile = KGlobal::dirs()->saveLocation ("appdata", QLatin1String( "/" )) + QLatin1String( "wordcompletion1.dict" );
+ qDebug() << "dictionaryFile is " << dictionaryFile;
if (WordList::saveWordList (map, dictionaryFile)) {
KConfigGroup cg(config, "Dictionary 0");
cg.writeEntry ("Filename", "wordcompletion1.dict");
diff --git a/wordcompletion/dictionarycreationwizard.h b/wordcompletion/dictionarycreationwizard.h
index 6aee2ec..c733a4b 100644
--- a/wordcompletion/dictionarycreationwizard.h
+++ b/wordcompletion/dictionarycreationwizard.h
@@ -22,9 +22,9 @@
#include <QtCore/QList>
#include <QtCore/QMap>
-#include <Q3ScrollView>
+#include <QScrollArea>
+#include <QWizard>
-#include <k3wizard.h>
#include <kcombobox.h>
#include <knuminput.h>
@@ -37,31 +37,36 @@ class QTextCodec;
class KComboBox;
class MergeWidget;
-class CreationSourceDetailsWidget : public QWidget, public Ui::CreationSourceDetailsUI {
- Q_OBJECT
+class CreationSourceWidget : public QWizardPage, public Ui::CreationSourceUI {
+ Q_OBJECT
public:
- CreationSourceDetailsWidget(QWidget *parent, const char *name)
- : QWidget(parent) {
- setupUi(this);
- setObjectName( QLatin1String( name ) );
- }
+ CreationSourceWidget(QWidget *parent, const char *name)
+ : QWizardPage(parent) {
+ setupUi(this);
+ setObjectName(QLatin1String( name ));
+ connect(emptyButton, SIGNAL(toggled(bool)), this, SLOT(emptyToggled(bool)));
+ }
+
+ virtual int nextId() const;
+private slots:
+ void emptyToggled(bool checked);
};
-class CreationSourceWidget : public QWidget, public Ui::CreationSourceUI {
+class CreationSourceDetailsWidget : public QWizardPage, public Ui::CreationSourceDetailsUI {
Q_OBJECT
public:
- CreationSourceWidget(QWidget *parent, const char *name)
- : QWidget(parent) {
+ CreationSourceDetailsWidget(QWidget *parent, const char *name)
+ : QWizardPage(parent) {
setupUi(this);
- setObjectName(QLatin1String( name ));
+ setObjectName( QLatin1String( name ) );
}
};
-class KDEDocSourceWidget : public QWidget, public Ui::KDEDocSourceUI {
+class KDEDocSourceWidget : public QWizardPage, public Ui::KDEDocSourceUI {
Q_OBJECT
public:
KDEDocSourceWidget(QWidget *parent, const char *name)
- : QWidget(parent) {
+ : QWizardPage(parent) {
setupUi(this);
setObjectName( QLatin1String( name ) );
languageButton->showLanguageCodes(true);
@@ -76,22 +81,27 @@ public:
* necessary information for creating a new dictionary for the word
* completion.
*/
-class DictionaryCreationWizard : public K3Wizard {
+class DictionaryCreationWizard : public QWizard {
Q_OBJECT
public:
DictionaryCreationWizard (QWidget *parent, const char *name,
const QStringList &dictionaryNames,
const QStringList &dictionaryFiles,
const QStringList &dictionaryLanguages);
- ~DictionaryCreationWizard();
+ virtual ~DictionaryCreationWizard();
QString createDictionary();
QString name();
QString language();
-private slots:
- void calculateAppropriate (bool);
-
+ enum Pages {
+ CreationSourcePage,
+ FilePage,
+ DirPage,
+ KDEDocPage,
+ MergePage
+ };
+
private:
void buildCodecList ();
void buildCodecCombo (KComboBox *combo);
@@ -110,10 +120,10 @@ private:
* KDE documentation.
* @author Gunnar Schmi Dt
*/
-class MergeWidget : public Q3ScrollView {
+class MergeWidget : public QWizardPage {
Q_OBJECT
public:
- MergeWidget(K3Wizard *parent, const char *name,
+ MergeWidget(QWidget *parent, const char *name,
const QStringList &dictionaryNames,
const QStringList &dictionaryFiles,
const QStringList &dictionaryLanguages);
@@ -123,6 +133,7 @@ public:
QString language ();
private:
+ QScrollArea *scrollArea;
QHash<QString, QCheckBox*> dictionaries;
QHash<QString, KIntNumInput*> weights;
QMap<QString,QString> languages;
@@ -133,11 +144,11 @@ private:
* KDE documentation.
* @author Gunnar Schmi Dt
*/
-class CompletionWizardWidget : public QWidget, public Ui::KDEDocSourceUI {
+class CompletionWizardWidget : public QWizardPage, public Ui::KDEDocSourceUI {
Q_OBJECT
friend class ConfigWizard;
public:
- CompletionWizardWidget(K3Wizard *parent, const char *name);
+ CompletionWizardWidget(QWidget *parent, const char *name);
~CompletionWizardWidget();
void ok (KConfig *config);
diff --git a/wordcompletion/wordlist.cpp b/wordcompletion/wordlist.cpp
index 6fc18e0..7a69db4 100644
--- a/wordcompletion/wordlist.cpp
+++ b/wordcompletion/wordlist.cpp
@@ -26,9 +26,10 @@
#include <QtXml/QXmlAttributes>
#include <QtXml/QXmlInputSource>
#include <QtXml/QXmlSimpleReader>
+#include <QProgressDialog>
+#include <QApplication>
#include <kstandarddirs.h>
-#include <kprogressdialog.h>
#include <klocale.h>
#include <kapplication.h>
@@ -110,14 +111,12 @@ WordMap XMLParser::getList() {
/***************************************************************************/
-KProgressDialog *progressDialog() {
- KProgressDialog *pdlg = new KProgressDialog(0, i18n("Creating Word List"), i18n("Parsing the KDE documentation..."), 0);
- pdlg->setAllowCancel (false);
- pdlg->showCancelButton (false);
+QProgressDialog *progressDialog() {
+ QProgressDialog *pdlg = new QProgressDialog(i18n("Creating Word List"), i18n("Parsing the KDE documentation..."), 0, 100);
+ //pdlg->setAllowCancel (false);
+ //pdlg->showCancelButton (false);
pdlg->setAutoReset(false);
pdlg->setAutoClose(false);
- pdlg->progressBar()->setMaximum(100);
- pdlg->progressBar()->setValue(0);
return pdlg;
}
@@ -218,7 +217,7 @@ void addWordsFromFile (WordMap &map, QString filename, QTextCodec *codec) {
#include <kdebug.h>
namespace WordList {
-WordMap parseFiles (QStringList files, QTextCodec *codec, KProgressDialog *pdlg) {
+WordMap parseFiles (QStringList files, QTextCodec *codec, QProgressDialog *pdlg) {
int progress = 0;
int steps = files.count();
int percent = 0;
@@ -230,14 +229,14 @@ WordMap parseFiles (QStringList files, QTextCodec *codec, KProgressDialog *pdlg)
if (steps != 0 && progress*100/steps > percent) {
percent = progress*100/steps;
- pdlg->progressBar()->setValue(percent);
+ pdlg->setValue(percent);
qApp->processEvents (QEventLoop::AllEvents, 20);
}
}
return map;
}
-WordMap mergeFiles (QMap<QString,int> files, KProgressDialog *pdlg) {
+WordMap mergeFiles (QMap<QString,int> files, QProgressDialog *pdlg) {
pdlg->setLabelText (i18n("Merging dictionaries..."));
pdlg->show();
qApp->processEvents (QEventLoop::AllEvents, 20);
@@ -271,7 +270,7 @@ WordMap mergeFiles (QMap<QString,int> files, KProgressDialog *pdlg) {
if (steps != 0 && progress*100/steps > percent) {
percent = progress*100/steps;
- pdlg->progressBar()->setValue(percent);
+ pdlg->setValue(percent);
qApp->processEvents (QEventLoop::AllEvents, 20);
}
}
@@ -290,7 +289,7 @@ WordMap mergeFiles (QMap<QString,int> files, KProgressDialog *pdlg) {
return resultMap;
}
-WordMap parseKDEDoc (QString language, KProgressDialog *pdlg) {
+WordMap parseKDEDoc (QString language, QProgressDialog *pdlg) {
pdlg->setLabelText (i18n("Parsing the KDE documentation..."));
pdlg->show();
qApp->processEvents (QEventLoop::AllEvents, 20);
@@ -308,7 +307,7 @@ WordMap parseKDEDoc (QString language, KProgressDialog *pdlg) {
return parseFiles (files, QTextCodec::codecForName("UTF-8"), pdlg);
}
-WordMap parseFile (QString filename, QTextCodec *codec, KProgressDialog *pdlg) {
+WordMap parseFile (QString filename, QTextCodec *codec, QProgressDialog *pdlg) {
pdlg->setLabelText (i18n("Parsing file..."));
pdlg->show();
qApp->processEvents (QEventLoop::AllEvents, 20);
@@ -319,7 +318,7 @@ WordMap parseFile (QString filename, QTextCodec *codec, KProgressDialog *pdlg) {
return parseFiles (files, codec, pdlg);
}
-WordMap parseDir (QString directory, QTextCodec *codec, KProgressDialog *pdlg) {
+WordMap parseDir (QString directory, QTextCodec *codec, QProgressDialog *pdlg) {
pdlg->setLabelText (i18n("Parsing directory..."));
pdlg->show();
qApp->processEvents (QEventLoop::AllEvents, 20);
@@ -499,7 +498,7 @@ void checkWord (const QString &word, const QString &modifiers, const WordMap &ma
}
}
-WordMap spellCheck (WordMap map, QString dictionary, KProgressDialog *pdlg) {
+WordMap spellCheck (WordMap map, QString dictionary, QProgressDialog *pdlg) {
if (dictionary.endsWith(QLatin1String(".dic"))) {
AffMap prefixes;
@@ -507,14 +506,14 @@ WordMap spellCheck (WordMap map, QString dictionary, KProgressDialog *pdlg) {
WordMap checkedMap;
loadAffFile (dictionary.left(dictionary.length()-4) + QLatin1String( ".aff" ), prefixes, suffixes);
- pdlg->progressBar()->reset();
- pdlg->setAllowCancel (false);
- pdlg->showCancelButton (false);
+ pdlg->reset();
+ //pdlg->setAllowCancel (false);
+ //pdlg->showCancelButton (false);
pdlg->setAutoReset(false);
pdlg->setAutoClose(false);
pdlg->setLabelText (i18n("Performing spell check..."));
- pdlg->progressBar()->setMaximum(100);
- pdlg->progressBar()->setValue(0);
+ pdlg->setMaximum(100);
+ pdlg->setValue(0);
qApp->processEvents (QEventLoop::AllEvents, 20);
int progress = 0;
int steps = 0;
@@ -545,7 +544,7 @@ WordMap spellCheck (WordMap map, QString dictionary, KProgressDialog *pdlg) {
progress++;
if (steps != 0 && progress*100/steps > percent) {
percent = progress*100/steps;
- pdlg->progressBar()->setValue(percent);
+ pdlg->setValue(percent);
qApp->processEvents (QEventLoop::AllEvents, 20);
}
}
diff --git a/wordcompletion/wordlist.h b/wordcompletion/wordlist.h
index 0c582b7..bf160ed 100644
--- a/wordcompletion/wordlist.h
+++ b/wordcompletion/wordlist.h
@@ -28,20 +28,20 @@
#include <QtCore/QTextStream>
class QTextCodec;
-class KProgressDialog;
+class QProgressDialog;
namespace WordList {
typedef QMap<QString,int> WordMap;
-KProgressDialog *progressDialog();
+QProgressDialog *progressDialog();
-WordMap parseKDEDoc (QString language, KProgressDialog *pdlg);
-WordMap parseFile (QString filename, QTextCodec *codec, KProgressDialog *pdlg);
-WordMap parseDir (QString directory, QTextCodec *codec, KProgressDialog *pdlg);
-WordMap mergeFiles (QMap<QString,int> files, KProgressDialog *pdlg);
+WordMap parseKDEDoc (QString language, QProgressDialog *pdlg);
+WordMap parseFile (QString filename, QTextCodec *codec, QProgressDialog *pdlg);
+WordMap parseDir (QString directory, QTextCodec *codec, QProgressDialog *pdlg);
+WordMap mergeFiles (QMap<QString,int> files, QProgressDialog *pdlg);
-WordMap spellCheck (WordMap wordlist, QString dictionary, KProgressDialog *pdlg);
+WordMap spellCheck (WordMap wordlist, QString dictionary, QProgressDialog *pdlg);
bool saveWordList (WordMap map, QString filename);
@@ -52,7 +52,7 @@ bool saveWordList (WordMap map, QString filename);
*/
class XMLParser : public QXmlDefaultHandler {
-public:
+public:
XMLParser();
~XMLParser();
@@ -60,10 +60,10 @@ public:
bool error (const QXmlParseException &exception);
bool fatalError (const QXmlParseException &exception);
QString errorString() const;
-
+
/** Processes the start of the document. */
bool startDocument();
-
+
/** Processes the start tag of an element. */
bool startElement (const QString &, const QString &, const QString &name,
const QXmlAttributes &attributes);
@@ -76,7 +76,7 @@ public:
/** Processes the end tag of an element. */
bool endElement (const QString &, const QString &, const QString &name);
-
+
/** Processes the end of the document. */
bool endDocument();