Skip to content

Commit

Permalink
Sample improvment
Browse files Browse the repository at this point in the history
  • Loading branch information
nbergont committed Mar 25, 2014
1 parent aa53013 commit 564ed98
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 30 deletions.
20 changes: 14 additions & 6 deletions Sample/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ License along with this library.
#include "QGVScene.h"
#include "QGVScene.h"
#include <QMessageBox>
#include <QMenu>

MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
Expand All @@ -32,6 +33,7 @@ MainWindow::MainWindow(QWidget *parent) :

connect(_scene, SIGNAL(nodeContextMenu(QGVNode*)), SLOT(nodeContextMenu(QGVNode*)));
connect(_scene, SIGNAL(nodeDoubleClick(QGVNode*)), SLOT(nodeDoubleClick(QGVNode*)));
connect(_scene, SIGNAL(edgeDoubleClick(QGVEdge*)), SLOT(nodeEdgeClick(QGVEdge*)));
}

MainWindow::~MainWindow()
Expand All @@ -43,11 +45,9 @@ void MainWindow::drawGraph()
{
/*
_scene->loadLayout("digraph test{node [style=filled,fillcolor=white];N1 -> N2;N2 -> N3;N3 -> N4;N4 -> N1;}");
connect(_scene, SIGNAL(nodeContextMenu(QGVNode*)), SLOT(nodeContextMenu(QGVNode*)));
connect(_scene, SIGNAL(nodeDoubleClick(QGVNode*)), SLOT(nodeDoubleClick(QGVNode*)));
ui->graphicsView->setScene(_scene);
return;
*/
_scene->clear();

//Configure scene attributes
_scene->setGraphAttribute("label", "DEMO");
Expand Down Expand Up @@ -120,8 +120,6 @@ void MainWindow::nodeContextMenu(QGVNode *node)
{
//Context menu exemple
QMenu menu(node->label());

menu.addSeparator();
menu.addAction(tr("Informations"));
menu.addAction(tr("Options"));

Expand All @@ -132,5 +130,15 @@ void MainWindow::nodeContextMenu(QGVNode *node)

void MainWindow::nodeDoubleClick(QGVNode *node)
{
QMessageBox::information(this, tr("Node double clicked"), tr("Node %1").arg(node->label()));
QMessageBox::information(this, tr("Node"), tr("Node %1").arg(node->label()));
}

void MainWindow::nodeEdgeClick(QGVEdge *edge)
{
QMessageBox::information(this, tr("Edge"), tr("Edge %1").arg(edge->label()));
}

void MainWindow::on_pushButton_clicked()
{
drawGraph();
}
5 changes: 4 additions & 1 deletion Sample/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@ class MainWindow : public QMainWindow
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
void drawGraph();

private slots:
void drawGraph();
void nodeContextMenu(QGVNode* node);
void nodeDoubleClick(QGVNode* node);
void nodeEdgeClick(QGVEdge *edge);

void on_pushButton_clicked();

private:
Ui::MainWindow *ui;
Expand Down
28 changes: 8 additions & 20 deletions Sample/MainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,17 @@
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
<string>QGV Sample</string>
</property>
<widget class="QWidget" name="centralWidget">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Draw</string>
</property>
</widget>
</item>
<item>
<widget class="QGraphicsViewEc" name="graphicsView">
<property name="renderHints">
Expand All @@ -27,25 +34,6 @@
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>817</width>
<height>21</height>
</rect>
</property>
</widget>
<widget class="QToolBar" name="mainToolBar">
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<widget class="QStatusBar" name="statusBar"/>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
Expand Down
4 changes: 1 addition & 3 deletions Sample/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ int main(int argc, char *argv[])
QApplication a(argc, argv);
MainWindow w;
w.show();

w.drawGraph();

//w.drawGraph();
return a.exec();
}

0 comments on commit 564ed98

Please sign in to comment.