Rapatriement dans la branche 0.3 des revisions 870 a 903.

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/branches/0.3@904 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
xavier
2010-03-28 16:27:48 +00:00
parent 815a2ea3e8
commit c3563a8307
261 changed files with 23264 additions and 2797 deletions

View File

@@ -117,13 +117,11 @@ QWidget *AboutQET::authorsTab() const {
QWidget *AboutQET::translatorsTab() const {
QLabel *translators = new QLabel();
addAuthor(translators, "Youssef Oualmakran", "youssefsan@qelectrotech.org", tr("Traduction en espagnol"));
addAuthor(translators, "Yuriy Litkevich", "yuriy@qelectrotech.org", tr("Traduction en russe"));
addAuthor(translators, "Jos\351 Carlos Martins", "jose@qelectrotech.org", tr("Traduction en portugais"));
addAuthor(translators, "Pavel Fric", "pavelfric@seznam.cz", tr("Traduction en tch\350que"));
/*
addAuthor(translators, "Luca Pedrazzi", "pedro@iworks.it", tr("Traduction en italien"));
*/
addAuthor(translators, "Youssef Oualmakran", "youssefsan@qelectrotech.org", tr("Traduction en espagnol"));
addAuthor(translators, "Yuriy Litkevich", "yuriy@qelectrotech.org", tr("Traduction en russe"));
addAuthor(translators, "Jos\351 Carlos Martins", "jose@qelectrotech.org", tr("Traduction en portugais"));
addAuthor(translators, "Pavel Fric", "pavelfric@seznam.cz", tr("Traduction en tch\350que"));
addAuthor(translators, "Paweł Śmiech", "pawel32640@interia.pl", tr("Traduction en polonais"));
translators -> setAlignment(Qt::AlignCenter);
translators -> setOpenExternalLinks(true);

View File

@@ -42,6 +42,7 @@ Conductor::Conductor(Terminal *p1, Terminal* p2, Element *parent, QGraphicsScene
terminal1(p1),
terminal2(p2),
destroyed(false),
text_item(0),
segments(NULL),
moving_point(false),
moving_segment(false),
@@ -750,6 +751,9 @@ QVariant Conductor::itemChange(GraphicsItemChange change, const QVariant &value)
// le conducteur vient de se faire deselectionner
setZValue(previous_z_value);
}
} else if (change == QGraphicsItem::ItemSceneHasChanged || change == QGraphicsItem::ItemVisibleHasChanged) {
// permet de positionner correctement le texte du conducteur lors de son ajout a un schema
calculateTextItemPosition();
}
return(QGraphicsPathItem::itemChange(change, value));
}
@@ -1075,6 +1079,7 @@ ConductorSegment *Conductor::middleSegment() {
*/
void Conductor::calculateTextItemPosition() {
if (properties_.type != ConductorProperties::Multi) return;
if (!text_item) return;
text_item -> setPos(middleSegment() -> middle());
}

View File

@@ -851,7 +851,12 @@ void DiagramView::editDefaultConductorProperties() {
bool DiagramView::event(QEvent *e) {
// fait en sorte que les raccourcis clavier arrivent prioritairement sur la
// vue plutot que de remonter vers les QMenu / QAction
if (e -> type() == QEvent::ShortcutOverride && scene -> focusItem()) {
if (
e -> type() == QEvent::ShortcutOverride &&
scene -> hasFocus() &&
scene -> focusItem() &&
scene -> focusItem() -> isSelected()
) {
e -> accept();
return(true);
}

View File

@@ -607,7 +607,7 @@ void AllowInternalConnectionsCommand::redo() {
Constructeur
@param elmt ElementScene concernee
@param old_infos Informations complementaires precedentes
@param old_infos Nouvelles informations complementaires
@param new_infos Nouvelles informations complementaires
@param parent QUndoCommand parent
*/
ChangeInformationsCommand::ChangeInformationsCommand(ElementScene *elmt, const QString &old_infos, const QString &new_infos, QUndoCommand *parent) :

View File

@@ -836,7 +836,7 @@ void ElementScene::slot_editSizeHotSpot() {
connect(dialog_buttons, SIGNAL(rejected()), &dialog_sh, SLOT(reject()));
// lance le dialogue
if (dialog_sh.exec() == QDialog::Accepted && is_read_only) {
if (dialog_sh.exec() == QDialog::Accepted && !is_read_only) {
QSize new_size(hotspot_editor -> elementSize());
QSize old_size(width(), height());
QPoint new_hotspot(hotspot_editor -> hotspot());

View File

@@ -77,8 +77,8 @@ const QDomElement PartPolygon::toXml(QDomDocument &xml_document) const {
int i = 1;
foreach(QPointF point, polygon()) {
point = mapToScene(point);
xml_element.setAttribute(QString("x%1").arg(i), point.x());
xml_element.setAttribute(QString("y%1").arg(i), point.y());
xml_element.setAttribute(QString("x%1").arg(i), QString("%1").arg(point.x()));
xml_element.setAttribute(QString("y%1").arg(i), QString("%1").arg(point.y()));
++ i;
}
if (!closed) xml_element.setAttribute("closed", "false");

View File

@@ -16,6 +16,7 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "qetelementeditor.h"
#include "qet.h"
#include "qetapp.h"
#include "elementscene.h"
#include "elementview.h"
@@ -88,6 +89,35 @@ QETElementEditor::~QETElementEditor() {
editors_.clear();
}
/**
@param el Le nouvel emplacement de l'element edite
*/
void QETElementEditor::setLocation(const ElementsLocation &el) {
location_ = el;
opened_from_file = false;
// modifie le mode lecture seule si besoin
ElementsCollectionItem *item = QETApp::collectionItem(location_);
bool must_be_read_only = item && !item -> isWritable();
if (isReadOnly() != must_be_read_only) {
setReadOnly(must_be_read_only);
}
slot_updateTitle();
}
/**
@param fn Le nouveau nom de fichier de l'element edite
*/
void QETElementEditor::setFileName(const QString &fn) {
filename_ = fn;
opened_from_file = true;
// modifie le mode lecture seule si besoin
bool must_be_read_only = !QFileInfo(filename_).isWritable();
if (isReadOnly() != must_be_read_only) {
setReadOnly(must_be_read_only);
}
slot_updateTitle();
}
/**
Met en place les actions
*/
@@ -349,12 +379,12 @@ void QETElementEditor::setupActions() {
Met en place les menus.
*/
void QETElementEditor::setupMenus() {
file_menu = new QMenu(tr("Fichier"), this);
edit_menu = new QMenu(tr("\311dition"), this);
display_menu = new QMenu(tr("Affichage"), this);
tools_menu = new QMenu(tr("Outils"), this);
file_menu = new QMenu(tr("&Fichier"), this);
edit_menu = new QMenu(tr("&\311dition"), this);
display_menu = new QMenu(tr("Afficha&ge"), this);
tools_menu = new QMenu(tr("O&utils"), this);
config_menu = new QMenu(tr("&Configuration"), this);
help_menu = new QMenu(tr("Aide"), this);
help_menu = new QMenu(tr("&Aide"), this);
file_menu -> setTearOffEnabled(true);
edit_menu -> setTearOffEnabled(true);
@@ -837,6 +867,46 @@ bool QETElementEditor::toLocation(const ElementsLocation &location) {
return(true);
}
/**
@param provided_location Emplacement d'un element
@return true si cet editeur est en train d'editer l'element dont
l'emplacement est location, false sinon
*/
bool QETElementEditor::isEditing(const ElementsLocation &provided_location) {
if (opened_from_file) {
return(
QET::compareCanonicalFilePaths(
filename_,
QETApp::realPath(provided_location.toString())
)
);
} else {
return(provided_location == location_);
}
}
/**
@param provided_filepath Chemin d'un element sur un filesystem
@return true si cet editeur est en train d'editer l'element dont
le chemin est filepath, false sinon
*/
bool QETElementEditor::isEditing(const QString &provided_filepath) {
// determine le chemin canonique de l'element actuelle edite, si applicable
QString current_filepath;
if (opened_from_file) {
current_filepath = filename_;
} else {
current_filepath = QETApp::realPath(location_.toString());
}
return(
QET::compareCanonicalFilePaths(
current_filepath,
provided_filepath
)
);
}
/**
specifie si l'editeur d'element doit etre en mode lecture seule
@param ro true pour activer le mode lecture seule, false pour le desactiver
@@ -872,9 +942,7 @@ 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;
QETElementEditor *cee = new QETElementEditor();
cee -> fromLocation(location);
cee -> show();
QETApp::instance() -> openElementLocations(QList<ElementsLocation>() << location);
}
/**
@@ -908,12 +976,11 @@ void QETElementEditor::openRecentFile(const QString &filepath) {
Cette methode ne controle pas si le fichier est deja ouvert
@param filepath Fichier a ouvrir
@see fromFile
@see QETApp::openElementFiles
*/
void QETElementEditor::openElement(const QString &filepath) {
if (filepath.isEmpty()) return;
QETElementEditor *cee = new QETElementEditor();
cee -> fromFile(filepath);
cee -> show();
QETApp::instance() -> openElementFiles(QStringList() << filepath);
}
/**

View File

@@ -115,6 +115,8 @@ class QETElementEditor : public QMainWindow {
void fromLocation(const ElementsLocation &);
bool toFile(const QString &);
bool toLocation(const ElementsLocation &);
bool isEditing(const ElementsLocation &);
bool isEditing(const QString &);
ElementScene *elementScene() const;
void readSettings();
void writeSettings();
@@ -217,15 +219,6 @@ inline OrientationSet QETElementEditor::orientations() const {
return(ce_scene -> orientations());
}
/**
@param el Le nouvel emplacement de l'element edite
*/
inline void QETElementEditor::setLocation(const ElementsLocation &el) {
location_ = el;
opened_from_file = false;
slot_updateTitle();
}
/**
@return l'emplacement de l'element edite
*/
@@ -233,15 +226,6 @@ inline ElementsLocation QETElementEditor::location() const {
return(location_);
}
/**
@param fn Le nouveau nom de fichier de l'element edite
*/
inline void QETElementEditor::setFileName(const QString &fn) {
filename_ = fn;
opened_from_file = true;
slot_updateTitle();
}
/**
@return le nom de fichier de l'element edite
*/

View File

@@ -255,9 +255,7 @@ void ElementsPanelWidget::importElement() {
// Ouverture de l'element dans l'editeur pour pouvoir ensuite l'enregistrer dans la categorie voulue
if (!fileName.isEmpty()) {
QETElementEditor *editor = new QETElementEditor();
editor -> fromFile(fileName);
editor -> show();
QETApp::instance() -> openElementFiles(QStringList() << fileName);
}
}
@@ -530,9 +528,7 @@ void ElementsPanelWidget::deleteElement() {
@param location Emplacement de l'element a editer
*/
void ElementsPanelWidget::launchElementEditor(const ElementsLocation &location) {
QETElementEditor *editor = new QETElementEditor();
editor -> fromLocation(location);
editor -> show();
QETApp::instance() -> openElementLocations(QList<ElementsLocation>() << location);
}
/**

View File

@@ -54,6 +54,7 @@ QDomElement FileElementDefinition::xml() {
bool FileElementDefinition::setXml(const QDomElement &xml_element) {
xml_element_.clear();
xml_element_.appendChild(xml_element_.importNode(xml_element, true));
is_null = false;
return(true);
}

View File

@@ -446,3 +446,25 @@ qreal QET::correctAngle(const qreal &angle) {
while (corrected_angle >= 360.0) corrected_angle -= 360.0;
return(corrected_angle);
}
/**
@param first Un premier chemin vers un fichier
@param second Un second chemin vers un fichier
@return true si les deux chemins existent existent et sont identiques
lorsqu'ils sont exprimes sous forme canonique
*/
bool QET::compareCanonicalFilePaths(const QString &first, const QString &second) {
QString first_canonical_path = QFileInfo(first).canonicalFilePath();
if (first_canonical_path.isEmpty()) return(false);
QString second_canonical_path = QFileInfo(second).canonicalFilePath();
if (second_canonical_path.isEmpty()) return(false);
#ifdef Q_WS_WIN
// sous Windows, on ramene les chemins en minuscules
first_canonical_path = first_canonical_path.toLower();
second_canonical_path = second_canonical_path.toLower();
#endif
return(first_canonical_path == second_canonical_path);
}

View File

@@ -25,9 +25,9 @@
*/
namespace QET {
/// version de QElectroTech (utilisee pour estampiller les projets et elements)
const QString version = "0.2";
const QString version = "0.22";
/// version affichee de QElectroTech
const QString displayedVersion = "0.2";
const QString displayedVersion = "0.22";
QString license();
/// Orientation (utilise pour les bornes mais aussi pour les elements)
enum Orientation {North, East, South, West};
@@ -122,5 +122,6 @@ namespace QET {
QET::DiagramArea diagramAreaFromString(const QString &);
QString pointerString(void *);
qreal correctAngle(const qreal &);
bool compareCanonicalFilePaths(const QString &, const QString &);
}
#endif

View File

@@ -753,10 +753,68 @@ void QETApp::openProjectFiles(const QStringList &files_list) {
void QETApp::openElementFiles(const QStringList &files_list) {
if (files_list.isEmpty()) return;
// creation et affichage d'un ou plusieurs editeurs d'element
foreach(QString element_file, files_list) {
QETElementEditor *element_editor = new QETElementEditor();
element_editor -> fromFile(element_file);
// evite autant que possible les doublons dans la liste fournie
QSet<QString> files_set;
foreach(QString file, files_list) {
QString canonical_filepath = QFileInfo(file).canonicalFilePath();
if (!canonical_filepath.isEmpty()) files_set << canonical_filepath;
}
// a ce stade, tous les fichiers dans le Set existent et sont a priori differents
if (files_set.isEmpty()) return;
// liste des editeurs d'element ouverts
QList<QETElementEditor *> element_editors = elementEditors();
// on traite les fichiers a la queue leu leu...
foreach(QString element_file, files_set) {
bool already_opened_in_existing_element_editor = false;
foreach(QETElementEditor *element_editor, element_editors) {
if (element_editor -> isEditing(element_file)) {
// ce fichier est deja ouvert dans un editeur
already_opened_in_existing_element_editor = true;
element_editor -> setVisible(true);
element_editor -> raise();
element_editor -> activateWindow();
break;
}
}
if (!already_opened_in_existing_element_editor) {
// ce fichier n'est ouvert dans aucun editeur
QETElementEditor *element_editor = new QETElementEditor();
element_editor -> fromFile(element_file);
}
}
}
/**
Ouvre les elements dont l'emplacement est passe en parametre. Si un element
est deja ouvert, la fentre qui l'edite est activee.
@param locations_list Emplacements a ouvrir
*/
void QETApp::openElementLocations(const QList<ElementsLocation> &locations_list) {
if (locations_list.isEmpty()) return;
// liste des editeurs d'element ouverts
QList<QETElementEditor *> element_editors = elementEditors();
// on traite les emplacements a la queue leu leu...
foreach(ElementsLocation element_location, locations_list) {
bool already_opened_in_existing_element_editor = false;
foreach(QETElementEditor *element_editor, element_editors) {
if (element_editor -> isEditing(element_location)) {
// cet emplacement est deja ouvert dans un editeur
already_opened_in_existing_element_editor = true;
element_editor -> setVisible(true);
element_editor -> raise();
element_editor -> activateWindow();
break;
}
}
if (!already_opened_in_existing_element_editor) {
// cet emplacement n'est ouvert dans aucun editeur
QETElementEditor *element_editor = new QETElementEditor();
element_editor -> fromLocation(element_location);
}
}
}

View File

@@ -161,6 +161,7 @@ class QETApp : public QETSingleApplication {
void openFiles(const QETArguments &);
void openProjectFiles(const QStringList &);
void openElementFiles(const QStringList &);
void openElementLocations(const QList<ElementsLocation> &);
void configureQET();
void aboutQET();

View File

@@ -1773,12 +1773,9 @@ void QETDiagramEditor::findElementInPanel(const ElementsLocation &location) {
@param location Emplacement de l'element a editer
*/
void QETDiagramEditor::editElementInEditor(const ElementsLocation &location) {
QETElementEditor *editor = new QETElementEditor();
editor -> fromLocation(location);
editor -> show();
QETApp::instance() -> openElementLocations(QList<ElementsLocation>() << location);
}
/**
@return Les proprietes par defaut pour le cartouche d'un schema
*/

View File

@@ -894,6 +894,7 @@ NamesList QETProject::namesListForIntegrationCategory() {
names.addName("es", "Elementos importados");
names.addName("ru", QString(russian_data, 24));
names.addName("cs", "Zaveden\351 prvky");
names.addName("pl", "Elementy importowane");
return(names);
}

View File

@@ -482,8 +482,8 @@ bool Terminal::valideXml(QDomElement &terminal) {
*/
bool Terminal::fromXml(QDomElement &terminal) {
return (
terminal.attribute("x").toDouble() == amarrage_elmt.x() &&\
terminal.attribute("y").toDouble() == amarrage_elmt.y() &&\
qFuzzyCompare(terminal.attribute("x").toDouble(), amarrage_elmt.x()) &&
qFuzzyCompare(terminal.attribute("y").toDouble(), amarrage_elmt.y()) &&
terminal.attribute("orientation").toInt() == sens
);
}