implemented delegate() function for graphics objects

preferencesAboutTextFull
Ivan Ilin 13 years ago
parent 2f34f5e5ff
commit 9aa3027c51
  1. 19
      src/adaptors/UBCFFSubsetAdaptor.cpp
  2. 5
      src/adaptors/UBCFFSubsetAdaptor.h
  3. 1
      src/domain/UBGraphicsAudioItem.h
  4. 16
      src/domain/UBGraphicsItemDelegate.h
  5. 3
      src/domain/UBGraphicsPDFItem.h
  6. 7
      src/domain/UBGraphicsPixmapItem.h
  7. 4
      src/domain/UBGraphicsProxyWidget.h
  8. 3
      src/domain/UBGraphicsSvgItem.h
  9. 1
      src/domain/UBGraphicsTextItem.cpp
  10. 3
      src/domain/UBGraphicsTextItem.h
  11. 1
      src/domain/UBGraphicsVideoItem.h
  12. 25
      src/domain/UBItem.h
  13. 1
      src/tools/UBGraphicsCurtainItem.cpp
  14. 2
      src/tools/UBGraphicsCurtainItem.h

@ -818,8 +818,8 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgImage(const QDomElement &ele
} }
// repositionSvgItem(svgItem, rx * 2 + 10, ry * 2 + 10, cx - rx - 5, cy - ry -5, hastransform, transform); // repositionSvgItem(svgItem, rx * 2 + 10, ry * 2 + 10, cx - rx - 5, cy - ry -5, hastransform, transform);
repositionPixmapItem(pixItem, width, height, x, y, hastransform, transform); repositionPixmapItem(pixItem, width, height, x, y, hastransform, transform);
// hashSceneItem(element, pixItem->); hashSceneItem(element, pixItem);
pixItem->Delegate()->lock(true);
return true; return true;
} }
@ -852,13 +852,13 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseIwbGroup(QDomNode *group)
return true; return true;
} }
//void UBCFFSubsetAdaptor::UBCFFSubsetReader::hashSceneItem(QDomNode &element, UBGraphicsItemDelegate *item) void UBCFFSubsetAdaptor::UBCFFSubsetReader::hashSceneItem(const QDomElement &element, UBGraphicsItem *item)
//{ {
//// adding element pointer to hash to refer if needed // adding element pointer to hash to refer if needed
// QString key = element.attribute(aId); QString key = element.attribute(aId);
// if (!key.isNull()) if (!key.isNull())
// persistedItems.insert(key, item); persistedItems.insert(key, item);
//} }
bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgElement(const QDomElement &parent) bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgElement(const QDomElement &parent)
{ {
@ -868,7 +868,6 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseSvgElement(const QDomElement &p
return false; return false;
} }
if (tagName == tRect && !parseSvgRect(parent)) return false; if (tagName == tRect && !parseSvgRect(parent)) return false;
else if (tagName == tEllipse && !parseSvgEllipse(parent)) return false; else if (tagName == tEllipse && !parseSvgEllipse(parent)) return false;
else if (tagName == tPolygon && !parseSvgPolygon(parent)) return false; else if (tagName == tPolygon && !parseSvgPolygon(parent)) return false;

@ -30,6 +30,7 @@ class UBGraphicsPixmapItem;
class UBGraphicsItemDelegate; class UBGraphicsItemDelegate;
class QTransform; class QTransform;
class QPainter; class QPainter;
class UBGraphicsItem;
struct IwbExt { struct IwbExt {
IwbExt() {;} IwbExt() {;}
@ -87,7 +88,7 @@ private:
QDomDocument mDOMdoc; QDomDocument mDOMdoc;
QDomNode mCurrentDOMElement; QDomNode mCurrentDOMElement;
QHash<QString, IwbExt> iwbExtProperties; QHash<QString, IwbExt> iwbExtProperties;
QHash<QString, UBGraphicsItemDelegate*> persistedItems; QHash<QString, UBGraphicsItem*> persistedItems;
bool hashElements(); bool hashElements();
void addExtentionsToHash(QDomElement *parent, QDomElement *topGroup); void addExtentionsToHash(QDomElement *parent, QDomElement *topGroup);
@ -109,7 +110,7 @@ private:
inline bool parseSvgImage(const QDomElement &element); inline bool parseSvgImage(const QDomElement &element);
// inline bool parseSvgTSpan(const QDomElement) // inline bool parseSvgTSpan(const QDomElement)
bool parseIwbGroup(QDomNode *element); bool parseIwbGroup(QDomNode *element);
inline void hashSceneItem(QDomNode *element, UBGraphicsItemDelegate *item); inline void hashSceneItem(const QDomElement &element, UBGraphicsItem *item);
// to kill // to kill
void parseTextAttributes(const QDomElement &element, qreal &fontSize, QColor &fontColor, void parseTextAttributes(const QDomElement &element, qreal &fontSize, QColor &fontColor,

@ -37,6 +37,7 @@ public:
} }
virtual UBItem* deepCopy () const; virtual UBItem* deepCopy () const;
virtual UBGraphicsItemDelegate *Delegate() const {return mDelegate;}
private slots: private slots:

@ -30,7 +30,7 @@ class UBGraphicsWidgetItem;
class DelegateButton: public QGraphicsSvgItem class DelegateButton: public QGraphicsSvgItem
{ {
Q_OBJECT; Q_OBJECT
public: public:
DelegateButton(const QString & fileName, QGraphicsItem* pDelegated, QGraphicsItem * parent = 0) DelegateButton(const QString & fileName, QGraphicsItem* pDelegated, QGraphicsItem * parent = 0)
@ -90,7 +90,7 @@ class DelegateButton: public QGraphicsSvgItem
class UBGraphicsItemDelegate : public QObject class UBGraphicsItemDelegate : public QObject
{ {
Q_OBJECT; Q_OBJECT
public: public:
UBGraphicsItemDelegate(QGraphicsItem* pDelegated, QObject * parent = 0, bool respectRatio = true, bool canRotate = false); UBGraphicsItemDelegate(QGraphicsItem* pDelegated, QObject * parent = 0, bool respectRatio = true, bool canRotate = false);
@ -129,17 +129,19 @@ class UBGraphicsItemDelegate : public QObject
void setMimeData(QMimeData* mimeData); void setMimeData(QMimeData* mimeData);
signals: signals:
void showOnDisplayChanged(bool shown); void showOnDisplayChanged(bool shown);
void lockChanged(bool locked); void lockChanged(bool locked);
public slots: public slots:
virtual void remove(bool canUndo = true); virtual void remove(bool canUndo = true);
void showMenu(); void showMenu();
virtual void showHide(bool show);
virtual void lock(bool lock);
virtual void duplicate();
protected: protected:
virtual void buildButtons() {}; virtual void buildButtons() {;}
virtual void decorateMenu(QMenu *menu); virtual void decorateMenu(QMenu *menu);
virtual void updateMenuActionState(); virtual void updateMenuActionState();
@ -164,9 +166,7 @@ class UBGraphicsItemDelegate : public QObject
protected slots: protected slots:
virtual void gotoContentSource(bool checked); virtual void gotoContentSource(bool checked);
virtual void showHide(bool show);
virtual void lock(bool lock);
virtual void duplicate();
private: private:

@ -48,6 +48,7 @@ class UBGraphicsPDFItem: public GraphicsPDFItem, public UBItem, public UBGraphic
virtual void remove(); virtual void remove();
virtual UBGraphicsPixmapItem* toPixmapItem() const; virtual UBGraphicsPixmapItem* toPixmapItem() const;
virtual UBGraphicsItemDelegate *Delegate() const {return mDelegate;}
protected: protected:
@ -57,7 +58,7 @@ class UBGraphicsPDFItem: public GraphicsPDFItem, public UBItem, public UBGraphic
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value); virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
UBGraphicsItemDelegate* mDelegate; // UBGraphicsItemDelegate* mDelegate;
}; };
#endif /* UBGRAPHICSPDFITEM_H_ */ #endif /* UBGRAPHICSPDFITEM_H_ */

@ -45,11 +45,13 @@ class UBGraphicsPixmapItem : public QObject, public QGraphicsPixmapItem, public
virtual void remove(); virtual void remove();
Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity); Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity)
void setOpacity(qreal op); void setOpacity(qreal op);
qreal opacity() const; qreal opacity() const;
virtual UBGraphicsItemDelegate* Delegate() const {return mDelegate;}
protected: protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
@ -60,7 +62,8 @@ protected:
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value); virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
UBGraphicsItemDelegate* mDelegate;
// UBGraphicsItemDelegate* mDelegate;
}; };

