/*
Copyright 2006-2013 The QElectroTech team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see .
*/
#include "numerotationcontext.h"
/**
* @brief NumerotationContext::clear, clear the content
*/
void NumerotationContext::clear () {
content_.clear();
}
/**
* @brief NumerotationContext::addValue, add a new value on the contexte
* @param type the type of value
* @param value the value itself
* @param increase the increase number of value
* @return true if value is append
*/
bool NumerotationContext::addValue(const QString &type, const QVariant &value, const int increase) {
if (!keyIsAcceptable(type) && !value.canConvert(QVariant::String)) return false;
if (keyIsNumber(type) && !value.canConvert(QVariant::Int)) return false;
QString valuestr = value.toString();
valuestr.remove("|");
content_ << type + "|" + valuestr + "|" + QString::number(increase);
return true;
}
/**
* @brief NumerotationContext::operator []
* @return the string at position @i
*/
QString NumerotationContext::operator [] (const int &i) const {
return (content_.at(i));
}
/**
* @brief NumerotationContext::operator << , append other
*/
void NumerotationContext::operator << (const NumerotationContext &other) {
for (int i=0; i