You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kbibtex/src/entryfield.cpp

228 lines
7.8 KiB

12 years ago
/***************************************************************************
* Copyright (C) 2004-2009 by Thomas Fischer *
* fischer@unix-ag.uni-kl.de *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program 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 General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "entryfield.h"
namespace BibTeX
{
EntryField::EntryField( FieldType fieldType ) : m_fieldType( fieldType )
{
m_fieldTypeName = fieldTypeToString( m_fieldType );
m_value = new Value();
}
EntryField::EntryField( const TQString &fieldTypeName ) : m_fieldTypeName( fieldTypeName )
12 years ago
{
m_fieldType = fieldTypeFromString( m_fieldTypeName );
m_value = new Value();
}
EntryField::EntryField( BibTeX::EntryField *other ) : m_fieldType( other->m_fieldType ), m_fieldTypeName( other->m_fieldTypeName ), m_value( NULL )
{
setValue( other->m_value );
}
EntryField::~EntryField()
{
delete m_value;
}
TQString EntryField::fieldTypeName() const
12 years ago
{
return m_fieldTypeName;
}
void EntryField::setFieldType( FieldType fieldType, const TQString& fieldTypeName )
12 years ago
{
m_fieldType = fieldType;
m_fieldTypeName = fieldTypeName;
}
EntryField::FieldType EntryField::fieldType() const
{
return m_fieldType;
}
TQString EntryField::fieldTypeToString( const FieldType fieldType )
12 years ago
{
switch ( fieldType )
{
case ftAbstract:
return TQString( "abstract" );
12 years ago
case ftAddress:
return TQString( "address" );
12 years ago
case ftAnnote:
return TQString( "annote" );
12 years ago
case ftAuthor:
return TQString( "author" );
12 years ago
case ftBookTitle:
return TQString( "booktitle" );
12 years ago
case ftChapter:
return TQString( "chapter" );
12 years ago
case ftCrossRef:
return TQString( "crossref" );
12 years ago
case ftDoi:
return TQString( "doi" );
12 years ago
case ftEdition:
return TQString( "edition" );
12 years ago
case ftEditor:
return TQString( "editor" );
12 years ago
case ftHowPublished:
return TQString( "howpublished" );
12 years ago
case ftInstitution:
return TQString( "institution" );
12 years ago
case ftISBN:
return TQString( "isbn" );
12 years ago
case ftISSN:
return TQString( "issn" );
12 years ago
case ftJournal:
return TQString( "journal" );
12 years ago
case ftKey:
return TQString( "key" );
12 years ago
case ftKeywords:
return TQString( "keywords" );
12 years ago
case ftLocalFile:
return TQString( "localfile" );
12 years ago
case ftLocation:
return TQString( "location" );
12 years ago
case ftMonth:
return TQString( "month" );
12 years ago
case ftNote:
return TQString( "note" );
12 years ago
case ftNumber:
return TQString( "number" );
12 years ago
case ftOrganization:
return TQString( "organization" );
12 years ago
case ftPages:
return TQString( "pages" );
12 years ago
case ftPublisher:
return TQString( "publisher" );
12 years ago
case ftSeries:
return TQString( "series" );
12 years ago
case ftSchool:
return TQString( "school" );
12 years ago
case ftTitle:
return TQString( "title" );
12 years ago
case ftType:
return TQString( "type" );
12 years ago
case ftURL:
return TQString( "url" );
12 years ago
case ftVolume:
return TQString( "volume" );
12 years ago
case ftYear:
return TQString( "year" );
12 years ago
default:
return TQString( "unknown" );
12 years ago
}
}
EntryField::FieldType EntryField::fieldTypeFromString( const TQString & fieldTypeString )
12 years ago
{
TQString fieldTypeStringLower = fieldTypeString.lower();
12 years ago
if ( fieldTypeStringLower == "abstract" )
return ftAbstract;
else if ( fieldTypeStringLower == "address" )
return ftAddress;
else if ( fieldTypeStringLower == "annote" )
return ftAnnote;
else if ( fieldTypeStringLower == "author" )
return ftAuthor;
else if ( fieldTypeStringLower == "booktitle" )
return ftBookTitle;
else if ( fieldTypeStringLower == "chapter" )
return ftChapter;
else if ( fieldTypeStringLower == "crossref" )
return ftCrossRef;
else if ( fieldTypeStringLower == "doi" )
return ftDoi;
else if ( fieldTypeStringLower == "edition" )
return ftEdition;
else if ( fieldTypeStringLower == "editor" )
return ftEditor;
else if ( fieldTypeStringLower == "howpublished" )
return ftHowPublished;
else if ( fieldTypeStringLower == "institution" )
return ftInstitution;
else if ( fieldTypeStringLower == "isbn" )
return ftISBN;
else if ( fieldTypeStringLower == "issn" )
return ftISSN;
else if ( fieldTypeStringLower == "journal" )
return ftJournal;
else if ( fieldTypeStringLower == "key" )
return ftKey;
else if ( fieldTypeStringLower == "keywords" )
return ftKeywords;
else if ( fieldTypeStringLower == "localfile" )
return ftLocalFile;
else if ( fieldTypeStringLower == "location" )
return ftLocation;
else if ( fieldTypeStringLower == "month" )
return ftMonth;
else if ( fieldTypeStringLower == "note" )
return ftNote;
else if ( fieldTypeStringLower == "number" )
return ftNumber;
else if ( fieldTypeStringLower == "organization" )
return ftOrganization;
else if ( fieldTypeStringLower == "pages" )
return ftPages;
else if ( fieldTypeStringLower == "publisher" )
return ftPublisher;
else if ( fieldTypeStringLower == "series" )
return ftSeries;
else if ( fieldTypeStringLower == "school" )
return ftSchool;
else if ( fieldTypeStringLower == "title" )
return ftTitle;
else if ( fieldTypeStringLower == "type" )
return ftType;
else if ( fieldTypeStringLower == "url" )
return ftURL;
else if ( fieldTypeStringLower == "volume" )
return ftVolume;
else if ( fieldTypeStringLower == "year" )
return ftYear;
else
return ftUnknown;
}
Value *EntryField::value()
{
return m_value;
}
void EntryField::setValue( const Value *value )
{
if ( value != m_value )
{
delete m_value;
if ( value != NULL )
{
m_value = new Value( value );
}
else
m_value = new Value();
}
}
}