Source.h header
#include <ew/core/Source.h>
Namespace ew::core
Source class
class ew::core::Source
A bibliographic source in the project's research library: a book, article, website, or other referenceable work. A Source is a first-class content object so it can be linked, embedded, searched, and shared through a library like any other. It carries its bibliographic kind, a citation key (the short handle used for in-text citations, e.g. "tolkien1954"), the work's title, and a bag of citation fields keyed by CSL (Citation Style Language) variable names – "author", "issued" (date), "container-title" (journal/book), "publisher", "volume", "page", "DOI", "URL", "accessed", and so on. Keeping the fields as an open key/value map (like an Entity's field values) lets any BibTeX/CSL field round-trip without a schema change; the citation formatters read the keys they know and ignore the rest.
Members
ew::core::Source::Source(ContentId id, SourceType type, QString title)
Creates a source of type with identity id and title (its citation key and fields start empty).
SourceType ew::core::Source::sourceType() const
The bibliographic kind (book, journal article, website, ...).
void ew::core::Source::setSourceType(SourceType type)
Sets the bibliographic kind.
const QString & ew::core::Source::title() const
The work's title (used for lists, links, previews, and the citation title field).
void ew::core::Source::setTitle(QString title)
Sets the work's title.
const QString & ew::core::Source::citationKey() const
The citation key: the short, stable handle used to cite this source in prose (e.g. "tolkien1954"). Empty until assigned; imports derive it from the BibTeX entry key.
void ew::core::Source::setCitationKey(QString citationKey)
Sets the citation key.
void ew::core::Source::setField(QString key, QString value)
Sets the value for citation field key (a CSL variable name), replacing any existing value.
std::optional< QString > ew::core::Source::field(QStringView key) const
Returns the value stored for citation field key, or std::nullopt if none is set.
bool ew::core::Source::hasField(QStringView key) const
Returns true if a value is stored for citation field key.
bool ew::core::Source::clearField(QStringView key)
Removes the value for citation field key. Returns true if a value was removed.
const std::map< QString, QString > & ew::core::Source::fields() const
All stored citation fields, keyed by CSL variable name in deterministic (sorted) order.
void ew::core::Source::setFields(std::map< QString, QString > fields)
Replaces every citation field at once (used to apply or undo a whole-source edit).