• Skip to content
  • Skip to link menu
KDE 4.4 API Reference
  • KDE API Reference
  • kdeedu
  • Sitemap
  • Contact Us
 

parley

comparisonwidget.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002 
00003     Copyright 2007 Frederik Gladhorn <frederik.gladhorn@kdemail.net>
00004 
00005  ***************************************************************************/
00006 
00007 /***************************************************************************
00008  *                                                                         *
00009  *   This program is free software; you can redistribute it and/or modify  *
00010  *   it under the terms of the GNU General Public License as published by  *
00011  *   the Free Software Foundation; either version 2 of the License, or     *
00012  *   (at your option) any later version.                                   *
00013  *                                                                         *
00014  ***************************************************************************/
00015 
00016 #include "comparisonwidget.h"
00017 
00018 #include <keduvocwordtype.h>
00019 #include <keduvoctranslation.h>
00020 #include <keduvocexpression.h>
00021 #include <keduvocdocument.h>
00022 #include <KDebug>
00023 #include <KMessageBox>
00024 
00025 ComparisonWidget::ComparisonWidget(QWidget *parent) : QWidget(parent)
00026 {
00027     setupUi(this);
00028 
00029     m_doc = 0;
00030 
00031     connect(makeAdjectiveButton, SIGNAL(clicked()), SLOT(slotMakeAdjectiveButton()));
00032     connect(makeAdverbButton, SIGNAL(clicked()), SLOT(slotMakeAdverbButton()));
00033 
00034     connect(comparativeLineEdit, SIGNAL(editingFinished()), SLOT(slotComparativeChanged()));
00035     connect(superlativeLineEdit, SIGNAL(editingFinished()), SLOT(slotSuperlativeChanged()));
00036 }
00037 
00038 void ComparisonWidget::setTranslation(KEduVocExpression * entry, int translation)
00039 {
00040     comparativeLineEdit->setText(QString());
00041     superlativeLineEdit->setText(QString());
00042     comparativeLineEdit->setEnabled(false);
00043     superlativeLineEdit->setEnabled(false);
00044 
00045     if (entry) {
00046         m_translation = entry->translation(translation);
00047     } else {
00048         m_translation = 0;
00049     }
00050 
00051     if (m_translation) {
00052         absoluteEntryLabel->setText(m_translation->text());
00053         setEnabled(true);
00054 
00055         if(m_translation->wordType()) {
00056             if(m_translation->wordType()->wordType() & KEduVocWordFlag::Adjective
00057                 || m_translation->wordType()->wordType() & KEduVocWordFlag::Adverb) {
00058                 comparativeLineEdit->setEnabled(true);
00059                 superlativeLineEdit->setEnabled(true);
00060 
00061                 comparativeLineEdit->setText(m_translation->comparative());
00062                 superlativeLineEdit->setText(m_translation->superlative());
00063             }
00064         }
00065     } else {
00066         setEnabled(false);
00067         absoluteEntryLabel->setText(QString());
00068     }
00069 }
00070 
00071 void ComparisonWidget::slotMakeAdjectiveButton()
00072 {
00073     if(!m_doc) {
00074         return;
00075     }
00076 
00077     // find an adjective container
00078     KEduVocWordType* container = m_doc->wordTypeContainer()->childOfType(KEduVocWordFlag::Adjective);
00079     if (container) {
00080         m_translation->setWordType(container);
00081         comparativeLineEdit->setEnabled(true);
00082         superlativeLineEdit->setEnabled(true);
00083         comparativeLineEdit->setFocus();
00084     } else {
00086         KMessageBox::information(this, i18n("Could not determine word type of adjectives"));
00087     }
00088 }
00089 
00090 void ComparisonWidget::slotMakeAdverbButton()
00091 {
00092     if(!m_doc) {
00093         return;
00094     }
00095 
00096     // find an adverb container
00097     KEduVocWordType* container = m_doc->wordTypeContainer()->childOfType(KEduVocWordFlag::Adverb);
00098     if (container) {
00099         m_translation->setWordType(container);
00100         comparativeLineEdit->setEnabled(true);
00101         superlativeLineEdit->setEnabled(true);
00102         comparativeLineEdit->setFocus();
00103     } else {
00105         KMessageBox::information(this, i18n("Could not determine word type of adverbs"));
00106     }
00107 }
00108 
00109 void ComparisonWidget::setDocument(KEduVocDocument * doc)
00110 {
00111     m_doc=doc;
00112 }
00113 
00114 void ComparisonWidget::slotComparativeChanged()
00115 {
00116     m_translation->setComparative(comparativeLineEdit->text());
00117 }
00118 
00119 void ComparisonWidget::slotSuperlativeChanged()
00120 {
00121      m_translation->setSuperlative(superlativeLineEdit->text());
00122 }
00123 
00124 
00125 #include "comparisonwidget.moc"

parley

Skip menu "parley"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdeedu

Skip menu "kdeedu"
  •     lib
  • kalzium
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  •   stepcore
Generated for kdeedu by doxygen 1.5.9-20090814
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal