Move files related to autonum in autoNum directory

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4771 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2016-11-07 15:11:12 +00:00
parent f21034fcbe
commit 2b952f4189
28 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,173 @@
/*
Copyright 2006-2016 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 <http://www.gnu.org/licenses/>.
*/
#include "numerotationcontext.h"
#include "qet.h"
/**
* Constructor
*/
NumerotationContext::NumerotationContext(){
}
/**
* Constructor from xml
*/
NumerotationContext::NumerotationContext(QDomElement &e) {
fromXml(e);
}
/**
* @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, const int initialvalue) {
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) + "|" + QString::number(initialvalue);
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<other.size(); ++i) content_.append(other[i]);
}
/**
* @brief NumerotationContext::size
* @return size of context
*/
int NumerotationContext::size() const {
return (content_.size());
}
/**
* @brief NumerotationContext::isEmpty
* @return true if numerotation contet is empty
*/
bool NumerotationContext::isEmpty() const {
if (content_.size() > 0) return false;
return true;
}
/**
* @brief NumerotationContext::itemAt
* @return the content at position @i 1:type 2:value 3:increase
*/
QStringList NumerotationContext::itemAt(const int i) const {
return (content_.at(i).split("|"));
}
/**
* @brief validRegExpNum
* @return all type use to numerotation
*/
QString NumerotationContext::validRegExpNum () const {
return ("unit|unitfolio|ten|hundred|string|idfolio|folio|machine|locmach|elementline|elementcolumn|elementprefix");
}
/**
* @brief NumerotationContext::validRegExpNumber
* @return all type represents a number
*/
QString NumerotationContext::validRegExpNumber() const {
return ("unit|unitfolio|ten|hundred");
}
/**
* @brief NumerotationContext::keyIsAcceptable
* @return true if @type is acceptable
*/
bool NumerotationContext::keyIsAcceptable(const QString &type) const {
return (type.contains(QRegExp(validRegExpNum())));
}
/**
* @brief NumerotationContext::keyIsNumber
* @return true if @type represent a number
*/
bool NumerotationContext::keyIsNumber(const QString &type) const {
return (type.contains(QRegExp(validRegExpNumber())));
}
/**
* @brief NumerotationContext::toXml
* Save the numerotation context in a QDomElement under the element name @str
*/
QDomElement NumerotationContext::toXml(QDomDocument &d, QString str) {
QDomElement num_auto = d.createElement(str);
for (int i=0; i<content_.size(); ++i) {
QStringList strl = itemAt(i);
QDomElement part = d.createElement("part");
part.setAttribute("type", strl.at(0));
part.setAttribute("value", strl.at(1));
part.setAttribute("increase", strl.at(2));
if (strl.at(0) == ("unitfolio") ||
strl.at(0) == ("tenfolio") ||
strl.at(0) == ("hundredfolio")) {
part.setAttribute("initialvalue", strl.at(3));
}
num_auto.appendChild(part);
}
return num_auto;
}
/**
* @brief NumerotationContext::fromXml
* load numerotation context from @e
*/
void NumerotationContext::fromXml(QDomElement &e) {
clear();
foreach(QDomElement qde, QET::findInDomElement(e, "part")) addValue(qde.attribute("type"), qde.attribute("value"), qde.attribute("increase").toInt(), qde.attribute("initialvalue").toInt());
}
/**
* @brief NumerotationContext::replaceValue
* This class replaces the current NC field value with content
* @param index of NC Item
* @param QString content to replace current value
*/
void NumerotationContext::replaceValue(int index, QString content) {
QString sep = "|";
QString type = content_[index].split("|").at(0);
QString value = content;
QString increase = content_[index].split("|").at(2);
QString initvalue = content_[index].split("|").at(3);
content_[index].replace(content_[index], type + "|" + value + "|" + increase + "|" + initvalue);
}

View File

@@ -0,0 +1,54 @@
/*
Copyright 2006-2016 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 <http://www.gnu.org/licenses/>.
*/
#ifndef NUMEROTATIONCONTEXT_H
#define NUMEROTATIONCONTEXT_H
#include <QStringList>
#include <QVariant>
#include <QDomElement>
/**
This class represents a numerotation context, i.e. the data (type, value, increase)
of a numerotation at a given time. It is notably used by conductor
to store the informations they need to do their autonumerotation.
*/
class NumerotationContext
{
public:
NumerotationContext ();
NumerotationContext (QDomElement &);
void clear();
bool addValue(const QString &, const QVariant & = QVariant(1), const int = 1, const int = 0);
QString operator[] (const int &) const;
void operator << (const NumerotationContext &);
int size() const;
bool isEmpty() const;
QStringList itemAt(const int) const;
QString validRegExpNum () const;
QString validRegExpNumber() const;
bool keyIsAcceptable (const QString &) const;
bool keyIsNumber(const QString &) const;
QDomElement toXml(QDomDocument &, QString);
void fromXml(QDomElement &);
void replaceValue(int, QString);
private:
QStringList content_;
};
#endif // NUMEROTATIONCONTEXT_H

View File

