mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-19 06:20:53 +01:00
Les dialogues pour ouvrir et enregistrer des fichiers gerent mieux le dossier a afficher par defaut
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@190 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -1074,7 +1074,7 @@ QList<QPointF> Conductor::junctions() const {
|
|||||||
|
|
||||||
// determine si le point est une bifurcation ou non
|
// determine si le point est une bifurcation ou non
|
||||||
bool is_bend = false;
|
bool is_bend = false;
|
||||||
Qt::Corner current_bend_type;
|
Qt::Corner current_bend_type = Qt::TopLeftCorner;
|
||||||
foreach(ConductorBend cb, bends_list) {
|
foreach(ConductorBend cb, bends_list) {
|
||||||
if (cb.first == point) {
|
if (cb.first == point) {
|
||||||
is_bend = true;
|
is_bend = true;
|
||||||
|
|||||||
@@ -242,7 +242,7 @@ void DiagramView::copy() {
|
|||||||
void DiagramView::paste() {
|
void DiagramView::paste() {
|
||||||
QString texte_presse_papier;
|
QString texte_presse_papier;
|
||||||
QDomDocument document_xml;
|
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;
|
if (!document_xml.setContent(texte_presse_papier)) return;
|
||||||
|
|
||||||
// listes pour recupere les elements et conducteurs ajoutes au schema par le coller
|
// 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) {
|
if (e -> buttons() == Qt::MidButton) {
|
||||||
QString texte_presse_papier;
|
QString texte_presse_papier;
|
||||||
QDomDocument document_xml;
|
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;
|
if (!document_xml.setContent(texte_presse_papier)) return;
|
||||||
|
|
||||||
// listes pour recupere les elements et conducteurs ajoutes au schema par le coller
|
// 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
|
@return true si l'enregistrement a reussi, false sinon
|
||||||
*/
|
*/
|
||||||
bool DiagramView::save() {
|
bool DiagramView::save() {
|
||||||
if (file_name == QString()) return(saveAs());
|
if (file_name.isEmpty()) return(saveAs());
|
||||||
else return(saveDiagramToFile(file_name));
|
else return(saveDiagramToFile(file_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -387,11 +387,11 @@ bool DiagramView::saveAs() {
|
|||||||
QString n_fichier = QFileDialog::getSaveFileName(
|
QString n_fichier = QFileDialog::getSaveFileName(
|
||||||
this,
|
this,
|
||||||
tr("Enregistrer sous"),
|
tr("Enregistrer sous"),
|
||||||
QDir::homePath(),
|
(file_name.isEmpty() ? QDir::homePath() : QDir(file_name)).absolutePath(),
|
||||||
tr("Sch\351ma QElectroTech (*.qet)")
|
tr("Sch\351ma QElectroTech (*.qet)")
|
||||||
);
|
);
|
||||||
// si aucun nom n'est entre, renvoie faux.
|
// 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
|
// 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";
|
if (!n_fichier.endsWith(".qet", Qt::CaseInsensitive)) n_fichier += ".qet";
|
||||||
// tente d'enregistrer le fichier
|
// tente d'enregistrer le fichier
|
||||||
@@ -465,7 +465,7 @@ void DiagramView::dialogPrint() {
|
|||||||
if (qpd.exec() == QDialog::Accepted) {
|
if (qpd.exec() == QDialog::Accepted) {
|
||||||
QPainter qp(&qprin);
|
QPainter qp(&qprin);
|
||||||
// impression physique (!= fichier PDF)
|
// 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
|
// lorsqu'on imprime en paysage sur imprimante reelle, il faut pivoter soi-meme le rendu
|
||||||
if (qprin.orientation() == QPrinter::Landscape) {
|
if (qprin.orientation() == QPrinter::Landscape) {
|
||||||
qp.rotate(90.0);
|
qp.rotate(90.0);
|
||||||
|
|||||||
@@ -426,10 +426,10 @@ void QETElementEditor::slot_open() {
|
|||||||
QString user_filename = QFileDialog::getOpenFileName(
|
QString user_filename = QFileDialog::getOpenFileName(
|
||||||
this,
|
this,
|
||||||
tr("Ouvrir un fichier"),
|
tr("Ouvrir un fichier"),
|
||||||
QETApp::customElementsDir(),
|
_filename.isEmpty() ? QETApp::customElementsDir() : QDir(_filename).absolutePath(),
|
||||||
tr("\311l\351ments QElectroTech (*.elmt);;Fichiers XML (*.xml);;Tous les fichiers (*)")
|
tr("\311l\351ments QElectroTech (*.elmt);;Fichiers XML (*.xml);;Tous les fichiers (*)")
|
||||||
);
|
);
|
||||||
if (user_filename == "") return;
|
if (user_filename.isEmpty()) return;
|
||||||
QETElementEditor *cee = new QETElementEditor();
|
QETElementEditor *cee = new QETElementEditor();
|
||||||
cee -> fromFile(user_filename);
|
cee -> fromFile(user_filename);
|
||||||
cee -> show();
|
cee -> show();
|
||||||
@@ -437,7 +437,7 @@ void QETElementEditor::slot_open() {
|
|||||||
|
|
||||||
bool QETElementEditor::slot_save() {
|
bool QETElementEditor::slot_save() {
|
||||||
// si on ne connait pas le nom du fichier en cours, enregistrer revient a enregistrer sous
|
// 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
|
// sinon on enregistre dans le nom de fichier connu
|
||||||
bool result_save = toFile(_filename);
|
bool result_save = toFile(_filename);
|
||||||
if (result_save) ce_scene -> undoStack().setClean();
|
if (result_save) ce_scene -> undoStack().setClean();
|
||||||
@@ -449,11 +449,11 @@ bool QETElementEditor::slot_saveAs() {
|
|||||||
QString fn = QFileDialog::getSaveFileName(
|
QString fn = QFileDialog::getSaveFileName(
|
||||||
this,
|
this,
|
||||||
tr("Enregistrer sous"),
|
tr("Enregistrer sous"),
|
||||||
QETApp::customElementsDir(),
|
_filename.isEmpty() ? QETApp::customElementsDir() : QDir(_filename).absolutePath(),
|
||||||
tr("\311l\351ments QElectroTech (*.elmt)")
|
tr("\311l\351ments QElectroTech (*.elmt)")
|
||||||
);
|
);
|
||||||
// si aucun nom n'est entre, renvoie faux.
|
// 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
|
// si le nom ne se termine pas par l'extension .elmt, celle-ci est ajoutee
|
||||||
if (!fn.endsWith(".elmt", Qt::CaseInsensitive)) fn += ".elmt";
|
if (!fn.endsWith(".elmt", Qt::CaseInsensitive)) fn += ".elmt";
|
||||||
// tente d'enregistrer le fichier
|
// tente d'enregistrer le fichier
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ void ElementsPanel::dropEvent(QDropEvent */*e*/) {
|
|||||||
void ElementsPanel::startDrag(Qt::DropActions /*supportedActions*/) {
|
void ElementsPanel::startDrag(Qt::DropActions /*supportedActions*/) {
|
||||||
// recupere le nom du fichier decrivant l'element
|
// recupere le nom du fichier decrivant l'element
|
||||||
QString nom_fichier = currentItem() -> data(0, 42).toString();
|
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
|
// objet QDrag pour realiser le drag'n drop
|
||||||
QDrag *drag = new QDrag(this);
|
QDrag *drag = new QDrag(this);
|
||||||
|
|||||||
@@ -251,9 +251,8 @@ void ExportDialog::slot_chooseAFile() {
|
|||||||
QDir::homePath(),
|
QDir::homePath(),
|
||||||
tr("Images (*.png *.bmp *.jpg *.svg)")
|
tr("Images (*.png *.bmp *.jpg *.svg)")
|
||||||
);
|
);
|
||||||
if (user_file != "") {
|
if (!user_file.isEmpty()) {
|
||||||
diagram_path = user_file;
|
filename -> setText(user_file);
|
||||||
filename -> setText(diagram_path);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -347,9 +346,10 @@ void ExportDialog::generateSvg(QFile &file) {
|
|||||||
dialogue.
|
dialogue.
|
||||||
*/
|
*/
|
||||||
void ExportDialog::slot_check() {
|
void ExportDialog::slot_check() {
|
||||||
|
QString diagram_path = filename -> text();
|
||||||
|
|
||||||
// verifie que le fichier a ete specifie
|
// verifie que le fichier a ete specifie
|
||||||
if (diagram_path == "") {
|
if (diagram_path.isEmpty()) {
|
||||||
QMessageBox::information(
|
QMessageBox::information(
|
||||||
this,
|
this,
|
||||||
tr("Fichier non sp\351cifi\351"),
|
tr("Fichier non sp\351cifi\351"),
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ class ExportDialog : public QDialog {
|
|||||||
// elements relatifs au traitement effectue par le dialogue
|
// elements relatifs au traitement effectue par le dialogue
|
||||||
Diagram *diagram;
|
Diagram *diagram;
|
||||||
QSize diagram_size;
|
QSize diagram_size;
|
||||||
QString diagram_path;
|
|
||||||
qreal diagram_ratio;
|
qreal diagram_ratio;
|
||||||
QVector<QRgb> ColorTab;
|
QVector<QRgb> ColorTab;
|
||||||
|
|
||||||
|
|||||||
@@ -74,8 +74,8 @@ void NamesListWidget::clean() {
|
|||||||
int names_count = tree_names -> topLevelItemCount() - 1;
|
int names_count = tree_names -> topLevelItemCount() - 1;
|
||||||
for (int i = names_count ; i >= 0 ; -- i) {
|
for (int i = names_count ; i >= 0 ; -- i) {
|
||||||
if (
|
if (
|
||||||
tree_names -> topLevelItem(i) -> text(0) == QString() &&\
|
tree_names -> topLevelItem(i) -> text(0).isEmpty() &&\
|
||||||
tree_names -> topLevelItem(i) -> text(1) == QString()
|
tree_names -> topLevelItem(i) -> text(1).isEmpty()
|
||||||
) {
|
) {
|
||||||
tree_names -> takeTopLevelItem(i);
|
tree_names -> takeTopLevelItem(i);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ bool NewElementWizard::validStep2() {
|
|||||||
QString file_name = qle_filename -> text();
|
QString file_name = qle_filename -> text();
|
||||||
|
|
||||||
// un nom doit avoir ete entre
|
// un nom doit avoir ete entre
|
||||||
if (file_name == QString()) {
|
if (file_name.isEmpty()) {
|
||||||
QMessageBox::critical(
|
QMessageBox::critical(
|
||||||
this,
|
this,
|
||||||
tr("Erreur"),
|
tr("Erreur"),
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ RESOURCES += qelectrotech.qrc
|
|||||||
TRANSLATIONS += lang/qet_en.ts lang/qt_fr.ts
|
TRANSLATIONS += lang/qet_en.ts lang/qt_fr.ts
|
||||||
RC_FILE = ico/windows_icon/application_icon/qelectrotech.rc
|
RC_FILE = ico/windows_icon/application_icon/qelectrotech.rc
|
||||||
QT += xml svg
|
QT += xml svg
|
||||||
CONFIG += debug_and_release
|
CONFIG += debug_and_release warn_on
|
||||||
CONFIG(debug, debug|release) {
|
CONFIG(debug, debug|release) {
|
||||||
TARGET = qelectrotech
|
TARGET = qelectrotech
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
@param files Liste de fichiers a ouvrir
|
@param files Liste de fichiers a ouvrir
|
||||||
@param parent le widget parent de la fenetre principale
|
@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
|
// cree les dossiers de configuration si necessaire
|
||||||
QDir config_dir(QETApp::configDir());
|
QDir config_dir(QETApp::configDir());
|
||||||
@@ -528,11 +528,12 @@ bool QETDiagramEditor::openDiagram() {
|
|||||||
QString nom_fichier = QFileDialog::getOpenFileName(
|
QString nom_fichier = QFileDialog::getOpenFileName(
|
||||||
this,
|
this,
|
||||||
tr("Ouvrir un fichier"),
|
tr("Ouvrir un fichier"),
|
||||||
QDir::homePath(),
|
open_dialog_dir.absolutePath(),
|
||||||
tr("Sch\351mas QElectroTech (*.qet);;Fichiers XML (*.xml);;Tous les fichiers (*)")
|
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
|
// verifie que le fichier n'est pas deja ouvert
|
||||||
QString chemin_fichier = QFileInfo(nom_fichier).canonicalFilePath();
|
QString chemin_fichier = QFileInfo(nom_fichier).canonicalFilePath();
|
||||||
foreach (QWidget *fenetre, workspace.windowList()) {
|
foreach (QWidget *fenetre, workspace.windowList()) {
|
||||||
|
|||||||
@@ -119,6 +119,8 @@ class QETDiagramEditor : public QMainWindow {
|
|||||||
private:
|
private:
|
||||||
QWorkspace workspace;
|
QWorkspace workspace;
|
||||||
QSignalMapper windowMapper;
|
QSignalMapper windowMapper;
|
||||||
|
/// Dossier a utiliser pour Fichier > ouvrir
|
||||||
|
QDir open_dialog_dir;
|
||||||
/// Dock pour le Panel d'Appareils
|
/// Dock pour le Panel d'Appareils
|
||||||
QDockWidget *qdw_pa;
|
QDockWidget *qdw_pa;
|
||||||
/// Panel d'Appareils
|
/// Panel d'Appareils
|
||||||
|
|||||||
Reference in New Issue
Block a user