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
|
/* This file is part of the KDE project
Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
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 "KWFootNoteDia.h"
#include "KWFootNoteDia.moc"
#include <tqbuttongroup.h>
#include <tqvbox.h>
#include <tqradiobutton.h>
#include <klocale.h>
#include <tqlayout.h>
#include <tqlineedit.h>
#include "KWConfigFootNoteDia.h"
/******************************************************************/
/* Class: KWFootNoteDia */
/******************************************************************/
KWFootNoteDia::KWFootNoteDia( NoteType _noteType, KWFootNoteVariable::Numbering _numberingType, const TQString & _manualString, TQWidget *parent, KWDocument *_doc, const char *name )
: KDialogBase( parent, name, true, TQString(), Ok|Cancel|User1, Ok, true )
{
m_doc =_doc;
//setButtonOKText(i18n("&Insert"));
setCaption( i18n("Insert Footnote/Endnote") );
TQVBox *page = makeVBoxMainWidget();
TQButtonGroup *grp = new TQButtonGroup( i18n("Numbering"), page );
TQGridLayout *grid = new TQGridLayout( grp, 9, 4, KDialog::marginHint(), KDialog::spacingHint());
m_rbAuto = new TQRadioButton( i18n("&Automatic"), grp );
m_rbManual= new TQRadioButton( i18n("&Manual"), grp );
grp->setExclusive( true );
int fHeight = grp->fontMetrics().height();
grid->addRowSpacing( 0, fHeight/2 ); // groupbox title
grid->addWidget( m_rbAuto, 1, 0);
grid->addWidget( m_rbManual, 2, 0);
if ( _numberingType == KWFootNoteVariable::Auto )
m_rbAuto->setChecked( true );
else
m_rbManual->setChecked( true );
m_footLine = new TQLineEdit( grp);
m_footLine->setText( _manualString );
connect( m_footLine, TQT_SIGNAL( textChanged ( const TQString & )), this, TQT_SLOT(footLineChanged( const TQString & )));
connect( grp, TQT_SIGNAL( clicked ( int ) ), this, TQT_SLOT(footNoteTypeChanged()));
grid->addWidget( m_footLine, 2, 1);
grp = new TQButtonGroup( 4, Qt::Vertical, page );
m_rbFootNote = new TQRadioButton( i18n("&Footnote"), grp );
m_rbEndNote = new TQRadioButton( i18n("&Endnote"), grp );
grp->setExclusive( true );
grp->insert( m_rbFootNote );
grp->insert( m_rbEndNote );
if (_noteType == FootNote )
m_rbFootNote->setChecked( true );
else
m_rbEndNote->setChecked( true );
footNoteTypeChanged();
setButtonText( KDialogBase::User1, i18n("C&onfigure...") );
connect( this, TQT_SIGNAL( user1Clicked() ), this, TQT_SLOT(slotConfigurate()));
}
void KWFootNoteDia::footNoteTypeChanged()
{
if ( m_rbManual->isChecked())
{
enableButtonOK( !m_footLine->text().isEmpty() );
m_footLine->setFocus();
}
else
{
enableButtonOK(true);
setFocus();
}
}
void KWFootNoteDia::footLineChanged( const TQString &text )
{
m_rbManual->setChecked( true );
if ( text.isEmpty() || footNoteAlreadyExists(text) )
enableButtonOK( false );
else
enableButtonOK( true );
}
NoteType KWFootNoteDia::noteType() const
{
return m_rbFootNote->isChecked() ? FootNote : EndNote;
}
KWFootNoteVariable::Numbering KWFootNoteDia::numberingType()const
{
return m_rbAuto->isChecked() ? KWFootNoteVariable::Auto : KWFootNoteVariable::Manual;
}
TQString KWFootNoteDia::manualString()const
{
return m_rbAuto->isChecked() ? TQString() : m_footLine->text();
}
void KWFootNoteDia::slotConfigurate()
{
KWConfigFootNoteDia *dia = new KWConfigFootNoteDia( this, "configfootnote", m_doc );
dia->exec();
delete dia;
}
bool KWFootNoteDia::footNoteAlreadyExists( const TQString & text )
{
return manualFootNotes.contains( text );
}
void KWFootNoteDia::appendManualFootNote( const TQString & text )
{
manualFootNotes.append( text );
}
|