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 <qbuttongroup.h>
#include <qvbox.h>
#include <qradiobutton.h>
#include <klocale.h>
#include <qlayout.h>
#include <qlineedit.h>
#include "KWConfigFootNoteDia.h"
/******************************************************************/
/* Class: KWFootNoteDia */
/******************************************************************/
KWFootNoteDia::KWFootNoteDia( NoteType _noteType, KWFootNoteVariable::Numbering _numberingType, const QString & _manualString, QWidget *parent, KWDocument *_doc, const char *name )
: KDialogBase( parent, name, true, QString::null, Ok|Cancel|User1, Ok, true )
{
m_doc =_doc;
//setButtonOKText(i18n("&Insert"));
setCaption( i18n("Insert Footnote/Endnote") );
QVBox *page = makeVBoxMainWidget();
QButtonGroup *grp = new QButtonGroup( i18n("Numbering"), page );
QGridLayout *grid = new QGridLayout( grp, 9, 4, KDialog::marginHint(), KDialog::spacingHint());
m_rbAuto = new QRadioButton( i18n("&Automatic"), grp );
m_rbManual= new QRadioButton( 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 QLineEdit( grp);
m_footLine->setText( _manualString );
connect( m_footLine, SIGNAL( textChanged ( const QString & )), this, SLOT(footLineChanged( const QString & )));
connect( grp, SIGNAL( clicked ( int ) ), this, SLOT(footNoteTypeChanged()));
grid->addWidget( m_footLine, 2, 1);
grp = new QButtonGroup( 4, Qt::Vertical, page );
m_rbFootNote = new QRadioButton( i18n("&Footnote"), grp );
m_rbEndNote = new QRadioButton( 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, SIGNAL( user1Clicked() ), this, 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 QString &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;
}
QString KWFootNoteDia::manualString()const
{
return m_rbAuto->isChecked() ? QString::null : m_footLine->text();
}
void KWFootNoteDia::slotConfigurate()
{
KWConfigFootNoteDia *dia = new KWConfigFootNoteDia( this, "configfootnote", m_doc );
dia->exec();
delete dia;
}
bool KWFootNoteDia::footNoteAlreadyExists( const QString & text )
{
return manualFootNotes.contains( text );
}
void KWFootNoteDia::appendManualFootNote( const QString & text )
{
manualFootNotes.append( text );
}
|