void DocumentMarkerController::addMarker(Range* range, DocumentMarker::MarkerType type, const String& description) { for (TextIterator markedText(range); !markedText.atEnd(); markedText.advance()) { RefPtr<Range> textPiece = markedText.range(); addMarker(&textPiece->startContainer(), DocumentMarker(type, textPiece->startOffset(), textPiece->endOffset(), description)); } }
void DocumentMarkerController::addDictationResultMarker(Range* range, const RetainPtr<id>& metadata) { for (TextIterator markedText(range); !markedText.atEnd(); markedText.advance()) { RefPtr<Range> textPiece = markedText.range(); addMarker(&textPiece->startContainer(), DocumentMarker(DocumentMarker::DictationResult, textPiece->startOffset(), textPiece->endOffset(), String(), Vector<String>(), metadata)); } }
void DocumentMarkerController::addMarker(Range* range, DocumentMarker::MarkerType type, const String& description, const Vector<String>& interpretations, const RetainPtr<id>& metadata) { for (TextIterator markedText(range); !markedText.atEnd(); markedText.advance()) { RefPtr<Range> textPiece = markedText.range(); addMarker(&textPiece->startContainer(), DocumentMarker(type, textPiece->startOffset(), textPiece->endOffset(), description, interpretations, metadata)); } }
void QLineEdit::cut() { QString t = markedText(); if ( !t.isEmpty() ) { copy(); del(); } }
void DocumentMarkerController::addMarker(Range* range, DocumentMarker::MarkerType type, const String& description) { // Use a TextIterator to visit the potentially multiple nodes the range covers. for (TextIterator markedText(range); !markedText.atEnd(); markedText.advance()) { RefPtr<Range> textPiece = markedText.range(); addMarker(textPiece->startContainer(), DocumentMarker(type, textPiece->startOffset(), textPiece->endOffset(), description)); } }
void DocumentMarkerController::addDictationResultMarker(Range* range, const RetainPtr<id>& metadata) { // Use a TextIterator to visit the potentially multiple nodes the range covers. for (TextIterator markedText(range); !markedText.atEnd(); markedText.advance()) { RefPtr<Range> textPiece = markedText.range(); addMarker(textPiece->startContainer(), DocumentMarker(DocumentMarker::DictationResult, textPiece->startOffset(), textPiece->endOffset(), String(), Vector<String>(), metadata)); } }
void DocumentMarkerController::addMarker(Range* range, DocumentMarker::MarkerType type, String description, const Vector<String>& interpretations, const RetainPtr<id>& metadata) { // Use a TextIterator to visit the potentially multiple nodes the range covers. for (TextIterator markedText(range); !markedText.atEnd(); markedText.advance()) { RefPtr<Range> textPiece = markedText.range(); addMarker(textPiece->startContainer(), DocumentMarker(type, textPiece->startOffset(), textPiece->endOffset(), description, interpretations, metadata)); } }
void DocumentMarkerController::addTextMatchMarker(const Range* range, bool activeMatch) { for (TextIterator markedText(range); !markedText.atEnd(); markedText.advance()) { RefPtr<Range> textPiece = markedText.range(); unsigned startOffset = textPiece->startOffset(); unsigned endOffset = textPiece->endOffset(); addMarker(&textPiece->startContainer(), DocumentMarker(startOffset, endOffset, activeMatch)); } }
void QLineEdit::copy() const { QString t = markedText(); if ( !t.isEmpty() ) { disconnect( QApplication::clipboard(), SIGNAL(dataChanged()), this, 0); QApplication::clipboard()->setText( t ); connect( QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(clipboardChanged()) ); } }
void DocumentMarkerController::removeMarkers(Range* range, DocumentMarker::MarkerTypes markerTypes, RemovePartiallyOverlappingMarkerOrNot shouldRemovePartiallyOverlappingMarker) { for (TextIterator markedText(range); !markedText.atEnd(); markedText.advance()) { if (!possiblyHasMarkers(markerTypes)) return; ASSERT(!m_markers.isEmpty()); RefPtr<Range> textPiece = markedText.range(); int startOffset = textPiece->startOffset(); int endOffset = textPiece->endOffset(); removeMarkers(textPiece->startContainer(), startOffset, endOffset - startOffset, markerTypes, shouldRemovePartiallyOverlappingMarker); } }
void DocumentMarkerController::addDictationPhraseWithAlternativesMarker(Range* range, const Vector<String>& interpretations) { ASSERT(interpretations.size() > 1); if (interpretations.size() <= 1) return; size_t numberOfAlternatives = interpretations.size() - 1; for (TextIterator markedText(range); !markedText.atEnd(); markedText.advance()) { RefPtr<Range> textPiece = markedText.range(); DocumentMarker marker(DocumentMarker::DictationPhraseWithAlternatives, textPiece->startOffset(), textPiece->endOffset(), "", Vector<String>(numberOfAlternatives), RetainPtr<id>()); for (size_t i = 0; i < numberOfAlternatives; ++i) marker.setAlternative(interpretations[i + 1], i); addMarker(&textPiece->startContainer(), marker); } }
void MyMultiEdit::mousePressEvent( QMouseEvent *e ) { if( e->button() == RightButton ) { if( hasMarkedText() ) { QString marked = markedText(); if( marked.left(7) == "http://" || marked.left(6) == "ftp://" ) { web_menu->popup(QCursor::pos()); web_menu->grabMouse(); } } return; } QMultiLineEdit::mousePressEvent(e); return; }
void DocumentMarkerController::addTextMatchMarker(const Range* range, bool activeMatch) { // Use a TextIterator to visit the potentially multiple nodes the range covers. for (TextIterator markedText(range); !markedText.atEnd(); markedText.advance()) { RefPtr<Range> textPiece = markedText.range(); unsigned startOffset = textPiece->startOffset(); unsigned endOffset = textPiece->endOffset(); addMarker(textPiece->startContainer(), DocumentMarker(startOffset, endOffset, activeMatch)); if (endOffset > startOffset) { // Rendered rects for markers in WebKit are not populated until each time // the markers are painted. However, we need it to happen sooner, because // the whole purpose of tickmarks on the scrollbar is to show where // matches off-screen are (that haven't been painted yet). Node* node = textPiece->startContainer(); Vector<RenderedDocumentMarker*> markers = markersFor(node); markers[markers.size() - 1]->setRenderedRect(range->boundingBox()); } } }
void MyMultiEdit::openUrl() { QString command; int pos; if( hasMarkedText() ) { QString marked = markedText(); if( marked.left(7) == "http://" ) { command = exec_http; command.detach(); if( (pos = exec_http.find("%u")) == -1 ) { command += " " + marked + " &"; } else { command.remove(pos, 2); command = command.insert(pos, marked); command += " &"; } system((const char *) command); //debug("exec: %s", (const char *) command ); } else if( marked.left(6) == "ftp://" ) { command = exec_ftp; command.detach(); if( (pos = exec_ftp.find("%u")) == -1 ) { command += " " + marked + " &"; } else { command.remove(pos, 2); command = command.insert(pos, marked); command += " &"; } system((const char *) command); //debug("exec: %s", (const char *) command ); } } }
void QLineEdit::mousePressEvent( QMouseEvent *e ) { killTimers(); d->inDoubleClick = FALSE; int margin = frame() ? 4 : 2; cursorPos = offset + xPosToCursorPos( &tbuf[(int)offset], fontMetrics(), e->pos().x() - margin, width() - 2*margin ); if ( e->button() == MidButton ) { #if defined(_WS_X11_) insert( QApplication::clipboard()->text() ); #else if ( style() == MotifStyle ) insert( QApplication::clipboard()->text() ); #endif return; #if 0 // it works, but it's wait until we have an API } else if ( hasMarkedText() && e->button() == LeftButton && ( (markAnchor > cursorPos && markDrag < cursorPos) || (markAnchor < cursorPos && markDrag > cursorPos) ) ) { QTextDrag * tdo = new QTextDrag( this ); tdo->setText( markedText() ); tdo->dragCopy(); delete tdo; return; #endif } int m1 = minMark(); int m2 = maxMark(); markAnchor = cursorPos; newMark( markAnchor, FALSE ); if ( cursorPos > m2 ) m2 = cursorPos; else if ( cursorPos < m1 ) m1 = cursorPos; repaintArea( m1, m2 ); dragScrolling = FALSE; }