28 #define YUILogComponent "qt-graph"
34 #include "YQApplication.h"
41 YQGraph::YQGraph(YWidget* parent,
const string& filename,
const string& layoutAlgorithm)
42 :
QY2Graph(filename, layoutAlgorithm, (QWidget*) parent->widgetRep()),
43 YGraph(parent, filename, layoutAlgorithm)
51 YQGraph::YQGraph(YWidget* parent,
void* graph)
52 :
QY2Graph((graph_t*)graph, (QWidget*) parent->widgetRep()),
53 YGraph(parent, (graph_t*) graph)
69 connect(
this, SIGNAL(backgroundContextMenuEvent(QContextMenuEvent*)),
70 this, SLOT(backgroundContextMenu(QContextMenuEvent*)));
72 connect(
this, SIGNAL(nodeContextMenuEvent(QContextMenuEvent*,
const QString&)),
73 this, SLOT(nodeContextMenu(QContextMenuEvent*,
const QString&)));
75 connect(
this, SIGNAL(nodeDoubleClickEvent(QMouseEvent*,
const QString&)),
76 this, SLOT(nodeDoubleClick(QMouseEvent*,
const QString&)));
81 YQGraph::renderGraph(
const string& filename,
const string& layoutAlgorithm)
83 QY2Graph::renderGraph(filename, layoutAlgorithm);
88 YQGraph::renderGraph(
void* graph)
90 QY2Graph::renderGraph((graph_t*)graph);
97 return std::min(160, sizeHint().width());
104 return std::min(120, sizeHint().height());
111 resize(newWidth, newHeight);
116 YQGraph::backgroundContextMenu(QContextMenuEvent* event)
118 if (notifyContextMenu())
120 lastActivatedNode.clear();
121 YQUI::yqApp()->setContextMenuPos(event->globalPos());
122 YQUI::ui()->sendEvent(
new YWidgetEvent(
this, YEvent::ContextMenuActivated));
128 YQGraph::nodeContextMenu(QContextMenuEvent* event,
const QString& name)
130 if (notifyContextMenu())
132 lastActivatedNode = name.toStdString();
133 YQUI::yqApp()->setContextMenuPos(event->globalPos());
134 YQUI::ui()->sendEvent(
new YWidgetEvent(
this, YEvent::ContextMenuActivated));
140 YQGraph::nodeDoubleClick(QMouseEvent* event,
const QString& name)
144 lastActivatedNode = name.toStdString();
145 YQUI::ui()->sendEvent(
new YWidgetEvent(
this, YEvent::Activated));
150 #include "YQGraph.moc"
virtual int preferredWidth()
virtual void setSize(int newWidth, int newHeight)
virtual int preferredHeight()