void SonicPiScintilla::transposeChars()
{
  int linenum, index;
  getCursorPosition(&linenum, &index);
  setSelection(linenum, 0, linenum + 1, 0);
  int lineLength = selectedText().size();

  //transpose chars
  if(index > 0){
    if(index < (lineLength - 1)){
      index = index + 1;
    }
    setSelection(linenum, index - 2, linenum, index);
    QString text = selectedText();
    QChar a, b;
    a = text.at(0);
    b = text.at(1);
    QString replacement  = "";
    replacement.append(b);
    replacement.append(a);
    replaceSelectedText(replacement);
  }

  setCursorPosition(linenum, index);
}
Esempio n. 2
0
void TextShow::copy()
{
#if QT_VERSION <= 0x030100
    QApplication::clipboard()->setText(selectedText());
#else
    QApplication::clipboard()->setText(selectedText(),QClipboard::Selection);
#endif
}
Esempio n. 3
0
QTextDrag *TextShow::dragObject(QWidget *parent) const
{
    if (!hasSelectedText())
        return NULL;
#if (COMPAT_QT_VERSION < 0x030000) || (COMPAT_QT_VERSION >= 0x030100)
    if (textFormat() == RichText){
        RichTextDrag *drag = new RichTextDrag(parent);
        drag->setRichText(selectedText());
        return drag;
    }
#endif
    return new QTextDrag(selectedText(), parent );
}
void KCHMViewWindow_KHTMLPart::clipCopy()
{
	QString text = selectedText();
	
	if ( !text.isEmpty() )
		QApplication::clipboard()->setText( text );
}
Esempio n. 5
0
QString Screen::getHistoryLine(int no)
{
  sel_begin = loc(0,no);
  sel_TL = sel_begin;
  sel_BR = loc(columns-1,no);
  return selectedText(false);
}
void DocumentWidget::selectAll()
{
  // pageNr == 0 indicated an invalid page (e.g. page number not yet
  // set)
  if (pageNr == 0)
    return;

  // Get a pointer to the page contents
  RenderedDocumentPage *pageData = documentCache->getPage(pageNr);
  if (pageData == 0) {
    kdDebug(1223) << "DocumentWidget::selectAll() pageData for page #" << pageNr << " is empty" << endl;
    return;
  }

  TextSelection selection;
  // mark everything as selected
  QString selectedText("");
  for(unsigned int i = 0; i < pageData->textBoxList.size(); i++) {
    selectedText += pageData->textBoxList[i].text;
    selectedText += "\n";
  }
  selection.set(pageNr, 0, pageData->textBoxList.size()-1, selectedText);

  selectedRegion = pageData->selectedRegion(selection);

  documentCache->selectText(selection);

  // Re-paint
  update();
}
Esempio n. 7
0
//VOXOX CHANGE by Rolando - 2009.05.11 - method called when lineedit lost focus
void VoxOxToolTipLineEdit::leaveEvent ( QEvent * event ){
	if (QLineEdit::text() == _toolTip || QLineEdit::text().isEmpty()) {//VOXOX CHANGE by Rolando - 2009.05.11 - if current text is equal to tooltip or is empty
		displayToolTipMessage();
		
	}
	else{
		int cursorPositionValue =  cursorPosition();//VOXOX CHANGE by Rolando - 2009.06.02 - gets current Cursor Position
		int intSelectedStart = -1;
		QString stringText;

		if(hasSelectedText()){//VOXOX CHANGE by Rolando - 2009.06.02 - if there is selected text
			stringText = selectedText();//VOXOX CHANGE by Rolando - 2009.06.02 - gets selected text
			intSelectedStart = selectionStart();//VOXOX CHANGE by Rolando - 2009.06.02 - gets position where selection starts		
		}
		
		if(_message == QLineEdit::text()){//VOXOX CHANGE by Rolando - 2009.05.11 - if current text is equal to _message then sets _shortMessage
			QLineEdit::setText(_shortMessage);
		}
		else{//VOXOX CHANGE by Rolando - 2009.05.11 - if current text is not equal to _message then updates _shortMessage and _message and then sets _shortMessage as current text
			updateMessageText(QLineEdit::text());
			QLineEdit::setText(_shortMessage);
		}

		//VOXOX CHANGE by Rolando - 2009.10.13 
		if(intSelectedStart >= 0 && intSelectedStart + stringText.length() <= getMaximumCharsAllowed()){//VOXOX CHANGE by Rolando - 2009.06.02 - if there is a text selected
			setSelection(intSelectedStart, stringText.length());//VOXOX CHANGE by Rolando - 2009.06.02 - as we set the long message in lineedit, we need to set the text was selected
		}

		currentTextChanged(text());
	}
	
	QLineEdit::leaveEvent(event);
	//changeFocusToParent();//VOXOX CHANGE by Rolando - 2009.05.22 - method to send focus to another widget when mouse leaves the lineedit
} 
Esempio n. 8
0
QString LineEdit::handleDCOP(int function, const QStringList& args)
{
  switch (function) {
    case DCOP::text:
      return text();
    case DCOP::setText:
      setWidgetText(args[0]);
      break;
    case DCOP::selection:
      return selectedText();
    case DCOP::setSelection:
      setSelectedWidgetText(args[0]);
      break;
    case DCOP::clear:
      setWidgetText("");
      break;
    case DCOP::setEditable:
      setReadOnly(args[0] == "false" || args[0] == "0");
      break;
    case DCOP::geometry:
    {
      QString geo = QString::number(this->x())+" "+QString::number(this->y())+" "+QString::number(this->width())+" "+QString::number(this->height());
      return geo;
      break;
    }
    case DCOP::hasFocus:
      return QString::number(this->hasFocus());
      break;
    default:
      return KommanderWidget::handleDCOP(function, args);
  }
  return QString();
}
void SonicPiScintilla::toggleComment() {
  beginUndoAction();

  int linenum, cursor;
  getCursorPosition(&linenum, &cursor);

  //select the whole line
  setSelection(linenum, 0, linenum, cursor+1);

  QString selection = selectedText();

  // make sure we don't comment empty lines
  if (selection.length() > 0) {
      // if it's already commented, uncomment
      if (selection[0] == '#') {
          selection.remove(0, 1);
          replaceSelectedText(selection);
          if (cursor > 0) {
              setCursorPosition(linenum, cursor - 1);
          } else {
              setCursorPosition(linenum, cursor);
          }
      } else {
          selection.prepend('#');
          replaceSelectedText(selection);
          setCursorPosition(linenum, cursor + 1);
      }
  }
  deselect();
  endUndoAction();
}
Esempio n. 10
0
void ScrollLine::mouseReleaseEvent( QMouseEvent *event )
{
   mClicked = false;
   GlobalConfigWidget::setClipboard( selectedText() );
   setCursorPosition( cursorPositionAt( event->pos() ) );
   QLineEdit::mouseReleaseEvent( event );
}
Esempio n. 11
0
void SLineEdit::contextMenuEvent(QContextMenuEvent *event)
{
  bool selection = hasSelectedText();
  bool ro = isReadOnly();
  QMenu menu(this);

  if (selection && !ro)
    menu.addAction(SCHAT_ICON(EditCut), tr("Cut"), this, SLOT(cut()));

  if (selection)
    menu.addAction(SCHAT_ICON(EditCopy), tr("Copy"), this, SLOT(cut()));

  if (!ro && !QApplication::clipboard()->text().isEmpty())
    menu.addAction(SCHAT_ICON(EditPaste), tr("Paste"), this, SLOT(paste()));

  if (selection && !ro)
    menu.addAction(SCHAT_ICON(Remove), tr("Delete"), this, SLOT(deleteSelected()));

  if (!menu.isEmpty())
    menu.addSeparator();

  if (!text().isEmpty() && text() != selectedText())
    menu.addAction(SCHAT_ICON(EditSelectAll), tr("Select All"), this, SLOT(selectAll()));

  if (!menu.isEmpty())
    menu.exec(event->globalPos());
}
Esempio n. 12
0
void HelpWindowWidget::selectionChanged()
{
    // The text selection has changed, so let the user know whether some text is
    // now selected

    emit copyTextEnabled(!selectedText().isEmpty());
}
Esempio n. 13
0
void MdiChild::goToSearchResult(int line, int index, QString term)
{
    this->setFocus();
    this->setSelection(line, index, line, index+term.length());
    if(! selectedText().compare(term) == 0)
        goToLine(line);
}
Esempio n. 14
0
void QsciEditor::toggleCase() {

	int lF, iF, lT, iT;

	getSelection( &lF, &iF, &lT, &iT );

	if ( not hasSelectedText() )
		return;

	QString txt = selectedText();
	QString newTxt;

	bool caps = true;

	Q_FOREACH( QChar ch, txt )
		if ( ch.isLetter() )
			caps &= ch.isUpper();

	if ( caps )
		newTxt = txt.toLower();

	else
		newTxt = txt.toUpper();

	removeSelectedText();
	insert( newTxt );

	setSelection( lF, iF, lT, iT );
};
Esempio n. 15
0
void GuidLineEdit::keyPressEvent(QKeyEvent * event)
{
    if (event == QKeySequence::Delete || event->key() == Qt::Key_Backspace)
    {
        int pos = cursorPosition();
        if (event->key() == Qt::Key_Backspace && pos > 0) {
            cursorBackward(false);
            pos = cursorPosition();
        }
        
        QString txt = text();
        QString selected = selectedText();

        if (!selected.isEmpty()) {
            pos = QLineEdit::selectionStart();
            for (int i = pos; i < pos + selected.count(); i++)
                if (txt[i] != QChar('-'))
                    txt[i] = QChar('.');
        }
        else 
            txt[pos] = QChar('.');

        setCursorPosition(0);
        insert(txt);
        setCursorPosition(pos);

        return;
    }

    // Call original event handler
    QLineEdit::keyPressEvent(event);
}
Esempio n. 16
0
int QLabel::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QFrame::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 12)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 12;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QString*>(_v) = text(); break;
        case 1: *reinterpret_cast< Qt::TextFormat*>(_v) = textFormat(); break;
        case 2: _a[0] = const_cast<void*>(reinterpret_cast<const void*>(pixmap())); break;
        case 3: *reinterpret_cast< bool*>(_v) = hasScaledContents(); break;
        case 4: *reinterpret_cast< Qt::Alignment*>(_v) = alignment(); break;
        case 5: *reinterpret_cast< bool*>(_v) = wordWrap(); break;
        case 6: *reinterpret_cast< int*>(_v) = margin(); break;
        case 7: *reinterpret_cast< int*>(_v) = indent(); break;
        case 8: *reinterpret_cast< bool*>(_v) = openExternalLinks(); break;
        case 9: *reinterpret_cast< Qt::TextInteractionFlags*>(_v) = textInteractionFlags(); break;
        case 10: *reinterpret_cast< bool*>(_v) = hasSelectedText(); break;
        case 11: *reinterpret_cast< QString*>(_v) = selectedText(); break;
        }
        _id -= 12;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setText(*reinterpret_cast< QString*>(_v)); break;
        case 1: setTextFormat(*reinterpret_cast< Qt::TextFormat*>(_v)); break;
        case 2: setPixmap(*reinterpret_cast< QPixmap*>(_v)); break;
        case 3: setScaledContents(*reinterpret_cast< bool*>(_v)); break;
        case 4: setAlignment(*reinterpret_cast< Qt::Alignment*>(_v)); break;
        case 5: setWordWrap(*reinterpret_cast< bool*>(_v)); break;
        case 6: setMargin(*reinterpret_cast< int*>(_v)); break;
        case 7: setIndent(*reinterpret_cast< int*>(_v)); break;
        case 8: setOpenExternalLinks(*reinterpret_cast< bool*>(_v)); break;
        case 9: setTextInteractionFlags(*reinterpret_cast< Qt::TextInteractionFlags*>(_v)); break;
        }
        _id -= 12;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 12;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Esempio n. 17
