1 #ifndef GRAPH_ANALYSIS_GUI_ITEMS_EDGELABEL_HPP 2 #define GRAPH_ANALYSIS_GUI_ITEMS_EDGELABEL_HPP 4 #include <QGraphicsTextItem> 6 #include <base-logging/Logging.hpp> 26 EdgeLabel(
const std::string& label, QGraphicsItem* item)
27 : QGraphicsTextItem(QString(label.c_str()), item)
29 setFlags(QGraphicsTextItem::ItemIsSelectable | ItemIsFocusable);
30 setTextInteractionFlags(Qt::NoTextInteraction);
31 setAcceptDrops(
false);
41 if(on && textInteractionFlags() == Qt::NoTextInteraction)
43 setTextInteractionFlags(Qt::TextEditorInteraction);
44 setFocus(Qt::MouseFocusReason);
48 QTextCursor c = textCursor();
49 c.select(QTextCursor::Document);
53 }
else if(!on && textInteractionFlags() == Qt::TextEditorInteraction)
55 setTextInteractionFlags(Qt::NoTextInteraction);
56 QTextCursor c = this->textCursor();
58 this->setTextCursor(c);
72 QVariant
itemChange(QGraphicsItem::GraphicsItemChange change,
const QVariant& value)
74 if(change == QGraphicsItem::ItemSelectedChange)
76 LOG_DEBUG_S <<
"itemChange ' " << this->toPlainText().toStdString()
77 <<
"', selected: '" << value.toString().toStdString() <<
"'";
79 if(change == QGraphicsItem::ItemSelectedChange && textInteractionFlags() != Qt::NoTextInteraction && !value.toBool())
84 return QGraphicsTextItem::itemChange(change, value);
91 #endif // GRAPH_ANALYSIS_GUI_ITEMS_EDGELABEL_HPP EdgeLabel(const std::string &label, QGraphicsItem *item)
constructor
Definition: EdgeLabel.hpp:26
void setTextInteraction(bool on, bool selectAll=false)
toggles direct editing options of the displayed text
Definition: EdgeLabel.hpp:39
Main namespace of the graph analysis library.
Definition: BFS.cpp:3
QVariant itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
qt item change callback
Definition: EdgeLabel.hpp:72
graphical edge text label implementation
Definition: EdgeLabel.hpp:18
void setText(const QString &label)
updates displayed text string to 'label'
Definition: EdgeLabel.hpp:64