add protobuf
diff --git a/chatbuf.proto b/chatbuf.proto
new file mode 100644
index 0000000..ca1312c
--- /dev/null
+++ b/chatbuf.proto
@@ -0,0 +1,13 @@
+package SyncDemo;
+
+message ChatMessage {
+ required string msgData = 1;
+ required string to = 2;
+ required string from = 3;
+ required int32 timestamp = 4;
+ enum ChatMessageType {
+ CHAT = 0;
+ OTHER = 1;
+ }
+ optional ChatMessageType type = 5;
+}
diff --git a/digesttreescene.cpp b/digesttreescene.cpp
index 8d2d5c3..483f1f6 100644
--- a/digesttreescene.cpp
+++ b/digesttreescene.cpp
@@ -8,11 +8,15 @@
#include <assert.h>
static const double Pi = 3.14159265358979323846264338327950288419717;
-static double TwoPi = 2.0 * Pi;
DigestTreeScene::DigestTreeScene(QWidget *parent)
: QGraphicsScene(parent)
{
+}
+
+void
+DigestTreeScene::plot() {
+ clear();
m_graph.clear();
std::vector<ogdf::node> v(5);
for (int i = 0; i < 5; i++)
@@ -74,11 +78,12 @@
QLineF line1(sourceArrowP1, sourceArrowP2);
addLine(line1, QPen(Qt::black));
- addPolygon(QPolygonF() << sourceArrowP0<< sourceArrowP1 << sourceArrowP2, QPen(Qt::black), QBrush(Qt::black));
+ addPolygon(QPolygonF() << sourceArrowP0<< sourceArrowP1 << sourceArrowP2, QPen(Qt::black), QBrush(Qt::black));
}
- /*
ogdf::node n;
+ int i = 0;
+ std::string s[5] = {"A", "B", "C", "D", "E"};
forall_nodes(n, m_graph) {
double x = GA.x(n);
@@ -86,12 +91,10 @@
double w = GA.width(n);
double h = GA.height(n);
QRectF boundingRect(x, y, w, h);
-
addEllipse(boundingRect, QPen(Qt::black), QBrush(Qt::green));
- QGraphicsTextItem *text = addText(QString(GA.labelNode(n).cstr()));
- text->setPos(x, y);
-
+ QGraphicsTextItem *text = addText(s[i].c_str());
+ text->setPos(x + 5, y + 5);
+ i++;
}
- */
}
diff --git a/digesttreescene.h b/digesttreescene.h
index 0d98f7e..1915c2f 100644
--- a/digesttreescene.h
+++ b/digesttreescene.h
@@ -11,6 +11,7 @@
public:
DigestTreeScene(QWidget *parent = 0);
+ void plot();
private:
ogdf::Graph m_graph;
};
diff --git a/digesttreeviewer.cpp b/digesttreeviewer.cpp
index cb52a9e..631ab92 100644
--- a/digesttreeviewer.cpp
+++ b/digesttreeviewer.cpp
@@ -7,4 +7,6 @@
{
DigestTreeScene *scene = new DigestTreeScene(this);
setScene(scene);
+ scene->plot();
+ scene->plot();
}
diff --git a/sync-demo.pri b/sync-demo.pri
new file mode 100644
index 0000000..88ab350
--- /dev/null
+++ b/sync-demo.pri
@@ -0,0 +1,18 @@
+PROTOPATH += .
+PROTOPATHS =
+for(p, PROTOPATH):PROTOPATHS += --proto_path=$${p}
+
+protobuf_decl.name = protobuf header
+protobuf_decl.input = PROTOS
+protobuf_decl.output = ${QMAKE_FILE_BASE}.pb.h
+protobuf_decl.commands = protoc --cpp_out="." $${PROTOPATHS} ${QMAKE_FILE_NAME}
+protobuf_decl.variable_out = GENERATED_FILES
+QMAKE_EXTRA_COMPILERS += protobuf_decl
+
+protobuf_impl.name = protobuf implementation
+protobuf_impl.input = PROTOS
+protobuf_impl.output = ${QMAKE_FILE_BASE}.pb.cc
+protobuf_impl.depends = ${QMAKE_FILE_BASE}.pb.h
+protobuf_impl.commands = $$escape_expand(\n)
+protobuf_impl.variable_out = GENERATED_SOURCES
+QMAKE_EXTRA_COMPILERS += protobuf_impl
diff --git a/sync-demo.pro b/sync-demo.pro
index b201cb7..ce3ac5a 100644
--- a/sync-demo.pro
+++ b/sync-demo.pro
@@ -11,10 +11,13 @@
FORMS = chatdialog.ui
-QMAKE_CXXFLAGS *= -g
+QMAKE_CXXFLAGS *= -g
+QMAKE_CFLAGS *= -g
QMAKE_LIBDIR *= /opt/local/lib /usr/local/lib /usr/lib ../../../third_party/OGDF/_release
INCLUDEPATH *= /opt/local/include /usr/local/include ../../../third_party/OGDF
-LIBS *= -lccn -lssl -lcrypto -lpthread -lOGDF
+LIBS *= -lccn -lssl -lcrypto -lpthread -lOGDF -lprotobuf
CONFIG += console
+PROTOS = chatbuf.proto
+include (sync-demo.pri)