#include <QDebug>
TranslationWidget::TranslationWidget(Backbone *backbone, QWidget *parent):
- QTextEdit(parent) {
+ QWidget(parent) {
this->backbone = backbone;
#endif
setWindowFlags(windowFlags() | Qt::Window);
- setContextMenuPolicy(Qt::CustomContextMenu);
-
- setReadOnly(true);
+ initializeUI();
- connect(this, SIGNAL(customContextMenuRequested(QPoint)),
+ connect(textEdit, SIGNAL(customContextMenuRequested(QPoint)),
this, SLOT(showContextMenu(QPoint)));
- initializeUI();
+
}
-void TranslationWidget::show(QModelIndex index) {
+
+void TranslationWidget::show() {
QWidget::show();
- clear();
+}
+
+void TranslationWidget::show(QModelIndex index) {
+
+ show();
QString v = index.model()->data(index, Qt::DisplayRole).toString();
Translation* t = backbone->result().value(v);
- setText(t->toHtml());
- update();
+
+ textEdit->clear();
+
+ textEdit->setPlainText(t->toHtml());
+
+ textEdit->repaint(this->rect());
+
}
void TranslationWidget::initializeUI() {
contextMenu->addAction(tr("Copy"), this, SLOT(copy()));
contextMenu->addAction(tr("Paste"), this, SLOT(paste()));
contextMenu->addAction(tr("Select all"), this, SLOT(selectAll()));
+
+ textEdit = new QTextEdit;
+ textEdit->setReadOnly(true);
+ textEdit->setContextMenuPolicy(Qt::CustomContextMenu);
+
+ verticalLayout = new QVBoxLayout;
+ setLayout(verticalLayout);
+ verticalLayout->addWidget(textEdit);
}
void TranslationWidget::showContextMenu(QPoint pos) {