OSDN Git Service

a2移行前のバックアップ。 master
authorwordring <kouichi_pm@users.osdn.me>
Thu, 10 Sep 2015 15:10:25 +0000 (00:10 +0900)
committerwordring <kouichi_pm@users.osdn.me>
Thu, 10 Sep 2015 15:10:25 +0000 (00:10 +0900)
24 files changed:
proxy/main.cpp
proxy/proxy.pro
proxy/tmcandidatewidget.cpp
proxy/tmcandidatewidget.h
proxy/tmclientconnection.cpp [moved from proxy/tmsocket.cpp with 87% similarity]
proxy/tmclientconnection.h [moved from proxy/tmsocket.h with 88% similarity]
proxy/tmdatabase.h
proxy/tmeditorwidget.cpp
proxy/tmeditorwidget.h
proxy/tmservice.cpp
proxy/tmservice.h
proxy/tmtext.cpp
proxy/tmtext.h
proxy/wordring.rc [deleted file]
widgets/ExpandPanel/ExpandPanel.pro [new file with mode: 0644]
widgets/ExpandPanel/expandpanel.cpp [new file with mode: 0644]
widgets/ExpandPanel/expandpanel.h [new file with mode: 0644]
widgets/ExpandPanel/expandplaintextedit.cpp [new file with mode: 0644]
widgets/ExpandPanel/expandplaintextedit.h [new file with mode: 0644]
widgets/ExpandPanelTest/ExpandPanelTest.pro [new file with mode: 0644]
widgets/ExpandPanelTest/main.cpp [new file with mode: 0644]
widgets/ExpandPanelTest/mainwindow.cpp [new file with mode: 0644]
widgets/ExpandPanelTest/mainwindow.h [new file with mode: 0644]
widgets/widgets.pro

index 5170b65..eea07b0 100644 (file)
@@ -1,7 +1,7 @@
 #include "mainwindow.h"
 #include "tmeditorwidget.h"
 
-#include "tmsocket.h"
+#include "tmclientconnection.h"
 #include "httpserver.h"
 #include "tmhttp.h"
 #include "tmservice.h"
@@ -123,11 +123,11 @@ int main(int argc, char *argv[])
                settings.setValue("Database/root", path);
        }
 #ifdef QT_DEBUG
-       settings.setValue("WordringConnection/url", "ws://wordring.net/ws");
+       settings.setValue("ServerConnection/url", "ws://wordring.net/ws");
 #else
-       if(remove) settings.remove("WordringConnection/url");
-       if(!settings.contains("WordringConnection/url"))
-               settings.setValue("WordringConnection/url", "ws://wordring.net/ws");
+       if(remove) settings.remove("ServerConnection/url");
+       if(!settings.contains("ServerConnection/url"))
+               settings.setValue("ServerConnection/url", "ws://wordring.net/ws");
 #endif
        TM::Service *service = new TM::Service(&settings, &a);
 
index 47c57f4..37801cf 100644 (file)
@@ -15,24 +15,24 @@ SOURCES += main.cpp\
        mainwindow.cpp \
        tmhttp.cpp \
        tmservice.cpp \
-       tmsocket.cpp \
        textwidget.cpp \
        tmtext.cpp \
        tmdatabase.cpp \
        tmcandidatewidget.cpp \
        tmeditorwidget.cpp \
-       tmcandidate.cpp
+       tmcandidate.cpp \
+    tmclientconnection.cpp
 
 HEADERS  += mainwindow.h \
        tmhttp.h \
        tmservice.h \
-       tmsocket.h \
        textwidget.h \
        tmtext.h \
        tmdatabase.h \
        tmcandidatewidget.h \
        tmeditorwidget.h \
-       tmcandidate.h
+       tmcandidate.h \
+    tmclientconnection.h
 
 DEFINES += PROXYSRCDIR=\\\"$$PWD\\\"
 #INCLUDEPATH += $$PWD/../language
index 972c732..8be4242 100644 (file)
@@ -1,7 +1,7 @@
 #include "tmcandidatewidget.h"
 #include "settings.h"
 #include "tmservice.h"
-#include "tmsocket.h"
+#include "tmclientconnection.h"
 
 #include <QToolBar>
 #include <QAction>
@@ -33,7 +33,7 @@ TM::CandidateWidget::CandidateWidget(Settings *settings, Service *service, QWidg
        connect(m_search, SIGNAL(triggered(bool)), this, SLOT(onSearchTriggered(bool)));
 }
 
-void TM::CandidateWidget::attach(SocketConnection *connection)
+void TM::CandidateWidget::attach(ClientConnection *connection)
 {
        if(m_connection == connection) return;
        if(m_connection) detach(connection);
@@ -42,7 +42,7 @@ void TM::CandidateWidget::attach(SocketConnection *connection)
        m_connection = connection;
 }
 
