Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/text/qtextcontrol.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    9292
    9393#ifndef QT_NO_CONTEXTMENU
    94 #if defined(Q_WS_WIN)
     94#if defined(Q_WS_WIN) || defined(Q_WS_X11)
    9595extern bool qt_use_rtl_extensions;
    9696#endif
     
    405405    setContent(format, text, document);
    406406
    407     QWidget *parentWidget = qobject_cast<QWidget*>(parent);
    408     if (parentWidget) {
    409         QTextOption opt = doc->defaultTextOption();
    410         opt.setTextDirection(parentWidget->layoutDirection());
    411         doc->setDefaultTextOption(opt);
    412     }
    413407    doc->setUndoRedoEnabled(interactionFlags & Qt::TextEditable);
    414408    q->setCursorWidth(-1);
     
    442436
    443437        // convenience signal forwards
    444         QObject::connect(doc, SIGNAL(contentsChanged()), q, SIGNAL(textChanged()));
    445438        QObject::connect(doc, SIGNAL(undoAvailable(bool)), q, SIGNAL(undoAvailable(bool)));
    446439        QObject::connect(doc, SIGNAL(redoAvailable(bool)), q, SIGNAL(redoAvailable(bool)));
     
    453446        doc->setUndoRedoEnabled(false);
    454447
     448    //Saving the index save some time.
     449    static int contentsChangedIndex = QTextDocument::staticMetaObject.indexOfSignal("contentsChanged()");
     450    static int textChangedIndex = QTextControl::staticMetaObject.indexOfSignal("textChanged()");
    455451    // avoid multiple textChanged() signals being emitted
    456     QObject::disconnect(doc, SIGNAL(contentsChanged()), q, SIGNAL(textChanged()));
     452    QMetaObject::disconnect(doc, contentsChangedIndex, q, textChangedIndex);
    457453
    458454    if (!text.isEmpty()) {
     
    489485    cursor.setCharFormat(charFormatForInsertion);
    490486
    491     QObject::connect(doc, SIGNAL(contentsChanged()), q, SIGNAL(textChanged()));
     487    QMetaObject::connect(doc, contentsChangedIndex, q, textChangedIndex);
    492488    emit q->textChanged();
    493489    if (!document)
     
    746742    Q_D(QTextControl);
    747743    d->repaintSelection();
     744    const int oldCursorPos = d->cursor.position();
    748745    d->doc->undo(&d->cursor);
     746    if (d->cursor.position() != oldCursorPos)
     747        emit cursorPositionChanged();
     748    emit microFocusChanged();
    749749    ensureCursorVisible();
    750750}
     
    754754    Q_D(QTextControl);
    755755    d->repaintSelection();
     756    const int oldCursorPos = d->cursor.position();
    756757    d->doc->redo(&d->cursor);
     758        if (d->cursor.position() != oldCursorPos)
     759        emit cursorPositionChanged();
     760    emit microFocusChanged();
    757761    ensureCursorVisible();
    758762}
     
    847851}
    848852
    849 void QTextControl::paste()
    850 {
    851     const QMimeData *md = QApplication::clipboard()->mimeData();
     853void QTextControl::paste(QClipboard::Mode mode)
     854{
     855    const QMimeData *md = QApplication::clipboard()->mimeData(mode);
    852856    if (md)
    853857        insertFromMimeData(md);
     
    884888{
    885889    Q_D(QTextControl);
    886     if (d->interactionFlags & Qt::NoTextInteraction)
    887         return;
     890    if (d->interactionFlags == Qt::NoTextInteraction) {
     891        e->ignore();
     892        return;
     893    }
    888894
    889895    d->contextWidget = contextWidget;
     
    10901096            }
    10911097            break;
    1092         case QEvent::LayoutDirectionChange: {
    1093             if (contextWidget) {
    1094                 QTextOption opt = document()->defaultTextOption();
    1095                 opt.setTextDirection(contextWidget->layoutDirection());
    1096                 document()->setDefaultTextOption(opt);
    1097             }
    1098         }
    1099             // FALL THROUGH
    11001098        default:
    11011099            break;
     
    12301228    }
    12311229    else if (e == QKeySequence::Paste) {
    1232            q->paste();
     1230        QClipboard::Mode mode = QClipboard::Clipboard;
     1231#ifdef Q_WS_X11
     1232        if (e->modifiers() == (Qt::CTRL | Qt::SHIFT) && e->key() == Qt::Key_Insert)
     1233            mode = QClipboard::Selection;
     1234#endif
     1235        q->paste(mode);
    12331236    }
    12341237#endif
     
    17651768    if (!menu)
    17661769        return;
    1767     menu->exec(screenPos);
    1768     delete menu;
     1770    menu->setAttribute(Qt::WA_DeleteOnClose);
     1771    menu->popup(screenPos);
    17691772#endif
    17701773}
     
    20762079#endif
    20772080
    2078 #if defined(Q_WS_WIN)
     2081#if defined(Q_WS_WIN) || defined(Q_WS_X11)
    20792082    if ((d->interactionFlags & Qt::TextEditable) && qt_use_rtl_extensions) {
    20802083#else
Note: See TracChangeset for help on using the changeset viewer.