QElectroTech 0.100.0-dev
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | Protected Member Functions | Private Attributes | List of all members
NamesList Class Reference

#include <nameslist.h>

Collaboration diagram for NamesList:
Collaboration graph

Public Member Functions

 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
 NamesList::name Return the adequate name regarding the current system locale. By order of preference, this function chooses:
 
void fromXml (const QDomElement &, const QHash< QString, QString > &=QHash< QString, QString >())
 
void fromXml (const pugi::xml_node &xml_element, const QHash< QString, QString > &xml_options=QHash< QString, QString >())
 NamesList::fromXml Load the list of lang <-> name from an xml description. xml_element must be the parent of a child element tagged "names" If a couple lang <-> name already exist, they will overwritten, else they will be appended.
 
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 ou cinq lettres (typiquement : les deux premieres de la locale du systeme) ; exemples : en pour l'anglais, fr pour le francais, pt_BR pour le portugais brésilien.

Constructor & Destructor Documentation

◆ NamesList()

NamesList::NamesList ( )

Constructeur

◆ ~NamesList()

NamesList::~NamesList ( )
virtual

Destructeur

Member Function Documentation

◆ addName()

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

Ajoute un nom a la liste

Parameters
langSigle de deux ou cinq 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.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ clearNames()

void NamesList::clearNames ( )

Supprime tous les noms

◆ count()

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

◆ fromXml() [1/2]

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

NamesList::fromXml Load the list of lang <-> name from an xml description. xml_element must be the parent of a child element tagged "names" If a couple lang <-> name already exist, they will overwritten, else they will be appended.

Parameters
xml_element: xml element to analyze
xml_options: A set of options related to XML parsing.
See also
getXmlOptions()
Here is the call graph for this function:

◆ fromXml() [2/2]

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()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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
Here is the caller graph for this function:

◆ isEmpty()

bool NamesList::isEmpty ( ) const
Returns
true si la liste de noms est vide, false sinon
Here is the caller graph for this function:

◆ langs()

QList< QString > NamesList::langs ( ) const
Returns
La liste de toutes les langues disponibles
Here is the caller graph for this function:

◆ name()

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

NamesList::name 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.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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

◆ 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

◆ 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

◆ 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

◆ removeName()

void NamesList::removeName ( const QString &  lang)

Enleve le nom dont une langue donnee

Parameters
langla langue pour laquelle il faut supprimer le nom

◆ 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()
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ hash_names

QHash<QString, QString> NamesList::hash_names
private

◆ MetaTypeId

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

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