diff --git a/conductor.cpp b/conductor.cpp index 7a1c14985..5d3a43a98 100644 --- a/conductor.cpp +++ b/conductor.cpp @@ -1074,7 +1074,7 @@ QList Conductor::junctions() const { // determine si le point est une bifurcation ou non bool is_bend = false; - Qt::Corner current_bend_type; + Qt::Corner current_bend_type = Qt::TopLeftCorner; foreach(ConductorBend cb, bends_list) { if (cb.first == point) { is_bend = true; diff --git a/diagramview.cpp b/diagramview.cpp index a692cb5fb..c0799b67d 100644 --- a/diagramview.cpp +++ b/diagramview.cpp @@ -242,7 +242,7 @@ void DiagramView::copy() { void DiagramView::paste() { QString texte_presse_papier; QDomDocument document_xml; - if ((texte_presse_papier = QApplication::clipboard() -> text()) == QString()) return; + if ((texte_presse_papier = QApplication::clipboard() -> text()).isEmpty()) return; if (!document_xml.setContent(texte_presse_papier)) return; // listes pour recupere les elements et conducteurs ajoutes au schema par le coller @@ -264,7 +264,7 @@ void DiagramView::mousePressEvent(QMouseEvent *e) { if (e -> buttons() == Qt::MidButton) { QString texte_presse_papier; QDomDocument document_xml; - if ((texte_presse_papier = QApplication::clipboard() -> text(QClipboard::Selection)) == QString()) return; + if ((texte_presse_papier = QApplication::clipboard() -> text(QClipboard::Selection)).isEmpty()) return; if (!document_xml.setContent(texte_presse_papier)) return; // listes pour recupere les elements et conducteurs ajoutes au schema par le coller @@ -369,7 +369,7 @@ void DiagramView::closeEvent(QCloseEvent *event) { @return true si l'enregistrement a reussi, false sinon */ bool DiagramView::save() { - if (file_name == QString()) return(saveAs()); + if (file_name.isEmpty()) return(saveAs()); else return(saveDiagramToFile(file_name)); } @@ -387,11 +387,11 @@ bool DiagramView::saveAs() { QString n_fichier = QFileDialog::getSaveFileName( this, tr("Enregistrer sous"), - QDir::homePath(), + (file_name.isEmpty() ? QDir::homePath() : QDir(file_name)).absolutePath(), tr("Sch\351ma QElectroTech (*.qet)") ); // si aucun nom n'est entre, renvoie faux. - if (n_fichier == "") return(false); + if (n_fichier.isEmpty()) return(false); // si le nom ne se termine pas par l'extension .qet, celle-ci est ajoutee if (!n_fichier.endsWith(".qet", Qt::CaseInsensitive)) n_fichier += ".qet"; // tente d'enregistrer le fichier @@ -465,7 +465,7 @@ void DiagramView::dialogPrint() { if (qpd.exec() == QDialog::Accepted) { QPainter qp(&qprin); // impression physique (!= fichier PDF) - if (qprin.outputFileName() == QString()) { + if (qprin.outputFileName().isEmpty()) { // lorsqu'on imprime en paysage sur imprimante reelle, il faut pivoter soi-meme le rendu if (qprin.orientation() == QPrinter::Landscape) { qp.rotate(90.0); diff --git a/editor/qetelementeditor.cpp b/editor/qetelementeditor.cpp index d367fb922..762d441d9 100644 --- a/editor/qetelementeditor.cpp +++ b/editor/qetelementeditor.cpp @@ -426,10 +426,10 @@ void QETElementEditor::slot_open() { QString user_filename = QFileDialog::getOpenFileName( this, tr("Ouvrir un fichier"), - QETApp::customElementsDir(), + _filename.isEmpty() ? QETApp::customElementsDir() : QDir(_filename).absolutePath(), tr("\311l\351ments QElectroTech (*.elmt);;Fichiers XML (*.xml);;Tous les fichiers (*)") ); - if (user_filename == "") return; + if (user_filename.isEmpty()) return; QETElementEditor *cee = new QETElementEditor(); cee -> fromFile(user_filename); cee -> show(); @@ -437,7 +437,7 @@ void QETElementEditor::slot_open() { bool QETElementEditor::slot_save() { // si on ne connait pas le nom du fichier en cours, enregistrer revient a enregistrer sous - if (_filename == QString()) return(slot_saveAs()); + if (_filename.isEmpty()) return(slot_saveAs()); // sinon on enregistre dans le nom de fichier connu bool result_save = toFile(_filename); if (result_save) ce_scene -> undoStack().setClean(); @@ -449,11 +449,11 @@ bool QETElementEditor::slot_saveAs() { QString fn = QFileDialog::getSaveFileName( this, tr("Enregistrer sous"), - QETApp::customElementsDir(), + _filename.isEmpty() ? QETApp::customElementsDir() : QDir(_filename).absolutePath(), tr("\311l\351ments QElectroTech (*.elmt)") ); // si aucun nom n'est entre, renvoie faux. - if (fn == "") return(false); + if (fn.isEmpty()) return(false); // si le nom ne se termine pas par l'extension .elmt, celle-ci est ajoutee if (!fn.endsWith(".elmt", Qt::CaseInsensitive)) fn += ".elmt"; // tente d'enregistrer le fichier diff --git a/elementspanel.cpp b/elementspanel.cpp index c95bdd560..db8033331 100644 --- a/elementspanel.cpp +++ b/elementspanel.cpp @@ -82,7 +82,7 @@ void ElementsPanel::dropEvent(QDropEvent */*e*/) { void ElementsPanel::startDrag(Qt::DropActions /*supportedActions*/) { // recupere le nom du fichier decrivant l'element QString nom_fichier = currentItem() -> data(0, 42).toString(); - if (nom_fichier == QString()) return; + if (nom_fichier.isEmpty()) return; // objet QDrag pour realiser le drag'n drop QDrag *drag = new QDrag(this); diff --git a/exportdialog.cpp b/exportdialog.cpp index 5a2588b9f..2807553fc 100644 --- a/exportdialog.cpp +++ b/exportdialog.cpp @@ -251,9 +251,8 @@ void ExportDialog::slot_chooseAFile() { QDir::homePath(), tr("Images (*.png *.bmp *.jpg *.svg)") ); - if (user_file != "") { - diagram_path = user_file; - filename -> setText(diagram_path); + if (!user_file.isEmpty()) { + filename -> setText(user_file); } } @@ -347,9 +346,10 @@ void ExportDialog::generateSvg(QFile &file) { dialogue. */ void ExportDialog::slot_check() { + QString diagram_path = filename -> text(); // verifie que le fichier a ete specifie - if (diagram_path == "") { + if (diagram_path.isEmpty()) { QMessageBox::information( this, tr("Fichier non sp\351cifi\351"), diff --git a/exportdialog.h b/exportdialog.h index ee311ae21..ef381a87c 100644 --- a/exportdialog.h +++ b/exportdialog.h @@ -45,7 +45,6 @@ class ExportDialog : public QDialog { // elements relatifs au traitement effectue par le dialogue Diagram *diagram; QSize diagram_size; - QString diagram_path; qreal diagram_ratio; QVector ColorTab; diff --git a/nameslistwidget.cpp b/nameslistwidget.cpp index 4d7ee33c8..87c3c5a45 100644 --- a/nameslistwidget.cpp +++ b/nameslistwidget.cpp @@ -74,8 +74,8 @@ void NamesListWidget::clean() { int names_count = tree_names -> topLevelItemCount() - 1; for (int i = names_count ; i >= 0 ; -- i) { if ( - tree_names -> topLevelItem(i) -> text(0) == QString() &&\ - tree_names -> topLevelItem(i) -> text(1) == QString() + tree_names -> topLevelItem(i) -> text(0).isEmpty() &&\ + tree_names -> topLevelItem(i) -> text(1).isEmpty() ) { tree_names -> takeTopLevelItem(i); } diff --git a/newelementwizard.cpp b/newelementwizard.cpp index 3def284a4..c596039ff 100644 --- a/newelementwizard.cpp +++ b/newelementwizard.cpp @@ -165,7 +165,7 @@ bool NewElementWizard::validStep2() { QString file_name = qle_filename -> text(); // un nom doit avoir ete entre - if (file_name == QString()) { + if (file_name.isEmpty()) { QMessageBox::critical( this, tr("Erreur"), diff --git a/qelectrotech.pro b/qelectrotech.pro index 57ff9931f..ce6aafdf2 100644 --- a/qelectrotech.pro +++ b/qelectrotech.pro @@ -132,7 +132,7 @@ RESOURCES += qelectrotech.qrc TRANSLATIONS += lang/qet_en.ts lang/qt_fr.ts RC_FILE = ico/windows_icon/application_icon/qelectrotech.rc QT += xml svg -CONFIG += debug_and_release +CONFIG += debug_and_release warn_on CONFIG(debug, debug|release) { TARGET = qelectrotech } else { diff --git a/qetdiagrameditor.cpp b/qetdiagrameditor.cpp index 277775a07..8b4a4fe8a 100644 --- a/qetdiagrameditor.cpp +++ b/qetdiagrameditor.cpp @@ -11,7 +11,7 @@ @param files Liste de fichiers a ouvrir @param parent le widget parent de la fenetre principale */ -QETDiagramEditor::QETDiagramEditor(const QStringList &files, QWidget *parent) : QMainWindow(parent) { +QETDiagramEditor::QETDiagramEditor(const QStringList &files, QWidget *parent) : QMainWindow(parent), open_dialog_dir(QDir::homePath()) { // cree les dossiers de configuration si necessaire QDir config_dir(QETApp::configDir()); @@ -528,11 +528,12 @@ bool QETDiagramEditor::openDiagram() { QString nom_fichier = QFileDialog::getOpenFileName( this, tr("Ouvrir un fichier"), - QDir::homePath(), + open_dialog_dir.absolutePath(), tr("Sch\351mas QElectroTech (*.qet);;Fichiers XML (*.xml);;Tous les fichiers (*)") ); - if (nom_fichier == "") return(false); + if (nom_fichier.isEmpty()) return(false); + open_dialog_dir = QDir(nom_fichier); // verifie que le fichier n'est pas deja ouvert QString chemin_fichier = QFileInfo(nom_fichier).canonicalFilePath(); foreach (QWidget *fenetre, workspace.windowList()) { diff --git a/qetdiagrameditor.h b/qetdiagrameditor.h index d4d24a5e5..9236dd1ab 100644 --- a/qetdiagrameditor.h +++ b/qetdiagrameditor.h @@ -119,6 +119,8 @@ class QETDiagramEditor : public QMainWindow { private: QWorkspace workspace; QSignalMapper windowMapper; + /// Dossier a utiliser pour Fichier > ouvrir + QDir open_dialog_dir; /// Dock pour le Panel d'Appareils QDockWidget *qdw_pa; /// Panel d'Appareils