From 4e8552eaba7db6d5c34565918af4858990c713cf Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Mon, 21 Apr 2008 12:12:07 +0000 Subject: [PATCH] Add an author contact info field - this will ease the creation of kns2 meta data directly from the xml. svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=799379 --- keduvocdocument/keduvocdocument.cpp | 24 +++++++++++++++++------- keduvocdocument/keduvocdocument.h | 7 +++++++ keduvocdocument/keduvockvtml2reader.cpp | 5 +++++ keduvocdocument/keduvockvtml2writer.cpp | 5 +++++ keduvocdocument/kvtml2defs.h | 1 + 5 files changed, 35 insertions(+), 7 deletions(-) diff --git a/keduvocdocument/keduvocdocument.cpp b/keduvocdocument/keduvocdocument.cpp index 1c386cc..6bb747a 100644 --- a/keduvocdocument/keduvocdocument.cpp +++ b/keduvocdocument/keduvocdocument.cpp @@ -85,6 +85,7 @@ public: QString m_title; QString m_author; + QString m_authorContact; QString m_license; QString m_comment; QString m_version; @@ -746,25 +747,37 @@ void KEduVocDocument::setUrl( const KUrl& url ) QString KEduVocDocument::title() const { - if ( d->m_lessonContainer->name().isEmpty() ) + if ( d->m_title.isEmpty() ) return d->m_url.fileName(); else return d->m_title; } - void KEduVocDocument::setTitle( const QString & title ) { d->m_title = title; d->m_lessonContainer->setName(title); } - QString KEduVocDocument::author() const { return d->m_author; } +void KEduVocDocument::setAuthor( const QString & s ) +{ + d->m_author = s.simplified(); +} + +QString KEduVocDocument::authorContact() const +{ + return d->m_authorContact; +} + +void KEduVocDocument::setAuthorContact( const QString & s ) +{ + d->m_authorContact = s.simplified(); +} QString KEduVocDocument::license() const { @@ -802,10 +815,7 @@ void KEduVocDocument::setQueryIdentifier( const QString &org, const QString &tra } -void KEduVocDocument::setAuthor( const QString & s ) -{ - d->m_author = s.simplified(); -} + void KEduVocDocument::setLicense( const QString & s ) diff --git a/keduvocdocument/keduvocdocument.h b/keduvocdocument/keduvocdocument.h index 5e05a1a..a206728 100644 --- a/keduvocdocument/keduvocdocument.h +++ b/keduvocdocument/keduvocdocument.h @@ -159,6 +159,13 @@ public: /** @returns the author of the file */ QString author() const; + /** set the author contact info + * @param contact email/contact info to set */ + void setAuthorContact( const QString & authorContact ); + + /** @returns the author contact information */ + QString authorContact() const; + /** set the license of the file * @param license license to set */ void setLicense( const QString & license ); diff --git a/keduvocdocument/keduvockvtml2reader.cpp b/keduvocdocument/keduvockvtml2reader.cpp index 789c83e..d3801d4 100644 --- a/keduvocdocument/keduvockvtml2reader.cpp +++ b/keduvocdocument/keduvockvtml2reader.cpp @@ -114,6 +114,11 @@ bool KEduVocKvtml2Reader::readInformation( QDomElement &informationElement ) m_doc->setAuthor( currentElement.text() ); } + currentElement = informationElement.firstChildElement( KVTML_AUTHORCONTACT ); + if ( !currentElement.isNull() ) { + m_doc->setAuthorContact( currentElement.text() ); + } + // read the license currentElement = informationElement.firstChildElement( KVTML_LICENSE ); if ( !currentElement.isNull() ) { diff --git a/keduvocdocument/keduvockvtml2writer.cpp b/keduvocdocument/keduvockvtml2writer.cpp index 4a1b30e..64ee0c4 100644 --- a/keduvocdocument/keduvockvtml2writer.cpp +++ b/keduvocdocument/keduvockvtml2writer.cpp @@ -112,6 +112,11 @@ bool KEduVocKvtml2Writer::writeInformation( QDomElement &informationElement, con informationElement.appendChild( newTextElement( KVTML_AUTHOR, m_doc->author() ) ); } + // author contact (mail/homepage) + if ( !m_doc->authorContact().isEmpty() ) { + informationElement.appendChild( newTextElement( KVTML_AUTHORCONTACT, m_doc->authorContact() ) ); + } + // license if ( !m_doc->license().isEmpty() ) { informationElement.appendChild( newTextElement( KVTML_LICENSE, m_doc->license() ) ); diff --git a/keduvocdocument/kvtml2defs.h b/keduvocdocument/kvtml2defs.h index ac816a2..c4dd617 100644 --- a/keduvocdocument/kvtml2defs.h +++ b/keduvocdocument/kvtml2defs.h @@ -26,6 +26,7 @@ #define KVTML_GENERATOR "generator" #define KVTML_TITLE "title" #define KVTML_AUTHOR "author" +#define KVTML_AUTHORCONTACT "contact" #define KVTML_LICENSE "license" #define KVTML_COMMENT "comment" #define KVTML_CATEGORY "category" -- 2.47.3