ElementEditor: qtelementeditor.cpp improve code style

This commit is contained in:
damianCaceres
2020-08-05 11:34:41 +01:00
committed by Laurent Trinques
parent 3d1e30b24e
commit 0507336622

View File

@@ -72,8 +72,7 @@ QETElementEditor::QETElementEditor(QWidget *parent) :
QETMainWindow(parent),
read_only(false),
min_title(tr("QElectroTech - Éditeur d'élément", "window title")),
opened_from_file(false)
{
opened_from_file(false) {
setWindowTitle(min_title);
setWindowIcon(QET::Icons::QETLogo);
@@ -111,8 +110,7 @@ QETElementEditor::~QETElementEditor() {
* The new location to edit
* @param el
*/
void QETElementEditor::setLocation(const ElementsLocation &el)
{
void QETElementEditor::setLocation(const ElementsLocation &el) {
location_ = el;
opened_from_file = false;
setReadOnly(!location_.isWritable());
@@ -214,6 +212,7 @@ void QETElementEditor::setupActions() {
copy -> setShortcut(QKeySequence::Copy);
paste -> setShortcut(QKeySequence::Paste);
paste_in_area -> setShortcut(tr("Ctrl+Shift+V"));
#ifndef Q_OS_MAC
edit_delete -> setShortcut(QKeySequence(Qt::Key_Delete));
#else
@@ -250,7 +249,8 @@ void QETElementEditor::setupActions() {
m_depth_action_group = QET::depthActionGroup(this);
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(
new ChangeZValueCommand(this -> elementScene(), action -> data().value<QET::DepthOption>()));
emit(this -> elementScene() -> partsZValueChanged());
});
@@ -259,7 +259,6 @@ void QETElementEditor::setupActions() {
depth_toolbar -> addActions(m_depth_action_group -> actions());
addToolBar(Qt::TopToolBarArea, depth_toolbar);
/*
* Action related to zoom
*/
@@ -280,7 +279,6 @@ void QETElementEditor::setupActions() {
connect(zoom_fit, SIGNAL(triggered()), m_view, SLOT(zoomFit() ));
connect(zoom_reset, SIGNAL(triggered()), m_view, SLOT(zoomReset() ));
/*
* Action related to primitive creation
*/
@@ -317,7 +315,6 @@ void QETElementEditor::setupActions() {
parts_toolbar -> addActions(parts -> actions());
addToolBar(Qt::LeftToolBarArea, parts_toolbar);
main_toolbar = new QToolBar(tr("Outils", "toolbar title"), this);
main_toolbar -> setObjectName("main_toolbar");
view_toolbar = new QToolBar(tr("Affichage", "toolbar title"), this);
@@ -381,7 +378,8 @@ void QETElementEditor::setupMenus() {
file_menu -> addAction(open_dxf);
QMenu *recentfile = file_menu -> addMenu(QET::Icons::DocumentOpenRecent, tr("&Récemment ouverts"));
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_as);
file_menu -> addAction(save_as_file);
@@ -429,8 +427,7 @@ void QETElementEditor::setupMenus() {
* @param p, the pos of the menu, in screen coordinate
* @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);
menu.addActions(std::move(actions));
menu.addSeparator();
@@ -452,15 +449,14 @@ void QETElementEditor::contextMenu(QPoint p, QList<QAction *> actions)
//Remove from the context menu the actions which are disabled.
const QList<QAction *>menu_actions = menu.actions();
for(QAction *action : menu_actions)
{
if(!action->isEnabled())
for(QAction *action : menu_actions) {
if(!action -> isEnabled()) {
menu.removeAction(action);
}
}
menu.exec(p);
}
/**
Met a jour les menus
*/
@@ -483,8 +479,9 @@ void QETElementEditor::slot_updateMenus() {
cut -> setEnabled(selected_items);
copy -> 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);
}
// actions dependant du contenu du presse-papiers
paste -> setEnabled(clipboard_elmt);
@@ -503,17 +500,20 @@ void QETElementEditor::slot_updateTitle() {
QString title = min_title;
title += " - " + m_elmt_scene -> names().name() + " ";
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);
}
}
/**
* @brief QETElementEditor::setupInterface
*/
void QETElementEditor::setupInterface()
{
void QETElementEditor::setupInterface() {
// editeur
m_elmt_scene = new ElementScene(this, 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
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();
if (selected_qgis.isEmpty()) {
clearToolsDock();
@@ -629,15 +628,18 @@ void QETElementEditor::slot_updateInformations()
for (QGraphicsItem *qgi: selected_qgis) {
if (CustomElementPart *cep = dynamic_cast<CustomElementPart *>(qgi)) {
cep_list << cep;
if (cep->xmlName() != selection_xml_name)
if (cep -> xmlName() != selection_xml_name) {
same_xml_name = false;
} else {
}
}
else {
style_editable = false;
same_xml_name = false;
}
}
if (style_editable)
if (style_editable) {
style_editable = StyleEditor::isStyleEditable(cep_list);
}
if (same_xml_name) {
if (selection_xml_name == "terminal" ||
@@ -668,27 +670,27 @@ void QETElementEditor::slot_updateInformations()
break;
}
}
} else
}
else {
equal = false;
}
if (editor)
{
if (editor) {
bool success = true;
if (equal == false) {
success = editor -> setParts(cep_list);
}
if (success)
{
if (success) {
m_tools_dock_stack -> insertWidget(1, editor);
m_tools_dock_stack -> setCurrentIndex(1);
}
else
{
else {
qDebug() << "Editor refused part.";
}
}
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
// TODO: maybe allowing multipart edit when number of points is the same?
//We add the editor widget
@@ -697,51 +699,44 @@ void QETElementEditor::slot_updateInformations()
CustomElementPart* part = editor -> currentPart();
bool equal = part == cep_list.first();
if (editor)
{
if (editor) {
bool success = true;
if (equal == false) {
success = editor -> setPart(cep_list.first());
}
if (success)
{
if (success) {
m_tools_dock_stack -> insertWidget(1, editor);
m_tools_dock_stack -> setCurrentIndex(1);
}
else
{
else {
qDebug() << "Editor refused part.";
}
}
return;
} else {
}
else {
qDebug() << "Multiedit not supported for: " << cep_list.first() -> xmlName();
}
}
//There's several parts selecteds and all can be edited by style editor.
if (style_editable)
{
if (style_editable) {
clearToolsDock();
ElementItemEditor *selection_editor = m_editors["style"];
if (selection_editor)
{
if (selection_editor -> setParts(cep_list))
{
if (selection_editor) {
if (selection_editor -> setParts(cep_list)) {
m_tools_dock_stack -> insertWidget(1, selection_editor);
m_tools_dock_stack -> setCurrentIndex(1);
}
else
{
else {
qDebug() << "Editor refused part.";
}
}
}
//Else we only display the number of selected items
else
{
else {
clearToolsDock();
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.
* If error is occurred return false
*/
bool QETElementEditor::checkElement()
{
bool QETElementEditor::checkElement() {
//List of warning and error
typedef QPair<QString, QString> QETWarning;
QList<QETWarning> warnings;
@@ -765,8 +759,7 @@ bool QETElementEditor::checkElement()
/// Warning #1: Element haven't got terminal
/// (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(
tr("Absence de borne", "warning title"),
tr(
@@ -778,17 +771,17 @@ bool QETElementEditor::checkElement()
}
/// Check folio report element
if (m_elmt_scene -> elementType().contains("report"))
{
if (m_elmt_scene -> elementType().contains("report")) {
int terminal =0;
foreach(QGraphicsItem *qgi, m_elmt_scene->items())
if (qgraphicsitem_cast<PartTerminal *>(qgi))
foreach(QGraphicsItem *qgi, m_elmt_scene -> items()) {
if (qgraphicsitem_cast<PartTerminal *>(qgi)) {
terminal ++;
}
}
///Error folio report must have only one terminal
if (terminal != 1)
{
if (terminal != 1) {
errors << qMakePair (tr("Absence de borne"),
tr("<br><b>Erreur</b> :"
"<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
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()));
}
if (warnings.size())
{
if (errors.size())
if (warnings.size()) {
if (errors.size()) {
dialog_message += QString (tr(" et"));
}
dialog_message += QString (tr(" %n avertissement(s)", "warnings", warnings.size()));
}
dialog_message += " :";
@@ -825,13 +820,17 @@ bool QETElementEditor::checkElement()
}
dialog_message += "</ol>";
if (errors.size())
if (errors.size()) {
QMessageBox::critical(this, tr("Erreurs"), dialog_message);
else
}
else {
QMessageBox::warning(this, tr("Avertissements"), dialog_message);
}
//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;
}
@@ -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")
);
setReadOnly(true);
} else {
}
else {
setReadOnly(false);
}
@@ -902,8 +902,7 @@ void QETElementEditor::fromFile(const QString &filepath) {
* @param fn : path of the file
* @return : true if succesfully save.
*/
bool QETElementEditor::toFile(const QString &fn)
{
bool QETElementEditor::toFile(const QString &fn) {
m_elmt_scene -> clearEventInterface();
m_elmt_scene -> clearSelection();
UncheckAddPrimitive();
@@ -920,21 +919,18 @@ bool QETElementEditor::toFile(const QString &fn)
return(writing);
}
/**
* @brief QETElementEditor::toLocation
* Save the element to Location
* @param location : location where we must save the current element
* @return true if succesfully saved
*/
bool QETElementEditor::toLocation(const ElementsLocation &location)
{
bool QETElementEditor::toLocation(const ElementsLocation &location) {
m_elmt_scene -> clearEventInterface();
m_elmt_scene -> clearSelection();
UncheckAddPrimitive();
if (!location.setXml(m_elmt_scene->toXml()))
{
if (!location.setXml(m_elmt_scene -> toXml())) {
QET::QetMessageBox::critical(this,
tr("Erreur", "message box title"),
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())
)
);
} else {
}
else {
return(provided_location == location_);
}
}
@@ -971,7 +968,8 @@ bool QETElementEditor::isEditing(const QString &provided_filepath) {
QString current_filepath;
if (opened_from_file) {
current_filepath = filename_;
} else {
}
else {
current_filepath = QETApp::realPath(location_.toString());
}
@@ -1072,7 +1070,9 @@ void QETElementEditor::addDynamicTextField() {
* Uncheck all action related to primitive
*/
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() {
// demande le chemin virtuel de l'element a ouvrir a l'utilisateur
ElementsLocation location = ElementDialog::getOpenElementLocation(this);
if (location.isNull()) return;
if (location.isNull()) {
return;
}
QETApp::instance() -> openElementLocations(QList<ElementsLocation>() << location);
}
@@ -1117,7 +1119,9 @@ void QETElementEditor::slot_openFile() {
void QETElementEditor::openRecentFile(const QString &filepath) {
// small hack to prevent all element editors from trying to topen the required
// recent file at the same time
if (qApp -> activeWindow() != this) return;
if (qApp -> activeWindow() != this) {
return;
}
openElement(filepath);
}
@@ -1147,7 +1151,9 @@ DXF->start(program,arguments);
@see QETApp::openElementFiles
*/
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()
// will discard non-existent files through QFileInfo::canonicalFilePath()
if (!QFile::exists(filepath)) {
@@ -1167,26 +1173,28 @@ void QETElementEditor::openElement(const QString &filepath) {
* @brief QETElementEditor::slot_reload
* 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 (!m_elmt_scene -> undoStack().isClean())
{
if (!m_elmt_scene -> undoStack().isClean()) {
QMessageBox::StandardButton answer = QET::QetMessageBox::question(this,
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"),
QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel,
QMessageBox::Cancel);
if (answer != QMessageBox::Yes) return;
if (answer != QMessageBox::Yes){
return;
}
}
//Reload the element
m_elmt_scene -> reset();
if (opened_from_file)
if (opened_from_file) {
fromFile(filename_);
else
}
else {
fromLocation(location_);
}
}
/**
* @brief QETElementEditor::slot_save
@@ -1194,26 +1202,24 @@ void QETElementEditor::slot_reload()
* If the filepath or location is unknown, use save_as instead
* @return true if save with success
*/
bool QETElementEditor::slot_save()
{
bool QETElementEditor::slot_save() {
// Check element befor writing
if (checkElement())
{
if (checkElement()) {
//If we don't know the name of the current file, use save as instead
if (opened_from_file)
{
if (filename_.isEmpty())
if (opened_from_file) {
if (filename_.isEmpty()) {
return(slot_saveAsFile());
}
//Else wa save to the file at filename_ path
bool result_save = toFile(filename_);
if (result_save) m_elmt_scene -> undoStack().setClean();
return(result_save);
}
else
{
if (location_.isNull())
else {
if (location_.isNull()) {
return(slot_saveAs());
}
//Else save to the known location
bool result_save = toLocation(location_);
@@ -1235,19 +1241,17 @@ bool QETElementEditor::slot_save()
* to this location
* @return true if save with success
*/
bool QETElementEditor::slot_saveAs()
{
bool QETElementEditor::slot_saveAs() {
// Check element befor writing
if (checkElement())
{
if (checkElement()) {
//Ask a location to user
ElementsLocation location = ElementDialog::getSaveElementLocation(this);
if (location.isNull())
if (location.isNull()) {
return(false);
}
bool result_save = toLocation(location);
if (result_save)
{
if (result_save) {
setLocation(location);
m_elmt_scene -> undoStack().setClean();
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
* @return true if save with success
*/
bool QETElementEditor::slot_saveAsFile()
{
bool QETElementEditor::slot_saveAsFile() {
// Check element befor writing
if (checkElement())
{
if (checkElement()) {
//Ask a filename to user, for save the element
QString fn = QFileDialog::getSaveFileName(
this,
@@ -1280,17 +1282,18 @@ bool QETElementEditor::slot_saveAsFile()
)
);
if (fn.isEmpty())
if (fn.isEmpty()) {
return(false);
}
//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";
}
bool result_save = toFile(fn);
//If the save success, the filename is keep
if (result_save)
{
if (result_save) {
setFileName(fn);
QETApp::elementsRecentFiles() -> fileWasOpened(fn);
m_elmt_scene -> undoStack().setClean();
@@ -1309,7 +1312,9 @@ bool QETElementEditor::slot_saveAsFile()
l'utilisateur.
*/
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
QMessageBox::StandardButton answer = QET::QetMessageBox::question(
this,
@@ -1325,9 +1330,17 @@ bool QETElementEditor::canClose() {
);
bool result;
switch(answer) {
case QMessageBox::Cancel: result = false; 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
case QMessageBox::Cancel: {
result = false;
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);
}
@@ -1338,8 +1351,7 @@ bool QETElementEditor::canClose() {
@return le widget enleve, ou 0 s'il n'y avait pas de widget a enlever
*/
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);
previous_widget -> setParent(nullptr);
previous_widget -> hide();
@@ -1380,7 +1392,10 @@ void QETElementEditor::closeEvent(QCloseEvent *qce) {
setAttribute(Qt::WA_DeleteOnClose);
m_elmt_scene -> reset();
qce -> accept();
} else qce -> ignore();
}
else {
qce -> ignore();
}
}
/**
@@ -1415,7 +1430,8 @@ void QETElementEditor::slot_createPartsList() {
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 -> blockSignals(false);
@@ -1428,7 +1444,8 @@ void QETElementEditor::slot_updatePartsList() {
int items_count = m_elmt_scene -> items().count();
if (m_parts_list -> count() != items_count) {
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);
int i = 0;
QList<QGraphicsItem *> items = m_elmt_scene -> zItems();
@@ -1466,17 +1483,20 @@ void QETElementEditor::slot_updateSelectionFromPartsList() {
* @brief QETElementEditor::readSettings
* Read settings
*/
void QETElementEditor::readSettings()
{
void QETElementEditor::readSettings() {
QSettings settings;
// dimensions et position de la fenetre
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...)
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
m_elmt_scene -> setInformations(settings.value("elementeditor/default-informations", "").toString());
@@ -1486,8 +1506,7 @@ void QETElementEditor::readSettings()
* @brief QETElementEditor::writeSettings
* Write the settings
*/
void QETElementEditor::writeSettings()
{
void QETElementEditor::writeSettings() {
QSettings settings;
settings.setValue("elementeditor/geometry", saveGeometry());
settings.setValue("elementeditor/state", saveState());
@@ -1532,17 +1551,14 @@ QString QETElementEditor::getOpenElementFileName(QWidget *parent, const QString
* Location of the element to edit
* @param location
*/
void QETElementEditor::fromLocation(const ElementsLocation &location)
{
if (!location.isElement())
{
void QETElementEditor::fromLocation(const ElementsLocation &location) {
if (!location.isElement()) {
QET::QetMessageBox::critical(this,
tr("Élément inexistant.", "message box title"),
tr("Le chemin virtuel choisi ne correspond pas à un élément.", "message box content"));
return;
}
if (!location.exist())
{
if (!location.exist()) {
QET::QetMessageBox::critical(this,
tr("Élément inexistant.", "message box title"),
tr("L'élément n'existe pas.", "message box content"));
@@ -1559,8 +1575,7 @@ void QETElementEditor::fromLocation(const ElementsLocation &location)
slot_createPartsList();
//location is read only
if (!location.isWritable())
{
if (!location.isWritable()) {
QET::QetMessageBox::warning(this,
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"));
@@ -1581,7 +1596,9 @@ void QETElementEditor::fromLocation(const ElementsLocation &location)
void QETElementEditor::pasteFromFile() {
// demande le chemin du fichier a ouvrir a l'utilisateur
QString element_file_path = getOpenElementFileName(this);
if (element_file_path.isEmpty()) return;
if (element_file_path.isEmpty()) {
return;
}
QString error_message;
QDomDocument xml_document;
@@ -1589,7 +1606,8 @@ void QETElementEditor::pasteFromFile() {
// le fichier doit etre lisible
if (!element_file.open(QIODevice::ReadOnly)) {
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
if (!xml_document.setContent(&element_file)) {
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
* to the clipboard and call ElementView::PasteInArea
*/
void QETElementEditor::pasteFromElement()
{
void QETElementEditor::pasteFromElement() {
//Ask for a location
ElementsLocation location = ElementDialog::getOpenElementLocation(this);
if (location.isNull())
if (location.isNull()) {
return;
}
if (!location.isElement())
{
if (!location.isElement()) {
QET::QetMessageBox::critical(this,
tr("Élément inexistant.", "message box title"),
tr("Le chemin virtuel choisi ne correspond pas à un élément.", "message box content"));
return;
}
if (!location.exist())
{
if (!location.exist()) {
QET::QetMessageBox::critical(this,
tr("Élément inexistant.", "message box title"),
tr("L'élément n'existe pas.", "message box content"));
@@ -1644,7 +1660,9 @@ void QETElementEditor::pasteFromElement()
*/
void QETElementEditor::updateCurrentPartEditor() {
// 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
if (ElementItemEditor *current_editor = dynamic_cast<ElementItemEditor *>(m_tools_dock_stack -> widget(1))) {