mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-19 23:20:52 +01:00
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@80 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -58,11 +58,15 @@ void ElementsCategoryEditor::buildDialog() {
|
|||||||
headers << tr("Langue") << tr("Nom");
|
headers << tr("Langue") << tr("Nom");
|
||||||
category_names -> setHeaderLabels(headers);
|
category_names -> setHeaderLabels(headers);
|
||||||
|
|
||||||
|
button_add_line = new QPushButton(tr("Ajouter une ligne"));
|
||||||
|
connect(button_add_line, SIGNAL(released()), this, SLOT(addLine()));
|
||||||
|
|
||||||
buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
connect(buttons, SIGNAL(rejected()), this, SLOT(reject()));
|
connect(buttons, SIGNAL(rejected()), this, SLOT(reject()));
|
||||||
|
|
||||||
editor_layout -> addWidget(new QLabel(tr("Vous pouvez sp\351cifier un nom par langue pour la cat\351gorie.")));
|
editor_layout -> addWidget(new QLabel(tr("Vous pouvez sp\351cifier un nom par langue pour la cat\351gorie.")));
|
||||||
editor_layout -> addWidget(category_names);
|
editor_layout -> addWidget(category_names);
|
||||||
|
editor_layout -> addWidget(button_add_line);
|
||||||
editor_layout -> addWidget(buttons);
|
editor_layout -> addWidget(buttons);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,22 +76,15 @@ void ElementsCategoryEditor::buildDialog() {
|
|||||||
*/
|
*/
|
||||||
void ElementsCategoryEditor::acceptCreation() {
|
void ElementsCategoryEditor::acceptCreation() {
|
||||||
// il doit y avoir au moins un nom
|
// il doit y avoir au moins un nom
|
||||||
int names_count = category_names -> topLevelItemCount();
|
if (!checkOneName()) return;
|
||||||
if (!names_count || (category_names -> topLevelItem(0) -> text(1)) == QString()) {
|
|
||||||
QMessageBox::critical(
|
|
||||||
this,
|
|
||||||
tr("La cat\351gorie doit avoir au moins un nom."),
|
|
||||||
tr("Vous devez entrer au moins un nom pour la cat\351gorie.")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// chargement des noms
|
// chargement des noms
|
||||||
category -> clearNames();
|
category -> clearNames();
|
||||||
|
int names_count = category_names -> topLevelItemCount();
|
||||||
for (int i = 0 ; i < names_count ; ++ i) {
|
for (int i = 0 ; i < names_count ; ++ i) {
|
||||||
category -> addName(
|
QString lang = category_names -> topLevelItem(i) -> text(0);
|
||||||
category_names -> topLevelItem(i) -> text(0),
|
QString value = category_names -> topLevelItem(i) -> text(1);
|
||||||
category_names -> topLevelItem(i) -> text(1)
|
if (lang != "" && value != "") category -> addName(lang, value);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// cree un nom de dossier a partir du 1er nom de la categorie
|
// cree un nom de dossier a partir du 1er nom de la categorie
|
||||||
@@ -103,5 +100,73 @@ void ElementsCategoryEditor::acceptCreation() {
|
|||||||
categorie
|
categorie
|
||||||
*/
|
*/
|
||||||
void ElementsCategoryEditor::acceptUpdate() {
|
void ElementsCategoryEditor::acceptUpdate() {
|
||||||
qDebug() << "acceptUpdate";
|
// il doit y avoir au moins un nom
|
||||||
|
if (!checkOneName()) return;
|
||||||
|
|
||||||
|
// chargement des noms
|
||||||
|
category -> clearNames();
|
||||||
|
int names_count = category_names -> topLevelItemCount();
|
||||||
|
for (int i = 0 ; i < names_count ; ++ i) {
|
||||||
|
QString lang = category_names -> topLevelItem(i) -> text(0);
|
||||||
|
QString value = category_names -> topLevelItem(i) -> text(1);
|
||||||
|
if (lang != "" && value != "") category -> addName(lang, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
category -> write();
|
||||||
|
|
||||||
|
QDialog::accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Nettoie la liste des noms en enlevant les lignes vides
|
||||||
|
*/
|
||||||
|
void ElementsCategoryEditor::clean() {
|
||||||
|
int names_count = category_names -> topLevelItemCount() - 1;
|
||||||
|
for (int i = names_count ; i >= 0 ; -- i) {
|
||||||
|
if (
|
||||||
|
category_names -> topLevelItem(i) -> text(0) == QString() &&\
|
||||||
|
category_names -> topLevelItem(i) -> text(1) == QString()
|
||||||
|
) {
|
||||||
|
category_names -> takeTopLevelItem(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Ajoute une ligne a l'editeur
|
||||||
|
*/
|
||||||
|
void ElementsCategoryEditor::addLine() {
|
||||||
|
clean();
|
||||||
|
QTreeWidgetItem *qtwi = new QTreeWidgetItem();
|
||||||
|
qtwi -> setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
|
||||||
|
category_names -> addTopLevelItem(qtwi);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Verifie qu'il y a au moins un nom
|
||||||
|
*/
|
||||||
|
bool ElementsCategoryEditor::checkOneName() {
|
||||||
|
updateHash();
|
||||||
|
if (!hash_names.size()) {
|
||||||
|
QMessageBox::critical(
|
||||||
|
this,
|
||||||
|
tr("La cat\351gorie doit avoir au moins un nom."),
|
||||||
|
tr("Vous devez entrer au moins un nom pour la cat\351gorie.")
|
||||||
|
);
|
||||||
|
return(false);
|
||||||
|
}
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Lit les noms valides dans hash_names
|
||||||
|
*/
|
||||||
|
void ElementsCategoryEditor::updateHash() {
|
||||||
|
hash_names.clear();
|
||||||
|
int names_count = category_names -> topLevelItemCount();
|
||||||
|
for (int i = 0 ; i < names_count ; ++ i) {
|
||||||
|
QString lang = category_names -> topLevelItem(i) -> text(0);
|
||||||
|
QString value = category_names -> topLevelItem(i) -> text(1);
|
||||||
|
if (lang != "" && value != "") hash_names.insert(lang, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
#ifndef ELEMENTS_CATEGORY_EDITOR_H
|
#ifndef ELEMENTS_CATEGORY_EDITOR_H
|
||||||
#define ELEMENTS_CATEGORY_EDITOR_H
|
#define ELEMENTS_CATEGORY_EDITOR_H
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
|
/**
|
||||||
|
Cette classe permet d'editer une categorie existante ou de creer une
|
||||||
|
categorie.
|
||||||
|
*/
|
||||||
class ElementsCategory;
|
class ElementsCategory;
|
||||||
class ElementsCategoryEditor : public QDialog {
|
class ElementsCategoryEditor : public QDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -15,13 +19,20 @@ class ElementsCategoryEditor : public QDialog {
|
|||||||
QTreeWidget *category_names;
|
QTreeWidget *category_names;
|
||||||
ElementsCategory *category;
|
ElementsCategory *category;
|
||||||
QDialogButtonBox *buttons;
|
QDialogButtonBox *buttons;
|
||||||
|
QPushButton *button_add_line;
|
||||||
|
QHash<QString, QString> hash_names;
|
||||||
|
|
||||||
bool mode_edit;
|
bool mode_edit;
|
||||||
// methodes
|
// methodes
|
||||||
private:
|
private:
|
||||||
void buildDialog();
|
void buildDialog();
|
||||||
|
void clean();
|
||||||
|
bool checkOneName();
|
||||||
|
void updateHash();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void acceptCreation();
|
void acceptCreation();
|
||||||
void acceptUpdate();
|
void acceptUpdate();
|
||||||
|
void addLine();
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -92,10 +92,7 @@ void NewElementWizard::valid() {
|
|||||||
case Dimensions:
|
case Dimensions:
|
||||||
|
|
||||||
case Category:
|
case Category:
|
||||||
|
|
||||||
current_state = Dimensions;
|
current_state = Dimensions;
|
||||||
button_next -> setText(tr("Suivant"));
|
button_next -> setText(tr("Suivant"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ HEADERS += aboutqet.h \
|
|||||||
newelementwizard.h \
|
newelementwizard.h \
|
||||||
qetapp.h \
|
qetapp.h \
|
||||||
terminal.h \
|
terminal.h \
|
||||||
ui_export_fichier.h \
|
|
||||||
elementscategoryeditor.h \
|
elementscategoryeditor.h \
|
||||||
elementscategory.h
|
elementscategory.h
|
||||||
SOURCES += aboutqet.cpp \
|
SOURCES += aboutqet.cpp \
|
||||||
|
|||||||
Reference in New Issue
Block a user