~ubuntu-branches/ubuntu/precise/kbibtex/precise

« back to all changes in this revision

Viewing changes to src/macrowidget.cpp

  • Committer: Package Import Robot
  • Author(s): Michael Hanke
  • Date: 2011-07-18 09:29:48 UTC
  • mfrom: (1.1.6) (2.1.5 sid)
  • Revision ID: package-import@ubuntu.com-20110718092948-ksxjmg7kdfamolmg
Tags: 0.3-1
* First upstream release for KDE4 (Closes: #634255). A number of search
  engines are still missing, in comparison to the 0.2 series.
* Bumped Standards-Version to 3.9.2, no changes necessary.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***************************************************************************
2
 
*   Copyright (C) 2004-2009 by Thomas Fischer                             *
3
 
*   fischer@unix-ag.uni-kl.de                                             *
4
 
*                                                                         *
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.                                   *
9
 
*                                                                         *
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.                          *
14
 
*                                                                         *
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
 
***************************************************************************/
20
 
#include <qlabel.h>
21
 
#include <qlayout.h>
22
 
 
23
 
#include <klineedit.h>
24
 
#include <kdialogbase.h>
25
 
#include <klocale.h>
26
 
#include <kdebug.h>
27
 
 
28
 
#include <element.h>
29
 
#include <fileexporterbibtex.h>
30
 
#include <fileimporterbibtex.h>
31
 
#include <fieldlineedit.h>
32
 
 
33
 
#include "macrowidget.h"
34
 
 
35
 
namespace KBibTeX
36
 
{
37
 
    QDialog::DialogCode MacroWidget::execute( BibTeX::Macro *macro, bool isReadOnly, QWidget *parent, const char *name )
38
 
    {
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" );
41
 
 
42
 
        dlg->setMainWidget( macroWidget );
43
 
        connect( dlg, SIGNAL( okClicked() ), macroWidget, SLOT( apply() ) );
44
 
 
45
 
        QDialog::DialogCode result = ( QDialog::DialogCode ) dlg->exec();
46
 
 
47
 
        delete( macroWidget );
48
 
        delete( dlg );
49
 
 
50
 
        return result;
51
 
    }
52
 
 
53
 
    MacroWidget::MacroWidget( BibTeX::Macro *bibtexmacro, bool isReadOnly, QWidget *parent, const char *name )
54
 
            : QWidget( parent, name ), m_isReadOnly( isReadOnly ), m_bibtexmacro( bibtexmacro )
55
 
    {
56
 
        setupGUI();
57
 
        reset();
58
 
    }
59
 
 
60
 
    MacroWidget::~MacroWidget()
61
 
    {
62
 
        // nothing
63
 
    }
64
 
 
65
 
    void MacroWidget::apply()
66
 
    {
67
 
        m_bibtexmacro->setKey( m_lineEditMacroId->text() );
68
 
        BibTeX::Value *value = m_fieldLineEditMacroValue->value();
69
 
        m_bibtexmacro->setValue( value );
70
 
    }
71
 
 
72
 
    void MacroWidget::reset()
73
 
    {
74
 
        m_lineEditMacroId->setText( m_bibtexmacro->key() );
75
 
        m_fieldLineEditMacroValue->setValue( m_bibtexmacro->value() );
76
 
    }
77
 
 
78
 
    void MacroWidget::setupGUI()
79
 
    {
80
 
        setMinimumWidth( 384 );
81
 
 
82
 
        QVBoxLayout * layout = new QVBoxLayout( this, 0, KDialog::spacingHint() );
83
 
 
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 );
90
 
 
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 );
96
 
    }
97
 
}
98
 
 
99
 
#include "macrowidget.moc"