QElectroTech  0.70
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
DiagramContext Class Reference

#include <diagramcontext.h>

Public Types

enum  KeyOrder { None, Alphabetical, DecreasingLength }
 

Public Member Functions

void add (DiagramContext other)
 DiagramContext::add Add all value of to this. If a key already exist, the value is replaced. If a key doesn't exist, she will be added. All other keys of this context, which are not present in , stay unchanged. More...
 
QList< QString > keys (KeyOrder=None) const
 
bool contains (const QString &) const
 
const QVariant operator[] (const QString &) const
 
bool addValue (const QString &, const QVariant &, bool show=true)
 
QVariant value (const QString &key) const
 
void clear ()
 
int count ()
 
bool keyMustShow (const QString &) const
 DiagramContext::keyMustShow. More...
 
bool operator== (const DiagramContext &) const
 
bool operator!= (const DiagramContext &) const
 
void toXml (QDomElement &, const QString &="property") const
 
void fromXml (const QDomElement &, const QString &="property")
 
void toSettings (QSettings &, const QString &) const
 
void fromSettings (QSettings &, const QString &)
 

Static Public Member Functions

static QString validKeyRegExp ()
 

Private Member Functions

bool keyIsAcceptable (const QString &) const
 

Static Private Member Functions

static bool stringLongerThan (const QString &, const QString &)
 

Private Attributes

QHash< QString, QVariant > m_content
 Diagram context data (key/value pairs) More...
 
QHash< QString, bool > m_content_show
 

Detailed Description

This class represents a diagram context, i.e. the data (a list of key/value pairs) of a diagram at a given time. It is notably used by titleblock templates to fetch the informations they need to do their rendering, or element for retrieve information about itself Key for element : label -> label or identification of element formula -> formula used to create the label (formula is make with variable) designation -> exhaustive comment used to explain what the element does. description -> exhaustive description used to explain what the element does. plant -> the plant assigned to the element comment -> a little comment wich can be displayed in the folio manufacturer -> the manufacturer of the element manufacturer-reference -> the manufacturer reference of the element quantity -> quantity of the element unity -> unity of the element auxiliary1 -> auxiliary 1 of element auxiliary2 -> auxiliary 2 of element machine-manufacturer-reference -> reference of the machine manufacturer supplier -> the supplier of the element function -> the function of element location -> the location assigned to the element frozenLabel -> label locked at a given time

Definition at line 53 of file diagramcontext.h.

Member Enumeration Documentation

◆ KeyOrder

Enumerator
None 
Alphabetical 
DecreasingLength 

Definition at line 56 of file diagramcontext.h.

Member Function Documentation

◆ add()

void DiagramContext::add ( DiagramContext  other)

DiagramContext::add Add all value of to this. If a key already exist, the value is replaced. If a key doesn't exist, she will be added. All other keys of this context, which are not present in , stay unchanged.

Parameters
other

Definition at line 31 of file diagramcontext.cpp.

References addValue(), keys(), and value().

Referenced by SearchAndReplaceWorker::replaceDiagram().

◆ addValue()

bool DiagramContext::addValue ( const QString &  key,
const QVariant &  value,
bool  show = true 
)
Parameters
keykey to insert in the context - the key may only contain lowercase letters and dashes. If embedded key is set, key must be find it else value is not added.
See also
DiagramContext::keyIsAcceptable()
Parameters
valuevalue to insert in the context
showif value is used to be show on the diagram or somewhere else, we can specify if he is show(true) or not(false)
Returns
true if the insertion succeeds, false otherwise

Definition at line 83 of file diagramcontext.cpp.

References keyIsAcceptable(), m_content, m_content_show, and value().

Referenced by add(), TitleBlockPropertiesWidget::changeCurrentTitleBlockTemplate(), DiagramContextWidget::context(), ReplaceElementDialog::context(), ElementInfoWidget::currentInfo(), fromSettings(), fromXml(), Element::fromXml(), ElementPropertiesEditorWidget::on_m_buttonBox_accepted(), PasteDiagramCommand::redo(), SearchAndReplaceWorker::replaceAdvanced(), SearchAndReplaceWorker::replaceElement(), QETProject::setFilePath(), BorderTitleBlock::setNextFolioNum(), BorderTitleBlock::setPreviousFolioNum(), Element::setUpFormula(), BorderTitleBlock::updateDiagramContextForTitleBlock(), QETProject::updateDiagramsFolioData(), and QETProject::write().

◆ clear()

void DiagramContext::clear ( )

Clear the content of this diagram context.

Definition at line 99 of file diagramcontext.cpp.

References m_content, and m_content_show.

Referenced by TitleBlockProperties::fromXml().

◆ contains()

