[KLF Application][KLF Tools][KLF Backend][KLF Home]
KLatexFormula Project
Public Types | Public Member Functions | Static Public Member Functions | List of all members
KLFLibEntry Class Reference

An entry (single formula) in the library. More...

#include <klflib.h>

Inheritance diagram for KLFLibEntry:
Inheritance graph
[legend]
Collaboration diagram for KLFLibEntry:
Collaboration graph
[legend]

Public Types

enum  PropertyId {
  Latex = 0, DateTime, Preview, PreviewSize,
  Category, Tags, Style
}
 
- Public Types inherited from KLFPropertizedObject
enum  ToStringFlag
 

Public Member Functions

 KLFLibEntry (const QString &latex=QString(), const QDateTime &dt=QDateTime(), const QImage &preview=QImage(), const QSize &previewsize=QSize(), const QString &category=QString(), const QString &tags=QString(), const KLFStyle &style=KLFStyle())
 
 KLFLibEntry (const QString &latex, const QDateTime &dt, const QImage &preview, const KLFStyle &style)
 
 KLFLibEntry (const KLFLibEntry &copy)
 
virtual ~KLFLibEntry ()
 
QString latex () const
 
QDateTime dateTime () const
 
QImage preview () const
 
QSize previewSize () const
 
QString category () const
 
QString tags () const
 
KLFStyle style () const
 
QString latexWithCategoryTagsComments () const
 
void setLatex (const QString &latex)
 
void setDateTime (const QDateTime &dt)
 
void setPreview (const QImage &img)
 
void setPreviewSize (const QSize &sz)
 
void setCategory (const QString &s)
 
void setTags (const QString &s)
 
void setStyle (const KLFStyle &style)
 
int setEntryProperty (const QString &propName, const QVariant &value)
 
- Public Member Functions inherited from KLFPropertizedObject
 KLFPropertizedObject (const QString &propertyNameSpace)
 
virtual ~KLFPropertizedObject ()
 
virtual QVariant property (const QString &propName) const
 
virtual QVariant property (int propId) const
 
QList< int > propertyIdList () const
 
QStringList propertyNameList () const
 
QMap< QString, QVariantallProperties () const
 
void setAllProperties (const QMap< QString, QVariant > &propValues)
 
QByteArray allPropertiesToByteArray () const
 
void setAllPropertiesFromByteArray (const QByteArray &data)
 
virtual QString toString (uint toStringFlags=0) const
 
int propertyMaxId () const
 
bool propertyIdRegistered (int propId) const
 
bool propertyNameRegistered (const QString &propertyName) const
 
int propertyIdForName (const QString &propertyName) const
 
QString propertyNameForId (int propId) const
 
QList< int > registeredPropertyIdList () const
 
QStringList registeredPropertyNameList () const
 
QMap< QString, int > registeredProperties () const
 

Static Public Member Functions

static QString categoryFromLatex (const QString &latex)
 
static QString tagsFromLatex (const QString &latex)
 
static QString stripCategoryTagsFromLatex (const QString &latex)
 
static QString latexAddCategoryTagsComment (const QString &latex, const QString &category, const QString &tags)
 
static QString normalizeCategoryPath (const QString &categoryPath)
 

Additional Inherited Members

- Public Attributes inherited from KLFPropertizedObject
 ToStringUseHtml
 
 ToStringUseHtmlDiv
 
 ToStringQuoteValues
 
 ToStringAllProperties
 
- Protected Member Functions inherited from KLFPropertizedObject
virtual void propertyValueChanged (int propId, const QVariant &oldValue, const QVariant &newValue)
 
virtual void setProperty (const QString &propname, const QVariant &value)
 
virtual void setProperty (int propId, const QVariant &value)
 
virtual int loadProperty (const QString &propname, const QVariant &value)
 
void registerBuiltInProperty (int propId, const QString &propName) const
 
int registerProperty (const QString &propertyName) const
 
