mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
Conductor autonum dialog : add remove autonum button.
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3270 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -133,10 +133,12 @@ void ConductorAutoNumerotation::numeratePotential() {
|
|||||||
void ConductorAutoNumerotation::numerateNewConductor() {
|
void ConductorAutoNumerotation::numerateNewConductor() {
|
||||||
if (!conductor_ || m_diagram->conductorsAutonumName().isEmpty()) return;
|
if (!conductor_ || m_diagram->conductorsAutonumName().isEmpty()) return;
|
||||||
|
|
||||||
QString name = m_diagram -> conductorsAutonumName();
|
NumerotationContext context = m_diagram->project()->conductorAutoNum(m_diagram -> conductorsAutonumName());
|
||||||
NumerotationContextCommands ncc (m_diagram->project()->conductorAutoNum(name), m_diagram);
|
if (context.isEmpty()) return;
|
||||||
|
|
||||||
|
NumerotationContextCommands ncc (context, m_diagram);
|
||||||
applyText(ncc.toRepresentedString());
|
applyText(ncc.toRepresentedString());
|
||||||
m_diagram->project()->addConductorAutoNum(name, ncc.next());
|
m_diagram->project()->addConductorAutoNum(m_diagram -> conductorsAutonumName(), ncc.next());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -388,10 +388,13 @@ void ProjectAutoNumConfigPage::applyProjectConf() {}
|
|||||||
*/
|
*/
|
||||||
void ProjectAutoNumConfigPage::initWidgets() {
|
void ProjectAutoNumConfigPage::initWidgets() {
|
||||||
m_label = new QLabel(tr("Num\351rotations disponibles :", "availables numerotations"), this);
|
m_label = new QLabel(tr("Num\351rotations disponibles :", "availables numerotations"), this);
|
||||||
|
|
||||||
m_context_cb = new QComboBox(this);
|
m_context_cb = new QComboBox(this);
|
||||||
m_context_cb->addItem(tr("Nouveau"));
|
m_context_cb->setEditable(true);
|
||||||
m_name_le = new QLineEdit(this);
|
m_context_cb->addItem(tr("Nom de la nouvelle num\351rotation"));
|
||||||
m_name_le->setPlaceholderText(tr("Nom de la nouvelle num\351rotation"));
|
|
||||||
|
m_remove_pb = new QPushButton(QET::Icons::EditDelete, QString(), this);
|
||||||
|
m_remove_pb -> setToolTip(tr("Supprimer la num\351rotation"));
|
||||||
|
|
||||||
m_saw = new SelectAutonumW(this);
|
m_saw = new SelectAutonumW(this);
|
||||||
}
|
}
|
||||||
@@ -404,7 +407,7 @@ void ProjectAutoNumConfigPage::initLayout() {
|
|||||||
QHBoxLayout *context_layout = new QHBoxLayout();
|
QHBoxLayout *context_layout = new QHBoxLayout();
|
||||||
context_layout -> addWidget (m_label);
|
context_layout -> addWidget (m_label);
|
||||||
context_layout -> addWidget (m_context_cb);
|
context_layout -> addWidget (m_context_cb);
|
||||||
context_layout -> addWidget (m_name_le);
|
context_layout -> addWidget (m_remove_pb);
|
||||||
|
|
||||||
QVBoxLayout *main_layout = new QVBoxLayout(this);
|
QVBoxLayout *main_layout = new QVBoxLayout(this);
|
||||||
this -> setLayout (main_layout);
|
this -> setLayout (main_layout);
|
||||||
@@ -434,8 +437,9 @@ void ProjectAutoNumConfigPage::adjustReadOnly() {
|
|||||||
* setup some connections
|
* setup some connections
|
||||||
*/
|
*/
|
||||||
void ProjectAutoNumConfigPage::buildConnections() {
|
void ProjectAutoNumConfigPage::buildConnections() {
|
||||||
connect(m_context_cb, SIGNAL (currentIndexChanged(QString)), this, SLOT (updateContext(QString)));
|
connect (m_context_cb, SIGNAL (currentIndexChanged(QString)), this, SLOT (updateContext(QString)));
|
||||||
connect(m_saw, SIGNAL (applyPressed()), this, SLOT (saveContext()));
|
connect (m_saw, SIGNAL (applyPressed()), this, SLOT (saveContext()));
|
||||||
|
connect (m_remove_pb, SIGNAL(clicked()), this, SLOT(removeContext()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -444,16 +448,8 @@ void ProjectAutoNumConfigPage::buildConnections() {
|
|||||||
* @param str, key of context stored in project
|
* @param str, key of context stored in project
|
||||||
*/
|
*/
|
||||||
void ProjectAutoNumConfigPage::updateContext(QString str) {
|
void ProjectAutoNumConfigPage::updateContext(QString str) {
|
||||||
if (str == tr("Nouveau")) {
|
if (str == tr("Nom de la nouvelle num\351rotation")) m_saw -> setContext(NumerotationContext());
|
||||||
m_saw -> setContext(NumerotationContext());
|
else m_saw ->setContext(project_->conductorAutoNum(str));
|
||||||
m_name_le -> setText(QString());
|
|
||||||
m_name_le ->setEnabled(true);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
m_saw ->setContext(project_->conductorAutoNum(str));
|
|
||||||
m_name_le -> setText(str);
|
|
||||||
m_name_le -> setDisabled(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -461,14 +457,30 @@ void ProjectAutoNumConfigPage::updateContext(QString str) {
|
|||||||
* Save the current displayed context in project
|
* Save the current displayed context in project
|
||||||
*/
|
*/
|
||||||
void ProjectAutoNumConfigPage::saveContext() {
|
void ProjectAutoNumConfigPage::saveContext() {
|
||||||
if (m_context_cb->currentText() == tr("Nouveau")) {
|
// If the text is the default text "Name of new numerotation" save the edited context
|
||||||
if (m_name_le->text().isEmpty()) {
|
// With the the name "No name"
|
||||||
m_name_le->setText(tr("Nouvel num\351rotation"));
|
if (m_context_cb -> currentText() == tr("Nom de la nouvelle num\351rotation")) {
|
||||||
}
|
project_->addConductorAutoNum (tr("Sans nom"), m_saw -> toNumContext());
|
||||||
project_->addConductorAutoNum(m_name_le -> text(), m_saw -> toNumContext());
|
m_context_cb -> addItem(tr("Sans nom"));
|
||||||
m_context_cb -> addItem(m_name_le -> text());
|
|
||||||
}
|
}
|
||||||
|
// If the text isn't yet to the autonum of the project, add this new item to the combo box.
|
||||||
|
else if ( !project_ -> conductorAutoNum().keys().contains( m_context_cb->currentText())) {
|
||||||
|
project()->addConductorAutoNum(m_context_cb->currentText(), m_saw->toNumContext());
|
||||||
|
m_context_cb -> addItem(m_context_cb->currentText());
|
||||||
|
}
|
||||||
|
// Else, the text already exist in the autonum of the project, just update the context
|
||||||
else {
|
else {
|
||||||
project_->addConductorAutoNum (m_context_cb -> currentText(), m_saw -> toNumContext());
|
project_->addConductorAutoNum (m_context_cb -> currentText(), m_saw -> toNumContext());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ProjectAutoNumConfigPage::removeContext
|
||||||
|
* Remove from project the current numerotation context
|
||||||
|
*/
|
||||||
|
void ProjectAutoNumConfigPage::removeContext() {
|
||||||
|
//if default text, return
|
||||||
|
if ( m_context_cb -> currentText() == tr("Nom de la nouvelle num\351rotation") ) return;
|
||||||
|
project_ -> removeConductorAutonum (m_context_cb -> currentText() );
|
||||||
|
m_context_cb -> removeItem (m_context_cb -> currentIndex() );
|
||||||
|
}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ class ReportPropertieWidget;
|
|||||||
class XRefPropertiesWidget;
|
class XRefPropertiesWidget;
|
||||||
class SelectAutonumW;
|
class SelectAutonumW;
|
||||||
class QComboBox;
|
class QComboBox;
|
||||||
|
class QPushButton;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This class, derived from ConfigPage, aims at providing the basic skeleton
|
This class, derived from ConfigPage, aims at providing the basic skeleton
|
||||||
@@ -175,12 +176,13 @@ class ProjectAutoNumConfigPage : public ProjectConfigPage {
|
|||||||
private slots:
|
private slots:
|
||||||
void updateContext(QString);
|
void updateContext(QString);
|
||||||
void saveContext();
|
void saveContext();
|
||||||
|
void removeContext();
|
||||||
|
|
||||||
//Attributes
|
//Attributes
|
||||||
private:
|
private:
|
||||||
QLabel *m_label;
|
QLabel *m_label;
|
||||||
QLineEdit *m_name_le;
|
|
||||||
QComboBox *m_context_cb;
|
QComboBox *m_context_cb;
|
||||||
|
QPushButton *m_remove_pb;
|
||||||
SelectAutonumW *m_saw;
|
SelectAutonumW *m_saw;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -481,6 +481,15 @@ void QETProject::addConductorAutoNum(QString key, NumerotationContext context) {
|
|||||||
m_conductor_autonum.insert(key, context);
|
m_conductor_autonum.insert(key, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief QETProject::removeConductorAutonum
|
||||||
|
* Remove the Numerotation Context stored with key
|
||||||
|
* @param key
|
||||||
|
*/
|
||||||
|
void QETProject::removeConductorAutonum(QString key) {
|
||||||
|
m_conductor_autonum.remove(key);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief QETProject::conductorAutoNum
|
* @brief QETProject::conductorAutoNum
|
||||||
* Return the numerotation context stored with @key.
|
* Return the numerotation context stored with @key.
|
||||||
|
|||||||
@@ -114,6 +114,7 @@ class QETProject : public QObject {
|
|||||||
|
|
||||||
QHash <QString, NumerotationContext> conductorAutoNum() const;
|
QHash <QString, NumerotationContext> conductorAutoNum() const;
|
||||||
void addConductorAutoNum (QString key, NumerotationContext context);
|
void addConductorAutoNum (QString key, NumerotationContext context);
|
||||||
|
void removeConductorAutonum (QString key);
|
||||||
NumerotationContext conductorAutoNum(const QString &key) const;
|
NumerotationContext conductorAutoNum(const QString &key) const;
|
||||||
|
|
||||||
QDomDocument toXml();
|
QDomDocument toXml();
|
||||||
|
|||||||
Reference in New Issue
Block a user