0
void VoxOxToolTipLineEdit::keyPressEvent(QKeyEvent * event) {
	if (!_cleared) {
		clearLineEdit();
		repaintPrimaryColor();
	}

	if (event->key()==Qt::Key_Return || event->key()==Qt::Key_Enter) {//if key pressed was return or enter
		if(!QLineEdit::text().isEmpty()){
			updateMessageText(QLineEdit::text());
			QLineEdit::setText(_shortMessage);
			currentTextChanged(text());
		}
		
		QLineEdit::keyPressEvent(event);
		changeFocusToParent();//VOXOX CHANGE by Rolando - 2009.05.22 - method to send focus to another widget when mouse leaves the lineedit
	}
	else{//if key pressed was not return or enter key
		int cursorPositionValue =  cursorPosition();//VOXOX CHANGE by Rolando - 2009.06.02 - gets current Cursor Position
		bool isShortMessage = QLineEdit::text() == _shortMessage;//VOXOX CHANGE by Rolando - 2009.06.02 - we need to check if current text is equal to _shortMessage
		int intSelectedStart = -1;
		QString text;

		if(hasSelectedText()){//VOXOX CHANGE by Rolando - 2009.06.02 - if there is selected text
			text = selectedText();//VOXOX CHANGE by Rolando - 2009.06.02 - gets selected text
			intSelectedStart = selectionStart();//VOXOX CHANGE by Rolando - 2009.06.02 - gets position where selection starts		
		}

		QLineEdit::setText(_message);//VOXOX CHANGE by Rolando - 2009.06.02 - sets long message 
		if(intSelectedStart >= 0){//VOXOX CHANGE by Rolando - 2009.06.02 - if there is a text selected
			setSelection(intSelectedStart, text.length());//VOXOX CHANGE by Rolando - 2009.06.02 - as we set the long message in lineedit, we need to set the text was selected
		}
		else{
			//VOXOX CHANGE by Rolando - 2009.06.02 - if there is not a text selected
			
			if(isShortMessage){//VOXOX CHANGE by Rolando - 2009.06.02 - if we had currentText equal to _shortMessage
				//VOXOX CHANGE by Rolando - 2009.10.13 
				if(cursorPositionValue == _shortMessage.length()){//VOXOX CHANGE by Rolando - 2009.06.02 - if cursor position is the rightest pos allowed
					setCursorPosition(_message.length());//VOXOX CHANGE by Rolando - 2009.06.02 - we move the cursor to rightest position after we changed the current text by _message
				}
				else{
					//VOXOX CHANGE by Rolando - 2009.06.02 - if cursor position is not the rightest pos allowed
					setCursorPosition(cursorPositionValue);//VOXOX CHANGE by Rolando - 2009.06.02 - if cursor position is not the rightest pos allowed
				}
			}
			else{
				//VOXOX CHANGE by Rolando - 2009.06.02 - if we had not currentText equal to _shortMessage
				setCursorPosition(cursorPositionValue);//VOXOX CHANGE by Rolando - 2009.06.02 - we move the cursor to old position + 1
			}
			
		}		
		
		QLineEdit::keyPressEvent(event);//processes event - it should be processed before update _shortMessage and _message variables
		updateMessageText(QLineEdit::text());//VOXOX CHANGE by Rolando - 2009.06.02 - we update the short and long messages
		
	}

	keyPressedSignal(event->key());
	
}
Esempio n. 18
0
QString SimplePartWidget::quoteMe() const
{
    QString selection = selectedText();
    if (selection.isEmpty())
        return page()->mainFrame()->toPlainText();
    else
        return selection;
}
Esempio n. 19
0
QString BookViewPreview::GetDisplayedCharacters()
{
    page()->triggerAction(QWebPage::SelectAll);
    QString text = selectedText();
    page()->triggerAction(QWebPage::MoveToStartOfDocument);
    page()->triggerAction(QWebPage::SelectNextChar);
    return text;
}
Esempio n. 20
0
void lmcMessageLog::showContextMenu(const QPoint& pos) {
	copyAction->setEnabled(!selectedText().isEmpty());
	copyLinkAction->setEnabled(linkHovered);
	//	Copy Link is currently hidden since it performs the same action as regular Copy
	//copyLinkAction->setVisible(false);
	selectAllAction->setEnabled(!page()->mainFrame()->documentElement().findFirst("body").firstChild().isNull());
	contextMenu->exec(mapToGlobal(pos));
}
Esempio n. 21
0
void MarbleWebView::copySelectedText()
{
    const QString text = selectedText();
    if (!text.isEmpty()) {
        QClipboard *clipboard = QApplication::clipboard();
        clipboard->setText(text);
    }
}
Esempio n. 22
0
void EvaChatView::copy( )
{
    if(hasSelection()) {
        TQString text = selectedText();
        text.replace(TQChar(0xa0), ' ');
        TQApplication::clipboard()->setText( text, TQClipboard::Clipboard );
        TQApplication::clipboard()->setText( text, TQClipboard::Selection );
    }
}
Esempio n. 23
0
void Save::underline()
{
    if (!storage.isEmpty()) {
        if (url() == storage.last().webLink) {
            storage.last().underLines.append(selectedText());
            qDebug()<<"Added "<<selectedText()<<" to underlined passages in "<<storage.last().pageTitle;
        }
    }
    else {
        Entry entry;
        entry.pageTitle = title();
        entry.webPage = page();
        entry.webLink = url();
        entry.underLines.append(selectedText());
        storage.append(entry);
        qDebug()<<"Stored "<<storage.last().pageTitle<<" and size is now "<<storage.size();
    }
}
Esempio n. 24
0
void
HTMLView::copyText()
{
    QString text = selectedText();

    // Copy both to clipboard and X11-selection
    QApplication::clipboard()->setText( text, QClipboard::Clipboard );
    QApplication::clipboard()->setText( text, QClipboard::Selection );
}
Esempio n. 25
0
void LineEditWidget::copyToNote()
{
	const QString note(hasSelectedText() ? selectedText() : text());

	if (!note.isEmpty())
	{
		NotesManager::addNote(BookmarksModel::UrlBookmark, QUrl(), note);
	}
}
Esempio n. 26
0
void KTextCursor::insertHtml( const QString &text, const QMap<QString, QString>& imgs )
{
	if(!imgs.isEmpty())
	{
		for(QMap<QString,QString>::const_iterator iter = imgs.begin(); iter != imgs.end(); iter++)
		{
			QString key = iter.key();
			QString file = iter.value();
			if(moviePool()->insertMovie(file, file))
			{
				//修改属性为动画。
				document()->addResource(QTextDocument::ImageResource, QUrl(file), moviePool()->currentImage(file));
			}
			else
			{
				QImage image(file);
				if(!image.isNull())
				{
					document()->addResource(QTextDocument::ImageResource, QUrl(file), image);
				}
			}
		}
	}

	int istart = position();
	insertHtml(text);
	int inow = position();

	if(!imgs.isEmpty() && inow > istart)
	{
		setPosition(istart);
		movePosition(NextCharacter, KeepAnchor, inow-istart);
		QString txt = selectedText();
		int index = txt.indexOf(QChar::ObjectReplacementCharacter, 0);
		while(index >= 0)
		{
			/*修改字体类型。*/
			setPosition(istart+index);
			movePosition(NextCharacter, KeepAnchor, 1);
			QTextCharFormat fmt = charFormat();			
			QTextImageFormat imgFmt = fmt.toImageFormat();
			QString key = imgFmt.name();
			if(imgs.contains(key))
			{
				imgFmt.setProperty(KImageKey, key);
				imgFmt.setName(imgs.value(key));
				imgFmt.setProperty(KAnimationImage, true);
				setCharFormat(imgFmt);
			}
			int idx = index+1;
			index = txt.indexOf(QChar::ObjectReplacementCharacter, idx);
		}
	}

	setPosition(inow);
}
Esempio n. 27
0
/** Remove any existing auto completion suggestion */
void HintingLineEdit::clearSuggestion() {
  if (!hasSelectedText())
    return;

  // Carefully cut out the selected text
  QString line = text();
  line = line.left(selectionStart()) +
         line.mid(selectionStart() + selectedText().length());
  setText(line);
}
Esempio n. 28
0
void TextShow::startDrag()
{
    QDragObject *drag = new QTextDrag(selectedText(), viewport());
    if ( isReadOnly() ) {
        drag->dragCopy();
    } else {
        if ( drag->drag() && QDragObject::target() != this && QDragObject::target() != viewport() )
            removeSelectedText();
    }
}
Esempio n. 29
0
void MainWindow::on_actionItalic_triggered()
{
    const QString text = selectedText();

    if ( text.isEmpty() ) {
        return;
    }

    replaceSelectedTextBy( QString( "_%1_" ).arg( text ) );
}
Esempio n. 30
0
void KJotsEdit::openUrl()
{
    if (hasSelectedText())
    {
        KURL url(selectedText());
        if(url.isValid())
        {
            new KRun(url);
        }
    }
}