PDA

View Full Version : QTextCursor selection forward and backward problem only on linux



patrik08
29th May 2008, 10:40
I have subclass QGraphicsItem to write a Layer text editor... xhtml editor
Subversion:
http://fop-miniscribus.googlecode.com/svn/trunk/GraphicsViewEdit/

Now i have problem on Linux..
this MouseMoveEvent run perfect on Window XP qt4.4 and QTextCursor select correct text
forward and backward ...

Why on linux (ubuntu) qt4.4 it select the full line and can not select only one or two Character?



/* subversion /include/mounttextprivate.cpp */
/* StartSelectionMouse = mouse position (QTextCursor) from MousePressEvent */

void TextWriter::tmouseMoveEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos)
{
///////////qDebug() << "### mouseMoveEvent in ";
const int cursorPos = _d->documentLayout()->hitTest(pos,Qt::ExactHit) + 1;
const int cursornow = cursorPos - 1;
/* if drag move mime make and return !!! */
if (C_cursor.hasSelection() && DragFill) {
cursortime = false;
repaintCursor();
return;
}
const int cursorPosFozze = _d->documentLayout()->hitTest(pos,Qt::FuzzyHit);
const int stopat = qMax(StartSelectionMouse,cursorPos);
const int startat = qMin(StartSelectionMouse,cursorPos);
////////////qDebug() << "### start/stop cell position " << StartSelectionMouse << cursorPos << cursorPosFozze;
if (StartSelectionMouse != -1 && cursorPos > 0 && !C_cursor.currentTable()) {
if (StartSelectionMouse != cursorPos) {
/////////setBlinkingCursorEnabled(false);
/* selection tracer */
cursorIsFocusIndicator = true;
if (stopat == cursorPos) {
/* cursor selection mode start>>>>>>>>>>>>>>>>>stop */
C_cursor.setPosition(StartSelectionMouse);
for (int i = StartSelectionMouse; i < cursorPos; ++i) {
C_cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor);
}
cursor_position = stopat;
} else {
/* cursor selection mode stop<<<<<<<<start */
C_cursor.setPosition(stopat);
const int diffs = stopat - cursornow;
/////////qDebug() << "### diffs " << diffs << "," << cursornow << "," << stopat;
for (int i = 0; i < diffs; ++i) {
C_cursor.movePosition(QTextCursor::PreviousCharact er, QTextCursor::KeepAnchor);
}
return;
}
repaintCursor();
}
}

if ( C_cursor.currentTable() ) {
QTextTable *table = C_cursor.currentTable();
QTextTableCell firstcell = OnPosition(StartSelectionMouse);
QTextTableCell lastcell = OnPosition(cursorPosFozze);
if ( firstcell.isValid() && lastcell.isValid() ) {
int fcellrow = firstcell.row();
int fcellcool = firstcell.column();
int numRows = qBound(1,lastcell.row() - fcellrow,table->rows());
int numColumns = qBound(1,lastcell.column() - fcellcool,table->columns());
///////qDebug() << "### nnrow / nncool " << numRows << numColumns;
C_cursor.selectedTableCells(&fcellrow,&numRows,&fcellcool,&numColumns);
C_cursor.setPosition(firstcell.firstPosition());
C_cursor.setPosition(lastcell.lastPosition(), QTextCursor::KeepAnchor);
cursor_position = stopat;
setBlinkingCursorEnabled(false);
QRectF tablerect = _d->documentLayout()->frameBoundingRect(table);
emit updateRequest(tablerect);
return;
}
}
}

patrik08
1st June 2008, 11:04
Is this a problem from qt version?
i write on mac on qt4.4 & linux qt4.3 .. are this possible?