@@ -0,0 +1,660 @@
/*
Copyright 2006-2016 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 <http://www.gnu.org/licenses/>.
*/
#include "numerotationcontextcommands.h"
#include "diagram.h"
/**
* @brief Constructor
*/
NumerotationContextCommands::NumerotationContextCommands(const NumerotationContext &nc, Diagram *d):
diagram_ (d),
context_ (nc),
strategy_ (NULL)
{}
/**
* @brief Destructor
*/
NumerotationContextCommands::~NumerotationContextCommands() {
if (strategy_) delete strategy_;
}
/**
* @brief NumerotationContextCommands::next
* @return the next numerotation context
*/
NumerotationContext NumerotationContextCommands::next() {
NumerotationContext contextnum;
for (int i=0; i<context_.size(); ++i) {
QStringList str = context_.itemAt(i);
setNumStrategy(str.at(0));
contextnum << strategy_ -> next(context_, i);
}
return contextnum;
}
/**
* @brief NumerotationContextCommands::previous
* @return the previous numerotation context
*/
NumerotationContext NumerotationContextCommands::previous() {
NumerotationContext contextnum;
for (int i=0; i<context_.size(); ++i) {
QStringList str = context_.itemAt(i);
setNumStrategy(str.at(0));
contextnum << strategy_ -> previous(context_, i);
}
return contextnum;
}
/**
* @brief NumerotationContextCommands::toFinalString
* @return the string represented by the numerotation context
*/
QString NumerotationContextCommands::toRepresentedString() {
QString num;
if (context_.size()) {
for (int i=0; i<context_.size(); i++) {
QStringList str = context_.itemAt(i);
setNumStrategy(str.at(0));
num += strategy_ -> toRepresentedString(str.at(1));
}
return num;
}
if (diagram_) return (diagram_ -> defaultConductorProperties.text);
return QString();
}
/**
* @brief NumerotationContextCommands::setNumStrategy
* apply the good strategy relative to @str
*/
void NumerotationContextCommands::setNumStrategy(const QString &str) {
if (strategy_) delete strategy_;
if (str == "unit") {
strategy_ = new UnitNum(diagram_);
return;
}
else if (str == "unitfolio") {
strategy_ = new UnitFNum (diagram_);
return;
}
else if (str == "ten") {
strategy_ = new TenNum (diagram_);
return;
}
else if (str == "tenfolio") {
strategy_ = new TenFNum (diagram_);
return;
}
else if (str == "hundred") {
strategy_ = new HundredNum (diagram_);
return;
}
else if (str == "hundredfolio") {
strategy_ = new HundredFNum (diagram_);
return;
}
else if (str == "string") {
strategy_ = new StringNum (diagram_);
return;
}
else if (str == "idfolio") {
strategy_ = new IdFolioNum (diagram_);
return;
}
else if (str=="folio"){
strategy_ = new FolioNum (diagram_);
return;
}
else if (str=="machine"){
strategy_ = new MachineNum (diagram_);
return;
}
else if (str=="locmach"){
strategy_ = new LocmachNum (diagram_);
return;
}
else if (str=="elementline"){
strategy_ = new ElementLineNum (diagram_);
return;
}
else if (str=="elementcolumn"){
strategy_ = new ElementColumnNum (diagram_);
return;
}
else if (str=="elementprefix"){
strategy_ = new ElementPrefixNum (diagram_);
return;
}
}
/**
* Constructor
*/
NumStrategy::NumStrategy (Diagram *d):
diagram_ (d)
{}
NumStrategy::~NumStrategy() {}
/**
* @brief NumStrategy::nextString
* @return the next value of @nc at position @i
*/
NumerotationContext NumStrategy::nextString (const NumerotationContext &nc, const int i) const {
QStringList strl = nc.itemAt(i);
NumerotationContext newnc;
newnc.addValue(strl.at(0), strl.at(1), strl.at(2).toInt());
return (newnc);
}
/**
* @brief NumStrategy::nextNumber
* @return the next value of @nc at position @i
*/
NumerotationContext NumStrategy::nextNumber (const NumerotationContext &nc, const int i) const {
QStringList strl = nc.itemAt(i);
NumerotationContext newnc;
QString value = QString::number( (strl.at(1).toInt()) + (strl.at(2).toInt()) );
newnc.addValue(strl.at(0), value, strl.at(2).toInt(), strl.at(3).toInt());
return (newnc);
}
/**
* @brief NumStrategy::previousNumber
* @return the previous value of @nc at position @i
*/
NumerotationContext NumStrategy::previousNumber(const NumerotationContext &nc, const int i) const {
QStringList strl = nc.itemAt(i);
NumerotationContext newnc;
QString value = QString::number( (strl.at(1).toInt()) - (strl.at(2).toInt()) );
newnc.addValue(strl.at(0), value, strl.at(2).toInt(), strl.at(3).toInt());
return (newnc);
}
/**
* Constructor
*/
UnitNum::UnitNum(Diagram *d):
NumStrategy(d)
{}
/**
* @brief UnitNum::toRepresentedString
* @return the represented string of num
*/
QString UnitNum::toRepresentedString(const QString num) const {
return (num);
}
/**
* @brief UnitNum::next
* @return the next NumerotationContext nc at position i
*/
NumerotationContext UnitNum::next (const NumerotationContext &nc, const int i) const {
return (nextNumber(nc, i));
}
/**
* @brief UnitNum::previous
* @return the previous NumerotationContext nc at posiiton i
*/
NumerotationContext UnitNum::previous(const NumerotationContext &nc, const int i) const {
return (previousNumber(nc, i));
}
/**
* Constructor
*/
UnitFNum::UnitFNum(Diagram *d):
NumStrategy(d)
{}
/**
* @brief UnitFNum::toRepresentedString
* @return the represented string of num
*/
QString UnitFNum::toRepresentedString(const QString num) const {
return (num);
}
/**
* @brief UnitFNum::next
* @return the next NumerotationContext nc at position i
*/
NumerotationContext UnitFNum::next (const NumerotationContext &nc, const int i) const {
return (nextNumber(nc, i));
}
/**
* @brief UnitFNum::previous
* @return the previous NumerotationContext nc at posiiton i
*/
NumerotationContext UnitFNum::previous(const NumerotationContext &nc, const int i) const {
return (previousNumber(nc, i));
}
/**
* Constructor
*/
TenNum::TenNum (Diagram *d):
NumStrategy (d)
{}
/**
* @brief TenNum::toRepresentedString
* @return the represented string of num
*/
QString TenNum::toRepresentedString(const QString num) const {
int numint = num.toInt();
QString numstr = num;
if (numint<10) numstr.prepend("0");
return (numstr);
}
/**
* @brief TenNum::next
* @return the next NumerotationContext nc at position i
*/
NumerotationContext TenNum::next (const NumerotationContext &nc, const int i) const {
return (nextNumber(nc, i));
}
/**
* @brief TenNum::previous
* @return the previous NumerotationContext nc at posiiton i
*/
NumerotationContext TenNum::previous(const NumerotationContext &nc, const int i) const {
return (previousNumber(nc, i));
}
/**
* Constructor
*/
TenFNum::TenFNum (Diagram *d):
NumStrategy (d)
{}
/**
* @brief TenFNum::toRepresentedString
* @return the represented string of num
*/
QString TenFNum::toRepresentedString(const QString num) const {
int numint = num.toInt();
QString numstr = num;
if (numint<10) numstr.prepend("0");
return (numstr);
}
/**
* @brief TenFNum::next
* @return the next NumerotationContext nc at position i
*/
NumerotationContext TenFNum::next (const NumerotationContext &nc, const int i) const {
return (nextNumber(nc, i));
}
/**
* @brief TenFNum::previous
* @return the previous NumerotationContext nc at posiiton i
*/
NumerotationContext TenFNum::previous(const NumerotationContext &nc, const int i) const {
return (previousNumber(nc, i));
}
/**
* Constructor
*/
HundredNum::HundredNum (Diagram *d):
NumStrategy (d)
{}
/**
* @brief HundredNum::toRepresentedString
* @return the represented string of num
*/
QString HundredNum::toRepresentedString(const QString num) const {
int numint = num.toInt();
QString numstr = num;
if (numint<100) {
if (numint<10) {
numstr.prepend("00");
}
else numstr.prepend("0");
}
return (numstr);
}
/**
* @brief HundredNum::next
* @return the next NumerotationContext nc at position i
*/
NumerotationContext HundredNum::next (const NumerotationContext &nc, const int i) const {
return (nextNumber(nc, i));
}
/**
* @brief HundredNum::previous
* @return the previous NumerotationContext nc at posiiton i
*/
NumerotationContext HundredNum::previous(const NumerotationContext &nc, const int i) const {
return (previousNumber(nc, i));
}
/**
* Constructor
*/
HundredFNum::HundredFNum (Diagram *d):
NumStrategy (d)
{}
/**
* @brief HundredFNum::toRepresentedString
* @return the represented string of num
*/
QString HundredFNum::toRepresentedString(const QString num) const {
int numint = num.toInt();
QString numstr = num;
if (numint<100) {
if (numint<10) {
numstr.prepend("00");
}
else numstr.prepend("0");
}
return (numstr);
}
/**
* @brief HundredFNum::next
* @return the next NumerotationContext nc at position i
*/
NumerotationContext HundredFNum::next (const NumerotationContext &nc, const int i) const {
return (nextNumber(nc, i));
}
/**
* @brief HundredFNum::previous
* @return the previous NumerotationContext nc at posiiton i
*/
NumerotationContext HundredFNum::previous(const NumerotationContext &nc, const int i) const {
return (previousNumber(nc, i));
}
/**
* Constructor
*/
StringNum::StringNum (Diagram *d):
NumStrategy (d)
{}
/**
* @brief StringNum::toRepresentedString
* @return the represented string of num
*/
QString StringNum::toRepresentedString(const QString str) const {
return (str);
}
/**
* @brief StringNum::next
* @return the next NumerotationContext nc at position i
*/
NumerotationContext StringNum::next (const NumerotationContext &nc, const int i) const {
return (nextString(nc, i));
}
/**
* @brief StringNum::previous
* @return the previous NumerotationContext nc at posiiton i
*/
NumerotationContext StringNum::previous(const NumerotationContext &nc, const int i) const {
return (nextString(nc, i));
}
/**
* Constructor
*/
IdFolioNum::IdFolioNum (Diagram *d):
NumStrategy (d)
{}
/**
* @brief IdFolioNum::toRepresentedString
* @return the represented string of num
*/
QString IdFolioNum::toRepresentedString(const QString str) const {
Q_UNUSED(str);
return ("%id");
}
/**
* @brief IdFolioNum::next
* @return the next NumerotationContext nc at position i
*/
NumerotationContext IdFolioNum::next (const NumerotationContext &nc, const int i) const {
return (nextString(nc, i));
}
/**
* @brief IdFolioNum::previous
* @return the previous NumerotationContext nc at posiiton i
*/
NumerotationContext IdFolioNum::previous(const NumerotationContext &nc, const int i) const {
return (nextString(nc, i));
}
/**
* Constructor
*/
FolioNum::FolioNum (Diagram *d):
NumStrategy (d)
{}
/**
* @brief FolioNum::toRepresentedString
* @return the represented string of folio
*/
QString FolioNum::toRepresentedString(const QString str) const {
Q_UNUSED(str);
return ("%F");
}
/**
* @brief FolioNum::next
* @return the next NumerotationContext nc at position i
*/
NumerotationContext FolioNum::next (const NumerotationContext &nc, const int i) const {
return (nextString(nc, i));
}
/**
* @brief FolioNum::previous
* @return the previous NumerotationContext nc at posiiton i
*/
NumerotationContext FolioNum::previous(const NumerotationContext &nc, const int i) const {
return (nextString(nc, i));
}
/**
* Constructor
*/
MachineNum::MachineNum (Diagram *d):
NumStrategy (d)
{}
/**
* @brief MachineNum::toRepresentedString
* @return the represented string of folio
*/
QString MachineNum::toRepresentedString(const QString str) const {
Q_UNUSED(str);
return "%M";
}
/**
* @brief MachineNum::next
* @return the next NumerotationContext nc at position i
*/
NumerotationContext MachineNum::next (const NumerotationContext &nc, const int i) const {
return (nextString(nc, i));
}
/**
* @brief MachineNum::previous
* @return the previous NumerotationContext nc at posiiton i
*/
NumerotationContext MachineNum::previous(const NumerotationContext &nc, const int i) const {
return (nextString(nc, i));
}
/**
* Constructor
*/
LocmachNum::LocmachNum (Diagram *d):
NumStrategy (d)
{}
/**
* @brief LocmachNum::toRepresentedString
* @return the represented string of folio
*/
QString LocmachNum::toRepresentedString(const QString str) const {
Q_UNUSED(str);
return "%LM";
}
/**
* @brief LocmachNum::next
* @return the next NumerotationContext nc at position i
*/
NumerotationContext LocmachNum::next (const NumerotationContext &nc, const int i) const {
return (nextString(nc, i));
}
/**
* @brief LocmachNum::previous
* @return the previous NumerotationContext nc at posiiton i
*/
NumerotationContext LocmachNum::previous(const NumerotationContext &nc, const int i) const {
return (nextString(nc, i));
}
/**
* Constructor
*/
ElementLineNum::ElementLineNum (Diagram *d):
NumStrategy (d)
{}
/**
* @brief ElementLineNum::toRepresentedString
* @return the represented string of folio
*/
QString ElementLineNum::toRepresentedString(const QString str) const {
Q_UNUSED(str);
return "%l";
}
/**
* @brief ElementLineNum::next
* @return the next NumerotationContext nc at position i
*/
NumerotationContext ElementLineNum::next (const NumerotationContext &nc, const int i) const {
return (nextString(nc, i));
}
/**
* @brief ElementLineNum::previous
* @return the previous NumerotationContext nc at posiiton i
*/
NumerotationContext ElementLineNum::previous(const NumerotationContext &nc, const int i) const {
return (nextString(nc, i));
}
/**
* Constructor
*/
ElementColumnNum::ElementColumnNum (Diagram *d):
NumStrategy (d)
{}
/**
* @brief ElementColumnNum::toRepresentedString
* @return the represented string of folio
*/
QString ElementColumnNum::toRepresentedString(const QString str) const {
Q_UNUSED(str);
return "%c";
}
/**
* @brief ElementColumnNum::next
* @return the next NumerotationContext nc at position i
*/
NumerotationContext ElementColumnNum::next (const NumerotationContext &nc, const int i) const {
return (nextString(nc, i));
}
/**
* @brief ElementColumnNum::previous
* @return the previous NumerotationContext nc at posiiton i
*/
NumerotationContext ElementColumnNum::previous(const NumerotationContext &nc, const int i) const {
return (nextString(nc, i));
}
/**
* Constructor
*/
ElementPrefixNum::ElementPrefixNum (Diagram *d):
NumStrategy (d)
{}
/**
* @brief ElementPrefixNum::toRepresentedString
* @return the represented string of folio
*/
QString ElementPrefixNum::toRepresentedString(const QString str) const {
Q_UNUSED(str);
return "%prefix";
}
/**
* @brief ElementPrefixNum::next
* @return the next NumerotationContext nc at position i
*/
NumerotationContext ElementPrefixNum::next (const NumerotationContext &nc, const int i) const {
return (nextString(nc, i));
}
/**
* @brief ElementPrefixNum::previous
* @return the previous NumerotationContext nc at posiiton i
*/
NumerotationContext ElementPrefixNum::previous(const NumerotationContext &nc, const int i) const {
return (nextString(nc, i));
}

View File

@@ -0,0 +1,191 @@
/*
Copyright 2006-2016 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 <http://www.gnu.org/licenses/>.
*/
#ifndef NUMEROTATIONCONTEXTCOMMANDS_H
#define NUMEROTATIONCONTEXTCOMMANDS_H
#include "numerotationcontext.h"
class NumStrategy;
class Diagram;
/**
* this class provide methods to handle content of NumerotationContext.
*/
class NumerotationContextCommands
{
public:
NumerotationContextCommands (const NumerotationContext &, Diagram * = nullptr);
~NumerotationContextCommands ();
NumerotationContext next ();
NumerotationContext previous ();
QString toRepresentedString ();
private:
void setNumStrategy (const QString &);
Diagram *diagram_;
NumerotationContext context_;
NumStrategy *strategy_;
};
class NumStrategy
{
public:
NumStrategy (Diagram * = nullptr);
virtual ~NumStrategy ();
virtual QString toRepresentedString (const QString) const = 0;
virtual NumerotationContext next (const NumerotationContext &, const int) const = 0;
virtual NumerotationContext previous (const NumerotationContext &, const int) const = 0;
protected:
NumerotationContext nextString (const NumerotationContext &, const int) const;
NumerotationContext nextNumber (const NumerotationContext &, const int) const;
NumerotationContext previousNumber (const NumerotationContext &, const int) const;
Diagram *diagram_;
};
class UnitNum: public NumStrategy
{
public:
UnitNum (Diagram *);
QString toRepresentedString(const QString) const;
NumerotationContext next (const NumerotationContext &, const int) const;
NumerotationContext previous (const NumerotationContext &, const int) const;
};
class UnitFNum: public NumStrategy
{
public:
UnitFNum (Diagram *);
QString toRepresentedString(const QString) const;
NumerotationContext next (const NumerotationContext &, const int) const;
NumerotationContext previous (const NumerotationContext &, const int) const;
};
class TenNum: public NumStrategy
{
public:
TenNum (Diagram *);
QString toRepresentedString(const QString) const;
NumerotationContext next (const NumerotationContext &, const int) const;
NumerotationContext previous (const NumerotationContext &, const int) const;
};
class TenFNum: public NumStrategy
{
public:
TenFNum (Diagram *);
QString toRepresentedString(const QString) const;
NumerotationContext next (const NumerotationContext &, const int) const;
NumerotationContext previous (const NumerotationContext &, const int) const;
};
class HundredNum: public NumStrategy
{
public:
HundredNum (Diagram *);
QString toRepresentedString(const QString) const;
NumerotationContext next (const NumerotationContext &, const int) const;
NumerotationContext previous (const NumerotationContext &, const int) const;
};
class HundredFNum: public NumStrategy
{
public:
HundredFNum (Diagram *);
QString toRepresentedString(const QString) const;
NumerotationContext next (const NumerotationContext &, const int) const;
NumerotationContext previous (const NumerotationContext &, const int) const;
};
class StringNum: public NumStrategy
{
public:
StringNum (Diagram *);
QString toRepresentedString(const QString) const;
NumerotationContext next (const NumerotationContext &, const int) const;
NumerotationContext previous (const NumerotationContext &, const int) const;
};
class IdFolioNum: public NumStrategy
{
public:
IdFolioNum (Diagram *);
QString toRepresentedString(const QString) const;
NumerotationContext next (const NumerotationContext &, const int) const;
NumerotationContext previous (const NumerotationContext &, const int) const;
};
class FolioNum: public NumStrategy
{
public:
FolioNum (Diagram *);
QString toRepresentedString(const QString) const;
NumerotationContext next (const NumerotationContext &, const int) const;
NumerotationContext previous (const NumerotationContext &, const int) const;
};
class MachineNum: public NumStrategy
{
public:
MachineNum (Diagram *);
QString toRepresentedString(const QString) const;
NumerotationContext next (const NumerotationContext &, const int) const;
NumerotationContext previous (const NumerotationContext &, const int) const;
};
class LocmachNum: public NumStrategy
{
public:
LocmachNum (Diagram *);
QString toRepresentedString(const QString) const;
NumerotationContext next (const NumerotationContext &, const int) const;
NumerotationContext previous (const NumerotationContext &, const int) const;
};
class ElementLineNum: public NumStrategy
{
public:
ElementLineNum (Diagram *);
QString toRepresentedString(const QString) const;
NumerotationContext next (const NumerotationContext &, const int) const;
NumerotationContext previous (const NumerotationContext &, const int) const;
};
class ElementColumnNum: public NumStrategy
{
public:
ElementColumnNum (Diagram *);
QString toRepresentedString(const QString) const;
NumerotationContext next (const NumerotationContext &, const int) const;
NumerotationContext previous (const NumerotationContext &, const int) const;
};
class ElementPrefixNum: public NumStrategy
{
public:
ElementPrefixNum (Diagram *);
QString toRepresentedString(const QString) const;
NumerotationContext next (const NumerotationContext &, const int) const;
NumerotationContext previous (const NumerotationContext &, const int) const;
};
#endif // NUMEROTATIONCONTEXTCOMMANDS_H

