#include "mainwindow.h"
#include "tmeditorwidget.h"
-#include "tmsocket.h"
+#include "tmclientconnection.h"
#include "httpserver.h"
#include "tmhttp.h"
#include "tmservice.h"
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);
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
#include "tmcandidatewidget.h"
#include "settings.h"
#include "tmservice.h"
-#include "tmsocket.h"
+#include "tmclientconnection.h"
#include <QToolBar>
#include <QAction>
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);
m_connection = connection;
}
-void TM::CandidateWidget::detach(SocketConnection *connection)
+void TM::CandidateWidget::detach(ClientConnection *connection)
{
if(m_connection != connection) return;
{
class Service;
-class SocketConnection;
+class ClientConnection;
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);
Settings *m_settings;
Service *m_service;
- SocketConnection *m_connection;
+ ClientConnection *m_connection;
QToolBar *m_toolbar;
QAction *m_search;
-#include "tmsocket.h"
+#include "tmclientconnection.h"
#include "tmservice.h"
#include "tmeditorwidget.h"
#include "tmcandidatewidget.h"
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)
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;
}
/*!
* \brief サーバからの文検索の結果、呼び出されます。
*/
-void TM::SocketConnection::insert_sentence(
+void TM::ClientConnection::insert_sentence(
QString sstring, QString tstring,
quint32 previous_crc, quint32 next_crc, QByteArray json)
{
}
}
-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);
*
* エディタから呼び出されます。
*/
-void TM::SocketConnection::save_sentence(TextSentence::pointer sentence)
+void TM::ClientConnection::save_sentence(TextSentence::pointer sentence)
{
assert(sentence->ssentence());
if(!sentence->tsentence()) return;
* 呼び出されたとき、訳文はありません。
* そこで、remove系がサービスに依頼する時は、原文を引数として渡します。
*/
-void TM::SocketConnection::remove_sentence(TextSentence::pointer sentence)
+void TM::ClientConnection::remove_sentence(TextSentence::pointer sentence)
{
assert(sentence->ssentence());
*
* サーバの検索結果の場合、訳文IDは、まだ付いていない。
*/
-void TM::SocketConnection::sentence_found(
+void TM::ClientConnection::sentence_found(
sentence_data_type result,
TextSentence::pointer sentence)
{
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";
* ブラウザは、編集モードにある場合、クリックで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";
* \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";
* \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;
* \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());
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());
* セグメント全体の検索が終わった時点でブラウザへ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();
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();
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;
}
{
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);
}
-#ifndef TMSOCKET_H
-#define TMSOCKET_H
+#ifndef TMCLIENTCONNECTION_H
+#define TMCLIENTCONNECTION_H
#include "html.h"
#include "text.h"
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();
QList<QWebSocket*> m_sockets;
};
-Q_DECLARE_METATYPE(SocketConnection::pointer)
+Q_DECLARE_METATYPE(ClientConnection::pointer)
} // namespace TM
-#endif // TMSOCKET_H
+#endif // TMCLIENTCONNECTION_H
#ifndef TMDATABASE_H
#define TMDATABASE_H
-#include "tmsocket.h"
+#include "tmclientconnection.h"
#include "tmtext.h"
#include <QObject>
#include "tmeditorwidget.h"
#include "tmservice.h"
-#include "tmsocket.h"
+#include "tmclientconnection.h"
#include "tmtext.h"
#include "settings.h"
* \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);
* \brief ブラウザ上でドキュメントがフォーカスを取得することで、
* 現在のSocketConnectionがフォーカスを失った時に呼び出されます。
*/
-void TM::EditorWidget::detach(SocketConnection *connection)
+void TM::EditorWidget::detach(ClientConnection *connection)
{
if(m_socket != connection) return;
#include "tmtext.h"
#include "textwidget.h"
-#include "tmsocket.h"
+#include "tmclientconnection.h"
#include "html.h"
#include "language.h"
{
class Service;
-//class SocketConnection;
+//class ClientConnection;
class Editor;
class SourcePanel;
class TargetPanel;
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);
Service *m_service;
Settings *m_settings;
quint16 m_http_port;
- SocketConnection *m_socket;
+ ClientConnection *m_socket;
QToolBar *m_toolbar;
QAction *m_edit_mode;
#include "settings.h"
#include "tmdatabase.h"
-#include "tmsocket.h"
+#include "tmclientconnection.h"
#include "tmeditorwidget.h"
#include "tmcandidatewidget.h"
#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)
{
}
-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;
return true;
}
-bool TM::WordringConnection::insert_sentence(
+bool TM::ServerConnection::insert_sentence(
sentence_data_type const &sdata,
sentence_data_type const & tdata)
{
/*!
* \brief サーバから訳文を消去します。
*/
-bool TM::WordringConnection::remove_sentence(
+bool TM::ServerConnection::remove_sentence(
sentence_data_type const &sdata,
sentence_data_type const &)
{
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;
*/
}
-void TM::WordringConnection::onTextMessageReceived(QString const &message)
+void TM::ServerConnection::onTextMessageReceived(QString const &message)
{
QJsonParseError jerror;
QJsonDocument jdocument = QJsonDocument::fromJson(message.toUtf8(), &jerror);
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()));
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()) // 制限値を超えているか検査。
{
}
}
-void TM::WordringConnection::sentence_found(QJsonObject json)
+void TM::ServerConnection::sentence_found(QJsonObject json)
{
QString site = json["site"].toString();
int scode = json["scode"].toInt();
, 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>();
void TM::Service::change_edit_mode(bool mode)
{
- for(SocketConnection *connection : m_connections)
+ for(ClientConnection *connection : m_connections)
{
connection->set_edit_mode(mode);
}
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;
}
// ブラウザに結果を送る。
TextSegmentList::pointer segments = sentence->segment_list();
assert(segments);
- SocketConnection* connection = segments->connection();
+ ClientConnection* connection = segments->connection();
assert(connection);
connection->sentence_found(result, sentence);
}
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);
{
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);
struct dispatcher_data_type
{
- SocketConnection::pointer connection;
+ ClientConnection::pointer connection;
int segment_id;
int index;
};
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();
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];
};
// TextSegmentList ------------------------------------------------------------
TM::TextSegmentList::TextSegmentList(
- Service *service, SocketConnection *connection)
+ Service *service, ClientConnection *connection)
: m_service(service)
, m_connection(connection)
, m_scode(0)
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; }
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;
{
class Service;
-class SocketConnection;
+class ClientConnection;
class TextSegment;
class TextSegmentList;
typedef std::weak_ptr<TextSegmentList> weak_pointer;
private:
- TextSegmentList(Service *service, SocketConnection *connection);
+ TextSegmentList(Service *service, ClientConnection *connection);
public:
// セグメント・リスト。
TextSentence::pointer current_sentence();
void set_current_sentence(TextSentence::pointer sentence);
- SocketConnection* connection();
+ ClientConnection* connection();
// 言語コード。
int scode() const;
// 親子。
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;
+++ /dev/null
-IDI_ICON ICON DISCARDABLE wordring.ico
\ No newline at end of file
--- /dev/null
+#-------------------------------------------------
+#
+# 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
+}
--- /dev/null
+#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());
+}
+
+
+
+
+
--- /dev/null
+#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
--- /dev/null
+#include "expandplaintextedit.h"
+
+ExpandPlainTextEdit::ExpandPlainTextEdit(ExpandContainer *parent)
+ : ExpandPanel<QPlainTextEdit>(parent)
+{
+
+}
+
--- /dev/null
+#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
--- /dev/null
+#-------------------------------------------------
+#
+# 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
--- /dev/null
+//#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();
+}
--- /dev/null
+#include "mainwindow.h"
+
+MainWindow::MainWindow(QWidget *parent)
+ : QMainWindow(parent)
+{
+}
+
+MainWindow::~MainWindow()
+{
+
+}
--- /dev/null
+#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
TEMPLATE = subdirs
+
+SUBDIRS += \
+ ExpandPanel \
+ ExpandPanelTest