void Editor::uncommentSelection() { int paragraphStart; int paragraphEnd; int indexStart; int indexEnd; getSelection(¶graphStart, &indexStart, ¶graphEnd, &indexEnd); if (paragraphStart < 0) { getCursorPosition(¶graphStart, &indexStart); paragraphEnd = paragraphStart; } if (paragraphStart >= 0 && paragraphEnd >= 0) { for (int i=paragraphStart; i<=paragraphEnd; ++i) { QString str = text(i); int whitespace = 0; while (str.startsWith("/") || (str.length() > 0 && str.at(0).isSpace())) { if (str.length() > 0 && str.at(0).isSpace()) ++whitespace; str.remove(0, 1); } if (whitespace > 0) str.prepend(QString().fill(QChar(' '), whitespace)); insertParagraph(str, i); removeParagraph(i + 1); } repaintChanged(); setModified(TRUE); } }
void MsgViewBase::sync(unsigned n) { if (!m_selectStr.isEmpty()){ bool bStart = false; for (; n < (unsigned)paragraphs(); n++){ QString s = text(n); if (s.find(MSG_ANCHOR) >= 0){ bStart = true; continue; } if (bStart) break; } if (n < (unsigned)paragraphs()){ int savePara; int saveIndex; getCursorPosition(&savePara, &saveIndex); int para = n; int index = 0; while (find(m_selectStr, false, false, true, ¶, &index)){ setSelection(para, index, para, index + m_selectStr.length(), ++m_nSelection); setSelectionAttributes(m_nSelection, colorGroup().highlight(), true); index += m_selectStr.length(); } setCursorPosition(savePara, saveIndex); repaintChanged(); } } TextShow::sync(); }
void Editor::cursorPosChanged( QTextCursor *c ) { if ( parenMatcher->match( c ) ) repaintChanged(); if ( hasError ) { emit clearErrorMarker(); hasError = FALSE; } }
void QEditor::selectCode(int line0, int col0, int line1, int col1, TypeSel sel_type) { getDocument()->removeSelection(sel_type); setCursorPosition(line0, col0); Q3TextCursor c1 = *textCursor(); setCursorPosition(line1, col1); Q3TextCursor c2 = *textCursor(); getDocument()->setSelectionStart( sel_type, c1 ); getDocument()->setSelectionEnd( sel_type, c2 ); repaintChanged(); }
void TableBody::mouseMoveEvent(QMouseEvent *e) { if (numRows() == 0) return; // *** prevent out of range // DRAFT CODE ! // Signal : find row, col(field name) emit flyOnEvent Signal int row = findRow(e->y()); int col = findCol(e->x()); if (row < 0 or col < 0) { emit htable->outOfCell(); // if... return; } emit htable->flyOnCell(row, col); if (e->buttons() == Qt::NoButton) return; if (e->buttons() == Qt::RightButton) return; if (e->buttons() & Qt::ControlModifier || gadget_click) return; if (row != prev_drag_row) { if (row == -1) { if (!autoscrolling) { // dragging outside table, cause scrolling scrolldir = (e->y() < 0) ? UP : DOWN; // killTimers(); // startTimer(scroll_delay); autoscrolling = true; } } else { ////killTimers(); autoscrolling = false; dragSelectTo(row); } } // repaintRow(row); // view->update(); repaintChanged(); }
void Editor::commentSelection() { int paragraphStart; int paragraphEnd; int indexStart; int indexEnd; getSelection(¶graphStart, &indexStart, ¶graphEnd, &indexEnd); if (paragraphStart < 0) { getCursorPosition(¶graphStart, &indexStart); paragraphEnd = paragraphStart; } if (paragraphStart >= 0 && paragraphEnd >= 0) { for (int i=paragraphStart; i<=paragraphEnd; ++i) insertAt(QString::fromLatin1("//"), i, 0); repaintChanged(); setModified(TRUE); } }
void QEditor::removeSelection(TypeSel sel_type) { getDocument()->removeSelection((int) sel_type); repaintChanged(); }
void QEditor::doMatch( Q3TextCursor* c ) { if( parenMatcher->match(c) ){ repaintChanged(); } }
void TableBody::mousePressEvent(QMouseEvent *e) { if (numRows() == 0) return; // *** prevent out of range // printf("mousePressEvent() 1\n"); static int last_row = -1; int row = findRow(e->y()); if (row == -1) { // printf("mousePressEvent\n"); htable->clearAllSelections(); if (e->y() >= 0) row = numRows(); // if SHIFT+click outside ~ first_drag_row = prev_drag_row = row; return; } if (!(htable->options & HTBL_ROW_SELECTION)) return; if (e->button() == Qt::LeftButton) { // folding if (htable->treemode && htable->folding && e->x() < htable->gadget_space + htable->treestep * htable->rowDepth(row) && htable->folded(row) != HeadedTable::Leaf) { emit htable->foldSubTree(row); gadget_click = true; last_row = row; // clearCache(); // dont use cache return; } if (e->modifiers() & Qt::ShiftModifier) { if (row < last_row) for (int i = row; i < last_row; i++) htable->setSelected(i, true); // virtual else for (int i = last_row; i <= row; i++) htable->setSelected(i, true); // virtual } else if (e->modifiers() & Qt::ControlModifier) { htable->setSelected(row, !htable->isSelected(row)); } else htable->selectOnlyOne(row); first_drag_row = prev_drag_row = row; emit htable->selectionChanged(); } else if (e->button() == Qt::RightButton) { if (!htable->isSelected(row)) htable->selectOnlyOne(row); emit htable->selectionChanged(); // better? emit htable->rightClicked(e->globalPos()); } last_row = row; // htable->repaint_changed(); repaintChanged(); // repaint // view->update(); // fast but use more CPU }