@ -41,7 +41,7 @@ class UBGraphicsProxyWidget: public QGraphicsProxyWidget, public UBItem, public
virtual void remove(); virtual void remove();
UBGraphicsItemDelegate* delegate (){ return mDelegate;} virtual UBGraphicsItemDelegate* delegate() const { return mDelegate;}
protected: protected:
@ -53,7 +53,7 @@ class UBGraphicsProxyWidget: public QGraphicsProxyWidget, public UBItem, public
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value); virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
UBGraphicsItemDelegate* mDelegate; // UBGraphicsItemDelegate* mDelegate;
}; };
#endif /* UBGRAPHICSPROXYWIDGET_H_ */ #endif /* UBGRAPHICSPROXYWIDGET_H_ */

@ -59,6 +59,7 @@ class UBGraphicsSvgItem: public QGraphicsSvgItem, public UBItem, public UBGraphi
virtual void remove(); virtual void remove();
virtual UBGraphicsPixmapItem* toPixmapItem() const; virtual UBGraphicsPixmapItem* toPixmapItem() const;
virtual UBGraphicsItemDelegate *Delegate() const {return mDelegate;}
protected: protected:
@ -70,7 +71,7 @@ class UBGraphicsSvgItem: public QGraphicsSvgItem, public UBItem, public UBGraphi
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value); virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
UBGraphicsItemDelegate* mDelegate; // UBGraphicsItemDelegate* mDelegate;
QByteArray mFileData; QByteArray mFileData;
}; };