View File

@@ -0,0 +1,272 @@
/*
Copyright 2006-2016 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 <http://www.gnu.org/licenses/>.
*/
#include "autonumberingdockwidget.h"
#include "qetapp.h"
#include "ui_autonumberingdockwidget.h"
#include "diagramview.h"
#include "diagram.h"
#include "titleblockproperties.h"
#include "numerotationcontext.h"
/**
* @brief AutoNumberingDockWidget::AutoNumberingDockWidget
* Constructor
* @param parent : parent widget
*/
AutoNumberingDockWidget::AutoNumberingDockWidget(QWidget *parent, QETProject *project) :
QDockWidget(parent),
ui(new Ui::AutoNumberingDockWidget),
project_(project)
{
ui->setupUi(this);
}
/**
* @brief AutoNumberingDockWidget::~AutoNumberingDockWidget
* Destructor
*/
AutoNumberingDockWidget::~AutoNumberingDockWidget()
{
this->disconnect();
delete ui;
}
/**
* @brief AutoNumberingDockWidget::clear
* Remove all combo box values
*/
void AutoNumberingDockWidget::clear()
{
ui->m_conductor_cb->clear();
ui->m_element_cb->clear();
ui->m_folio_cb->clear();
}
/**
* @brief AutoNumberingDockWidget::setProject
* @param project: project to be setted
* @param projectview: projectview to be setted
* assign Project and ProjectView, connect all signals and setContext
*/
void AutoNumberingDockWidget::setProject(QETProject *project, ProjectView *projectview) {
project_ = project;
projectview_ = projectview;
//Conductor Signals
connect(project_, SIGNAL(conductorAutoNumChanged()),this,SLOT(conductorAutoNumChanged()));
connect (project_,SIGNAL(conductorAutoNumRemoved()), this,SLOT(conductorAutoNumChanged()));
connect (project_,SIGNAL(conductorAutoNumAdded()), this,SLOT(conductorAutoNumChanged()));
connect(projectview_,SIGNAL(diagramActivated(DiagramView*)),this,SLOT(setConductorActive(DiagramView*)));
//Element Signals
connect (project_,SIGNAL(elementAutoNumRemoved()), this,SLOT(elementAutoNumChanged()));
connect (project_,SIGNAL(elementAutoNumAdded()), this,SLOT(elementAutoNumChanged()));
//Folio Signals
connect (project_,SIGNAL(folioAutoNumRemoved()), this,SLOT(folioAutoNumChanged()));
connect (project_,SIGNAL(folioAutoNumAdded()), this,SLOT(folioAutoNumChanged()));
connect (this,
SIGNAL(folioAutoNumChanged(QString)),
&projectview_->currentDiagram()->diagram()->border_and_titleblock,
SLOT (slot_setAutoPageNum(QString)));
connect(project_, SIGNAL(defaultTitleBlockPropertiesChanged()),this,SLOT(setActive()));
//Conductor, Element and Folio Signals
connect(projectview_,SIGNAL(projectClosed(ProjectView*)),this,SLOT(clear()));
//Set Combobox Context
setContext();
}
/**
* @brief AutoNumberingDockWidget::setContext
* Add all itens to comboboxes
*/
void AutoNumberingDockWidget::setContext() {
this->clear();
//Conductor Combobox
ui->m_conductor_cb->addItem("");
QList <QString> keys_conductor = project_->conductorAutoNum().keys();
if (!keys_conductor.isEmpty()) {
foreach (QString str, keys_conductor) { ui->m_conductor_cb-> addItem(str); }
}
//Element Combobox
ui->m_element_cb->addItem("");
QList <QString> keys_element = project_->elementAutoNum().keys();
if (!keys_element.isEmpty()) {
foreach (QString str, keys_element) {ui->m_element_cb -> addItem(str);}
}
//Folio Combobox
ui->m_folio_cb->addItem("");
QList <QString> keys_folio = project_->folioAutoNum().keys();
if (!keys_folio.isEmpty()) {
foreach (QString str, keys_folio) { ui->m_folio_cb -> addItem(str);}
}
this->setActive();
}
/**
* @brief AutoNumberingDockWidget::setConductorActive
* @param dv: activated diagramview
*/
void AutoNumberingDockWidget::setConductorActive(DiagramView* dv) {
if (dv!=NULL) {
QString conductor_autonum = dv->diagram()->conductorsAutonumName();
int conductor_index = ui->m_conductor_cb->findText(conductor_autonum);
ui->m_conductor_cb->setCurrentIndex(conductor_index);
}
}
/**
* @brief AutoNumberingDockWidget::setActive
* Set current used autonumberings
*/
void AutoNumberingDockWidget::setActive() {
if (projectview_!=NULL) {
//Conductor
if (projectview_->currentDiagram()) {
QString conductor_autonum = projectview_->currentDiagram()->diagram()->conductorsAutonumName();
int conductor_index = ui->m_conductor_cb->findText(conductor_autonum);
ui->m_conductor_cb->setCurrentIndex(conductor_index);
}
//Element
QString element_formula = project_->elementAutoNumCurrentFormula();
QString active_element_autonum = project_->elementCurrentAutoNum();
int el_index = ui->m_element_cb->findText(active_element_autonum);
ui->m_element_cb->setCurrentIndex(el_index);
//Folio
if (project_->defaultTitleBlockProperties().folio == "%autonum") {
QString page_autonum = project_->defaultTitleBlockProperties().auto_page_num;
int folio_index = ui->m_folio_cb->findText(page_autonum);
ui->m_folio_cb->setCurrentIndex(folio_index);
}
}
}
/**
* @brief AutoNumberingDockWidget::conductorAutoNumChanged
* Add new or remove conductor auto num from combobox
*/
void AutoNumberingDockWidget::conductorAutoNumChanged() {
ui->m_conductor_cb->clear();
//Conductor Combobox
ui->m_conductor_cb->addItem("");
QList <QString> keys_conductor = project_->conductorAutoNum().keys();
if (!keys_conductor.isEmpty()) {
foreach (QString str, keys_conductor) { ui->m_conductor_cb-> addItem(str); }
}
setActive();
}
/**
* @brief AutoNumberingDockWidget::on_m_conductor_cb_activated
* @param unused
* Set new conductor AutoNum
*/
void AutoNumberingDockWidget::on_m_conductor_cb_activated(int) {
QString current_autonum = ui->m_conductor_cb->currentText();
QString current_formula = project_->conductorAutoNumFormula(current_autonum);
if (current_autonum != "") {
project_->setConductorAutoNumCurrentFormula(current_formula, current_autonum);
}
else
project_->setConductorAutoNumCurrentFormula("","");
projectview_->currentDiagram()->diagram()->setConductorsAutonumName(current_autonum);
projectview_->currentDiagram()->diagram()->loadCndFolioSeq();
}
/**
* @brief AutoNumberingDockWidget::elementAutoNumChanged
* Add new or remove element auto num from combobox
*/
void AutoNumberingDockWidget::elementAutoNumChanged() {
ui->m_element_cb->clear();
//Element Combobox
ui->m_element_cb->addItem("");
QList <QString> keys_element = project_->elementAutoNum().keys();
if (!keys_element.isEmpty()) {
foreach (QString str, keys_element) {ui->m_element_cb -> addItem(str);}
}
setActive();
}
/**
* @brief AutoNumberingDockWidget::on_m_element_cb_activated
* @param unused
* Set new element AutoNum
*/
void AutoNumberingDockWidget::on_m_element_cb_activated(int) {
QString current_autonum = ui->m_element_cb->currentText();
QString current_formula = project_->elementAutoNumFormula(current_autonum);
if (current_autonum != "") {
project_->setElementAutoNumCurrentFormula(current_formula, current_autonum);
}
else
project_->setElementAutoNumCurrentFormula("","");
projectview_->currentDiagram()->diagram()->loadElmtFolioSeq();
}
/**
* @brief AutoNumberingDockWidget::folioAutoNumChanged
* Add new or remove folio auto num from combobox
*/
void AutoNumberingDockWidget::folioAutoNumChanged() {
ui->m_folio_cb->clear();
//Folio Combobox
ui->m_folio_cb->addItem("");
QList <QString> keys_folio = project_->folioAutoNum().keys();
if (!keys_folio.isEmpty()) {
foreach (QString str, keys_folio) { ui->m_folio_cb -> addItem(str);}
}
setActive();
}
/**
* @brief AutoNumberingDockWidget::on_m_folio_cb_activated
* @param unused
* Set new folio AutoNum
*/
void AutoNumberingDockWidget::on_m_folio_cb_activated(int) {
QString current_autonum = ui->m_folio_cb->currentText();
TitleBlockProperties ip = project_ -> defaultTitleBlockProperties();
if (current_autonum != "") {
ip.setAutoPageNum(current_autonum);
ip.folio = "%autonum";
project_->setDefaultTitleBlockProperties(ip);
}
else {
ip.folio = "%id/%total";
project_->setDefaultTitleBlockProperties(ip);
}
emit(folioAutoNumChanged(current_autonum));
}

View File

@@ -0,0 +1,63 @@
/*
Copyright 2006-2016 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 <http://www.gnu.org/licenses/>.
*/
#ifndef AUTONUMBERINGDOCKWIDGET_H
#define AUTONUMBERINGDOCKWIDGET_H_H
#include "qetproject.h"
#include "projectview.h"
#include <QDockWidget>
namespace Ui {
class AutoNumberingDockWidget;
}
class AutoNumberingDockWidget : public QDockWidget
{
Q_OBJECT
public:
explicit AutoNumberingDockWidget(QWidget *parent = 0, QETProject *project = nullptr);
~AutoNumberingDockWidget();
void setContext();
void setProject(QETProject*, ProjectView*);
public slots:
void setActive();
void setConductorActive(DiagramView*);
private slots:
void on_m_conductor_cb_activated(int);
void on_m_element_cb_activated(int);
void on_m_folio_cb_activated(int);
void conductorAutoNumChanged();
void elementAutoNumChanged();
void folioAutoNumChanged();
void clear();
signals:
void folioAutoNumChanged(QString);
private:
Ui::AutoNumberingDockWidget *ui;
QETProject* project_;
ProjectView* projectview_;
};
#endif // AUTONUMBERINGDOCKWIDGET_H

View File

