mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-19 23:20:52 +01:00
ElementEditor: qtelementeditor.cpp improve code style
This commit is contained in:
committed by
Laurent Trinques
parent
3d1e30b24e
commit
0507336622
@@ -72,8 +72,7 @@ QETElementEditor::QETElementEditor(QWidget *parent) :
|
|||||||
QETMainWindow(parent),
|
QETMainWindow(parent),
|
||||||
read_only(false),
|
read_only(false),
|
||||||
min_title(tr("QElectroTech - Éditeur d'élément", "window title")),
|
min_title(tr("QElectroTech - Éditeur d'élément", "window title")),
|
||||||
opened_from_file(false)
|
opened_from_file(false) {
|
||||||
{
|
|
||||||
setWindowTitle(min_title);
|
setWindowTitle(min_title);
|
||||||
setWindowIcon(QET::Icons::QETLogo);
|
setWindowIcon(QET::Icons::QETLogo);
|
||||||
|
|
||||||
@@ -111,8 +110,7 @@ QETElementEditor::~QETElementEditor() {
|
|||||||
* The new location to edit
|
* The new location to edit
|
||||||
* @param el
|
* @param el
|
||||||
*/
|
*/
|
||||||
void QETElementEditor::setLocation(const ElementsLocation &el)
|
void QETElementEditor::setLocation(const ElementsLocation &el) {
|
||||||
{
|
|
||||||
location_ = el;
|
location_ = el;
|
||||||
opened_from_file = false;
|
opened_from_file = false;
|
||||||
setReadOnly(!location_.isWritable());
|
setReadOnly(!location_.isWritable());
|
||||||
@@ -214,6 +212,7 @@ void QETElementEditor::setupActions() {
|
|||||||
copy -> setShortcut(QKeySequence::Copy);
|
copy -> setShortcut(QKeySequence::Copy);
|
||||||
paste -> setShortcut(QKeySequence::Paste);
|
paste -> setShortcut(QKeySequence::Paste);
|
||||||
paste_in_area -> setShortcut(tr("Ctrl+Shift+V"));
|
paste_in_area -> setShortcut(tr("Ctrl+Shift+V"));
|
||||||
|
|
||||||
#ifndef Q_OS_MAC
|
#ifndef Q_OS_MAC
|
||||||
edit_delete -> setShortcut(QKeySequence(Qt::Key_Delete));
|
edit_delete -> setShortcut(QKeySequence(Qt::Key_Delete));
|
||||||
#else
|
#else
|
||||||
@@ -250,8 +249,9 @@ void QETElementEditor::setupActions() {
|
|||||||
m_depth_action_group = QET::depthActionGroup(this);
|
m_depth_action_group = QET::depthActionGroup(this);
|
||||||
|
|
||||||
connect(m_depth_action_group, &QActionGroup::triggered, [this](QAction *action) {
|
connect(m_depth_action_group, &QActionGroup::triggered, [this](QAction *action) {
|
||||||
this->elementScene()->undoStack().push(new ChangeZValueCommand(this->elementScene(), action->data().value<QET::DepthOption>()));
|
this -> elementScene() -> undoStack().push(
|
||||||
emit(this->elementScene()->partsZValueChanged());
|
new ChangeZValueCommand(this -> elementScene(), action -> data().value<QET::DepthOption>()));
|
||||||
|
emit(this -> elementScene() -> partsZValueChanged());
|
||||||
});
|
});
|
||||||
|
|
||||||
depth_toolbar = addToolBar(tr("Profondeur", "toolbar title"));
|
depth_toolbar = addToolBar(tr("Profondeur", "toolbar title"));
|
||||||
@@ -259,7 +259,6 @@ void QETElementEditor::setupActions() {
|
|||||||
depth_toolbar -> addActions(m_depth_action_group -> actions());
|
depth_toolbar -> addActions(m_depth_action_group -> actions());
|
||||||
addToolBar(Qt::TopToolBarArea, depth_toolbar);
|
addToolBar(Qt::TopToolBarArea, depth_toolbar);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Action related to zoom
|
* Action related to zoom
|
||||||
*/
|
*/
|
||||||
@@ -280,7 +279,6 @@ void QETElementEditor::setupActions() {
|
|||||||
connect(zoom_fit, SIGNAL(triggered()), m_view, SLOT(zoomFit() ));
|
connect(zoom_fit, SIGNAL(triggered()), m_view, SLOT(zoomFit() ));
|
||||||
connect(zoom_reset, SIGNAL(triggered()), m_view, SLOT(zoomReset() ));
|
connect(zoom_reset, SIGNAL(triggered()), m_view, SLOT(zoomReset() ));
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Action related to primitive creation
|
* Action related to primitive creation
|
||||||
*/
|
*/
|
||||||
@@ -307,9 +305,9 @@ void QETElementEditor::setupActions() {
|
|||||||
connect(add_terminal, SIGNAL(triggered()), this, SLOT(addTerminal() ));
|
connect(add_terminal, SIGNAL(triggered()), this, SLOT(addTerminal() ));
|
||||||
connect(add_dynamic_text_field, &QAction::triggered, this, &QETElementEditor::addDynamicTextField);
|
connect(add_dynamic_text_field, &QAction::triggered, this, &QETElementEditor::addDynamicTextField);
|
||||||
|
|
||||||
add_polygon ->setStatusTip(tr("Double-click pour terminer la forme, Click droit pour annuler le dernier point"));
|
add_polygon -> setStatusTip(tr("Double-click pour terminer la forme, Click droit pour annuler le dernier point"));
|
||||||
add_text ->setStatusTip(tr("Ajouter un texte d'élément non éditable dans les schémas"));
|
add_text -> setStatusTip(tr("Ajouter un texte d'élément non éditable dans les schémas"));
|
||||||
add_dynamic_text_field ->setStatusTip(tr("Ajouter un texte d'élément pouvant être édité dans les schémas"));
|
add_dynamic_text_field -> setStatusTip(tr("Ajouter un texte d'élément pouvant être édité dans les schémas"));
|
||||||
|
|
||||||
parts_toolbar = addToolBar(tr("Parties", "toolbar title"));
|
parts_toolbar = addToolBar(tr("Parties", "toolbar title"));
|
||||||
parts_toolbar -> setAllowedAreas(Qt::AllToolBarAreas);
|
parts_toolbar -> setAllowedAreas(Qt::AllToolBarAreas);
|
||||||
@@ -317,7 +315,6 @@ void QETElementEditor::setupActions() {
|
|||||||
parts_toolbar -> addActions(parts -> actions());
|
parts_toolbar -> addActions(parts -> actions());
|
||||||
addToolBar(Qt::LeftToolBarArea, parts_toolbar);
|
addToolBar(Qt::LeftToolBarArea, parts_toolbar);
|
||||||
|
|
||||||
|
|
||||||
main_toolbar = new QToolBar(tr("Outils", "toolbar title"), this);
|
main_toolbar = new QToolBar(tr("Outils", "toolbar title"), this);
|
||||||
main_toolbar -> setObjectName("main_toolbar");
|
main_toolbar -> setObjectName("main_toolbar");
|
||||||
view_toolbar = new QToolBar(tr("Affichage", "toolbar title"), this);
|
view_toolbar = new QToolBar(tr("Affichage", "toolbar title"), this);
|
||||||
@@ -380,8 +377,9 @@ void QETElementEditor::setupMenus() {
|
|||||||
file_menu -> addAction(open_file);
|
file_menu -> addAction(open_file);
|
||||||
file_menu -> addAction(open_dxf);
|
file_menu -> addAction(open_dxf);
|
||||||
QMenu *recentfile = file_menu -> addMenu(QET::Icons::DocumentOpenRecent, tr("&Récemment ouverts"));
|
QMenu *recentfile = file_menu -> addMenu(QET::Icons::DocumentOpenRecent, tr("&Récemment ouverts"));
|
||||||
recentfile->addActions(QETApp::elementsRecentFiles()->menu()->actions());
|
recentfile -> addActions(QETApp::elementsRecentFiles() -> menu() -> actions());
|
||||||
connect(QETApp::elementsRecentFiles(), SIGNAL(fileOpeningRequested(const QString &)), this, SLOT(openRecentFile(const QString &)));
|
connect(QETApp::elementsRecentFiles(), SIGNAL(
|
||||||
|
fileOpeningRequested(const QString &)), this, SLOT(openRecentFile(const QString &)));
|
||||||
file_menu -> addAction(save);
|
file_menu -> addAction(save);
|
||||||
file_menu -> addAction(save_as);
|
file_menu -> addAction(save_as);
|
||||||
file_menu -> addAction(save_as_file);
|
file_menu -> addAction(save_as_file);
|
||||||
@@ -429,8 +427,7 @@ void QETElementEditor::setupMenus() {
|
|||||||
* @param p, the pos of the menu, in screen coordinate
|
* @param p, the pos of the menu, in screen coordinate
|
||||||
* @param actions, a list of actions who can be prepended to the context menu.
|
* @param actions, a list of actions who can be prepended to the context menu.
|
||||||
*/
|
*/
|
||||||
void QETElementEditor::contextMenu(QPoint p, QList<QAction *> actions)
|
void QETElementEditor::contextMenu(QPoint p, QList<QAction *> actions) {
|
||||||
{
|
|
||||||
QMenu menu(this);
|
QMenu menu(this);
|
||||||
menu.addActions(std::move(actions));
|
menu.addActions(std::move(actions));
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
@@ -452,15 +449,14 @@ void QETElementEditor::contextMenu(QPoint p, QList<QAction *> actions)
|
|||||||
|
|
||||||
//Remove from the context menu the actions which are disabled.
|
//Remove from the context menu the actions which are disabled.
|
||||||
const QList<QAction *>menu_actions = menu.actions();
|
const QList<QAction *>menu_actions = menu.actions();
|
||||||
for(QAction *action : menu_actions)
|
for(QAction *action : menu_actions) {
|
||||||
{
|
if(!action -> isEnabled()) {
|
||||||
if(!action->isEnabled())
|
|
||||||
menu.removeAction(action);
|
menu.removeAction(action);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
menu.exec(p);
|
menu.exec(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Met a jour les menus
|
Met a jour les menus
|
||||||
*/
|
*/
|
||||||
@@ -483,8 +479,9 @@ void QETElementEditor::slot_updateMenus() {
|
|||||||
cut -> setEnabled(selected_items);
|
cut -> setEnabled(selected_items);
|
||||||
copy -> setEnabled(selected_items);
|
copy -> setEnabled(selected_items);
|
||||||
edit_delete -> setEnabled(selected_items);
|
edit_delete -> setEnabled(selected_items);
|
||||||
foreach (QAction *action, m_depth_action_group -> actions())
|
foreach (QAction *action, m_depth_action_group -> actions()) {
|
||||||
action->setEnabled(selected_items);
|
action -> setEnabled(selected_items);
|
||||||
|
}
|
||||||
|
|
||||||
// actions dependant du contenu du presse-papiers
|
// actions dependant du contenu du presse-papiers
|
||||||
paste -> setEnabled(clipboard_elmt);
|
paste -> setEnabled(clipboard_elmt);
|
||||||
@@ -503,17 +500,20 @@ void QETElementEditor::slot_updateTitle() {
|
|||||||
QString title = min_title;
|
QString title = min_title;
|
||||||
title += " - " + m_elmt_scene -> names().name() + " ";
|
title += " - " + m_elmt_scene -> names().name() + " ";
|
||||||
if (!filename_.isEmpty() || !location_.isNull()) {
|
if (!filename_.isEmpty() || !location_.isNull()) {
|
||||||
if (!m_elmt_scene -> undoStack().isClean()) title += tr("[Modifié]", "window title tag");
|
if (!m_elmt_scene -> undoStack().isClean()) {
|
||||||
|
title += tr("[Modifié]", "window title tag");
|
||||||
}
|
}
|
||||||
if (isReadOnly()) title += tr(" [lecture seule]", "window title tag");
|
}
|
||||||
|
if (isReadOnly()) {
|
||||||
|
title += tr(" [lecture seule]", "window title tag");
|
||||||
setWindowTitle(title);
|
setWindowTitle(title);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief QETElementEditor::setupInterface
|
* @brief QETElementEditor::setupInterface
|
||||||
*/
|
*/
|
||||||
void QETElementEditor::setupInterface()
|
void QETElementEditor::setupInterface() {
|
||||||
{
|
|
||||||
// editeur
|
// editeur
|
||||||
m_elmt_scene = new ElementScene(this, this);
|
m_elmt_scene = new ElementScene(this, this);
|
||||||
m_view = new ElementView(m_elmt_scene, this);
|
m_view = new ElementView(m_elmt_scene, this);
|
||||||
@@ -607,8 +607,7 @@ void QETElementEditor::slot_setNoDragToView() {
|
|||||||
Si plusieurs primitives sont selectionnees, seule leur quantite est
|
Si plusieurs primitives sont selectionnees, seule leur quantite est
|
||||||
affichee. Sinon, un widget d'edition approprie est mis en place.
|
affichee. Sinon, un widget d'edition approprie est mis en place.
|
||||||
*/
|
*/
|
||||||
void QETElementEditor::slot_updateInformations()
|
void QETElementEditor::slot_updateInformations() {
|
||||||
{
|
|
||||||
QList<QGraphicsItem *> selected_qgis = m_elmt_scene -> selectedItems();
|
QList<QGraphicsItem *> selected_qgis = m_elmt_scene -> selectedItems();
|
||||||
if (selected_qgis.isEmpty()) {
|
if (selected_qgis.isEmpty()) {
|
||||||
clearToolsDock();
|
clearToolsDock();
|
||||||
@@ -623,21 +622,24 @@ void QETElementEditor::slot_updateInformations()
|
|||||||
QList<CustomElementPart *> cep_list;
|
QList<CustomElementPart *> cep_list;
|
||||||
|
|
||||||
CustomElementPart* part = dynamic_cast<CustomElementPart *>(selected_qgis.first());
|
CustomElementPart* part = dynamic_cast<CustomElementPart *>(selected_qgis.first());
|
||||||
QString selection_xml_name = part->xmlName();
|
QString selection_xml_name = part -> xmlName();
|
||||||
bool same_xml_name = true;
|
bool same_xml_name = true;
|
||||||
bool style_editable = true;
|
bool style_editable = true;
|
||||||
for (QGraphicsItem *qgi: selected_qgis) {
|
for (QGraphicsItem *qgi: selected_qgis) {
|
||||||
if (CustomElementPart *cep = dynamic_cast<CustomElementPart *>(qgi)) {
|
if (CustomElementPart *cep = dynamic_cast<CustomElementPart *>(qgi)) {
|
||||||
cep_list << cep;
|
cep_list << cep;
|
||||||
if (cep->xmlName() != selection_xml_name)
|
if (cep -> xmlName() != selection_xml_name) {
|
||||||
same_xml_name = false;
|
same_xml_name = false;
|
||||||
} else {
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
style_editable = false;
|
style_editable = false;
|
||||||
same_xml_name = false;
|
same_xml_name = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (style_editable)
|
if (style_editable) {
|
||||||
style_editable = StyleEditor::isStyleEditable(cep_list);
|
style_editable = StyleEditor::isStyleEditable(cep_list);
|
||||||
|
}
|
||||||
|
|
||||||
if (same_xml_name) {
|
if (same_xml_name) {
|
||||||
if (selection_xml_name == "terminal" ||
|
if (selection_xml_name == "terminal" ||
|
||||||
@@ -653,7 +655,7 @@ void QETElementEditor::slot_updateInformations()
|
|||||||
|
|
||||||
// TODO: Check if it takes longer than setting the parts again to the editor.
|
// TODO: Check if it takes longer than setting the parts again to the editor.
|
||||||
bool equal = true;
|
bool equal = true;
|
||||||
QList<CustomElementPart*> parts = editor->currentParts();
|
QList<CustomElementPart*> parts = editor -> currentParts();
|
||||||
if (parts.length() == cep_list.length()) {
|
if (parts.length() == cep_list.length()) {
|
||||||
for (auto cep: cep_list) {
|
for (auto cep: cep_list) {
|
||||||
bool part_found = false;
|
bool part_found = false;
|
||||||
@@ -668,80 +670,73 @@ void QETElementEditor::slot_updateInformations()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
|
else {
|
||||||
equal = false;
|
equal = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (editor)
|
if (editor) {
|
||||||
{
|
|
||||||
bool success = true;
|
bool success = true;
|
||||||
if (equal == false) {
|
if (equal == false) {
|
||||||
success = editor->setParts(cep_list);
|
success = editor -> setParts(cep_list);
|
||||||
}
|
}
|
||||||
if (success)
|
if (success) {
|
||||||
{
|
m_tools_dock_stack -> insertWidget(1, editor);
|
||||||
m_tools_dock_stack->insertWidget(1, editor);
|
|
||||||
m_tools_dock_stack -> setCurrentIndex(1);
|
m_tools_dock_stack -> setCurrentIndex(1);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
qDebug() << "Editor refused part.";
|
qDebug() << "Editor refused part.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else if (selection_xml_name == "polygon" && cep_list.length() == 1) {
|
}
|
||||||
|
else if (selection_xml_name == "polygon" && cep_list.length() == 1) {
|
||||||
// multi edit for polygons makes no sense
|
// multi edit for polygons makes no sense
|
||||||
// TODO: maybe allowing multipart edit when number of points is the same?
|
// TODO: maybe allowing multipart edit when number of points is the same?
|
||||||
//We add the editor widget
|
//We add the editor widget
|
||||||
clearToolsDock();
|
clearToolsDock();
|
||||||
ElementItemEditor *editor = static_cast<ElementItemEditor*>(m_editors[selection_xml_name]);
|
ElementItemEditor *editor = static_cast<ElementItemEditor*>(m_editors[selection_xml_name]);
|
||||||
CustomElementPart* part = editor->currentPart();
|
CustomElementPart* part = editor -> currentPart();
|
||||||
bool equal = part == cep_list.first();
|
bool equal = part == cep_list.first();
|
||||||
|
|
||||||
if (editor)
|
if (editor) {
|
||||||
{
|
|
||||||
bool success = true;
|
bool success = true;
|
||||||
if (equal == false) {
|
if (equal == false) {
|
||||||
success = editor->setPart(cep_list.first());
|
success = editor -> setPart(cep_list.first());
|
||||||
}
|
}
|
||||||
if (success)
|
if (success) {
|
||||||
{
|
m_tools_dock_stack -> insertWidget(1, editor);
|
||||||
m_tools_dock_stack->insertWidget(1, editor);
|
|
||||||
m_tools_dock_stack -> setCurrentIndex(1);
|
m_tools_dock_stack -> setCurrentIndex(1);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
qDebug() << "Editor refused part.";
|
qDebug() << "Editor refused part.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
} else {
|
}
|
||||||
qDebug() << "Multiedit not supported for: " << cep_list.first()->xmlName();
|
else {
|
||||||
|
qDebug() << "Multiedit not supported for: " << cep_list.first() -> xmlName();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//There's several parts selecteds and all can be edited by style editor.
|
//There's several parts selecteds and all can be edited by style editor.
|
||||||
if (style_editable)
|
if (style_editable) {
|
||||||
{
|
|
||||||
clearToolsDock();
|
clearToolsDock();
|
||||||
ElementItemEditor *selection_editor = m_editors["style"];
|
ElementItemEditor *selection_editor = m_editors["style"];
|
||||||
if (selection_editor)
|
if (selection_editor) {
|
||||||
{
|
if (selection_editor -> setParts(cep_list)) {
|
||||||
if (selection_editor -> setParts(cep_list))
|
m_tools_dock_stack -> insertWidget(1, selection_editor);
|
||||||
{
|
|
||||||
m_tools_dock_stack->insertWidget(1, selection_editor);
|
|
||||||
m_tools_dock_stack -> setCurrentIndex(1);
|
m_tools_dock_stack -> setCurrentIndex(1);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
qDebug() << "Editor refused part.";
|
qDebug() << "Editor refused part.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Else we only display the number of selected items
|
//Else we only display the number of selected items
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
clearToolsDock();
|
clearToolsDock();
|
||||||
m_default_informations -> setText(tr("%n partie(s) sélectionnée(s).",
|
m_default_informations -> setText(tr("%n partie(s) sélectionnée(s).",
|
||||||
"",
|
"",
|
||||||
@@ -756,8 +751,7 @@ void QETElementEditor::slot_updateInformations()
|
|||||||
* Do several check about element.
|
* Do several check about element.
|
||||||
* If error is occurred return false
|
* If error is occurred return false
|
||||||
*/
|
*/
|
||||||
bool QETElementEditor::checkElement()
|
bool QETElementEditor::checkElement() {
|
||||||
{
|
|
||||||
//List of warning and error
|
//List of warning and error
|
||||||
typedef QPair<QString, QString> QETWarning;
|
typedef QPair<QString, QString> QETWarning;
|
||||||
QList<QETWarning> warnings;
|
QList<QETWarning> warnings;
|
||||||
@@ -765,8 +759,7 @@ bool QETElementEditor::checkElement()
|
|||||||
|
|
||||||
/// Warning #1: Element haven't got terminal
|
/// Warning #1: Element haven't got terminal
|
||||||
/// (except for report, because report must have one terminal and this checking is do below)
|
/// (except for report, because report must have one terminal and this checking is do below)
|
||||||
if (!m_elmt_scene -> containsTerminals() && !m_elmt_scene -> elementType().contains("report"))
|
if (!m_elmt_scene -> containsTerminals() && !m_elmt_scene -> elementType().contains("report")) {
|
||||||
{
|
|
||||||
warnings << qMakePair(
|
warnings << qMakePair(
|
||||||
tr("Absence de borne", "warning title"),
|
tr("Absence de borne", "warning title"),
|
||||||
tr(
|
tr(
|
||||||
@@ -778,17 +771,17 @@ bool QETElementEditor::checkElement()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Check folio report element
|
/// Check folio report element
|
||||||
if (m_elmt_scene -> elementType().contains("report"))
|
if (m_elmt_scene -> elementType().contains("report")) {
|
||||||
{
|
|
||||||
int terminal =0;
|
int terminal =0;
|
||||||
|
|
||||||
foreach(QGraphicsItem *qgi, m_elmt_scene->items())
|
foreach(QGraphicsItem *qgi, m_elmt_scene -> items()) {
|
||||||
if (qgraphicsitem_cast<PartTerminal *>(qgi))
|
if (qgraphicsitem_cast<PartTerminal *>(qgi)) {
|
||||||
terminal ++;
|
terminal ++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
///Error folio report must have only one terminal
|
///Error folio report must have only one terminal
|
||||||
if (terminal != 1)
|
if (terminal != 1) {
|
||||||
{
|
|
||||||
errors << qMakePair (tr("Absence de borne"),
|
errors << qMakePair (tr("Absence de borne"),
|
||||||
tr("<br><b>Erreur</b> :"
|
tr("<br><b>Erreur</b> :"
|
||||||
"<br>Les reports de folio doivent posséder une seul borne."
|
"<br>Les reports de folio doivent posséder une seul borne."
|
||||||
@@ -797,19 +790,21 @@ bool QETElementEditor::checkElement()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!errors.count() && !warnings.count()) return(true);
|
if (!errors.count() && !warnings.count()) {
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
// Display warnings
|
// Display warnings
|
||||||
QString dialog_message = tr("La vérification de cet élément a généré", "message box content");
|
QString dialog_message = tr("La vérification de cet élément a généré", "message box content");
|
||||||
|
|
||||||
if (errors.size())
|
if (errors.size()) {
|
||||||
dialog_message += QString(tr(" %n erreur(s)", "errors", errors.size()));
|
dialog_message += QString(tr(" %n erreur(s)", "errors", errors.size()));
|
||||||
|
}
|
||||||
|
|
||||||
if (warnings.size())
|
if (warnings.size()) {
|
||||||
{
|
if (errors.size()) {
|
||||||
if (errors.size())
|
|
||||||
dialog_message += QString (tr(" et"));
|
dialog_message += QString (tr(" et"));
|
||||||
|
}
|
||||||
dialog_message += QString (tr(" %n avertissement(s)", "warnings", warnings.size()));
|
dialog_message += QString (tr(" %n avertissement(s)", "warnings", warnings.size()));
|
||||||
}
|
}
|
||||||
dialog_message += " :";
|
dialog_message += " :";
|
||||||
@@ -825,13 +820,17 @@ bool QETElementEditor::checkElement()
|
|||||||
}
|
}
|
||||||
dialog_message += "</ol>";
|
dialog_message += "</ol>";
|
||||||
|
|
||||||
if (errors.size())
|
if (errors.size()) {
|
||||||
QMessageBox::critical(this, tr("Erreurs"), dialog_message);
|
QMessageBox::critical(this, tr("Erreurs"), dialog_message);
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
QMessageBox::warning(this, tr("Avertissements"), dialog_message);
|
QMessageBox::warning(this, tr("Avertissements"), dialog_message);
|
||||||
|
}
|
||||||
|
|
||||||
//if error == 0 that means they are only warning, we return true.
|
//if error == 0 that means they are only warning, we return true.
|
||||||
if (errors.count() == 0) return(true);
|
if (errors.count() == 0) {
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -886,7 +885,8 @@ void QETElementEditor::fromFile(const QString &filepath) {
|
|||||||
tr("Vous n'avez pas les privilèges nécessaires pour modifier cet élement. Il sera donc ouvert en lecture seule.", "message box content")
|
tr("Vous n'avez pas les privilèges nécessaires pour modifier cet élement. Il sera donc ouvert en lecture seule.", "message box content")
|
||||||
);
|
);
|
||||||
setReadOnly(true);
|
setReadOnly(true);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
setReadOnly(false);
|
setReadOnly(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -902,13 +902,12 @@ void QETElementEditor::fromFile(const QString &filepath) {
|
|||||||
* @param fn : path of the file
|
* @param fn : path of the file
|
||||||
* @return : true if succesfully save.
|
* @return : true if succesfully save.
|
||||||
*/
|
*/
|
||||||
bool QETElementEditor::toFile(const QString &fn)
|
bool QETElementEditor::toFile(const QString &fn) {
|
||||||
{
|
m_elmt_scene -> clearEventInterface();
|
||||||
m_elmt_scene->clearEventInterface();
|
m_elmt_scene -> clearSelection();
|
||||||
m_elmt_scene->clearSelection();
|
|
||||||
UncheckAddPrimitive();
|
UncheckAddPrimitive();
|
||||||
|
|
||||||
QDomDocument element_xml = m_elmt_scene->toXml();
|
QDomDocument element_xml = m_elmt_scene -> toXml();
|
||||||
bool writing = QET::writeXmlFile(element_xml, fn);
|
bool writing = QET::writeXmlFile(element_xml, fn);
|
||||||
if (!writing) {
|
if (!writing) {
|
||||||
QET::QetMessageBox::warning(
|
QET::QetMessageBox::warning(
|
||||||
@@ -920,21 +919,18 @@ bool QETElementEditor::toFile(const QString &fn)
|
|||||||
return(writing);
|
return(writing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief QETElementEditor::toLocation
|
* @brief QETElementEditor::toLocation
|
||||||
* Save the element to Location
|
* Save the element to Location
|
||||||
* @param location : location where we must save the current element
|
* @param location : location where we must save the current element
|
||||||
* @return true if succesfully saved
|
* @return true if succesfully saved
|
||||||
*/
|
*/
|
||||||
bool QETElementEditor::toLocation(const ElementsLocation &location)
|
bool QETElementEditor::toLocation(const ElementsLocation &location) {
|
||||||
{
|
m_elmt_scene -> clearEventInterface();
|
||||||
m_elmt_scene->clearEventInterface();
|
m_elmt_scene -> clearSelection();
|
||||||
m_elmt_scene->clearSelection();
|
|
||||||
UncheckAddPrimitive();
|
UncheckAddPrimitive();
|
||||||
|
|
||||||
if (!location.setXml(m_elmt_scene->toXml()))
|
if (!location.setXml(m_elmt_scene -> toXml())) {
|
||||||
{
|
|
||||||
QET::QetMessageBox::critical(this,
|
QET::QetMessageBox::critical(this,
|
||||||
tr("Erreur", "message box title"),
|
tr("Erreur", "message box title"),
|
||||||
tr("Impossible d'enregistrer l'élément", "message box content"));
|
tr("Impossible d'enregistrer l'élément", "message box content"));
|
||||||
@@ -956,7 +952,8 @@ bool QETElementEditor::isEditing(const ElementsLocation &provided_location) {
|
|||||||
QETApp::realPath(provided_location.toString())
|
QETApp::realPath(provided_location.toString())
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return(provided_location == location_);
|
return(provided_location == location_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -971,7 +968,8 @@ bool QETElementEditor::isEditing(const QString &provided_filepath) {
|
|||||||
QString current_filepath;
|
QString current_filepath;
|
||||||
if (opened_from_file) {
|
if (opened_from_file) {
|
||||||
current_filepath = filename_;
|
current_filepath = filename_;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
current_filepath = QETApp::realPath(location_.toString());
|
current_filepath = QETApp::realPath(location_.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1064,7 +1062,7 @@ void QETElementEditor::addTerminal() {
|
|||||||
* Set dynamic text field creation interface to scene
|
* Set dynamic text field creation interface to scene
|
||||||
*/
|
*/
|
||||||
void QETElementEditor::addDynamicTextField() {
|
void QETElementEditor::addDynamicTextField() {
|
||||||
m_elmt_scene->setEventInterface(new ESEventAddDynamicTextField(m_elmt_scene));
|
m_elmt_scene -> setEventInterface(new ESEventAddDynamicTextField(m_elmt_scene));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1072,7 +1070,9 @@ void QETElementEditor::addDynamicTextField() {
|
|||||||
* Uncheck all action related to primitive
|
* Uncheck all action related to primitive
|
||||||
*/
|
*/
|
||||||
void QETElementEditor::UncheckAddPrimitive() {
|
void QETElementEditor::UncheckAddPrimitive() {
|
||||||
foreach(QAction *action, parts->actions()) action -> setChecked(false);
|
foreach(QAction *action, parts -> actions()) {
|
||||||
|
action -> setChecked(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1089,7 +1089,9 @@ void QETElementEditor::slot_new() {
|
|||||||
void QETElementEditor::slot_open() {
|
void QETElementEditor::slot_open() {
|
||||||
// demande le chemin virtuel de l'element a ouvrir a l'utilisateur
|
// demande le chemin virtuel de l'element a ouvrir a l'utilisateur
|
||||||
ElementsLocation location = ElementDialog::getOpenElementLocation(this);
|
ElementsLocation location = ElementDialog::getOpenElementLocation(this);
|
||||||
if (location.isNull()) return;
|
if (location.isNull()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
QETApp::instance() -> openElementLocations(QList<ElementsLocation>() << location);
|
QETApp::instance() -> openElementLocations(QList<ElementsLocation>() << location);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1117,7 +1119,9 @@ void QETElementEditor::slot_openFile() {
|
|||||||
void QETElementEditor::openRecentFile(const QString &filepath) {
|
void QETElementEditor::openRecentFile(const QString &filepath) {
|
||||||
// small hack to prevent all element editors from trying to topen the required
|
// small hack to prevent all element editors from trying to topen the required
|
||||||
// recent file at the same time
|
// recent file at the same time
|
||||||
if (qApp -> activeWindow() != this) return;
|
if (qApp -> activeWindow() != this) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
openElement(filepath);
|
openElement(filepath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1135,7 +1139,7 @@ QString program = (QDir::homePath() + "/.qet/DXFtoQET");
|
|||||||
#endif
|
#endif
|
||||||
QStringList arguments;
|
QStringList arguments;
|
||||||
QProcess *DXF = new QProcess(qApp);
|
QProcess *DXF = new QProcess(qApp);
|
||||||
DXF->start(program,arguments);
|
DXF -> start(program,arguments);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1147,7 +1151,9 @@ DXF->start(program,arguments);
|
|||||||
@see QETApp::openElementFiles
|
@see QETApp::openElementFiles
|
||||||
*/
|
*/
|
||||||
void QETElementEditor::openElement(const QString &filepath) {
|
void QETElementEditor::openElement(const QString &filepath) {
|
||||||
if (filepath.isEmpty()) return;
|
if (filepath.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// we have to test the file existence here because QETApp::openElementFiles()
|
// we have to test the file existence here because QETApp::openElementFiles()
|
||||||
// will discard non-existent files through QFileInfo::canonicalFilePath()
|
// will discard non-existent files through QFileInfo::canonicalFilePath()
|
||||||
if (!QFile::exists(filepath)) {
|
if (!QFile::exists(filepath)) {
|
||||||
@@ -1167,25 +1173,27 @@ void QETElementEditor::openElement(const QString &filepath) {
|
|||||||
* @brief QETElementEditor::slot_reload
|
* @brief QETElementEditor::slot_reload
|
||||||
* Reload the element from the file or location
|
* Reload the element from the file or location
|
||||||
*/
|
*/
|
||||||
void QETElementEditor::slot_reload()
|
void QETElementEditor::slot_reload() {
|
||||||
{
|
|
||||||
//If user already edit the element, ask confirmation to reload
|
//If user already edit the element, ask confirmation to reload
|
||||||
if (!m_elmt_scene -> undoStack().isClean())
|
if (!m_elmt_scene -> undoStack().isClean()) {
|
||||||
{
|
|
||||||
QMessageBox::StandardButton answer = QET::QetMessageBox::question(this,
|
QMessageBox::StandardButton answer = QET::QetMessageBox::question(this,
|
||||||
tr("Recharger l'élément", "dialog title"),
|
tr("Recharger l'élément", "dialog title"),
|
||||||
tr("Vous avez efffectué des modifications sur cet élément. Si vous le rechargez, ces modifications seront perdues. Voulez-vous vraiment recharger l'élément ?", "dialog content"),
|
tr("Vous avez efffectué des modifications sur cet élément. Si vous le rechargez, ces modifications seront perdues. Voulez-vous vraiment recharger l'élément ?", "dialog content"),
|
||||||
QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel,
|
QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel,
|
||||||
QMessageBox::Cancel);
|
QMessageBox::Cancel);
|
||||||
if (answer != QMessageBox::Yes) return;
|
if (answer != QMessageBox::Yes){
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Reload the element
|
//Reload the element
|
||||||
m_elmt_scene -> reset();
|
m_elmt_scene -> reset();
|
||||||
if (opened_from_file)
|
if (opened_from_file) {
|
||||||
fromFile(filename_);
|
fromFile(filename_);
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
fromLocation(location_);
|
fromLocation(location_);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1194,26 +1202,24 @@ void QETElementEditor::slot_reload()
|
|||||||
* If the filepath or location is unknown, use save_as instead
|
* If the filepath or location is unknown, use save_as instead
|
||||||
* @return true if save with success
|
* @return true if save with success
|
||||||
*/
|
*/
|
||||||
bool QETElementEditor::slot_save()
|
bool QETElementEditor::slot_save() {
|
||||||
{
|
|
||||||
// Check element befor writing
|
// Check element befor writing
|
||||||
if (checkElement())
|
if (checkElement()) {
|
||||||
{
|
|
||||||
//If we don't know the name of the current file, use save as instead
|
//If we don't know the name of the current file, use save as instead
|
||||||
if (opened_from_file)
|
if (opened_from_file) {
|
||||||
{
|
if (filename_.isEmpty()) {
|
||||||
if (filename_.isEmpty())
|
|
||||||
return(slot_saveAsFile());
|
return(slot_saveAsFile());
|
||||||
|
}
|
||||||
|
|
||||||
//Else wa save to the file at filename_ path
|
//Else wa save to the file at filename_ path
|
||||||
bool result_save = toFile(filename_);
|
bool result_save = toFile(filename_);
|
||||||
if (result_save) m_elmt_scene -> undoStack().setClean();
|
if (result_save) m_elmt_scene -> undoStack().setClean();
|
||||||
return(result_save);
|
return(result_save);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
if (location_.isNull()) {
|
||||||
if (location_.isNull())
|
|
||||||
return(slot_saveAs());
|
return(slot_saveAs());
|
||||||
|
}
|
||||||
|
|
||||||
//Else save to the known location
|
//Else save to the known location
|
||||||
bool result_save = toLocation(location_);
|
bool result_save = toLocation(location_);
|
||||||
@@ -1235,21 +1241,19 @@ bool QETElementEditor::slot_save()
|
|||||||
* to this location
|
* to this location
|
||||||
* @return true if save with success
|
* @return true if save with success
|
||||||
*/
|
*/
|
||||||
bool QETElementEditor::slot_saveAs()
|
bool QETElementEditor::slot_saveAs() {
|
||||||
{
|
|
||||||
// Check element befor writing
|
// Check element befor writing
|
||||||
if (checkElement())
|
if (checkElement()) {
|
||||||
{
|
|
||||||
//Ask a location to user
|
//Ask a location to user
|
||||||
ElementsLocation location = ElementDialog::getSaveElementLocation(this);
|
ElementsLocation location = ElementDialog::getSaveElementLocation(this);
|
||||||
if (location.isNull())
|
if (location.isNull()) {
|
||||||
return(false);
|
return(false);
|
||||||
|
}
|
||||||
|
|
||||||
bool result_save = toLocation(location);
|
bool result_save = toLocation(location);
|
||||||
if (result_save)
|
if (result_save) {
|
||||||
{
|
|
||||||
setLocation(location);
|
setLocation(location);
|
||||||
m_elmt_scene->undoStack().setClean();
|
m_elmt_scene -> undoStack().setClean();
|
||||||
emit saveToLocation(location);
|
emit saveToLocation(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1264,11 +1268,9 @@ bool QETElementEditor::slot_saveAs()
|
|||||||
* Ask a file to user and save the current edited element to this file
|
* Ask a file to user and save the current edited element to this file
|
||||||
* @return true if save with success
|
* @return true if save with success
|
||||||
*/
|
*/
|
||||||
bool QETElementEditor::slot_saveAsFile()
|
bool QETElementEditor::slot_saveAsFile() {
|
||||||
{
|
|
||||||
// Check element befor writing
|
// Check element befor writing
|
||||||
if (checkElement())
|
if (checkElement()) {
|
||||||
{
|
|
||||||
//Ask a filename to user, for save the element
|
//Ask a filename to user, for save the element
|
||||||
QString fn = QFileDialog::getSaveFileName(
|
QString fn = QFileDialog::getSaveFileName(
|
||||||
this,
|
this,
|
||||||
@@ -1280,17 +1282,18 @@ bool QETElementEditor::slot_saveAsFile()
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (fn.isEmpty())
|
if (fn.isEmpty()) {
|
||||||
return(false);
|
return(false);
|
||||||
|
}
|
||||||
|
|
||||||
//If the name doesn't end by .elmt, we add it
|
//If the name doesn't end by .elmt, we add it
|
||||||
if (!fn.endsWith(".elmt", Qt::CaseInsensitive))
|
if (!fn.endsWith(".elmt", Qt::CaseInsensitive)) {
|
||||||
fn += ".elmt";
|
fn += ".elmt";
|
||||||
|
}
|
||||||
|
|
||||||
bool result_save = toFile(fn);
|
bool result_save = toFile(fn);
|
||||||
//If the save success, the filename is keep
|
//If the save success, the filename is keep
|
||||||
if (result_save)
|
if (result_save) {
|
||||||
{
|
|
||||||
setFileName(fn);
|
setFileName(fn);
|
||||||
QETApp::elementsRecentFiles() -> fileWasOpened(fn);
|
QETApp::elementsRecentFiles() -> fileWasOpened(fn);
|
||||||
m_elmt_scene -> undoStack().setClean();
|
m_elmt_scene -> undoStack().setClean();
|
||||||
@@ -1309,7 +1312,9 @@ bool QETElementEditor::slot_saveAsFile()
|
|||||||
l'utilisateur.
|
l'utilisateur.
|
||||||
*/
|
*/
|
||||||
bool QETElementEditor::canClose() {
|
bool QETElementEditor::canClose() {
|
||||||
if (m_elmt_scene -> undoStack().isClean()) return(true);
|
if (m_elmt_scene -> undoStack().isClean()) {
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
// demande d'abord a l'utilisateur s'il veut enregistrer l'element en cours
|
// demande d'abord a l'utilisateur s'il veut enregistrer l'element en cours
|
||||||
QMessageBox::StandardButton answer = QET::QetMessageBox::question(
|
QMessageBox::StandardButton answer = QET::QetMessageBox::question(
|
||||||
this,
|
this,
|
||||||
@@ -1325,9 +1330,17 @@ bool QETElementEditor::canClose() {
|
|||||||
);
|
);
|
||||||
bool result;
|
bool result;
|
||||||
switch(answer) {
|
switch(answer) {
|
||||||
case QMessageBox::Cancel: result = false; break; // l'utilisateur annule : echec de la fermeture
|
case QMessageBox::Cancel: {
|
||||||
case QMessageBox::Yes: result = slot_save(); break; // l'utilisateur dit oui : la reussite depend de l'enregistrement
|
result = false;
|
||||||
default: result = true; // l'utilisateur dit non ou ferme le dialogue: c'est reussi
|
break; // l'utilisateur annule : echec de la fermeture
|
||||||
|
}
|
||||||
|
case QMessageBox::Yes: {
|
||||||
|
result = slot_save();
|
||||||
|
break; // l'utilisateur dit oui : la reussite depend de l'enregistrement
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
result = true; // l'utilisateur dit non ou ferme le dialogue: c'est reussi
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
@@ -1338,9 +1351,8 @@ bool QETElementEditor::canClose() {
|
|||||||
@return le widget enleve, ou 0 s'il n'y avait pas de widget a enlever
|
@return le widget enleve, ou 0 s'il n'y avait pas de widget a enlever
|
||||||
*/
|
*/
|
||||||
QWidget *QETElementEditor::clearToolsDock() {
|
QWidget *QETElementEditor::clearToolsDock() {
|
||||||
if (QWidget *previous_widget = m_tools_dock_stack->widget(1))
|
if (QWidget *previous_widget = m_tools_dock_stack -> widget(1)) {
|
||||||
{
|
m_tools_dock_stack -> removeWidget(previous_widget);
|
||||||
m_tools_dock_stack->removeWidget(previous_widget);
|
|
||||||
previous_widget -> setParent(nullptr);
|
previous_widget -> setParent(nullptr);
|
||||||
previous_widget -> hide();
|
previous_widget -> hide();
|
||||||
return(previous_widget);
|
return(previous_widget);
|
||||||
@@ -1380,7 +1392,10 @@ void QETElementEditor::closeEvent(QCloseEvent *qce) {
|
|||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
m_elmt_scene -> reset();
|
m_elmt_scene -> reset();
|
||||||
qce -> accept();
|
qce -> accept();
|
||||||
} else qce -> ignore();
|
}
|
||||||
|
else {
|
||||||
|
qce -> ignore();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1415,7 +1430,8 @@ void QETElementEditor::slot_createPartsList() {
|
|||||||
qlwi -> setSelected(qgi -> isSelected());
|
qlwi -> setSelected(qgi -> isSelected());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
m_parts_list -> addItem(new QListWidgetItem(tr("Trop de primitives, liste non générée.")));
|
m_parts_list -> addItem(new QListWidgetItem(tr("Trop de primitives, liste non générée.")));
|
||||||
}
|
}
|
||||||
m_parts_list -> blockSignals(false);
|
m_parts_list -> blockSignals(false);
|
||||||
@@ -1428,7 +1444,8 @@ void QETElementEditor::slot_updatePartsList() {
|
|||||||
int items_count = m_elmt_scene -> items().count();
|
int items_count = m_elmt_scene -> items().count();
|
||||||
if (m_parts_list -> count() != items_count) {
|
if (m_parts_list -> count() != items_count) {
|
||||||
slot_createPartsList();
|
slot_createPartsList();
|
||||||
} else if (items_count <= QET_MAX_PARTS_IN_ELEMENT_EDITOR_LIST) {
|
}
|
||||||
|
else if (items_count <= QET_MAX_PARTS_IN_ELEMENT_EDITOR_LIST) {
|
||||||
m_parts_list -> blockSignals(true);
|
m_parts_list -> blockSignals(true);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
QList<QGraphicsItem *> items = m_elmt_scene -> zItems();
|
QList<QGraphicsItem *> items = m_elmt_scene -> zItems();
|
||||||
@@ -1466,17 +1483,20 @@ void QETElementEditor::slot_updateSelectionFromPartsList() {
|
|||||||
* @brief QETElementEditor::readSettings
|
* @brief QETElementEditor::readSettings
|
||||||
* Read settings
|
* Read settings
|
||||||
*/
|
*/
|
||||||
void QETElementEditor::readSettings()
|
void QETElementEditor::readSettings() {
|
||||||
{
|
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
|
||||||
// dimensions et position de la fenetre
|
// dimensions et position de la fenetre
|
||||||
QVariant geometry = settings.value("elementeditor/geometry");
|
QVariant geometry = settings.value("elementeditor/geometry");
|
||||||
if (geometry.isValid()) restoreGeometry(geometry.toByteArray());
|
if (geometry.isValid()) {
|
||||||
|
restoreGeometry(geometry.toByteArray());
|
||||||
|
}
|
||||||
|
|
||||||
// etat de la fenetre (barres d'outils, docks...)
|
// etat de la fenetre (barres d'outils, docks...)
|
||||||
QVariant state = settings.value("elementeditor/state");
|
QVariant state = settings.value("elementeditor/state");
|
||||||
if (state.isValid()) restoreState(state.toByteArray());
|
if (state.isValid()) {
|
||||||
|
restoreState(state.toByteArray());
|
||||||
|
}
|
||||||
|
|
||||||
// informations complementaires de l'element : valeur par defaut
|
// informations complementaires de l'element : valeur par defaut
|
||||||
m_elmt_scene -> setInformations(settings.value("elementeditor/default-informations", "").toString());
|
m_elmt_scene -> setInformations(settings.value("elementeditor/default-informations", "").toString());
|
||||||
@@ -1486,8 +1506,7 @@ void QETElementEditor::readSettings()
|
|||||||
* @brief QETElementEditor::writeSettings
|
* @brief QETElementEditor::writeSettings
|
||||||
* Write the settings
|
* Write the settings
|
||||||
*/
|
*/
|
||||||
void QETElementEditor::writeSettings()
|
void QETElementEditor::writeSettings() {
|
||||||
{
|
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
settings.setValue("elementeditor/geometry", saveGeometry());
|
settings.setValue("elementeditor/geometry", saveGeometry());
|
||||||
settings.setValue("elementeditor/state", saveState());
|
settings.setValue("elementeditor/state", saveState());
|
||||||
@@ -1532,17 +1551,14 @@ QString QETElementEditor::getOpenElementFileName(QWidget *parent, const QString
|
|||||||
* Location of the element to edit
|
* Location of the element to edit
|
||||||
* @param location
|
* @param location
|
||||||
*/
|
*/
|
||||||
void QETElementEditor::fromLocation(const ElementsLocation &location)
|
void QETElementEditor::fromLocation(const ElementsLocation &location) {
|
||||||
{
|
if (!location.isElement()) {
|
||||||
if (!location.isElement())
|
|
||||||
{
|
|
||||||
QET::QetMessageBox::critical(this,
|
QET::QetMessageBox::critical(this,
|
||||||
tr("Élément inexistant.", "message box title"),
|
tr("Élément inexistant.", "message box title"),
|
||||||
tr("Le chemin virtuel choisi ne correspond pas à un élément.", "message box content"));
|
tr("Le chemin virtuel choisi ne correspond pas à un élément.", "message box content"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!location.exist())
|
if (!location.exist()) {
|
||||||
{
|
|
||||||
QET::QetMessageBox::critical(this,
|
QET::QetMessageBox::critical(this,
|
||||||
tr("Élément inexistant.", "message box title"),
|
tr("Élément inexistant.", "message box title"),
|
||||||
tr("L'élément n'existe pas.", "message box content"));
|
tr("L'élément n'existe pas.", "message box content"));
|
||||||
@@ -1559,8 +1575,7 @@ void QETElementEditor::fromLocation(const ElementsLocation &location)
|
|||||||
slot_createPartsList();
|
slot_createPartsList();
|
||||||
|
|
||||||
//location is read only
|
//location is read only
|
||||||
if (!location.isWritable())
|
if (!location.isWritable()) {
|
||||||
{
|
|
||||||
QET::QetMessageBox::warning(this,
|
QET::QetMessageBox::warning(this,
|
||||||
tr("Édition en lecture seule", "message box title"),
|
tr("Édition en lecture seule", "message box title"),
|
||||||
tr("Vous n'avez pas les privilèges nécessaires pour modifier cet élement. Il sera donc ouvert en lecture seule.", "message box content"));
|
tr("Vous n'avez pas les privilèges nécessaires pour modifier cet élement. Il sera donc ouvert en lecture seule.", "message box content"));
|
||||||
@@ -1581,7 +1596,9 @@ void QETElementEditor::fromLocation(const ElementsLocation &location)
|
|||||||
void QETElementEditor::pasteFromFile() {
|
void QETElementEditor::pasteFromFile() {
|
||||||
// demande le chemin du fichier a ouvrir a l'utilisateur
|
// demande le chemin du fichier a ouvrir a l'utilisateur
|
||||||
QString element_file_path = getOpenElementFileName(this);
|
QString element_file_path = getOpenElementFileName(this);
|
||||||
if (element_file_path.isEmpty()) return;
|
if (element_file_path.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QString error_message;
|
QString error_message;
|
||||||
QDomDocument xml_document;
|
QDomDocument xml_document;
|
||||||
@@ -1589,7 +1606,8 @@ void QETElementEditor::pasteFromFile() {
|
|||||||
// le fichier doit etre lisible
|
// le fichier doit etre lisible
|
||||||
if (!element_file.open(QIODevice::ReadOnly)) {
|
if (!element_file.open(QIODevice::ReadOnly)) {
|
||||||
error_message = QString(tr("Impossible d'ouvrir le fichier %1.", "message box content")).arg(element_file_path);
|
error_message = QString(tr("Impossible d'ouvrir le fichier %1.", "message box content")).arg(element_file_path);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
// le fichier doit etre un document XML
|
// le fichier doit etre un document XML
|
||||||
if (!xml_document.setContent(&element_file)) {
|
if (!xml_document.setContent(&element_file)) {
|
||||||
error_message = tr("Ce fichier n'est pas un document XML valide", "message box content");
|
error_message = tr("Ce fichier n'est pas un document XML valide", "message box content");
|
||||||
@@ -1608,22 +1626,20 @@ void QETElementEditor::pasteFromFile() {
|
|||||||
* Ask an element to user, copy the xml definition of the element
|
* Ask an element to user, copy the xml definition of the element
|
||||||
* to the clipboard and call ElementView::PasteInArea
|
* to the clipboard and call ElementView::PasteInArea
|
||||||
*/
|
*/
|
||||||
void QETElementEditor::pasteFromElement()
|
void QETElementEditor::pasteFromElement() {
|
||||||
{
|
|
||||||
//Ask for a location
|
//Ask for a location
|
||||||
ElementsLocation location = ElementDialog::getOpenElementLocation(this);
|
ElementsLocation location = ElementDialog::getOpenElementLocation(this);
|
||||||
if (location.isNull())
|
if (location.isNull()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!location.isElement())
|
if (!location.isElement()) {
|
||||||
{
|
|
||||||
QET::QetMessageBox::critical(this,
|
QET::QetMessageBox::critical(this,
|
||||||
tr("Élément inexistant.", "message box title"),
|
tr("Élément inexistant.", "message box title"),
|
||||||
tr("Le chemin virtuel choisi ne correspond pas à un élément.", "message box content"));
|
tr("Le chemin virtuel choisi ne correspond pas à un élément.", "message box content"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!location.exist())
|
if (!location.exist()) {
|
||||||
{
|
|
||||||
QET::QetMessageBox::critical(this,
|
QET::QetMessageBox::critical(this,
|
||||||
tr("Élément inexistant.", "message box title"),
|
tr("Élément inexistant.", "message box title"),
|
||||||
tr("L'élément n'existe pas.", "message box content"));
|
tr("L'élément n'existe pas.", "message box content"));
|
||||||
@@ -1644,10 +1660,12 @@ void QETElementEditor::pasteFromElement()
|
|||||||
*/
|
*/
|
||||||
void QETElementEditor::updateCurrentPartEditor() {
|
void QETElementEditor::updateCurrentPartEditor() {
|
||||||
// si aucun widget d'edition n'est affiche, on ne fait rien
|
// si aucun widget d'edition n'est affiche, on ne fait rien
|
||||||
if (!m_tools_dock_stack -> currentIndex()) return;
|
if (!m_tools_dock_stack -> currentIndex()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// s'il y a un widget d'edition affiche, on le met a jour
|
// s'il y a un widget d'edition affiche, on le met a jour
|
||||||
if (ElementItemEditor *current_editor = dynamic_cast<ElementItemEditor *>(m_tools_dock_stack->widget(1))) {
|
if (ElementItemEditor *current_editor = dynamic_cast<ElementItemEditor *>(m_tools_dock_stack -> widget(1))) {
|
||||||
current_editor -> updateForm();
|
current_editor -> updateForm();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user