mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-09-13 20:23:04 +02:00
Diagram command: additem, minor improvement
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3370 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
parent
1a842dc263
commit
0af31b9105
@ -29,30 +29,16 @@
|
|||||||
#include "conductorautonumerotation.h"
|
#include "conductorautonumerotation.h"
|
||||||
#include <QPropertyAnimation>
|
#include <QPropertyAnimation>
|
||||||
|
|
||||||
/**
|
QString itemText(const QetGraphicsItem *item) {
|
||||||
* Specialized template function
|
return item->name();
|
||||||
*/
|
|
||||||
template<>
|
|
||||||
QString itemText <DiagramImageItem *> (DiagramImageItem *item) {
|
|
||||||
Q_UNUSED(item);
|
|
||||||
return QObject::tr("une image");
|
|
||||||
}
|
}
|
||||||
template<>
|
|
||||||
QString itemText <IndependentTextItem *> (IndependentTextItem *item) {
|
QString itemText(const IndependentTextItem *item) {
|
||||||
Q_UNUSED(item);
|
Q_UNUSED(item);
|
||||||
return QObject::tr("un champ texte");
|
return QObject::tr("un champ texte");
|
||||||
}
|
}
|
||||||
template<>
|
|
||||||
QString itemText <Element *> (Element *item) {
|
QString itemText(const Conductor *item) {
|
||||||
return QObject::tr("un \351l\351ment : %1").arg(item->name());
|
|
||||||
}
|
|
||||||
template<>
|
|
||||||
QString itemText <QetShapeItem *> (QetShapeItem *item) {
|
|
||||||
Q_UNUSED(item);
|
|
||||||
return QObject::tr("une shape");
|
|
||||||
}
|
|
||||||
template<>
|
|
||||||
QString itemText <Conductor *> (Conductor *item) {
|
|
||||||
Q_UNUSED(item);
|
Q_UNUSED(item);
|
||||||
return QObject::tr("un conducteur");
|
return QObject::tr("un conducteur");
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@ class Element;
|
|||||||
class ElementTextItem;
|
class ElementTextItem;
|
||||||
class IndependentTextItem;
|
class IndependentTextItem;
|
||||||
class DiagramImageItem;
|
class DiagramImageItem;
|
||||||
|
class QetGraphicsItem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The AddItemCommand class
|
* @brief The AddItemCommand class
|
||||||
@ -73,14 +74,10 @@ class AddItemCommand : public QUndoCommand {
|
|||||||
QPointF m_pos;
|
QPointF m_pos;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
//Return a string to describe a QGraphicsItem
|
||||||
*Template function: return generique name of a QGraphicsItem.
|
QString itemText(const QetGraphicsItem *item);
|
||||||
*/
|
QString itemText(const IndependentTextItem *item);
|
||||||
template <typename T>
|
QString itemText(const Conductor *item);
|
||||||
QString itemText(T item) {
|
|
||||||
Q_UNUSED (item);
|
|
||||||
return QObject::tr("un item");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This command removes content from a particular diagram.
|
This command removes content from a particular diagram.
|
||||||
|
@ -180,6 +180,14 @@ QRectF DiagramImageItem::boundingRect() const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief DiagramImageItem::name
|
||||||
|
* @return the generic name of this item (picture)
|
||||||
|
*/
|
||||||
|
QString DiagramImageItem::name() const {
|
||||||
|
return tr("une image");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Load the image from this xml element
|
Load the image from this xml element
|
||||||
@param e xml element that define an image
|
@param e xml element that define an image
|
||||||
|
@ -55,6 +55,7 @@ class DiagramImageItem : public QetGraphicsItem {
|
|||||||
virtual void editProperty();
|
virtual void editProperty();
|
||||||
void setPixmap(const QPixmap &pixmap);
|
void setPixmap(const QPixmap &pixmap);
|
||||||
virtual QRectF boundingRect() const;
|
virtual QRectF boundingRect() const;
|
||||||
|
virtual QString name() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
|
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
|
||||||
|
@ -37,6 +37,7 @@ class QetGraphicsItem : public QGraphicsObject {
|
|||||||
virtual void rotateBy(const qreal &);
|
virtual void rotateBy(const qreal &);
|
||||||
virtual void applyRotation(const qreal &);
|
virtual void applyRotation(const qreal &);
|
||||||
virtual void editProperty (){}
|
virtual void editProperty (){}
|
||||||
|
virtual QString name()const {return QString("");}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void positionChange(QPointF);
|
void positionChange(QPointF);
|
||||||
|
@ -371,3 +371,27 @@ void QetShapeItem::editProperty()
|
|||||||
//...or not
|
//...or not
|
||||||
setScale(scale_);
|
setScale(scale_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief QetShapeItem::name
|
||||||
|
* @return the name of the curent shape.
|
||||||
|
*/
|
||||||
|
QString QetShapeItem::name() const {
|
||||||
|
switch (m_shapeType) {
|
||||||
|
case Line:
|
||||||
|
return tr("une ligne");
|
||||||
|
break;
|
||||||
|
case Rectangle:
|
||||||
|
return tr("un rectangle");
|
||||||
|
break;
|
||||||
|
case Ellipse:
|
||||||
|
return tr("une \351llipse");
|
||||||
|
break;
|
||||||
|
case Polyline:
|
||||||
|
return tr("une polyligne");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return tr("une shape");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -58,6 +58,7 @@ class QetShapeItem : public QetGraphicsItem
|
|||||||
virtual bool toDXF (const QString &filepath);
|
virtual bool toDXF (const QString &filepath);
|
||||||
|
|
||||||
virtual void editProperty();
|
virtual void editProperty();
|
||||||
|
virtual QString name() const;
|
||||||
|
|
||||||
void setP2 (QPointF P2);
|
void setP2 (QPointF P2);
|
||||||
void setNextPoint (QPointF P);
|
void setNextPoint (QPointF P);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user