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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
|
/* This file is part of the KDE project
Copyright (C) 2002 Montel Laurent <lmontel@mandrakesoft.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "KWDocument.h"
#include "KWConfigFootNoteDia.h"
#include "KWConfigFootNoteDia.moc"
#include "KWVariable.h"
#include "KWCommand.h"
#include "KWFrameSet.h"
#include <KoParagDia.h>
#include <KoUnitWidgets.h>
#include <klocale.h>
#include <knuminput.h>
#include <qradiobutton.h>
#include <qwhatsthis.h>
#include <qvbuttongroup.h>
#include <qlabel.h>
#include <qvbox.h>
#include <qlayout.h>
#include <qcombobox.h>
KWConfigFootNoteDia::KWConfigFootNoteDia( QWidget *parent, const char *name, KWDocument *doc )
: KDialogBase(Tabbed, QString::null, Ok | Cancel , Ok, parent, name, true)
{
setCaption( i18n("Configure Endnote/Footnote") );
m_doc = doc;
resize( 510, 310 );
setupTab1();
setupTab2();
setupTab3();
}
void KWConfigFootNoteDia::setupTab1()
{
QVBox * page = addVBoxPage( i18n( "Footnotes" ) );
m_footNoteConfig = new KoCounterStyleWidget( false, true, false, page );
//m_footNoteConfig->numTypeChanged( KoParagCounter::NUM_LIST );
m_footNoteConfig->setCounter (static_cast<KWVariableSettings*>(m_doc->variableCollection()->variableSetting())->footNoteCounter() );
}
void KWConfigFootNoteDia::setupTab2()
{
QVBox * page = addVBoxPage( i18n( "Endnotes" ) );
m_endNoteConfig = new KoCounterStyleWidget( false, true/*onlyStyleLetter*/,false, page );
//m_endNoteConfig->numTypeChanged( KoParagCounter::NUM_LIST );
m_endNoteConfig->setCounter (static_cast<KWVariableSettings*>(m_doc->variableCollection()->variableSetting())->endNoteCounter() );
}
void KWConfigFootNoteDia::setupTab3()
{
QFrame * page = addPage( i18n( "Separator Line" ) );
QString comment= i18n ("Configure the separator line. The separator line "
"is drawn directly above the frame for the footnotes.");
QWhatsThis::add(page, comment);
QVBoxLayout *pageLayout= new QVBoxLayout( page, 0, KDialog::spacingHint());
QButtonGroup *positionGroupBox = new QButtonGroup( i18n( "Position"), page );
comment= i18n ("The separator can be positioned horizontally by picking one "
"of the three alignments.");
QWhatsThis::add(positionGroupBox, comment);
positionGroupBox->setColumnLayout(0, Qt::Vertical );
QVBoxLayout *positionLayout = new QVBoxLayout( positionGroupBox->layout() );
positionLayout->setAlignment( Qt::AlignTop );
// i18n context information necessary for gender considerations (e.g. in Polish)
rbPosLeft = new QRadioButton( i18n("Position", "Left"), positionGroupBox, "rbPosLeft" );
positionLayout->addWidget( rbPosLeft );
rbPosCentered = new QRadioButton( i18n("Position", "Centered"), positionGroupBox, "rbPosCentered" );
positionLayout->addWidget( rbPosCentered );
rbPosRight = new QRadioButton( i18n("Position", "Right"), positionGroupBox, "rbPosRight" );
positionLayout->addWidget( rbPosRight );
pageLayout->addWidget( positionGroupBox );
switch( m_doc->footNoteSeparatorLinePosition() ) {
case SLP_LEFT:
rbPosLeft->setChecked( true);
break;
case SLP_CENTERED:
rbPosCentered->setChecked( true);
break;
case SLP_RIGHT:
rbPosRight->setChecked( true);
break;
}
QGridLayout *layout = new QGridLayout( 0, 1, 1, 0, KDialog::spacingHint());
spWidth = new KoUnitDoubleSpinBox(page, 0, 5, 0.5, m_doc->footNoteSeparatorLineWidth(), m_doc->unit(), 1);
layout->addWidget( spWidth, 1, 1 );
spLength = new KIntNumInput( page, "spLength" );
spLength->setRange( 1, 100, 1,false );
spLength->setValue( m_doc->footNoteSeparatorLineLength());
spLength->setSuffix(i18n(" %"));
layout->addWidget( spLength, 0, 1 );
QLabel *lSize = new QLabel( i18n( "&Width:"), page );
lSize->setBuddy( spWidth );
comment= i18n ("The width is the thickness of the separator line, set to 0 for no separator line.");
QWhatsThis::add(lSize, comment);
QWhatsThis::add(spWidth, comment);
layout->addWidget( lSize, 1, 0 );
QSpacerItem* spacer = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
layout->addMultiCell( spacer, 0, 1, 2, 2 );
QLabel *lWidth = new QLabel( i18n("&Size on page:"), page, "lWidth" );
lWidth->setBuddy( spLength );
comment= i18n ("The size of the separator line can be defined as a percentage of the width of the page.");
QWhatsThis::add(spLength, comment);
QWhatsThis::add(lWidth, comment);
layout->addWidget( lWidth, 0, 0 );
pageLayout->addLayout( layout );
QHBoxLayout *styleLayout = new QHBoxLayout( 0, 0, KDialog::spacingHint(), "styleLayout");
QLabel *styleLabel = new QLabel( i18n("Style:"), page );
styleLayout->addWidget( styleLabel );
m_cbLineType = new QComboBox( page );
QStringList lst;
lst <<i18n("Solid");
lst <<i18n("Dash Line");
lst <<i18n("Dot Line");
lst <<i18n("Dash Dot Line");
lst <<i18n("Dash Dot Dot Line");
m_cbLineType->insertStringList( lst );
m_cbLineType->setCurrentItem( static_cast<int>(m_doc->footNoteSeparatorLineType()));
comment= i18n ("The separator line can be drawn as a solid line or as a line which has a "
"pattern; the pattern can be set in the style-type.");
QWhatsThis::add(styleLabel, comment);
QWhatsThis::add(m_cbLineType, comment);
styleLayout->addWidget( m_cbLineType );
QSpacerItem* spacer_2 = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
styleLayout->addItem( spacer_2 );
pageLayout->addLayout( styleLayout );
QSpacerItem* spacer_3 = new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding );
pageLayout->addItem( spacer_3 );
}
void KWConfigFootNoteDia::slotOk()
{
KMacroCommand * macro = 0L;
KCommand *cmd = 0L;
KoParagCounter counter =static_cast<KWVariableSettings*>(m_doc->variableCollection()->variableSetting())->footNoteCounter();
if (counter != m_footNoteConfig->counter() )
{
macro = new KMacroCommand(i18n("Change End-/Footnote Variable Settings"));
cmd= new KWChangeFootEndNoteSettingsCommand( i18n("Change End-/Footnote Variable Settings") , counter, m_footNoteConfig->counter() ,true ,m_doc);
macro->addCommand(cmd );
}
counter = static_cast<KWVariableSettings*>(m_doc->variableCollection()->variableSetting())->endNoteCounter();
if (counter != m_endNoteConfig->counter() )
{
if ( !macro )
macro = new KMacroCommand(i18n("Change End-/Footnote Variable Settings"));
cmd= new KWChangeFootEndNoteSettingsCommand( i18n("Change End-/Footnote Variable Settings") , counter, m_endNoteConfig->counter() ,false ,m_doc);
macro->addCommand(cmd );
}
int val =spLength->value();
double width = spWidth->value();
SeparatorLinePos tmp = SLP_LEFT;
SeparatorLineLineType type = static_cast<SeparatorLineLineType>(m_cbLineType->currentItem());
if ( rbPosRight->isChecked())
tmp = SLP_RIGHT;
else if ( rbPosCentered->isChecked())
tmp = SLP_CENTERED;
else if ( rbPosLeft->isChecked())
tmp = SLP_LEFT;
if ( (val != m_doc->footNoteSeparatorLineLength())||
tmp != m_doc->footNoteSeparatorLinePosition()||
width!= m_doc->footNoteSeparatorLineWidth() ||
type != m_doc->footNoteSeparatorLineType())
{
if ( !macro )
macro = new KMacroCommand(i18n("Change Footnote Line Separator Settings"));
cmd = new KWChangeFootNoteLineSeparatorParametersCommand( i18n("Change Footnote Line Separator Settings") , m_doc->footNoteSeparatorLinePosition(), tmp, m_doc->footNoteSeparatorLineLength(), val,m_doc->footNoteSeparatorLineWidth(), width, m_doc->footNoteSeparatorLineType(), type, m_doc);
macro->addCommand( cmd );
}
if ( macro )
{
macro->execute();
m_doc->addCommand( macro );
}
KDialogBase::slotOk();
}
|