QElectroTech  0.70
Public Member Functions | Static Public Attributes | Protected Member Functions | Private Attributes | List of all members
NamesList Class Reference

#include <nameslist.h>

Public Member Functions

 NamesList ()
 
 NamesList (const NamesList &)
 
virtual ~NamesList ()
 
void addName (const QString &, const QString &)
 
void removeName (const QString &)
 
void clearNames ()
 
QList< QString > langs () const
 
bool isEmpty () const
 
int count () const
 
QString & operator[] (const QString &)
 
const QString operator[] (const QString &) const
 
bool operator!= (const NamesList &) const
 
bool operator== (const NamesList &) const
 
QString name (const QString &=QString()) const
 
void fromXml (const QDomElement &, const QHash< QString, QString > &=QHash< QString, QString >())
 
QDomElement toXml (QDomDocument &, const QHash< QString, QString > &=QHash< QString, QString >()) const
 

Static Public Attributes

static int MetaTypeId = qRegisterMetaType<NamesList>("NamesList")
 

Protected Member Functions

QHash< QString, QString > getXmlOptions (const QHash< QString, QString > &=QHash< QString, QString >()) const
 

Private Attributes

QHash< QString, QString > hash_names
 

Detailed Description

Cette classe represente une liste de noms, utilisee par les elements et categories pour embarquer un meme nom en plusieurs langues. Les langues sont representees par deux lettres (typiquement : les deux premieres de la locale du systeme) ; exemples : en pour l'anglais, fr pour le francais.

Definition at line 29 of file nameslist.h.

Constructor & Destructor Documentation

◆ NamesList() [1/2]

NamesList::NamesList ( )

Constructeur

Definition at line 27 of file nameslist.cpp.

◆ NamesList() [2/2]

NamesList::NamesList ( const NamesList other)

Constructeur de copie

Parameters
otherLa NamesList a copier

Definition at line 34 of file nameslist.cpp.

◆ ~NamesList()

NamesList::~NamesList ( )
virtual

Destructeur

Definition at line 40 of file nameslist.cpp.

Member Function Documentation

◆ addName()

void NamesList::addName ( const QString &  lang,
const QString &  name 
)

Ajoute un nom a la liste

Parameters
langSigle de deux lettres representant une langue. Si cela n'est pas respecte, l'insertion n'est pas effectuee.
nameNom lui-meme. Ce ne doit pas etre une chaine de caractere vide. Si cela n'est pas respecte, l'insertion n'est pas effectuee.

Definition at line 50 of file nameslist.cpp.

References hash_names, and name().

Referenced by NewElementWizard::buildStep3(), ElementsCategoryEditor::ElementsCategoryEditor(), fromXml(), NameListWidget::names(), QETProject::namesListForIntegrationCategory(), and XmlElementCollection::XmlElementCollection().

◆ clearNames()

void NamesList::clearNames ( )

Supprime tous les noms

Definition at line 66 of file nameslist.cpp.

References hash_names.

◆ count()

int NamesList::count ( ) const
Returns
Le nombre de noms dans la liste

Definition at line 87 of file nameslist.cpp.

References hash_names.

◆ fromXml()

void NamesList::fromXml ( const QDomElement &  xml_element,
const QHash< QString, QString > &  xml_options = QHash<QString, QString>() 
)

Charge la liste de noms depuis un element XML. Cet element est sense etre le parent d'un element "names", qui contient lui meme les "name". Les noms precedemment contenus dans la liste ne sont pas effaces mais peuvent etre ecrases.

Parameters
xml_elementL'element XML a analyser
xml_optionsA set of options related to XML parsing.
See also
getXmlOptions()

Definition at line 120 of file nameslist.cpp.

References addName(), getXmlOptions(), and name().

Referenced by ElementScene::applyInformations(), Element::buildFromXml(), and TitleBlockCell::loadContentFromXml().

◆ getXmlOptions()

