Changeset 9378:def54486b2b0 in orange


Ignore:
Timestamp:
12/16/11 17:52:43 (2 years ago)
Author:
miha <miha.stajdohar@…>
Branch:
default
Convert:
4467eba7990b02915e27e0c23ed7fe218efc165a
Message:

New Class for TextItem.

Location:
source/orangeqt
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • source/orangeqt/networkcurve.cpp

    r9363 r9378  
    1818 
    1919#include "networkcurve.h" 
     20#include "point.h" 
    2021 
    2122#include <QtCore/QMap> 
     
    12901291    for (it = labels.constBegin(); it != labels.constEnd(); ++it) 
    12911292    { 
    1292         QGraphicsTextItem* item = new QGraphicsTextItem(it.value(), this); 
     1293        LabelItem* item = new LabelItem(it.value(), this); 
    12931294        item->setZValue(0.6); 
    12941295        item->setFont(plot()->font()); 
  • source/orangeqt/networkcurve.h

    r9361 r9378  
    214214    typedef QList<EdgeItem*> Edges; 
    215215    typedef QMap<int, NodeItem*> Nodes; 
    216     typedef QMap<int, QGraphicsTextItem*> Labels; 
     216    typedef QMap<int, LabelItem*> Labels; 
    217217 
    218218    explicit NetworkCurve(QGraphicsItem* parent = 0); 
  • source/orangeqt/point.cpp

    r9361 r9378  
    6262} 
    6363 
     64LabelItem::LabelItem(QGraphicsItem* parent): QGraphicsTextItem(parent) 
     65{ 
     66} 
     67 
     68LabelItem::LabelItem(const QString &text, QGraphicsItem *parent): QGraphicsTextItem(text, parent) 
     69{ 
     70} 
     71 
     72LabelItem::~LabelItem() 
     73{ 
     74} 
     75/* 
     76void LabelItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) 
     77{ 
     78    Q_UNUSED(widget); 
     79    if (dd->control) { 
     80        painter->save(); 
     81        QRectF r = option->exposedRect; 
     82        painter->translate(-dd->controlOffset()); 
     83        r.translate(dd->controlOffset()); 
     84 
     85        QTextDocument *doc = dd->control->document(); 
     86        QTextDocumentLayout *layout = qobject_cast<QTextDocumentLayout *>(doc->documentLayout()); 
     87 
     88        // the layout might need to expand the root frame to 
     89        // the viewport if NoWrap is set 
     90        if (layout) 
     91            layout->setViewport(dd->boundingRect); 
     92 
     93        dd->control->drawContents(painter, r); 
     94 
     95        if (layout) 
     96            layout->setViewport(QRect()); 
     97 
     98        painter->restore(); 
     99    } 
     100 
     101    if (option->state & (QStyle::State_Selected | QStyle::State_HasFocus)) 
     102        qt_graphicsItem_highlightSelected(this, painter, option); 
     103} 
     104*/ 
    64105 
    65106Point::Point(int symbol, QColor color, int size, QGraphicsItem* parent): QGraphicsObject(parent), 
  • source/orangeqt/point.h

    r9377 r9378  
    4545    int state; 
    4646    bool transparent; 
     47}; 
     48 
     49class LabelItem : public QGraphicsTextItem 
     50{ 
     51public: 
     52    LabelItem(QGraphicsItem *parent = 0); 
     53    LabelItem(const QString &text, QGraphicsItem *parent = 0); 
     54    ~LabelItem(); 
    4755}; 
    4856 
     
    164172    static QHash<PointData, QPixmap> pixmap_cache; 
    165173 
    166     QGraphicsTextItem* label; 
     174    LabelItem* label; 
    167175 
    168176private: 
Note: See TracChangeset for help on using the changeset viewer.