@@ -0,0 +1,94 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AutoNumberingDockWidget</class>
<widget class="QDockWidget" name="AutoNumberingDockWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Autonumerotation Séléction</string>
</property>
<widget class="QWidget" name="dockWidgetContents">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="sizeConstraint">
<enum>QLayout::SetMaximumSize</enum>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string/>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Element</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="m_element_cb"/>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="m_conductor_cb"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Conductor</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Folio</string>
</property>
</widget>
</item>
<item row="3" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="m_folio_cb"/>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,213 @@
/*
Copyright 2006-2016 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 <http://www.gnu.org/licenses/>.
*/
#include "autonumberingmanagementw.h"
#include "ui_autonumberingmanagementw.h"
#include "numparteditorw.h"
#include <QMessageBox>
#include "numerotationcontextcommands.h"
#include "formulaautonumberingw.h"
#include "ui_formulaautonumberingw.h"
#include "qdebug.h"
#include "qetproject.h"
#include "diagram.h"
/**
* Constructor
*/
AutoNumberingManagementW::AutoNumberingManagementW(QETProject *project, QWidget *parent) :
QWidget(parent),
project_(project)
{
ui = new Ui::AutoNumberingManagementW;
ui->setupUi(this);
ui->m_apply_locations_rb->setHidden(true);
ui->m_selected_locations_le->setHidden(true);
ui->folioWidget->setHidden(true);
ui->m_selected_folios_widget->setDisabled(true);
ui->m_selected_folios_le->setDisabled(true);
ui->m_selected_folios_le->setReadOnly(true);
applyEnable(false);
setProjectContext();
}
/**
* Destructor
*/
AutoNumberingManagementW::~AutoNumberingManagementW()
{
delete ui;
}
/**
* @brief AutoNumberingManagementW::setProjectContext
* Add Default Project Status
*/
void AutoNumberingManagementW::setProjectContext() {
ui->m_status_cb->addItem(tr("Under Development"));
ui->m_status_cb->addItem(tr("Installing"));
ui->m_status_cb->addItem(tr("Built"));
}
/**
* @brief AutoNumberingManagementW::on_m_status_cb_currentIndexChanged
* Load Default Status Options
*/
void AutoNumberingManagementW::on_m_status_cb_currentIndexChanged(int index) {
//Under Development
if (index == 0) {
ui->conductorWidget->setEnabled(true);
ui->elementWidget->setEnabled(true);
ui->folioWidget->setEnabled(true);
ui->m_both_conductor_rb->setChecked(true);
ui->m_both_element_rb->setChecked(true);
ui->m_both_folio_rb->setChecked(true);
}
//Installing
else if (index == 1) {
ui->conductorWidget->setEnabled(true);
ui->elementWidget->setEnabled(true);
ui->folioWidget->setEnabled(true);
ui->m_new_conductor_rb->setChecked(true);
ui->m_new_element_rb->setChecked(true);
ui->m_new_folio_rb->setChecked(true);
}
//Built
else if (index == 2) {
ui->m_disable_conductor_rb->setChecked(true);
ui->m_disable_element_rb->setChecked(true);
ui->m_disable_folio_rb->setChecked(true);
}
}
/**
* @brief AutoNumberingManagementW::on_m_apply_folios_rb_clicked
* Set From Folios Combobox
*/
void AutoNumberingManagementW::on_m_apply_folios_rb_clicked() {
if (ui->m_apply_folios_rb->isChecked()) {
ui->m_selected_folios_widget->setEnabled(true);
ui->m_selected_folios_le->setEnabled(true);
if (ui->m_from_folios_cb->count()<=0) {
ui->m_from_folios_cb->clear();
ui->m_from_folios_cb->addItem("");
foreach (Diagram *diagram, project_->diagrams()){
if (diagram->title() != "")
ui->m_from_folios_cb->addItem(diagram->title(),diagram->folioIndex());
else ui->m_from_folios_cb->addItem(QString::number(diagram->folioIndex()),diagram->folioIndex());
}
}
if (ui->m_from_folios_cb->currentIndex() > 0)
applyEnable(true);
else applyEnable(false);
}
}
/**
* @brief AutoNumberingManagementW::on_m_from_folios_cb_currentIndexChanged
* Set To Folios Combobox
*/
void AutoNumberingManagementW::on_m_from_folios_cb_currentIndexChanged(int index) {
ui->m_to_folios_cb->clear();
ui->m_selected_folios_le->clear();
ui->m_selected_folios_le->setEnabled(true);
if (index > 0) {
ui->m_to_folios_cb->setEnabled(true);
ui->m_to_folios_cb->addItem("");
for (int i=index;i<project_->diagrams().size();i++) {
if (project_->diagrams().at(i)->title() != "") {
ui->m_to_folios_cb->addItem(project_->diagrams().at(i)->title(),project_->diagrams().at(i)->folioIndex());
}
else ui->m_to_folios_cb->addItem(QString::number(project_->diagrams().at(i)->folioIndex()),project_->diagrams().at(i)->folioIndex());
}
applyEnable(true);
ui->m_selected_folios_le->clear();
ui->m_selected_folios_le->insert(ui->m_from_folios_cb->currentText());
}
else applyEnable(false);
}
/**
* @brief AutoNumberingManagementW::on_m_to_folios_cb_currentIndexChanged
* Set selected folios Line Edit content
*/
void AutoNumberingManagementW::on_m_to_folios_cb_currentIndexChanged(int index) {
if (index > 0) {
QString from = ui->m_from_folios_cb->currentText();
QString to = ui->m_to_folios_cb->currentText();
ui->m_selected_folios_le->clear();
ui->m_selected_folios_le->insert(from + " - " + to);
ui->m_selected_folios_le->setDisabled(true);
}
applyEnable(true);
}
/**
* @brief AutoNumberingManagementW::on_m_apply_project_rb_clicked
* Disable folio widget
*/
void AutoNumberingManagementW::on_m_apply_project_rb_clicked() {
ui->m_selected_folios_widget->setDisabled(true);
ui->m_selected_folios_le->setDisabled(true);
applyEnable(true);
}
/**
* @brief AutoNumberingManagementW::on_buttonBox_clicked
* Action on @buttonBox clicked
*/
void AutoNumberingManagementW::on_buttonBox_clicked(QAbstractButton *button) {
//transform button to int
int answer = ui -> buttonBox -> buttonRole(button);
switch (answer) {
//apply the context in the diagram displayed by @diagram_chooser.
case QDialogButtonBox::ApplyRole:
applyEnable(false);
emit applyPressed();
break;
case QDialogButtonBox::HelpRole:
QMessageBox::information(this, tr("Auto Numbering Management", "title window"),
tr("In this Menu you can set whether you want the Auto Numberings to be updated or not."
" For Element Auto Numbering you have 4 options of Update Policy:\n"
"-Both: both New and Existent Element labels will be updated. This is the default option.\n"
"-Update Only New: only new created Elements will be updated. Existent Element labels will be frozen.\n"
"-Update Only Existent: only existent Elements will be updated. New Elements will be assigned "
"their formula but will not update once created.\n"
"-Disable: both New and Existent Element labels will not be updated. This is valid for new folios as well.\n"
"Note: These options DO NOT allow or block Auto Numberings, only their Update Policy."
));
break;
}
}
/**
* @brief AutoNumberingManagementW::applyEnable
* enable/disable the apply button
*/
void AutoNumberingManagementW::applyEnable(bool b) {
if (b){
bool valid= true;
if (ui->m_apply_project_rb->isChecked())
ui -> buttonBox -> button(QDialogButtonBox::Apply) -> setEnabled(valid);
else if (ui->m_apply_folios_rb->isChecked())
ui -> buttonBox -> button(QDialogButtonBox::Apply) -> setEnabled(valid);
}
else {
ui -> buttonBox -> button(QDialogButtonBox::Apply) -> setEnabled(b);
}
}

View File

@@ -0,0 +1,63 @@
/*
Copyright 2006-2016 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 <http://www.gnu.org/licenses/>.
*/
#ifndef AUTONUMBERINGMANAGEMENTW_H
#define AUTONUMBERINGMANAGEMENTW_H
#include <QWidget>
class NumPartEditorW;
class QAbstractButton;
class QETProject;
namespace Ui {
class AutoNumberingManagementW;
}
class AutoNumberingManagementW : public QWidget
{
Q_OBJECT
//METHODS
public:
explicit AutoNumberingManagementW(QETProject *project, QWidget *parent = 0);
~AutoNumberingManagementW();
Ui::AutoNumberingManagementW *ui;
void setProjectContext ();
void contextToFormula ();
QString elementFormula();
//SIGNALS
signals:
void applyPressed();
//SLOTS
private slots:
void on_m_from_folios_cb_currentIndexChanged(int);
void on_m_to_folios_cb_currentIndexChanged(int);
void on_m_status_cb_currentIndexChanged(int);
void on_m_apply_folios_rb_clicked();
void on_m_apply_project_rb_clicked();
void on_buttonBox_clicked(QAbstractButton *);
void applyEnable (bool = true);
//ATTRIBUTES
private:
QETProject *project_;
};
#endif // AUTONUMBERINGMANAGEMENTW_H

View File

@@ -0,0 +1,470 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AutoNumberingManagementW</class>
<widget class="QWidget" name="AutoNumberingManagementW">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>650</width>
<height>550</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>460</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>50</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>450</width>
<height>253</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>50</height>
</size>
</property>
<property name="mouseTracking">
<bool>false</bool>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAsNeeded</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustToContents</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignHCenter|Qt::AlignTop</set>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>630</width>
<height>495</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>430</width>
<height>250</height>
</size>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="sizeConstraint">
<enum>QLayout::SetFixedSize</enum>
</property>
<item row="0" column="1">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Project Status:</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QComboBox" name="m_status_cb">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToContents</enum>
</property>
</widget>
</item>
<item row="5" column="1" colspan="3">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="1" colspan="3">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Range</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="2" column="0">
<widget class="QLineEdit" name="m_selected_folios_le">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QRadioButton" name="m_apply_locations_rb">
<property name="text">
<string>Apply to Selected Locations</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="m_apply_folios_rb">
<property name="text">
<string>Apply to Selected Folios</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QRadioButton" name="m_apply_project_rb">
<property name="text">
<string>Apply to Entire Project</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLineEdit" name="m_selected_locations_le"/>
</item>
<item row="5" column="0">
<widget class="QWidget" name="m_selected_folios_widget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>From</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="m_from_folios_cb">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_6">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>To</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="m_to_folios_cb">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0" colspan="4">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Update Policy</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QWidget" name="conductorWidget" native="true">
<layout class="QHBoxLayout" name="conductor_hl">
<item>
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Conductor</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="m_both_conductor_rb">
<property name="text">
<string>Both</string>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="m_new_conductor_rb">
<property name="text">
<string>Only New</string>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="m_existent_conductor_rb">
<property name="text">
<string>Only Existent</string>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="m_disable_conductor_rb">
<property name="text">
<string>Disable</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="elementWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QHBoxLayout" name="element_hl">
<item>
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Element</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="m_both_element_rb">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Both</string>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="m_new_element_rb">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Only New</string>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="m_existent_element_rb">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Only Existent</string>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="m_disable_element_rb">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Disable</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="folioWidget" native="true">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
<kerning>true</kerning>
</font>
</property>
<layout class="QHBoxLayout" name="folio_hl">
<item>
<widget class="QLabel" name="label_4">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Folio</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="m_new_folio_rb">
<property name="text">
<string>Only New</string>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="m_existent_folio_rb">
<property name="text">
<string>Existent</string>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="m_both_folio_rb">
<property name="text">
<string>Both</string>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="m_disable_folio_rb">
<property name="text">
<string>Disable</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Apply|QDialogButtonBox::Help</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,79 @@
/*
Copyright 2006-2016 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 <http://www.gnu.org/licenses/>.
*/
#include "autonumselectorwidget.h"
#include "ui_autonumselectorwidget.h"
/**
* @brief AutonumSelectorWidget::AutonumSelectorWidget
* Constructor with texts to fill the combo box
* @param items, items for fill the combo box
* @param parent, parent widget
*/
AutonumSelectorWidget::AutonumSelectorWidget(const QStringList &items, QWidget *parent) :
QWidget(parent),
ui(new Ui::AutonumSelectorWidget)
{
ui->setupUi(this);
ui -> m_available_autonum_cb -> addItems(items);
}
/**
* @brief AutonumSelectorWidget::~AutonumSelectorWidget
* Destructor
*/
AutonumSelectorWidget::~AutonumSelectorWidget() {
delete ui;
}
/**
* @brief AutonumSelectorWidget::setCurrentItem
* Set the combo box current index by text.
* If text doesn't exist, set current index -1
* @param item, item of index
*/
void AutonumSelectorWidget::setCurrentItem(const QString &item) {
ui -> m_available_autonum_cb -> setCurrentIndex( ui -> m_available_autonum_cb -> findText(item));
}
/**
* @brief AutonumSelectorWidget::setItems
* Populate this widget with the content of @items
* Previous items is clear.
* @param items
*/
void AutonumSelectorWidget::setItems(const QStringList &items) {
ui -> m_available_autonum_cb -> clear();
ui -> m_available_autonum_cb -> addItems(items);
}
/**
* @brief AutonumSelectorWidget::text
* @return the current displayed text
*/
QString AutonumSelectorWidget::text() const {
return ui -> m_available_autonum_cb -> currentText();
}
/**
* @brief AutonumSelectorWidget::on_m_edit_autonum_pb_clicked
* Just emit the signal openAutonumEditor.
* The owner of AutonumSelectorWidget need to connect the signal.
*/
void AutonumSelectorWidget::on_m_edit_autonum_pb_clicked() {
emit openAutonumEditor();
}

