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

parley

  • sources
  • kde-4.14
  • kdeedu
  • parley
  • src
  • editor
comparisonwidget.cpp
Go to the documentation of this file.
1 /***************************************************************************
2 
3  Copyright 2007 Frederik Gladhorn <frederik.gladhorn@kdemail.net>
4 
5  ***************************************************************************/
6 
7 /***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #include "comparisonwidget.h"
17 
18 #include <keduvocwordtype.h>
19 #include <keduvoctranslation.h>
20 #include <keduvocexpression.h>
21 #include <keduvocdocument.h>
22 #include <KMessageBox>
23 
24 using namespace Editor;
25 
26 ComparisonWidget::ComparisonWidget(QWidget *parent) : QWidget(parent)
27 {
28  setupUi(this);
29 
30  m_doc = 0;
31 
32  connect(makeAdjectiveButton, SIGNAL(clicked()), SLOT(slotMakeAdjectiveButton()));
33  connect(makeAdverbButton, SIGNAL(clicked()), SLOT(slotMakeAdverbButton()));
34 
35  connect(comparativeLineEdit, SIGNAL(editingFinished()), SLOT(slotComparativeChanged()));
36  connect(superlativeLineEdit, SIGNAL(editingFinished()), SLOT(slotSuperlativeChanged()));
37 }
38 
39 void ComparisonWidget::setTranslation(KEduVocExpression * entry, int translation)
40 {
41  comparativeLineEdit->setText(QString());
42  superlativeLineEdit->setText(QString());
43  comparativeLineEdit->setEnabled(false);
44  superlativeLineEdit->setEnabled(false);
45 
46  if (entry) {
47  m_translation = entry->translation(translation);
48  } else {
49  m_translation = 0;
50  }
51 
52  if (m_translation) {
53  absoluteEntryLabel->setText(m_translation->text());
54  setEnabled(true);
55 
56  if (m_translation->wordType()) {
57  if (m_translation->wordType()->wordType() & KEduVocWordFlag::Adjective
58  || m_translation->wordType()->wordType() & KEduVocWordFlag::Adverb) {
59  comparativeLineEdit->setEnabled(true);
60  superlativeLineEdit->setEnabled(true);
61 
62  comparativeLineEdit->setText(m_translation->comparative());
63  superlativeLineEdit->setText(m_translation->superlative());
64  }
65  }
66  } else {
67  setEnabled(false);
68  absoluteEntryLabel->setText(QString());
69  }
70 }
71 
72 void ComparisonWidget::slotMakeAdjectiveButton()
73 {
74  if (!m_doc) {
75  return;
76  }
77 
78  // find an adjective container
79  KEduVocWordType* container = m_doc->wordTypeContainer()->childOfType(KEduVocWordFlag::Adjective);
80  if (container) {
81  m_translation->setWordType(container);
82  comparativeLineEdit->setEnabled(true);
83  superlativeLineEdit->setEnabled(true);
84  comparativeLineEdit->setFocus();
85  } else {
87  KMessageBox::information(this, i18n("Could not determine word type of adjectives"));
88  }
89 }
90 
91 void ComparisonWidget::slotMakeAdverbButton()
92 {
93  if (!m_doc) {
94  return;
95  }
96 
97  // find an adverb container
98  KEduVocWordType* container = m_doc->wordTypeContainer()->childOfType(KEduVocWordFlag::Adverb);
99  if (container) {
100  m_translation->setWordType(container);
101  comparativeLineEdit->setEnabled(true);
102  superlativeLineEdit->setEnabled(true);
103  comparativeLineEdit->setFocus();
104  } else {
106  KMessageBox::information(this, i18n("Could not determine word type of adverbs"));
107  }
108 }
109 
110 void ComparisonWidget::setDocument(KEduVocDocument * doc)
111 {
112  m_doc = doc;
113 }
114 
115 void ComparisonWidget::slotComparativeChanged()
116 {
117  m_translation->setComparative(comparativeLineEdit->text());
118 }
119 
120 void ComparisonWidget::slotSuperlativeChanged()
121 {
122  m_translation->setSuperlative(superlativeLineEdit->text());
123 }
124 
125 
126 #include "comparisonwidget.moc"
QWidget
QWidget::setupUi
void setupUi(QWidget *widget)
QWidget::setEnabled
void setEnabled(bool)
QString
Editor::ComparisonWidget::ComparisonWidget
ComparisonWidget(QWidget *parent=0)
Definition: comparisonwidget.cpp:26
Editor::ComparisonWidget::setDocument
void setDocument(KEduVocDocument *doc)
To know about word types that are currently defined.
Definition: comparisonwidget.cpp:110
comparisonwidget.h
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Editor::ComparisonWidget::setTranslation
void setTranslation(KEduVocExpression *entry, int translation)
Update the word.
Definition: comparisonwidget.cpp:39
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:15:56 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

parley

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

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal