37 #include "hbaction.h" |
37 #include "hbaction.h" |
38 #include "hbselectioncontrol_p.h" |
38 #include "hbselectioncontrol_p.h" |
39 #include "hbmeshlayout_p.h" |
39 #include "hbmeshlayout_p.h" |
40 #include "hbsmileyengine_p.h" |
40 #include "hbsmileyengine_p.h" |
41 #include "hbinputeditorinterface.h" |
41 #include "hbinputeditorinterface.h" |
42 #include "hbfeaturemanager_p.h" |
42 #include "hbfeaturemanager_r.h" |
43 #include "hbtextmeasurementutility_p.h" |
43 #include "hbtextmeasurementutility_p.h" |
44 #include "hbtapgesture.h" |
44 #include "hbtapgesture.h" |
45 #include "hbpangesture.h" |
45 #include "hbpangesture.h" |
46 |
46 |
47 #include <QApplication> |
47 #include <QApplication> |
686 \reimp |
686 \reimp |
687 */ |
687 */ |
688 void HbAbstractEdit::updatePrimitives() |
688 void HbAbstractEdit::updatePrimitives() |
689 { |
689 { |
690 Q_D(HbAbstractEdit); |
690 Q_D(HbAbstractEdit); |
691 HbWidget::updatePrimitives(); |
691 |
692 |
692 if (d->polished && !d->updatePrimitivesInProgress) { |
693 if (d->scrollArea) { |
693 |
694 d->doc->setTextWidth(d->scrollArea->size().width()); |
694 d->updatePrimitivesInProgress = true; |
695 if(d->placeholderDoc) { |
695 |
696 d->placeholderDoc->setTextWidth(d->scrollArea->size().width()); |
696 HbWidget::updatePrimitives(); |
697 } |
697 |
698 } |
698 if (d->scrollArea) { |
699 QRectF canvasGeom(QRectF(QPointF(0,0),d->doc->size())); |
699 d->doc->setTextWidth(d->scrollArea->size().width()); |
700 if(d->scrollArea) { |
700 if(d->placeholderDoc) { |
701 canvasGeom.setHeight(qMax(d->scrollArea->size().height(), d->doc->size().height())); |
701 d->placeholderDoc->setTextWidth(d->scrollArea->size().width()); |
702 } |
702 } |
703 //Changed from setGeometry() to setPreferredSize() because it causes |
703 } |
704 //weird input behavior otherwise. |
704 QRectF canvasGeom(QRectF(QPointF(0,0),d->doc->size())); |
705 d->canvas->setPreferredSize(canvasGeom.size()); |
705 if(d->scrollArea) { |
706 d->ensureCursorVisible(); |
706 canvasGeom.setHeight(qMax(d->scrollArea->size().height(), d->doc->size().height())); |
707 if (d->selectionControl) { |
707 } |
708 d->selectionControl->updatePrimitives(); |
708 |
709 } |
709 d->canvas->setGeometry(canvasGeom); |
710 |
710 |
|
711 d->ensureCursorVisible(); |
|
712 if (d->selectionControl) { |
|
713 d->selectionControl->updatePrimitives(); |
|
714 } |
|
715 |
|
716 d->updatePrimitivesInProgress=false; |
|
717 } |
711 } |
718 } |
712 |
719 |
713 /*! |
720 /*! |
714 Replaces editor content with \a text. |
721 Replaces editor content with \a text. |
715 |
722 |
1117 \sa QTextCursor::movePosition() |
1117 \sa QTextCursor::movePosition() |
1118 */ |
1118 */ |
1119 void HbAbstractEdit::moveCursor(QTextCursor::MoveOperation op, QTextCursor::MoveMode mode) |
1119 void HbAbstractEdit::moveCursor(QTextCursor::MoveOperation op, QTextCursor::MoveMode mode) |
1120 { |
1120 { |
1121 Q_D(HbAbstractEdit); |
1121 Q_D(HbAbstractEdit); |
1122 //const QTextCursor oldCursor = d->cursor; |
|
1123 d->cursor.movePosition(op, mode); |
1122 d->cursor.movePosition(op, mode); |
1124 |
1123 |
1125 d->updateCurrentCharFormat(); |
1124 d->updateCurrentCharFormat(); |
1126 |
1125 |
1127 d->ensureCursorVisible(); |
1126 d->ensureCursorVisible(); |
1285 |
1284 |
1286 menu->setAttribute(Hb::InputMethodNeutral); |
1285 menu->setAttribute(Hb::InputMethodNeutral); |
1287 |
1286 |
1288 if (d->cursor.hasSelection() && d->canCut()) { |
1287 if (d->cursor.hasSelection() && d->canCut()) { |
1289 connect( |
1288 connect( |
1290 menu->addAction("Cut"), SIGNAL(triggered()), |
1289 menu->addAction(hbTrId("txt_common_menu_cut")), SIGNAL(triggered()), |
1291 this, SLOT(cut())); |
1290 this, SLOT(cut())); |
1292 } |
1291 } |
1293 if (d->cursor.hasSelection() && d->canCopy()) { |
1292 if (d->cursor.hasSelection() && d->canCopy()) { |
1294 connect( |
1293 connect( |
1295 menu->addAction("Copy"), SIGNAL(triggered()), |
1294 menu->addAction(hbTrId("txt_common_menu_copy")), SIGNAL(triggered()), |
1296 this, SLOT(copy())); |
1295 this, SLOT(copy())); |
1297 } |
1296 } |
1298 if (!d->cursor.hasSelection() && !d->doc->isEmpty() && d->canCopy()){ |
1297 if (!d->cursor.hasSelection() && !d->doc->isEmpty() && d->canCopy()){ |
1299 connect( |
1298 connect( |
1300 menu->addAction("Select"), SIGNAL(triggered()), |
1299 menu->addAction(hbTrId("txt_common_menu_select")), SIGNAL(triggered()), |
1301 this, SLOT(selectClickedWord())); |
1300 this, SLOT(selectClickedWord())); |
1302 connect( |
1301 connect( |
1303 menu->addAction("Select all"), SIGNAL(triggered()), |
1302 menu->addAction(hbTrId("txt_common_menu_select_all_contents")), SIGNAL(triggered()), |
1304 this, SLOT(selectAll())); |
1303 this, SLOT(selectAll())); |
1305 } |
1304 } |
1306 if (d->canPaste()) { |
1305 if (d->canPaste()) { |
1307 connect( |
1306 connect( |
1308 menu->addAction("Paste"), SIGNAL(triggered()), |
1307 menu->addAction(hbTrId("txt_common_menu_paste")), SIGNAL(triggered()), |
1309 this, SLOT(paste())); |
1308 this, SLOT(paste())); |
1310 } |
1309 } |
1311 if (d->cursor.hasSelection()) { |
1310 if (d->cursor.hasSelection()) { |
1312 connect( |
1311 connect( |
1313 menu->addAction("Deselect"), SIGNAL(triggered()), |
1312 menu->addAction(hbTrId("txt_common_menu_deselect")), SIGNAL(triggered()), |
1314 this, SLOT(deselect())); |
1313 this, SLOT(deselect())); |
1315 } |
1314 } |
1316 if (d->canFormat()) { |
1315 if (d->canFormat()) { |
1317 connect( |
1316 connect( |
1318 menu->addAction("Format"), SIGNAL(triggered()), |
1317 menu->addAction(hbTrId("txt_common_menu_format")), SIGNAL(triggered()), |
1319 this, SLOT(format())); |
1318 this, SLOT(format())); |
1320 } |
1319 } |
1321 |
1320 |
1322 emit aboutToShowContextMenu(menu, d->tapPosition); |
1321 emit aboutToShowContextMenu(menu, d->tapPosition); |
1323 |
1322 |