mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-19 06:20:53 +01:00
Implementation d'un menu reinitialiser les conducteurs modifies
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@161 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -1001,6 +1001,11 @@ void Conductor::setProfile(const ConductorProfile &cp) {
|
||||
calculateTextItemPosition();
|
||||
}
|
||||
|
||||
/// @return le profil de ce conducteur
|
||||
ConductorProfile Conductor::profile() const {
|
||||
return(conductor_profile);
|
||||
}
|
||||
|
||||
bool Conductor::isSingleLine() const {
|
||||
return(is_single_line);
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@ class Conductor : public QGraphicsPathItem {
|
||||
QDomElement toXml(QDomDocument &, QHash<Terminal *, int> &) const;
|
||||
const QList<ConductorSegment *> segmentsList() const;
|
||||
void setProfile(const ConductorProfile &);
|
||||
ConductorProfile profile() const;
|
||||
void setSingleLine(bool);
|
||||
bool isSingleLine() const;
|
||||
|
||||
|
||||
@@ -388,6 +388,40 @@ void ChangeConductorCommand::redo() {
|
||||
else conductor -> setProfile(new_profile);
|
||||
}
|
||||
|
||||
/**
|
||||
Constructeur
|
||||
@param c Conducteurs reinitialises
|
||||
@param p Anciens profils des conducteurs
|
||||
@param parent QUndoCommand parent
|
||||
*/
|
||||
ResetConductorCommand::ResetConductorCommand(
|
||||
const QHash<Conductor *, ConductorProfile> &cp,
|
||||
QUndoCommand *parent
|
||||
) :
|
||||
QUndoCommand(QObject::tr("R\351initialiser ") + QET::ElementsAndConductorsSentence(0, cp.count()), parent),
|
||||
conductors_profiles(cp)
|
||||
{
|
||||
}
|
||||
|
||||
/// Destructeur
|
||||
ResetConductorCommand::~ResetConductorCommand() {
|
||||
}
|
||||
|
||||
/// Annule la reinitialisation des conducteurs
|
||||
void ResetConductorCommand::undo() {
|
||||
foreach(Conductor *c, conductors_profiles.keys()) {
|
||||
c -> setProfile(conductors_profiles[c]);
|
||||
}
|
||||
}
|
||||
|
||||
/// Refait la reinitialisation des conducteurs
|
||||
void ResetConductorCommand::redo() {
|
||||
foreach(Conductor *c, conductors_profiles.keys()) {
|
||||
ConductorProfile t(conductors_profiles[c]);
|
||||
c -> setProfile(ConductorProfile());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Constructeur
|
||||
@param d Schema dont on modifie le cartouche
|
||||
|
||||
@@ -225,16 +225,38 @@ class ChangeConductorCommand : public QUndoCommand {
|
||||
|
||||
// attributs
|
||||
private:
|
||||
/// DiagramTextItem modifie
|
||||
/// Conducteur modifie
|
||||
Conductor *conductor;
|
||||
/// texte avant changement
|
||||
/// profil avant changement
|
||||
ConductorProfile old_profile;
|
||||
/// texte apres changement
|
||||
/// profil apres changement
|
||||
ConductorProfile new_profile;
|
||||
/// booleen pour ne pas executer le premier redo()
|
||||
bool first_redo;
|
||||
};
|
||||
|
||||
/**
|
||||
Cette classe represente l'action de reinitialiser des conducteurs
|
||||
*/
|
||||
class ResetConductorCommand : public QUndoCommand {
|
||||
// constructeurs, destructeur
|
||||
public:
|
||||
ResetConductorCommand(const QHash<Conductor *, ConductorProfile> &, QUndoCommand * = 0);
|
||||
virtual ~ResetConductorCommand();
|
||||
private:
|
||||
ResetConductorCommand(const ResetConductorCommand &);
|
||||
|
||||
// methodes
|
||||
public:
|
||||
virtual void undo();
|
||||
virtual void redo();
|
||||
|
||||
// attributs
|
||||
private:
|
||||
/// Conducteurs reinitialises et leurs anciens profils
|
||||
QHash<Conductor *, ConductorProfile> conductors_profiles;
|
||||
};
|
||||
|
||||
/**
|
||||
Cette classe represente l'action de modifier les informations du cartouche d'un schema
|
||||
*/
|
||||
|
||||
@@ -669,3 +669,21 @@ void DiagramView::editConductor() {
|
||||
delete ccpc;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Reinitialise le profil des conducteurs selectionnes
|
||||
*/
|
||||
void DiagramView::resetConductors() {
|
||||
// recupere les conducteurs selectionnes
|
||||
QSet<Conductor *> selected_conductors = scene -> selectedConductors();
|
||||
|
||||
// repere les conducteurs modifies (= profil non nul)
|
||||
QHash<Conductor *, ConductorProfile> conductors_and_profiles;
|
||||
foreach(Conductor *conductor, selected_conductors) {
|
||||
ConductorProfile profile = conductor -> profile();
|
||||
if (!profile.isNull()) conductors_and_profiles.insert(conductor, profile);
|
||||
}
|
||||
|
||||
if (conductors_and_profiles.isEmpty()) return;
|
||||
scene -> undoStack().push(new ResetConductorCommand(conductors_and_profiles));
|
||||
}
|
||||
|
||||
@@ -74,6 +74,7 @@ class DiagramView : public QGraphicsView {
|
||||
void adjustSceneRect();
|
||||
void updateWindowTitle();
|
||||
void editConductor();
|
||||
void resetConductors();
|
||||
|
||||
private slots:
|
||||
void slot_selectionChanged();
|
||||
|
||||
BIN
ico/conductor2.png
Normal file
BIN
ico/conductor2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 145 B |
@@ -13,6 +13,7 @@
|
||||
<file>ico/category_new.png</file>
|
||||
<file>ico/circle.png</file>
|
||||
<file>ico/conductor.png</file>
|
||||
<file>ico/conductor2.png</file>
|
||||
<file>ico/configure.png</file>
|
||||
<file>ico/copy.png</file>
|
||||
<file>ico/cut.png</file>
|
||||
|
||||
@@ -162,6 +162,7 @@ void QETDiagramEditor::actions() {
|
||||
delete_selection = new QAction(QIcon(":/ico/delete.png"), tr("Supprimer"), this);
|
||||
rotate_selection = new QAction(QIcon(":/ico/pivoter.png"), tr("Pivoter"), this);
|
||||
conductor_prop = new QAction(QIcon(":/ico/conductor.png"), tr("Propri\351t\351s du conducteur"), this);
|
||||
conductor_reset = new QAction(QIcon(":/ico/conductor2.png"), tr("R\351initialiser les conducteurs"), this);
|
||||
infos_diagram = new QAction(QIcon(":/ico/info.png"), tr("Informations sur le sch\351ma"), this);
|
||||
add_column = new QAction(QIcon(":/ico/add_col.png"), tr("Ajouter une colonne"), this);
|
||||
remove_column = new QAction(QIcon(":/ico/remove_col.png"), tr("Enlever une colonne"), this);
|
||||
@@ -210,6 +211,7 @@ void QETDiagramEditor::actions() {
|
||||
delete_selection -> setShortcut(QKeySequence(tr("Suppr")));
|
||||
rotate_selection -> setShortcut(QKeySequence(tr("Ctrl+R")));
|
||||
conductor_prop -> setShortcut(QKeySequence(tr("Ctrl+J")));
|
||||
conductor_reset -> setShortcut(QKeySequence(tr("Ctrl+K")));
|
||||
|
||||
zoom_in -> setShortcut(QKeySequence::ZoomIn);
|
||||
zoom_out -> setShortcut(QKeySequence::ZoomOut);
|
||||
@@ -314,6 +316,7 @@ void QETDiagramEditor::actions() {
|
||||
connect(next_window, SIGNAL(triggered()), &workspace, SLOT(activateNextWindow()) );
|
||||
connect(prev_window, SIGNAL(triggered()), &workspace, SLOT(activatePreviousWindow()) );
|
||||
connect(conductor_prop, SIGNAL(triggered()), this, SLOT(slot_editConductor()) );
|
||||
connect(conductor_reset, SIGNAL(triggered()), this, SLOT(slot_resetConductors()) );
|
||||
connect(infos_diagram, SIGNAL(triggered()), this, SLOT(slot_editInfos()) );
|
||||
connect(add_column, SIGNAL(triggered()), this, SLOT(slot_addColumn()) );
|
||||
connect(remove_column, SIGNAL(triggered()), this, SLOT(slot_removeColumn()) );
|
||||
@@ -372,6 +375,7 @@ void QETDiagramEditor::menus() {
|
||||
menu_edition -> addAction(rotate_selection);
|
||||
menu_edition -> addSeparator();
|
||||
menu_edition -> addAction(conductor_prop);
|
||||
menu_edition -> addAction(conductor_reset);
|
||||
menu_edition -> addSeparator();
|
||||
menu_edition -> addAction(infos_diagram);
|
||||
menu_edition -> addAction(add_column);
|
||||
@@ -653,6 +657,9 @@ void QETDiagramEditor::slot_updateActions() {
|
||||
DiagramView *sv = currentDiagram();
|
||||
bool opened_document = (sv != 0);
|
||||
|
||||
// nombre de conducteurs selectionnes
|
||||
int selected_conductors_count = opened_document ? sv -> diagram() -> selectedConductors().count() : 0;
|
||||
|
||||
// actions ayant juste besoin d'un document ouvert
|
||||
close_file -> setEnabled(opened_document);
|
||||
save_file -> setEnabled(opened_document);
|
||||
@@ -667,7 +674,8 @@ void QETDiagramEditor::slot_updateActions() {
|
||||
zoom_out -> setEnabled(opened_document);
|
||||
zoom_fit -> setEnabled(opened_document);
|
||||
zoom_reset -> setEnabled(opened_document);
|
||||
conductor_prop -> setEnabled(opened_document && sv -> diagram() -> selectedConductors().count() == 1);
|
||||
conductor_prop -> setEnabled(opened_document && selected_conductors_count == 1);
|
||||
conductor_reset -> setEnabled(opened_document && selected_conductors_count);
|
||||
infos_diagram -> setEnabled(opened_document);
|
||||
add_column -> setEnabled(opened_document);
|
||||
remove_column -> setEnabled(opened_document);
|
||||
@@ -734,7 +742,7 @@ void QETDiagramEditor::addDiagramView(DiagramView *dv) {
|
||||
|
||||
// ajoute la fenetre
|
||||
QWidget *p = workspace.addWindow(dv);
|
||||
connect(dv, SIGNAL(selectionChanged()), this, SLOT(slot_updateActions()));
|
||||
connect(dv -> diagram(), SIGNAL(selectionChanged()), this, SLOT(slot_updateActions()));
|
||||
connect(dv, SIGNAL(modeChanged()), this, SLOT(slot_updateActions()));
|
||||
|
||||
// affiche la fenetre
|
||||
@@ -776,6 +784,7 @@ void QETDiagramEditor::slot_updateWindowsMenu() {
|
||||
if (!windows.isEmpty()) windows_menu -> addSeparator();
|
||||
for (int i = 0 ; i < windows.size() ; ++ i) {
|
||||
DiagramView *dv = qobject_cast<DiagramView *>(windows.at(i));
|
||||
if (!dv) continue;
|
||||
QString dv_title = dv -> windowTitle().left(dv -> windowTitle().length() - 3);
|
||||
QAction *action = windows_menu -> addAction(dv_title);
|
||||
action -> setStatusTip(tr("Active la fen\352tre ") + dv_title);
|
||||
@@ -831,8 +840,20 @@ void QETDiagramEditor::slot_shrink() {
|
||||
sv -> shrink();
|
||||
}
|
||||
|
||||
/**
|
||||
Edite les proprietes du conducteur selectionne
|
||||
*/
|
||||
void QETDiagramEditor::slot_editConductor() {
|
||||
if (DiagramView *dv = currentDiagram()) {
|
||||
dv -> editConductor();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Reinitialise les conducteurs selectionnes
|
||||
*/
|
||||
void QETDiagramEditor::slot_resetConductors() {
|
||||
if (DiagramView *dv = currentDiagram()) {
|
||||
dv -> resetConductors();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,6 +66,7 @@ class QETDiagramEditor : public QMainWindow {
|
||||
void slot_expand();
|
||||
void slot_shrink();
|
||||
void slot_editConductor();
|
||||
void slot_resetConductors();
|
||||
|
||||
// attributs
|
||||
protected:
|
||||
@@ -92,6 +93,7 @@ class QETDiagramEditor : public QMainWindow {
|
||||
QAction *delete_selection;
|
||||
QAction *rotate_selection;
|
||||
QAction *conductor_prop;
|
||||
QAction *conductor_reset;
|
||||
QAction *infos_diagram;
|
||||
QAction *add_column;
|
||||
QAction *remove_column;
|
||||
|
||||
Reference in New Issue
Block a user