QHash< QString, QString > NamesList::getXmlOptions ( const QHash< QString, QString > &  xml_options = QHash<QString, QString>()) const
protected
Parameters
xml_optionsA set of options related to XML parsing. Available keys: ParentTagName (falls back to "names") TagName (falls back to "name") LanguageAttribute (falls back to "lang")
Returns
the same set, with at least all the known options

Definition at line 164 of file nameslist.cpp.

Referenced by fromXml(), and toXml().

◆ isEmpty()

bool NamesList::isEmpty ( ) const
Returns
true si la liste de noms est vide, false sinon

Definition at line 80 of file nameslist.cpp.

References hash_names.

Referenced by TitleBlockTemplate::finalTextForCell(), NameListWidget::isEmpty(), and name().

◆ langs()

QList< QString > NamesList::langs ( ) const
Returns
La liste de toutes les langues disponibles

Definition at line 73 of file nameslist.cpp.

References hash_names.

Referenced by NameListWidget::setNames().

◆ name()

QString NamesList::name ( const QString &  fallback_name = QString()) const

Return the adequate name regarding the current system locale. By order of preference, this function chooses:

  • the name in the system language
  • the English name
  • the provided fallback name if non-empty
  • the first language encountered in the list
  • an empty string
    Parameters
    fallback_namename to be returned when no adequate name has been found
    Returns
    The adequate name regarding the current system locale.

Definition at line 205 of file nameslist.cpp.

References hash_names, isEmpty(), and QETApp::langFromSetting().

Referenced by addName(), TitleBlockTemplate::finalTextForCell(), fromXml(), TitleBlockCell::loadContentFromXml(), and Element::name().

◆ operator!=()

bool NamesList::operator!= ( const NamesList nl) const
Parameters
nlune autre liste de noms
Returns
true si les listes de noms sont differentes, false sinon

Definition at line 182 of file nameslist.cpp.

References hash_names, and QET::Icons::nl.

◆ operator==()

bool NamesList::operator== ( const NamesList nl) const
Parameters
nlune autre liste de noms
Returns
true si les listes de noms sont identiques, false sinon

Definition at line 190 of file nameslist.cpp.

References hash_names, and QET::Icons::nl.

◆ operator[]() [1/2]

QString & NamesList::operator[] ( const QString &  lang)
Parameters
langune langue
Returns
Le nom dans la langue donnee ou QString() si ce nom n'est pas defini

Definition at line 96 of file nameslist.cpp.

References hash_names.

◆ operator[]() [2/2]

const QString NamesList::operator[] ( const QString &  lang) const
Parameters
langune langue
Returns
Le nom dans la langue donnee ou QString() si ce nom n'est pas defini

Definition at line 105 of file nameslist.cpp.

References hash_names.

◆ removeName()

void NamesList::removeName ( const QString &  lang)

Enleve le nom dont une langue donnee

Parameters
langla langue pour laquelle il faut supprimer le nom

Definition at line 59 of file nameslist.cpp.

References hash_names.

◆ toXml()

QDomElement NamesList::toXml ( QDomDocument &  xml_document,
const QHash< QString, QString > &  xml_options = QHash<QString, QString>() 
) const

Exporte la liste des noms vers un element XML. Veillez a verifier que la liste de noms n'est pas vide avant de l'exporter.

Parameters
xml_documentLe document XML dans lequel l'element XML sera insere
xml_optionsA set of options related to XML parsing.
Returns
L'element XML correspondant a la section "names"
See also
count()

Definition at line 143 of file nameslist.cpp.

References getXmlOptions(), and hash_names.

Referenced by XmlElementCollection::addElement(), ECHSXmlToFile::copyDirectory(), XmlElementCollection::createDir(), ElementCollectionHandler::createDir(), TitleBlockCell::saveContentToXml(), ElementCollectionHandler::setNames(), ElementScene::toXml(), and XmlElementCollection::XmlElementCollection().

Member Data Documentation

◆ hash_names

QHash<QString, QString> NamesList::hash_names
private

◆ MetaTypeId

int NamesList::MetaTypeId = qRegisterMetaType<NamesList>("NamesList")
static

Definition at line 41 of file nameslist.h.


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