mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-31 16:50:52 +01:00
Classes "Schema" et "SchemaVue" renommees en "Diagram" et "DiagramView"
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@44 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
271
qetapp.cpp
271
qetapp.cpp
@@ -1,10 +1,9 @@
|
||||
#include "qetapp.h"
|
||||
#include "schemavue.h"
|
||||
#include "schema.h"
|
||||
#include "diagramview.h"
|
||||
#include "diagram.h"
|
||||
#include "panelappareils.h"
|
||||
#include "aboutqet.h"
|
||||
#include "exportdialog.h"
|
||||
// #include "borderinset.h"
|
||||
|
||||
/**
|
||||
constructeur
|
||||
@@ -21,27 +20,27 @@ QETApp::QETApp(QWidget *parent) : QMainWindow(parent) {
|
||||
QStringList args = QCoreApplication::arguments();
|
||||
|
||||
// recupere les chemins de fichiers parmi les arguments
|
||||
QStringList fichiers;
|
||||
QStringList files;
|
||||
for (int i = 1 ; i < args.size() ; ++ i) {
|
||||
if (QFileInfo(args.at(i)).exists()) fichiers << args.at(i);
|
||||
if (QFileInfo(args.at(i)).exists()) files << args.at(i);
|
||||
}
|
||||
|
||||
// si des chemins de fichiers valides sont passes en arguments
|
||||
QList<SchemaVue *> schema_vues;
|
||||
if (fichiers.size()) {
|
||||
QList<DiagramView *> diagram_views;
|
||||
if (files.size()) {
|
||||
// alors on ouvre ces fichiers
|
||||
foreach(QString fichier, fichiers) {
|
||||
SchemaVue *sv = new SchemaVue(this);
|
||||
if (sv -> ouvrir(fichier)) schema_vues << sv;
|
||||
foreach(QString file, files) {
|
||||
DiagramView *sv = new DiagramView(this);
|
||||
if (sv -> ouvrir(file)) diagram_views << sv;
|
||||
else delete sv;
|
||||
}
|
||||
}
|
||||
|
||||
// si aucun schema n'a ete ouvert jusqu'a maintenant, on ouvre un nouveau schema
|
||||
if (!schema_vues.size()) schema_vues << new SchemaVue(this);
|
||||
if (!diagram_views.size()) diagram_views << new DiagramView(this);
|
||||
|
||||
// ajout de tous les SchemaVue necessaires
|
||||
foreach (SchemaVue *sv, schema_vues) addSchemaVue(sv);
|
||||
// ajout de tous les DiagramView necessaires
|
||||
foreach (DiagramView *sv, diagram_views) addDiagramView(sv);
|
||||
|
||||
// titre de la fenetre
|
||||
setWindowTitle(tr("QElectroTech"));
|
||||
@@ -75,7 +74,7 @@ QETApp::QETApp(QWidget *parent) : QMainWindow(parent) {
|
||||
qsti -> setToolTip(tr("QElectroTech"));
|
||||
connect(qsti, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(systray(QSystemTrayIcon::ActivationReason)));
|
||||
menu_systray = new QMenu(tr("QElectroTech"));
|
||||
menu_systray -> addAction(masquer_appli);
|
||||
menu_systray -> addAction(reduce_appli);
|
||||
menu_systray -> addAction(quitter_qet);
|
||||
qsti -> setContextMenu(menu_systray);
|
||||
qsti -> show();
|
||||
@@ -87,17 +86,17 @@ QETApp::QETApp(QWidget *parent) : QMainWindow(parent) {
|
||||
setWindowState(Qt::WindowMaximized);
|
||||
|
||||
// connexions signaux / slots pour une interface sensee
|
||||
connect(&workspace, SIGNAL(windowActivated(QWidget *)), this, SLOT(slot_updateActions()));
|
||||
connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(slot_updateActions()));
|
||||
connect(&workspace, SIGNAL(windowActivated(QWidget *)), this, SLOT(slot_updateActions()));
|
||||
connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(slot_updateActions()));
|
||||
}
|
||||
|
||||
/**
|
||||
Gere les evenements relatifs au QSystemTrayIcon
|
||||
@param raison un entier representant l'evenement survenu sur le systray
|
||||
*/
|
||||
void QETApp::systray(QSystemTrayIcon::ActivationReason raison) {
|
||||
void QETApp::systray(QSystemTrayIcon::ActivationReason reason) {
|
||||
if (!QSystemTrayIcon::isSystemTrayAvailable()) return;
|
||||
switch(raison) {
|
||||
switch(reason) {
|
||||
case QSystemTrayIcon::Context:
|
||||
// affichage du menu
|
||||
(qsti -> contextMenu()) -> show();
|
||||
@@ -105,7 +104,7 @@ void QETApp::systray(QSystemTrayIcon::ActivationReason raison) {
|
||||
case QSystemTrayIcon::DoubleClick:
|
||||
case QSystemTrayIcon::Trigger:
|
||||
// reduction ou restauration de l'application
|
||||
if (isVisible()) systrayReduire(); else systrayRestaurer();
|
||||
if (isVisible()) systrayReduce(); else systrayRestore();
|
||||
break;
|
||||
case QSystemTrayIcon::Unknown:
|
||||
default: // ne rien faire
|
||||
@@ -116,27 +115,27 @@ void QETApp::systray(QSystemTrayIcon::ActivationReason raison) {
|
||||
/**
|
||||
Reduit l'application dans le systray
|
||||
*/
|
||||
void QETApp::systrayReduire() {
|
||||
void QETApp::systrayReduce() {
|
||||
// on sauvegarde la position et les dimensions de l'application
|
||||
wg = saveGeometry();
|
||||
// on cache l'application
|
||||
hide();
|
||||
// on ajoute le menu "Restaurer" et on enlève le menu "Masquer"
|
||||
menu_systray -> insertAction(masquer_appli, restaurer_appli);
|
||||
menu_systray -> removeAction(masquer_appli);
|
||||
// on ajoute le menu "Restaurer" et on enleve le menu "Masquer"
|
||||
menu_systray -> insertAction(reduce_appli, restore_appli);
|
||||
menu_systray -> removeAction(reduce_appli);
|
||||
}
|
||||
|
||||
/**
|
||||
Restaure l'application reduite dans le systray
|
||||
*/
|
||||
void QETApp::systrayRestaurer() {
|
||||
void QETApp::systrayRestore() {
|
||||
// on restaure la position et les dimensions de l'application
|
||||
restoreGeometry(wg);
|
||||
// on affiche l'application
|
||||
show();
|
||||
// on ajoute le menu "Masquer" et on enlève le menu "Restaurer"
|
||||
menu_systray -> insertAction(restaurer_appli, masquer_appli);
|
||||
menu_systray -> removeAction(restaurer_appli);
|
||||
// on ajoute le menu "Masquer" et on enleve le menu "Restaurer"
|
||||
menu_systray -> insertAction(restore_appli, reduce_appli);
|
||||
menu_systray -> removeAction(restore_appli);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,20 +143,20 @@ void QETApp::systrayRestaurer() {
|
||||
@param qce Le QCloseEvent correspondant a l'evenement de fermeture
|
||||
*/
|
||||
void QETApp::closeEvent(QCloseEvent *qce) {
|
||||
quitter(qce);
|
||||
quit(qce);
|
||||
}
|
||||
|
||||
/**
|
||||
Gere la sortie de l'application
|
||||
@param e Le QCloseEvent correspondant a l'evenement de fermeture
|
||||
*/
|
||||
void QETApp::quitter(QCloseEvent *e) {
|
||||
void QETApp::quit(QCloseEvent *e) {
|
||||
// quitte directement s'il n'y a aucun schema ouvert
|
||||
bool peut_quitter = true;
|
||||
if (schemaEnCours()) {
|
||||
if (diagramEnCours()) {
|
||||
// sinon demande la permission de fermer chaque schema
|
||||
foreach(QWidget *fenetre, workspace.windowList()) {
|
||||
if (qobject_cast<SchemaVue *>(fenetre)) {
|
||||
if (qobject_cast<DiagramView *>(fenetre)) {
|
||||
workspace.setActiveWindow(fenetre);
|
||||
if (!fermer()) {
|
||||
peut_quitter = false;
|
||||
@@ -181,10 +180,10 @@ void QETApp::toggleFullScreen() {
|
||||
}
|
||||
|
||||
/**
|
||||
Active ou desactive l'antialiasing sur le rendu graphique du Schema
|
||||
Active ou desactive l'antialiasing sur le rendu graphique du Diagram
|
||||
*/
|
||||
void QETApp::toggleAntialiasing() {
|
||||
SchemaVue *sv = schemaEnCours();
|
||||
DiagramView *sv = diagramEnCours();
|
||||
if (!sv) return;
|
||||
sv -> setAntialiasing(!sv -> antialiased());
|
||||
toggle_aa -> setText(sv -> antialiased() ? tr("D\351sactiver l'&antialiasing") : tr("Activer l'&antialiasing"));
|
||||
@@ -207,58 +206,58 @@ void QETApp::aPropos() {
|
||||
*/
|
||||
void QETApp::actions() {
|
||||
// icones et labels
|
||||
nouveau_fichier = new QAction(QIcon(":/ico/new.png"), tr("&Nouveau"), this);
|
||||
ouvrir_fichier = new QAction(QIcon(":/ico/open.png"), tr("&Ouvrir"), this);
|
||||
fermer_fichier = new QAction(QIcon(":/ico/fileclose.png"), tr("&Fermer"), this);
|
||||
enr_fichier = new QAction(QIcon(":/ico/save.png"), tr("&Enregistrer"), this);
|
||||
enr_fichier_sous = new QAction(QIcon(":/ico/saveas.png"), tr("Enregistrer sous"), this);
|
||||
importer = new QAction(QIcon(":/ico/import.png"), tr("&Importer"), this);
|
||||
exporter = new QAction(QIcon(":/ico/export.png"), tr("E&xporter"), this);
|
||||
imprimer = new QAction(QIcon(":/ico/print.png"), tr("Imprimer"), this);
|
||||
quitter_qet = new QAction(QIcon(":/ico/exit.png"), tr("&Quitter"), this);
|
||||
nouveau_fichier = new QAction(QIcon(":/ico/new.png"), tr("&Nouveau"), this);
|
||||
ouvrir_fichier = new QAction(QIcon(":/ico/open.png"), tr("&Ouvrir"), this);
|
||||
fermer_fichier = new QAction(QIcon(":/ico/fileclose.png"), tr("&Fermer"), this);
|
||||
enr_fichier = new QAction(QIcon(":/ico/save.png"), tr("&Enregistrer"), this);
|
||||
enr_fichier_sous = new QAction(QIcon(":/ico/saveas.png"), tr("Enregistrer sous"), this);
|
||||
importer = new QAction(QIcon(":/ico/import.png"), tr("&Importer"), this);
|
||||
exporter = new QAction(QIcon(":/ico/export.png"), tr("E&xporter"), this);
|
||||
imprimer = new QAction(QIcon(":/ico/print.png"), tr("Imprimer"), this);
|
||||
quitter_qet = new QAction(QIcon(":/ico/exit.png"), tr("&Quitter"), this);
|
||||
|
||||
annuler = new QAction(QIcon(":/ico/undo.png"), tr("Annu&ler"), this);
|
||||
refaire = new QAction(QIcon(":/ico/redo.png"), tr("Re&faire"), this);
|
||||
couper = new QAction(QIcon(":/ico/cut.png"), tr("Co&uper"), this);
|
||||
copier = new QAction(QIcon(":/ico/copy.png"), tr("Cop&ier"), this);
|
||||
coller = new QAction(QIcon(":/ico/paste.png"), tr("C&oller"), this);
|
||||
sel_tout = new QAction( tr("Tout s\351lectionner"), this);
|
||||
sel_rien = new QAction( tr("D\351s\351lectionner tout"), this);
|
||||
sel_inverse = new QAction( tr("Inverser la s\351lection"), this);
|
||||
supprimer = new QAction(QIcon(":/ico/delete.png"), tr("Supprimer"), this);
|
||||
pivoter = new QAction(QIcon(":/ico/pivoter.png"), tr("Pivoter"), this);
|
||||
infos_schema = new QAction(QIcon(":/ico/info.png"), tr("Informations sur le sch\351ma"), this);
|
||||
add_column = new QAction( tr("Ajouter une colonne"), this);
|
||||
remove_column = new QAction( tr("Enlever une colonne"), this);
|
||||
annuler = new QAction(QIcon(":/ico/undo.png"), tr("Annu&ler"), this);
|
||||
refaire = new QAction(QIcon(":/ico/redo.png"), tr("Re&faire"), this);
|
||||
couper = new QAction(QIcon(":/ico/cut.png"), tr("Co&uper"), this);
|
||||
copier = new QAction(QIcon(":/ico/copy.png"), tr("Cop&ier"), this);
|
||||
coller = new QAction(QIcon(":/ico/paste.png"), tr("C&oller"), this);
|
||||
sel_tout = new QAction( tr("Tout s\351lectionner"), this);
|
||||
sel_rien = new QAction( tr("D\351s\351lectionner tout"), this);
|
||||
sel_inverse = new QAction( tr("Inverser la s\351lection"), this);
|
||||
supprimer = new QAction(QIcon(":/ico/delete.png"), tr("Supprimer"), this);
|
||||
pivoter = new QAction(QIcon(":/ico/pivoter.png"), tr("Pivoter"), this);
|
||||
infos_diagram = new QAction(QIcon(":/ico/info.png"), tr("Informations sur le sch\351ma"), this);
|
||||
add_column = new QAction( tr("Ajouter une colonne"), this);
|
||||
remove_column = new QAction( tr("Enlever une colonne"), this);
|
||||
|
||||
toggle_aa = new QAction( tr("D\351sactiver l'&antialiasing"), this);
|
||||
zoom_avant = new QAction(QIcon(":/ico/viewmag+.png"), tr("Zoom avant"), this);
|
||||
zoom_arriere = new QAction(QIcon(":/ico/viewmag-.png"), tr("Zoom arri\350re"), this);
|
||||
zoom_adapte = new QAction(QIcon(":/ico/viewmagfit.png"), tr("Zoom adapt\351"), this);
|
||||
zoom_reset = new QAction(QIcon(":/ico/viewmag.png"), tr("Pas de zoom"), this);
|
||||
toggle_aa = new QAction( tr("D\351sactiver l'&antialiasing"), this);
|
||||
zoom_avant = new QAction(QIcon(":/ico/viewmag+.png"), tr("Zoom avant"), this);
|
||||
zoom_arriere = new QAction(QIcon(":/ico/viewmag-.png"), tr("Zoom arri\350re"), this);
|
||||
zoom_adapte = new QAction(QIcon(":/ico/viewmagfit.png"), tr("Zoom adapt\351"), this);
|
||||
zoom_reset = new QAction(QIcon(":/ico/viewmag.png"), tr("Pas de zoom"), this);
|
||||
|
||||
mode_selection = new QAction(QIcon(":/ico/select.png"), tr("Mode Selection"), this);
|
||||
mode_visualise = new QAction(QIcon(":/ico/move.png"), tr("Mode Visualisation"), this);
|
||||
mode_selection = new QAction(QIcon(":/ico/select.png"), tr("Mode Selection"), this);
|
||||
mode_visualise = new QAction(QIcon(":/ico/move.png"), tr("Mode Visualisation"), this);
|
||||
|
||||
entrer_pe = new QAction(QIcon(":/ico/entrer_fs.png"), tr("Passer en &mode plein \351cran"), this);
|
||||
sortir_pe = new QAction(QIcon(":/ico/sortir_fs.png"), tr("Sortir du &mode plein \351cran"), this);
|
||||
configurer = new QAction(QIcon(":/ico/configure.png"), tr("&Configurer QElectroTech"), this);
|
||||
entrer_pe = new QAction(QIcon(":/ico/entrer_fs.png"), tr("Passer en &mode plein \351cran"), this);
|
||||
sortir_pe = new QAction(QIcon(":/ico/sortir_fs.png"), tr("Sortir du &mode plein \351cran"), this);
|
||||
configurer = new QAction(QIcon(":/ico/configure.png"), tr("&Configurer QElectroTech"), this);
|
||||
|
||||
f_mosaique = new QAction( tr("&Mosa\357que"), this);
|
||||
f_cascade = new QAction( tr("&Cascade"), this);
|
||||
f_reorganise = new QAction( tr("Arranger les fen\352tres réduites"),this);
|
||||
f_suiv = new QAction( tr("Fen\352tre suivante"), this);
|
||||
f_prec = new QAction( tr("Fen\352tre pr\351c\351dente"), this);
|
||||
f_mosaique = new QAction( tr("&Mosa\357que"), this);
|
||||
f_cascade = new QAction( tr("&Cascade"), this);
|
||||
f_reorganise = new QAction( tr("Arranger les fen\352tres r\351duites"), this);
|
||||
f_suiv = new QAction( tr("Fen\352tre suivante"), this);
|
||||
f_prec = new QAction( tr("Fen\352tre pr\351c\351dente"), this);
|
||||
|
||||
a_propos_de_qet = new QAction(QIcon(":/ico/qet.png"), tr("\300 &propos de QElectroTech"), this);
|
||||
a_propos_de_qt = new QAction(QIcon(":/ico/qt.png"), tr("\300 propos de &Qt"), this);
|
||||
a_propos_de_qet = new QAction(QIcon(":/ico/qet.png"), tr("\300 &propos de QElectroTech"), this);
|
||||
a_propos_de_qt = new QAction(QIcon(":/ico/qt.png"), tr("\300 propos de &Qt"), this);
|
||||
|
||||
masquer_appli = new QAction(QIcon(":/ico/masquer.png"), tr("&Masquer"), this);
|
||||
restaurer_appli = new QAction(QIcon(":/ico/restaurer.png"), tr("&Restaurer"), this);
|
||||
reduce_appli = new QAction(QIcon(":/ico/masquer.png"), tr("&Masquer"), this);
|
||||
restore_appli = new QAction(QIcon(":/ico/restaurer.png"), tr("&Restaurer"), this);
|
||||
|
||||
// info-bulles
|
||||
masquer_appli -> setToolTip(tr("Reduire QElectroTech dans le systray"));
|
||||
restaurer_appli -> setToolTip(tr("Restaurer QElectroTech"));
|
||||
reduce_appli -> setToolTip(tr("Reduire QElectroTech dans le systray"));
|
||||
restore_appli -> setToolTip(tr("Restaurer QElectroTech"));
|
||||
|
||||
// raccourcis clavier
|
||||
nouveau_fichier -> setShortcut(QKeySequence::New);
|
||||
@@ -310,7 +309,7 @@ void QETApp::actions() {
|
||||
sel_inverse -> setStatusTip(tr("D\351s\351lectionne les \351l\351ments s\351lectionn\351s et s\351lectionne les \351l\351ments non s\351lectionn\351s"));
|
||||
supprimer -> setStatusTip(tr("Enl\350ve les \351l\351ments s\351lectionn\351s du sch\351ma"));
|
||||
pivoter -> setStatusTip(tr("Pivote les \351l\351ments s\351lectionn\351s"));
|
||||
infos_schema -> setStatusTip(tr("\311dite les informations affich\351es par le cartouche"));
|
||||
infos_diagram -> setStatusTip(tr("\311dite les informations affich\351es par le cartouche"));
|
||||
add_column -> setStatusTip(tr("Ajoute une colonne au sch\351ma"));
|
||||
remove_column -> setStatusTip(tr("Enl\350ve une colonne au sch\351ma"));
|
||||
|
||||
@@ -329,7 +328,7 @@ void QETApp::actions() {
|
||||
|
||||
f_mosaique -> setStatusTip(tr("Dispose les fen\352tres en mosa\357que"));
|
||||
f_cascade -> setStatusTip(tr("Dispose les fen\352tres en cascade"));
|
||||
f_reorganise -> setStatusTip(tr("Aligne les fen\352tres réduites"));
|
||||
f_reorganise -> setStatusTip(tr("Aligne les fen\352tres r\351duites"));
|
||||
f_suiv -> setStatusTip(tr("Active la fen\352tre suivante"));
|
||||
f_prec -> setStatusTip(tr("Active la fen\352tre pr\351c\351dente"));
|
||||
|
||||
@@ -347,7 +346,7 @@ void QETApp::actions() {
|
||||
grp_visu_sel -> setExclusive(true);
|
||||
|
||||
// connexion a des slots
|
||||
connect(quitter_qet, SIGNAL(triggered()), this, SLOT(quitter()) );
|
||||
connect(quitter_qet, SIGNAL(triggered()), this, SLOT(quit()) );
|
||||
connect(sel_tout, SIGNAL(triggered()), this, SLOT(slot_selectAll()) );
|
||||
connect(sel_rien, SIGNAL(triggered()), this, SLOT(slot_selectNothing()) );
|
||||
connect(sel_inverse, SIGNAL(triggered()), this, SLOT(slot_selectInvert()) );
|
||||
@@ -359,8 +358,8 @@ void QETApp::actions() {
|
||||
connect(mode_visualise, SIGNAL(triggered()), this, SLOT(slot_setVisualisationMode()));
|
||||
connect(a_propos_de_qet, SIGNAL(triggered()), this, SLOT(aPropos()) );
|
||||
connect(a_propos_de_qt, SIGNAL(triggered()), qApp, SLOT(aboutQt()) );
|
||||
connect(masquer_appli, SIGNAL(triggered()), this, SLOT(systrayReduire ()) );
|
||||
connect(restaurer_appli, SIGNAL(triggered()), this, SLOT(systrayRestaurer()) );
|
||||
connect(reduce_appli, SIGNAL(triggered()), this, SLOT(systrayReduce()) );
|
||||
connect(restore_appli, SIGNAL(triggered()), this, SLOT(systrayRestore()) );
|
||||
connect(zoom_avant, SIGNAL(triggered()), this, SLOT(slot_zoomPlus()) );
|
||||
connect(zoom_arriere, SIGNAL(triggered()), this, SLOT(slot_zoomMoins()) );
|
||||
connect(zoom_adapte, SIGNAL(triggered()), this, SLOT(slot_zoomFit()) );
|
||||
@@ -381,7 +380,7 @@ void QETApp::actions() {
|
||||
connect(f_reorganise, SIGNAL(triggered()), &workspace, SLOT(arrangeIcons()) );
|
||||
connect(f_suiv, SIGNAL(triggered()), &workspace, SLOT(activateNextWindow()) );
|
||||
connect(f_prec, SIGNAL(triggered()), &workspace, SLOT(activatePreviousWindow()) );
|
||||
connect(infos_schema, SIGNAL(activated()), this, SLOT(editInfos()) );
|
||||
connect(infos_diagram, SIGNAL(activated()), this, SLOT(editInfos()) );
|
||||
connect(add_column, SIGNAL(activated()), this, SLOT(slot_addColumn()) );
|
||||
connect(remove_column, SIGNAL(activated()), this, SLOT(slot_removeColumn()) );
|
||||
}
|
||||
@@ -435,7 +434,7 @@ void QETApp::menus() {
|
||||
menu_edition -> addAction(supprimer);
|
||||
menu_edition -> addAction(pivoter);
|
||||
menu_edition -> addSeparator();
|
||||
menu_edition -> addAction(infos_schema);
|
||||
menu_edition -> addAction(infos_diagram);
|
||||
menu_edition -> addAction(add_column);
|
||||
menu_edition -> addAction(remove_column);
|
||||
|
||||
@@ -465,7 +464,7 @@ void QETApp::menus() {
|
||||
menu_config -> addAction(entrer_pe);
|
||||
menu_config -> addAction(configurer);
|
||||
|
||||
// menu Fenêtres
|
||||
// menu Fenetres
|
||||
slot_updateMenuFenetres();
|
||||
|
||||
// menu Aide
|
||||
@@ -514,7 +513,7 @@ void QETApp::dialogue_imprimer() {
|
||||
|
||||
if (qpd.exec() == QDialog::Accepted) {
|
||||
QPainter qp(&qprin);
|
||||
Schema *sc = schemaEnCours() -> scene;
|
||||
Diagram *sc = diagramEnCours() -> scene;
|
||||
sc -> setAffichageGrille(false);
|
||||
sc -> render(&qp);
|
||||
sc -> setAffichageGrille(true);
|
||||
@@ -525,7 +524,7 @@ void QETApp::dialogue_imprimer() {
|
||||
Gere l'export de schema vers un autre format (PNG pour le moment)
|
||||
*/
|
||||
void QETApp::dialogue_exporter() {
|
||||
Schema *sc = schemaEnCours() -> scene;
|
||||
Diagram *sc = diagramEnCours() -> scene;
|
||||
ExportDialog ed(*sc);
|
||||
ed.exec();
|
||||
}
|
||||
@@ -536,8 +535,8 @@ void QETApp::dialogue_exporter() {
|
||||
@return true si l'enregistrement a reussi, false sinon
|
||||
*/
|
||||
bool QETApp::enregistrer() {
|
||||
if (!schemaEnCours()) return(false);
|
||||
return(schemaEnCours() -> enregistrer());
|
||||
if (!diagramEnCours()) return(false);
|
||||
return(diagramEnCours() -> enregistrer());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -550,8 +549,8 @@ bool QETApp::enregistrer() {
|
||||
@todo detecter le chemin du bureau automatiquement
|
||||
*/
|
||||
bool QETApp::dialogue_enregistrer_sous() {
|
||||
if (!schemaEnCours()) return(false);
|
||||
return(schemaEnCours() -> enregistrer_sous());
|
||||
if (!diagramEnCours()) return(false);
|
||||
return(diagramEnCours() -> enregistrer_sous());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -559,7 +558,7 @@ bool QETApp::dialogue_enregistrer_sous() {
|
||||
@return true si tout s'est bien passe ; false si vous executez cette fonction dans un univers non cartesien (en fait y'a pas de return(false) :p)
|
||||
*/
|
||||
bool QETApp::nouveau() {
|
||||
addSchemaVue(new SchemaVue(this));
|
||||
addDiagramView(new DiagramView(this));
|
||||
return(true);
|
||||
}
|
||||
|
||||
@@ -573,14 +572,14 @@ bool QETApp::ouvrir() {
|
||||
this,
|
||||
tr("Ouvrir un fichier"),
|
||||
QDir::homePath(),
|
||||
tr("Schema QelectroTech (*.qet);;Fichiers XML (*.xml);;Tous les fichiers (*)")
|
||||
tr("Diagram QelectroTech (*.qet);;Fichiers XML (*.xml);;Tous les fichiers (*)")
|
||||
);
|
||||
if (nom_fichier == "") return(false);
|
||||
|
||||
// verifie que le fichier n'est pas deja ouvert
|
||||
QString chemin_fichier = QFileInfo(nom_fichier).canonicalFilePath();
|
||||
foreach (QWidget *fenetre, workspace.windowList()) {
|
||||
SchemaVue *fenetre_en_cours = qobject_cast<SchemaVue *>(fenetre);
|
||||
DiagramView *fenetre_en_cours = qobject_cast<DiagramView *>(fenetre);
|
||||
if (QFileInfo(fenetre_en_cours -> nom_fichier).canonicalFilePath() == chemin_fichier) {
|
||||
workspace.setActiveWindow(fenetre);
|
||||
return(false);
|
||||
@@ -588,10 +587,10 @@ bool QETApp::ouvrir() {
|
||||
}
|
||||
|
||||
// ouvre le fichier
|
||||
SchemaVue *sv = new SchemaVue(this);
|
||||
DiagramView *sv = new DiagramView(this);
|
||||
int code_erreur;
|
||||
if (sv -> ouvrir(nom_fichier, &code_erreur)) {
|
||||
addSchemaVue(sv);
|
||||
addDiagramView(sv);
|
||||
return(true);
|
||||
} else {
|
||||
QString message_erreur;
|
||||
@@ -613,123 +612,123 @@ bool QETApp::ouvrir() {
|
||||
@todo detecter les modifications et ne demander que si besoin est
|
||||
*/
|
||||
bool QETApp::fermer() {
|
||||
SchemaVue *sv = schemaEnCours();
|
||||
DiagramView *sv = diagramEnCours();
|
||||
if (!sv) return(false);
|
||||
bool fermeture_schema = sv -> close();
|
||||
if (fermeture_schema) delete sv;
|
||||
return(fermeture_schema);
|
||||
bool fermeture_diagram = sv -> close();
|
||||
if (fermeture_diagram) delete sv;
|
||||
return(fermeture_diagram);
|
||||
}
|
||||
|
||||
/**
|
||||
@return Le SchemaVue qui a le focus dans l'interface MDI
|
||||
@return Le DiagramView qui a le focus dans l'interface MDI
|
||||
*/
|
||||
SchemaVue *QETApp::schemaEnCours() {
|
||||
return(qobject_cast<SchemaVue *>(workspace.activeWindow()));
|
||||
DiagramView *QETApp::diagramEnCours() {
|
||||
return(qobject_cast<DiagramView *>(workspace.activeWindow()));
|
||||
}
|
||||
|
||||
/**
|
||||
Effectue l'action "couper" sur le schema en cours
|
||||
*/
|
||||
void QETApp::slot_couper() {
|
||||
if(schemaEnCours()) schemaEnCours() -> couper();
|
||||
if(diagramEnCours()) diagramEnCours() -> couper();
|
||||
}
|
||||
|
||||
/**
|
||||
Effectue l'action "copier" sur le schema en cours
|
||||
Effectue l'action "copier" sur le diagram en cours
|
||||
*/
|
||||
void QETApp::slot_copier() {
|
||||
if(schemaEnCours()) schemaEnCours() -> copier();
|
||||
if(diagramEnCours()) diagramEnCours() -> copier();
|
||||
}
|
||||
|
||||
/**
|
||||
Effectue l'action "coller" sur le schema en cours
|
||||
*/
|
||||
void QETApp::slot_coller() {
|
||||
if(schemaEnCours()) schemaEnCours() -> coller();
|
||||
if(diagramEnCours()) diagramEnCours() -> coller();
|
||||
}
|
||||
|
||||
/**
|
||||
Effectue l'action "zoom avant" sur le schema en cours
|
||||
Effectue l'action "zoom avant" sur le diagram en cours
|
||||
*/
|
||||
void QETApp::slot_zoomPlus() {
|
||||
if(schemaEnCours()) schemaEnCours() -> zoomPlus();
|
||||
if(diagramEnCours()) diagramEnCours() -> zoomPlus();
|
||||
}
|
||||
|
||||
/**
|
||||
Effectue l'action "zoom arriere" sur le schema en cours
|
||||
*/
|
||||
void QETApp::slot_zoomMoins() {
|
||||
if(schemaEnCours()) schemaEnCours() -> zoomMoins();
|
||||
if(diagramEnCours()) diagramEnCours() -> zoomMoins();
|
||||
}
|
||||
|
||||
/**
|
||||
Effectue l'action "zoom arriere" sur le schema en cours
|
||||
Effectue l'action "zoom arriere" sur le diagram en cours
|
||||
*/
|
||||
void QETApp::slot_zoomFit() {
|
||||
if(schemaEnCours()) schemaEnCours() -> zoomFit();
|
||||
if(diagramEnCours()) diagramEnCours() -> zoomFit();
|
||||
}
|
||||
|
||||
/**
|
||||
Effectue l'action "zoom par defaut" sur le schema en cours
|
||||
*/
|
||||
void QETApp::slot_zoomReset() {
|
||||
if(schemaEnCours()) schemaEnCours() -> zoomReset();
|
||||
if(diagramEnCours()) diagramEnCours() -> zoomReset();
|
||||
}
|
||||
|
||||
/**
|
||||
Effectue l'action "selectionner tout" sur le schema en cours
|
||||
*/
|
||||
void QETApp::slot_selectAll() {
|
||||
if(schemaEnCours()) schemaEnCours() -> selectAll();
|
||||
if(diagramEnCours()) diagramEnCours() -> selectAll();
|
||||
}
|
||||
|
||||
/**
|
||||
Effectue l'action "deselectionenr tout" sur le schema en cours
|
||||
*/
|
||||
void QETApp::slot_selectNothing() {
|
||||
if(schemaEnCours()) schemaEnCours() -> selectNothing();
|
||||
if(diagramEnCours()) diagramEnCours() -> selectNothing();
|
||||
}
|
||||
|
||||
/**
|
||||
Effectue l'action "inverser la selection" sur le schema en cours
|
||||
*/
|
||||
void QETApp::slot_selectInvert() {
|
||||
if(schemaEnCours()) schemaEnCours() -> selectInvert();
|
||||
if(diagramEnCours()) diagramEnCours() -> selectInvert();
|
||||
}
|
||||
|
||||
/**
|
||||
Effectue l'action "supprimer" sur le schema en cours
|
||||
*/
|
||||
void QETApp::slot_supprimer() {
|
||||
if(schemaEnCours()) schemaEnCours() -> supprimer();
|
||||
if(diagramEnCours()) diagramEnCours() -> supprimer();
|
||||
}
|
||||
|
||||
/**
|
||||
Effectue l'action "pivoter" sur le schema en cours
|
||||
*/
|
||||
void QETApp::slot_pivoter() {
|
||||
if(schemaEnCours()) schemaEnCours() -> pivoter();
|
||||
if(diagramEnCours()) diagramEnCours() -> pivoter();
|
||||
}
|
||||
|
||||
/**
|
||||
Effectue l'action "mode selection" sur le schema en cours
|
||||
*/
|
||||
void QETApp::slot_setSelectionMode() {
|
||||
if(schemaEnCours()) schemaEnCours() -> setSelectionMode();
|
||||
if(diagramEnCours()) diagramEnCours() -> setSelectionMode();
|
||||
}
|
||||
|
||||
/**
|
||||
Effectue l'action "mode visualisation" sur le schema en cours
|
||||
*/
|
||||
void QETApp::slot_setVisualisationMode() {
|
||||
if(schemaEnCours()) schemaEnCours() -> setVisualisationMode();
|
||||
if(diagramEnCours()) diagramEnCours() -> setVisualisationMode();
|
||||
}
|
||||
|
||||
/**
|
||||
gere les actions ayant besoin d'un document ouvert
|
||||
*/
|
||||
void QETApp::slot_updateActions() {
|
||||
SchemaVue *sv = schemaEnCours();
|
||||
DiagramView *sv = diagramEnCours();
|
||||
bool document_ouvert = (sv != 0);
|
||||
|
||||
// actions ayant juste besoin d'un document ouvert
|
||||
@@ -747,7 +746,7 @@ void QETApp::slot_updateActions() {
|
||||
zoom_adapte -> setEnabled(document_ouvert);
|
||||
zoom_reset -> setEnabled(document_ouvert);
|
||||
toggle_aa -> setEnabled(document_ouvert);
|
||||
infos_schema -> setEnabled(document_ouvert);
|
||||
infos_diagram -> setEnabled(document_ouvert);
|
||||
|
||||
// actions ayant aussi besoin d'un historique des actions
|
||||
annuler -> setEnabled(document_ouvert);
|
||||
@@ -797,15 +796,21 @@ void QETApp::slot_updateActions() {
|
||||
|
||||
/**
|
||||
Ajoute un schema dans l'espace de travail
|
||||
@param sv L'objet SchemaVue a ajouter a l'espace de travail
|
||||
@param sv L'objet DiagramView a ajouter a l'espace de travail
|
||||
*/
|
||||
void QETApp::addSchemaVue(SchemaVue *sv) {
|
||||
void QETApp::addDiagramView(DiagramView *sv) {
|
||||
if (!sv) return;
|
||||
SchemaVue *s_v = schemaEnCours();
|
||||
|
||||
// on maximise la nouvelle fenetre si la fenetre en cours est inexistante ou bien maximisee
|
||||
DiagramView *s_v = diagramEnCours();
|
||||
bool maximise = ((!s_v) || (s_v -> windowState() & Qt::WindowMaximized));
|
||||
|
||||
// ajoute la fenetre
|
||||
QWidget *p = workspace.addWindow(sv);
|
||||
connect(sv, SIGNAL(selectionChanged()), this, SLOT(slot_updateActions()));
|
||||
connect(sv, SIGNAL(modeChanged()), this, SLOT(slot_updateActions()));
|
||||
|
||||
// affiche la fenetre
|
||||
if (maximise) p -> showMaximized();
|
||||
else p -> show();
|
||||
}
|
||||
@@ -836,12 +841,12 @@ void QETApp::slot_updateMenuFenetres() {
|
||||
QList<QWidget *> fenetres = workspace.windowList();
|
||||
if (!fenetres.isEmpty()) menu_fenetres -> addSeparator();
|
||||
for (int i = 0 ; i < fenetres.size() ; ++ i) {
|
||||
SchemaVue *sv = qobject_cast<SchemaVue *>(fenetres.at(i));
|
||||
DiagramView *sv = qobject_cast<DiagramView *>(fenetres.at(i));
|
||||
QString sv_titre = sv -> windowTitle().left(sv -> windowTitle().length() - 3);
|
||||
QAction *action = menu_fenetres -> addAction(sv_titre);
|
||||
action -> setStatusTip(tr("Active la fen\352tre ") + sv_titre);
|
||||
action -> setCheckable(true);
|
||||
action -> setChecked(sv == schemaEnCours());
|
||||
action -> setChecked(sv == diagramEnCours());
|
||||
connect(action, SIGNAL(triggered()), &windowMapper, SLOT(map()));
|
||||
windowMapper.setMapping(action, sv);
|
||||
}
|
||||
@@ -871,7 +876,7 @@ QString QETApp::customElementsDir() {
|
||||
lequel QET lira les informations de configuration et de personnalisation
|
||||
propres a l'utilisateur courant. Ce dossier est generalement
|
||||
C:\Documents And Settings\utilisateur\Application Data\qet sous Windows et
|
||||
~/.qet sous les systèmes type UNIX.
|
||||
~/.qet sous les systemes type UNIX.
|
||||
@return Le chemin du dossier de configuration de QElectroTech
|
||||
*/
|
||||
QString QETApp::configDir() {
|
||||
@@ -929,7 +934,7 @@ QString QETApp::languagesPath() {
|
||||
|
||||
void QETApp::editInfos() {
|
||||
// ne fait rien s'il n'y a pas de schema ouvert
|
||||
SchemaVue *sv = schemaEnCours();
|
||||
DiagramView *sv = diagramEnCours();
|
||||
if (!sv) return;
|
||||
|
||||
// recupere le cartouche du schema
|
||||
@@ -942,9 +947,9 @@ void QETApp::editInfos() {
|
||||
|
||||
QLineEdit *titre = new QLineEdit(inset -> title(), &popup);
|
||||
QLineEdit *auteur = new QLineEdit(inset -> author(), &popup);
|
||||
QDate date_schema = QDate(inset -> date());
|
||||
if (date_schema.isNull() || !date_schema.isValid()) date_schema = QDate::currentDate();
|
||||
QDateEdit *date = new QDateEdit(date_schema, &popup);
|
||||
QDate date_diagram = QDate(inset -> date());
|
||||
if (date_diagram.isNull() || !date_diagram.isValid()) date_diagram = QDate::currentDate();
|
||||
QDateEdit *date = new QDateEdit(date_diagram, &popup);
|
||||
date -> setCalendarPopup(true);
|
||||
QLineEdit *fichier = new QLineEdit(inset -> fileName(), &popup);
|
||||
QLineEdit *folio = new QLineEdit(inset -> folio(), &popup);
|
||||
@@ -980,7 +985,7 @@ void QETApp::editInfos() {
|
||||
}
|
||||
|
||||
void QETApp::slot_addColumn() {
|
||||
SchemaVue *sv = schemaEnCours();
|
||||
DiagramView *sv = diagramEnCours();
|
||||
if (!sv) return;
|
||||
|
||||
// ajoute la colonne
|
||||
@@ -996,7 +1001,7 @@ void QETApp::slot_addColumn() {
|
||||
}
|
||||
|
||||
void QETApp::slot_removeColumn() {
|
||||
SchemaVue *sv = schemaEnCours();
|
||||
DiagramView *sv = diagramEnCours();
|
||||
if (!sv) return;
|
||||
sv -> scene -> border_and_inset.removeColumn();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user