1
/***************************************************************************
2
* Copyright (C) 2004-2009 by Thomas Fischer *
3
* fischer@unix-ag.uni-kl.de *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License as published by *
7
* the Free Software Foundation; either version 2 of the License, or *
8
* (at your option) any later version. *
10
* This program is distributed in the hope that it will be useful, *
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13
* GNU General Public License for more details. *
15
* You should have received a copy of the GNU General Public License *
16
* along with this program; if not, write to the *
17
* Free Software Foundation, Inc., *
18
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19
***************************************************************************/
23
#include <klineedit.h>
24
#include <kdialogbase.h>
29
#include <fileexporterbibtex.h>
30
#include <fileimporterbibtex.h>
31
#include <fieldlineedit.h>
33
#include "macrowidget.h"
37
QDialog::DialogCode MacroWidget::execute( BibTeX::Macro *macro, bool isReadOnly, QWidget *parent, const char *name )
39
KDialogBase * dlg = new KDialogBase( parent, name, TRUE, i18n( "Edit BibTeX Macro" ), KDialogBase::Ok | KDialogBase::Cancel );
40
MacroWidget* macroWidget = new MacroWidget( macro, isReadOnly, dlg, "MacroWidget" );
42
dlg->setMainWidget( macroWidget );
43
connect( dlg, SIGNAL( okClicked() ), macroWidget, SLOT( apply() ) );
45
QDialog::DialogCode result = ( QDialog::DialogCode ) dlg->exec();
47
delete( macroWidget );
53
MacroWidget::MacroWidget( BibTeX::Macro *bibtexmacro, bool isReadOnly, QWidget *parent, const char *name )
54
: QWidget( parent, name ), m_isReadOnly( isReadOnly ), m_bibtexmacro( bibtexmacro )
60
MacroWidget::~MacroWidget()
65
void MacroWidget::apply()
67
m_bibtexmacro->setKey( m_lineEditMacroId->text() );
68
BibTeX::Value *value = m_fieldLineEditMacroValue->value();
69
m_bibtexmacro->setValue( value );
72
void MacroWidget::reset()
74
m_lineEditMacroId->setText( m_bibtexmacro->key() );
75
m_fieldLineEditMacroValue->setValue( m_bibtexmacro->value() );
78
void MacroWidget::setupGUI()
80
setMinimumWidth( 384 );
82
QVBoxLayout * layout = new QVBoxLayout( this, 0, KDialog::spacingHint() );
84
QLabel *label = new QLabel( i18n( "Macro &id:" ), this );
85
layout->addWidget( label );
86
m_lineEditMacroId = new KLineEdit( this, "m_lineEditMacroId" );
87
m_lineEditMacroId->setReadOnly( m_isReadOnly );
88
layout->addWidget( m_lineEditMacroId );
89
label->setBuddy( m_lineEditMacroId );
91
label = new QLabel( i18n( "Macro &value:" ), this );
92
layout->addWidget( label );
93
m_fieldLineEditMacroValue = new KBibTeX::FieldLineEdit( i18n( "Macro" ), KBibTeX::FieldLineEdit::itMultiLine, m_isReadOnly, this, "m_fieldLineEditMacroValue" );
94
layout->addWidget( m_fieldLineEditMacroValue );
95
label->setBuddy( m_fieldLineEditMacroValue );
99
#include "macrowidget.moc"