summaryrefslogtreecommitdiffstats
path: root/kvoctrain/kvoctrain/entry-dialogs/AuxInfoEntryPage.cpp
blob: 87e0fe59c0cce73faee10d06d33dc62838dad2ee (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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
/***************************************************************************

                       edit "additional" properties

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

    begin          : Thu Nov 25 17:29:44 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 <tqmultilineedit.h>

#include "AuxInfoEntryPage.h"
#include "EntryDlg.h"

#include <langset.h>

#include <LineList.h>

AuxInfoEntryPage::AuxInfoEntryPage
(
  EntryDlg   *_dlgbook,
  bool        multi_sel,
  TQString     syno,
  TQString     anto,
  TQString     exam,
  TQString     rem,
  TQString     para,
  TQWidget    *parent,
  const char *name
)
 : AuxInfoEntryPageForm( parent, name ), dlgbook(_dlgbook)

{
  TQFontMetrics fm (synonym_line->font());
  int sz = fm.lineSpacing();

  synonym_line->setMaximumHeight(sz*3);
  antonym_line->setMaximumHeight(sz*3);
  para_line->setMaximumHeight(sz*3);
  remark_line->setMaximumHeight(sz*3);
  examp_line->setMaximumHeight(sz*3);

  connect( para_line, TQT_SIGNAL(textChanged()), TQT_SLOT(slotParaSelected()) );
  connect( remark_line, TQT_SIGNAL(textChanged()), TQT_SLOT(slotRemarkSelected()) );
  connect( examp_line, TQT_SIGNAL(textChanged()), TQT_SLOT(slotExampSelected()) );
  connect( antonym_line, TQT_SIGNAL(textChanged()), TQT_SLOT(slotAntonymSelected()) );
  connect( synonym_line, TQT_SIGNAL(textChanged()), TQT_SLOT(slotSynonymSelected()) );

  setData(multi_sel, syno, anto, exam, rem, para);
}


void AuxInfoEntryPage::setData(bool multi_sel, TQString syno, TQString anto, TQString  example, TQString remark, TQString para)
{
  synonym_line->setText(syno);
  antonym_line->setText(anto);
  examp_line->setText(example);
  remark_line->setText(remark);
  para_line->setText(para);

  if (multi_sel) {
    synonym_line ->setEnabled(false);
    antonym_line ->setEnabled(false);
    remark_line ->setEnabled(false);
    examp_line ->setEnabled(false);
    para_line ->setEnabled(false);
  }

  setModified(false);
}


void AuxInfoEntryPage::slotSynonymSelected()
{
  setModified(true);
  synonym = synonym_line->text();
}


void AuxInfoEntryPage::slotAntonymSelected()
{
  setModified(true);
  antonym = antonym_line->text();
}


void AuxInfoEntryPage::slotRemarkSelected ()
{
  setModified(true);
  remark = remark_line->text();
}


void AuxInfoEntryPage::slotExampSelected ()
{
  setModified(true);
  example = examp_line->text();
}


void AuxInfoEntryPage::slotParaSelected ()
{
  setModified(true);
  paraphrase = para_line->text();
}


TQString AuxInfoEntryPage::getSynonym ()
{
  normalize(synonym);
  return synonym;
}


TQString AuxInfoEntryPage::getAntonym ()
{
  normalize(antonym);
  return antonym;
}


TQString AuxInfoEntryPage::getExample ()
{
  normalize(example);
  return example;
}


TQString AuxInfoEntryPage::getRemark  ()
{
  normalize(remark);
  return remark;
}


TQString AuxInfoEntryPage::getParaphrase  ()
{
  normalize(paraphrase);
  return paraphrase;
}


void AuxInfoEntryPage::normalize (TQString &str)
{
  LineList ll (str);
  ll.normalizeWS();
  str = ll.allLines();
}


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


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

  synonym_line->setEnabled (ena);
  antonym_line->setEnabled (ena);
  para_line->setEnabled (ena);
  remark_line->setEnabled (ena);
  examp_line->setEnabled (ena);
}


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

#include "AuxInfoEntryPage.moc"