View File

@@ -0,0 +1,55 @@
/*
Copyright 2006-2016 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 <http://www.gnu.org/licenses/>.
*/
#ifndef AUTONUMSELECTORWIDGET_H
#define AUTONUMSELECTORWIDGET_H
#include <QWidget>
namespace Ui {
class AutonumSelectorWidget;
}
/**
* @brief The AutonumSelectorWidget class
* This widget show a combobox to select an autonum and a button to edit the autonum
* The combo box is empty and the button isn't linked with anything, it's the role of caller
* of this class to fill the combo box and edit the connection with the button.
*/
class AutonumSelectorWidget : public QWidget
{
Q_OBJECT
public:
explicit AutonumSelectorWidget(const QStringList &items, QWidget *parent = 0);
~AutonumSelectorWidget();
void setCurrentItem (const QString &item);
void setItems (const QStringList &items);
QString text () const;
signals:
void openAutonumEditor ();
private slots:
void on_m_edit_autonum_pb_clicked();
private:
Ui::AutonumSelectorWidget *ui;
};
#endif // AUTONUMSELECTORWIDGET_H

View File

@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AutonumSelectorWidget</class>
<widget class="QWidget" name="AutonumSelectorWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Autonumérotation :</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="m_available_autonum_cb"/>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="m_edit_autonum_pb">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>éditer les numérotations</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../qelectrotech.qrc">
<normaloff>:/ico/16x16/configure.png</normaloff>:/ico/16x16/configure.png</iconset>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../../qelectrotech.qrc"/>
</resources>
<connections/>
</ui>

View File

@@ -0,0 +1,113 @@
/*
Copyright 2006-2016 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 <http://www.gnu.org/licenses/>.
*/
#include "dialogautonum.h"
#include "ui_dialogautonum.h"
//#include "conductorautonumerotation.h"
#include "qetmessagebox.h"
#include "ui/selectautonumw.h"
/**
* @brief DialogAutoNum::DialogAutoNum
* @param dg
* @param parent
*/
DialogAutoNum::DialogAutoNum(Diagram *dg, QWidget *parent) :
QDialog(parent),
ui(new Ui::DialogAutoNum),
dg_ (dg)
{
ui -> setupUi(this);
ui -> configuration_layout -> addWidget (new SelectAutonumW());
dgselect_ = new diagramselection( dg_ -> project(), ui -> annotation_tab);
ui -> verticalLayout_Selection -> addWidget(dgselect_);
}
/**
* @brief Destructor
*/
DialogAutoNum::~DialogAutoNum(){
delete ui;
}
/**
* @brief DialogAutoNum::on_pushButton_delete_clicked
*/
void DialogAutoNum::on_pushButton_delete_clicked() {
// get list of diagrams selected
QList<Diagram *>listDiag = dgselect_ -> list_of_DiagramSelected();
if(listDiag.count()<=0) return;
QString diagramsTitle;
for(int i=0; i<listDiag.count(); i++){
diagramsTitle += listDiag.at(i) -> title();
if(i+1 < listDiag.count()) diagramsTitle += ", ";
}
// Ask if user is sure to delete the conductor numerotation
QMessageBox::StandardButton answer = QET::QetMessageBox::critical(
this,
tr("Suppression des annotations conducteurs", "Attention"),
QString(
tr("Voulez-vous vraiment supprimer les annotations conducteurs de :\n\n%1 ?")
).arg(diagramsTitle),
QMessageBox::Yes | QMessageBox::No,
QMessageBox::No
);
// if yes remove all
if( answer == QMessageBox::Yes) {
for(int i=0; i<listDiag.count(); i++){
/*ConductorAutoNumerotation can(listDiag.at(i));
can.removeNumOfDiagram();*/
}
}
}
/**
* @brief set the autonum to all diagram selected
*/
void DialogAutoNum::on_pushButton_annotation_clicked(){
// Get list of diagrams selected
QList<Diagram *>listDiag = dgselect_ -> list_of_DiagramSelected();
if(listDiag.count()<=0) return;
QString diagramsTitle;
for(int i=0; i<listDiag.count(); i++){
diagramsTitle += listDiag.at(i) -> title();
if(i+1 < listDiag.count()) diagramsTitle += ", ";
}
// Ask if user is sure to numerate the conductor
QET::QetMessageBox::warning(
this,
tr("Annotation des conducteurs", "Attention"),
QString(
tr("Voulez-vous vraiment annoter les conducteurs de :\n\n%1 ?")
).arg(diagramsTitle),
QMessageBox::Yes | QMessageBox::No,
QMessageBox::No
);
}
/**
* @brief Close the dialog
*/
void DialogAutoNum::on_pushButton_close_clicked() {
close();
}

View File

@@ -0,0 +1,49 @@
/*
Copyright 2006-2016 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 <http://www.gnu.org/licenses/>.
*/
#ifndef DIALOGAUTONUM_H
#define DIALOGAUTONUM_H
#include <QDialog>
#include "diagram.h"
#include "ui/diagramselection.h"
namespace Ui {
class DialogAutoNum;
}
class DialogAutoNum : public QDialog
{
Q_OBJECT
public:
explicit DialogAutoNum(Diagram *dg, QWidget *parent = 0);
~DialogAutoNum();
private slots:
void on_pushButton_annotation_clicked();
void on_pushButton_delete_clicked();
void on_pushButton_close_clicked();
private:
Ui::DialogAutoNum *ui;
Diagram *dg_;
diagramselection *dgselect_;
};
#endif // DialogAutoNum_H

View File

@@ -0,0 +1,162 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DialogAutoNum</class>
<widget class="QDialog" name="DialogAutoNum">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>482</width>
<height>416</height>
</rect>
</property>
<property name="windowTitle">
<string>Annotation des schémas</string>
</property>
<property name="windowIcon">
<iconset resource="../../qelectrotech.qrc">
<normaloff>:/ico/oxygen-icons/32x32/apps/qelectrotech.png</normaloff>:/ico/oxygen-icons/32x32/apps/qelectrotech.png</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="configuration_tab">
<attribute name="title">
<string>Configuration</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<layout class="QVBoxLayout" name="configuration_layout">
<property name="spacing">
<number>0</number>
</property>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="annotation_tab">
<attribute name="title">
<string>Annotation</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox_Selection">
<property name="title">
<string>Sélection</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_">
<item>
<widget class="QRadioButton" name="radioButton_conductor">
<property name="text">
<string>Conducteurs</string>
</property>
<property name="icon">
<iconset resource="../../qelectrotech.qrc">
<normaloff>:/ico/22x22/conductor2.png</normaloff>:/ico/22x22/conductor2.png</iconset>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_component">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Composants</string>
</property>
<property name="icon">
<iconset resource="../../qelectrotech.qrc">
<normaloff>:/ico/22x22/single_page.png</normaloff>:/ico/22x22/single_page.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_Selection"/>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="pushButton_annotation">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Numérotée les folio sélectionné&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Annotation (alpha)</string>
</property>
<property name="icon">
<iconset resource="../../qelectrotech.qrc">
<normaloff>:/ico/16x16/edit-select-all.png</normaloff>:/ico/16x16/edit-select-all.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_delete">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Supprimé la numérotation des folio sélectionné&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Supprimer l'annotation</string>
</property>
<property name="icon">
<iconset resource="../../qelectrotech.qrc">
<normaloff>:/ico/16x16/edit-delete.png</normaloff>:/ico/16x16/edit-delete.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_close">
<property name="text">
<string>Fermer</string>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources>
<include location="../../qelectrotech.qrc"/>
</resources>
<connections/>
</ui>

View File

@@ -0,0 +1,216 @@
/*
Copyright 2006-2016 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 <http://www.gnu.org/licenses/>.
*/
#include "folioautonumbering.h"
#include "ui_folioautonumbering.h"
#include <QMessageBox>
#include <QPushButton>
#include <QtWidgets>
#include "qetproject.h"
#include "diagram.h"
/**
* Constructor
*/
FolioAutonumberingW::FolioAutonumberingW(QETProject *project, QWidget *parent) :
QWidget(parent),
project_(project),
ui(new Ui::FolioAutonumberingW)
{
ui->setupUi(this);
applyEnable(false);
ui->m_from_cb->setEnabled(false);
ui->m_new_tabs_sb->setEnabled(false);
ui->m_to_cb->setEnabled(false);
}
/**
* Destructor
*/
FolioAutonumberingW::~FolioAutonumberingW()
{
delete ui;
}
/**
* @brief FolioAutonumberingW::setContext
* construct autonums in the comboBox selected in the @autonum_chooser QcomboBox
*/
void FolioAutonumberingW::setContext(QList <QString> autonums) {
foreach (QString str, autonums) { ui->m_autonums_cb->addItem(str);}
}
/**
* @brief FolioAutonumberingW::autoNumSelected
* returns the current autonum selected
*/
QString FolioAutonumberingW::autoNumSelected(){
return ui->m_autonums_cb->currentText();
}
/**
* @brief FolioAutonumberingW::fromFolio
* returns the current "From Folio" index
*/
int FolioAutonumberingW::fromFolio(){
return ui->m_from_cb->currentIndex()-1;
}
/**
* @brief FolioAutonumberingW::toFolio
* returns the current "To Folio" index
*/
int FolioAutonumberingW::toFolio(){
return ui->m_to_cb->currentIndex()+this->fromFolio()+1;
}
/**
* @brief FolioAutonumberingW::newFoliosNumber
* returns the number of folios to create
*/
int FolioAutonumberingW::newFoliosNumber(){
return ui->m_new_tabs_sb->value();
}
/**
* @brief FolioAutonumberingW::updateFolioList
* update Folio List in From and To ComboBox
*/
void FolioAutonumberingW::updateFolioList(){
ui -> m_from_cb->clear();
ui -> m_to_cb->clear();
if (newFolios){
this -> on_m_create_new_tabs_rb_clicked();
} else {
this -> on_m_autonumber_tabs_rb_clicked();
}
}
/**
* @brief FolioAutonumberingW::on_m_create_new_tabs_rb_clicked
* Enable New Tabs SpinBox
*/
void FolioAutonumberingW::on_m_create_new_tabs_rb_clicked() {
ui->m_from_cb->setEnabled(false);
ui->m_to_cb->setEnabled(false);
ui->m_new_tabs_sb->setEnabled(true);
applyEnable();
newFolios = true;
}
/**
* @brief FolioAutonumberingW::on_m_autonumber_tabs_rb_clicked
* Enable From ComboBox, fill From ComboBox
*/
void FolioAutonumberingW::on_m_autonumber_tabs_rb_clicked() {
ui->m_new_tabs_sb->setEnabled(false);
ui->m_from_cb->setEnabled(true);
ui->m_to_cb->setEnabled(true);
if (ui->m_from_cb->count()<=0){
ui->m_from_cb->clear();
ui->m_from_cb->addItem("");
foreach (Diagram *diagram, project_->diagrams()){
ui->m_from_cb->addItem(diagram->title());
}
}
applyEnable();
newFolios = false;
}
/**
* @brief FolioAutonumberingW::on_m_new_tabs_sb_valueChanged
* Enable Apply if any new folio is to be created
*/
void FolioAutonumberingW::on_m_new_tabs_sb_valueChanged(int){
if (ui->m_new_tabs_sb->value()>0) applyEnable(true);
else applyEnable(false);
}
/**
* @brief FolioAutonumberingW::on_m_from_cb_currentIndexChanged
* Enable To ComboBox
*/
void FolioAutonumberingW::on_m_from_cb_currentIndexChanged(int){
int index = ui->m_from_cb->currentIndex();
ui->m_to_cb->clear();
if (index > 0){
ui->m_to_cb->setEnabled(true);
for (int i=index;i<project_->diagrams().size();i++)
ui->m_to_cb->addItem(project_->diagrams().at(i)->title());
applyEnable(true);
}
else{
applyEnable();
}
}
/**
* @brief SelectAutonumW::on_buttonBox_clicked
* Action on @buttonBox clicked
*/
void FolioAutonumberingW::on_buttonBox_clicked(QAbstractButton *button) {
//transform button to int
int answer = ui -> buttonBox -> buttonRole(button);
switch (answer) {
//help dialog - not implemented yet -
case QDialogButtonBox::HelpRole:
QMessageBox::information (this, tr("Folio Autonumbering", "title window"),
tr("C'est ici que vous pouvez définir la manière dont sera numéroté les nouveaux folios.\n"
"-Une numérotation est composée d'une variable minimum.\n"
"-Vous pouvez ajouter ou supprimer une variable de numérotation par le biais des boutons - et +.\n"
"-Une variable de numérotation comprant: un type, une valeur et une incrémentation.\n"
"\n-les types \"Chiffre 1\", \"Chiffre 01\" et \"Chiffre 001\", représente un type numérique définie dans le champs \"Valeur\", "
"qui s'incrémente à chaque nouveau folio de la valeur du champ \"Incrémentation\".\n"
"-\"Chiffre 01\" et \"Chiffre 001\", sont respectivement représenté sur le schéma par deux et trois digits minimum.\n"
"Si le chiffre définie dans le champs Valeur posséde moins de digits que le type choisit,"
"celui-ci sera précédé par un ou deux 0 afin de respecter son type.\n"
"\n-Le type \"Texte\", représente un texte fixe.\nLe champs \"Incrémentation\" n'est pas utilisé.\n",
"help dialog about the folio autonumerotation"
));
break;
case QDialogButtonBox::ApplyRole:
applyEnable(true);
emit applyPressed();
updateFolioList();
break;
}
}
/**
* @brief SelectAutonumW::applyEnable
* enable/disable the apply button
*/
void FolioAutonumberingW::applyEnable(bool b) {
if (b){
bool valid = true;
if (ui->m_create_new_tabs_rb->isChecked()){
if (ui->m_new_tabs_sb->value()==0) valid = false;
ui->buttonBox->button(QDialogButtonBox::Apply)->setEnabled(valid);
}
else{
if (ui->m_to_cb->currentText()=="") valid = false;
ui->buttonBox->button(QDialogButtonBox::Apply)->setEnabled(valid);
}
}
else{
ui -> buttonBox -> button(QDialogButtonBox::Apply) -> setEnabled(b);
}
}

