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