22 #define YUILogComponent "qt-graph" 28 #include "YQApplication.h" 35 YQGraph::YQGraph(YWidget* parent,
const string& filename,
const string& layoutAlgorithm)
36 :
QY2Graph(filename, layoutAlgorithm, (QWidget*) parent->widgetRep()),
37 YGraph(parent, filename, layoutAlgorithm)
45 YQGraph::YQGraph(YWidget* parent,
void* graph)
46 :
QY2Graph((graph_t*)graph, (QWidget*) parent->widgetRep()),
47 YGraph(parent, (graph_t*) graph)
63 connect(
this, SIGNAL(backgroundContextMenuEvent(QContextMenuEvent*)),
64 this, SLOT(backgroundContextMenu(QContextMenuEvent*)));
66 connect(
this, SIGNAL(nodeContextMenuEvent(QContextMenuEvent*,
const QString&)),
67 this, SLOT(nodeContextMenu(QContextMenuEvent*,
const QString&)));
69 connect(
this, SIGNAL(nodeDoubleClickEvent(QMouseEvent*,
const QString&)),
70 this, SLOT(nodeDoubleClick(QMouseEvent*,
const QString&)));
75 YQGraph::renderGraph(
const string& filename,
const string& layoutAlgorithm)
77 QY2Graph::renderGraph(filename, layoutAlgorithm);
82 YQGraph::renderGraph(
void* graph)
84 QY2Graph::renderGraph((graph_t*)graph);
91 return std::min(160, sizeHint().width());
98 return std::min(120, sizeHint().height());
105 resize(newWidth, newHeight);
110 YQGraph::backgroundContextMenu(QContextMenuEvent* event)
112 if (notifyContextMenu())
114 lastActivatedNode.clear();
115 YQUI::yqApp()->setContextMenuPos(event->globalPos());
116 YQUI::ui()->sendEvent(
new YWidgetEvent(
this, YEvent::ContextMenuActivated));
122 YQGraph::nodeContextMenu(QContextMenuEvent* event,
const QString& name)
124 if (notifyContextMenu())
126 lastActivatedNode = name.toStdString();
127 YQUI::yqApp()->setContextMenuPos(event->globalPos());
128 YQUI::ui()->sendEvent(
new YWidgetEvent(
this, YEvent::ContextMenuActivated));
134 YQGraph::nodeDoubleClick(QMouseEvent* event,
const QString& name)
138 lastActivatedNode = name.toStdString();
139 YQUI::ui()->sendEvent(
new YWidgetEvent(
this, YEvent::Activated));
144 #include "YQGraph.moc" virtual int preferredWidth()
Preferred width of the widget.
The QY2Graph widget shows a graph layouted by graphviz in a QGraphicsView/QGraphicsScene.
virtual void setSize(int newWidth, int newHeight)
Set the new size of the widget.
virtual int preferredHeight()
Preferred height of the widget.