View File

@@ -0,0 +1,72 @@
/*
Copyright 2006-2016 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 <http://www.gnu.org/licenses/>.
*/
#ifndef FOLIOAUTONUMBERING_H
#define FOLIOAUTONUMBERING_H
#include <QWidget>
#include "numerotationcontext.h"
class NumPartEditorW;
class QAbstractButton;
class QETProject;
namespace Ui {
class FolioAutonumberingW;
}
class FolioAutonumberingW : public QWidget
{
Q_OBJECT
//METHODS
public:
explicit FolioAutonumberingW(QETProject *project, QWidget *parent = 0);
~FolioAutonumberingW();
void setContext (QList <QString> autonums);
NumerotationContext toNumContext() const;
QString autoNumSelected();
int newFoliosNumber();
bool newFolios;
int fromFolio();
int toFolio();
// SIGNALS
signals:
void applyPressed();
void m_autonumber_tabs_rb_clicked();
//SLOTS
private slots:
void on_m_create_new_tabs_rb_clicked();
void on_m_autonumber_tabs_rb_clicked();
void on_m_new_tabs_sb_valueChanged(int);
void on_buttonBox_clicked(QAbstractButton *);
void on_m_from_cb_currentIndexChanged(int);
void applyEnable (bool = true);
//ATTRIBUTES
private:
QETProject *project_;
Ui::FolioAutonumberingW *ui;
QList <NumPartEditorW *> num_part_list_;
NumerotationContext m_context;
void updateFolioList();
};
#endif // FOLIOAUTONUMBERING_H

View File

@@ -0,0 +1,295 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>FolioAutonumberingW</class>
<widget class="QWidget" name="FolioAutonumberingW">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>524</width>
<height>550</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>460</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>50</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>450</width>
<height>253</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>50</height>
</size>
</property>
<property name="mouseTracking">
<bool>false</bool>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAsNeeded</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustToContents</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignHCenter|Qt::AlignTop</set>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>504</width>
<height>495</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>430</width>
<height>250</height>
</size>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="sizeConstraint">
<enum>QLayout::SetFixedSize</enum>
</property>
<item row="2" column="1" colspan="2">
<widget class="QGroupBox" name="Options">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string> Options de numérotation</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="2" column="1">
<widget class="QComboBox" name="m_to_cb">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToContents</enum>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Nouveaux Folios</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="m_from_cb">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToContents</enum>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="m_new_tabs_sb">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<number>999</number>
</property>
<property name="displayIntegerBase">
<number>10</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>À</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>De</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QGroupBox" name="Select">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Sélection:</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QRadioButton" name="m_create_new_tabs_rb">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Créer de nouveaux Folios</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="m_autonumber_tabs_rb">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>NumAuto des folios séléctionnés</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Numérotation automatique de Folio :</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QComboBox" name="m_autonums_cb">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToContents</enum>
</property>
</widget>
</item>
<item row="3" column="1" colspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Apply</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,74 @@
/*
Copyright 2006-2016 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 <http://www.gnu.org/licenses/>.
*/
#include "formulaautonumberingw.h"
#include "ui_formulaautonumberingw.h"
#include <QMessageBox>
#include <QPushButton>
#include <QtWidgets>
/**
* Constructor
*/
FormulaAutonumberingW::FormulaAutonumberingW(QWidget *parent) :
QWidget(parent),
ui(new Ui::FormulaAutonumberingW)
{
ui->setupUi(this);
setContext(formula_);
}
/**
* Destructor
*/
FormulaAutonumberingW::~FormulaAutonumberingW()
{
delete ui;
}
/**
* @brief FormulaAutonumberingW::setContext
* @param formula to be inserted into context
*/
void FormulaAutonumberingW::setContext(QString formula) {
ui->m_formula_le->insert(formula);
}
/**
* @brief FormulaAutonumberingW::clearContext
* @param clear formula line edit text
*/
void FormulaAutonumberingW::clearContext() {
ui->m_formula_le->clear();
}
/**
* @brief FormulaAutonumberingW::formula
* @return formula to be stored into project
*/
QString FormulaAutonumberingW::formula() {
return ui->m_formula_le->text();
}
/**
* @brief FormulaAutonumberingW::on_m_formula_le_textChanged
* Update Apply Button
*/
void FormulaAutonumberingW::on_m_formula_le_textChanged(QString text) {
emit (textChanged(text));
}

View File

@@ -0,0 +1,65 @@
/*
Copyright 2006-2016 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 <http://www.gnu.org/licenses/>.
*/
#ifndef FORMULAAUTONUMBERINGW_H
#define FORMULAAUTONUMBERINGW_H
#include <QWidget>
class QAbstractButton;
namespace Ui {
class FormulaAutonumberingW;
}
/**
This class implements the element autonumbering widget.
It loads the current formula applied to new elements and allows
the user to overwrite it with a new formula. Formula is added
while parsing label in customelement.cpp
*/
class FormulaAutonumberingW : public QWidget
{
Q_OBJECT
//METHODS
public:
explicit FormulaAutonumberingW(QWidget *parent = 0);
~FormulaAutonumberingW();
QString formula();
void setContext(QString);
void clearContext();
Ui::FormulaAutonumberingW *ui;
private:
// SIGNALS
signals:
void applyPressed();
void textChanged(QString);
//SLOTS
private slots:
void on_m_formula_le_textChanged(QString);
//ATTRIBUTES
private:
QString formula_;
};
#endif // FORMULAAUTONUMBERINGW_H

View File

