17 #include <QWebSocketServer>
31 class HtmlData : public RangeData
34 typedef std::shared_ptr<HtmlData> pointer;
36 enum : int { Type = UserData::User + 1, };
39 HtmlData(HtmlNode node_, int begin_, int tail_);
44 static pointer create(HtmlNode node_, int begin_, int tail_);
51 * \brief HtmlRangeから構造化テキストに変換するためのクラスです。
56 Text::pointer to_text(HtmlRange range);
57 Text::pointer stuff_text(Text::pointer parent, QString const &string);
59 bool is_ignorable_white_space(QChar const &ch);
61 static bool is_white_space(QChar const &ch);
71 Text::pointer m_source_sentence;
72 Text::pointer m_target_sentence;
73 QJsonArray m_link_data;
81 class SocketConnection : public QObject
86 SocketConnection(Settings *settings, Service *service,
87 EditorWidget *editor_widget, QWebSocket *socket);
88 virtual ~SocketConnection();
90 //quint16 port() const;
92 void send_message(QString const &message);
93 void send_message(QJsonObject const &json);
95 void set_edit_mode(bool edit_mode);
96 //void set_source_language(int code);
97 //void set_target_language(int code);
100 void editCmd(int id, QString html);
103 void changeEditMode(bool edit_mode);
106 void do_edit(QJsonObject const &json);
107 void do_focus(QJsonObject const &json);
108 void do_blur(QJsonObject const &json);
109 void do_load(QJsonObject const &json);
111 Text::pointer to_text(HtmlRange range) const;
114 void onTextMessageReceived(QString const &message);
115 void onBinaryMessageReceived(QByteArray const &message);
118 Settings *m_settings;
124 int m_source_language;
125 int m_target_language;
127 EditorWidget *m_editor_widget;
129 HtmlDocument m_document; /*!< 現在処理中のHTML文書パラグラフを保持 */
130 Text::pointer m_text; /*!< HtmlData付のパラグラフをテキストとして保持 */
131 //QJsonArray m_json; /*!< */
134 class SocketServer : public QObject
138 SocketServer(Settings *settings, Service* service,
139 EditorWidget *editor_widget, QObject *parent);
142 quint16 port() const;
148 void onNewConnection();
149 void onDisconnected();
152 void attachConnections(QWebSocket* socket);
153 void detachConnections(QWebSocket* socket);
157 Settings *m_settings;
160 QWebSocketServer *m_server;
161 QList<QWebSocket*> m_sockets;
163 EditorWidget *m_editor_widget;