summaryrefslogtreecommitdiffstats
path: root/kvoctrain/kvoctrain/entry-dialogs/AdjEntryPage.cpp
blob: ce97d871e2e8a1ce132386406e0fd412ae94166e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/***************************************************************************

                   dialog page for adjectives (comparison)

    -----------------------------------------------------------------------

    begin          : Sat Dec 4 18:09:29 1999

    copyright      : (C) 1999-2001 Ewald Arnold <kvoctrain@ewald-arnold.de>
                     (C) 2001 The KDE-EDU team
                     (C) 2005 Peter Hedlund <peter.hedlund@kdemail.net>

    -----------------------------------------------------------------------

 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   * 
 *                                                                         *
 ***************************************************************************/


#include "AdjEntryPage.h"
#include "EntryDlg.h"

#include <langset.h>

#include <qlineedit.h>


AdjEntryPage::AdjEntryPage(EntryDlg *_dlgbook, bool multi_sel, const Comparison &comp, QWidget *parent, const char *name)
  : AdjEntryPageForm( parent, name ), dlgbook(_dlgbook)
{
  comparisons = comp;

  connect( lev1Field, SIGNAL(textChanged(const QString&)), SLOT(lev1Changed(const QString&)) );
  connect( lev2Field, SIGNAL(textChanged(const QString&)), SLOT(lev2Changed(const QString&)) );
  connect( lev3Field, SIGNAL(textChanged(const QString&)), SLOT(lev3Changed(const QString&)) );

  setData(multi_sel, comp);
}


void AdjEntryPage::setData(bool multi_sel, const Comparison  &comp)
{
  if (multi_sel) {
    lev1Field->setEnabled(false);
    lev2Field->setEnabled(false);
    lev3Field->setEnabled(false);
  }
  else {
    lev1Field->setText (comp.l1());
    lev2Field->setText (comp.l2());
    lev3Field->setText (comp.l3());
  }
  setModified(false);
}


void AdjEntryPage::lev1Changed(const QString& s)
{
  setModified(true);
  comparisons.setL1 (s);
}


void AdjEntryPage::lev2Changed(const QString& s)
{
  setModified(true);
  comparisons.setL2 (s);
}


void AdjEntryPage::lev3Changed(const QString& s)
{
  setModified(true);
  comparisons.setL3 (s);
}


bool AdjEntryPage::isModified()
{
  return modified;
}


void AdjEntryPage::setEnabled(int enable)
{
  bool ena = enable == EntryDlg::EnableAll;

  lev1Field->setEnabled (ena);
  lev2Field->setEnabled (ena);
  lev3Field->setEnabled (ena);
}


void AdjEntryPage::setModified(bool mod)
{
  modified = mod;
  if (mod)
    emit sigModified();
}

#include "AdjEntryPage.moc"