bool DiagramContext::contains ( const QString &  key) const
Parameters
keystring key
Returns
true if that key is known to the diagram context, false otherwise

Definition at line 62 of file diagramcontext.cpp.

References m_content.

Referenced by DynamicTextItemDelegate::availableInfo(), CrossRefItem::elementPositionText(), Element::fromXml(), and SearchAndReplaceWorker::replaceAdvanced().

◆ count()

int DiagramContext::count ( )
Returns
the number of key/value pairs stored in this object.

Definition at line 107 of file diagramcontext.cpp.

References m_content.

Referenced by autonum::AssignVariables::assignProjectVar(), and autonum::AssignVariables::assignTitleBlockVar().

◆ fromSettings()

void DiagramContext::fromSettings ( QSettings &  settings,
const QString &  array_name 
)

Read this context properties from settings by running through the array named array_name.

Definition at line 177 of file diagramcontext.cpp.

References addValue().

Referenced by TitleBlockProperties::fromSettings().

◆ fromXml()

void DiagramContext::fromXml ( const QDomElement &  e,
const QString &  tag_name = "property" 
)

Read this context properties from the e XML element, looking for tags named tag_name (defaults to "property").

Definition at line 149 of file diagramcontext.cpp.

References addValue(), QET::findInDomElement(), and m_content_show.

Referenced by ElementScene::applyInformations(), Element::buildFromXml(), ElementsLocation::elementInformations(), TitleBlockProperties::fromXml(), Element::fromXml(), and QETProject::readProjectPropertiesXml().

◆ keyIsAcceptable()

bool DiagramContext::keyIsAcceptable ( const QString &  key) const
private
Parameters
keya key string
Returns
true if that key is acceptable, false otherwise

Definition at line 207 of file diagramcontext.cpp.

References validKeyRegExp().

Referenced by addValue().

◆ keyMustShow()

bool DiagramContext::keyMustShow ( const QString &  key) const

DiagramContext::keyMustShow.

Returns
the value pairs with key, if key no found, return false

Definition at line 115 of file diagramcontext.cpp.

References m_content_show.

Referenced by Element::fromXml().

◆ keys()

QList< QString > DiagramContext::keys ( DiagramContext::KeyOrder  order = None) const

◆ operator!=()

bool DiagramContext::operator!= ( const DiagramContext dc) const

Definition at line 126 of file diagramcontext.cpp.

◆ operator==()

bool DiagramContext::operator== ( const DiagramContext dc) const

Definition at line 121 of file diagramcontext.cpp.

References m_content, and m_content_show.

◆ operator[]()

const QVariant DiagramContext::operator[] ( const QString &  key) const
Parameters
key

Definition at line 69 of file diagramcontext.cpp.

References m_content.

◆ stringLongerThan()

bool DiagramContext::stringLongerThan ( const QString &  a,
const QString &  b 
)
staticprivate
Returns
True if a is longer than b, false otherwise.

Definition at line 199 of file diagramcontext.cpp.

Referenced by keys().

◆ toSettings()

void DiagramContext::toSettings ( QSettings &  settings,
const QString &  array_name 
) const

Export this context properties to settings by creating an array named array_name.

Definition at line 161 of file diagramcontext.cpp.

References m_content.

Referenced by TitleBlockProperties::toSettings().

◆ toXml()

void DiagramContext::toXml ( QDomElement &  e,
const QString &  tag_name = "property" 
) const

Export this context properties under the e XML element, using tags named tag_name (defaults to "property").

Definition at line 134 of file diagramcontext.cpp.

References keys(), m_content, m_content_show, and value().

Referenced by TitleBlockProperties::toXml(), ElementScene::toXml(), Element::toXml(), and QETProject::writeProjectPropertiesXml().

◆ validKeyRegExp()

QString DiagramContext::validKeyRegExp ( )
static
Returns
the regular expression used to check whether a given key is acceptable.
See also
keyIsAcceptable()

Definition at line 192 of file diagramcontext.cpp.

Referenced by DiagramContextWidget::highlightNonAcceptableKeys(), and keyIsAcceptable().

◆ value()

QVariant DiagramContext::value ( const QString &  key) const

Member Data Documentation

◆ m_content

QHash<QString, QVariant> DiagramContext::m_content
private

Diagram context data (key/value pairs)

Definition at line 86 of file diagramcontext.h.

Referenced by addValue(), clear(), contains(), count(), keys(), operator==(), operator[](), toSettings(), toXml(), and value().

◆ m_content_show

QHash<QString, bool> DiagramContext::m_content_show
private

Definition at line 87 of file diagramcontext.h.

Referenced by addValue(), clear(), fromXml(), keyMustShow(), operator==(), and toXml().


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