@ -30,7 +30,6 @@ QColor UBGraphicsTextItem::lastUsedTextColor;
UBGraphicsTextItem::UBGraphicsTextItem(QGraphicsItem * parent) UBGraphicsTextItem::UBGraphicsTextItem(QGraphicsItem * parent)
: QGraphicsTextItem(parent) : QGraphicsTextItem(parent)
, mDelegate(0)
, mMultiClickState(0) , mMultiClickState(0)
, mLastMousePressTime(QTime::currentTime()) , mLastMousePressTime(QTime::currentTime())
{ {

@ -78,6 +78,7 @@ class UBGraphicsTextItem : public QGraphicsTextItem, public UBItem, public UBRes
{ {
mColorOnLightBackground = pColorOnLightBackground; mColorOnLightBackground = pColorOnLightBackground;
} }
virtual UBGraphicsItemDelegate *Delegate() const {return mDelegate;}
signals: signals:
void textUndoCommandAdded(UBGraphicsTextItem *textItem); void textUndoCommandAdded(UBGraphicsTextItem *textItem);
@ -96,7 +97,7 @@ class UBGraphicsTextItem : public QGraphicsTextItem, public UBItem, public UBRes
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value); virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
private: private:
UBGraphicsItemDelegate *mDelegate; // UBGraphicsItemDelegate *mDelegate;
qreal mTextHeight; qreal mTextHeight;
int mMultiClickState; int mMultiClickState;

@ -40,6 +40,7 @@ public:
{ {
return mVideoWidget; return mVideoWidget;
} }
virtual UBGraphicsItemDelegate *Delegate() const {return mDelegate;}
public slots: public slots:

@ -16,6 +16,7 @@
#define UBITEM_H #define UBITEM_H
#include <QtGui> #include <QtGui>
#include "domain/UBGraphicsItemDelegate.h"
class UBGraphicsScene; class UBGraphicsScene;
@ -84,21 +85,23 @@ class UBItem
class UBGraphicsItem class UBGraphicsItem
{ {
protected: protected:
UBGraphicsItem() UBGraphicsItem() : mDelegate(0)
{ {
// NOOP // NOOP
} }
UBGraphicsItemDelegate* mDelegate;
virtual ~UBGraphicsItem() virtual ~UBGraphicsItem()
{ {
// NOOP // NOOP
} }
public: public:
virtual UBGraphicsItemDelegate *Delegate() const {return 0;}
virtual void remove() = 0;
virtual void remove() = 0;
}; };
#endif // UBITEM_H #endif // UBITEM_H

@ -36,7 +36,6 @@ const QColor UBGraphicsCurtainItem::sDarkBackgroundOpaqueControlColor = QColor(6
UBGraphicsCurtainItem::UBGraphicsCurtainItem(QGraphicsItem* parent) UBGraphicsCurtainItem::UBGraphicsCurtainItem(QGraphicsItem* parent)
: QGraphicsRectItem(parent) : QGraphicsRectItem(parent)
, mDelegate(0)
{ {
mDelegate = new UBGraphicsCurtainItemDelegate(this, 0); mDelegate = new UBGraphicsCurtainItemDelegate(this, 0);
mDelegate->init(); mDelegate->init();

@ -65,7 +65,7 @@ class UBGraphicsCurtainItem : public QObject, public QGraphicsRectItem, public U
QColor drawColor() const; QColor drawColor() const;
QColor opaqueControlColor() const; QColor opaqueControlColor() const;
UBGraphicsItemDelegate* mDelegate; // UBGraphicsItemDelegate* mDelegate;
static const QColor sDrawColor; static const QColor sDrawColor;
static const QColor sDarkBackgroundDrawColor; static const QColor sDarkBackgroundDrawColor;

Loading…
Cancel
Save