15 #include <QWebSocketServer>
22 class HtmlData : public RangeData
25 typedef std::shared_ptr<HtmlData> pointer;
27 enum : int { Type = UserData::User + 1, };
30 HtmlData(HtmlNode node_, int begin_, int tail_);
35 static pointer create(HtmlNode node_, int begin_, int tail_);
46 Text::pointer to_text(HtmlRange range);
47 Text::pointer stuff_text(Text::pointer parent, QString const &string);
49 bool is_ignorable_white_space(QChar const &ch);
51 static bool is_white_space(QChar const &ch);
57 class SocketConnection : public QObject
62 SocketConnection(Widget *widget, QWebSocket *socket);
63 virtual ~SocketConnection();
65 //quint16 port() const;
67 void send_message(QString const &message);
68 void send_message(QJsonObject const &json);
70 void set_edit_mode(bool edit_mode);
71 //void set_source_language(int code);
72 //void set_target_language(int code);
75 void editCmd(int id, QString html);
78 void changeEditMode(bool edit_mode);
81 void do_edit(QJsonObject const &json);
82 void do_focus(QJsonObject const &json);
83 void do_blur(QJsonObject const &json);
84 void do_load(QJsonObject const &json);
86 Text::pointer to_text(HtmlRange range) const;
89 void onTextMessageReceived(QString const &message);
90 void onBinaryMessageReceived(QByteArray const &message);
96 int m_source_language;
97 int m_target_language;
101 HtmlDocument m_document;
104 class SocketServer : public QObject
108 SocketServer(Widget *widget, quint16 port, QObject *parent);
110 quint16 port() const;
115 void onNewConnection();
116 void onDisconnected();
119 void attachConnections(QWebSocket* socket);
120 void detachConnections(QWebSocket* socket);
124 QWebSocketServer *m_server;