summaryrefslogtreecommitdiffstats
path: root/kvoctrain/kvoctrain/entry-dialogs/MCEntryPage.cpp
blob: a6967704860db0fa001fa8b152f1568d566950bc (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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/***************************************************************************

              dialog page for multiple choice suggestions

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

    begin          : Mon Oct 29 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 "MCEntryPage.h"
#include "EntryDlg.h"

#include <langset.h>

#include <tqlineedit.h>


MCEntryPage::MCEntryPage(EntryDlg *_dlgbook, bool multi_sel, const MultipleChoice &mc, TQWidget *parent, const char *name)
  : MCEntryPageForm( parent, name ), dlgbook(_dlgbook)
{
  multiplechoice = mc;

  connect( mc1Field, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(mc1Changed(const TQString&)) );
  connect( mc2Field, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(mc2Changed(const TQString&)) );
  connect( mc3Field, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(mc3Changed(const TQString&)) );
  connect( mc4Field, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(mc4Changed(const TQString&)) );
  connect( mc5Field, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(mc5Changed(const TQString&)) );

  setData(multi_sel, mc);
}


void MCEntryPage::setData(bool multi_sel, const MultipleChoice &mc)
{
  mc1Field->setText (mc.mc1());
  mc2Field->setText (mc.mc2());
  mc3Field->setText (mc.mc3());
  mc4Field->setText (mc.mc4());
  mc5Field->setText (mc.mc5());

  if (multi_sel)
  {
    mc1Field->setEnabled(false);
    mc2Field->setEnabled(false);
    mc3Field->setEnabled(false);
    mc4Field->setEnabled(false);
    mc5Field->setEnabled(false);
  }

  setModified(false);
}


void MCEntryPage::mc1Changed(const TQString& s)
{
  setModified(true);
  multiplechoice.setMC1 (s);
}


void MCEntryPage::mc2Changed(const TQString& s)
{
  setModified(true);
  multiplechoice.setMC2 (s);
}


void MCEntryPage::mc3Changed(const TQString& s)
{
  setModified(true);
  multiplechoice.setMC3 (s);
}


void MCEntryPage::mc4Changed(const TQString& s)
{
  setModified(true);
  multiplechoice.setMC4 (s);
}


void MCEntryPage::mc5Changed(const TQString& s)
{
  setModified(true);
  multiplechoice.setMC5 (s);
}


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


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


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

  mc1Field->setEnabled (ena);
  mc2Field->setEnabled (ena);
  mc3Field->setEnabled (ena);
  mc4Field->setEnabled (ena);
  mc5Field->setEnabled (ena);
}

#include "MCEntryPage.moc"