-void TM::CandidateWidget::detach(SocketConnection *connection)
+void TM::CandidateWidget::detach(ClientConnection *connection)
 {
        if(m_connection != connection) return;
 
index 0a2e005..5e0eb51 100644 (file)
@@ -16,7 +16,7 @@ namespace TM
 {
 
 class Service;
-class SocketConnection;
+class ClientConnection;
 
 class CandidateWidget : public QWidget
 {
@@ -24,8 +24,8 @@ class CandidateWidget : public QWidget
 public:
        CandidateWidget(Settings *settings, Service *service, QWidget *parent = 0);
 
-       void attach(SocketConnection *connection);
-       void detach(SocketConnection *connection);
+       void attach(ClientConnection *connection);
+       void detach(ClientConnection *connection);
 
        void clear();
        void append(QString text);
@@ -38,7 +38,7 @@ private:
        Settings *m_settings;
        Service *m_service;
 
-       SocketConnection *m_connection;
+       ClientConnection *m_connection;
 
        QToolBar *m_toolbar;
        QAction *m_search;
similarity index 87%
rename from proxy/tmsocket.cpp
rename to proxy/tmclientconnection.cpp
index 7d37c05..47112f5 100644 (file)
@@ -1,4 +1,4 @@
-#include "tmsocket.h"
+#include "tmclientconnection.h"
 #include "tmservice.h"
 #include "tmeditorwidget.h"
 #include "tmcandidatewidget.h"
@@ -48,9 +48,9 @@ TM::HtmlData::pointer TM::HtmlData::create(HtmlNode node_, int begin_, int tail_
        return pointer(new HtmlData(node_, begin_, tail_));
 }
 
-// SocketConnection -----------------------------------------------------------
+// ClientConnection -----------------------------------------------------------
 
-TM::SocketConnection::SocketConnection(Settings *settings, Service *service,
+TM::ClientConnection::ClientConnection(Settings *settings, Service *service,
                                                                        QWebSocket *socket)
        : QObject(socket)
        , m_settings(settings)
@@ -67,14 +67,14 @@ TM::SocketConnection::SocketConnection(Settings *settings, Service *service,
                        this, SLOT(onBinaryMessageReceived(QByteArray const&)));
 }
 
-TM::SocketConnection::~SocketConnection()
+TM::ClientConnection::~ClientConnection()
 {
        m_service->editor_widget()->detach(this);
        m_service->candidate_widget()->detach(this);
        m_service->detach(this);
 }
 
-TM::TextSegmentList::pointer TM::SocketConnection::segment_list()
+TM::TextSegmentList::pointer TM::ClientConnection::segment_list()
 {
        return m_segments;
 }
@@ -82,7 +82,7 @@ TM::TextSegmentList::pointer TM::SocketConnection::segment_list()
 /*!
  * \brief サーバからの文検索の結果、呼び出されます。
  */
-void TM::SocketConnection::insert_sentence(
+void TM::ClientConnection::insert_sentence(
                QString sstring, QString tstring,
                quint32 previous_crc, quint32 next_crc, QByteArray json)
 {
@@ -99,19 +99,19 @@ void TM::SocketConnection::insert_sentence(
        }
 }
 
-QWebSocket* TM::SocketConnection::socket()
+QWebSocket* TM::ClientConnection::socket()
 {
        QWebSocket * result = qobject_cast<QWebSocket*>(parent());
        return result;
 }
 
-void TM::SocketConnection::send_message(QString const &message)
+void TM::ClientConnection::send_message(QString const &message)
 {
        QWebSocket *ws = socket();
        if(ws) ws->sendTextMessage(message);
 }
 
-void TM::SocketConnection::send_message(QJsonObject const &json)
+void TM::ClientConnection::send_message(QJsonObject const &json)
 {
        QJsonDocument doc;
        doc.setObject(json);
@@ -123,7 +123,7 @@ void TM::SocketConnection::send_message(QJsonObject const &json)
  *
  * エディタから呼び出されます。
  */
-void TM::SocketConnection::save_sentence(TextSentence::pointer sentence)
+void TM::ClientConnection::save_sentence(TextSentence::pointer sentence)
 {
        assert(sentence->ssentence());
        if(!sentence->tsentence()) return;
@@ -167,7 +167,7 @@ void TM::SocketConnection::save_sentence(TextSentence::pointer sentence)
  * 呼び出されたとき、訳文はありません。
  * そこで、remove系がサービスに依頼する時は、原文を引数として渡します。
  */
-void TM::SocketConnection::remove_sentence(TextSentence::pointer sentence)
+void TM::ClientConnection::remove_sentence(TextSentence::pointer sentence)
 {
        assert(sentence->ssentence());
 
@@ -187,7 +187,7 @@ void TM::SocketConnection::remove_sentence(TextSentence::pointer sentence)
  *
  * サーバの検索結果の場合、訳文IDは、まだ付いていない。
  */
-void TM::SocketConnection::sentence_found(
+void TM::ClientConnection::sentence_found(
                sentence_data_type result,
                TextSentence::pointer sentence)
 {
@@ -203,16 +203,16 @@ void TM::SocketConnection::sentence_found(
        set_segment(segment_id, segment->to_html());
 }
 
-void TM::SocketConnection::sentence_inserted(TextSentence::pointer)
+void TM::ClientConnection::sentence_inserted(TextSentence::pointer)
 {
 }
 
-void TM::SocketConnection::changeEditMode(bool edit_mode)
+void TM::ClientConnection::changeEditMode(bool edit_mode)
 {
        set_edit_mode(edit_mode);
 }
 
-void TM::SocketConnection::changeLanguage()
+void TM::ClientConnection::changeLanguage()
 {
        QJsonObject json;
        json["cmd"] = "reload";
@@ -225,7 +225,7 @@ void TM::SocketConnection::changeLanguage()
  * ブラウザは、編集モードにある場合、クリックでedit_segmentを発行します。
  * 編集モードではリンクのクリックは無効です。
  */
-void TM::SocketConnection::set_edit_mode(bool edit_mode)
+void TM::ClientConnection::set_edit_mode(bool edit_mode)
 {
        QJsonObject json;
        json["cmd"] = "set_edit_mode";
@@ -238,7 +238,7 @@ void TM::SocketConnection::set_edit_mode(bool edit_mode)
  * \param segment_id セグメントのID。
  * \param html セグメントに対応するHTML文字列。
  */
-void TM::SocketConnection::set_segment(int segment_id, QString html)
+void TM::ClientConnection::set_segment(int segment_id, QString html)
 {
        QJsonObject json;
        json["cmd"] = "set_segment";
@@ -251,7 +251,7 @@ void TM::SocketConnection::set_segment(int segment_id, QString html)
  * \brief ウェブブラウザ上でクリックされ、edit_segmentコマンドが発行されたときに
  * 呼び出されます。
  */
-void TM::SocketConnection::do_edit_segment(QJsonObject const &json)
+void TM::ClientConnection::do_edit_segment(QJsonObject const &json)
 {
        assert(json.contains("segment_id"));
        if(!json.contains("segment_id")) return;
@@ -270,7 +270,7 @@ void TM::SocketConnection::do_edit_segment(QJsonObject const &json)
  * \brief ウェブブラウザ上でドキュメントがフォーカスを取得し、
  * focusコマンドが発行されたときに呼び出されます。
  */
-void TM::SocketConnection::do_focus(QJsonObject const &)
+void TM::ClientConnection::do_focus(QJsonObject const &)
 {
        set_edit_mode(m_service->editor_widget()->edit_mode());
 
@@ -283,12 +283,12 @@ void TM::SocketConnection::do_focus(QJsonObject const &)
                m_service->editor_widget()->set_segment(m_segments->current_segment());
 }
 
-void TM::SocketConnection::do_blur(QJsonObject const &)
+void TM::ClientConnection::do_blur(QJsonObject const &)
 {
        //m_editor_widget->detach(this);
 }
 
-void TM::SocketConnection::do_load(QJsonObject const &json)
+void TM::ClientConnection::do_load(QJsonObject const &json)
 {
        set_edit_mode(m_service->editor_widget()->edit_mode());
 
@@ -304,7 +304,7 @@ void TM::SocketConnection::do_load(QJsonObject const &json)
  * セグメント全体の検索が終わった時点でブラウザへsegment_loaded応答を返します。
  * ブラウザは、segment_loadedを受けて、そのセグメントをクリック可能にします。
  */
-void TM::SocketConnection::do_load_segment(QJsonObject const &json)
+void TM::ClientConnection::do_load_segment(QJsonObject const &json)
 {
        assert(json.contains("segment_id"));
        int segment_id = json["segment_id"].toString().toInt();
@@ -320,7 +320,7 @@ void TM::SocketConnection::do_load_segment(QJsonObject const &json)
                m_service->find_sentence(sentence);
 }
 
-void TM::SocketConnection::onTextMessageReceived(QString const &message)
+void TM::ClientConnection::onTextMessageReceived(QString const &message)
 {
        QJsonObject json = QJsonDocument::fromJson(message.toUtf8()).object();
        QString cmd = json["cmd"].toString();
@@ -331,7 +331,7 @@ void TM::SocketConnection::onTextMessageReceived(QString const &message)
        else if(cmd == "load_segment") do_load_segment(json);
 }
 
-void TM::SocketConnection::onBinaryMessageReceived(QByteArray const &message)
+void TM::ClientConnection::onBinaryMessageReceived(QByteArray const &message)
 {
        qDebug() << message;
 }
@@ -377,7 +377,7 @@ void TM::SocketServer::onNewConnection()
 {
        QWebSocket *socket = m_server->nextPendingConnection();
        connect(socket, SIGNAL(disconnected()), this, SLOT(onDisconnected()));
-       new SocketConnection(m_settings, m_service, socket);
+       new ClientConnection(m_settings, m_service, socket);
        m_sockets.push_back(socket);
 }
 
similarity index 88%
rename from proxy/tmsocket.h
rename to proxy/tmclientconnection.h
index 8e657f2..014e161 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef TMSOCKET_H
-#define TMSOCKET_H
+#ifndef TMCLIENTCONNECTION_H
+#define TMCLIENTCONNECTION_H
 
 #include "html.h"
 #include "text.h"
@@ -30,18 +30,18 @@ namespace TM
 
 class Service;
 
-class SocketConnection : public QObject
+class ClientConnection : public QObject
 {
        Q_OBJECT
 
 public:
-       typedef QPointer<SocketConnection> pointer;
+       typedef QPointer<ClientConnection> pointer;
        typedef QMap<int, TextSegment::pointer> segment_map_type;
        typedef segment_map_type::iterator segment_map_iterator;
 
 public:
-       SocketConnection(Settings *settings, Service *service, QWebSocket *socket);
-       virtual ~SocketConnection();
+       ClientConnection(Settings *settings, Service *service, QWebSocket *socket);
+       virtual ~ClientConnection();
 
        //
        TextSegmentList::pointer segment_list();
@@ -125,8 +125,8 @@ private:
        QList<QWebSocket*> m_sockets;
 };
 
-Q_DECLARE_METATYPE(SocketConnection::pointer)
+Q_DECLARE_METATYPE(ClientConnection::pointer)
 
 } // namespace TM
 
-#endif // TMSOCKET_H
+#endif // TMCLIENTCONNECTION_H
index 0d6074c..6e884b3 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef TMDATABASE_H
 #define TMDATABASE_H
 
-#include "tmsocket.h"
+#include "tmclientconnection.h"
 #include "tmtext.h"
 
 #include <QObject>
index daf44a5..47cb9d7 100644 (file)
@@ -1,6 +1,6 @@
 #include "tmeditorwidget.h"
 #include "tmservice.h"
-#include "tmsocket.h"
+#include "tmclientconnection.h"
 #include "tmtext.h"
 
 #include "settings.h"
@@ -85,7 +85,7 @@ TM::EditorWidget::EditorWidget(Settings *settings, Service *service, QWidget *pa
  * \brief ブラウザ上でドキュメントがフォーカスを取得したとき、
  * SocketConnectionから呼び出されます。
  */
-void TM::EditorWidget::attach(SocketConnection *socket)
+void TM::EditorWidget::attach(ClientConnection *socket)
 {
        if(m_socket == socket) return;
        if(m_socket) detach(m_socket);
@@ -101,7 +101,7 @@ void TM::EditorWidget::attach(SocketConnection *socket)
  * \brief ブラウザ上でドキュメントがフォーカスを取得することで、
  * 現在のSocketConnectionがフォーカスを失った時に呼び出されます。
  */
-void TM::EditorWidget::detach(SocketConnection *connection)
+void TM::EditorWidget::detach(ClientConnection *connection)
 {
        if(m_socket != connection) return;
 
index 4fb00a6..f7ac3ed 100644 (file)
@@ -3,7 +3,7 @@
 
 #include "tmtext.h"
 #include "textwidget.h"
-#include "tmsocket.h"
+#include "tmclientconnection.h"
 
 #include "html.h"
 #include "language.h"
@@ -40,7 +40,7 @@ namespace TM
 {
 
 class Service;
-//class SocketConnection;
+//class ClientConnection;
 class Editor;
 class SourcePanel;
 class TargetPanel;
@@ -51,8 +51,8 @@ class EditorWidget : public QWidget
 public:
        EditorWidget(Settings *settings, Service *service, QWidget *parent = 0);
 
-       void attach(SocketConnection *socket);
-       void detach(SocketConnection *connection);
+       void attach(ClientConnection *socket);
+       void detach(ClientConnection *connection);
 
        void set_http_port(quint16 http_port);
 
@@ -89,7 +89,7 @@ private:
        Service *m_service;
        Settings *m_settings;
        quint16 m_http_port;
-       SocketConnection *m_socket;
+       ClientConnection *m_socket;
 
        QToolBar *m_toolbar;
        QAction *m_edit_mode;
index 6146cf7..96565c9 100644 (file)
@@ -4,7 +4,7 @@
 #include "settings.h"
 #include "tmdatabase.h"
 
-#include "tmsocket.h"
+#include "tmclientconnection.h"
 
 #include "tmeditorwidget.h"
 #include "tmcandidatewidget.h"
@@ -27,9 +27,9 @@
 
 #include "debug.h"
 
-// WordringConnection ---------------------------------------------------------
+// ServerConnection ---------------------------------------------------------
 
-TM::WordringConnection::WordringConnection(Settings *settings, Service *service)
+TM::ServerConnection::ServerConnection(Settings *settings, Service *service)
        : QObject(service)
        , m_settings(settings)
        , m_socket(nullptr)
@@ -38,7 +38,7 @@ TM::WordringConnection::WordringConnection(Settings *settings, Service *service)
 {
 }
 
-bool TM::WordringConnection::find_sentence(sentence_data_type const &sdata)
+bool TM::ServerConnection::find_sentence(sentence_data_type const &sdata)
 {
        if(m_request_limit < m_requests.size()) return false;
 
@@ -64,7 +64,7 @@ bool TM::WordringConnection::find_sentence(sentence_data_type const &sdata)
        return true;
 }
 
-bool TM::WordringConnection::insert_sentence(
+bool TM::ServerConnection::insert_sentence(
                sentence_data_type const &sdata,
                sentence_data_type const & tdata)
 {
@@ -115,7 +115,7 @@ bool TM::WordringConnection::insert_sentence(
 /*!
  * \brief サーバから訳文を消去します。
  */
-bool TM::WordringConnection::remove_sentence(
+bool TM::ServerConnection::remove_sentence(
                sentence_data_type const &sdata,
                sentence_data_type const &)
 {
@@ -141,22 +141,22 @@ bool TM::WordringConnection::remove_sentence(
        return true;
 }
 
-void TM::WordringConnection::onConnected()
+void TM::ServerConnection::onConnected()
 {
-       qDebug() << "WordringConnection::onConnected()";
+       qDebug() << "ServerConnection::onConnected()";
        send();
 }
 
-void TM::WordringConnection::onDisconnected()
+void TM::ServerConnection::onDisconnected()
 {
        if(m_socket) m_socket->deleteLater();
        m_socket = nullptr;
 }
 
-void TM::WordringConnection::onError(QAbstractSocket::SocketError e)
+void TM::ServerConnection::onError(QAbstractSocket::SocketError e)
 {
-       qDebug() << "WordringConnection::onError()";
-       if(m_socket) qDebug() << "WordringConnection::onError" << m_socket->errorString();
+       qDebug() << "ServerConnection::onError()";
+       if(m_socket) qDebug() << "ServerConnection::onError" << m_socket->errorString();
 
        if(e == QAbstractSocket::RemoteHostClosedError) return;
        //if(!m_request_limit) return;
@@ -182,7 +182,7 @@ void TM::WordringConnection::onError(QAbstractSocket::SocketError e)
        */
 }
 
-void TM::WordringConnection::onTextMessageReceived(QString const &message)
+void TM::ServerConnection::onTextMessageReceived(QString const &message)
 {
        QJsonParseError jerror;
        QJsonDocument jdocument = QJsonDocument::fromJson(message.toUtf8(), &jerror);
@@ -201,14 +201,14 @@ void TM::WordringConnection::onTextMessageReceived(QString const &message)
        if(cmd == "found") sentence_found(json);
 }
 
-void TM::WordringConnection::onBinaryMessageReceived(QByteArray const &)
+void TM::ServerConnection::onBinaryMessageReceived(QByteArray const &)
 {
        assert(false);
 }
 
-void TM::WordringConnection::open()
+void TM::ServerConnection::open()
 {
-       assert(m_settings->contains("WordringConnection/url"));
+       assert(m_settings->contains("ServerConnection/url"));
        m_socket = new QWebSocket("", QWebSocketProtocol::VersionLatest, this);
 
        connect(m_socket, SIGNAL(connected()), this, SLOT(onConnected()));
@@ -220,11 +220,11 @@ void TM::WordringConnection::open()
        connect(m_socket, SIGNAL(binaryMessageReceived(QByteArray)),
                        this, SLOT(onBinaryMessageReceived(QByteArray)));
 
-       QString url = m_settings->value("WordringConnection/url").toString();
+       QString url = m_settings->value("ServerConnection/url").toString();
        m_socket->open(QUrl(url));
 }
 
-void TM::WordringConnection::send()
+void TM::ServerConnection::send()
 {
        if(m_request_limit < m_requests.size()) // 制限値を超えているか検査。
        {
@@ -242,7 +242,7 @@ void TM::WordringConnection::send()
        }
 }
 
-void TM::WordringConnection::sentence_found(QJsonObject json)
+void TM::ServerConnection::sentence_found(QJsonObject json)
 {
        QString site      = json["site"].toString();
        int     scode     = json["scode"].toInt();
@@ -312,7 +312,7 @@ TM::Service::Service(Settings *settings, QObject *parent)
        , m_candidate_widget(nullptr)
        , m_database_thread(new QThread(this))
        , m_database(new Database(settings, this))
-       , m_wordring(new WordringConnection(settings, this))
+       , m_wordring(new ServerConnection(settings, this))
        , m_current_connection(nullptr)
 {
        qRegisterMetaType<sentence_data_type>();
@@ -341,7 +341,7 @@ void TM::Service::set_editor_widget(EditorWidget *editor) { m_editor_widget = ed
 
 void TM::Service::change_edit_mode(bool mode)
 {
-       for(SocketConnection *connection : m_connections)
+       for(ClientConnection *connection : m_connections)
        {
                connection->set_edit_mode(mode);
        }
@@ -351,17 +351,17 @@ TM::CandidateWidget* TM::Service::candidate_widget() { return m_candidate_widget
 
 void TM::Service::set_candidate_widget(CandidateWidget *candidate) { m_candidate_widget = candidate; }
 
-void TM::Service::attach(SocketConnection *connection)
+void TM::Service::attach(ClientConnection *connection)
 {
        m_connections.insert(connection);
 }
 
-void TM::Service::detach(SocketConnection *connection)
+void TM::Service::detach(ClientConnection *connection)
 {
        m_connections.remove(connection);
 }
 
-void TM::Service::set_current_connection(SocketConnection *connection)
+void TM::Service::set_current_connection(ClientConnection *connection)
 {
        m_current_connection = connection;
 }
@@ -569,7 +569,7 @@ void TM::Service::sentence_found(sentence_data_type result,
        // ブラウザに結果を送る。
        TextSegmentList::pointer segments = sentence->segment_list();
        assert(segments);
-       SocketConnection* connection = segments->connection();
+       ClientConnection* connection = segments->connection();
        assert(connection);
        connection->sentence_found(result, sentence);
 }
@@ -636,7 +636,7 @@ void TM::Service::sentence_found(
        sstring = normalize(result.scode, sstring);
 
        // ブラウザへ通知。
-       for(SocketConnection *connection : m_connections)
+       for(ClientConnection *connection : m_connections)
        {
                TextSegmentList::pointer segments = connection->segment_list();
                QList<TextSentence::pointer> i = segments->find_sentences(sstring);
index 5b1f31f..a57ce20 100644 (file)
@@ -28,15 +28,15 @@ namespace TM
 {
 
 class Service;
-class SocketConnection;
+class ClientConnection;
 class EditorWidget;
 class CandidateWidget;
 
-class WordringConnection : public QObject
+class ServerConnection : public QObject
 {
        Q_OBJECT
 public:
-       WordringConnection(Settings *settings, Service *service);
+       ServerConnection(Settings *settings, Service *service);
 
        bool find_sentence(sentence_data_type const &sdata);
 
@@ -76,7 +76,7 @@ class Service : public QObject
 
        struct dispatcher_data_type
        {
-               SocketConnection::pointer connection;
+               ClientConnection::pointer connection;
                int segment_id;
                int index;
        };
@@ -93,10 +93,10 @@ public:
 
        void change_edit_mode(bool mode);
 
-       // SocketConnection
-       void attach(SocketConnection *connection);
-       void detach(SocketConnection *connection);
-       void set_current_connection(SocketConnection *connection);
+       // ClientConnection
+       void attach(ClientConnection *connection);
+       void detach(ClientConnection *connection);
+       void set_current_connection(ClientConnection *connection);
 
        // CRC32
        void setup_crc_table();
@@ -158,10 +158,10 @@ private:
        QThread *m_database_thread;
        Database *m_database;
 
-       WordringConnection *m_wordring;
+       ServerConnection *m_wordring;
 
-       QSet<SocketConnection*> m_connections;
-       SocketConnection *m_current_connection;
+       QSet<ClientConnection*> m_connections;
+       ClientConnection *m_current_connection;
 
        quint32 m_crc_table[256];
 };
index a5680ee..f3260e4 100644 (file)
@@ -1061,7 +1061,7 @@ TM::TextSegment::pointer TM::TextSegment::create(
 // TextSegmentList ------------------------------------------------------------
 
 TM::TextSegmentList::TextSegmentList(
-               Service *service, SocketConnection *connection)
+               Service *service, ClientConnection *connection)
        : m_service(service)
        , m_connection(connection)
        , m_scode(0)
@@ -1132,7 +1132,7 @@ void TM::TextSegmentList::set_current_sentence(TextSentence::pointer sentence)
        m_current_sentence = sentence;
 }
 
-TM::SocketConnection* TM::TextSegmentList::connection() { return m_connection; }
+TM::ClientConnection* TM::TextSegmentList::connection() { return m_connection; }
 
 int TM::TextSegmentList::scode() const { assert(m_scode); return m_scode; }
 
@@ -1151,7 +1151,7 @@ QString TM::TextSegmentList::host() const { return m_url.host(); }
 TM::Service* TM::TextSegmentList::service() { return m_service; }
 
 TM::TextSegmentList::pointer TM::TextSegmentList::create(
-               Service *service, SocketConnection *connection)
+               Service *service, ClientConnection *connection)
 {
        pointer result(new TextSegmentList(service, connection));
        result->m_self = result;
index 0a1867a..60380d7 100644 (file)
@@ -20,7 +20,7 @@ namespace TM
 {
 
 class Service;
-class SocketConnection;
+class ClientConnection;
 class TextSegment;
 class TextSegmentList;
 
@@ -337,7 +337,7 @@ public:
        typedef std::weak_ptr<TextSegmentList> weak_pointer;
 
 private:
-       TextSegmentList(Service *service, SocketConnection *connection);
+       TextSegmentList(Service *service, ClientConnection *connection);
 
 public:
        // セグメント・リスト。
@@ -355,7 +355,7 @@ public:
        TextSentence::pointer current_sentence();
        void set_current_sentence(TextSentence::pointer sentence);
 
-       SocketConnection* connection();
+       ClientConnection* connection();
 
        // 言語コード。
        int scode() const;
@@ -371,12 +371,12 @@ public:
        // 親子。
        Service* service();
 
-       static pointer create(Service *service, SocketConnection *connection);
+       static pointer create(Service *service, ClientConnection *connection);
 
 private:
        Service *m_service;
 
-       SocketConnection *m_connection; /*!< このリストのオーナーとなるコネクション */
+       ClientConnection *m_connection; /*!< このリストのオーナーとなるコネクション */
        int m_scode; /*!< 原文言語コード。*/
        int m_tcode; /*!< 訳文言語コード。 */
        QUrl m_url;
diff --git a/proxy/wordring.rc b/proxy/wordring.rc
deleted file mode 100644 (file)
index bd39dfd..0000000
+++ /dev/null
@@ -1 +0,0 @@
-IDI_ICON       ICON    DISCARDABLE     wordring.ico
\ No newline at end of file
diff --git a/widgets/ExpandPanel/ExpandPanel.pro b/widgets/ExpandPanel/ExpandPanel.pro
new file mode 100644 (file)
index 0000000..e5b4df9
--- /dev/null
@@ -0,0 +1,21 @@
+#-------------------------------------------------
+#
+# Project created by QtCreator 2015-09-06T14:50:59
+#
+#-------------------------------------------------
+
+QT       += widgets
+
+TARGET = ExpandPanel
+TEMPLATE = lib
+CONFIG += staticlib
+
+SOURCES += expandpanel.cpp \
+    expandplaintextedit.cpp
+
+HEADERS += expandpanel.h \
+    expandplaintextedit.h
+unix {
+    target.path = /usr/lib
+    INSTALLS += target
+}
diff --git a/widgets/ExpandPanel/expandpanel.cpp b/widgets/ExpandPanel/expandpanel.cpp
new file mode 100644 (file)
index 0000000..4e1096e
--- /dev/null
@@ -0,0 +1,36 @@
+#include "expandpanel.h"
+
+
+// ExpandContainer ------------------------------------------------------------
+
+ExpandContainer::ExpandContainer(ScrollWidget *parent)
+       : QWidget(parent)
+       , m_parent(parent)
+{
+
+}
+
+void ExpandContainer::do_child_resize(QWidget *child)
+{
+       ;
+}
+
+// VerticalContainer ----------------------------------------------------------
+
+
+VerticalContainer::VerticalContainer(ScrollWidget *parent)
+       : ExpandContainer(parent)
+{
+
+}
+
+void VerticalContainer::resizeEvent(QResizeEvent *ev)
+{
+       if(ev->size().width() == ev->oldSize().width()) return;
+       for(QWidget* child : m_children) child->setFixedWidth(ev->size().width());
+}
+
+
+
+
+
diff --git a/widgets/ExpandPanel/expandpanel.h b/widgets/ExpandPanel/expandpanel.h
new file mode 100644 (file)
index 0000000..0175dec
--- /dev/null
@@ -0,0 +1,79 @@
+#ifndef EXPANDPANEL_H
+#define EXPANDPANEL_H
+
+#include <QWidget>
+#include <QScrollArea>
+
+#include <QResizeEvent>
+
+#include <QList>
+
+#include <QDebug>
+
+//class ExpandContainer;
+class VerticalContainer;
+class ScrollWidget;
+
+class ExpandContainer : public QWidget
+{
+       Q_OBJECT
+public:
+       ExpandContainer(ScrollWidget *parent);
+
+       void do_child_resize(QWidget *child);
+
+protected:
+       ScrollWidget *m_parent;
+       QList<QWidget*> m_children;
+};
+
+template <typename T>
+class ExpandPanel : public T
+{
+public:
+       ExpandPanel(ExpandContainer *parent)
+               : T(parent)
+               , m_parent_container(parent)
+       {
+               setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
+               //setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+               //setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+       }
+
+protected:
+       void resizeEvent(QResizeEvent *ev)
+       {
+               if(ev->oldSize() == ev->size()) return;
+               T::resizeEvent(ev);
+               ExpandContainer *ec =
+                               qobject_cast<ExpandContainer*>(parentWidget());
+               if(ec) ec->do_child_resize(this);
+       }
+
+private:
+       ExpandContainer *m_parent_container;
+};
+
+class VerticalContainer : public ExpandContainer
+{
+       Q_OBJECT
+public:
+       VerticalContainer(ScrollWidget *parent);
+
+protected:
+       void resizeEvent(QResizeEvent *ev);
+
+private:
+};
+
+class ScrollWidget : public QScrollArea
+{
+       Q_OBJECT
+public:
+       explicit ScrollWidget(QWidget *parent);
+
+private:
+       ExpandContainer *m_expand_container;
+};
+
+#endif // EXPANDPANEL_H
diff --git a/widgets/ExpandPanel/expandplaintextedit.cpp b/widgets/ExpandPanel/expandplaintextedit.cpp
new file mode 100644 (file)
index 0000000..8a90d85
--- /dev/null
@@ -0,0 +1,8 @@
+#include "expandplaintextedit.h"
+
+ExpandPlainTextEdit::ExpandPlainTextEdit(ExpandContainer *parent)
+       : ExpandPanel<QPlainTextEdit>(parent)
+{
+
+}
+
diff --git a/widgets/ExpandPanel/expandplaintextedit.h b/widgets/ExpandPanel/expandplaintextedit.h
new file mode 100644 (file)
index 0000000..97e7acf
--- /dev/null
@@ -0,0 +1,15 @@
+#ifndef EXPANDPLAINTEXTEDIT_H
+#define EXPANDPLAINTEXTEDIT_H
+
+#include "expandpanel.h"
+
+#include <QPlainTextEdit>
+
+class ExpandPlainTextEdit : public ExpandPanel<QPlainTextEdit>
+{
+       Q_OBJECT
+public:
+       ExpandPlainTextEdit(ExpandContainer *parent = 0);
+};
+
+#endif // EXPANDPLAINTEXTEDIT_H
diff --git a/widgets/ExpandPanelTest/ExpandPanelTest.pro b/widgets/ExpandPanelTest/ExpandPanelTest.pro
new file mode 100644 (file)
index 0000000..b1b4415
--- /dev/null
@@ -0,0 +1,31 @@
+#-------------------------------------------------
+#
+# Project created by QtCreator 2015-09-06T14:58:23
+#
+#-------------------------------------------------
+
+QT       += core gui
+
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+TARGET = ExpandPanelTest
+TEMPLATE = app
+
+
+SOURCES += main.cpp\
+               mainwindow.cpp
+
+HEADERS  += mainwindow.h
+
+win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../ExpandPanel/release/ -lExpandPanel
+else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../ExpandPanel/debug/ -lExpandPanel
+else:unix: LIBS += -L$$OUT_PWD/../ExpandPanel/ -lExpandPanel
+
+INCLUDEPATH += $$PWD/../ExpandPanel
+DEPENDPATH += $$PWD/../ExpandPanel
+
+win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../ExpandPanel/release/libExpandPanel.a
+else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../ExpandPanel/debug/libExpandPanel.a
+else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../ExpandPanel/release/ExpandPanel.lib
+else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../ExpandPanel/debug/ExpandPanel.lib
+else:unix: PRE_TARGETDEPS += $$OUT_PWD/../ExpandPanel/libExpandPanel.a
diff --git a/widgets/ExpandPanelTest/main.cpp b/widgets/ExpandPanelTest/main.cpp
new file mode 100644 (file)
index 0000000..f215115
--- /dev/null
@@ -0,0 +1,53 @@
+//#include "mainwindow.h"
+
+//#include "expandpanel.h"
+
+#include <QApplication>
+#include <QLabel>
+#include <QVBoxLayout>
+#include <QSizePolicy>
+
+int main(int argc, char *argv[])
+{
+       QApplication a(argc, argv);
+/*
+       ExpandLabel el;
+       el.setTextFormat(Qt::RichText);
+       el.setText("test2<br><b>test3 test3 test3 test3 test3 test3 test3 test3 test3 test3 test3 test3 test3 test3 </b>");
+       el.show();
+
+       el.setWordWrap(true);
+
+       el.setFixedWidth(320);
+       //QLabel l;
+       //l.setText("test");
+       //l.show();
+       //MainWindow w;
+       //w.show();
+*/
+       QString text = QString::fromLocal8Bit(
+               "<h1>ラベルの実験</h1>"
+               "<p><b>test</b> <s>test</s> test test test test test test"
+               " test test test test test test test test test test test</p>");
+
+       QWidget w;
+       w.setLayout(new QVBoxLayout(&w));
+       QLabel *l1 = new QLabel(text);
+       l1->setFrameStyle(QFrame::StyledPanel | QFrame::Raised);
+       l1->setWordWrap(true);
+       l1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+       l1->setMargin(10);
+
+       QLabel *l2 = new QLabel("test2<br><b>test3 <s>test3</s> test3 test3 test3 test3 test3 test3 test3 test3 test3 test3 test3 test3 </b>");
+       l2->setWordWrap(true);
+       l2->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
+       w.layout()->addWidget(l1);
+       w.layout()->addWidget(l2);
+
+       w.layout()->setAlignment(Qt::AlignTop);
+       w.layout()->setMargin(2);
+       //w.layout()->setAlignment(l1, Qt::AlignTop);
+       //w.layout()->setAlignment(l2, Qt::AlignTop);
+       w.show();
+       return a.exec();
+}
diff --git a/widgets/ExpandPanelTest/mainwindow.cpp b/widgets/ExpandPanelTest/mainwindow.cpp
new file mode 100644 (file)
index 0000000..be909bd
--- /dev/null
@@ -0,0 +1,11 @@
+#include "mainwindow.h"
+
+MainWindow::MainWindow(QWidget *parent)
+       : QMainWindow(parent)
+{
+}
+
+MainWindow::~MainWindow()
+{
+
+}
diff --git a/widgets/ExpandPanelTest/mainwindow.h b/widgets/ExpandPanelTest/mainwindow.h
new file mode 100644 (file)
index 0000000..22e5efe
--- /dev/null
@@ -0,0 +1,29 @@
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include "expandpanel.h"
+#include <QLabel>
+#include <QPlainTextEdit>
+
+#include <QMainWindow>
+
+class MainWindow : public QMainWindow
+{
+       Q_OBJECT
+
+public:
+       MainWindow(QWidget *parent = 0);
+       ~MainWindow();
+};
+
+class ExpandLabel : public ExpandPanel<QLabel>
+{
+       Q_OBJECT
+
+public:
+       ExpandLabel(ExpandContainer *parent = 0) : ExpandPanel(parent) { }
+
+};
+
+
+#endif // MAINWINDOW_H
index 9671085..870d1c0 100644 (file)
@@ -1 +1,5 @@
 TEMPLATE = subdirs
+
+SUBDIRS += \
+       ExpandPanel \
+    ExpandPanelTest