@@ -0,0 +1,115 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>FormulaAutonumberingW</class>
<widget class="QWidget" name="FormulaAutonumberingW">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>370</width>
<height>305</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Auto Naming Pattern:</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<widget class="QLineEdit" name="m_formula_le">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="inputMask">
<string notr="true"/>
</property>
<property name="text">
<string notr="true"/>
</property>
<property name="placeholderText">
<string>Insert Formula Here e.g.: %prefix%l%c</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Formula:</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="locale">
<locale language="French" country="France"/>
</property>
<property name="text">
<string>You can use the following variables to your formula:
-%prefix: Default Element Prefix
-%l: Element Line
-%c: Element Column
-%F: Folio Name
-%f or %id: Folio ID
-%total: Total of folios
You can also assign any other titleblock variable
that you create. Text and number inputs are
also available.</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,318 @@
/*
Copyright 2006-2016 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 <http://www.gnu.org/licenses/>.
*/
#include <QRegExp>
#include "numparteditorw.h"
#include "ui_numparteditorw.h"
/**
* Constructor
*/
NumPartEditorW::NumPartEditorW(QWidget *parent) :
QWidget(parent),
ui(new Ui::NumPartEditorW),
intValidator (new QIntValidator(0,99999,this))
{
ui -> setupUi(this);
setVisibleItems();
setType(NumPartEditorW::unit, true);
}
/**
* Constructor
* Build with value of @context at position i
*/
NumPartEditorW::NumPartEditorW (NumerotationContext &context, int i, QWidget *parent):
QWidget(parent),
ui(new Ui::NumPartEditorW),
intValidator (new QIntValidator(0,99999,this))
{
ui -> setupUi(this);
setVisibleItems();
if(context.size()==0) setType(NumPartEditorW::unit, true);
else {
QStringList strl = context.itemAt(i);
if (strl.at(0)=="unit") setType(NumPartEditorW::unit, true);
else if (strl.at(0)=="unitfolio") setType(NumPartEditorW::unitfolio, true);
else if (strl.at(0)=="ten") setType(NumPartEditorW::ten, true);
else if (strl.at(0)=="tenfolio") setType(NumPartEditorW::tenfolio, true);
else if (strl.at(0)=="hundred") setType(NumPartEditorW::hundred, true);
else if (strl.at(0)=="hundredfolio") setType(NumPartEditorW::hundredfolio, true);
else if (strl.at(0)=="string") setType(NumPartEditorW::string);
else if (strl.at(0)=="idfolio") setType(NumPartEditorW::idfolio);
else if (strl.at(0)=="folio") setType(NumPartEditorW::folio);
else if (strl.at(0)=="machine") setType(NumPartEditorW::machine);
else if (strl.at(0)=="locmach") setType(NumPartEditorW::locmach);
else if (strl.at(0)=="elementline") setType(NumPartEditorW::elementline);
else if (strl.at(0)=="elementcolumn") setType(NumPartEditorW::elementcolumn);
else if (strl.at(0)=="elementprefix") setType(NumPartEditorW::elementprefix);
ui -> value_field -> setText(strl.at(1));
ui -> increase_spinBox -> setValue(strl.at(2).toInt());
}
}
/**
* Destructor
*/
NumPartEditorW::~NumPartEditorW()
{
delete intValidator;
delete ui;
}
void NumPartEditorW::setVisibleItems() {
ui->type_cb->setInsertPolicy(QComboBox::InsertAtBottom);
QStringList items;
if (parentWidget()->parentWidget()->objectName()=="FolioTab") {
items << tr("Chiffre 1") << tr("Chiffre 01")
<< tr("Chiffre 001")
<< tr("Texte");
}
else if (parentWidget()->parentWidget()->objectName()=="ConductorTab") {
items << tr("Chiffre 1") << tr("Chiffre 1 - Folio") << tr("Chiffre 01")
<< tr("Chiffre 01 - Folio") << tr("Chiffre 001") << tr("Chiffre 001 - Folio")
<< tr("Texte") << tr("N° folio") << tr("Folio") << tr("Machine") << tr("Locmach");
}
else
items << tr("Chiffre 1") << tr("Chiffre 1 - Folio") << tr("Chiffre 01")
<< tr("Chiffre 01 - Folio") << tr("Chiffre 001") << tr("Chiffre 001 - Folio")
<< tr("Texte") << tr("N° folio") << tr("Folio") << tr("Machine") << tr("Locmach")
<< tr("Element Line") << tr("Element Column") << tr("Element Prefix");
ui->type_cb->insertItems(0,items);
}
/**
* @brief NumPartEditorW::toNumContext
* @return the display to NumerotationContext
*/
NumerotationContext NumPartEditorW::toNumContext() {
NumerotationContext nc;
QString type_str;
switch (type_) {
case unit:
type_str = "unit";
break;
case unitfolio:
type_str = "unitfolio";
break;
case ten:
type_str = "ten";
break;
case tenfolio:
type_str = "tenfolio";
break;
case hundred:
type_str = "hundred";
break;
case hundredfolio:
type_str = "hundredfolio";
break;
case string:
type_str = "string";
break;
case idfolio:
type_str = "idfolio";
break;
case folio:
type_str = "folio";
break;
case machine:
type_str = "machine";
break;
case locmach:
type_str = "locmach";
break;
case elementline:
type_str = "elementline";
break;
case elementcolumn:
type_str = "elementcolumn";
break;
case elementprefix:
type_str = "elementprefix";
break;
}
if (type_str == "unitfolio" || type_str == "tenfolio" || type_str == "hundredfolio")
nc.addValue(type_str, ui -> value_field -> displayText(), ui -> increase_spinBox -> value(), ui->value_field->displayText().toInt());
else
nc.addValue(type_str, ui -> value_field -> displayText(), ui -> increase_spinBox -> value());
return nc;
}
/**
* @brief NumPartEditorW::isValid
* @return true if value field isn't empty or if type is folio
*/
bool NumPartEditorW::isValid() {
if (type_ == folio || type_ == idfolio || type_ == elementline || type_ == machine || type_ == locmach ||
type_ == elementcolumn || type_ == elementprefix) {return true;}
else if(ui -> value_field -> text().isEmpty()) {return false;}
else return true;
}
/**
* @brief NumPartEditorW::on_type_cb_activated
* Action when user change the type comboBox
*/
void NumPartEditorW::on_type_cb_activated(int) {
if (ui->type_cb->currentText() == tr("Chiffre 1"))
setType(unit);
else if (ui->type_cb->currentText() == tr("Chiffre 1 - Folio"))
setType(unitfolio);
else if (ui->type_cb->currentText() == tr("Chiffre 01"))
setType(ten);
else if (ui->type_cb->currentText() == tr("Chiffre 01 - Folio"))
setType(tenfolio);
else if (ui->type_cb->currentText() == tr("Chiffre 001"))
setType(hundred);
else if (ui->type_cb->currentText() == tr("Chiffre 001 - Folio"))
setType(hundredfolio);
else if (ui->type_cb->currentText() == tr("Texte"))
setType(string);
else if (ui->type_cb->currentText() == tr("N° folio"))
setType(idfolio);
else if (ui->type_cb->currentText() == tr("Folio"))
setType(folio);
else if (ui->type_cb->currentText() == tr("Machine"))
setType(machine);
else if (ui->type_cb->currentText() == tr("Locmach"))
setType(locmach);
else if (ui->type_cb->currentText() == tr("Element Line"))
setType(elementline);
else if (ui->type_cb->currentText() == tr("Element Column"))
setType(elementcolumn);
else if (ui->type_cb->currentText() == tr("Element Prefix"))
setType(elementprefix);
emit changed();
}
/**
* @brief NumPartEditorW::on_value_field_textChanged
* emit changed when @value_field text changed
*/
void NumPartEditorW::on_value_field_textEdited() {
emit changed();
}
/**
* @brief NumPartEditorW::on_increase_spinBox_valueChanged
* emit changed when @increase_spinBox value changed
*/
void NumPartEditorW::on_increase_spinBox_valueChanged(int) {
if (!ui -> value_field -> text().isEmpty()) emit changed();
}
/**
* @brief NumPartEditorW::setType
* Set good behavior by type @t
* @param t, type used
* @param fnum, force the behavior of numeric type
*/
void NumPartEditorW::setType(NumPartEditorW::type t, bool fnum) {
setCurrentIndex(t);
//if @t is a numeric type and preview type @type_ isn't a numeric type
//or @fnum is true, we set numeric behavior
if ( ((t==unit || t==unitfolio || t==ten || t==tenfolio || t==hundred || t==hundredfolio) &&
(type_==string || type_==folio || type_==machine || type_==locmach ||type_==idfolio ||
type_==elementcolumn || type_==elementline || type_==elementprefix))
|| fnum) {
ui -> value_field -> clear();
ui -> value_field -> setEnabled(true);
ui -> value_field -> setValidator(intValidator);
ui -> increase_spinBox -> setEnabled(true);
ui -> increase_spinBox -> setValue(1);
}
//@t isn't a numeric type
else if (t == string || t == folio || t == idfolio || t == elementline || t == machine || t == locmach ||
t == elementcolumn || t == elementprefix) {
ui -> value_field -> clear();
ui -> increase_spinBox -> setDisabled(true);
if (t==string) {
ui -> value_field -> setValidator(0);
ui -> value_field -> setEnabled(true);
}
else if (t==folio) {
ui -> value_field -> setDisabled(true);
ui -> increase_spinBox -> setDisabled(true);
}
else if (t==machine) {
ui -> value_field -> setDisabled(true);
ui -> increase_spinBox -> setDisabled(true);
}
else if (t==locmach) {
ui -> value_field -> setDisabled(true);
ui -> increase_spinBox -> setDisabled(true);
}
else if (t==idfolio) {
ui -> value_field -> setDisabled(true);
ui -> increase_spinBox -> setDisabled(true);
}
else if (t==elementcolumn) {
ui -> value_field -> setDisabled(true);
ui -> increase_spinBox -> setDisabled(true);
}
else if (t==elementline) {
ui -> value_field -> setDisabled(true);
ui -> increase_spinBox -> setDisabled(true);
}
else if (t==elementprefix) {
ui -> value_field -> setDisabled(true);
ui -> increase_spinBox -> setDisabled(true);
}
}
type_= t;
}
/**
* @brief NumPartEditorW::setCurrentIndex
* Set Current Index of type_cb
* @param t, type used
*/
void NumPartEditorW::setCurrentIndex(NumPartEditorW::type t) {
int i;
if (t == unit)
i = ui->type_cb->findText(tr("Chiffre 1"));
else if (t == unitfolio)
i = ui->type_cb->findText(tr("Chiffre 1 - Folio"));
else if (t == ten)
i = ui->type_cb->findText(tr("Chiffre 01"));
else if (t == tenfolio)
i = ui->type_cb->findText(tr("Chiffre 01 - Folio"));
else if (t == hundred)
i = ui->type_cb->findText(tr("Chiffre 001"));
else if (t == hundredfolio)
i = ui->type_cb->findText(tr("Chiffre 001 - Folio"));
else if (t == string)
i = ui->type_cb->findText(tr("Texte"));
else if (t == idfolio)
i = ui->type_cb->findText(tr("N° folio"));
else if (t == folio)
i = ui->type_cb->findText(tr("Folio"));
else if (t == machine)
i = ui->type_cb->findText(tr("Machine"));
else if (t == locmach)
i = ui->type_cb->findText(tr("Locmach"));
else if (t == elementline)
i = ui->type_cb->findText(tr("Element Line"));
else if (t == elementcolumn)
i = ui->type_cb->findText(tr("Element Column"));
else if (t == elementprefix)
i = ui->type_cb->findText(tr("Element Prefix"));
ui->type_cb->setCurrentIndex(i);
}

View File

@@ -0,0 +1,73 @@
/*
Copyright 2006-2016 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 <http://www.gnu.org/licenses/>.
*/
#ifndef NUMPARTEDITORW_H
#define NUMPARTEDITORW_H
#include <QWidget>
#include <QValidator>
#include "numerotationcontext.h"
/**
*This class represent a single part num widget. By this widget, we can define and edit
*how the num auto must work .
*This widget is called by selectautonumw.
*/
namespace Ui {
class NumPartEditorW;
}
class NumPartEditorW : public QWidget
{
Q_OBJECT
//METHODS
public:
explicit NumPartEditorW(QWidget *parent = 0);
NumPartEditorW (NumerotationContext &, int, QWidget *parent=0);
~NumPartEditorW();
enum type {unit,unitfolio,ten,tenfolio, hundred, hundredfolio,
string,idfolio,folio,machine,locmach,
elementline,elementcolumn,elementprefix,
};
NumerotationContext toNumContext();
bool isValid ();
type type_;
private:
void setVisibleItems();
void disableItem(int index);
void setCurrentIndex(NumPartEditorW::type);
private slots:
void on_type_cb_activated(int);
void on_value_field_textEdited();
void on_increase_spinBox_valueChanged(int);
void setType (NumPartEditorW::type t, bool=false);
signals:
void changed ();
private:
Ui::NumPartEditorW *ui;
QValidator *intValidator;
};
#endif // NUMPARTEDITORW_H

View File

