00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "KWDocument.h"
00021 #include "KWConfigFootNoteDia.h"
00022 #include "KWConfigFootNoteDia.moc"
00023 #include "KWVariable.h"
00024 #include "KWCommand.h"
00025 #include "KWFrameSet.h"
00026
00027 #include <KoParagDia.h>
00028 #include <KoUnitWidgets.h>
00029
00030 #include <klocale.h>
00031 #include <knuminput.h>
00032
00033 #include <qradiobutton.h>
00034 #include <qwhatsthis.h>
00035 #include <qvbuttongroup.h>
00036 #include <qlabel.h>
00037 #include <qvbox.h>
00038 #include <qlayout.h>
00039 #include <qcombobox.h>
00040
00041
00042 KWConfigFootNoteDia::KWConfigFootNoteDia( QWidget *parent, const char *name, KWDocument *doc )
00043 : KDialogBase(Tabbed, QString::null, Ok | Cancel , Ok, parent, name, true)
00044 {
00045 setCaption( i18n("Configure Endnote/Footnote") );
00046 m_doc = doc;
00047
00048 resize( 510, 310 );
00049 setupTab1();
00050 setupTab2();
00051 setupTab3();
00052 }
00053
00054 void KWConfigFootNoteDia::setupTab1()
00055 {
00056 QVBox * page = addVBoxPage( i18n( "Footnotes" ) );
00057 m_footNoteConfig = new KoCounterStyleWidget( false, true, false, page );
00058
00059 m_footNoteConfig->setCounter (static_cast<KWVariableSettings*>(m_doc->variableCollection()->variableSetting())->footNoteCounter() );
00060 }
00061
00062 void KWConfigFootNoteDia::setupTab2()
00063 {
00064 QVBox * page = addVBoxPage( i18n( "Endnotes" ) );
00065 m_endNoteConfig = new KoCounterStyleWidget( false, true,false, page );
00066
00067 m_endNoteConfig->setCounter (static_cast<KWVariableSettings*>(m_doc->variableCollection()->variableSetting())->endNoteCounter() );
00068 }
00069
00070
00071 void KWConfigFootNoteDia::setupTab3()
00072 {
00073 QFrame * page = addPage( i18n( "Separator Line" ) );
00074 QString comment= i18n ("Configure the separator line. The separator line "
00075 "is drawn directly above the frame for the footnotes.");
00076 QWhatsThis::add(page, comment);
00077 QVBoxLayout *pageLayout= new QVBoxLayout( page, 0, KDialog::spacingHint());
00078
00079 QButtonGroup *positionGroupBox = new QButtonGroup( i18n( "Position"), page );
00080 comment= i18n ("The separator can be positioned horizontally by picking one "
00081 "of the three alignments.");
00082 QWhatsThis::add(positionGroupBox, comment);
00083 positionGroupBox->setColumnLayout(0, Qt::Vertical );
00084 QVBoxLayout *positionLayout = new QVBoxLayout( positionGroupBox->layout() );
00085 positionLayout->setAlignment( Qt::AlignTop );
00086
00087
00088 rbPosLeft = new QRadioButton( i18n("Position", "Left"), positionGroupBox, "rbPosLeft" );
00089 positionLayout->addWidget( rbPosLeft );
00090
00091 rbPosCentered = new QRadioButton( i18n("Position", "Centered"), positionGroupBox, "rbPosCentered" );
00092 positionLayout->addWidget( rbPosCentered );
00093
00094 rbPosRight = new QRadioButton( i18n("Position", "Right"), positionGroupBox, "rbPosRight" );
00095 positionLayout->addWidget( rbPosRight );
00096 pageLayout->addWidget( positionGroupBox );
00097 switch( m_doc->footNoteSeparatorLinePosition() ) {
00098 case SLP_LEFT:
00099 rbPosLeft->setChecked( true);
00100 break;
00101 case SLP_CENTERED:
00102 rbPosCentered->setChecked( true);
00103 break;
00104 case SLP_RIGHT:
00105 rbPosRight->setChecked( true);
00106 break;
00107 }
00108
00109 QGridLayout *layout = new QGridLayout( 0, 1, 1, 0, KDialog::spacingHint());
00110
00111 spWidth = new KoUnitDoubleSpinBox(page, 0, 5, 0.5, 1.0, m_doc->unit(), 1);
00112 spWidth->setValue( m_doc->footNoteSeparatorLineWidth());
00113 layout->addWidget( spWidth, 1, 1 );
00114
00115 spLength = new KIntNumInput( page, "spLength" );
00116 spLength->setRange( 1, 100, 1,false );
00117 spLength->setValue( m_doc->footNoteSeparatorLineLength());
00118 spLength->setSuffix(i18n(" %"));
00119 layout->addWidget( spLength, 0, 1 );
00120
00121 QLabel *lSize = new QLabel( i18n( "&Width:"), page );
00122 lSize->setBuddy( spWidth );
00123 comment= i18n ("The width is the thickness of the separator line, set to 0 for no separator line.");
00124 QWhatsThis::add(lSize, comment);
00125 QWhatsThis::add(spWidth, comment);
00126 layout->addWidget( lSize, 1, 0 );
00127
00128 QSpacerItem* spacer = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
00129 layout->addMultiCell( spacer, 0, 1, 2, 2 );
00130
00131 QLabel *lWidth = new QLabel( i18n("&Size on page:"), page, "lWidth" );
00132 lWidth->setBuddy( spLength );
00133 comment= i18n ("The size of the separator line can be defined as a percentage of the width of the page.");
00134 QWhatsThis::add(spLength, comment);
00135 QWhatsThis::add(lWidth, comment);
00136 layout->addWidget( lWidth, 0, 0 );
00137 pageLayout->addLayout( layout );
00138
00139 QHBoxLayout *styleLayout = new QHBoxLayout( 0, 0, KDialog::spacingHint(), "styleLayout");
00140
00141 QLabel *styleLabel = new QLabel( i18n("Style:"), page );
00142 styleLayout->addWidget( styleLabel );
00143
00144 m_cbLineType = new QComboBox( page );
00145 QStringList lst;
00146 lst <<i18n("Solid");
00147 lst <<i18n("Dash Line");
00148 lst <<i18n("Dot Line");
00149 lst <<i18n("Dash Dot Line");
00150 lst <<i18n("Dash Dot Dot Line");
00151 m_cbLineType->insertStringList( lst );
00152 m_cbLineType->setCurrentItem( static_cast<int>(m_doc->footNoteSeparatorLineType()));
00153 comment= i18n ("The separator line can be drawn as a solid line or as a line which has a "
00154 "pattern; the pattern can be set in the style-type.");
00155 QWhatsThis::add(styleLabel, comment);
00156 QWhatsThis::add(m_cbLineType, comment);
00157 styleLayout->addWidget( m_cbLineType );
00158
00159 QSpacerItem* spacer_2 = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
00160 styleLayout->addItem( spacer_2 );
00161 pageLayout->addLayout( styleLayout );
00162 QSpacerItem* spacer_3 = new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding );
00163 pageLayout->addItem( spacer_3 );
00164 }
00165
00166
00167 void KWConfigFootNoteDia::slotOk()
00168 {
00169 KMacroCommand * macro = 0L;
00170 KCommand *cmd = 0L;
00171 KoParagCounter counter =static_cast<KWVariableSettings*>(m_doc->variableCollection()->variableSetting())->footNoteCounter();
00172 if (counter != m_footNoteConfig->counter() )
00173 {
00174 macro = new KMacroCommand(i18n("Change End-/Footnote Variable Settings"));
00175 cmd= new KWChangeFootEndNoteSettingsCommand( i18n("Change End-/Footnote Variable Settings") , counter, m_footNoteConfig->counter() ,true ,m_doc);
00176 macro->addCommand(cmd );
00177 }
00178 counter = static_cast<KWVariableSettings*>(m_doc->variableCollection()->variableSetting())->endNoteCounter();
00179 if (counter != m_endNoteConfig->counter() )
00180 {
00181 if ( !macro )
00182 macro = new KMacroCommand(i18n("Change End-/Footnote Variable Settings"));
00183 cmd= new KWChangeFootEndNoteSettingsCommand( i18n("Change End-/Footnote Variable Settings") , counter, m_endNoteConfig->counter() ,false ,m_doc);
00184 macro->addCommand(cmd );
00185 }
00186
00187 int val =spLength->value();
00188 double width = spWidth->value();
00189 SeparatorLinePos tmp = SLP_LEFT;
00190 SeparatorLineLineType type = static_cast<SeparatorLineLineType>(m_cbLineType->currentItem());
00191 if ( rbPosRight->isChecked())
00192 tmp = SLP_RIGHT;
00193 else if ( rbPosCentered->isChecked())
00194 tmp = SLP_CENTERED;
00195 else if ( rbPosLeft->isChecked())
00196 tmp = SLP_LEFT;
00197
00198 if ( (val != m_doc->footNoteSeparatorLineLength())||
00199 tmp != m_doc->footNoteSeparatorLinePosition()||
00200 width!= m_doc->footNoteSeparatorLineWidth() ||
00201 type != m_doc->footNoteSeparatorLineType())
00202 {
00203 if ( !macro )
00204 macro = new KMacroCommand(i18n("Change Footnote Line Separator Settings"));
00205 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);
00206 macro->addCommand( cmd );
00207 }
00208
00209 if ( macro )
00210 {
00211 macro->execute();
00212 m_doc->addCommand( macro );
00213 }
00214
00215 KDialogBase::slotOk();
00216 }