QString propertyNameSpace () const
 
QVector< QVariantpropertyVector () const
 
- Static Protected Member Functions inherited from KLFPropertizedObject
static void registerBuiltInProperty (const QString &propNameSpace, int propId, const QString &name)
 
static int registerProperty (const QString &propNameSpace, const QString &propertyName)
 
static int propertyMaxId (const QString &propNameSpace)
 
static bool propertyIdRegistered (const QString &propNameSpace, int propId)
 
static bool propertyNameRegistered (const QString &propNameSpace, const QString &propertyName)
 
static int propertyIdForName (const QString &propNameSpace, const QString &propertyName)
 
static QString propertyNameForId (const QString &propNameSpace, int propId)
 
static QList< int > registeredPropertyIdList (const QString &propNameSpace)
 
static QStringList registeredPropertyNameList (const QString &propNameSpace)
 
static QMap< QString, int > registeredProperties (const QString &propNameSpace)
 

Detailed Description

An entry (single formula) in the library.

Stores Latex code, Date/Time of evaluation, A preview image, A Category String, A Tags String, and a Style in a KLFPropertizedObject-based object.

This object can be used as a normal value (ie. it has copy constructor, assignment operator and default constructor).

Definition at line 55 of file klflib.h.

Member Enumeration Documentation

Note
The numeric IDs don't have to be preserved from one version of KLF to another, since they are nowhere stored. Properties are always stored by name when dealing in scopes larger than the running application (saved files, etc.).
Enumerator
Latex 

The Latex Code of the equation.

DateTime 

The Date/Time at which the equation was evaluated.

Preview 

An Image Preview of equation (scaled down QImage)

PreviewSize 

A cached value of the size of value in Preview.

Category 

The Category to which eq. belongs (path-style string)

Tags 

Tags about the equation (string)

Style 

KLFStyle style used.

Definition at line 61 of file klflib.h.

Constructor & Destructor Documentation

KLFLibEntry::KLFLibEntry ( const QString latex = QString(),
const QDateTime dt = QDateTime(),
const QImage preview = QImage(),
const QSize previewsize = QSize(),
const QString category = QString(),
const QString tags = QString(),
const KLFStyle style = KLFStyle() 
)
KLFLibEntry::KLFLibEntry ( const QString latex,
const QDateTime dt,
const QImage preview,
const KLFStyle style 
)

This constructor extracts the legacy-style category and tags from latex, and stores latex with those tags stripped.

Definition at line 64 of file klflib.cpp.

References category(), categoryFromLatex(), setCategory(), setDateTime(), setLatex(), setPreview(), setPreviewSize(), setStyle(), setTags(), QImage::size(), stripCategoryTagsFromLatex(), tags(), and tagsFromLatex().

KLFLibEntry::KLFLibEntry ( const KLFLibEntry copy)
KLFLibEntry::~KLFLibEntry ( )
virtual

Definition at line 87 of file klflib.cpp.

Member Function Documentation

QString KLFLibEntry::category ( ) const
inline
QString KLFLibEntry::categoryFromLatex ( const QString latex)
static

Parses and returns legacy-style category comment string from latex string in the form

%: Category

Definition at line 122 of file klflib.cpp.

References QString::mid(), and QString::section().

Referenced by KLFLibEntry(), and operator>>().

QDateTime KLFLibEntry::dateTime ( ) const
inline
QString KLFLibEntry::latex ( ) const
inline
QString KLFLibEntry::latexAddCategoryTagsComment ( const QString latex,
const QString category,
const QString tags 
)
static

Creates a latex with category and tags comments

Definition at line 179 of file klflib.cpp.

References QString::isEmpty(), and latex().

Referenced by KLFLibLegacyEngine::changeEntries(), and KLFLibLegacyFileDataPrivate::toLegacyLibItem().

QString KLFLibEntry::latexWithCategoryTagsComments ( ) const
inline

Definition at line 90 of file klflib.h.