@@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>NumPartEditorW</class>
<widget class="QWidget" name="NumPartEditorW">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>368</width>
<height>33</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>3</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<widget class="QComboBox" name="type_cb">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="value_field">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="increase_spinBox">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="wrapping">
<bool>false</bool>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="specialValueText">
<string/>
</property>
<property name="accelerated">
<bool>true</bool>
</property>
<property name="prefix">
<string/>
</property>
<property name="minimum">
<number>1</number>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,334 @@
/*
Copyright 2006-2016 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 <http://www.gnu.org/licenses/>.
*/
#include "selectautonumw.h"
#include "ui_selectautonumw.h"
#include "numparteditorw.h"
#include <QMessageBox>
#include "numerotationcontextcommands.h"
#include "formulaautonumberingw.h"
#include "ui_formulaautonumberingw.h"
#include "qdebug.h"
/**
* Constructor
*/
SelectAutonumW::SelectAutonumW(QWidget *parent) :
QWidget(parent),
ui(new Ui::SelectAutonumW)
{
ui->setupUi(this);
if (this->parentWidget() -> objectName()=="ElementTab"){
m_feaw = new FormulaAutonumberingW();
ui->scrollAreaWidgetContents->layout()->addWidget(m_feaw);
}
else if (this->parentWidget() -> objectName()=="ConductorTab"){
m_fcaw = new FormulaAutonumberingW();
m_fcaw->ui->label->setHidden(true);
ui->scrollAreaWidgetContents->layout()->addWidget(m_fcaw);
}
setContext(NumerotationContext());
}
SelectAutonumW::SelectAutonumW(const NumerotationContext &context, QWidget *parent) :
QWidget(parent),
ui(new Ui::SelectAutonumW)
{
if (this->parentWidget() -> objectName()=="ElementTab"){
m_feaw = new FormulaAutonumberingW();
ui->scrollAreaWidgetContents->layout()->addWidget(m_feaw);
}
else if (this->parentWidget() -> objectName()=="ConductorTab"){
m_fcaw = new FormulaAutonumberingW();
m_fcaw->ui->label->setHidden(true);
ui->scrollAreaWidgetContents->layout()->addWidget(m_fcaw);
}
ui->setupUi(this);
setContext(context);
}
/**
* Destructor
*/
SelectAutonumW::~SelectAutonumW()
{
delete ui;
}
/**
* @brief SelectAutonumW::setCurrentContext
* build the context of current diagram selected in the @diagram_chooser QcomboBox
*/
void SelectAutonumW::setContext(const NumerotationContext &context) {
m_context = context;
qDeleteAll(num_part_list_);
num_part_list_.clear();
if (m_context.size() == 0) { //@context contain nothing, build a default numPartEditor
on_add_button_clicked();
}
else {
for (int i=0; i<m_context.size(); ++i) { //build with the content of @context
NumPartEditorW *part= new NumPartEditorW(m_context, i, this);
connect (part, SIGNAL(changed()), this, SLOT(applyEnable()));
num_part_list_ << part;
ui -> editor_layout -> addWidget(part);
}
}
num_part_list_.size() == 1 ?
ui -> remove_button -> setDisabled(true):
ui -> remove_button -> setEnabled (true);
applyEnable(false);
}
/**
* @brief SelectAutonumW::toNumContext
* @return the content to @num_part_list to NumerotationContext
*/
NumerotationContext SelectAutonumW::toNumContext() const {
NumerotationContext nc;
foreach (NumPartEditorW *npew, num_part_list_) nc << npew -> toNumContext();
return nc;
}
/**
* @brief SelectAutonumW::on_add_button_clicked
* Action on add_button, add a @NumPartEditor
*/
void SelectAutonumW::on_add_button_clicked() {
applyEnable(false);
NumPartEditorW *part = new NumPartEditorW(this);
connect (part, SIGNAL(changed()), this, SLOT(applyEnable()));
num_part_list_ << part;
ui -> editor_layout -> addWidget(part);
ui -> remove_button -> setEnabled(true);
}
/**
* @brief SelectAutonumW::on_remove_button_clicked
* Action on remove button, remove the last @NumPartEditor
*/
void SelectAutonumW::on_remove_button_clicked() {
//remove if @num_part_list contains more than one item
if (num_part_list_.size() > 1) {
NumPartEditorW *part = num_part_list_.takeLast();
disconnect(part, SIGNAL(changed()), this, SLOT(applyEnable()));
delete part;
if (num_part_list_.size() == 1) {
ui -> remove_button -> setDisabled(true);
}
}
applyEnable();
}
/**
* @brief SelectAutonumW::formula
* @return autonumbering widget formula
*/
QString SelectAutonumW::formula() {
if (this->parentWidget() -> objectName()=="ElementTab")
return m_feaw->formula();
else if (this->parentWidget() ->objectName()=="ConductorTab")
return m_fcaw->formula();
else return "";
}
/**
* @brief SelectAutonumW::on_buttonBox_clicked
* Action on @buttonBox clicked
*/
void SelectAutonumW::on_buttonBox_clicked(QAbstractButton *button) {
//transform button to int
int answer = ui -> buttonBox -> buttonRole(button);
switch (answer) {
//Reset the curent context
case QDialogButtonBox::ResetRole:
setContext(m_context);
break;
//help dialog
case QDialogButtonBox::HelpRole:
if (this->parentWidget() -> objectName()=="FolioTab"){
QMessageBox::information (this, tr("Folio Autonumérotation", "title window"),
tr("C'est ici que vous pouvez définir la manière dont sera numéroté les nouveaux folios.\n"
"-Une numérotation est composée d'une variable minimum.\n"
"-Vous pouvez ajouter ou supprimer une variable de numérotation par le biais des boutons - et +.\n"
"-Une variable de numérotation comprant: un type, une valeur et une incrémentation.\n"
"\n-les types \"Chiffre 1\", \"Chiffre 01\" et \"Chiffre 001\", représente un type numérique définie dans le champs \"Valeur\", "
"qui s'incrémente à chaque nouveau folio de la valeur du champ \"Incrémentation\".\n"
"-\"Chiffre 01\" et \"Chiffre 001\", sont respectivement représenté sur le schéma par deux et trois digits minimum.\n"
"Si le chiffre définie dans le champs Valeur posséde moins de digits que le type choisit,"
"celui-ci sera précédé par un ou deux 0 afin de respecter son type.\n"
"\n-Le type \"Texte\", représente un texte fixe.\nLe champs \"Incrémentation\" n'est pas utilisé.\n",
"help dialog about the folio autonumerotation"
));
break;
}
else{
QMessageBox::information (this, tr("Conducteur Autonumérotation", "title window"),
tr("C'est ici que vous pouvez définir la manière dont sera numéroté les nouveaux conducteurs.\n"
"-Une numérotation est composée d'une variable minimum.\n"
"-Vous pouvez ajouter ou supprimer une variable de numérotation par le biais des boutons - et +.\n"
"-Une variable de numérotation comprant: un type, une valeur et une incrémentation.\n"
"\n-les types \"Chiffre 1\", \"Chiffre 01\" et \"Chiffre 001\", représente un type numérique définie dans le champs \"Valeur\", "
"qui s'incrémente à chaque nouveau conducteur de la valeur du champ \"Incrémentation\".\n"
"-\"Chiffre 01\" et \"Chiffre 001\", sont respectivement représenté sur le schéma par deux et trois digits minimum.\n"
"Si le chiffre définie dans le champs Valeur posséde moins de digits que le type choisit,"
"celui-ci sera précédé par un ou deux 0 afin de respecter son type.\n"
"\n-Le type \"Texte\", représente un texte fixe.\nLe champs \"Incrémentation\" n'est pas utilisé.\n"
"\n-Le type \"N° folio\" représente le n° du folio en cours.\nLes autres champs ne sont pas utilisés.\n"
"\n-Le type \"Folio\" représente le nom du folio en cours.\nLes autres champs ne sont pas utilisés.",
"help dialog about the conductor autonumerotation"
));
break;
}
//apply the context in the diagram displayed by @diagram_chooser.
case QDialogButtonBox::ApplyRole:
applyEnable(false);
emit applyPressed();
break;
};
}
/**
* @brief SelectAutonumW::applyEnableOnContextChanged
* enable/disable the apply button after changing the autonum name
*/
void SelectAutonumW::applyEnableOnContextChanged(QString) {
applyEnable(true);
}
/**
* @brief SelectAutonumW::applyEnable
* enable/disable the apply button
*/
void SelectAutonumW::applyEnable(bool b) {
if (b){
bool valid= true;
foreach (NumPartEditorW *npe, num_part_list_) if (!npe -> isValid()) valid= false;
ui -> buttonBox -> button(QDialogButtonBox::Apply) -> setEnabled(valid);
}
else {
ui -> buttonBox -> button(QDialogButtonBox::Apply) -> setEnabled(b);
}
if (this->parentWidget() -> objectName()=="ElementTab")
contextToFormula();
if (this->parentWidget()->objectName()=="ConductorTab")
contextToFormula();
}
/**
* @brief SelectAutonumW::contextToFormula
* Apply formula to ElementAutonumbering Widget
*/
void SelectAutonumW::contextToFormula() {
FormulaAutonumberingW* m_faw;
if (this->parentWidget() -> objectName()=="ElementTab")
m_faw = m_feaw;
if (this->parentWidget()->objectName()=="ConductorTab")
m_faw = m_fcaw;
m_faw->clearContext();
int count_unit = 0;
int count_unitf = 0;
int count_ten = 0;
int count_tenf = 0;
int count_hundred = 0;
int count_hundredf = 0;
foreach (NumPartEditorW *npe, num_part_list_) {
if (npe->isValid()) {
if (npe->type_ == NumPartEditorW::idfolio) {
m_faw->setContext("%id");
}
else if (npe->type_ == NumPartEditorW::folio) {
m_faw->setContext("%F");
}
else if (npe->type_ == NumPartEditorW::machine) {
m_faw->setContext("%M");
}
else if (npe->type_ == NumPartEditorW::locmach) {
m_faw->setContext("%LM");
}
else if (npe->type_ == NumPartEditorW::elementcolumn) {
m_faw->setContext("%c");
}
else if (npe->type_ == NumPartEditorW::elementline) {
m_faw->setContext("%l");
}
else if (npe->type_ == NumPartEditorW::elementprefix) {
m_faw->setContext("%prefix");
}
else if (npe->type_ == NumPartEditorW::string) {
m_faw->setContext(npe->toNumContext().itemAt(0).at(1));
}
else if (npe->type_ == NumPartEditorW::unit) {
count_unit++;
m_faw->setContext("%sequ_"+QString::number(count_unit));
}
else if (npe->type_ == NumPartEditorW::unitfolio) {
count_unitf++;
m_faw->setContext("%sequf_"+QString::number(count_unitf));
}
else if (npe->type_ == NumPartEditorW::ten) {
count_ten++;
m_faw->setContext("%seqt_"+QString::number(count_ten));
}
else if (npe->type_ == NumPartEditorW::tenfolio) {
count_tenf++;
m_faw->setContext("%seqtf_"+QString::number(count_tenf));
}
else if (npe->type_ == NumPartEditorW::hundred) {
count_hundred++;
m_faw->setContext("%seqh_"+QString::number(count_hundred));
}
else if (npe->type_ == NumPartEditorW::hundredfolio) {
count_hundredf++;
m_faw->setContext("%seqhf_"+QString::number(count_hundredf));
}
}
}
}
/**
* @brief SelectAutonumW::on_m_next_pb_clicked
* Increase NumerotationContext
*/
void SelectAutonumW::on_m_next_pb_clicked() {
NumerotationContextCommands ncc (toNumContext());
setContext(ncc.next());
applyEnable(true);
}
/**
* @brief SelectAutonumW::on_m_previous_pb_clicked
* Decrease NumerotationContext
*/
void SelectAutonumW::on_m_previous_pb_clicked() {
NumerotationContextCommands ncc (toNumContext());
setContext(ncc.previous());
applyEnable(true);
}

View File

@@ -0,0 +1,73 @@
/*
Copyright 2006-2016 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 <http://www.gnu.org/licenses/>.
*/
#ifndef SELECTAUTONUMW_H
#define SELECTAUTONUMW_H
#include <QWidget>
#include "numerotationcontext.h"
#include "formulaautonumberingw.h"
class NumPartEditorW;
class QAbstractButton;
class FormulaAutonumberingW;
namespace Ui {
class SelectAutonumW;
}
class SelectAutonumW : public QWidget
{
Q_OBJECT
//METHODS
public:
explicit SelectAutonumW(QWidget *parent = 0);
explicit SelectAutonumW(const NumerotationContext &context, QWidget *parent = 0);
~SelectAutonumW();
void setContext (const NumerotationContext &context);
NumerotationContext toNumContext() const;
void contextToFormula ();
QString formula();
signals:
void applyPressed();
//SLOT
public slots:
void applyEnableOnContextChanged(QString);
private slots:
void on_add_button_clicked();
void on_remove_button_clicked();
void on_buttonBox_clicked(QAbstractButton *);
void applyEnable (bool = true);
//ATTRIBUTES
void on_m_next_pb_clicked();
void on_m_previous_pb_clicked();
private:
Ui::SelectAutonumW *ui;
QList <NumPartEditorW *> num_part_list_;
NumerotationContext m_context;
FormulaAutonumberingW *m_feaw;
FormulaAutonumberingW *m_fcaw;
};
#endif // SELECTAUTONUMW_H

View File

@@ -0,0 +1,303 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SelectAutonumW</class>
<widget class="QWidget" name="SelectAutonumW">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>418</width>
<height>508</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>400</width>
<height>455</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="mouseTracking">
<bool>false</bool>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAsNeeded</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustToContents</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>453</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>400</width>
<height>450</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="sizeConstraint">
<enum>QLayout::SetFixedSize</enum>
</property>
<item>
<widget class="QGroupBox" name="definition_groupe">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Définition</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="sizeConstraint">
<enum>QLayout::SetFixedSize</enum>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="remove_button">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Supprimer une variable de numérotation&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../qelectrotech.qrc">
<normaloff>:/ico/22x22/list-remove.png</normaloff>:/ico/22x22/list-remove.png</iconset>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="add_button">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Ajouter une variable de numérotation&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../qelectrotech.qrc">
<normaloff>:/ico/22x22/list-add.png</normaloff>:/ico/22x22/list-add.png</iconset>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="m_previous_pb">
<property name="toolTip">
<string>Précédent</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../qelectrotech.qrc">
<normaloff>:/ico/16x16/arrow-left.png</normaloff>:/ico/16x16/arrow-left.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="m_next_pb">
<property name="toolTip">
<string>Suivant</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../qelectrotech.qrc">
<normaloff>:/ico/16x16/arrow-right.png</normaloff>:/ico/16x16/arrow-right.png</iconset>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="editor_layout" stretch="0">
<property name="spacing">
<number>0</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<layout class="QHBoxLayout" name="label_layout" stretch="0,0,0">
<property name="spacing">
<number>0</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<widget class="QLabel" name="type_label">
<property name="text">
<string>Type</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="value_label">
<property name="text">
<string>Valeur</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="increase_label">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Incrémentation</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Apply|QDialogButtonBox::Help|QDialogButtonBox::Reset</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../../qelectrotech.qrc"/>
</resources>
<connections/>
</ui>