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
***************************************************************************/
26
#include <fieldlistview.h>
27
#include <entrywidgetwarningsitem.h>
28
#include "entrywidgetauthor.h"
33
EntryWidgetAuthor::EntryWidgetAuthor( BibTeX::File *bibtexfile, bool isReadOnly, QWidget *parent, const char *name )
34
: EntryWidgetTab( bibtexfile, isReadOnly, parent, name )
39
EntryWidgetAuthor::~EntryWidgetAuthor()
44
bool EntryWidgetAuthor::isModified()
46
return m_fieldListViewAuthor->isModified() || m_fieldListViewEditor->isModified();
49
void EntryWidgetAuthor::updateGUI( BibTeX::Entry::EntryType entryType, bool enableAll )
51
bool enableWidget = enableAll || BibTeX::Entry::getRequireStatus( entryType, BibTeX::EntryField::ftAuthor ) != BibTeX::Entry::frsIgnored;
52
m_fieldListViewAuthor->setEnabled( enableWidget );
54
enableWidget = enableAll || BibTeX::Entry::getRequireStatus( entryType, BibTeX::EntryField::ftEditor ) != BibTeX::Entry::frsIgnored;
55
m_fieldListViewEditor->setEnabled( enableWidget );
58
void EntryWidgetAuthor::apply( BibTeX::Entry *entry )
60
BibTeX::Value * value = m_fieldListViewAuthor->value();
61
setValue( entry, BibTeX::EntryField::ftAuthor, value );
62
if ( value != NULL ) delete value;
64
value = m_fieldListViewEditor->value();
65
setValue( entry, BibTeX::EntryField::ftEditor, value );
66
if ( value != NULL ) delete value;
69
void EntryWidgetAuthor::reset( BibTeX::Entry *entry )
71
BibTeX::EntryField * field = entry->getField( BibTeX::EntryField::ftAuthor );
72
m_fieldListViewAuthor->setValue( field != NULL ? field->value() : NULL );
74
field = entry->getField( BibTeX::EntryField::ftEditor );
75
m_fieldListViewEditor->setValue( field != NULL ? field->value() : NULL );
78
void EntryWidgetAuthor::updateWarnings( BibTeX::Entry::EntryType entryType, QListView *listViewWarnings )
80
if ( entryType == BibTeX::Entry::etBook || entryType == BibTeX::Entry::etInBook )
82
if ( m_fieldListViewAuthor->isEmpty() && m_fieldListViewEditor->isEmpty() )
83
new EntryWidgetWarningsItem( EntryWidgetWarningsItem::wlWarning, i18n( "The fields 'Author' or 'Editor' are required, but both are missing" ), m_fieldListViewAuthor, listViewWarnings, "warning" );
87
addMissingWarning( entryType, BibTeX::EntryField::ftAuthor, m_fieldListViewAuthor->caption(), !m_fieldListViewAuthor->isEmpty(), m_fieldListViewAuthor, listViewWarnings );
89
addMissingWarning( entryType, BibTeX::EntryField::ftEditor, m_fieldListViewEditor->caption(), !m_fieldListViewEditor->isEmpty(), m_fieldListViewEditor, listViewWarnings );
93
void EntryWidgetAuthor::setupGUI()
95
QGridLayout * gridLayout = new QGridLayout( this, 2, 3, KDialog::marginHint(), KDialog::spacingHint(), "gridLayout" );
96
gridLayout->setColSpacing( 1, KDialog::spacingHint() * 4 );
98
QLabel *label = new QLabel( QString( "%1:" ).arg( i18n( "Author" ) ), this );
99
gridLayout->addWidget( label, 0, 0 );
100
m_fieldListViewAuthor = new KBibTeX::FieldListView( i18n( "Author" ), i18n( "May only contain ASCII characters, in case of doubt keep English form", "NewAuthor" ), m_isReadOnly, this );
101
m_fieldListViewAuthor->setFieldType( BibTeX::EntryField::ftAuthor );
102
gridLayout->addWidget( m_fieldListViewAuthor, 1, 0 );
103
label->setBuddy( m_fieldListViewAuthor );
105
label = new QLabel( QString( "%1:" ).arg( i18n( "Editor" ) ), this );
106
gridLayout->addWidget( label, 0, 2 );
107
m_fieldListViewEditor = new KBibTeX::FieldListView( i18n( "Editor" ), i18n( "May only contain ASCII characters, in case of doubt keep English form", "NewEditor" ), m_isReadOnly, this );
108
m_fieldListViewEditor->setFieldType( BibTeX::EntryField::ftEditor );
109
gridLayout->addWidget( m_fieldListViewEditor, 1, 2 );
110
label->setBuddy( m_fieldListViewEditor );
114
#include "entrywidgetauthor.moc"