Referenced by KLFMainWin::restoreFromLibrary().

QString KLFLibEntry::normalizeCategoryPath ( const QString categoryPath)
static

Renders a category-path "pretty" by removing any double-slashes to single slashes. Trailing slashes are removed. The root category is an empty string.

When a category is set to a lib-entry with setCategory(), it is automatically normalized.

Returned paths may be compared string-wise for equality.

Definition at line 195 of file klflib.cpp.

References QString::chop(), QString::endsWith(), and QString::trimmed().

Referenced by KLFLibModelCache::fetchMore().

QImage KLFLibEntry::preview ( ) const
inline
QSize KLFLibEntry::previewSize ( ) const
inline
void KLFLibEntry::setCategory ( const QString s)
inline
Note
this function normalizes category to remove any double-'/' to avoid empty sections. Equality between categories can be compared stringwise.

See also normalizeCategoryPath().

Definition at line 101 of file klflib.h.

References KLFPropertizedObject::setProperty().

Referenced by KLFLibEntry().

void KLFLibEntry::setDateTime ( const QDateTime dt)
inline

Definition at line 94 of file klflib.h.

References KLFPropertizedObject::setProperty().

Referenced by KLFLibEntry().

int KLFLibEntry::setEntryProperty ( const QString propName,
const QVariant value 
)

Set the property named name to value value. If the property does not yet exist in the registered properties, it is registered.

Returns
-1 for error, or the property ID that was successfully (maybe registered and) set.

Definition at line 92 of file klflib.cpp.

References Category, DateTime, KLF_FUNC_SINGLE_RUN, Latex, Preview, PreviewSize, KLFPropertizedObject::propertyIdForName(), propId, KLFPropertizedObject::registerBuiltInProperty(), KLFPropertizedObject::registerProperty(), KLFPropertizedObject::setProperty(), Style, and Tags.

Referenced by KLFLibDBEngine::saveResourceProperty().

void KLFLibEntry::setLatex ( const QString latex)
inline

Definition at line 93 of file klflib.h.

References KLFPropertizedObject::setProperty().

Referenced by KLFLibEntry().

void KLFLibEntry::setPreview ( const QImage img)
inline

Definition at line 95 of file klflib.h.

References KLFPropertizedObject::setProperty().

Referenced by KLFLibEntry().

void KLFLibEntry::setPreviewSize ( const QSize sz)
inline

Definition at line 96 of file klflib.h.

References KLFPropertizedObject::setProperty().

Referenced by KLFLibEntry(), and KLFLibDBEngine::saveResourceProperty().

void KLFLibEntry::setStyle ( const KLFStyle style)
inline

Definition at line 103 of file klflib.h.

References QVariant::fromValue(), Q_DECLARE_METATYPE(), and KLFPropertizedObject::setProperty().

Referenced by KLFLibEntry().

void KLFLibEntry::setTags ( const QString s)
inline

Definition at line 102 of file klflib.h.

References KLFPropertizedObject::setProperty().

Referenced by KLFLibEntry().

QString KLFLibEntry::stripCategoryTagsFromLatex ( const QString latex)
static

Removes legacy-style category and tags comment from latex string

Definition at line 145 of file klflib.cpp.

References QString::length(), and QString::mid().

Referenced by KLFLibLegacyEngine::changeEntries(), KLFLibEntry(), KLFLibLegacyFileDataPrivate::toLegacyLibItem(), and KLFLibLegacyFileDataPrivate::toLibEntry().

KLFStyle KLFLibEntry::style ( ) const
inline
QString KLFLibEntry::tags ( ) const
inline
QString KLFLibEntry::tagsFromLatex ( const QString latex)
static

Parses and returns legacy-style tags comment string from latex string

Definition at line 131 of file klflib.cpp.

References QString::mid(), and QString::section().

Referenced by KLFLibEntry(), and operator>>().


The documentation for this class was generated from the following files:

Generated by doxygen 1.8.11